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

Posted

I'm attempting to create an explosion in the world when LivingAttackEvent is triggered and certain criteria are met, but, when said criteria are met, the console spams the debug println and subsequently spits out an apparently endless error message that repeats the same few lines. Could someone please explain what's wrong with this?

 

The event (with unrelated parts omitted):

@SubscribeEvent
public void onHit(LivingAttackEvent event)
{
	if(event.entityLiving instanceof EntityPlayer)
	{
		if(event.source.getSourceOfDamage() != null)
		{
			if(event.entityLiving.getCurrentArmor(2) != null)
			{
				if(event.entityLiving.getCurrentArmor(2).getItem() instanceof ItemInlayArmor)
				{
					ItemStack armor = event.entityLiving.getCurrentArmor(2);
					if(armor.hasTagCompound())
					{
						if(armor.getTagCompound().getString("id").equals("minecraft:gunpowder"))
						{
							System.out.println("BANG!");
							event.entityLiving.worldObj.createExplosion(event.source.getSourceOfDamage(), event.source.getSourceOfDamage().posX, event.source.getSourceOfDamage().posY, event.source.getSourceOfDamage().posZ, 1F, true);
						}

One section of the repeating error:

at com.ferret.relics.handlers.RelicEventHandler.onHit(RelicEventHandler.java:120) ~[RelicEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_RelicEventHandler_onHit_LivingAttackEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138) ~[EventBus.class:?]
at net.minecraftforge.common.ForgeHooks.onLivingAttack(ForgeHooks.java:341) ~[ForgeHooks.class:?]
at net.minecraft.entity.player.EntityPlayer.attackEntityFrom(EntityPlayer.java:1125) ~[EntityPlayer.class:?]
at net.minecraft.entity.player.EntityPlayerMP.attackEntityFrom(EntityPlayerMP.java:594) ~[EntityPlayerMP.class:?]
at net.minecraft.world.Explosion.doExplosionA(Explosion.java:166) ~[Explosion.class:?]
at net.minecraft.world.WorldServer.newExplosion(WorldServer.java:1087) ~[WorldServer.class:?]
at net.minecraft.world.World.createExplosion(World.java:2362) ~[World.class:?]
at com.ferret.relics.handlers.RelicEventHandler.onHit(RelicEventHandler.java:120) ~[RelicEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_RelicEventHandler_onHit_LivingAttackEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138) ~[EventBus.class:?]
at net.minecraftforge.common.ForgeHooks.onLivingAttack(ForgeHooks.java:341) ~[ForgeHooks.class:?]
at net.minecraft.entity.player.EntityPlayer.attackEntityFrom(EntityPlayer.java:1125) ~[EntityPlayer.class:?]
at net.minecraft.entity.player.EntityPlayerMP.attackEntityFrom(EntityPlayerMP.java:594) ~[EntityPlayerMP.class:?]
at net.minecraft.world.Explosion.doExplosionA(Explosion.java:166) ~[Explosion.class:?]
at net.minecraft.world.WorldServer.newExplosion(WorldServer.java:1087) ~[WorldServer.class:?]
at net.minecraft.world.World.createExplosion(World.java:2362) ~[World.class:?]

I am not sure, but it might be that an explosion triggers LivingAttackEvent.. so in your condition you might want to check if the source is an explosion and if it is do nothing

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.