Search in sources :

Example 1 with PacketPlayerItem

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.");
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) PacketPlayerItem(com.builtbroken.mc.core.network.packet.PacketPlayerItem)

Example 2 with PacketPlayerItem

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ILauncherController(resonant.api.explosion.ILauncherController) PacketPlayerItem(com.builtbroken.mc.core.network.packet.PacketPlayerItem)

Example 3 with PacketPlayerItem

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);
}
Also used : PacketPlayerItem(com.builtbroken.mc.core.network.packet.PacketPlayerItem)

Example 4 with 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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ILauncherController(resonant.api.explosion.ILauncherController) PacketPlayerItem(com.builtbroken.mc.core.network.packet.PacketPlayerItem)

Aggregations

PacketPlayerItem (com.builtbroken.mc.core.network.packet.PacketPlayerItem)4 TileEntity (net.minecraft.tileentity.TileEntity)2 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)2 ILauncherController (resonant.api.explosion.ILauncherController)2 ItemStack (net.minecraft.item.ItemStack)1