Search in sources :

Example 11 with PacketFXSignal

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;
}
Also used : Block(net.minecraft.block.Block) PacketFXSignal(forestry.core.network.packets.PacketFXSignal) ItemStack(net.minecraft.item.ItemStack)

Example 12 with PacketFXSignal

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);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) PacketFXSignal(forestry.core.network.packets.PacketFXSignal) IFruitBearer(forestry.api.genetics.IFruitBearer)

Example 13 with PacketFXSignal

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;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) PacketFXSignal(forestry.core.network.packets.PacketFXSignal) ItemStack(net.minecraft.item.ItemStack)

Example 14 with PacketFXSignal

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;
}
Also used : PacketFXSignal(forestry.core.network.packets.PacketFXSignal)

Example 15 with PacketFXSignal

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;
}
Also used : PacketFXSignal(forestry.core.network.packets.PacketFXSignal) ItemStack(net.minecraft.item.ItemStack)

Aggregations

PacketFXSignal (forestry.core.network.packets.PacketFXSignal)15 ItemStack (net.minecraft.item.ItemStack)8 IBlockState (net.minecraft.block.state.IBlockState)5 Block (net.minecraft.block.Block)4 EnumActionResult (net.minecraft.util.EnumActionResult)2 ICheckPollinatable (forestry.api.genetics.ICheckPollinatable)1 IFruitBearer (forestry.api.genetics.IFruitBearer)1 IPollinatable (forestry.api.genetics.IPollinatable)1 IButterfly (forestry.api.lepidopterology.IButterfly)1 IButterflyNursery (forestry.api.lepidopterology.IButterflyNursery)1 BlockRegistryArboriculture (forestry.arboriculture.blocks.BlockRegistryArboriculture)1 TileSapling (forestry.arboriculture.tiles.TileSapling)1 ActionResult (net.minecraft.util.ActionResult)1