Jump to content

[SOLVED(Finally)][1.4.7]Gui not opening due to 'Not being a Network Mod'


Recommended Posts

Posted

Ok, so i have my tile entity, gui handler, container, slot, etc for my custom compressor type thing but whenever i right click on it in game the console 'yells' at me for not being a network mod. Any help would be good on fixing 'not being a network mod', I have no idea what it means by that or how to fix it.

 

-- Vemahk20

Posted

Having recently had a similar issue:

 

All I can say is that GUIs are a right pain in the ass and there are about four things that can happen that'll cause the error.

I'll try and find my particular issue when I get home, as it was a little more obscure.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Can you post your code please? That would make it much easier for us to help you with your problem.

 

Right... Code...

 

GUI Compressor

@SideOnly(Side.CLIENT)
public class GuiCompressor extends GuiContainer
{
    private TileEntityCompressor compressorInventory;

    public GuiCompressor(InventoryPlayer par1InventoryPlayer, TileEntityCompressor par2TileEntityCompressor)
    {
        super(new ContainerCompressor(par1InventoryPlayer, par2TileEntityCompressor));
        this.compressorInventory = par2TileEntityCompressor;
    }

    /**
     * Draw the foreground layer for the GuiContainer (everything in front of the items)
     */
    protected void drawGuiContainerForegroundLayer(int par1, int par2)
    {
        this.fontRenderer.drawString("Compressor", 60, 6, 4210752);
        this.fontRenderer.drawString("Inventory", 8, this.ySize - 96 + 2, 4210752);
    }

    /**
     * Draw the background layer for the GuiContainer (everything behind the items)
     */
    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    {
        int var4 = this.mc.renderEngine.getTexture("/gui/furnace.png");
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.renderEngine.bindTexture(var4);
        int var5 = (this.width - this.xSize) / 2;
        int var6 = (this.height - this.ySize) / 2;
        this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
        int var7;

        if (this.compressorInventory.isBurning())
        {
            var7 = this.compressorInventory.getBurnTimeRemainingScaled(12);
            this.drawTexturedModalRect(var5 + 56, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2);
        }

        var7 = this.compressorInventory.getCookProgressScaled(24);
        this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, var7 + 1, 16);
    }
}

GUI Handler

package IndustrialBreakout.Gui;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
import IndustrialBreakout.TileEntity.*;
import IndustrialBreakout.Containers.*;

public class IBGuiHandler implements IGuiHandler {
        //returns an instance of the Container you made earlier
        @Override
        public Object getServerGuiElement(int id, EntityPlayer player, World world,
                        int x, int y, int z) {
                TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
                if(tileEntity instanceof TileEntityCompressor){
                        return new ContainerCompressor(player.inventory, (TileEntityCompressor) tileEntity);
                }
                return null;
        }

        //returns an instance of the Gui you made earlier
        @Override
        public Object getClientGuiElement(int id, EntityPlayer player, World world,
                        int x, int y, int z) {
                TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
                if(tileEntity instanceof TileEntityCompressor){
                        return new GuiCompressor(player.inventory, (TileEntityCompressor) tileEntity);
                }
                return null;

        }
}

COntainter

package IndustrialBreakout.Containers;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import IndustrialBreakout.TileEntity.*;
import IndustrialBreakout.Machines.recipes.CompressorRecipes;
import IndustrialBreakout.Slot.*;
import IndustrialBreakout.*;

public class ContainerCompressor extends Container
{
    private TileEntityCompressor compressor;
    private int lastCookTime = 0;
    private int lastBurnTime = 0;
    private int lastItemBurnTime = 0;

    public ContainerCompressor(InventoryPlayer par1InventoryPlayer, TileEntityCompressor par2TileEntityCompressor)
    {
        this.compressor = par2TileEntityCompressor;
        this.addSlotToContainer(new Slot(par2TileEntityCompressor, 0, 56, 17));
        this.addSlotToContainer(new Slot(par2TileEntityCompressor, 1, 56, 53));
        this.addSlotToContainer(new SlotCompressor(par1InventoryPlayer.player, par2TileEntityCompressor, 2, 116, 35));
        int var3;

        for (var3 = 0; var3 < 3; ++var3)
        {
            for (int var4 = 0; var4 < 9; ++var4)
            {
                this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
            }
        }

        for (var3 = 0; var3 < 9; ++var3)
        {
            this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
        }
    }

    public void addCraftingToCrafters(ICrafting par1ICrafting)
    {
        super.addCraftingToCrafters(par1ICrafting);
        par1ICrafting.sendProgressBarUpdate(this, 0, this.compressor.compressorCookTime);
        par1ICrafting.sendProgressBarUpdate(this, 1, this.compressor.compressorBurnTime);
        par1ICrafting.sendProgressBarUpdate(this, 2, this.compressor.currentItemBurnTime);
    }

