use of net.minecraft.state.properties.DoubleBlockHalf in project upgrade-aquatic by team-abnormals.
the class FloweringRushBlock method onBlockHarvested.
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
DoubleBlockHalf doubleblockhalf = state.get(HALF);
BlockPos blockpos = doubleblockhalf == DoubleBlockHalf.LOWER ? pos.up() : pos.down();
BlockState blockstate = worldIn.getBlockState(blockpos);
if (blockstate.getBlock() == this && blockstate.get(HALF) != doubleblockhalf) {
worldIn.playEvent(player, 2001, blockpos, Block.getStateId(blockstate));
if (!worldIn.isRemote && !player.isCreative()) {
spawnDrops(state, worldIn, pos, (TileEntity) null, player, player.getHeldItemMainhand());
spawnDrops(blockstate, worldIn, pos, (TileEntity) null, player, player.getHeldItemMainhand());
}
if (blockstate.get(HALF) == DoubleBlockHalf.LOWER) {
worldIn.destroyBlock(blockpos, false);
}
}
super.onBlockHarvested(worldIn, pos, state, player);
}
use of net.minecraft.state.properties.DoubleBlockHalf in project upgrade-aquatic by team-abnormals.
the class TallBeachgrassBlock method onBlockHarvested.
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
DoubleBlockHalf doubleblockhalf = state.get(HALF);
BlockPos blockpos = doubleblockhalf == DoubleBlockHalf.LOWER ? pos.up() : pos.down();
BlockState blockstate = worldIn.getBlockState(blockpos);
if (blockstate.getBlock() == this && blockstate.get(HALF) != doubleblockhalf) {
worldIn.setBlockState(blockpos, Blocks.AIR.getDefaultState(), 35);
worldIn.playEvent(player, 2001, blockpos, Block.getStateId(blockstate));
if (!worldIn.isRemote && !player.isCreative() && player.getHeldItemMainhand().getItem() instanceof ShearsItem) {
spawnAsEntity(worldIn, pos, new ItemStack(UABlocks.BEACHGRASS.get()));
spawnAsEntity(worldIn, pos.up(), new ItemStack(UABlocks.BEACHGRASS.get()));
} else if (!worldIn.isRemote && !player.isCreative() && !(player.getHeldItemMainhand().getItem() instanceof ShearsItem)) {
Random rand = new Random();
if (rand.nextFloat() < 0.125F) {
spawnAsEntity(worldIn, pos, new ItemStack(Items.BEETROOT_SEEDS));
}
}
}
super.onBlockHarvested(worldIn, pos, state, player);
}
use of net.minecraft.state.properties.DoubleBlockHalf in project FarmersDelight by vectorwing.
the class WildRiceBlock method updateShape.
@Override
public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
BlockState currentState = super.updateShape(stateIn, facing, facingState, worldIn, currentPos, facingPos);
DoubleBlockHalf half = stateIn.getValue(HALF);
if (!currentState.isAir()) {
worldIn.getLiquidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(worldIn));
}
if (facing.getAxis() != Direction.Axis.Y || half == DoubleBlockHalf.LOWER != (facing == Direction.UP) || facingState.getBlock() == this && facingState.getValue(HALF) != half) {
return half == DoubleBlockHalf.LOWER && facing == Direction.DOWN && !stateIn.canSurvive(worldIn, currentPos) ? Blocks.AIR.defaultBlockState() : stateIn;
} else {
return Blocks.AIR.defaultBlockState();
}
}
use of net.minecraft.state.properties.DoubleBlockHalf in project FarmersDelight by vectorwing.
the class WildRiceBlock method removeBottomHalf.
protected static void removeBottomHalf(World world, BlockPos pos, BlockState state, PlayerEntity player) {
DoubleBlockHalf half = state.getValue(HALF);
if (half == DoubleBlockHalf.UPPER) {
BlockPos floorPos = pos.below();
BlockState floorState = world.getBlockState(floorPos);
if (floorState.getBlock() == state.getBlock() && floorState.getValue(HALF) == DoubleBlockHalf.LOWER) {
world.setBlock(floorPos, Blocks.WATER.defaultBlockState(), 35);
world.levelEvent(player, 2001, floorPos, Block.getId(floorState));
}
}
}
use of net.minecraft.state.properties.DoubleBlockHalf in project minecolonies by ldtteam.
the class BlockScarecrow method use.
@Override
public ActionResultType use(final BlockState state, final World worldIn, final BlockPos pos, final PlayerEntity player, final Hand hand, final BlockRayTraceResult ray) {
// If the world is server, open the inventory of the field.
if (!worldIn.isClientSide) {
// Get the entity of the bottom half
DoubleBlockHalf half = state.getValue(HALF);
final TileEntity entity = worldIn.getBlockEntity(half == DoubleBlockHalf.UPPER ? pos.below() : pos);
if (entity instanceof ScarecrowTileEntity) {
NetworkHooks.openGui((ServerPlayerEntity) player, (ScarecrowTileEntity) entity, pos);
} else {
return ActionResultType.FAIL;
}
}
// This must succeed in Remote to stop more right click interactions like placing blocks
return ActionResultType.SUCCESS;
}
Aggregations