This commit is contained in:
paulevsGitch 2020-10-03 23:28:04 +03:00
parent a968b9bb23
commit 8beabd0f96
18 changed files with 176 additions and 63 deletions

View file

@ -12,7 +12,9 @@ import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.BlockRegistry;
public class BlockBlueVineLantern extends BlockBase {
public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
@ -22,9 +24,14 @@ public class BlockBlueVineLantern extends BlockBase {
this.setDefaultState(this.stateManager.getDefaultState().with(NATURAL, false));
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return state.get(NATURAL) ? world.getBlockState(pos.down()).getBlock() == BlockRegistry.BLUE_VINE : true;
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (state.get(NATURAL) && world.isAir(pos.down())) {
if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
}
else {