    /**
     * Looks for changes made in the container, sends them to every listener.
     */
    public void detectAndSendChanges()
    {
        super.detectAndSendChanges();

        for (int var1 = 0; var1 < this.crafters.size(); ++var1)
        {
            ICrafting var2 = (ICrafting)this.crafters.get(var1);

            if (this.lastCookTime != this.compressor.compressorCookTime)
            {
                var2.sendProgressBarUpdate(this, 0, this.compressor.compressorCookTime);
            }

            if (this.lastBurnTime != this.compressor.compressorBurnTime)
            {
                var2.sendProgressBarUpdate(this, 1, this.compressor.compressorBurnTime);
            }

            if (this.lastItemBurnTime != this.compressor.currentItemBurnTime)
            {
                var2.sendProgressBarUpdate(this, 2, this.compressor.currentItemBurnTime);
            }
        }

        this.lastCookTime = this.compressor.compressorCookTime;
        this.lastBurnTime = this.compressor.compressorBurnTime;
        this.lastItemBurnTime = this.compressor.currentItemBurnTime;
    }

    @SideOnly(Side.CLIENT)
    public void updateProgressBar(int par1, int par2)
    {
        if (par1 == 0)
        {
            this.compressor.compressorCookTime = par2;
        }

        if (par1 == 1)
        {
            this.compressor.compressorBurnTime = par2;
        }

        if (par1 == 2)
        {
            this.compressor.currentItemBurnTime = par2;
        }
    }

    public boolean canInteractWith(EntityPlayer par1EntityPlayer)
    {
        return this.compressor.isUseableByPlayer(par1EntityPlayer);
    }

    /**
     * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
     */
    public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
    {
        ItemStack var3 = null;
        Slot var4 = (Slot)this.inventorySlots.get(par2);

        if (var4 != null && var4.getHasStack())
        {
            ItemStack var5 = var4.getStack();
            var3 = var5.copy();

            if (par2 == 2)
            {
                if (!this.mergeItemStack(var5, 3, 39, true))
                {
                    return null;
                }

                var4.onSlotChange(var5, var3);
            }
            else if (par2 != 1 && par2 != 0)
            {
                if (CompressorRecipes.smelting().getSmeltingResult(var5) != null)
                {
                    if (!this.mergeItemStack(var5, 0, 1, false))
                    {
                        return null;
                    }
                }
                else if (TileEntityCompressor.isItemFuel(var5))
                {
                    if (!this.mergeItemStack(var5, 1, 2, false))
                    {
                        return null;
                    }
                }
                else if (par2 >= 3 && par2 < 30)
                {
                    if (!this.mergeItemStack(var5, 30, 39, false))
                    {
                        return null;
                    }
                }
                else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(var5, 3, 30, false))
                {
                    return null;
                }
            }
            else if (!this.mergeItemStack(var5, 3, 39, false))
            {
                return null;
            }

            if (var5.stackSize == 0)
            {
                var4.putStack((ItemStack)null);
            }
            else
            {
                var4.onSlotChanged();
            }

            if (var5.stackSize == var3.stackSize)
            {
                return null;
            }

            var4.onPickupFromSlot(par1EntityPlayer, var5);
        }

        return var3;
    }
}

Compressor

package IndustrialBreakout.Machines;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import IndustrialBreakout.*;
import IndustrialBreakout.TileEntity.*;

public class BlockIBMachineCompressor extends BlockContainer
{
    /**
     * Is the random generator used by compressor to drop the inventory contents in random directions.
     */
    private Random compressorRand = new Random();

    /** True if this is an active compressor, false if idle */
    private final boolean isActive;

    /**
     * This flag is used to prevent the compressor inventory to be dropped upon block removal, is used internally when the
     * compressor block changes from idle to active and vice-versa.
     */
    private static boolean keepCompressorInventory = false;

    public BlockIBMachineCompressor(int par1, boolean par2)
    {
        super(par1, Material.rock);
        this.isActive = par2;
        this.blockIndexInTexture = 45;
    }

    /**
     * Returns the ID of the items to drop on destruction.
     */
    public int idDropped(int par1, Random par2Random, int par3)
    {
        return Block.stoneOvenIdle.blockID;
    }

    /**
     * Called whenever the block is added into the world. Args: world, x, y, z
     */
    public void onBlockAdded(World par1World, int par2, int par3, int par4)
    {
        super.onBlockAdded(par1World, par2, par3, par4);
        this.setDefaultDirection(par1World, par2, par3, par4);
    }

    /**
     * set a blocks direction
     */
    private void setDefaultDirection(World par1World, int par2, int par3, int par4)
    {
        if (!par1World.isRemote)
        {
            int var5 = par1World.getBlockId(par2, par3, par4 - 1);
            int var6 = par1World.getBlockId(par2, par3, par4 + 1);
            int var7 = par1World.getBlockId(par2 - 1, par3, par4);
            int var8 = par1World.getBlockId(par2 + 1, par3, par4);
            byte var9 = 3;

            if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
            {
                var9 = 3;
            }

            if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
            {
                var9 = 2;
            }

            if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
            {
                var9 = 5;
            }

            if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
            {
                var9 = 4;
            }

            par1World.setBlockMetadataWithNotify(par2, par3, par4, var9);
        }
    }

    @SideOnly(Side.CLIENT)

