AE2 KeyCounter Overflow Fix

Quick rating

Community listing page, reviews here may not be monitored by the author.

AE2 KeyCounter Overflow Fix

No reviews yet

Fixes an integer overflow issue in Applied Energistics 2's `VariantCounter` that can cause AE2 key counts to overflow when approaching the `long` limit.

Mod Loaders
Minecraft

About

Description

AE2 KeyCounter Overflow Fix

AE2's VariantCounter uses a long to store the amount of each AEKey. When the stored amount approaches the maximum value of a long, adding more items can cause an integer overflow, resulting in an incorrect (potentially negative) amount.

This mod fixes this issue by preventing VariantCounter from exceeding the valid range of a Java long.

When an addition would cause an overflow, the amount is automatically clamped to the maximum or minimum representable value instead.

This mod is intended as a lightweight compatibility and bug-fix mod. It does not add any new gameplay features or content.