Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,12 @@ public void registerBars(List<UnaryOperator<TemplateBarBuilder>> bars, PanelSync
syncManager.syncValue("energy_capacity", energyCapacityValue);

bars.add(b -> b.progress(() -> {
if (energyCapacityValue.getValue().equals(BigInteger.ZERO)) return 0;
return energyStoredValue.getValue().divide(energyCapacityValue.getValue()).doubleValue();
BigInteger capacity = energyCapacityValue.getValue();
BigInteger stored = energyStoredValue.getValue();
if (stored.equals(BigInteger.ZERO)) return 0;
double factor = capacity.divide(stored).doubleValue();
if (factor == 0) return 0;
return 1 / factor;
})
.texture(GTGuiTextures.PROGRESS_BAR_MULTI_ENERGY_YELLOW)
.tooltipBuilder(t -> {
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/gregtech/mixins/mui2/BigIntAdapterMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package gregtech.mixins.mui2;

import net.minecraft.network.PacketBuffer;

import io.netty.buffer.ByteBuf;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

// todo remove in next mui2 update
@Mixin(targets = "com.cleanroommc.modularui.utils.serialization.ByteBufAdapters$3")
public class BigIntAdapterMixin {

@Redirect(method = "serialize(Lnet/minecraft/network/PacketBuffer;Ljava/math/BigInteger;)V",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeBytes([B)Lio/netty/buffer/ByteBuf;"))
public ByteBuf fixIncorrectCall(PacketBuffer instance, byte[] bytes) {
return instance.writeByteArray(bytes);
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.gregtech.mui2.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"maxShiftBy": 10
},
"mixins": [
"BigIntAdapterMixin",
"TextWidgetMixin"
],
"client": [
Expand Down
Loading