Prevent handled and/or proximity from sending players over the edge into hot or icy temperature levels
Kongga666 opened this issue ยท 0 comments
Overview
In armorModifier we have a snippet of code that Prevent armor from sending players over the edge into hot or icy temperature levels.
// Prevent armor from sending players over the edge into hot or icy temperature levels
TemperatureLevel armorAdjTemp = current.increment(heatingPieces.get() / 2 - coolingPieces.get() / 2);
if (armorAdjTemp == TemperatureLevel.HOT && current != TemperatureLevel.HOT) current = armorAdjTemp.decrement(1);
else if (armorAdjTemp == TemperatureLevel.ICY && current != TemperatureLevel.ICY) current = armorAdjTemp.increment(1);
else current = armorAdjTemp;
I Think it would be nice, through Configuration, to have the same logic for:
- Handled Items handheldModifier
- And/Or for Bloc Proximity proximityModifier
Code Proposition
Handled Items
protected static TemperatureLevel handheldModifier(Player player, TemperatureLevel current)
{
AtomicInteger coolingItems = new AtomicInteger();
AtomicInteger heatingItems = new AtomicInteger();
player.getHandSlots().forEach((stack -> {
if (stack.is(ModTags.Items.COOLING_HELD_ITEMS)) coolingItems.getAndIncrement();
if (stack.is(ModTags.Items.HEATING_HELD_ITEMS)) heatingItems.getAndIncrement();
}));
// Prevent handled from sending players over the edge into hot or icy temperature levels
TemperatureLevel AdjTemp = current.increment(heatingItems.get() - coolingItems.get());
if (AdjTemp == TemperatureLevel.HOT && current != TemperatureLevel.HOT) current = AdjTemp.decrement(1);
else if (AdjTemp == TemperatureLevel.ICY && current != TemperatureLevel.ICY) current = AdjTemp.increment(1);
else current = AdjTemp;
return current;
}
Proximity Block
private static TemperatureLevel proximityModifier(Level level, BlockPos pos, TemperatureLevel current)
{
Set<BlockPos> heating = Sets.newHashSet();
Set<BlockPos> cooling = Sets.newHashSet();
// If the player's position is obstructed (for example, when mounted or inside a block), use the position above instead
if (!level.isEmptyBlock(pos))
pos = pos.above();
AreaFill.fill(level, pos, (checkerLevel, checkedPos) -> {
addHeatingOrCooling(heating, cooling, checkerLevel, checkedPos.pos());
});
// Prevent proximity from sending players over the edge into hot or icy temperature levels
TemperatureLevel AdjTemp;
if (heating.size() > cooling.size()) AdjTemp = current.increment(1);
else if (cooling.size() > heating.size()) AdjTemp = current.decrement(1);
else AdjTemp = current;
if (AdjTemp == TemperatureLevel.HOT && current != TemperatureLevel.HOT) current = AdjTemp.decrement(1);
else if (AdjTemp == TemperatureLevel.ICY && current != TemperatureLevel.ICY) current = AdjTemp.increment(1);
else current = AdjTemp;
return current;
}
Why would this feature be useful?
I think having the possibilty to Prevent handled and/or proximity from sending players over the edge into hot or icy temperature levels
thorugh configuration can softer the temperature mitigation system for those who want it.
Moreover it would make Extreme Temperature Levels only Biome/Weather dependent.