Bit more complex than the title suggests. Had a few other posts about making a throwing weapon, and this is a follow-up to that. How do I make my entity(The thrown object) drop itself when it lands? So far, I have the following on my entity file.
package com.nolwest.ionceium.entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class entityDiamondShard extends EntityThrowable{
public entityDiamondShard(World world){
super (world);
}
private static final ResourceLocation texture = new ResourceLocation("ic", "textures/entity/renderdiamondshard.png");
public entityDiamondShard(World world, EntityLivingBase entity){
super(world, entity);
}
public entityDiamondShard(World world, double x, double y, double z){
super(world, x, y, z);
}
/**
* Called when this EntityThrowable hits a block or entity.
*/
@Override
protected void onImpact(MovingObjectPosition mop){
if (mop.entityHit != null)
{
//Damage Here
float DiamondShardDamage = 8F;
mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), DiamondShardDamage);
}
for (int i = 0; i < 8; ++i)
{
this.worldObj.spawnParticle("crit", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}
//Kills it when it lands
if (!this.worldObj.isRemote)
{
this.setDead();
}
}
}
I have it set to die when it lands, as you can see. I just don't know how to, on that same location it landed, also drop a copy of the item used to throw it, a Diamond Shard in this case, next to it. I want it to be recoverable if it misses, whatever way that's possible, and this seemed the simplest to me.
I do not know all of the methods for creating mods just yet, but I'm getting the hang of the syntax needed for it. Soon enough I'll be able to do this on my own.. (Hopefully...)
Thanks! I won't be the easiest student, but I'll try to keep your life as easy as I can.
I understand your statement, but I don't know if you understood mine. I have absolutely no idea, nor found anything from googling, how to set up anything else as far as the dropping of the item. Not setting the location on death, or even how to spawn an entity, for the most part, at a given location other than at a player. I gtg for my night time, so I'll be back on in about 12 hours or so, have things to do tomorrow morning. Again, thanks for all your help. You have been a big help for my mod, Melonslise
It's quite similar to when you were spawning your projectile. You'll need to instantiate a new EntityItem and spawn it in the world with world.spawnEntityInWorld. Don't forget to spawn it on server side only.
It's pretty simple, you should've taken a look at the chicken code for example.
What do you mean by Chicken Code? The MC source code? I'll see if I can figure it out from there, as to get a bit more practice doing that. Then I wont have to make so many posts!
Bit more complex than the title suggests. Had a few other posts about making a throwing weapon, and this is a follow-up to that. How do I make my entity(The thrown object) drop itself when it lands? So far, I have the following on my entity file.
I have it set to die when it lands, as you can see. I just don't know how to, on that same location it landed, also drop a copy of the item used to throw it, a Diamond Shard in this case, next to it. I want it to be recoverable if it misses, whatever way that's possible, and this seemed the simplest to me.
I do not know all of the methods for creating mods just yet, but I'm getting the hang of the syntax needed for it. Soon enough I'll be able to do this on my own.. (Hopefully...)
Thanks! I won't be the easiest student, but I'll try to keep your life as easy as I can.
Check if your collision was a block a spawn a new itemStack with your item at the position of the entity on death.
I understand your statement, but I don't know if you understood mine. I have absolutely no idea, nor found anything from googling, how to set up anything else as far as the dropping of the item. Not setting the location on death, or even how to spawn an entity, for the most part, at a given location other than at a player. I gtg for my night time, so I'll be back on in about 12 hours or so, have things to do tomorrow morning. Again, thanks for all your help. You have been a big help for my mod, Melonslise
It's quite similar to when you were spawning your projectile. You'll need to instantiate a new EntityItem and spawn it in the world with world.spawnEntityInWorld. Don't forget to spawn it on server side only.
It's pretty simple, you should've taken a look at the chicken code for example.
What do you mean by Chicken Code? The MC source code? I'll see if I can figure it out from there, as to get a bit more practice doing that. Then I wont have to make so many posts!