Posted September 1, 201411 yr 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.
September 1, 201411 yr 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!
September 1, 201411 yr Author 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.
September 1, 201411 yr Author 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.
September 1, 201411 yr I always use dropFewItems. Idk how to do enchants but you should look at the vanilla code for skeletons. Check out my mod, Realms of Chaos, here. If I helped you, be sure to press the "Thank You" button!
September 1, 201411 yr Author 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.