Jump to content

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


Skelyvelocirap

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