November 9, 20213 yr Don't know about fire but I know there's a method which you can call on the instance of the lightning called something along the lines of "setEffectOnly" which will spawn a lightning that doesn't create fire and doesn't damage entities.
November 9, 20213 yr Author For a special one that I created Here is the code @Override public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { ItemStack itemStack = pPlayer.getItemInHand(pHand); if(itemStack.is(Items.DIAMOND)){ LightningBolt bolt = new LightningBolt(EntityType.LIGHTNING_BOLT, pLevel); bolt.setPos(pPos.getX(), pPos.getY(), pPos.getZ()); pLevel.addFreshEntity(bolt); }else pPlayer.sendMessage(new TextComponent("You have no diamond!"), Util.NIL_UUID); return InteractionResult.SUCCESS; }
November 9, 20213 yr use LightningBolt#setVisualOnly with parm true, this will stop the LightningBolt for damage Entities and place Fire, after that you need to call the damge function manualy, something like: List<Entity> entities = lightningBolt.level.getEntities(this, new AABB(this.getX() - 3.0D, this.getY() - 3.0D, this.getZ() - 3.0D, this.getX() + 3.0D, this.getY() + 6.0D + 3.0D, this.getZ() + 3.0D), Entity::isAlive); for(Entity entity : entities) { if (!net.minecraftforge.event.ForgeEventFactory.onEntityStruckByLightning(entity, this)) entity.thunderHit((ServerLevel)lightningBolt.level, this); } }
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.