Posted December 19, 20222 yr 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? Edited December 19, 20222 yr by NatePlays95 grammar
December 19, 20222 yr EntityAttributeModificationEvent https://forge.gemwire.uk/wiki/Making_Entities#Entity_Attributes Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
December 19, 20222 yr Author 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.
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.