Hello. I am working on a mod, and I am trying to spawn mobs. How do I do that? I have the event set up, just need code for spawning the mob into the world. I tried this, but the mob disappeared after a few moments:
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.item.ItemTossEvent;
public class Events {
@SubscribeEvent
public void itemDropped(ItemTossEvent e) {
System.out.println("Item Dropped:"+e.entityItem.getEntityItem().toString());
if (e.entityItem.getEntityItem().getItem() == TheMod.theItem) {
EntityPig pigToSpawn=new EntityPig(e.entityItem.worldObj);
pigToSpawn.posX=e.entity.posX;
pigToSpawn.posY=e.entity.posY;
pigToSpawn.posZ=e.entity.posZ;
e.entity.worldObj.spawnEntityInWorld(pigToSpawn);
e.entity.setDead();
}
};
}
Pretty sure they are disappearing because of e.entity.setDead();
That's killing the dropped item. I think the problem here is that they have directly set posX, posY & posZ instead of using Entity#setLocationAndAngles()(Short hand for the method setLocationAndAngles in the class EntityLivingBase).
That's killing the dropped item. I think the problem here is that they have directly set posX, posY & posZ instead of using Entity#setLocationAndAngles()(Short hand for the method setLocationAndAngles in the class EntityLivingBase).
oops my bad haven't messed with entities in over a month. but now i know lol.
Hello. I am working on a mod, and I am trying to spawn mobs. How do I do that? I have the event set up, just need code for spawning the mob into the world. I tried this, but the mob disappeared after a few moments:
I have made a mod!
Minecraft in Minecraft... kinda
Pretty sure they are disappearing because of e.entity.setDead();
I currently have three mods.
Dirty's Cotton 1.0.1 for 1.7.10: forum post
OP-ig Make pigs not useless! Curseforge
I'll get a banner one day. I'm busy
Dirty's Hardcore Vanilla Overhaul Mod(Cancelled until further notice): forum post
That's killing the dropped item. I think the problem here is that they have directly set posX, posY & posZ instead of using Entity#setLocationAndAngles()(Short hand for the method setLocationAndAngles in the class EntityLivingBase).
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
This is not the signature you are looking for.
Banners and such things
oops my bad haven't messed with entities in over a month. but now i know lol.
I currently have three mods.
Dirty's Cotton 1.0.1 for 1.7.10: forum post
OP-ig Make pigs not useless! Curseforge
I'll get a banner one day. I'm busy
Dirty's Hardcore Vanilla Overhaul Mod(Cancelled until further notice): forum post
setLocationAndAngles() did work. Thanks!
I have made a mod!
Minecraft in Minecraft... kinda
But now, I have this code:
Now they are submarining.
Also, how do I get them to face where the player is facing?
I have made a mod!
Minecraft in Minecraft... kinda