use of net.minecraft.world.level.block.state.BlockState in project Tropicraft by Tropicraft.
the class TikiTorchBlock method playerDestroy.
@Override
public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity te, ItemStack stack) {
TorchSection section = state.getValue(SECTION);
BlockPos base = pos.below(section.height);
for (TorchSection otherSection : TorchSection.values()) {
BlockPos pos2 = base.above(otherSection.height);
BlockState state2 = world.getBlockState(pos2);
if (state2.getBlock() == this && state2.getValue(SECTION) == otherSection) {
super.playerDestroy(world, player, pos2, state2, te, stack);
world.setBlock(pos2, world.getFluidState(pos2).createLegacyBlock(), world.isClientSide ? 11 : 3);
}
}
}
use of net.minecraft.world.level.block.state.BlockState in project Tropicraft by Tropicraft.
the class HugePlantBlock method placeAt.
public void placeAt(LevelAccessor world, BlockPos pos, int flags) {
Shape shape = Shape.fromSeed(this, pos);
for (BlockPos plantPos : shape) {
BlockState plantState = shape.blockAt(plantPos);
world.setBlock(plantPos, plantState, flags);
}
}
use of net.minecraft.world.level.block.state.BlockState in project Tropicraft by Tropicraft.
the class HugePlantBlock method setPlacedBy.
@Override
public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
Shape shape = Shape.fromSeed(this, pos);
for (BlockPos plantPos : shape) {
if (!plantPos.equals(pos)) {
BlockState plantState = shape.blockAt(plantPos);
world.setBlock(plantPos, plantState, Constants.BlockFlags.DEFAULT);
}
}
}
use of net.minecraft.world.level.block.state.BlockState in project Tropicraft by Tropicraft.
the class JigarbovTorchPlacement method onPlaceBlock.
@SubscribeEvent
public static void onPlaceBlock(BlockEvent.EntityPlaceEvent event) {
BlockState placedState = event.getPlacedBlock();
Block placedBlock = placedState.getBlock();
if (placedBlock == Blocks.REDSTONE_WALL_TORCH) {
RegistryObject<RedstoneWallTorchBlock> jigarbovTorchBlock = getJigarbovTorchFor(event.getPlacedAgainst().getBlock());
if (jigarbovTorchBlock != null) {
BlockState jigarbovTorch = jigarbovTorchBlock.get().defaultBlockState();
jigarbovTorch = copyPropertiesTo(jigarbovTorch, placedState);
event.getWorld().setBlock(event.getPos(), jigarbovTorch, Block.UPDATE_ALL);
}
}
}
use of net.minecraft.world.level.block.state.BlockState in project Tropicraft by Tropicraft.
the class PineappleBlock method tick.
@Override
public void tick(final BlockState state, final ServerLevel world, final BlockPos pos, final Random random) {
if (pos.getY() > world.getMaxBuildHeight() - 2) {
return;
}
// Current metadata
int growth = state.getValue(STAGE);
if (state.getBlock() == this && growth <= TOTAL_GROW_TICKS && world.isEmptyBlock(pos.above()) && state.getValue(HALF) == DoubleBlockHalf.LOWER) {
if (growth >= TOTAL_GROW_TICKS - 1) {
// Set current state
BlockState growthState = state.setValue(STAGE, TOTAL_GROW_TICKS);
world.setBlock(pos, growthState, Constants.BlockFlags.DEFAULT | Constants.BlockFlags.NO_RERENDER);
// Place actual pineapple plant above stem
BlockState fullGrowth = growthState.setValue(HALF, DoubleBlockHalf.UPPER);
world.setBlock(pos.above(), fullGrowth, Constants.BlockFlags.DEFAULT);
} else {
BlockState growthState = state.setValue(STAGE, growth + 1);
world.setBlock(pos, growthState, Constants.BlockFlags.DEFAULT | Constants.BlockFlags.NO_RERENDER);
}
}
}
Aggregations