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;
}
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);
}
Aggregations