• 1

    posted a message on Brand New 1.7 snapshot Survival server (No Whitelist)
    Now first off I am Kafes and i am a player of this server. Secondly first couple of days on this server i really had some good fun. I really liked the community thing that was going on. So i built myself a manor and started working. The neighbours were really helpfull and nice aswell. However i'm going to have to complain about some abusiveness going on in this server. I've seen some rise in the amount of trolling aswell. These are just my opinions which i might get banned for but i am not accusing anyone or anything. Just stating these. One thing Pyro i dislike an invisible man flying around handing presents to everyone in a survival server. The starting ender chest is great and all but... Also while i was in the server today my neighbours started being killed randomly by being teleported around, what was that all about? I reckon if you started playing survival and not play superhero that would be better. Cheers.

    Anyway here is my long thingy of ideas that you probably will just ignore but anyway good day friends!
    Posted in: PC Servers
  • 1

    posted a message on [ModLoader1.7.3] Adding Custom MOBs and MORE!
    Hey inlanoche, thanks for everything. Oh, and that poor gnome :sad.gif:

    Anyways, i was tinkering with my codes a bit. I figured a way to open inventory when right clicking a mob with.. an item. I though you could use it and am sharing it. ( with anyone)

    Although its a bit stupid because you can open the mobs inventory right away without taming but you can fit it in...

    I'm a bad guide and teacher, so i couldn't really make this tutorialish but i might edit this reply when i have time, which i don't right now.


    So , in your EntitySomething code add this:

        public boolean interact(EntityPlayer entityplayer)
        {
            ItemStack itemstack = entityplayer.inventory.getCurrentItem();
    
                if(itemstack != null && itemstack.itemID == Item.bone.shiftedIndex) 
                {
    
                    {
                        ModLoader.OpenGUI(entityplayer, new SomethingInventoryGui(entityplayer.inventory, inventory));
                    }
                    return true;
                } else
                	
                    return false;
                
    
          }


    This is where the game opens the inventory/gui when you right click it. As you can see in this part:

                if(itemstack != null && itemstack.itemID == Item.bone.shiftedIndex) 


    You must right click the mob with a bone to open its inventory.

    You must also add this below all your codes.

        public SomethingInventory inventory;


    SomethingInventory(entityplayer.inventory, inventory));


    There is a bit more you must add, here is the full code for EntitySomething.

    Full EntitySomething code(edit accordingly!):

    package net.minecraft.src;
    
    import java.util.List;
    import java.util.Random;
    
    public class EntitySomething extends EntityAnimal
    {
            public EntitySomething(World world)
            {
                    super(world);
                    inventory = new SomethingInventory(this);
                    texture = "/something.png";        // your mob texture 
                    setSize(0.9F*1.25F, 0.9F*1.25F);
                    moveSpeed = 0.75F;
                    //yOffset *= 6F;
            health = 15;
    
                               
            }
        public void writeEntityToNBT(NBTTagCompound nbttagcompound) 
        { 
            super.writeEntityToNBT(nbttagcompound); 
            nbttagcompound.setTag("Inventory", inventory.writeToNBT(new NBTTagList())); // it writes the inventory t
        } 
        
        public void onDeath(Entity entity)  //when mob dies
        { 
            
            inventory.dropAllItems();   // when dead drop all inventory! **
            super.onDeath(entity);
        }
        
        
     
        public void readEntityFromNBT(NBTTagCompound nbttagcompound) 
        { 
            super.readEntityFromNBT(nbttagcompound); 
            NBTTagList nbttaglist = nbttagcompound.getTagList("Inventory"); // must read inventory
            inventory.readFromNBT(nbttaglist);
        } 
     
        protected String getLivingSound()  // sounds, edit them accordingly...
        { 
            return "Something"; 
        } 
     
        protected String getHurtSound() 
        { 
            return "SomethingHurt"; 
        } 
     
        protected String getDeathSound() 
        { 
            return "SomethingDeath"; 
        } 
     
        protected float getSoundVolume() 
        { 
            return 0.6F; 
        } 
     
        protected int getDropItemId() 
        { 
            return 0; 
        } 
        
        protected void dropFewItems() // what the mob drops when killed
        {
            int i = rand.nextInt(3);
            for(int j = 0; j < i; j++)
            {
                dropItem(Item.leather.shiftedIndex, 1); //sometimes leather
            }
    
            i = rand.nextInt(3);
            for(int k = 0; k < i; k++)
            {
                dropItem(Item.egg.shiftedIndex, 1); // sometimes eggs
            }
        }
        
    
        public boolean interact(EntityPlayer entityplayer)
        {
            ItemStack itemstack = entityplayer.inventory.getCurrentItem();
    
                if(itemstack != null && itemstack.itemID == Item.bone.shiftedIndex)
                {
    
                    {
                        ModLoader.OpenGUI(entityplayer, new SomethingInventoryGui(entityplayer.inventory, inventory));
                    }
                    return true;
                } else
                	
                    return false;
                
    
          }
      
        public SomethingInventory inventory;
    }

    This here is the gui of the inventory. Here is the code for that one.

    SomethingInventoryGui:

    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3) braces deadcode 
    
    package net.minecraft.src;
    
    import net.minecraft.client.Minecraft;
    import org.lwjgl.opengl.GL11;
    
    // Referenced classes of package net.minecraft.src:
    //            GuiContainer, CJB_DogContainer, FontRenderer, RenderEngine, 
    //            InventoryPlayer, CJB_DogInventory
    
    public class SomethingInventoryGui extends GuiContainer
    {
    
        public SomethingInventoryGui(InventoryPlayer inventoryplayer, SomethingInventory somethinginventory)
        {
            super(new SomethingContainer(inventoryplayer, somethinginventory));
        }
    
        protected void drawGuiContainerForegroundLayer()
        {
            fontRenderer.drawString("Inventory", 52, 6, 0x404040); // name of inventory displaced on top
            fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
        }
    
        protected void drawGuiContainerBackgroundLayer(float f)
        {
            int i = mc.renderEngine.getTexture("/inventory.png"); //place for inventory texture
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            mc.renderEngine.bindTexture(i);
            int j = (width - xSize) / 2;
            int k = (height - ySize) / 2;
            drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
        }
    
        public boolean doesGuiPauseGame()
        {
            return true;
        }
    }
     

    Here is where you define your gui. You must make the texture too. Here is one:

            int i = mc.renderEngine.getTexture("/inventory.png"); //place for inventory texture


    http://www.2shared.com/photo/wVkMVbKB/inventory.html

    Now you also need the gui code, like so:

    SomethingInventory:

    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3) braces deadcode 
    
    package net.minecraft.src;
    
    
    // Referenced classes of package net.minecraft.src:
    //            IInventory, ItemStack, NBTTagCompound, NBTTagList, 
    //            SomethingEntity, EntityPlayer, ItemArmor
    
    public class SomethingInventory
        implements IInventory
    {
    
        public SomethingInventory(EntitySomething entitysomething) //your entity
        {
            inventory = new ItemStack[9];
            inventoryChanged = false;
            ent = entitysomething;
        }
    
        private int getInventorySlotContainItem(int i)
        {
            for(int j = 0; j < inventory.length; j++)
            {
                if(inventory[j] != null && inventory[j].itemID == i)
                {
                    return j;
                }
            }
    
            return -1;
        }
    
        public int storeItemStack(ItemStack itemstack)
        {
            for(int i = 0; i < inventory.length; i++)
            {
                if(inventory[i] != null && inventory[i].itemID == itemstack.itemID && inventory[i].isStackable() && inventory[i].stackSize < inventory[i].getMaxStackSize() && inventory[i].stackSize < getInventoryStackLimit() && (!inventory[i].getHasSubtypes() || inventory[i].getItemDamage() == itemstack.getItemDamage()))
                {
                    return i;
                }
            }
    
            return -1;
        }
    
        public int getFirstEmptyStack()
        {
            for(int i = 0; i < inventory.length; i++)
            {
                if(inventory[i] == null)
                {
                    return i;
                }
            }
    
            return -1;
        }
    
        private int storePartialItemStack(ItemStack itemstack)
        {
            int i = itemstack.itemID;
            int j = itemstack.stackSize;
            int k = storeItemStack(itemstack);
            if(k < 0)
            {
                k = getFirstEmptyStack();
            }
            if(k < 0)
            {
                return j;
            }
            if(inventory[k] == null)
            {
                inventory[k] = new ItemStack(i, 0, itemstack.getItemDamage());
            }
            int l = j;
            if(l > inventory[k].getMaxStackSize() - inventory[k].stackSize)
            {
                l = inventory[k].getMaxStackSize() - inventory[k].stackSize;
            }
            if(l > getInventoryStackLimit() - inventory[k].stackSize)
            {
                l = getInventoryStackLimit() - inventory[k].stackSize;
            }
            if(l == 0)
            {
                return j;
            } else
            {
                j -= l;
                inventory[k].stackSize += l;
                inventory[k].animationsToGo = 5;
                return j;
            }
        }
    
        public boolean consumeInventoryItem(int i)
        {
            int j = getInventorySlotContainItem(i);
            if(j < 0)
            {
                return false;
            }
            if(--inventory[j].stackSize <= 0)
            {
                inventory[j] = null;
            }
            return true;
        }
    
        public boolean addItemStackToInventory(ItemStack itemstack)
        {
            if(!itemstack.isItemDamaged())
            {
                int i;
                do
                {
                    i = itemstack.stackSize;
                    itemstack.stackSize = storePartialItemStack(itemstack);
                } while(itemstack.stackSize > 0 && itemstack.stackSize < i);
                return itemstack.stackSize < i;
            }
            int j = getFirstEmptyStack();
            if(j >= 0)
            {
                inventory[j] = ItemStack.copyItemStack(itemstack);
                itemstack.stackSize = 0;
                return true;
            } else
            {
                return false;
            }
        }
    
        public ItemStack decrStackSize(int i, int j)
        {
            ItemStack aitemstack[] = inventory;
            if(i >= inventory.length)
            {
                aitemstack = armorInventory;
                i -= inventory.length;
            }
            if(aitemstack[i] != null)
            {
                if(aitemstack[i].stackSize <= j)
                {
                    ItemStack itemstack = aitemstack[i];
                    aitemstack[i] = null;
                    return itemstack;
                }
                ItemStack itemstack1 = aitemstack[i].splitStack(j);
                if(aitemstack[i].stackSize == 0)
                {
                    aitemstack[i] = null;
                }
                return itemstack1;
            } else
            {
                return null;
            }
        }
    
        public void setInventorySlotContents(int i, ItemStack itemstack)
        {
            ItemStack aitemstack[] = inventory;
            if(i >= aitemstack.length)
            {
                i -= aitemstack.length;
                aitemstack = armorInventory;
            }
            aitemstack[i] = itemstack;
        }
    
        public NBTTagList writeToNBT(NBTTagList nbttaglist)
        {
            for(int i = 0; i < inventory.length; i++)
            {
                if(inventory[i] != null)
                {
                    NBTTagCompound nbttagcompound = new NBTTagCompound();
                    nbttagcompound.setByte("Slot", (byte)i);
                    inventory[i].writeToNBT(nbttagcompound);
                    nbttaglist.setTag(nbttagcompound);
                }
            }
    
            for(int j = 0; j < armorInventory.length; j++)
            {
                if(armorInventory[j] != null)
                {
                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                    nbttagcompound1.setByte("Slot", (byte)(j + 100));
                    armorInventory[j].writeToNBT(nbttagcompound1);
                    nbttaglist.setTag(nbttagcompound1);
                }
            }
    
            return nbttaglist;
        }
    
        public void readFromNBT(NBTTagList nbttaglist)
        {
            inventory = new ItemStack[9];
            armorInventory = new ItemStack[1];
            for(int i = 0; i < nbttaglist.tagCount(); i++)
            {
                NBTTagCompound nbttagcompound = (NBTTagCompound)nbttaglist.tagAt(i);
                int j = nbttagcompound.getByte("Slot") & 0xff;
                ItemStack itemstack = new ItemStack(nbttagcompound);
                if(itemstack.getItem() == null)
                {
                    continue;
                }
                if(j >= 0 && j < inventory.length)
                {
                    inventory[j] = itemstack;
                }
                if(j >= 100 && j < armorInventory.length + 100)
                {
                    armorInventory[j - 100] = itemstack;
                }
            }
    
        }
    
        public int getSizeInventory()
        {
            return inventory.length + 1;
        }
    
        public ItemStack getStackInSlot(int i)
        {
            ItemStack aitemstack[] = inventory;
            if(i >= aitemstack.length)
            {
                i -= aitemstack.length;
                aitemstack = armorInventory;
            }
            return aitemstack[i];
        }
    
        public String getInvName()
        {
            return "Inventory";
        }
    
        public int getInventoryStackLimit()
        {
            return 64;
        }
    
        public void onInventoryChanged()
        {
            inventoryChanged = true;
        }
    
        public boolean canInteractWith(EntityPlayer entityplayer)
        {
            if(ent.isDead)
            {
                return false;
            } else
            {
                return entityplayer.getDistanceSqToEntity(ent) <= 64D;
            }
        }
    
    
    
        public boolean func_28018_c(ItemStack itemstack)
        {
            for(int i = 0; i < armorInventory.length; i++)
            {
                if(armorInventory[i] != null && armorInventory[i].isStackEqual(itemstack))
                {
                    return true;
                }
            }
    
            for(int j = 0; j < inventory.length; j++)
            {
                if(inventory[j] != null && inventory[j].isStackEqual(itemstack))
                {
                    return true;
                }
            }
    
            return false;
        }
    
        public void dropAllItems()
        {
            for(int i = 0; i < inventory.length; i++)
            {
                if(inventory[i] != null)
                {
                    ent.entityDropItem(inventory[i], 0.0F);
                    inventory[i] = null;
                }
            }
    
    
        }
    
        public ItemStack inventory[];
        public ItemStack armorInventory[];
        public EntitySomething ent;
        public boolean inventoryChanged;
    }
     

    So in this one you MUST change the entity with yours or your entity will give an error. I used my EntitySomething here but you must change it with EntityCat and so on.

    You also need SomethingContainer code:

    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3) braces deadcode 
    
    package net.minecraft.src;
    
    import java.util.List;
    
    // Referenced classes of package net.minecraft.src:
    //            Container, IInventory, CJB_DogSlotArmor, Slot, 
    //            ItemStack, EntityPlayer
    
    public class SomethingContainer extends Container
    {
    
        public SomethingContainer(IInventory iinventory, IInventory iinventory1)
        {
            doginventory = iinventory1;
            for(int i = 0; i < 1; i++)
            {
                //addSlot(new CJB_DogSlotArmor(this, doginventory, doginventory.getSizeInventory() - 1 - i, 8, 8 + i * 18));
            }
    
            for(int j = 0; j < 3; j++)
            {
                for(int i1 = 0; i1 < 3; i1++)
                {
                    addSlot(new Slot(doginventory, i1 + j * 3, 62 + i1 * 18, 17 + j * 18));
                }
    
            }
    
            for(int k = 0; k < 3; k++)
            {
                for(int j1 = 0; j1 < 9; j1++)
                {
                    addSlot(new Slot(iinventory, j1 + k * 9 + 9, 8 + j1 * 18, 84 + k * 18));
                }
    
            }
    
            for(int l = 0; l < 9; l++)
            {
                addSlot(new Slot(iinventory, l, 8 + l * 18, 142));
            }
    
        }
    
        public boolean isUsableByPlayer(EntityPlayer entityplayer)
        {
            return doginventory.canInteractWith(entityplayer);
        }
    
        public ItemStack getStackInSlot(int i)
        {
            ItemStack itemstack = null;
            Slot slot = (Slot)slots.get(i);
            if(slot != null && slot.getHasStack())
            {
                ItemStack itemstack1 = slot.getStack();
                itemstack = itemstack1.copy();
                if(i >= 10 && i < 46)
                {
                    func_28125_a(itemstack1, 1, 10, false);
                } else
                {
                    func_28125_a(itemstack1, 10, 46, false);
                }
                if(itemstack1.stackSize == 0)
                {
                    slot.putStack(null);
                } else
                {
                    slot.onSlotChanged();
                }
                if(itemstack1.stackSize != itemstack.stackSize)
                {
                    slot.onPickupFromSlot(itemstack1);
                } else
                {
                    return null;
                }
            }
            return itemstack;
        }
    
        private IInventory doginventory;
    }


    After you are done with these, you should have an inventory pop up when you right click that Entity with a bone(you can edit). Also the entity will drop all of the items in its inventory upon death. Simple but can be coded furthermore to a more advanced code.

    Note: I wrote all these in a hurry, sorry. I didn't have much time while writing these so there might be something wrong.


    Posted in: Tutorials
  • 1

    posted a message on [ModLoader1.7.3] Adding Custom MOBs and MORE!
    PneumonicFungus i had the same problem, it was a long time ago and i don't remember however i do remember it being something about the mob. So the reason it crashes MIGHT be something about your mob. If you can't find it in your world too it probably is the problem. Check your mob codes out.

    If you still think your spawnerblock is bugged, try setting the mob that it spawns into a pig or another mob. If it crashes and doesn't spawn a pig too then your spawner is bugged, if it works then your mob is bugged.

    By the way inlanoche i love your tameable mob tutorial! You are a great help i hope you keep things up :smile.gif:
    Posted in: Tutorials
  • To post a comment, please .