    /**
     * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
     */
    public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        if (par5 == 1)
        {
            return this.blockIndexInTexture + 17;
        }
        else if (par5 == 0)
        {
            return this.blockIndexInTexture + 17;
        }
        else
        {
            int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
            return par5 != var6 ? this.blockIndexInTexture : (this.isActive ? this.blockIndexInTexture + 16 : this.blockIndexInTexture - 1);
        }
    }

    @SideOnly(Side.CLIENT)

    /**
     * A randomly called display update to be able to add particles or other items for display
     */
    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        if (this.isActive)
        {
            int var6 = par1World.getBlockMetadata(par2, par3, par4);
            float var7 = (float)par2 + 0.5F;
            float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
            float var9 = (float)par4 + 0.5F;
            float var10 = 0.52F;
            float var11 = par5Random.nextFloat() * 0.6F - 0.3F;

            if (var6 == 4)
            {
                par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 5)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 2)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 3)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
            }
        }
    }

    /**
     * Returns the block texture based on the side being looked at.  Args: side
     */
    public int getBlockTextureFromSide(int par1)
    {
        return par1 == 1 ? this.blockIndexInTexture + 17 : (par1 == 0 ? this.blockIndexInTexture + 17 : (par1 == 3 ? this.blockIndexInTexture - 1 : this.blockIndexInTexture));
    }

    /**
     * Called upon block activation (right click on the block.)
     */
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
    {
        if (world.isRemote)
        {
            return true;
        }
        else
        {
            player.openGui(mod_IndustrialBreakout.instance, 0, world, x, y, z);
        }
        return true;
    }

    /**
     * Update which block ID the compressor is using depending on whether or not it is burning
     */
    public static void updateCompressorBlockState(boolean par0, World par1World, int par2, int par3, int par4)
    {
        int var5 = par1World.getBlockMetadata(par2, par3, par4);
        TileEntity var6 = par1World.getBlockTileEntity(par2, par3, par4);
        keepCompressorInventory = true;

        if (par0)
        {
            par1World.setBlockWithNotify(par2, par3, par4, Block.stoneOvenActive.blockID);
        }
        else
        {
            par1World.setBlockWithNotify(par2, par3, par4, Block.stoneOvenIdle.blockID);
        }

        keepCompressorInventory = false;
        par1World.setBlockMetadataWithNotify(par2, par3, par4, var5);

        if (var6 != null)
        {
            var6.validate();
            par1World.setBlockTileEntity(par2, par3, par4, var6);
        }
    }

    /**
     * Returns a new instance of a block's tile entity class. Called on placing the block.
     */
    public TileEntity createNewTileEntity(World par1World)
    {
        return new IndustrialBreakout.TileEntity.TileEntityCompressor();
    }

    /**
     * Called when the block is placed in the world.
     */
    public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
    {
        int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

        if (var6 == 0)
        {
            par1World.setBlockMetadataWithNotify(par2, par3, par4, 2);
        }

        if (var6 == 1)
        {
            par1World.setBlockMetadataWithNotify(par2, par3, par4, 5);
        }

        if (var6 == 2)
        {
            par1World.setBlockMetadataWithNotify(par2, par3, par4, 3);
        }

        if (var6 == 3)
        {
            par1World.setBlockMetadataWithNotify(par2, par3, par4, 4);
        }
    }

    /**
     * ejects contained items into the world, and notifies neighbours of an update, as appropriate
     */
    public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
    {
        if (!keepCompressorInventory)
        {
            TileEntityCompressor var7 = (TileEntityCompressor)par1World.getBlockTileEntity(par2, par3, par4);

            if (var7 != null)
            {
                for (int var8 = 0; var8 < var7.getSizeInventory(); ++var8)
                {
                    ItemStack var9 = var7.getStackInSlot(var8);

                    if (var9 != null)
                    {
                        float var10 = this.compressorRand.nextFloat() * 0.8F + 0.1F;
                        float var11 = this.compressorRand.nextFloat() * 0.8F + 0.1F;
                        float var12 = this.compressorRand.nextFloat() * 0.8F + 0.1F;

                        while (var9.stackSize > 0)
                        {
                            int var13 = this.compressorRand.nextInt(21) + 10;

                            if (var13 > var9.stackSize)
                            {
                                var13 = var9.stackSize;
                            }

                            var9.stackSize -= var13;
                            EntityItem var14 = new EntityItem(par1World, (double)((float)par2 + var10), (double)((float)par3 + var11), (double)((float)par4 + var12), new ItemStack(var9.itemID, var13, var9.getItemDamage()));

                            if (var9.hasTagCompound())
                            {
                                var14.func_92014_d().setTagCompound((NBTTagCompound)var9.getTagCompound().copy());
                            }

                            float var15 = 0.05F;
                            var14.motionX = (double)((float)this.compressorRand.nextGaussian() * var15);
                            var14.motionY = (double)((float)this.compressorRand.nextGaussian() * var15 + 0.2F);
                            var14.motionZ = (double)((float)this.compressorRand.nextGaussian() * var15);
                            par1World.spawnEntityInWorld(var14);
                        }
                    }
                }
            }
        }

        super.breakBlock(par1World, par2, par3, par4, par5, par6);
    }
}

SlotCompressor

package IndustrialBreakout.Slot;

import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.AchievementList;
import net.minecraft.util.MathHelper;
import cpw.mods.fml.common.registry.GameRegistry;
import IndustrialBreakout.*;

public class SlotCompressor extends Slot
{
    /** The player that is using the GUI where this slot resides. */
    private EntityPlayer thePlayer;
    private int field_75228_b;

    public SlotCompressor(EntityPlayer par1EntityPlayer, IInventory par2IInventory, int par3, int par4, int par5)
    {
        super(par2IInventory, par3, par4, par5);
        this.thePlayer = par1EntityPlayer;
    }

    /**
     * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
     */
    public boolean isItemValid(ItemStack par1ItemStack)
    {
        return false;
    }

    /**
     * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
     * stack.
     */
    public ItemStack decrStackSize(int par1)
    {
        if (this.getHasStack())
        {
            this.field_75228_b += Math.min(par1, this.getStack().stackSize);
        }

        return super.decrStackSize(par1);
    }

    public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
    {
        this.onCrafting(par2ItemStack);
        super.onPickupFromSlot(par1EntityPlayer, par2ItemStack);
    }

    /**
     * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
     * internal count then calls onCrafting(item).
     */
    protected void onCrafting(ItemStack par1ItemStack, int par2)
    {
        this.field_75228_b += par2;
        this.onCrafting(par1ItemStack);
    }

    /**
     * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
     */
    protected void onCrafting(ItemStack par1ItemStack)
    {
        par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b);

        this.field_75228_b = 0;

        GameRegistry.onItemSmelted(thePlayer, par1ItemStack);
    }
}

TileEntityCompressor

package IndustrialBreakout.TileEntity;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import IndustrialBreakout.*;
import IndustrialBreakout.Machines.*;
import IndustrialBreakout.Machines.recipes.CompressorRecipes;

public class TileEntityCompressor extends TileEntity implements IInventory, ISidedInventory
{
    /**
     * The ItemStacks that hold the items currently being used in the compressor
     */
    private ItemStack[] compressorItemStacks = new ItemStack[3];

    /** The number of ticks that the compressor will keep burning */
    public int compressorBurnTime = 0;

    /**
     * The number of ticks that a fresh copy of the currently-burning item would keep the compressor burning for
     */
    public int currentItemBurnTime = 0;

    /** The number of ticks that the current item has been cooking for */
    public int compressorCookTime = 0;

    /**
     * Returns the number of slots in the inventory.
     */
    public int getSizeInventory()
    {
        return this.compressorItemStacks.length;
    }

    /**
     * Returns the stack in slot i
     */
    public ItemStack getStackInSlot(int par1)
    {
        return this.compressorItemStacks[par1];
    }

    /**
     * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
     * new stack.
     */
    public ItemStack decrStackSize(int par1, int par2)
    {
        if (this.compressorItemStacks[par1] != null)
        {
            ItemStack var3;

            if (this.compressorItemStacks[par1].stackSize <= par2)
            {
                var3 = this.compressorItemStacks[par1];
                this.compressorItemStacks[par1] = null;
                return var3;
            }
            else
            {
                var3 = this.compressorItemStacks[par1].splitStack(par2);

                if (this.compressorItemStacks[par1].stackSize == 0)
                {
                    this.compressorItemStacks[par1] = null;
                }

                return var3;
            }
        }
        else
        {
            return null;
        }
    }

    /**
     * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
     * like when you close a workbench GUI.
     */
    public ItemStack getStackInSlotOnClosing(int par1)
    {
        if (this.compressorItemStacks[par1] != null)
        {
            ItemStack var2 = this.compressorItemStacks[par1];
            this.compressorItemStacks[par1] = null;
            return var2;
        }
        else
        {
            return null;
        }
    }

    /**
     * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
     */
    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    {
        this.compressorItemStacks[par1] = par2ItemStack;

        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
        {
            par2ItemStack.stackSize = this.getInventoryStackLimit();
        }
    }

    /**
     * Returns the name of the inventory.
     */
    public String getInvName()
    {
        return "container.compressor";
    }

    
    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readFromNBT(par1NBTTagCompound);
        NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
        this.compressorItemStacks = new ItemStack[this.getSizeInventory()];

        for (int var3 = 0; var3 < var2.tagCount(); ++var3)
        {
            NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
            byte var5 = var4.getByte("Slot");

            if (var5 >= 0 && var5 < this.compressorItemStacks.length)
            {
                this.compressorItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
            }
        }

        this.compressorBurnTime = par1NBTTagCompound.getShort("BurnTime");
        this.compressorCookTime = par1NBTTagCompound.getShort("CookTime");
        this.currentItemBurnTime = getItemBurnTime(this.compressorItemStacks[1]);
    }
    
    
    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.writeToNBT(par1NBTTagCompound);
        par1NBTTagCompound.setShort("BurnTime", (short)this.compressorBurnTime);
        par1NBTTagCompound.setShort("CookTime", (short)this.compressorCookTime);
        NBTTagList var2 = new NBTTagList();

        for (int var3 = 0; var3 < this.compressorItemStacks.length; ++var3)
        {
            if (this.compressorItemStacks[var3] != null)
            {
                NBTTagCompound var4 = new NBTTagCompound();
                var4.setByte("Slot", (byte)var3);
                this.compressorItemStacks[var3].writeToNBT(var4);
                var2.appendTag(var4);
            }
        }

        par1NBTTagCompound.setTag("Items", var2);
    }

    /**
     * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
     * this more of a set than a get?*
     */
    public int getInventoryStackLimit()
    {
        return 64;
    }

    @SideOnly(Side.CLIENT)

    /**
     * Returns an integer between 0 and the passed value representing how close the current item is to being completely
     * cooked
     */
    public int getCookProgressScaled(int par1)
    {
        return this.compressorCookTime * par1 / 200;
    }

    @SideOnly(Side.CLIENT)

    /**
     * Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel
     * item, where 0 means that the item is exhausted and the passed value means that the item is fresh
     */
    public int getBurnTimeRemainingScaled(int par1)
    {
        if (this.currentItemBurnTime == 0)
        {
            this.currentItemBurnTime = 200;
        }

        return this.compressorBurnTime * par1 / this.currentItemBurnTime;
    }

    /**
     * Returns true if the compressor is currently burning
     */
    public boolean isBurning()
    {
        return this.compressorBurnTime > 0;
    }

    /**
     * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
     * ticks and creates a new spawn inside its implementation.
     */
    public void updateEntity()
    {
        boolean var1 = this.compressorBurnTime > 0;
        boolean var2 = false;

        if (this.compressorBurnTime > 0)
        {
            --this.compressorBurnTime;
        }

        if (!this.worldObj.isRemote)
        {
            if (this.compressorBurnTime == 0 && this.canSmelt())
            {
                this.currentItemBurnTime = this.compressorBurnTime = getItemBurnTime(this.compressorItemStacks[1]);

                if (this.compressorBurnTime > 0)
                {
                    var2 = true;

                    if (this.compressorItemStacks[1] != null)
                    {
                        --this.compressorItemStacks[1].stackSize;

                        if (this.compressorItemStacks[1].stackSize == 0)
                        {
                            this.compressorItemStacks[1] = this.compressorItemStacks[1].getItem().getContainerItemStack(compressorItemStacks[1]);
                        }
                    }
                }
            }

            if (this.isBurning() && this.canSmelt())
            {
                ++this.compressorCookTime;

                if (this.compressorCookTime == 200)
                {
                    this.compressorCookTime = 0;
                    this.smeltItem();
                    var2 = true;
                }
            }
            else
            {
                this.compressorCookTime = 0;
            }

            if (var1 != this.compressorBurnTime > 0)
            {
                var2 = true;
                BlockIBMachineCompressor.updateCompressorBlockState(this.compressorBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
            }
        }

        if (var2)
        {
            this.onInventoryChanged();
        }
    }

    /**
     * Returns true if the compressor can smelt an item, i.e. has a source item, destination stack isn't full, etc.
     */
    private boolean canSmelt()
    {
        if (this.compressorItemStacks[0] == null)
        {
            return false;
        }
        else
        {
            ItemStack var1 = CompressorRecipes.smelting().getSmeltingResult(this.compressorItemStacks[0]);
            if (var1 == null) return false;
            if (this.compressorItemStacks[2] == null) return true;
            if (!this.compressorItemStacks[2].isItemEqual(var1)) return false;
            int result = compressorItemStacks[2].stackSize + var1.stackSize;
            return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());
        }
    }

    /**
     * Turn one item from the compressor source stack into the appropriate smelted item in the compressor result stack
     */
    public void smeltItem()
    {
        if (this.canSmelt())
        {
            ItemStack var1 = CompressorRecipes.smelting().getSmeltingResult(this.compressorItemStacks[0]);

            if (this.compressorItemStacks[2] == null)
            {
                this.compressorItemStacks[2] = var1.copy();
            }
            else if (this.compressorItemStacks[2].isItemEqual(var1))
            {
                compressorItemStacks[2].stackSize += var1.stackSize;
            }

            --this.compressorItemStacks[0].stackSize;

            if (this.compressorItemStacks[0].stackSize <= 0)
            {
                this.compressorItemStacks[0] = null;
            }
        }
    }

    /**
     * Returns the number of ticks that the supplied fuel item will keep the compressor burning, or 0 if the item isn't
     * fuel
     */
    public static int getItemBurnTime(ItemStack par0ItemStack)
    {
        if (par0ItemStack == null)
        {
            return 0;
        }
        else
        {
            int var1 = par0ItemStack.getItem().itemID;
            Item var2 = par0ItemStack.getItem();

            if (par0ItemStack.getItem() instanceof ItemBlock && Block.blocksList[var1] != null)
            {
                Block var3 = Block.blocksList[var1];

                if (var3 == Block.woodSingleSlab)
                {
                    return 150;
                }

                if (var3.blockMaterial == Material.wood)
                {
                    return 300;
                }
            }

            if (var2 instanceof ItemTool && ((ItemTool) var2).getToolMaterialName().equals("WOOD")) return 200;
            if (var2 instanceof ItemSword && ((ItemSword) var2).func_77825_f().equals("WOOD")) return 200;
            if (var2 instanceof ItemHoe && ((ItemHoe) var2).func_77842_f().equals("WOOD")) return 200;
            if (var1 == Item.stick.itemID) return 100;
            if (var1 == Item.coal.itemID) return 1600;
            if (var1 == Item.bucketLava.itemID) return 20000;
            if (var1 == Block.sapling.blockID) return 100;
            if (var1 == Item.blazeRod.itemID) return 2400;
            return GameRegistry.getFuelValue(par0ItemStack);
        }
    }

    /**
     * Return true if item is a fuel source (getItemBurnTime() > 0).
     */
    public static boolean isItemFuel(ItemStack par0ItemStack)
    {
        return getItemBurnTime(par0ItemStack) > 0;
    }

    /**
     * Do not make give this method the name canInteractWith because it clashes with Container
     */
    public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
    {
        return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
    }

    public void openChest() {}

    public void closeChest() {}

    @Override
    public int getStartInventorySide(ForgeDirection side)
    {
        if (side == ForgeDirection.DOWN) return 1;
        if (side == ForgeDirection.UP) return 0;
        return 2;
    }

    @Override
    public int getSizeInventorySide(ForgeDirection side)
    {
        return 1;
    }
}

Main Mod File

package IndustrialBreakout;

import IndustrialBreakout.Gui.IBGuiHandler;
import IndustrialBreakout.Machines.BlockIBMachineCompressor;
import IndustrialBreakout.blocks.BlockIB;
import IndustrialBreakout.items.ItemIB;
import IndustrialBreakout.items.ItemIBAxe;
import IndustrialBreakout.items.ItemIBHoe;
import IndustrialBreakout.items.ItemIBPickaxe;
import IndustrialBreakout.items.ItemIBShovel;
import IndustrialBreakout.items.ItemIBSword;
import IndustrialBreakout.proxy.CommonProxy;
import IndustrialBreakout.world.WorldGeneratorIB;
import IndustrialBreakout.TileEntity.*;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import IndustrialBreakout.reference.*;

@Mod(modid = "industrialBreakout", name="Industrial Breakout", version="0.1 Beta")
@NetworkMod(clientSideRequired=true)
public class mod_IndustrialBreakout {

	public static WorldGeneratorIB worldGen = new WorldGeneratorIB();

        @Instance("mod_IndustrialBreakout")
        public static mod_IndustrialBreakout instance;
        
        @SidedProxy(clientSide="IndustrialBreakout.proxy.ClientProxy", serverSide="IndustrialBreakout.proxy.CommonProxy")
        public static CommonProxy proxy;
        
        @PreInit
        public void preInit(FMLPreInitializationEvent event) {
                // Stub Method
        }
        
        @Init
        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
                NetworkRegistry.instance().registerGuiHandler(this, new IBGuiHandler());
                GameRegistry.registerWorldGenerator(worldGen);
                fml();
                craft();
                smelt();
                name();
                register();
        }
        
        public void fml(){
        	MinecraftForge.setBlockHarvestLevel(oreTitanium, "pickaxe", 2);
        	MinecraftForge.setBlockHarvestLevel(oreChargedCoal, "pickaxe", 2);
        	MinecraftForge.setBlockHarvestLevel(compressedCobble, "pickaxe", 1);
        	MinecraftForge.setBlockHarvestLevel(compressedStone, "pickaxe", 1);
        	MinecraftForge.setBlockHarvestLevel(oreTin, "pickaxe", 2);
        	MinecraftForge.setBlockHarvestLevel(oreCopper, "pickaxe", 1);
        }
        
        public void craft(){
        	GameRegistry.addRecipe(new ItemStack(compressedCobble, 1), new Object[] {"###", "###", "###", '#', Block.cobblestone});
        	GameRegistry.addRecipe(new ItemStack(compressedStone, 1), new Object[] {"###", "###", "###", '#', Block.stone});
        	GameRegistry.addRecipe(new ItemStack(ingotBronze, 4), new Object[] {"##", "#$", '#', ingotCopper, '$', ingotTin});
        }
        
        public void smelt(){
        	GameRegistry.addSmelting(oreTitanium.blockID, new ItemStack(ingotTitanium, 1), 1.0F);
        	GameRegistry.addSmelting(oreTin.blockID, new ItemStack(ingotTin, 1), 1.0F);
        	GameRegistry.addSmelting(oreCopper.blockID, new ItemStack(ingotCopper, 1), 1.0F);
        	GameRegistry.addSmelting(compressedCobble.blockID, new ItemStack(compressedStone, 1), 0.0F);
        }
        
        public void name(){
        	//Blocks
        	LanguageRegistry.addName(compressedCobble, "Compressed Cobblestosne");
        	LanguageRegistry.addName(compressedStone, "Compressed Stone");
        	LanguageRegistry.addName(oreTitanium, "Titanium Ore");
        	LanguageRegistry.addName(oreChargedCoal, "Charged Coal Ore");
        	LanguageRegistry.addName(oreTin, "Tin Ore");
        	LanguageRegistry.addName(oreCopper, "Copper Ore");
        	LanguageRegistry.addName(blockCopper, "Copper Block");
        	LanguageRegistry.addName(blockTin, "Tin Block");
        	LanguageRegistry.addName(machineCompressorIdle, "Idle Compressor");
        	LanguageRegistry.addName(machineCompressorActive, "Active Compressor");
        	
        	//Items
        	LanguageRegistry.addName(ingotTitanium, "Titanium Ingot");
        	LanguageRegistry.addName(chargedCoal, "Charged Coal");
        	LanguageRegistry.addName(pickaxeTitanium, "Titanium Pickaxe");
        	LanguageRegistry.addName(adminPickaxe, "Pickaxe of the Admin");
        	LanguageRegistry.addName(ingotTin, "Tin Ingot");
        	LanguageRegistry.addName(ingotCopper, "Copper Ingot");
        	LanguageRegistry.addName(ingotBronze, "Bronze Ingot");
        	LanguageRegistry.addName(pickaxeBronze, "Bronze Pickaxe");
        	LanguageRegistry.addName(axeBronze, "Bronze Axe");
        	LanguageRegistry.addName(swordBronze, "Bronze Sword");
        	LanguageRegistry.addName(shovelBronze, "Bronze Shovel");
        	LanguageRegistry.addName(hoeBronze, "Bronze Hoe");
        }
        
	public void register(){
        	//Blocks
        	GameRegistry.registerBlock(compressedCobble, "Compressed Cobble");
        	GameRegistry.registerBlock(compressedStone, "Compressed Stone");
        	GameRegistry.registerBlock(oreTitanium, "Titanium Ore");
        	GameRegistry.registerBlock(oreChargedCoal, "Charged Coal Ore");
        	GameRegistry.registerBlock(oreTin, "Tin Ore");
        	GameRegistry.registerBlock(oreCopper, "Copper Ore");
        	GameRegistry.registerBlock(blockCopper, "Copper Block");
        	GameRegistry.registerBlock(blockTin, "Tin Block");
        	GameRegistry.registerBlock(machineCompressorIdle, "Idle Compressor");
        	GameRegistry.registerBlock(machineCompressorActive, "Active Compressor");
        	
        	//Items
        	GameRegistry.registerItem(ingotTitanium, "Titanium Ingot");
        	GameRegistry.registerItem(chargedCoal, "Charged Coal");
        	GameRegistry.registerItem(pickaxeTitanium, "Titanium Pickaxe");
        	GameRegistry.registerItem(adminPickaxe, "Pickaxe of the Admin");
        	GameRegistry.registerItem(ingotTin, "Tin Ingot");
        	GameRegistry.registerItem(ingotCopper, "Copper Ingot");
        	GameRegistry.registerItem(ingotBronze, "Bronze Ingot");
        	GameRegistry.registerItem(pickaxeBronze, "Bronze Pickaxe");
        	GameRegistry.registerItem(axeBronze, "Bronze Axe");
        	GameRegistry.registerItem(swordBronze, "Bronze Sword");
        	GameRegistry.registerItem(shovelBronze, "Bronze Shovel");
        	GameRegistry.registerItem(hoeBronze, "Bronze Hoe");
        	
        	//Tile Entities
        	GameRegistry.registerTileEntity(TileEntityCompressor.class, "Compressor");
        }

        //Tool Materials
        public static EnumToolMaterial Titanium = EnumHelper.addToolMaterial("titanium", 2, 2000, 7.0F, 3, 16);
        public static EnumToolMaterial Bronze = EnumHelper.addToolMaterial("bronze", 2, 512, 6.0F, 3, 10);
        
        //Armor Materials
        
        //Items
        public static final Item ingotTitanium = (new ItemIB(200, 0)).setItemName("ingotTitanium").setCreativeTab(CreativeTabs.tabMaterials);
        public static final Item chargedCoal = (new ItemIB(201, 1)).setItemName("chargedCoal").setCreativeTab(CreativeTabs.tabMaterials);
        public static final Item pickaxeTitanium = (new ItemIBPickaxe(202, 2, Titanium)).setItemName("pickaxeTitanium");
        public static final Item adminPickaxe = (new ItemIBPickaxe(203, 3, EnumHelper.addToolMaterial("adminPick", 4, -1, 100.0F, 20, 100))).setItemName("adminPickaxe");
        public static final Item ingotTin = (new ItemIB(204, 4)).setItemName("ingotTin").setCreativeTab(CreativeTabs.tabMaterials);
        public static final Item ingotCopper = (new ItemIB(205, 5)).setItemName("ingotCopper").setCreativeTab(CreativeTabs.tabMaterials);
        public static final Item ingotBronze = (new ItemIB(206, 6)).setItemName("ingotBronze").setCreativeTab(CreativeTabs.tabMaterials);
        public static final Item pickaxeBronze = (new ItemIBPickaxe(207, 7, Bronze)).setItemName("pickaxeBronze");
        public static final Item axeBronze = (new ItemIBAxe(208, 8, Bronze)).setItemName("axeBronze");
        public static final Item swordBronze = (new ItemIBSword(209, 9, Bronze)).setItemName("swordBronze");
        public static final Item shovelBronze = (new ItemIBShovel(210, 10, Bronze)).setItemName("shovelBronze");
        public static final Item hoeBronze = (new ItemIBHoe(211, 11, Bronze)).setItemName("hoeBronze");        
        
        //Blocks
        public static final Block compressedCobble = new BlockIB(200, 0, Material.rock).setHardness(4.0F).setResistance(6.0F).setBlockName("compressedCobble").setCreativeTab(CreativeTabs.tabBlock);
        public static final Block compressedStone = new BlockIB(201, 1, Material.rock).setHardness(4.0F).setResistance(6.0F).setBlockName("compressedStone").setCreativeTab(CreativeTabs.tabBlock);
        public static final Block oreTitanium = new BlockIB(202, 2, Material.iron).setHardness(5.0F).setResistance(7.0F).setBlockName("oreTitanium").setCreativeTab(CreativeTabs.tabBlock);
        public static final Block oreChargedCoal = new BlockIB(203, 3, Material.iron).setHardness(5.0F).setResistance(7.0F).setBlockName("oreChargedCoal").setCreativeTab(CreativeTabs.tabBlock);
        public static final Block oreTin = new BlockIB(204, 4, Material.iron).setHardness(6.0F).setResistance(10.0F).setBlockName("oreTin").setCreativeTab(CreativeTabs.tabBlock);
        public static final Block oreCopper = new BlockIB(205, 5, Material.iron).setHardness(6.0F).setResistance(9.0F).setBlockName("oreCopper").setCreativeTab(CreativeTabs.tabBlock);
        public static final Block blockCopper = new BlockIB(208, 6, Material.iron).setHardness(7.0F).setResistance(10.0F).setBlockName("blockCopper").setCreativeTab(CreativeTabs.tabBlock);
        public static final Block blockTin = new BlockIB(209, 7, Material.iron).setHardness(8.0F).setResistance(11.0F).setBlockName("blockTin").setCreativeTab(CreativeTabs.tabBlock);
        		
        
        //Machines
        public static final Block machineCompressorIdle = (new BlockIBMachineCompressor(210, false)).setHardness(10.0F).setResistance(7.0F).setBlockName("machineCompressorIdle").setCreativeTab(CreativeTabs.tabBlock);
        public static final Block machineCompressorActive = (new BlockIBMachineCompressor(211, true)).setHardness(10.0F).setResistance(7.0F).setBlockName("machineCompressorActive").setCreativeTab(CreativeTabs.tabBlock).setLightValue(1.0F);
        //public static final Block machineExtractorIdle = (new BlockIBMachine(208, false, 2)).setHardness(11.0F).setResistance(7.0F).setBlockName("machineExtractorIdle").setCreativeTab(CreativeTabs.tabBlock);
        //public static final Block machineExtractorActive = (new BlockIBMachine(209, true, 3)).setHardness(11.0F).setResistance(7.0F).setBlockName("machineExtractorActive").setCreativeTab(CreativeTabs.tabBlock).setLightValue(1.0F);
        
        //Special Items
        
        //Armor
        //public static final Item helmetBronze = (new ItemIBArmor(212, 12, 4)).setBlockName("helmetBronze")
        //public static final Item chestplateBronze = (new ItemIBArmor(213, 13, 3)).setBlockName("chestplateBronze")
        //public static final Item leggingsBronze = (new ItemIBArmor(214, 14, 2)).setBlockName("leggingsBronze")
        //public static final Item bootsBronze = (new ItemIBArmor(215, 15, 1)).setBlockName("bootsBronze")
}

 

