I'm trying to do an late game item for my magic mod, it's basically an infinite fuel called Sun Piece. I want to add a feature that when a Sun piece is dropped it set the block on fire, I managed to make the fire appears but there's some weird bugs, it was creating floating fires, also the doesn't burn out and can't hurt mobs. I think that I'm doing something wrong, but since this is my first mod (Not first java) I have no idea. How would I do it properly?
Here's Sun Piece class:
public class SunPiece extends Item {
public SunPiece(){
super();
setUnlocalizedName("sunpiece");
setRegistryName("sunpiece");
setCreativeTab(CreativeTabs.MISC);
setMaxStackSize(1);
setContainerItem(this);
}
@Override
public int getItemBurnTime(ItemStack itemStack) {
return 12800;
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if(!entityIn.isBurning()) {
entityIn.setFire(10);
}
}
@Override
public boolean hasCustomEntity(ItemStack stack) {
return true;
}
@Override
public Entity createEntity(World world, Entity location, ItemStack itemstack){
EntityItem item = new EntityItem(world, location.posX, location.posY, location.posZ, itemstack) {
@Override
public boolean isEntityInvulnerable(DamageSource source) {
if(source.isFireDamage())return true;
return super.isEntityInvulnerable(source);
}
};
item.motionX = location.motionX;
item.motionY = location.motionY;
item.motionZ = location.motionZ;
item.isAirBorne = true;
item.setDefaultPickupDelay();
return item;
}
@Override
public boolean onEntityItemUpdate(EntityItem entityItem) {
World world = entityItem.world;
if(world.getBlockState(entityItem.getPosition()) == Blocks.AIR.getDefaultState()) {
if(world.getBlockState(entityItem.getPosition().down()) != Blocks.AIR.getDefaultState())
if(entityItem.motionZ == 0 && world.getBlockState(entityItem.getPosition()) != Blocks.FIRE.getDefaultState())
world.setBlockState(entityItem.getPosition(), Blocks.FIRE.getDefaultState());
}
return bFull3D;
}
}
I'm doing the fire set on metod onEntityItemUpdate()