use of forestry.core.network.packets.PacketFXSignal in project ForestryMC by ForestryMC.
the class CropDestroyDouble method harvestBlock.
@Override
protected NonNullList<ItemStack> harvestBlock(World world, BlockPos pos) {
Block block = blockState.getBlock();
Block blockUp = blockStateUp.getBlock();
NonNullList<ItemStack> harvested = NonNullList.create();
block.getDrops(harvested, world, pos, blockState, 0);
blockUp.getDrops(harvested, world, pos.up(), blockStateUp, 0);
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState);
NetworkUtil.sendNetworkPacket(packet, pos, world);
world.setBlockToAir(pos.up());
if (replantState != null) {
world.setBlockState(pos, replantState, Constants.FLAG_BLOCK_SYNC);
} else {
world.setBlockToAir(pos);
}
return harvested;
}
use of forestry.core.network.packets.PacketFXSignal in project ForestryMC by ForestryMC.
the class CropFruit method harvestBlock.
@Override
protected NonNullList<ItemStack> harvestBlock(World world, BlockPos pos) {
IFruitBearer tile = TileUtil.getTile(world, pos, IFruitBearer.class);
if (tile == null) {
return NonNullList.create();
}
IBlockState blockState = world.getBlockState(pos);
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState);
NetworkUtil.sendNetworkPacket(packet, pos, world);
return tile.pickFruit(ItemStack.EMPTY);
}
use of forestry.core.network.packets.PacketFXSignal in project ForestryMC by ForestryMC.
the class CropPeat method harvestBlock.
@Override
protected NonNullList<ItemStack> harvestBlock(World world, BlockPos pos) {
NonNullList<ItemStack> drops = NonNullList.create();
drops.add(ModuleCore.getItems().peat.getItemStack());
IBlockState blockState = world.getBlockState(pos);
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState);
NetworkUtil.sendNetworkPacket(packet, pos, world);
world.setBlockState(pos, Blocks.DIRT.getDefaultState(), Constants.FLAG_BLOCK_SYNC);
return drops;
}
use of forestry.core.network.packets.PacketFXSignal in project ForestryMC by ForestryMC.
the class BlockUtil method setBlockToAirWithSound.
public static boolean setBlockToAirWithSound(World world, BlockPos pos, IBlockState oldState) {
if (world.setBlockToAir(pos)) {
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, oldState);
NetworkUtil.sendNetworkPacket(packet, pos, world);
return true;
}
return false;
}
use of forestry.core.network.packets.PacketFXSignal in project ForestryMC by ForestryMC.
the class CropChorusFlower method harvestBlock.
@Override
protected NonNullList<ItemStack> harvestBlock(World world, BlockPos pos) {
NonNullList<ItemStack> harvested = NonNullList.create();
harvested.add(new ItemStack(Blocks.CHORUS_FLOWER));
float chance = ForgeEventFactory.fireBlockHarvesting(harvested, world, pos, BLOCK_STATE, 0, 1.0F, false, null);
harvested.removeIf(next -> world.rand.nextFloat() > chance);
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, BLOCK_STATE);
NetworkUtil.sendNetworkPacket(packet, pos, world);
world.setBlockToAir(pos);
return harvested;
}
Aggregations