Jump to content

Recommended Posts

Posted

Have you looked at how vanilla animals (e.g. pig or sheep) do it?

 

Mob entities (which include animals) have goals, which are registered and run by the entity's GoalSelector object.  Every mob entity has a goal selector, which is public, and the goal selector has a getRunningGoals() method to get all of the currently-active goals.  Take a look at e.g. PigEntity and find the obviously-named goal which controls panic behaviour. That should be all the info you need.

 

It might actually be simpler just to check that the animal has a non-null getRevengeTarget()... depends on how much control you want over the process.  An animal can have a revenge target but not have a running panic goal if it can't find somewhere to flee to, for example.

  • Thanks 1
Posted (edited)
  On 2/19/2020 at 5:08 PM, DragonITA said:

@desht, wow, thanks a lot! I simply cant see the Vanilla code, but thank for your help!

Expand  

If you can't view vanilla code from your IDE, get that fixed ASAP. It's absolutely critical to be able to see how vanilla and Forge code does stuff, not to mention being able to set debugging breakpoints. 

Edited by desht
  • Like 1
Posted
  On 2/19/2020 at 5:50 PM, DragonITA said:

What is ASAP?

 

Expand  

As Soon As Possible

  • Like 1

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

  • 4 weeks later...
Posted (edited)
  On 2/19/2020 at 5:33 PM, desht said:

If you can't view vanilla code from your IDE, get that fixed ASAP. It's absolutely critical to be able to see how vanilla and Forge code does stuff, not to mention being able to set debugging breakpoints. 

Expand  

So, with the school i not have much time, but i tried to do what i can. I searched a lot about streams and optional, and this is what i actually have:

 

https://github.com/DragonGamerDevelopers/NewFantasyMod/blob/1.15.2/src/main/java/mod/dragonita/fantasymod/entities/UnicornEntity.java#L45

 

Now it say me that the optional was empty, i really not know why, as my entity walk, look me, if i attack it it flee (The panic), etc…. So i need help. I have done all what i have can do in the Java basic side, but i think that this was a problem more related to modding as Java basic. I have see the Vanilla of getRunningGoals, so normally it should work, so why it don‘t work?

Edited by DragonITA

New in Modding? == Still learning!

Posted
  On 3/14/2020 at 9:51 PM, loordgek said:
return entity.goalSelector.getRunningGoals().anyMatch(prioritizedGoal -> prioritizedGoal.getGoal().getClass() == TargetGoal);

 

Expand  

@loordgek, thanks for replying! I not am a expert in Java, but it always return false. It not should be the case. I am trying to make a animation if the entity was attacked and the Panic Goal was activated, i kill all my entity (i not have add a regular spawn) and attack the entity, but the Logger always say me that it was false, but i attacked the entity, so it can‘t be was false (as it run in a random position, so it was false), so i not understand why it was always false.

New in Modding? == Still learning!

Posted

I think it's a Mojang problem, or am I using it wrong? Because otherwise it's impossible to get a goal, and the function «getRunningGoals()» is also useless

  On 2/19/2020 at 4:56 PM, desht said:

It might actually be simpler just to check that the animal has a non-null getRevengeTarget()... depends on how much control you want over the process.  An animal can have a revenge target but not have a running panic goal if it can't find somewhere to flee to, for example.

Expand  

@desht, my entity extends Agreableentity, like a pig, and i don‘t think that a passive entity has a revengetarget.

New in Modding? == Still learning!

Posted
  On 3/17/2020 at 11:48 AM, DragonITA said:

How do you know this?

Expand  

Not sure if this is 100% correct, but unless something is graphics, sound, or input, I would pretty much guess that it's server-side, otherwise the client could corrupt/hack stuff.

Posted
  On 3/17/2020 at 12:23 PM, DragonITA said:

@Ugdhar, i should send a PacketBuffer, but i have a many questions: why and how.

Expand  

Unfortunately, not something I've messed with yet, so I can't help you. I was just explaining how (I'm guessing) the other person was figuring it was server side..

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Sorry for the late response, but the game opened and I made a world but it's stuck at 0% Here's the latest.log https://mclo.gs/peEb1R8 I disabled The Factory Must Grow and soulsweapons
    • Hey everyone! Two of my friends downloaded this modpack and are having an issue with the blocks loading in correctly. Grass looks like bamboo, waystones look like two barrels stacked on eachother, and wheat looks like water and stairs. What is this problem? How can we fix it? Neither of my other friends or myself had this issue. 
    • I removed Yung's cave biome mod and It wasnt in one of those biomes however the log file said the same line (([25Apr2025 21:20:15.500] [Flywheel Task Executor #5/WARN] [Embeddium-MixinTaintDetector/]: Mod(s) [oculus] are modifying Embeddium class me.jellysquid.mods.sodium.client.render.vertex.serializers.VertexSerializerRegistryImpl, which may cause instability.))
    • Note: i had a couple of ideas, but i just don't know how to execute them. The main idea was to make the new block (let's exemplify with a mixer) be essentially a clone of the mechanical mixer (different texture tho) that would have a different recipe type (instead of mixing, advanced_mixing) and i would copy all the create mod recipes and edit the processing time while also adding the tier dependent ones.
    • Hi! Before everything, thank you for even reading. I'm coming here in need of help making a few aspects for a create mod addon. It's an addon that aims to add almost the full periodic table with realistic ways of obtaining all the elements and capability of almost full automation. For what purpose? A techy armor and to go to the moon and rocky planets of the solar system. It'll have 3 different tiers of machines (mixer, millstone, crushing wheels): basic (just the normal create mod machines but renamed), advanced (25% faster and has recipes only possible for this tier and above) end elite (75% faster than basic and recipes only available for this tier). The problem is, I'm not a coder. I know less than the basics. I know how to do everything else but these machine tiers and i need some help if you can.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.