mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
Implement some BlockData stuff on Fabric, make stuff less jank
This commit is contained in:
@@ -1,4 +1,11 @@
|
|||||||
package com.dfsek.terra.api.generic.world.block.data;
|
package com.dfsek.terra.api.generic.world.block.data;
|
||||||
|
|
||||||
public interface Slab extends Bisected, Waterlogged {
|
public interface Slab extends Waterlogged {
|
||||||
|
Type getType();
|
||||||
|
|
||||||
|
void setType(Type type);
|
||||||
|
|
||||||
|
enum Type {
|
||||||
|
TOP, BOTTOM, DOUBLE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,21 @@ import com.dfsek.terra.api.generic.generator.ChunkGenerator;
|
|||||||
import com.dfsek.terra.api.generic.world.BiomeGrid;
|
import com.dfsek.terra.api.generic.world.BiomeGrid;
|
||||||
import com.dfsek.terra.api.generic.world.World;
|
import com.dfsek.terra.api.generic.world.World;
|
||||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Bisected;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Slab;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Stairs;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Waterlogged;
|
||||||
import com.dfsek.terra.api.generic.world.vector.Vector3;
|
import com.dfsek.terra.api.generic.world.vector.Vector3;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
|
import com.dfsek.terra.biome.palette.SinglePalette;
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||||
import com.dfsek.terra.util.PaletteUtil;
|
import com.dfsek.terra.util.PaletteUtil;
|
||||||
import com.dfsek.terra.util.SlabUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class TerraChunkGenerator implements com.dfsek.terra.api.generic.generator.TerraChunkGenerator {
|
public class TerraChunkGenerator implements com.dfsek.terra.api.generic.generator.TerraChunkGenerator {
|
||||||
@@ -26,11 +33,15 @@ public class TerraChunkGenerator implements com.dfsek.terra.api.generic.generato
|
|||||||
|
|
||||||
private final ConfigPack configPack;
|
private final ConfigPack configPack;
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
|
private final MaterialData water;
|
||||||
|
private final SinglePalette<BlockData> blank;
|
||||||
|
|
||||||
|
|
||||||
public TerraChunkGenerator(ConfigPack c, TerraPlugin main) {
|
public TerraChunkGenerator(ConfigPack c, TerraPlugin main) {
|
||||||
this.configPack = c;
|
this.configPack = c;
|
||||||
this.main = main;
|
this.main = main;
|
||||||
|
water = main.getWorldHandle().createMaterialData("minecraft:water");
|
||||||
|
blank = new SinglePalette<>(main.getWorldHandle().createBlockData("minecraft:air"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,20 +121,20 @@ public class TerraChunkGenerator implements com.dfsek.terra.api.generic.generato
|
|||||||
data = PaletteUtil.getPalette(x, y, z, c, sampler).get(paletteLevel, cx, cz);
|
data = PaletteUtil.getPalette(x, y, z, c, sampler).get(paletteLevel, cx, cz);
|
||||||
chunk.setBlock(x, y, z, data);
|
chunk.setBlock(x, y, z, data);
|
||||||
if(paletteLevel == 0 && c.doSlabs() && y < 255) {
|
if(paletteLevel == 0 && c.doSlabs() && y < 255) {
|
||||||
SlabUtil.prepareBlockPartFloor(data, chunk.getBlockData(x, y + 1, z), chunk, new Vector3(x, y + 1, z), c.getSlabPalettes(),
|
prepareBlockPartFloor(data, chunk.getBlockData(x, y + 1, z), chunk, new Vector3(x, y + 1, z), c.getSlabPalettes(),
|
||||||
c.getStairPalettes(), c.getSlabThreshold(), sampler);
|
c.getStairPalettes(), c.getSlabThreshold(), sampler);
|
||||||
}
|
}
|
||||||
paletteLevel++;
|
paletteLevel++;
|
||||||
} else if(y <= sea) {
|
} else if(y <= sea) {
|
||||||
chunk.setBlock(x, y, z, seaPalette.get(sea - y, x + xOrig, z + zOrig));
|
chunk.setBlock(x, y, z, seaPalette.get(sea - y, x + xOrig, z + zOrig));
|
||||||
if(justSet && c.doSlabs()) {
|
if(justSet && c.doSlabs()) {
|
||||||
SlabUtil.prepareBlockPartCeiling(data, chunk.getBlockData(x, y, z), chunk, new Vector3(x, y, z), c.getSlabPalettes(), c.getStairPalettes(), c.getSlabThreshold(), sampler);
|
prepareBlockPartCeiling(data, chunk.getBlockData(x, y, z), chunk, new Vector3(x, y, z), c.getSlabPalettes(), c.getStairPalettes(), c.getSlabThreshold(), sampler);
|
||||||
}
|
}
|
||||||
justSet = false;
|
justSet = false;
|
||||||
paletteLevel = 0;
|
paletteLevel = 0;
|
||||||
} else {
|
} else {
|
||||||
if(justSet && c.doSlabs()) {
|
if(justSet && c.doSlabs()) {
|
||||||
SlabUtil.prepareBlockPartCeiling(data, chunk.getBlockData(x, y, z), chunk, new Vector3(x, y, z), c.getSlabPalettes(), c.getStairPalettes(), c.getSlabThreshold(), sampler);
|
prepareBlockPartCeiling(data, chunk.getBlockData(x, y, z), chunk, new Vector3(x, y, z), c.getSlabPalettes(), c.getStairPalettes(), c.getSlabThreshold(), sampler);
|
||||||
}
|
}
|
||||||
justSet = false;
|
justSet = false;
|
||||||
paletteLevel = 0;
|
paletteLevel = 0;
|
||||||
@@ -137,6 +148,67 @@ public class TerraChunkGenerator implements com.dfsek.terra.api.generic.generato
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void prepareBlockPartFloor(BlockData down, BlockData orig, ChunkGenerator.ChunkData chunk, Vector3 block, Map<MaterialData, Palette<BlockData>> slabs,
|
||||||
|
Map<MaterialData, Palette<BlockData>> stairs, double thresh, Sampler sampler) {
|
||||||
|
if(sampler.sample(block.getBlockX(), block.getBlockY() - 0.4, block.getBlockZ()) > thresh) {
|
||||||
|
if(stairs != null) {
|
||||||
|
Palette<BlockData> stairPalette = stairs.get(down.getMaterial());
|
||||||
|
if(stairPalette != null) {
|
||||||
|
BlockData stair = stairPalette.get(0, block.getBlockX(), block.getBlockZ()).clone();
|
||||||
|
Stairs stairNew = (Stairs) stair;
|
||||||
|
if(placeStair(orig, chunk, block, thresh, sampler, stairNew)) return; // Successfully placed part.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BlockData slab = slabs.getOrDefault(down.getMaterial(), blank).get(0, block.getBlockX(), block.getBlockZ());
|
||||||
|
if(slab instanceof Waterlogged) {
|
||||||
|
((Waterlogged) slab).setWaterlogged(orig.matches(water));
|
||||||
|
} else if(orig.matches(water)) return;
|
||||||
|
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), slab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepareBlockPartCeiling(BlockData up, BlockData orig, ChunkGenerator.ChunkData chunk, Vector3 block, Map<MaterialData, Palette<BlockData>> slabs,
|
||||||
|
Map<MaterialData, Palette<BlockData>> stairs, double thresh, Sampler sampler) {
|
||||||
|
if(sampler.sample(block.getBlockX(), block.getBlockY() + 0.4, block.getBlockZ()) > thresh) {
|
||||||
|
if(stairs != null) {
|
||||||
|
Palette<BlockData> stairPalette = stairs.get(up.getMaterial());
|
||||||
|
if(stairPalette != null) {
|
||||||
|
BlockData stair = stairPalette.get(0, block.getBlockX(), block.getBlockZ()).clone();
|
||||||
|
Stairs stairNew = (Stairs) stair.clone();
|
||||||
|
stairNew.setHalf(Bisected.Half.TOP);
|
||||||
|
if(placeStair(orig, chunk, block, thresh, sampler, stairNew)) return; // Successfully placed part.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BlockData slab = slabs.getOrDefault(up.getMaterial(), blank).get(0, block.getBlockX(), block.getBlockZ()).clone();
|
||||||
|
if(slab instanceof Bisected) ((Bisected) slab).setHalf(Bisected.Half.TOP);
|
||||||
|
if(slab instanceof Slab) ((Slab) slab).setType(Slab.Type.TOP);
|
||||||
|
if(slab instanceof Waterlogged) {
|
||||||
|
((Waterlogged) slab).setWaterlogged(orig.matches(water));
|
||||||
|
} else if(orig.matches(water)) return; // Only replace water if waterlogged.
|
||||||
|
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), slab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean placeStair(BlockData orig, ChunkGenerator.ChunkData chunk, Vector3 block, double thresh, Sampler sampler, Stairs stairNew) {
|
||||||
|
|
||||||
|
if(sampler.sample(block.getBlockX() - 0.55, block.getBlockY(), block.getBlockZ()) > thresh) {
|
||||||
|
|
||||||
|
stairNew.setFacing(BlockFace.WEST);
|
||||||
|
} else if(sampler.sample(block.getBlockX(), block.getBlockY(), block.getBlockZ() - 0.55) > thresh) {
|
||||||
|
stairNew.setFacing(BlockFace.NORTH);
|
||||||
|
} else if(sampler.sample(block.getBlockX(), block.getBlockY(), block.getBlockZ() + 0.55) > thresh) {
|
||||||
|
stairNew.setFacing(BlockFace.SOUTH);
|
||||||
|
} else if(sampler.sample(block.getBlockX() + 0.55, block.getBlockY(), block.getBlockZ()) > thresh) {
|
||||||
|
stairNew.setFacing(BlockFace.EAST);
|
||||||
|
} else stairNew = null;
|
||||||
|
if(stairNew != null) {
|
||||||
|
if(orig.matches(water)) stairNew.setWaterlogged(orig.matches(water));
|
||||||
|
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), stairNew);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateBiomes(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biome) {
|
public void generateBiomes(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biome) {
|
||||||
int xOrig = (chunkX << 4);
|
int xOrig = (chunkX << 4);
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
package com.dfsek.terra.util;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.gaea.world.palette.Palette;
|
|
||||||
import com.dfsek.terra.api.generic.generator.ChunkGenerator;
|
|
||||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
|
||||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
|
||||||
import com.dfsek.terra.api.generic.world.block.data.Stairs;
|
|
||||||
import com.dfsek.terra.api.generic.world.vector.Vector3;
|
|
||||||
import com.dfsek.terra.generation.Sampler;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public final class SlabUtil {
|
|
||||||
public static void prepareBlockPartFloor(BlockData down, BlockData orig, ChunkGenerator.ChunkData chunk, Vector3 block, Map<MaterialData, Palette<BlockData>> slabs,
|
|
||||||
Map<MaterialData, Palette<BlockData>> stairs, double thresh, Sampler sampler) {
|
|
||||||
/*
|
|
||||||
if(sampler.sample(block.getBlockX(), block.getBlockY() - 0.4, block.getBlockZ()) > thresh) {
|
|
||||||
if(stairs != null) {
|
|
||||||
Palette<BlockData> stairPalette = stairs.get(down.getMaterial());
|
|
||||||
if(stairPalette != null) {
|
|
||||||
BlockData stair = stairPalette.get(0, block.getBlockX(), block.getBlockZ()).clone();
|
|
||||||
Stairs stairNew = (Stairs) stair;
|
|
||||||
if(placeStair(orig, chunk, block, thresh, sampler, stairNew)) return; // Successfully placed part.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BlockData slab = slabs.getOrDefault(down.getMaterial(), PaletteUtil.BLANK_PALETTE).get(0, block.getBlockX(), block.getBlockZ());
|
|
||||||
if(slab instanceof Waterlogged) {
|
|
||||||
((Waterlogged) slab).setWaterlogged(orig.matches(PaletteUtil.WATER));
|
|
||||||
} else if(orig.matches(PaletteUtil.WATER)) return;
|
|
||||||
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), slab);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void prepareBlockPartCeiling(BlockData up, BlockData orig, ChunkGenerator.ChunkData chunk, Vector3 block, Map<MaterialData, Palette<BlockData>> slabs,
|
|
||||||
Map<MaterialData, Palette<BlockData>> stairs, double thresh, Sampler sampler) {
|
|
||||||
/*
|
|
||||||
if(sampler.sample(block.getBlockX(), block.getBlockY() + 0.4, block.getBlockZ()) > thresh) {
|
|
||||||
if(stairs != null) {
|
|
||||||
Palette<BlockData> stairPalette = stairs.get(up.getMaterial());
|
|
||||||
if(stairPalette != null) {
|
|
||||||
BlockData stair = stairPalette.get(0, block.getBlockX(), block.getBlockZ()).clone();
|
|
||||||
Stairs stairNew = (Stairs) stair.clone();
|
|
||||||
stairNew.setHalf(Bisected.Half.TOP);
|
|
||||||
if(placeStair(orig, chunk, block, thresh, sampler, stairNew)) return; // Successfully placed part.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BlockData slab = slabs.getOrDefault(up.getMaterial(), PaletteUtil.BLANK_PALETTE).get(0, block.getBlockX(), block.getBlockZ()).clone();
|
|
||||||
if(slab instanceof Bisected) ((Bisected) slab).setHalf(Bisected.Half.TOP);
|
|
||||||
if(slab instanceof Slab) ((Slab) slab).setType(Slab.Type.TOP);
|
|
||||||
if(slab instanceof Waterlogged) {
|
|
||||||
((Waterlogged) slab).setWaterlogged(orig.matches(PaletteUtil.WATER));
|
|
||||||
} else if(orig.matches(PaletteUtil.WATER)) return; // Only replace water if waterlogged.
|
|
||||||
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), slab);
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean placeStair(BlockData orig, ChunkGenerator.ChunkData chunk, Vector3 block, double thresh, Sampler sampler, Stairs stairNew) {
|
|
||||||
/*
|
|
||||||
if(sampler.sample(block.getBlockX() - 0.55, block.getBlockY(), block.getBlockZ()) > thresh) {
|
|
||||||
|
|
||||||
stairNew.setFacing(BlockFace.WEST);
|
|
||||||
} else if(sampler.sample(block.getBlockX(), block.getBlockY(), block.getBlockZ() - 0.55) > thresh) {
|
|
||||||
stairNew.setFacing(BlockFace.NORTH);
|
|
||||||
} else if(sampler.sample(block.getBlockX(), block.getBlockY(), block.getBlockZ() + 0.55) > thresh) {
|
|
||||||
stairNew.setFacing(BlockFace.SOUTH);
|
|
||||||
} else if(sampler.sample(block.getBlockX() + 0.55, block.getBlockY(), block.getBlockZ()) > thresh) {
|
|
||||||
stairNew.setFacing(BlockFace.EAST);
|
|
||||||
} else stairNew = null;
|
|
||||||
if(stairNew != null) {
|
|
||||||
if(orig.matches(PaletteUtil.WATER)) stairNew.setWaterlogged(true);
|
|
||||||
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), stairNew);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+4
-2
@@ -4,7 +4,7 @@ import com.dfsek.terra.api.generic.world.block.BlockData;
|
|||||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||||
|
|
||||||
public class BukkitBlockData implements BlockData {
|
public class BukkitBlockData implements BlockData {
|
||||||
private final org.bukkit.block.data.BlockData delegate;
|
private org.bukkit.block.data.BlockData delegate;
|
||||||
|
|
||||||
public BukkitBlockData(org.bukkit.block.data.BlockData delegate) {
|
public BukkitBlockData(org.bukkit.block.data.BlockData delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
@@ -29,7 +29,9 @@ public class BukkitBlockData implements BlockData {
|
|||||||
@Override
|
@Override
|
||||||
public BukkitBlockData clone() {
|
public BukkitBlockData clone() {
|
||||||
try {
|
try {
|
||||||
return (BukkitBlockData) super.clone();
|
BukkitBlockData n = (BukkitBlockData) super.clone();
|
||||||
|
n.delegate = delegate.clone();
|
||||||
|
return n;
|
||||||
} catch(CloneNotSupportedException e) {
|
} catch(CloneNotSupportedException e) {
|
||||||
throw new Error(e);
|
throw new Error(e);
|
||||||
}
|
}
|
||||||
|
|||||||
+14
@@ -3,6 +3,7 @@ package com.dfsek.terra.bukkit.world.block.data;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
||||||
import com.dfsek.terra.api.generic.world.block.data.Bisected;
|
import com.dfsek.terra.api.generic.world.block.data.Bisected;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Slab;
|
||||||
import com.dfsek.terra.api.generic.world.block.data.Stairs;
|
import com.dfsek.terra.api.generic.world.block.data.Stairs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,4 +83,17 @@ public final class BukkitEnumAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Slab.Type fromBukkitSlabType(org.bukkit.block.data.type.Slab.Type type) {
|
||||||
|
switch(type) {
|
||||||
|
case BOTTOM:
|
||||||
|
return Slab.Type.BOTTOM;
|
||||||
|
case TOP:
|
||||||
|
return Slab.Type.TOP;
|
||||||
|
case DOUBLE:
|
||||||
|
return Slab.Type.DOUBLE;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-6
@@ -8,30 +8,28 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BukkitMultipleFacing extends BukkitBlockData implements MultipleFacing {
|
public class BukkitMultipleFacing extends BukkitBlockData implements MultipleFacing {
|
||||||
private final org.bukkit.block.data.MultipleFacing delegate;
|
|
||||||
|
|
||||||
public BukkitMultipleFacing(org.bukkit.block.data.MultipleFacing delegate) {
|
public BukkitMultipleFacing(org.bukkit.block.data.MultipleFacing delegate) {
|
||||||
super(delegate);
|
super(delegate);
|
||||||
this.delegate = delegate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<BlockFace> getFaces() {
|
public Set<BlockFace> getFaces() {
|
||||||
return delegate.getFaces().stream().map(BukkitEnumAdapter::fromBukkitBlockFace).collect(Collectors.toSet());
|
return ((org.bukkit.block.data.MultipleFacing) super.getHandle()).getFaces().stream().map(BukkitEnumAdapter::fromBukkitBlockFace).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFace(BlockFace face, boolean facing) {
|
public void setFace(BlockFace face, boolean facing) {
|
||||||
delegate.setFace(TerraEnumAdapter.fromTerraBlockFace(face), facing);
|
((org.bukkit.block.data.MultipleFacing) super.getHandle()).setFace(TerraEnumAdapter.fromTerraBlockFace(face), facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<BlockFace> getAllowedFaces() {
|
public Set<BlockFace> getAllowedFaces() {
|
||||||
return delegate.getAllowedFaces().stream().map(BukkitEnumAdapter::fromBukkitBlockFace).collect(Collectors.toSet());
|
return ((org.bukkit.block.data.MultipleFacing) super.getHandle()).getAllowedFaces().stream().map(BukkitEnumAdapter::fromBukkitBlockFace).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasFace(BlockFace f) {
|
public boolean hasFace(BlockFace f) {
|
||||||
return delegate.hasFace(TerraEnumAdapter.fromTerraBlockFace(f));
|
return ((org.bukkit.block.data.MultipleFacing) super.getHandle()).hasFace(TerraEnumAdapter.fromTerraBlockFace(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.dfsek.terra.bukkit.world.block.data;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Slab;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Waterlogged;
|
||||||
|
import com.dfsek.terra.bukkit.world.block.BukkitBlockData;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
public class BukkitSlab extends BukkitBlockData implements Slab {
|
||||||
|
public BukkitSlab(BlockData delegate) {
|
||||||
|
super(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWaterlogged() {
|
||||||
|
return ((Waterlogged) getHandle()).isWaterlogged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWaterlogged(boolean waterlogged) {
|
||||||
|
((Waterlogged) getHandle()).setWaterlogged(waterlogged);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getType() {
|
||||||
|
return BukkitEnumAdapter.fromBukkitSlabType(((org.bukkit.block.data.type.Slab) getHandle()).getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setType(Type type) {
|
||||||
|
((org.bukkit.block.data.type.Slab) getHandle()).setType(TerraEnumAdapter.fromTerraSlabType(type));
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-10
@@ -5,50 +5,48 @@ import com.dfsek.terra.api.generic.world.block.data.Stairs;
|
|||||||
import com.dfsek.terra.bukkit.world.block.BukkitBlockData;
|
import com.dfsek.terra.bukkit.world.block.BukkitBlockData;
|
||||||
|
|
||||||
public class BukkitStairs extends BukkitBlockData implements Stairs {
|
public class BukkitStairs extends BukkitBlockData implements Stairs {
|
||||||
private final org.bukkit.block.data.type.Stairs stairs;
|
|
||||||
|
|
||||||
public BukkitStairs(org.bukkit.block.data.type.Stairs delegate) {
|
public BukkitStairs(org.bukkit.block.data.type.Stairs delegate) {
|
||||||
super(delegate);
|
super(delegate);
|
||||||
this.stairs = delegate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Shape getShape() {
|
public Shape getShape() {
|
||||||
return BukkitEnumAdapter.fromBukkitStair(stairs.getShape());
|
return BukkitEnumAdapter.fromBukkitStair(((org.bukkit.block.data.type.Stairs) super.getHandle()).getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setShape(Shape shape) {
|
public void setShape(Shape shape) {
|
||||||
stairs.setShape(TerraEnumAdapter.fromTerraStair(shape));
|
((org.bukkit.block.data.type.Stairs) super.getHandle()).setShape(TerraEnumAdapter.fromTerraStair(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Half getHalf() {
|
public Half getHalf() {
|
||||||
return BukkitEnumAdapter.fromBukkitHalf(stairs.getHalf());
|
return BukkitEnumAdapter.fromBukkitHalf(((org.bukkit.block.data.type.Stairs) super.getHandle()).getHalf());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHalf(Half half) {
|
public void setHalf(Half half) {
|
||||||
stairs.setHalf(TerraEnumAdapter.fromTerraHalf(half));
|
((org.bukkit.block.data.type.Stairs) super.getHandle()).setHalf(TerraEnumAdapter.fromTerraHalf(half));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockFace getFacing() {
|
public BlockFace getFacing() {
|
||||||
return BukkitEnumAdapter.fromBukkitBlockFace(stairs.getFacing());
|
return BukkitEnumAdapter.fromBukkitBlockFace(((org.bukkit.block.data.type.Stairs) super.getHandle()).getFacing());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFacing(BlockFace facing) {
|
public void setFacing(BlockFace facing) {
|
||||||
stairs.setFacing(TerraEnumAdapter.fromTerraBlockFace(facing));
|
((org.bukkit.block.data.type.Stairs) super.getHandle()).setFacing(TerraEnumAdapter.fromTerraBlockFace(facing));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWaterlogged() {
|
public boolean isWaterlogged() {
|
||||||
return stairs.isWaterlogged();
|
return ((org.bukkit.block.data.type.Stairs) super.getHandle()).isWaterlogged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWaterlogged(boolean waterlogged) {
|
public void setWaterlogged(boolean waterlogged) {
|
||||||
stairs.setWaterlogged(waterlogged);
|
((org.bukkit.block.data.type.Stairs) super.getHandle()).setWaterlogged(waterlogged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -4,19 +4,17 @@ import com.dfsek.terra.api.generic.world.block.data.Waterlogged;
|
|||||||
import com.dfsek.terra.bukkit.world.block.BukkitBlockData;
|
import com.dfsek.terra.bukkit.world.block.BukkitBlockData;
|
||||||
|
|
||||||
public class BukkitWaterlogged extends BukkitBlockData implements Waterlogged {
|
public class BukkitWaterlogged extends BukkitBlockData implements Waterlogged {
|
||||||
private boolean waterlogged;
|
|
||||||
|
|
||||||
public BukkitWaterlogged(org.bukkit.block.data.Waterlogged delegate) {
|
public BukkitWaterlogged(org.bukkit.block.data.Waterlogged delegate) {
|
||||||
super(delegate);
|
super(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWaterlogged() {
|
public boolean isWaterlogged() {
|
||||||
return waterlogged;
|
return ((org.bukkit.block.data.Waterlogged) super.getHandle()).isWaterlogged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWaterlogged(boolean waterlogged) {
|
public void setWaterlogged(boolean waterlogged) {
|
||||||
this.waterlogged = waterlogged;
|
((org.bukkit.block.data.Waterlogged) super.getHandle()).setWaterlogged(waterlogged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
@@ -3,6 +3,7 @@ package com.dfsek.terra.bukkit.world.block.data;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
||||||
import org.bukkit.block.data.Bisected;
|
import org.bukkit.block.data.Bisected;
|
||||||
|
import org.bukkit.block.data.type.Slab;
|
||||||
import org.bukkit.block.data.type.Stairs;
|
import org.bukkit.block.data.type.Stairs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,4 +82,17 @@ public final class TerraEnumAdapter {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Slab.Type fromTerraSlabType(com.dfsek.terra.api.generic.world.block.data.Slab.Type type) {
|
||||||
|
switch(type) {
|
||||||
|
case TOP:
|
||||||
|
return Slab.Type.TOP;
|
||||||
|
case DOUBLE:
|
||||||
|
return Slab.Type.DOUBLE;
|
||||||
|
case BOTTOM:
|
||||||
|
return Slab.Type.BOTTOM;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,16 +15,13 @@ import com.dfsek.terra.config.lang.LangUtil;
|
|||||||
import com.dfsek.terra.fabric.inventory.FabricItemHandle;
|
import com.dfsek.terra.fabric.inventory.FabricItemHandle;
|
||||||
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
|
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
|
||||||
import com.dfsek.terra.fabric.world.FabricBiome;
|
import com.dfsek.terra.fabric.world.FabricBiome;
|
||||||
import com.dfsek.terra.fabric.world.FabricMaterialData;
|
|
||||||
import com.dfsek.terra.fabric.world.FabricWorldHandle;
|
import com.dfsek.terra.fabric.world.FabricWorldHandle;
|
||||||
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
||||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
||||||
import com.dfsek.terra.registry.ConfigRegistry;
|
import com.dfsek.terra.registry.ConfigRegistry;
|
||||||
import com.dfsek.terra.util.MaterialSet;
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.client.world.GeneratorType;
|
import net.minecraft.client.world.GeneratorType;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.BuiltinRegistries;
|
import net.minecraft.util.registry.BuiltinRegistries;
|
||||||
@@ -141,18 +138,6 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
MaterialSet set = new MaterialSet();
|
|
||||||
|
|
||||||
set.add(new FabricMaterialData(Blocks.STONE));
|
|
||||||
set.add(new FabricMaterialData(Blocks.DIRT));
|
|
||||||
|
|
||||||
System.out.println("Contains: " + set.contains(new FabricMaterialData(Blocks.AIR)));
|
|
||||||
System.out.println("Contains: " + set.contains(new FabricMaterialData(Blocks.STONE)));
|
|
||||||
|
|
||||||
System.out.println("Matches: " + new FabricMaterialData(Blocks.STONE).matches(new FabricMaterialData(Blocks.STONE)));
|
|
||||||
System.out.println("Matches: " + new FabricMaterialData(Blocks.STONE).matches(new FabricMaterialData(Blocks.DIRT)));
|
|
||||||
|
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
plugin.load(this);
|
plugin.load(this);
|
||||||
config = new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra");
|
config = new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra");
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.dfsek.terra.fabric.world;
|
|
||||||
|
|
||||||
import com.dfsek.terra.registry.TerraRegistry;
|
|
||||||
import net.minecraft.world.biome.Biome;
|
|
||||||
|
|
||||||
public class FabricBiomeRegistry extends TerraRegistry<Biome> {
|
|
||||||
}
|
|
||||||
@@ -5,9 +5,15 @@ import com.dfsek.terra.api.generic.world.WorldHandle;
|
|||||||
import com.dfsek.terra.api.generic.world.block.Block;
|
import com.dfsek.terra.api.generic.world.block.Block;
|
||||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||||
|
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||||
|
import com.dfsek.terra.fabric.world.block.FabricMaterialData;
|
||||||
|
import com.dfsek.terra.fabric.world.block.data.FabricStairs;
|
||||||
|
import com.dfsek.terra.fabric.world.block.data.FabricWaterlogged;
|
||||||
import com.mojang.brigadier.StringReader;
|
import com.mojang.brigadier.StringReader;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.command.argument.BlockArgumentParser;
|
import net.minecraft.command.argument.BlockArgumentParser;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
|
|
||||||
public class FabricWorldHandle implements WorldHandle {
|
public class FabricWorldHandle implements WorldHandle {
|
||||||
@Override
|
@Override
|
||||||
@@ -29,7 +35,11 @@ public class FabricWorldHandle implements WorldHandle {
|
|||||||
public FabricBlockData createBlockData(String data) {
|
public FabricBlockData createBlockData(String data) {
|
||||||
BlockArgumentParser parser = new BlockArgumentParser(new StringReader(data), true);
|
BlockArgumentParser parser = new BlockArgumentParser(new StringReader(data), true);
|
||||||
try {
|
try {
|
||||||
return new FabricBlockData(parser.parse(true).getBlockState());
|
BlockState state = parser.parse(true).getBlockState();
|
||||||
|
if(state == null) throw new IllegalArgumentException("Invalid data: " + data);
|
||||||
|
if(state.contains(Properties.STAIR_SHAPE)) return new FabricStairs(state);
|
||||||
|
if(state.contains(Properties.WATERLOGGED)) return new FabricWaterlogged(state);
|
||||||
|
return new FabricBlockData(state);
|
||||||
} catch(CommandSyntaxException e) {
|
} catch(CommandSyntaxException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,10 +1,11 @@
|
|||||||
package com.dfsek.terra.fabric.world;
|
package com.dfsek.terra.fabric.world.block;
|
||||||
|
|
||||||
import com.dfsek.terra.api.generic.world.block.Block;
|
import com.dfsek.terra.api.generic.world.block.Block;
|
||||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||||
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
||||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||||
|
import com.dfsek.terra.fabric.world.FabricAdapters;
|
||||||
import com.dfsek.terra.fabric.world.handles.world.FabricWorldAccess;
|
import com.dfsek.terra.fabric.world.handles.world.FabricWorldAccess;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.WorldAccess;
|
||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
package com.dfsek.terra.fabric.world;
|
package com.dfsek.terra.fabric.world.block;
|
||||||
|
|
||||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
public class FabricBlockData implements BlockData {
|
public class FabricBlockData implements BlockData {
|
||||||
private final BlockState delegate;
|
protected BlockState delegate;
|
||||||
|
|
||||||
public FabricBlockData(BlockState delegate) {
|
public FabricBlockData(BlockState delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.dfsek.terra.fabric.world;
|
package com.dfsek.terra.fabric.world.block;
|
||||||
|
|
||||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
package com.dfsek.terra.fabric.world.block.data;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Bisected;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Stairs;
|
||||||
|
import net.minecraft.block.enums.BlockHalf;
|
||||||
|
import net.minecraft.block.enums.StairShape;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
|
||||||
|
public final class FabricEnumAdapter {
|
||||||
|
public static Stairs.Shape fromFabricStairShape(StairShape shape) {
|
||||||
|
switch(shape) {
|
||||||
|
case OUTER_RIGHT:
|
||||||
|
return Stairs.Shape.OUTER_RIGHT;
|
||||||
|
case INNER_RIGHT:
|
||||||
|
return Stairs.Shape.INNER_RIGHT;
|
||||||
|
case OUTER_LEFT:
|
||||||
|
return Stairs.Shape.OUTER_LEFT;
|
||||||
|
case INNER_LEFT:
|
||||||
|
return Stairs.Shape.INNER_LEFT;
|
||||||
|
case STRAIGHT:
|
||||||
|
return Stairs.Shape.STRAIGHT;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bisected.Half fromFabricHalf(BlockHalf half) {
|
||||||
|
switch(half) {
|
||||||
|
case BOTTOM:
|
||||||
|
return Bisected.Half.BOTTOM;
|
||||||
|
case TOP:
|
||||||
|
return Bisected.Half.TOP;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockFace fromFabricDirection(Direction direction) {
|
||||||
|
switch(direction) {
|
||||||
|
case DOWN:
|
||||||
|
return BlockFace.DOWN;
|
||||||
|
case UP:
|
||||||
|
return BlockFace.UP;
|
||||||
|
case WEST:
|
||||||
|
return BlockFace.WEST;
|
||||||
|
case EAST:
|
||||||
|
return BlockFace.EAST;
|
||||||
|
case NORTH:
|
||||||
|
return BlockFace.NORTH;
|
||||||
|
case SOUTH:
|
||||||
|
return BlockFace.SOUTH;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
package com.dfsek.terra.fabric.world.block.data;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Stairs;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
|
|
||||||
|
public class FabricStairs extends FabricWaterlogged implements Stairs {
|
||||||
|
public FabricStairs(BlockState delegate) {
|
||||||
|
super(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Shape getShape() {
|
||||||
|
return FabricEnumAdapter.fromFabricStairShape(getHandle().get(Properties.STAIR_SHAPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setShape(Shape shape) {
|
||||||
|
super.delegate = getHandle().with(Properties.STAIR_SHAPE, TerraEnumAdapter.fromTerraStairShape(shape));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Half getHalf() {
|
||||||
|
return FabricEnumAdapter.fromFabricHalf(getHandle().get(Properties.BLOCK_HALF));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHalf(Half half) {
|
||||||
|
super.delegate = getHandle().with(Properties.BLOCK_HALF, TerraEnumAdapter.fromTerraHalf(half));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockFace getFacing() {
|
||||||
|
return FabricEnumAdapter.fromFabricDirection(getHandle().get(Properties.HORIZONTAL_FACING));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFacing(BlockFace facing) {
|
||||||
|
super.delegate = getHandle().with(Properties.HORIZONTAL_FACING, TerraEnumAdapter.fromTerraBlockFace(facing));
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.dfsek.terra.fabric.world.block.data;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Waterlogged;
|
||||||
|
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
|
|
||||||
|
public class FabricWaterlogged extends FabricBlockData implements Waterlogged {
|
||||||
|
public FabricWaterlogged(BlockState delegate) {
|
||||||
|
super(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWaterlogged() {
|
||||||
|
return delegate.get(Properties.WATERLOGGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWaterlogged(boolean waterlogged) {
|
||||||
|
super.delegate = delegate.with(Properties.WATERLOGGED, waterlogged);
|
||||||
|
}
|
||||||
|
}
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
package com.dfsek.terra.fabric.world.block.data;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Bisected;
|
||||||
|
import com.dfsek.terra.api.generic.world.block.data.Stairs;
|
||||||
|
import net.minecraft.block.enums.BlockHalf;
|
||||||
|
import net.minecraft.block.enums.StairShape;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
|
||||||
|
public final class TerraEnumAdapter {
|
||||||
|
public static StairShape fromTerraStairShape(Stairs.Shape shape) {
|
||||||
|
switch(shape) {
|
||||||
|
case STRAIGHT:
|
||||||
|
return StairShape.STRAIGHT;
|
||||||
|
case INNER_LEFT:
|
||||||
|
return StairShape.INNER_LEFT;
|
||||||
|
case OUTER_LEFT:
|
||||||
|
return StairShape.OUTER_LEFT;
|
||||||
|
case INNER_RIGHT:
|
||||||
|
return StairShape.INNER_RIGHT;
|
||||||
|
case OUTER_RIGHT:
|
||||||
|
return StairShape.OUTER_RIGHT;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockHalf fromTerraHalf(Bisected.Half half) {
|
||||||
|
switch(half) {
|
||||||
|
case TOP:
|
||||||
|
return BlockHalf.TOP;
|
||||||
|
case BOTTOM:
|
||||||
|
return BlockHalf.BOTTOM;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Direction fromTerraBlockFace(BlockFace face) {
|
||||||
|
switch(face) {
|
||||||
|
case SOUTH:
|
||||||
|
return Direction.SOUTH;
|
||||||
|
case NORTH:
|
||||||
|
return Direction.NORTH;
|
||||||
|
case EAST:
|
||||||
|
return Direction.EAST;
|
||||||
|
case WEST:
|
||||||
|
return Direction.WEST;
|
||||||
|
case UP:
|
||||||
|
return Direction.UP;
|
||||||
|
case DOWN:
|
||||||
|
return Direction.DOWN;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -2,7 +2,7 @@ package com.dfsek.terra.fabric.world.generator;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.generic.generator.ChunkGenerator;
|
import com.dfsek.terra.api.generic.generator.ChunkGenerator;
|
||||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||||
import com.dfsek.terra.fabric.world.FabricBlockData;
|
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package com.dfsek.terra.fabric.world.handles.chunk;
|
|||||||
import com.dfsek.terra.api.generic.world.Chunk;
|
import com.dfsek.terra.api.generic.world.Chunk;
|
||||||
import com.dfsek.terra.api.generic.world.World;
|
import com.dfsek.terra.api.generic.world.World;
|
||||||
import com.dfsek.terra.api.generic.world.block.Block;
|
import com.dfsek.terra.api.generic.world.block.Block;
|
||||||
import com.dfsek.terra.fabric.world.FabricBlock;
|
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||||
import com.dfsek.terra.fabric.world.handles.world.FabricWorldAccess;
|
import com.dfsek.terra.fabric.world.handles.world.FabricWorldAccess;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.ChunkRegion;
|
import net.minecraft.world.ChunkRegion;
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import com.dfsek.terra.api.generic.world.Chunk;
|
|||||||
import com.dfsek.terra.api.generic.world.World;
|
import com.dfsek.terra.api.generic.world.World;
|
||||||
import com.dfsek.terra.api.generic.world.block.Block;
|
import com.dfsek.terra.api.generic.world.block.Block;
|
||||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||||
import com.dfsek.terra.fabric.world.FabricBlock;
|
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGenerator;
|
import com.dfsek.terra.fabric.world.generator.FabricChunkGenerator;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.WorldAccess;
|
||||||
|
|||||||
+3
-2
@@ -7,8 +7,9 @@ import com.dfsek.terra.api.generic.world.Chunk;
|
|||||||
import com.dfsek.terra.api.generic.world.World;
|
import com.dfsek.terra.api.generic.world.World;
|
||||||
import com.dfsek.terra.api.generic.world.block.Block;
|
import com.dfsek.terra.api.generic.world.block.Block;
|
||||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||||
import com.dfsek.terra.fabric.world.FabricBlock;
|
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.WorldAccess;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -24,7 +25,7 @@ public class FabricWorldAccess implements World {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSeed() {
|
public long getSeed() {
|
||||||
return 1234; // TODO: actually implement this
|
return ((StructureWorldAccess) delegate).getSeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import com.dfsek.terra.api.generic.world.Chunk;
|
|||||||
import com.dfsek.terra.api.generic.world.World;
|
import com.dfsek.terra.api.generic.world.World;
|
||||||
import com.dfsek.terra.api.generic.world.block.Block;
|
import com.dfsek.terra.api.generic.world.block.Block;
|
||||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||||
import com.dfsek.terra.fabric.world.FabricBlock;
|
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGenerator;
|
import com.dfsek.terra.fabric.world.generator.FabricChunkGenerator;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.ChunkRegion;
|
import net.minecraft.world.ChunkRegion;
|
||||||
|
|||||||
Reference in New Issue
Block a user