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.

NatePlays95

Members
  • Joined

  • Last visited

  1. Yep, that's what I'm looking for, thanks a bunch! I'm a bit worried it didn't work on an already existing world, but for new worlds it works perfectly fine.
  2. Ok, so, I understand that new entities have their attributes set by subscribing to EntityAttributeCreationEvent and all, including custom ones. I got that to work no problems. However, say I have a new Attribute: public static final DeferredRegister<Attribute> REGISTRY = DeferredRegister.create(ForgeRegistries.Keys.ATTRIBUTES, MhbMod.MODID); public static final RegistryObject<Attribute> DEFENSE = registerAttr("defense", () -> new RangedAttribute("attribute.mhb.defense", 0, 0, 1024)); private static <T extends Attribute> RegistryObject<T> registerAttr(final String name, final Supplier<T> sup) { return REGISTRY.register(name, sup); } And I want to add it to an existing entity type, like EntityType.PLAYER. This is what I had in mind: @SubscribeEvent public static void createAttributes(EntityAttributeCreationEvent event){ event.put(EntityType.PLAYER, AttributeSupplier.builder().add(DEFENSE.get(), 3).build() ); } It seemed really clever, but EntityAttributeCreationEvent itself will thrown an error if any individual entity type has more than one AttributeSupplier.Builder mapped. I also considered accessing the Map inside EntityAttributeCreationEvent and replacing the existing player mapping with my own, but not only is that destructive, but the variable is private anyway so that's dead. Clearly, this is not the right approach. What else could I do then? Should I add the Attribute later on on events like "entity joining the world / spawning" or "entity tick" so that any player entity can be selected?

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.