Skip to content

Commit

Permalink
Slight changes, Improvements, Fixes and Optimized temperature setting…
Browse files Browse the repository at this point in the history
…s for balanced gameplay
  • Loading branch information
Garkatron committed Jan 10, 2025
1 parent da0b307 commit 08c399d
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import net.minecraft.core.item.Item;

public interface IPlayerEntity {
Block stanley_lib$getBlockUnderPlayer();
Item stanley_lib$getItemInHand();
Block stanley$getBlockUnderPlayer();
Item stanley$getItemInHand();

boolean[] hasLeatherArmor(EntityPlayer player);
boolean[] stanley$hasLeatherArmor(EntityPlayer player);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,114 +9,114 @@ public interface IStanleyPlayerEntity extends IPlayerEntity {
*
* @return The current temperature as a float.
*/
double stanley_lib$getPlayerTemperature();
double stanley$getPlayerTemperature();

/**
* Gets the previous temperature of the player.
*
* @return The current temperature as a float.
*/
double stanley_lib$getPlayerPreviousTemperature();
double stanley$getPlayerPreviousTemperature();


/**
* Sets the player's temperature to a specific value.
*
* @param temperature The new temperature value.
*/
void stanley_lib$setPlayerTemperature(double temperature);
void stanley$setPlayerTemperature(double temperature);

/**
* Increases the player's temperature by a specified amount.
*
* @param amount The amount to increase the temperature by.
*/
void stanley_lib$increasePlayerTemperature(double amount);
void stanley$increasePlayerTemperature(double amount);

/**
* Decreases the player's temperature by a specified amount.
*
* @param amount The amount to decrease the temperature by.
*/
void stanley_lib$decreasePlayerTemperature(double amount);
void stanley$decreasePlayerTemperature(double amount);

/**
* Checks if the player is overheating.
*
* @return True if the player is overheating, false otherwise.
*/
boolean stanley_lib$isPlayerOverheating();
boolean stanley$isPlayerOverheating();

/**
* Checks if the player is freezing.
*
* @return True if the player is freezing, false otherwise.
*/
boolean stanley_lib$isPlayerFreezing();
boolean stanley$isPlayerFreezing();

/**
* Resets the player's temperature to the default value.
**/
void stanley_lib$resetPlayerTemperature();
void stanley$resetPlayerTemperature();

/**
* Kills the player's by freezing.
**/
void stanley_lib$killByFreezing();
void stanley$killByFreezing();

/**
* Kills the player's by overheating.
**/
void stanley_lib$killByOverheating();
void stanley$killByOverheating();

/**
* Hurt's the player by freezing
*
* @param amount The amount to hurt the player.
**/
void stanley_lib$hurtByFreezing(int amount);
void stanley$hurtByFreezing(int amount);

/**
* Hurt's the player by freezing
*
* @param amount The amount to hurt the player.
**/
void stanley_lib$hurtByOverheating(int amount);
void stanley$hurtByOverheating(int amount);

/**
* Hurt's the player by cold
*
* @param amount The amount to hurt the player.
**/
void stanley_lib$hurtByCold(int amount);
void stanley$hurtByCold(int amount);

/**
* Hurt's the player by heat
*
* @param amount The amount to hurt the player.
**/
void stanley_lib$hurtByHeat(int amount);
void stanley$hurtByHeat(int amount);

/**
* Update's player temperature
**/
void stanley_lib$updateTemperature();
void stanley$updateTemperature();

/**
* Sets the player's temperature state to a specific value.
*
* @param state The new temperature value.
**/
void stanley_lib$setTemperatureState(PlayerTemperatureState state);
void stanley$setTemperatureState(PlayerTemperatureState state);

/**
* Get the player's temperature state.
**/
PlayerTemperatureState stanley_lib$getState();
PlayerTemperatureState stanley$getState();

/**
* Get a heat source near of the player
**/
Block stanley_lib$getHeatSource();
Block stanley$getHeatSource();

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public TemperatureManager(IStanleyPlayerEntity custom_player) {
public void update() {
IPlayerEntity iplayer = (IPlayerEntity) custom_player;

Block under_player_block = iplayer.stanley_lib$getBlockUnderPlayer();
Block under_player_block = iplayer.stanley$getBlockUnderPlayer();
EntityPlayer player = (EntityPlayer) (Object) this.custom_player;

Biome current_biome_at_block = player.world.getBlockBiome((int) player.x, (int) player.y, (int) player.z);
Season current_season = player.world.seasonManager.getCurrentSeason();
boolean[] leather_armors = iplayer.hasLeatherArmor(player);
boolean[] leather_armors = iplayer.stanley$hasLeatherArmor(player);
Weather current_weather = player.world.getCurrentWeather();

Double current_temperature = custom_player.stanley_lib$getPlayerTemperature();
Double current_temperature = custom_player.stanley$getPlayerTemperature();

updatePlayerTemperatureState(player, current_temperature);

Expand Down Expand Up @@ -121,7 +121,7 @@ public void update() {
}

// Adjust temperature based on equipped item
Item item = custom_player.stanley_lib$getItemInHand();
Item item = custom_player.stanley$getItemInHand();
if (
MOD_CONFIG.getConfig().getBoolean("itemEffects.itemAffectsTemperature") &&
item!=null
Expand Down Expand Up @@ -177,50 +177,50 @@ public void updatePlayerTemperatureState(EntityPlayer player, Double current_tem

// Temperature state checks
if (isOverheating) {
custom_player.stanley_lib$setTemperatureState(PlayerTemperatureState.OVERHEATING);
custom_player.stanley$setTemperatureState(PlayerTemperatureState.OVERHEATING);
if (!sent_messages[0]) {
player.sendMessage("You are overheating! Current temperature: " + current_temperature);
}
sent_messages[0] = sent_messages[1] = sent_messages[2] = sent_messages[3] = true;

//custom_player.stanley_lib$killByOverheating();
custom_player.stanley_lib$hurtByHeat(1);
custom_player.stanley$hurtByHeat(1);

} else if (isHot) {
custom_player.stanley_lib$setTemperatureState(PlayerTemperatureState.HOT);
custom_player.stanley$setTemperatureState(PlayerTemperatureState.HOT);
if (!sent_messages[1]) {
player.sendMessage("You are hot. Current temperature: " + current_temperature);
}
sent_messages[0] = sent_messages[1] = sent_messages[2] = sent_messages[3] = true;

} else if (isNormal) {
custom_player.stanley_lib$setTemperatureState(PlayerTemperatureState.NORMAL);
custom_player.stanley$setTemperatureState(PlayerTemperatureState.NORMAL);
sent_messages[0] = sent_messages[1] = sent_messages[2] = sent_messages[3] = true;

// player.sendMessage("Your temperature is normal. Current temperature: " + current_temperature);
} else if (isCold) {
custom_player.stanley_lib$setTemperatureState(PlayerTemperatureState.COLD);
custom_player.stanley$setTemperatureState(PlayerTemperatureState.COLD);
if (!sent_messages[2]) {
player.sendMessage("You are cold. Current temperature: " + current_temperature);
}
sent_messages[0] = sent_messages[1] = sent_messages[2] = sent_messages[3] = true;
} else if (isFreezing) {
custom_player.stanley_lib$setTemperatureState(PlayerTemperatureState.FREEZING);
custom_player.stanley$setTemperatureState(PlayerTemperatureState.FREEZING);
if (!sent_messages[3]) {
player.sendMessage("You are freezing! Current temperature: " + current_temperature);
}
sent_messages[0] = sent_messages[1] = sent_messages[2] = sent_messages[3] = true;
custom_player.stanley_lib$hurtByHeat(1);
custom_player.stanley$hurtByHeat(1);

}
}

public void adjustPlayerTemperature(Double totalAdjustment) {
double rTotalAdjustment = Math.round(totalAdjustment * 10000.0f) / 10000.0f; // round to 4 decimal places
if (rTotalAdjustment > 0) {
custom_player.stanley_lib$increasePlayerTemperature(rTotalAdjustment);
custom_player.stanley$increasePlayerTemperature(rTotalAdjustment);
} else {
custom_player.stanley_lib$decreasePlayerTemperature(-rTotalAdjustment);
custom_player.stanley$decreasePlayerTemperature(-rTotalAdjustment);
}
}
}
Loading

0 comments on commit 08c399d

Please sign in to comment.