Jump to content

Recommended Posts

Posted

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
  }
}

 

Posted
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 

Posted
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

Posted
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
Posted

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

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.