Fur rotation fix, new structure format
This commit is contained in:
parent
7431a228ef
commit
ff0f9f18a9
5 changed files with 80 additions and 35 deletions
|
@ -24,6 +24,8 @@ import net.minecraft.sound.BlockSoundGroup;
|
|||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
|
@ -33,6 +35,7 @@ import net.minecraft.world.WorldAccess;
|
|||
import net.minecraft.world.WorldView;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable {
|
||||
|
@ -115,6 +118,16 @@ public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable
|
|||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
|
||||
}
|
||||
|
||||
static {
|
||||
BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 0.5, 1.0));
|
||||
BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.0, 0.5, 0.0, 1.0, 1.0, 1.0));
|
||||
|
|
|
@ -18,6 +18,7 @@ import ru.betterend.util.StructureHelper;
|
|||
import ru.betterend.world.features.EndFeature;
|
||||
import ru.betterend.world.features.ListFeature;
|
||||
import ru.betterend.world.features.ListFeature.StructureInfo;
|
||||
import ru.betterend.world.features.NBTStructureFeature.TerrainMerge;
|
||||
|
||||
public class EndBiome {
|
||||
protected List<EndBiome> subbiomes = Lists.newArrayList();
|
||||
|
@ -142,12 +143,12 @@ public class EndBiome {
|
|||
enties.forEach((entry) -> {
|
||||
JsonObject e = entry.getAsJsonObject();
|
||||
Structure structure = StructureHelper.readStructure(path + e.get("nbt").getAsString() + ".nbt");
|
||||
boolean adjustTerrain = e.get("adjustTerrain").getAsBoolean();
|
||||
TerrainMerge terrainMerge = TerrainMerge.getFromString(e.get("terrainMerge").getAsString());
|
||||
int offsetY = e.get("offsetY").getAsInt();
|
||||
list.add(new StructureInfo(structure, offsetY, adjustTerrain));
|
||||
list.add(new StructureInfo(structure, offsetY, terrainMerge));
|
||||
});
|
||||
if (!list.isEmpty()) {
|
||||
structuresFeature = EndFeature.makeChansedFeature(nm + "_structures", new ListFeature(list), 30);
|
||||
structuresFeature = EndFeature.makeChansedFeature(nm + "_structures", new ListFeature(list), 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,9 @@ public class ListFeature extends NBTStructureFeature {
|
|||
|
||||
@Override
|
||||
protected boolean canSpawn(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
return pos.getY() > 58 && world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN);
|
||||
int cx = pos.getX() >> 4;
|
||||
int cz = pos.getZ() >> 4;
|
||||
return ((cx + cz) & 1) == 0 && pos.getY() > 58 && world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,19 +45,19 @@ public class ListFeature extends NBTStructureFeature {
|
|||
protected int getYOffset(Structure structure, StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
return selected.offsetY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean adjustSurface(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
return selected.adjustTerrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TerrainMerge getTerrainMerge(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
return selected.terrainMerge;
|
||||
}
|
||||
|
||||
public static final class StructureInfo {
|
||||
public final boolean adjustTerrain;
|
||||
public final TerrainMerge terrainMerge;
|
||||
public final Structure structure;
|
||||
public final int offsetY;
|
||||
|
||||
public StructureInfo(Structure structure, int offsetY, boolean adjustTerrain) {
|
||||
this.adjustTerrain = adjustTerrain;
|
||||
public StructureInfo(Structure structure, int offsetY, TerrainMerge terrainMerge) {
|
||||
this.terrainMerge = terrainMerge;
|
||||
this.structure = structure;
|
||||
this.offsetY = offsetY;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
|||
|
||||
protected abstract int getYOffset(Structure structure, StructureWorldAccess world, BlockPos pos, Random random);
|
||||
|
||||
protected abstract boolean adjustSurface(StructureWorldAccess world, BlockPos pos, Random random);
|
||||
protected abstract TerrainMerge getTerrainMerge(StructureWorldAccess world, BlockPos pos, Random random);
|
||||
|
||||
protected BlockPos getGround(StructureWorldAccess world, BlockPos center) {
|
||||
Biome biome = world.getBiome(center);
|
||||
|
@ -87,14 +87,15 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
|||
BlockRotation rotation = getRotation(world, center, random);
|
||||
BlockMirror mirror = getMirror(world, center, random);
|
||||
BlockPos offset = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN);
|
||||
center = center.add(0, getYOffset(structure, world, center, random), 0);
|
||||
center = center.add(0, getYOffset(structure, world, center, random) + 0.5, 0);
|
||||
|
||||
BlockBox bounds = makeBox(center);
|
||||
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
|
||||
center = center.add(-offset.getX() * 0.5, 1, -offset.getZ() * 0.5);
|
||||
center = center.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
|
||||
structure.place(world, center, placementData, random);
|
||||
|
||||
if (adjustSurface(world, center, random)) {
|
||||
TerrainMerge merge = getTerrainMerge(world, center, random);
|
||||
if (merge != TerrainMerge.NONE) {
|
||||
Mutable mut = new Mutable();
|
||||
int x1 = center.getX();
|
||||
int z1 = center.getZ();
|
||||
|
@ -125,15 +126,25 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
|||
mut.setY(mut.getY() - 1);
|
||||
BlockState stateSt = world.getBlockState(mut);
|
||||
if (!stateSt.isIn(EndTags.GEN_TERRAIN)) {
|
||||
SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig();
|
||||
boolean isTop = mut.getY() == surfMax && state.getMaterial().blocksLight();
|
||||
BlockState top = isTop ? config.getTopMaterial() : config.getUnderMaterial();
|
||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||
if (merge == TerrainMerge.SURFACE) {
|
||||
SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig();
|
||||
boolean isTop = mut.getY() == surfMax && state.getMaterial().blocksLight();
|
||||
BlockState top = isTop ? config.getTopMaterial() : config.getUnderMaterial();
|
||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (stateSt.isIn(EndTags.END_GROUND) && state.getMaterial().blocksLight()) {
|
||||
SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig();
|
||||
BlocksHelper.setWithoutUpdate(world, mut, config.getUnderMaterial());
|
||||
if (merge == TerrainMerge.SURFACE) {
|
||||
SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig();
|
||||
BlocksHelper.setWithoutUpdate(world, mut, config.getUnderMaterial());
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -177,4 +188,22 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
|||
|
||||
return template;
|
||||
}
|
||||
|
||||
public static enum TerrainMerge {
|
||||
NONE,
|
||||
SURFACE,
|
||||
OBJECT;
|
||||
|
||||
public static TerrainMerge getFromString(String type) {
|
||||
if (type.equals("surface")) {
|
||||
return SURFACE;
|
||||
}
|
||||
else if (type.equals("object")) {
|
||||
return OBJECT;
|
||||
}
|
||||
else {
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"structures": [
|
||||
{ "nbt": "stump_1", "offsetY": 0, "adjustTerrain": false },
|
||||
{ "nbt": "stump_2", "offsetY": 0, "adjustTerrain": false },
|
||||
{ "nbt": "fallen_log_1", "offsetY": 0, "adjustTerrain": false },
|
||||
{ "nbt": "fallen_log_2", "offsetY": 0, "adjustTerrain": false },
|
||||
{ "nbt": "ruins_1", "offsetY": 0, "adjustTerrain": true },
|
||||
{ "nbt": "ruins_2", "offsetY": 0, "adjustTerrain": true },
|
||||
{ "nbt": "ruins_3", "offsetY": 0, "adjustTerrain": true },
|
||||
{ "nbt": "ruins_4", "offsetY": 0, "adjustTerrain": true },
|
||||
{ "nbt": "ruins_5", "offsetY": 0, "adjustTerrain": true },
|
||||
{ "nbt": "ruins_6", "offsetY": 0, "adjustTerrain": true },
|
||||
{ "nbt": "ruins_7", "offsetY": 0, "adjustTerrain": true },
|
||||
{ "nbt": "ruins_8", "offsetY": 0, "adjustTerrain": true },
|
||||
{ "nbt": "small_mansion", "offsetY": -1, "adjustTerrain": false }
|
||||
{ "nbt": "stump_1", "offsetY": 0, "terrainMerge": "none" },
|
||||
{ "nbt": "stump_2", "offsetY": 0, "terrainMerge": "none" },
|
||||
{ "nbt": "fallen_log_1", "offsetY": 0, "terrainMerge": "none" },
|
||||
{ "nbt": "fallen_log_2", "offsetY": 0, "terrainMerge": "none" },
|
||||
{ "nbt": "ruins_1", "offsetY": 0, "terrainMerge": "surface" },
|
||||
{ "nbt": "ruins_2", "offsetY": 0, "terrainMerge": "surface" },
|
||||
{ "nbt": "ruins_3", "offsetY": 0, "terrainMerge": "surface" },
|
||||
{ "nbt": "ruins_4", "offsetY": 0, "terrainMerge": "surface" },
|
||||
{ "nbt": "ruins_5", "offsetY": 0, "terrainMerge": "surface" },
|
||||
{ "nbt": "ruins_6", "offsetY": 0, "terrainMerge": "surface" },
|
||||
{ "nbt": "ruins_7", "offsetY": 0, "terrainMerge": "surface" },
|
||||
{ "nbt": "ruins_8", "offsetY": 0, "terrainMerge": "surface" },
|
||||
{ "nbt": "small_mansion", "offsetY": -1, "terrainMerge": "object" }
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue