-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
86 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/com/zuxelus/energycontrol/hooks/ThermalExpansionHooks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.zuxelus.energycontrol.hooks; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.zuxelus.hooklib.asm.Hook; | ||
|
||
import cofh.redstoneflux.api.IEnergyStorage; | ||
import cofh.thermalexpansion.block.storage.TileCell; | ||
import net.minecraft.tileentity.TileEntity; | ||
|
||
public class ThermalExpansionHooks { | ||
public static Map<TileEntity, ArrayList> map = new HashMap<TileEntity, ArrayList>(); | ||
|
||
@Hook | ||
public static void update(TileCell te) { | ||
if (!map.containsKey(te) || te.getWorld().isRemote) | ||
return; | ||
|
||
long value = 0; | ||
IEnergyStorage storage = ((TileCell) te).getEnergyStorage(); | ||
if (storage != null) { | ||
value = storage.getEnergyStored(); | ||
} | ||
|
||
ArrayList<Long> values = map.get(te); | ||
if (values != null && values.size() > 0) { | ||
for (int i = 20; i > 0; i--) | ||
values.set(i, values.get(i - 1)); | ||
values.set(0, value); | ||
} else { | ||
values = new ArrayList<>(); | ||
for (int i = 0; i < 21; i++) | ||
values.add(value); | ||
map.put(te, values); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters