August 13, 20178 yr Use Entity#setItemStackToSlot to set the item in an entity's equipment slot. If the mob should always spawn with this equipment or always has a chance to spawn with it, override EntityLiving#setEquipmentBasedOnDifficulty to set the equipment and then override EntityLiving#onInitialSpawn to call it. If the equipment is specific to the way it's being spawned, set the equipment manually before spawning it. Edit: Forgot to mention that EntityLiving#setEquipmentBasedOnDifficulty needs to be called from EntityLiving#onInitialSpawn. Edited August 13, 20178 yr by Choonster Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
August 13, 20178 yr Author I'm doing this, but I don't know what to put in new ItemStack(), when it comes to my custom items @SubscribeEvent public static void onJacketSpawn(EntityJoinWorldEvent event) { if (!(event.getEntity() instanceof EntityMasterJacket)) { return; } EntityMasterJacket mj = (EntityMasterJacket) event.getEntity(); mj.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack()); } Edited August 13, 20178 yr by Plgue
August 13, 20178 yr Author Seems to be that the code stops here: if (!(event.getEntity() instanceof EntityMasterJacket)) { return; }
August 13, 20178 yr You probably need to do it in the entity's class. Choonster's Entity#setItemStackToSlot method is probably the best way to go.
August 13, 20178 yr 23 minutes ago, Plgue said: I'm doing this, but I don't know what to put in new ItemStack(), when it comes to my custom items Why are you using EntityJoinWorldEvent for your own entity? Look at the constructors of the ItemStack class to what parameters they require. You should have your Item and Block instances stored in static fields of a class (usually called something like ModItems/ModBlocks), you can get the instances from these fields to pass to the ItemStack constructor. Do you actually know Java? You need to have a solid understanding of both Java and OO programming in general to a make a mod. This forum isn't for helping people with basic Java issues. 13 minutes ago, Plgue said: Seems to be that the code stops here: Do you ever spawn an EntityMasterJacket? Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
August 13, 20178 yr 2 minutes ago, Plgue said: What method would I put it in? I explained that in my first reply. I've also just edited it to include a detail that I forgot (EntityLiving#setEquipmentBasedOnDifficulty needs to be called from EntityLiving#onInitialSpawn). Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
August 13, 20178 yr Author I'm sorry about not knowing too much about Minecraft coding, I know basic Java though.
August 13, 20178 yr Plgue I personally just looking into the zombie class to see how vanilla minecraft does it
August 13, 20178 yr Author This whole time the armor and items have been equipped, It's just not rendering for some reason
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.