Jump to content

Recommended Posts

Posted

This is the item that my custom mob drops on death:

 

public class ItemPinkSweater extends ItemArmor {
    public ItemPinkSweater()
    {
        super(ItemArmor.ArmorMaterial.CLOTH, 0, 1);

        this.setTextureName("leather_chestplate");
        this.setMaxStackSize(1);
        this.setUnlocalizedName("pinkSweater");
    }
}

 

This is how my custom mob drops it:

 

    protected Item getDropItem()
    {
        return new ItemPinkSweater();
    }

 

When I look at my custom leather chestplate in NEI it renders fine (as an ordinary leather chestplate) but when my mob drops it, it has the purple/black broken texture and when I pick it up my game crashes with this error:

 

java.lang.NullPointerException: Rendering item
at net.minecraft.client.renderer.entity.RenderItem.func_94149_a(RenderItem.java:732)
at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:498)
at net.minecraft.client.renderer.entity.RenderItem.func_82406_b(RenderItem.java:565)
at net.minecraft.client.gui.GuiIngame.func_73832_a(GuiIngame.java:955)
at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:206)
at net.minecraftforge.client.GuiIngameForge.func_73830_a(GuiIngameForge.java:141)
at net.minecraft.client.renderer.EntityRenderer.func_78480_b(EntityRenderer.java:1038)
at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:990)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:887)
at net.minecraft.client.main.Main.main(SourceFile:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:286)
at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:376)
at org.multimc.EntryPoint.listen(EntryPoint.java:165)
at org.multimc.EntryPoint.main(EntryPoint.java:54)

I like trains.

Posted

Don't return a new instance of the item. Return the one that you register. For example, YourItemsClass.pink_sweater

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Posted

The thing is, I want each instance of my entity to drop a randomly enchanted pink sweater on death so I guess the getDropItem class isn't the right method to use.

 

Also enchants are property of the ItemStack, not the Item. I don't know what I was expecting.

I like trains.

Posted

I tried doing something like this in my entity class:

 

public void setDead()
    {
        super.setDead();

        this.entityDropItem(this.sweater, 0F);
    }

 

this.sweater is an ItemStack where the wrapped Item is the same instance as the one I registered but when my mob dies it drops 3 items but I can only pick 1 of them up. I can only destroy the other two by pouring lava over them.

I like trains.

Posted

Since I want the sweater drop to be rare I used dropRareDrop which worked great. All right so that's one hurdle down, several to go.

 

Enchanting is actually pretty easy if a bit strange:

 

EnchantmentHelper.addRandomEnchantment(new Random(), your_item_stack, number_of_levels);

 

And it adds random enchants appropriate to the itemm type and material. I say it's a bit strange because the method returns the ItemStack instance instead of simply being void. But oh well.

I like trains.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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