Posted May 12, 201312 yr I have created a throw-able bomb(grenade i guess) but it doesn't explode if i throw it forward or down i have to throw it up into the air and it must com back down to the ground it doesn't even work if i throw it up at a tree it has to come back to the ground. EntityBomb: package dudesmods.lozmod; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.Explosion; import net.minecraft.world.World; public class EntityBomb extends EntityThrowable { public EntityBomb(World par1World) { super(par1World); } public EntityBomb(World par1World, EntityLiving par2EntityLiving) { super(par1World, par2EntityLiving); } public EntityBomb(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); } protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0); } if(this.worldObj.isRemote) { explode(); } if(!this.worldObj.isRemote) { this.setDead(); } } private void explode() { if(!exploded) { exploded = true; worldObj.createExplosion(this, posX, posY, posZ, 4.0F, true); } } boolean exploded; } ItemBomb: package dudesmods.lozmod; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemBomb extends Item { public ItemBomb(int par1) { super(par1); setMaxStackSize(32); setCreativeTab(LOZmod.tabLozMod); } public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { if(!entityplayer.capabilities.isCreativeMode) { --itemstack.stackSize; } if (!world.isRemote) { world.spawnEntityInWorld(new EntityBomb(world, entityplayer)); } return itemstack; } } ModClassStuffs: bomb = new ItemBomb(16501).setUnlocalizedName("bomb").setMaxStackSize(32); EntityRegistry.registerGlobalEntityID(EntityBomb.class, "bomb", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntityBomb.class, "bomb", 2, this, 20, 2, false); (im aware i have no RenderingRegistry thing, it shows up as a white box and i'm fine with that until i get this to work. Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
May 12, 201312 yr Author Anyone? Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
May 12, 201312 yr If I had to take a shot in the dark, I'd say that it might be because the worldObj variable isn't set in time for the onImpact to know what it is. Try adding System.out.println(worldObj); in the onImpact method. Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
May 12, 201312 yr Author If I had to take a shot in the dark, I'd say that it might be because the worldObj variable isn't set in time for the onImpact to know what it is. Try adding System.out.println(worldObj); in the onImpact method. When just thrown i get: 2013-05-12 17:00:16 [iNFO] [sTDOUT] net.minecraft.world.WorldServer@55a8c7aa But when i throw it up, it comes down, and explodes i get: 2013-05-12 17:00:09 [iNFO] [sTDOUT] net.minecraft.world.WorldServer@55a8c7aa 2013-05-12 17:00:09 [iNFO] [sTDOUT] net.minecraft.client.multiplayer.WorldClient@4ba70c56 Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
May 12, 201312 yr Yea, that's what I figured. It sounds like your worldObj isn't being updated. There's your problem. =) Good luck! Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
May 12, 201312 yr Author Yea, that's what I figured. It sounds like your worldObj isn't being updated. There's your problem. =) Good luck! So... what do i do? Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
May 12, 201312 yr If I'm correct, you need to add in read and write NBT methods, so that information about the entity can be transferred. Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
May 12, 201312 yr Author If I'm correct, you need to add in read and write NBT methods, so that information about the entity can be transferred. NBT is beyond me. all i know is that it stores info like inventories and stuff. Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
May 12, 201312 yr Take a look at the EntityLargeFireball class as an example. Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
May 12, 201312 yr Author Take a look at the EntityLargeFireball class as an example. Still not working. Revised EntityBomb: package dudesmods.lozmod; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.Explosion; import net.minecraft.world.World; public class EntityBomb extends EntityThrowable { public int field_92057_e = 1; public EntityBomb(World par1World) { super(par1World); } public EntityBomb(World par1World, EntityLiving par2EntityLiving) { super(par1World, par2EntityLiving); } public EntityBomb(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); } protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0); } if(this.worldObj.isRemote) { explode(); } if(!this.worldObj.isRemote) { this.setDead(); } System.out.println(worldObj); } public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { super.writeEntityToNBT(par1NBTTagCompound); par1NBTTagCompound.setInteger("ExplosionLOZBomb", this.field_92057_e); } public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { super.readEntityFromNBT(par1NBTTagCompound); if (par1NBTTagCompound.hasKey("ExplosionLOZBomb")) { this.field_92057_e = par1NBTTagCompound.getInteger("ExplosionLOZBomb"); } } private void explode() { if(!exploded) { exploded = true; worldObj.createExplosion(this, posX, posY, posZ, 4.0F, true); } } boolean exploded; } Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
May 13, 201312 yr Do you have a PacketHandler clientside? I'm not sure how to do it using Forge Hooks (I'm pretty sure there is) but for all my mods I modify NetClientHandler in the receivedEntityPacket method. Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
May 13, 201312 yr Author Do you have a PacketHandler clientside? I'm not sure how to do it using Forge Hooks (I'm pretty sure there is) but for all my mods I modify NetClientHandler in the receivedEntityPacket method. My brain is starting to hurt a little. I've never had to use packet handlers in minecraft. Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
May 13, 201312 yr Author -Bump- Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
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.