Posted December 11, 20213 yr Hi! I want to make a debug mod. One feature of it is to show the active goals over all living entities. So I made some code in my EventHandler: @SubscribeEvent public void showGoal(RenderNameplateEvent event) { if (event.getEntity instanceof ItemEntity || event.getEntity instanceof Player) return; if (((Mob) event.getEntity())goalSelector.getRunningGoals().toArray().length <= 0) return; ((Mob) event.getEntity()).goalSelector.getRunningGoals().forEach(goal -> { //Set the name to the goal that I want }); } The problem is, that event.getEntity() returns an Entity, but for getting the goals of the entity I need a Mob (no, there isn't an event.getEntityLiving()). How would I get the entity as a Mob? Ps: I can get the world of the entity with event.getEntity().getCommandSenderWorld(); Edited December 11, 20213 yr by OutCraft Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can Also: PLEASE use SPOILERS for logs!
December 11, 20213 yr Author 42 minutes ago, diesieben07 said: Learn basic Java, such as the instanceof operator and casting. The problem is that it gives me the living entity as Entity. I can cast it to Mob (I know Java, I know how to cast), but then I also can't get the goals because the Entity that I get doesn't have goals. Goals are only registered on Mobs and Entities that extend Mob Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can Also: PLEASE use SPOILERS for logs!
December 11, 20213 yr Author @SubscribeEvent public void showGoal(RenderNameplateEvent event) { Entity entity = event.getEntity(); System.out.println(entity + ": " + "Hi!"); <- This triggers for all entities ((Mob) entity).goalSelector.getRunningGoals().forEach(goal -> { System.out.println(entity + ": " + "Hi!"); <- This never triggers event.setContent(new TextComponent(goal.getGoal().getClass().getName())); }); System.out.println(((Mob) entity).goalSelector.getRunningGoals().toArray().length); <- This gives length 0 } Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can Also: PLEASE use SPOILERS for logs!
December 11, 20213 yr Author 3 minutes ago, diesieben07 said: Goals are a server side thing and not present on the client. Ahh, this makes sense! Can I get the goals with a clientside mod or do I need the mod on the Server and transfer packets? Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can Also: PLEASE use SPOILERS for logs!
December 11, 20213 yr Author Ok, thanks for your help Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can Also: PLEASE use SPOILERS for logs!
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.