--Vemahk20

Posted

@NetworkMod(clientSideRequired=true)

 

This is insufficient for using GUIs.  You need to specify packet handlers for client and server as well, even if they don't do anything (because your mod is just adding chest-like objects).

 

If your GUI uses any kind of buttons or other functionality, you will need to pass data back and forth.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Well, i kind of gathered earlier that that line was the problem but i really have no idea how to change it to match my needs :(

Can you help me with that? :)

Posted

Yeah, you have to pass in your modid to your instance. But you also have to change your @NetworkMod annotation to:

 

clientSideRequired = true, serverSideRequired = false, clientPacketHandlerSpec = @SidedPacketHandler(channels = UCReferences.CHANNEL_NAME, packetHandler = ClientPacketHandler.class), serverPacketHandlerSpec = @SidedPacketHandler(channels = UCReferences.CHANNEL_NAME, packetHandler = ServerPacketHandler.class))

 

 

And in the ClientPacketHandler class:

 

package com.larsg310.uc.core.handlers;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;

public class ClientPacketHandler implements IPacketHandler
{
    @Override
    public void onPacketData(INetworkManager manager, Packet250CustomPayload payload, Player player)
    {
        DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data));
    }
}

 

 

And in your ServerPacketHandler class:

 

package com.larsg310.uc.core.handlers;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;

public class ServerPacketHandler implements IPacketHandler
{
    @Override
    public void onPacketData(INetworkManager manager, Packet250CustomPayload payload, Player player)
    {
        DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data));
        EntityPlayer sender = (EntityPlayer) player;
    }
}

 

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Yeah, you have to pass in your modid to your instance. But you also have to change your @NetworkMod annotation to:

 

clientSideRequired = true, serverSideRequired = false, clientPacketHandlerSpec = @SidedPacketHandler(channels = UCReferences.CHANNEL_NAME, packetHandler = ClientPacketHandler.class), serverPacketHandlerSpec = @SidedPacketHandler(channels = UCReferences.CHANNEL_NAME, packetHandler = ServerPacketHandler.class))

 

 

And in the ClientPacketHandler class:

 

package com.larsg310.uc.core.handlers;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;

public class ClientPacketHandler implements IPacketHandler
{
    @Override
    public void onPacketData(INetworkManager manager, Packet250CustomPayload payload, Player player)
    {
        DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data));
    }
}

 

 

And in your ServerPacketHandler class:

 

package com.larsg310.uc.core.handlers;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;

public class ServerPacketHandler implements IPacketHandler
{
    @Override
    public void onPacketData(INetworkManager manager, Packet250CustomPayload payload, Player player)
    {
        DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data));
        EntityPlayer sender = (EntityPlayer) player;
    }
}

 

 

I have no idea what you meant by the channel name... Uuhhgg... :)

In the sample of the @Mod thing... What's a channel? xD

Posted

The channels and Packet handlers are NOT needed to use Guis.

So I just needed to make my Instance my modid?

        @Instance("industrialBreakout")

        public static mod_IndustrialBreakout instance;

 

^^^???

 

EDIT: OMG IT WORKS, THANK YOU SOOOO MUCH!!!

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.