February 8, 20223 yr Author @SubscribeEvent public void onPlayerPreTick(final TickEvent.PlayerTickEvent event ,final AttachCapabilitiesEvent<Entity> event1){ Player player = event.player; boolean iof = player instanceof Player; if (iof ==true) { LazyOptional<MyCapabilityInterface> stats1 = player.getCapability(MyCapability.INSTANCE); MyCapabilityInterface myCapabilityInterface = stats1.orElseThrow(IllegalStateException::new); myCapabilityInterface.tick(event.player); final MyCapabilityProviderEntity provider = new MyCapabilityProviderEntity(player); event1.addCapability(IDENTIFIER, provider); Is this what you mean? I'm getting an error on this one, but... Edited February 12, 20223 yr by ocome
February 9, 20223 yr Author Do you mean to call Event instead of tickevent and get each item from there? In the case of ManaOvarlay, it was good without using addCapability, and I thought it would be the same way this time, but I couldn't figure out why this was bad Edited February 9, 20223 yr by ocome
February 9, 20223 yr no, you need both the TickEvent which calls your custom logic each Tick and the AttachCapabilitiesEvent which adds the Capability to all Entities which should hava your Capability. Read the doc about Events it explains everything about how to use Events. If you don't know how to create a Event handler, I would recommend you to first learn the basics of java before modding minecraft
February 10, 20223 yr Author I understand. I'm stuck and will study the documentation and java a little deeper. if (event.phase == TickEvent.Phase.START) { MyCapabilityImplementation.tick(event.player); } By the way, is there any problem in creating it this way?
February 10, 20223 yr 7 hours ago, ocome said: By the way, is there any problem in creating it this way? looks okay but I would recommend you to check also the side, since you should call the logic only on server and if it's required update the client via a custom Packet
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.