Jump to content

Recommended Posts

Posted

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.

Posted

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;
    }

 

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.