Advanced Peripherals

Advanced Peripherals

30M Downloads

Powah Ender cell numeric clamping

GStefanowich opened this issue ยท 4 comments

commented

Describe

The Powah mod makes it capable to store insane amounts of power, using Ender Cells

The Powah manual states that an Energy Cell can hold up to 9E of power (Still not sure what the unit of measurement E is yet)

However, the mod compatibility seems to clamp the read energy stored as an int.

cell = peripheral.find("enderCell")

cell.getEnergy()
-- Returns "2147483647" (Max 32bit)

cell.getMaxEnergy()
-- Returns "2000000000000" >32 bit

As seen above though, the "MaxEnergy" is read correctly, at 2 trillion

I tested type(cell.getMaxEnergy()) if it was actually being handled as a string, but it does say number.

Steps to reproduce

  1. Obtain an Ender Cell and 2x Energy Cell (Nitro) (Capable of storing 2B power each)
  2. Place the Ender Cell, open the Ender Cell and shift click both Energy Cells inside (Setting capacity at 4B)
  3. Use a creative power source of some kind to fill the cell past 2.147B / 32-bit int (of 4B capacity)
  4. Use a ComputerCraft computer to attempt reading the current stored power

Multiplayer?

Yes

Version

1.20.1-0.7.40r (Latest 1.20.1)

Minecraft, Forge and maybe other related mods versions

NeoForge 47.1.101 Minecraft 1.20.1

Screenshots or Videos

No response

Crashlog/log

No response

commented

hm fun, both of them should convert from long to double, not sure if this is powah's issue

commented

CC-Tweaked provides a getEnergy method for energy_storage blocks. Is it possible that it's overriding AdvancedPeripherals implementation?

image

The energy_storage equivalent is an int.

https://github.com/cc-tweaked/CC-Tweaked/blob/d77f5f135f9251d027cc900dc27fd80160b632b9/projects/common/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/AbstractEnergyMethods.java#L36-L43

Makes the following methods available:

  • enderCell:
    • getEnergy
    • getMaxEnergy
  • energy_storage:
    • getEnergy
    • getEnergyCapacity
commented

Yeah that can be the problem

commented

I don't think there's a way I can call one specific implementation of it here.

I can open an issue over with CC:Tweaked instead, but I'm not sure how they'd fix it without also directly supporting Powahs Energy class.

https://github.com/Technici4n/Powah/blob/f4d7cf9840f5366783285133b8e5d6e365d6dd1c/src/main/java/owmii/powah/lib/block/AbstractEnergyStorage.java#L166-L168

energy_storage uses the Forge net.minecraftforge.energy.IEnergyStorage, which is also an int.