use of com.builtbroken.mc.core.network.packet.PacketPlayerItem in project Engine by VoltzEngine-Project.
the class ItemBase method read.
//=============================================
//============== Network ====================
//=============================================
@Override
public void read(ByteBuf buf, EntityPlayer player, PacketType packet) {
if (packet instanceof PacketPlayerItem) {
int slot = ((PacketPlayerItem) packet).slotId;
ItemStack stack = player.inventory.getStackInSlot(slot);
if (stack != null) {
if (stack.getItem() == this) {
try {
node.readPacketData(buf, player, stack);
} catch (Exception e) {
Engine.logger().error("ItemBase#read() >> Unexpected error while handling packet on stack[" + stack + "] item[" + stack.getItem() + "] from packet[" + packet + "]", e);
}
} else if (Engine.runningAsDev) {
Engine.logger().error("ItemBase#read() >> stack in slot[" + slot + "] item is not an instance of " + this + " can not read packet.");
}
} else if (Engine.runningAsDev) {
Engine.logger().error("ItemBase#read() >> stack in slot[" + slot + "] item is null preventing packet reading.");
}
}
}
use of com.builtbroken.mc.core.network.packet.PacketPlayerItem in project ICBM-Classic by BuiltBrokenModding.
the class ItemRadarGun method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (world.isRemote) {
MovingObjectPosition objectMouseOver = player.rayTrace(200, 1);
TileEntity tileEntity = world.getTileEntity(objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ);
if (!(tileEntity instanceof ILauncherController)) {
Engine.instance.packetHandler.sendToServer(new PacketPlayerItem(player, objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ));
}
}
return stack;
}
use of com.builtbroken.mc.core.network.packet.PacketPlayerItem in project ICBM-Classic by BuiltBrokenModding.
the class GuiFrequency method syncHzSettingToServer.
public void syncHzSettingToServer(EntityPlayer player, float value) {
PacketPlayerItem packetPlayerItem = new PacketPlayerItem(player, player.inventory.currentItem, value);
Engine.instance.packetHandler.sendToServer(packetPlayerItem);
}
use of com.builtbroken.mc.core.network.packet.PacketPlayerItem in project ICBM-Classic by BuiltBrokenModding.
the class ItemLaserDetonator method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (world.isRemote) {
MovingObjectPosition objectMouseOver = player.rayTrace(200, 1);
TileEntity tileEntity = world.getTileEntity(objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ);
if (!(tileEntity instanceof ILauncherController)) {
Engine.instance.packetHandler.sendToServer(new PacketPlayerItem(player, objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ));
}
}
return stack;
}
Aggregations