Jump to content

[1.15.2] Check if it is snowing in the chunk an entity is in


izofar

Recommended Posts

I am intercepting a LivingUpdateEvent, and have accessed event.getEntity.getWorld(), but don't know where to go from here. So far, I have found world#isRaining, but not one for snowing, so I figure I check if it is raining and if the biome is cold, but how do I find the biome? I suspect I can do this with the chunk provider, but I'm not sure, since all of the methods I've found on GitHub or past forums seems to make references to outdated fields (I even checked MCPBot to see if I could find some of these fields obfuscated, to no avail). Specifically, I can't seem to call world#getBiome

 

Edit: As of now, I have found World#func_226691_t_ which seems to return a biome given a BlockPos. From this I have:

world.func_226691_t_(player.getPosition()).getPrecipitation() == Biome.RainType.SNOW

 

 

However, this seems to only check the type of precipitation, not when it is precipitating.

Edited by izofar
Link to comment
Share on other sites

My recommendation would be to use World#isRaining in conjunction with Biome#getTemperature (with the biome obtained via World#getBiome). Though, it sounds like you're already doing that; why won't getBiome work for you?

 

Edit: My bad, I was a little too hasty; I've edited my answer.

Edited by imacatlolol
  • Like 2

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

24 minutes ago, imacatlolol said:

why won't getBiome work for you?

I'm not sure why, Eclipse is telling me net.minecraft.world.World has no method called getBiome. This is odd since the 1.15 source code I've seen have accessed it.

Link to comment
Share on other sites

13 minutes ago, izofar said:

Eclipse is telling me net.minecraft.world.World has no method called getBiome.

45 minutes ago, izofar said:

Edit: As of now, I have found World#func_226691_t_ which seems to return a biome given a BlockPos.

Sounds like an issue of using outdated MCP mappings. Make sure you're using the latest snapshot version (20200513-1.15.1 at the time of writing this).

  • Like 1

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

1 minute ago, imacatlolol said:

Sounds like an issue of using outdated MCP mappings. Make sure you're using the latest snapshot version (20200513-1.15.1 at the time of writing this).

Makes sense, considering I used the methods.csv of the latest snapshot to find World#func_226691_t_ in the first place :) 

  • Haha 1
Link to comment
Share on other sites

34 minutes ago, imacatlolol said:

Sounds like an issue of using outdated MCP mappings. Make sure you're using the latest snapshot version (20200513-1.15.1 at the time of writing this).

Unfortunately, I have never had to do this before. I changed the build.gradle accordingly:

mappings channel: 'snapshot', version: '20200513-1.15.1'

 

 then ran ./gradlew genRunEclipse, ./gradlew eclipse and ./gradlew --refresh-dependencies with success. This didn't invalidate the references I had before and what should be the updated references still don't work :/ am I missing a step?

 

Edit:

 

ExampleMod/src/main/java/com/jacobdil/dillmod/entity/ai/goal/CollideGoal.java:174: error: cannot find symbol
                    return this.world.func_226665_a__(this.entity, this.entity.getBoundingBox().offset(blockpos));
                                     ^
  symbol:   method func_226665_a__(MobEntity,AxisAlignedBB)
  location: variable world of type IWorldReader

 

That looks promising, but if only my IDE would follow along!

Edited by izofar
Link to comment
Share on other sites

4 minutes ago, izofar said:

This didn't invalidate the references I had before and what should be the updated references still don't work :/ am I missing a step?

Hmm, I don't use Eclipse myself so I'm not entirely sure if it's a problem with that or if it's something else... All I usually have to do is press a button which re-imports the Gradle project (I use IntelliJ IDEA). Not sure if Eclipse has a similar function somewhere.

 

You could also try deleting your Gradle cache to force it to refresh. There should be a .gradle folder in your computer's user directory, all you should have to do is delete the caches folder. Not sure if it'll work as I expect, but it may be worth a shot if you can't figure out anything else (unless someone who knows Eclipse better than me can provide some tips).

  • Thanks 1

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

15 minutes ago, imacatlolol said:

There should be a .gradle folder in your computer's user directory, all you should have to do is delete the caches folder.

It seems like I'm learning, since I did think to try this, and it worked! Thank you so much, you're a champ

  • Like 1
Link to comment
Share on other sites

30 minutes ago, izofar said:

This didn't invalidate the references I had before and what should be the updated references still don't work :/ am I missing a step?

Have you tried Right Click on Project -> Refresh?

Eclipse does not automatically refresh if there are changes done on the disk (that is not managed by Eclipse).

Seems to be fixed.

Edited by DavidM
  • Thanks 1

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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