Search in sources :

Example 6 with PacketFXSignal

use of forestry.core.network.packets.PacketFXSignal in project ForestryMC by ForestryMC.

the class FarmableSapling method plantSaplingAt.

@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
    ItemStack copy = germling.copy();
    player.setHeldItem(EnumHand.MAIN_HAND, copy);
    EnumActionResult actionResult = copy.onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
    player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
    if (actionResult == EnumActionResult.SUCCESS) {
        PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, Blocks.SAPLING.getDefaultState());
        NetworkUtil.sendNetworkPacket(packet, pos, world);
        return true;
    }
    return false;
}
Also used : EnumActionResult(net.minecraft.util.EnumActionResult) PacketFXSignal(forestry.core.network.packets.PacketFXSignal) ItemStack(net.minecraft.item.ItemStack)

Example 7 with PacketFXSignal

use of forestry.core.network.packets.PacketFXSignal in project ForestryMC by ForestryMC.

the class CropRubber method harvestBlock.

@Override
protected NonNullList<ItemStack> harvestBlock(World world, BlockPos pos) {
    NonNullList<ItemStack> harvested = NonNullList.create();
    harvested.add(PluginIC2.resin.copy());
    PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState);
    NetworkUtil.sendNetworkPacket(packet, pos, world);
    world.setBlockState(pos, replantState, Constants.FLAG_BLOCK_SYNC);
    return harvested;
}
Also used : PacketFXSignal(forestry.core.network.packets.PacketFXSignal) ItemStack(net.minecraft.item.ItemStack)

Example 8 with PacketFXSignal

use of forestry.core.network.packets.PacketFXSignal in project ForestryMC by ForestryMC.

the class BlockUtil method setBlockWithPlaceSound.

public static boolean setBlockWithPlaceSound(World world, BlockPos pos, IBlockState blockState) {
    if (world.setBlockState(pos, blockState)) {
        PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, blockState);
        NetworkUtil.sendNetworkPacket(packet, pos, world);
        return true;
    }
    return false;
}
Also used : PacketFXSignal(forestry.core.network.packets.PacketFXSignal)

Example 9 with PacketFXSignal

use of forestry.core.network.packets.PacketFXSignal in project ForestryMC by ForestryMC.

the class BlockUtil method setBlockWithBreakSound.

public static boolean setBlockWithBreakSound(World world, BlockPos pos, IBlockState blockState, IBlockState oldState) {
    if (world.setBlockState(pos, blockState)) {
        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 10 with PacketFXSignal

use of forestry.core.network.packets.PacketFXSignal in project ForestryMC by ForestryMC.

the class ItemGermlingGE method onItemRightClickPollen.

private static ActionResult<ItemStack> onItemRightClickPollen(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, BlockPos pos, ITree tree) {
    ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(worldIn, pos);
    if (checkPollinatable == null || !checkPollinatable.canMateWith(tree)) {
        return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
    }
    IPollinatable pollinatable = GeneticsUtil.getOrCreatePollinatable(playerIn.getGameProfile(), worldIn, pos, true);
    if (pollinatable == null || !pollinatable.canMateWith(tree)) {
        return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
    }
    if (worldIn.isRemote) {
        return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
    } else {
        pollinatable.mateWith(tree);
        IBlockState blockState = worldIn.getBlockState(pos);
        PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState);
        NetworkUtil.sendNetworkPacket(packet, pos, worldIn);
        if (!playerIn.capabilities.isCreativeMode) {
            itemStackIn.shrink(1);
        }
        return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
    }
}
Also used : ICheckPollinatable(forestry.api.genetics.ICheckPollinatable) IBlockState(net.minecraft.block.state.IBlockState) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) IPollinatable(forestry.api.genetics.IPollinatable) PacketFXSignal(forestry.core.network.packets.PacketFXSignal)

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