Hello! Im trying to get biome on player's position, if the player is in desert biome the variable "temperature" should increase but it doesn't. am i missing something?
package net.mcreator.drowningbelow.procedures;import net.minecraftforge.fml.common.Mod;import net.minecraftforge.eventbus.api.SubscribeEvent;import net.minecraftforge.eventbus.api.Event;import net.minecraftforge.event.TickEvent;import net.minecraft.world.entity.player.Player;import net.minecraft.world.entity.Entity;import net.minecraft.network.chat.Component;import net.minecraft.resources.ResourceLocation;import net.mcreator.drowningbelow.network.DrowningbelowModVariables;import javax.annotation.Nullable;import net.minecraft.world.level.LevelAccessor;import net.minecraft.core.BlockPos;import net.minecraft.world.level.Level;import net.minecraft.client.Minecraft;import net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator;import net.minecraft.server.MinecraftServer;import net.minecraft.world.level.biome.Biome;import java.io.Console;@Mod.EventBusSubscriberpublicclassTemperaturaProcedure{privatestatic final int TICKS_INTERVAL =60;// 60 ticks = 3 segundosprivatestaticint tickCounter =0;privatestatic final int TICK_BIOME_INTERVAL =60;privatestaticint tickBiomeCounter =0;@SubscribeEventpublicstaticvoid onPlayerTick(TickEvent.PlayerTickEvent event){if(event.phase ==TickEvent.Phase.END){
tickCounter++;
tickBiomeCounter++;if(tickCounter >= TICKS_INTERVAL){
tickCounter =0;
checkAndUpdateTemperature(event.player);}if(tickBiomeCounter >= TICK_BIOME_INTERVAL){
tickBiomeCounter =0;
execute(event, event.player.level(), event.player);}
displayTemperature(event.player);}}privatestaticvoid checkAndUpdateTemperature(Entity entity){if(entity == null)return;if(entity.isInWaterRainOrBubble()){double newTemperature =(entity.getCapability(DrowningbelowModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(newDrowningbelowModVariables.PlayerVariables())).Temperatura-2;
entity.getCapability(DrowningbelowModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability ->{
capability.Temperatura= newTemperature;
capability.syncPlayerVariables(entity);});}}privatestaticvoid displayTemperature(Entity entity){if(entity == null)return;if(entity instanceof Player _player &&!_player.level().isClientSide()){double temperatura =(entity.getCapability(DrowningbelowModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(newDrowningbelowModVariables.PlayerVariables())).Temperatura;
_player.displayClientMessage(Component.literal("\u00A76\u00A7l\u2600\u00A7e\u00A7l Temperatura \u00A76\u00A7l\u2600 \u00A7e\u00A7l"+ temperatura +"\u00B0"),true);}}privatestaticvoid execute(@NullableEvent event,LevelAccessor world,Entity entity){System.out.println("Esto si se mando 2");if(world.getBiome(BlockPos.containing(entity.getX(), entity.getY(), entity.getX())).is(newResourceLocation("desert"))){System.out.println("Esto si se mando 3");double _setval =(entity.getCapability(DrowningbelowModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(newDrowningbelowModVariables.PlayerVariables())).Temperatura+2;
entity.getCapability(DrowningbelowModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability ->{
capability.Temperatura= _setval;
capability.syncPlayerVariables(entity);});System.out.println("Esto si se mando 4");}}}
Important Information
By using this site, you agree to our Terms of Use.
Trying to get biome on player's position
in Modder Support
Hello! Im trying to get biome on player's position, if the player is in desert biome the variable "temperature" should increase but it doesn't. am i missing something?