Search in sources :

Example 1 with MessageNBT

use of binnie.core.network.packet.MessageNBT in project Binnie by ForestryMC.

the class BlockFlower method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack heldItem = player.getHeldItemMainhand();
    if (heldItem.isEmpty() || heldItem.getItem() != BinnieCore.getFieldKit() || !player.isSneaking()) {
        return false;
    }
    if (world.isRemote) {
        return true;
    }
    TileEntity tile = world.getTileEntity(pos);
    if (!(tile instanceof TileEntityFlower)) {
        return true;
    }
    TileEntityFlower tileFlower = (TileEntityFlower) tile;
    IFlower flower = tileFlower.getFlower();
    if (flower == null) {
        return true;
    }
    IFlowerGenome flowerGenome = flower.getGenome();
    NBTTagCompound info = new NBTTagCompound();
    info.setString("Species", flowerGenome.getPrimary().getUID());
    info.setString("Species2", flowerGenome.getSecondary().getUID());
    info.setFloat("Age", flower.getAge() / flowerGenome.getLifespan());
    info.setShort("Colour", (short) flowerGenome.getPrimaryColor().getID());
    info.setShort("Colour2", (short) flowerGenome.getSecondaryColor().getID());
    info.setBoolean("Wilting", flower.isWilted());
    info.setBoolean("Flowered", flower.hasFlowered());
    Botany.proxy.sendToPlayer(new MessageNBT(PacketID.FIELDKIT.ordinal(), info), player);
    heldItem.damageItem(1, player);
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IFlowerGenome(binnie.botany.api.genetics.IFlowerGenome) MessageNBT(binnie.core.network.packet.MessageNBT) IFlower(binnie.botany.api.genetics.IFlower) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) TileEntityFlower(binnie.botany.tile.TileEntityFlower)

Example 2 with MessageNBT

use of binnie.core.network.packet.MessageNBT in project Binnie by ForestryMC.

the class GeneTracker method synchToPlayer.

public void synchToPlayer(EntityPlayer player) {
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    writeToNBT(nbttagcompound);
    Genetics.proxy.sendToPlayer(new MessageNBT(GeneticsPacket.GENE_TRACKER_SYNC.ordinal(), nbttagcompound), player);
}
Also used : MessageNBT(binnie.core.network.packet.MessageNBT) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

MessageNBT (binnie.core.network.packet.MessageNBT)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 IFlower (binnie.botany.api.genetics.IFlower)1 IFlowerGenome (binnie.botany.api.genetics.IFlowerGenome)1 TileEntityFlower (binnie.botany.tile.TileEntityFlower)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1