Topic category: Help with Minecraft modding (Java Edition)
Hey, it's me again here with another complex idea I need help with.
I want my entity throwable to have a boomerang type function. So I kind of know the function of this. I have code for damaging the entity. But I need help with actual code for the rest of it. here is my idea for the mechanic:
so, entity throwable dissapears when it hits a block or entity is because of set dead. what I need is to delete that part (I need it later though) and add in a motion, so in place of set dead when it hits a block or entity it has a motion. When it hits an entity or a block the motion will return/be backwards. Then I need CollideWithPlayer that will 1. Set dead the entity and 2. give the player the item back.
If anyone wants to help or has code or something please reply. I am working in 1.7.10 version.
@#19.1
boolean hasCollided = false;
@Override
public void onUpdate() {
if(hasCollided){
super.onUpdate();
inAirTicks++;
if(inAirTicks > 60){
setDead();
}
}
}
this does not work, I am not sure If I did it correctly though.
Did you set the bool on collision to true?
@#20
boolean hasCollided = true;
@Override
public void onUpdate() {
if(hasCollided){
super.onUpdate();
inAirTicks++;
if(inAirTicks > 60){
setDead();
}
}
}
I mean on collison with entity!
Hmm, So i have been trying for a 3 weeks now, trying to have it so when my projectile hits the player it setDead and gives the player an item. I tried but could not get mop instance of entity player to work, so I am trying this:
private void returnToPlayer(boolean catched)
{
if (this.shootingEntity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer)this.shootingEntity;
if (!player.inventory.addItemStackToInventory(this.inventory.get(mcreator_stevensShield.block)));
{
if(!this.worldObj.isRemote)
this.worldObj.spawnEntityInWorld(
new EntityItem(
this.worldObj
, (catched)? this.posX : this.shootingEntity.posX
, (catched)? this.posY : this.shootingEntity.posY
, (catched)? this.posZ : this.shootingEntity.posZ
, this.inventory.get(mcreator_stevensShield.block)));
}
}
}
but this is also wrong, can someone please point me in right direction? I am really stuck on this.
@#22
I am thinking that this code is not useable at all, I must use mop instance of entityplayer, but I am not sure how to have proper code for giving player item.
@#21
Hmm, I think maybe I need mop instance of EntityPlayer to make it so when projectile hits player it setDead and gives the player an item.