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.StateManager;
|
||||||
import net.minecraft.state.property.DirectionProperty;
|
import net.minecraft.state.property.DirectionProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
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.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
|
@ -33,6 +35,7 @@ import net.minecraft.world.WorldAccess;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
import ru.betterend.util.BlocksHelper;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable {
|
public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable {
|
||||||
|
@ -115,6 +118,16 @@ public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable
|
||||||
return ERenderLayer.CUTOUT;
|
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 {
|
static {
|
||||||
BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 0.5, 1.0));
|
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));
|
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.EndFeature;
|
||||||
import ru.betterend.world.features.ListFeature;
|
import ru.betterend.world.features.ListFeature;
|
||||||
import ru.betterend.world.features.ListFeature.StructureInfo;
|
import ru.betterend.world.features.ListFeature.StructureInfo;
|
||||||
|
import ru.betterend.world.features.NBTStructureFeature.TerrainMerge;
|
||||||
|
|
||||||
public class EndBiome {
|
public class EndBiome {
|
||||||
protected List<EndBiome> subbiomes = Lists.newArrayList();
|
protected List<EndBiome> subbiomes = Lists.newArrayList();
|
||||||
|
@ -142,12 +143,12 @@ public class EndBiome {
|
||||||
enties.forEach((entry) -> {
|
enties.forEach((entry) -> {
|
||||||
JsonObject e = entry.getAsJsonObject();
|
JsonObject e = entry.getAsJsonObject();
|
||||||
Structure structure = StructureHelper.readStructure(path + e.get("nbt").getAsString() + ".nbt");
|
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();
|
int offsetY = e.get("offsetY").getAsInt();
|
||||||
list.add(new StructureInfo(structure, offsetY, adjustTerrain));
|
list.add(new StructureInfo(structure, offsetY, terrainMerge));
|
||||||
});
|
});
|
||||||
if (!list.isEmpty()) {
|
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
|
@Override
|
||||||
protected boolean canSpawn(StructureWorldAccess world, BlockPos pos, Random random) {
|
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
|
@Override
|
||||||
|
@ -45,17 +47,17 @@ public class ListFeature extends NBTStructureFeature {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean adjustSurface(StructureWorldAccess world, BlockPos pos, Random random) {
|
protected TerrainMerge getTerrainMerge(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||||
return selected.adjustTerrain;
|
return selected.terrainMerge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class StructureInfo {
|
public static final class StructureInfo {
|
||||||
public final boolean adjustTerrain;
|
public final TerrainMerge terrainMerge;
|
||||||
public final Structure structure;
|
public final Structure structure;
|
||||||
public final int offsetY;
|
public final int offsetY;
|
||||||
|
|
||||||
public StructureInfo(Structure structure, int offsetY, boolean adjustTerrain) {
|
public StructureInfo(Structure structure, int offsetY, TerrainMerge terrainMerge) {
|
||||||
this.adjustTerrain = adjustTerrain;
|
this.terrainMerge = terrainMerge;
|
||||||
this.structure = structure;
|
this.structure = structure;
|
||||||
this.offsetY = offsetY;
|
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 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) {
|
protected BlockPos getGround(StructureWorldAccess world, BlockPos center) {
|
||||||
Biome biome = world.getBiome(center);
|
Biome biome = world.getBiome(center);
|
||||||
|
@ -87,14 +87,15 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
||||||
BlockRotation rotation = getRotation(world, center, random);
|
BlockRotation rotation = getRotation(world, center, random);
|
||||||
BlockMirror mirror = getMirror(world, center, random);
|
BlockMirror mirror = getMirror(world, center, random);
|
||||||
BlockPos offset = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN);
|
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);
|
BlockBox bounds = makeBox(center);
|
||||||
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
|
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);
|
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();
|
Mutable mut = new Mutable();
|
||||||
int x1 = center.getX();
|
int x1 = center.getX();
|
||||||
int z1 = center.getZ();
|
int z1 = center.getZ();
|
||||||
|
@ -125,15 +126,25 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
||||||
mut.setY(mut.getY() - 1);
|
mut.setY(mut.getY() - 1);
|
||||||
BlockState stateSt = world.getBlockState(mut);
|
BlockState stateSt = world.getBlockState(mut);
|
||||||
if (!stateSt.isIn(EndTags.GEN_TERRAIN)) {
|
if (!stateSt.isIn(EndTags.GEN_TERRAIN)) {
|
||||||
SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig();
|
if (merge == TerrainMerge.SURFACE) {
|
||||||
boolean isTop = mut.getY() == surfMax && state.getMaterial().blocksLight();
|
SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig();
|
||||||
BlockState top = isTop ? config.getTopMaterial() : config.getUnderMaterial();
|
boolean isTop = mut.getY() == surfMax && state.getMaterial().blocksLight();
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
BlockState top = isTop ? config.getTopMaterial() : config.getUnderMaterial();
|
||||||
|
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (stateSt.isIn(EndTags.END_GROUND) && state.getMaterial().blocksLight()) {
|
if (stateSt.isIn(EndTags.END_GROUND) && state.getMaterial().blocksLight()) {
|
||||||
SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig();
|
if (merge == TerrainMerge.SURFACE) {
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, config.getUnderMaterial());
|
SurfaceConfig config = world.getBiome(mut).getGenerationSettings().getSurfaceConfig();
|
||||||
|
BlocksHelper.setWithoutUpdate(world, mut, config.getUnderMaterial());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -177,4 +188,22 @@ public abstract class NBTStructureFeature extends DefaultFeature {
|
||||||
|
|
||||||
return template;
|
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": [
|
"structures": [
|
||||||
{ "nbt": "stump_1", "offsetY": 0, "adjustTerrain": false },
|
{ "nbt": "stump_1", "offsetY": 0, "terrainMerge": "none" },
|
||||||
{ "nbt": "stump_2", "offsetY": 0, "adjustTerrain": false },
|
{ "nbt": "stump_2", "offsetY": 0, "terrainMerge": "none" },
|
||||||
{ "nbt": "fallen_log_1", "offsetY": 0, "adjustTerrain": false },
|
{ "nbt": "fallen_log_1", "offsetY": 0, "terrainMerge": "none" },
|
||||||
{ "nbt": "fallen_log_2", "offsetY": 0, "adjustTerrain": false },
|
{ "nbt": "fallen_log_2", "offsetY": 0, "terrainMerge": "none" },
|
||||||
{ "nbt": "ruins_1", "offsetY": 0, "adjustTerrain": true },
|
{ "nbt": "ruins_1", "offsetY": 0, "terrainMerge": "surface" },
|
||||||
{ "nbt": "ruins_2", "offsetY": 0, "adjustTerrain": true },
|
{ "nbt": "ruins_2", "offsetY": 0, "terrainMerge": "surface" },
|
||||||
{ "nbt": "ruins_3", "offsetY": 0, "adjustTerrain": true },
|
{ "nbt": "ruins_3", "offsetY": 0, "terrainMerge": "surface" },
|
||||||
{ "nbt": "ruins_4", "offsetY": 0, "adjustTerrain": true },
|
{ "nbt": "ruins_4", "offsetY": 0, "terrainMerge": "surface" },
|
||||||
{ "nbt": "ruins_5", "offsetY": 0, "adjustTerrain": true },
|
{ "nbt": "ruins_5", "offsetY": 0, "terrainMerge": "surface" },
|
||||||
{ "nbt": "ruins_6", "offsetY": 0, "adjustTerrain": true },
|
{ "nbt": "ruins_6", "offsetY": 0, "terrainMerge": "surface" },
|
||||||
{ "nbt": "ruins_7", "offsetY": 0, "adjustTerrain": true },
|
{ "nbt": "ruins_7", "offsetY": 0, "terrainMerge": "surface" },
|
||||||
{ "nbt": "ruins_8", "offsetY": 0, "adjustTerrain": true },
|
{ "nbt": "ruins_8", "offsetY": 0, "terrainMerge": "surface" },
|
||||||
{ "nbt": "small_mansion", "offsetY": -1, "adjustTerrain": false }
|
{ "nbt": "small_mansion", "offsetY": -1, "terrainMerge": "object" }
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue