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

Heya,

I'm trying to make it so that my entity, the Quipper, becomes hostile and attacks everything nearby if anything gets hurt near it.  At the moment, I'm not worried about actually making them hostile, but triggering the event itself, and notifying myself with a console message.

Here is the code I used:

@Mod.EventBusSubscriber(modid = FeyWild.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class QuipperEvents {

    @SubscribeEvent
    public void attackEntitiesTrigger(LivingHurtEvent event) {
      	// Establish living entity, and its block position
        LivingEntity entity = event.getEntityLiving();
        BlockPos pos = event.getEntityLiving().blockPosition();
        World world = event.getEntityLiving().level;

        // Create a 20x20x20 block radius from where the entity is hurt
        AxisAlignedBB blockAABB = new AxisAlignedBB(pos).inflate(20, 20, 20);

        assert world != null;
      	// Checking for the amount of quippers in that radius
        List<QuipperEntity> entities = world.getEntities
                (EntityInit.QUIPPER.get(), blockAABB, dryadEntity -> true);
	// If there are more than 0 quippers in the radius, display message
        if (entities.size() > 0) {
            FeyWild.LOGGER.info("You've frenzied the quippers!");
        }
    }
}

I assume it's not working because I'm misinterpreting LivingEntityHurtEvent to mean something else, but if anyone could steer me in the right direction, that would be much appreciated.

The version you are using is no longer supported on this forum.

Please update to a modern version of Minecraft to receive support.

Currently supported versions are 1.19.2 (Latest) and 1.18.2 (LTS).

Guest
This topic is now closed to further replies.

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.