Fixed missing vines & texture overlays

This commit is contained in:
paulevsGitch 2021-02-13 23:47:16 +03:00
parent f57df6ac0b
commit 70d44fa825
214 changed files with 129 additions and 27 deletions

View file

@ -11,7 +11,7 @@ import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndBlocks;
public class AeterniumAnvil extends EndAnvilBlock {
public static final IntProperty DESTRUCTION = BlockProperties.DESTRUCTION_LONG;
private static final IntProperty DESTRUCTION = BlockProperties.DESTRUCTION_LONG;
public AeterniumAnvil() {
super(EndBlocks.AETERNIUM_BLOCK.getDefaultMaterialColor(), EndToolMaterial.AETERNIUM.getMiningLevel());

View file

@ -24,7 +24,7 @@ import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class EndAnvilBlock extends AnvilBlock implements BlockPatterned {
public static final IntProperty DESTRUCTION = BlockProperties.DESTRUCTION;
private static final IntProperty DESTRUCTION = BlockProperties.DESTRUCTION;
protected final int level;
public EndAnvilBlock(MaterialColor color, int level) {

View file

@ -77,6 +77,10 @@ public class VineBlock extends BlockBaseNotFull implements IRenderTypeable, Fert
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.XZ;
}
public boolean canGenerate(BlockState state, WorldView world, BlockPos pos) {
return isSupport(state, world, pos);
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {

View file

@ -3,36 +3,68 @@ package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.VineBlock;
import ru.betterend.util.BlocksHelper;
public class VineFeature extends InvertedScatterFeature {
private final Block vineBlock;
private final int maxLength;
private final boolean vine;
public VineFeature(Block vineBlock, int maxLength) {
super(6);
this.vineBlock = vineBlock;
this.maxLength = maxLength;
this.vine = vineBlock instanceof VineBlock;
}
@Override
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return world.isAir(blockPos) && vineBlock.canPlaceAt(AIR, world, blockPos);
BlockState state = world.getBlockState(blockPos);
return state.getMaterial().isReplaceable() && canPlaceBlock(state, world, blockPos);
}
@Override
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
int h = BlocksHelper.downRay(world, blockPos, random.nextInt(maxLength)) - 1;
if (h > 2) {
BlocksHelper.setWithoutUpdate(world, blockPos, vineBlock.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
BlockState top = getTopState();
BlockState middle = getMiggleState();
BlockState bottom = getBottomState();
BlocksHelper.setWithoutUpdate(world, blockPos, top);
for (int i = 1; i < h; i++) {
BlocksHelper.setWithoutUpdate(world, blockPos.down(i), vineBlock.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithoutUpdate(world, blockPos.down(i), middle);
}
BlocksHelper.setWithoutUpdate(world, blockPos.down(h), vineBlock.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
BlocksHelper.setWithoutUpdate(world, blockPos.down(h), bottom);
}
}
private boolean canPlaceBlock(BlockState state, StructureWorldAccess world, BlockPos blockPos) {
if (vine) {
return ((VineBlock) vineBlock).canGenerate(state, world, blockPos);
}
else {
return vineBlock.canPlaceAt(state, world, blockPos);
}
}
private BlockState getTopState() {
BlockState state = vineBlock.getDefaultState();
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP) : state;
}
private BlockState getMiggleState() {
BlockState state = vineBlock.getDefaultState();
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE) : state;
}
private BlockState getBottomState() {
BlockState state = vineBlock.getDefaultState();
return vine ? state.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM) : state;
}
}