@SubscribeEvent
public static void crimsonIngotCraft(EntityJoinWorldEvent event){
Entity entity = event.getEntity();
World world = entity.world;
double posX = entity.getPosX();
double posY = entity.getPosY();
double posZ = entity.getPosZ();
if(entity instanceof ItemEntity && !(entity instanceof SpecialItemEntity)){
ItemEntity itemEntity = (ItemEntity) event.getEntity();
if(itemEntity.getItem().getItem() == itemInit.RED_PEARL.get()){
SpecialItemEntity ie = new SpecialItemEntity(entity.world,entity.getPosX(),entity.getPosY(),entity.getPosZ(),((ItemEntity) entity).getItem());
event.setCanceled(true);
SpecialItemEntity specialItemEntity = new SpecialItemEntity(world,posX,posY,posZ,((ItemEntity) entity).getItem().getStack());
}
}
}
I changed code into this and SpecialItemEntity clas is:
package com.azizd.thunderbird.entities;
import com.azizd.thunderbird.init.blockInit;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class SpecialItemEntity extends ItemEntity {
public SpecialItemEntity(World worldIn, double x, double y, double z, ItemStack stack) {
super(worldIn, x, y, z, stack);
}
@Override
public void tick() {
BlockPos pos= new BlockPos(getPosX(),getPosY(),getPosZ());
if(inWater){
this.setDead();
this.world.setBlockState(pos,blockInit.BLOCK_OF_RED_PEARL.get().getDefaultState());
}
}
}
The item deletes when i press the q button.