gnosticChemist Posted January 25, 2019 Posted January 25, 2019 (edited) 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() Edited January 26, 2019 by gnosticChemist Problem resolved Quote
mirk Posted January 26, 2019 Posted January 26, 2019 I'm not sure if you're supposed to compare BlockStates. Have you taken a look at how Flint & Steel spawns its fires? 1 Quote
gnosticChemist Posted January 26, 2019 Author Posted January 26, 2019 8 hours ago, mirk said: I'm not sure if you're supposed to compare BlockStates. Have you taken a look at how Flint & Steel spawns its fires? Thanks, it solved. When I see how Flint & Steel put fire I realized that my code doesn't give the flags that the fire need. I still have to verify if the item isn't flying because if is it creates flying fires that sometimes doesn't burn out, but is't work perfectly. Here's the code if anyone is having the same problem: @Override public boolean onEntityItemUpdate(EntityItem entityItem) { BlockPos pos = entityItem.getPosition(); World world = entityItem.world; if(world.isAirBlock(pos) && !world.isAirBlock(pos.down())) { world.setBlockState(entityItem.getPosition(), Blocks.FIRE.getDefaultState(),11); //This line /\ set the fire with the properly flags } return bFull3D; } Quote
Recommended Posts
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.