Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.5] Cannot check if the player is in a specific biome


Recommended Posts

I'm trying to check if the player is in a swamp biome. For some reason, it doesn't want to work though. This is what an old post used to make it work(it was recommended to them) but for some reason it doesn't seam to work even being in the same versions. Can someone tell me what I'm doing wrong?

@Override
public boolean onEntitySwing(ItemStack stack, LivingEntity entity) {
  World world = entity.level;
  Biome entityBiome = world.getBiome(entity.blockPosition());
  if(entityBiome == ForgeRegistries.BIOMES.getValue(Biomes.SWAMP.getRegistryName())) {
    //REST OF THE CODE
  }
}

 

Link to post
Share on other sites
6 minutes ago, Skelyvelocirap said:

Ohhhhh, alright. I thought it included both. Hmmm, then is there another way i can do this?

You can use Registry#BIOMES and than do your logic 

Link to post
Share on other sites
1 minute ago, Skelyvelocirap said:

Registry#BIOMES? It doesn't show up for some reason. I get Registry#BIOME_REGISTRY and two other similar ones but not Registry#BIOMES. I tried the three other things and none of them are right.

I mean that but it dosen't work with Biomes, because you getting a RegistryKey<Biome>. You also can check if the Biome you get from the World eqauls Biomes#SWAMP

Link to post
Share on other sites
12 minutes ago, Skelyvelocirap said:

I tried to do that but it doesn't work because Biomes#SWAMP is a registry key while World#GetBiome() returns a biome. In other words its the same as using the Registry#BIOMES_REGISTRY.

Check if the RessourceLocation from the biome and the RegistryKey#location are equal

  • Like 1
Link to post
Share on other sites

Alright so, I had to mess with it. I don't know if its exactly what you were saying but thats the only way it seems to work.

entityBiome.getRegistryName().toString().matches(Biomes.SWAMP.location().toString()

This is the condition which seems to work now. Thanks for your help! :D

Link to post
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.

Guest
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.