Squander Posted June 3, 2023 Posted June 3, 2023 @SubscribeEvent public static void onAttachToEntity(AttachCapabilitiesEvent<Entity> event){ if(event.getObject() instanceof Player player){ event.addCapability(Helper.createRL("player_data"), new PlayerData(player)); } } public PlayerData(Player player) { this.player = player; this.setCurrentEnergy(this.getMaxEnergy()); } public int getMaxEnergy() { return (int) this.player.getAttributeValue(AttributeInit.MAX_ENERGY.get()); } and console log https://gist.github.com/MatyBotStorage/138473d7c4c7a43ad4b453baa4fda529 Quote
ChampionAsh5357 Posted June 5, 2023 Posted June 5, 2023 Why do you need a capability if you are using an attribute instead? You should not need to intermingle the two systems like this. Quote
Recommended Posts
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.