Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent handled and/or proximity from sending players over the edge into hot or icy temperature levels #882

Open
Kongga666 opened this issue Oct 16, 2024 · 0 comments
Labels

Comments

@Kongga666
Copy link

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:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant