Posted June 21, 20214 yr 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 } }
June 21, 20214 yr ForgeRegistries cantains only the biomes that are add via mods, and not the vanilla Biomes
June 21, 20214 yr Author Ohhhhh, alright. I thought it included both. Hmmm, then is there another way i can do this?
June 21, 20214 yr 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
June 21, 20214 yr Author 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.
June 21, 20214 yr 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
June 21, 20214 yr Author 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.
June 21, 20214 yr 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
June 21, 20214 yr Author 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!
June 21, 20214 yr Author That works, thank you! I tried to do that yesterday which didn't work, i just noticed its because i forgot to get the registry name before doing #equals. Well thank you very much for your help!
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.