Posted September 26, 201312 yr Okay, I have my custom spawn eggs all set up and they work perfectly Except when I use them with a dispenser they only fire out the egg, not spawn the entity I've made my own dispenser behaviour class here package advmobs; import net.minecraft.block.BlockDispenser; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.IBlockSource; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemMonsterPlacer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; final class DispenserBehaviourAdvMobEgg extends BehaviorDefaultDispenseItem { /** * Dispense the specified stack, play the dispense sound and spawn particles. */ public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { EnumFacing enumfacing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata()); double d0 = par1IBlockSource.getX() + (double)enumfacing.getFrontOffsetX(); double d1 = (double)((float)par1IBlockSource.getYInt() + 0.2F); double d2 = par1IBlockSource.getZ() + (double)enumfacing.getFrontOffsetZ(); Entity entity = AdvMobsPlacer.spawnCreature(par1IBlockSource.getWorld(), par2ItemStack.getItemDamage(), d0, d1, d2); if (entity instanceof EntityLivingBase && par2ItemStack.hasDisplayName()) { ((EntityLiving)entity).setCustomNameTag(par2ItemStack.getDisplayName()); } par2ItemStack.splitStack(1); return par2ItemStack; } } It's basically the same as the vanilla one except I've subsituted ItemMonsterPlacer with my own According to another topic I read they said it needed to be registered, but didn't say how they managed it. I've searched, quite a lot, and can't find any answers on how to register a new dispenser behaviour, if you do actually need to, and I can't find anything about it in the code So, can anyone help me and show me how I'm supposed to register this? or explain why it isn't working? if you need code from my mob placer item I can provide. EDIT: I know this is probably gunna be something really easy, I just can't seem to get it
September 26, 201312 yr Look at net.minecraft.dispenser DispenserBehaviorMobEgg You'll probably need to duplicate that class for your spawn eggs and add the behavior to the dispenser behavior listing (see DispenserBehaviors). 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.
September 26, 201312 yr Author The DispenserBehaviours bit was what I was missing I knew it would be simple Thank you
September 26, 201312 yr Author Okay, scratch that, it's still not working I added in a new class for the registering package advmobs; import net.minecraft.block.BlockDispenser; import net.minecraft.dispenser.DispenserBehaviors; public class AdvMobBehaviours { public static void registerVanillaDispenserBehaviors() { BlockDispenser.dispenseBehaviorRegistry.putObject(Advmobs.advmobsplacer, new DispenserBehaviourAdvMobEgg()); } } and the DispenserBehaviourAdvMobEgg is the same as in my original post I tried adding BlockDispenser.dispenseBehaviorRegistry.putObject(Advmobs.advmobsplacer, new DispenserBehaviourAdvMobEgg()); into the main mod file but to no avail I've also tried changing the method name, extending DispenserBehavior with that name and another name so am I missing something else?
September 26, 201312 yr Are you making sure that this code is getting called? Also, when I mucked about with this, I called it in my mod's PostInit function, and it worked (but I was also adding custom behaviors to a custom dispenser). 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.
September 26, 201312 yr Author Yeah, I just needed to put it in the PostInit apparently Thank you ... again haha
September 26, 201312 yr Yeah, I just needed to put it in the PostInit apparently I'm not surprised. I had mine in postInit for a good reason (cough, probably because I backtracked the vanilla code to figure out when it registered its behaviors). 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.
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.