Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

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

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.