Skip to content

Commit

Permalink
1.12.2-0.3.2a
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuxelus committed May 27, 2024
1 parent 9a2449d commit e583c60
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle_old
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
apply plugin: 'net.minecraftforge.gradle.forge'

version = "1.12.2-0.3.2"
version = "1.12.2-0.3.2a"
group= "com.zuxelus.energycontrol"
archivesBaseName = "EnergyControl"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

import com.zuxelus.energycontrol.api.CardState;
import com.zuxelus.energycontrol.api.ItemStackHelper;
import com.zuxelus.energycontrol.hooks.ThermalExpansionHooks;
import com.zuxelus.energycontrol.init.ModItems;
import com.zuxelus.energycontrol.items.cards.ItemCardMain;
import com.zuxelus.energycontrol.items.cards.ItemCardThermalExpansion;
import com.zuxelus.energycontrol.items.cards.ItemCardType;
import com.zuxelus.energycontrol.items.kits.ItemKitMain;
import com.zuxelus.energycontrol.items.kits.ItemKitThermalExpansion;
import com.zuxelus.energycontrol.utils.DataHelper;
import com.zuxelus.energycontrol.utils.FluidInfo;

import cofh.core.block.TileNameable;
Expand All @@ -29,6 +31,7 @@
import cofh.thermalexpansion.block.machine.TileMachineBase;
import cofh.thermalexpansion.block.machine.TileRefinery;
import cofh.thermalexpansion.block.machine.TileSmelter;
import cofh.thermalexpansion.block.storage.TileCell;
import cofh.thermalexpansion.item.ItemAugment;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand All @@ -47,9 +50,9 @@ public NBTTagCompound getEnergyData(TileEntity te) {
NBTTagCompound tag = new NBTTagCompound();
IEnergyStorage storage = ((TilePowered) te).getEnergyStorage();
if (storage != null) {
tag.setString("euType", "RF");
tag.setDouble("storage", storage.getEnergyStored());
tag.setDouble("maxStorage", storage.getMaxEnergyStored());
tag.setString(DataHelper.EUTYPE, "RF");
tag.setDouble(DataHelper.ENERGY, storage.getEnergyStored());
tag.setDouble(DataHelper.CAPACITY, storage.getMaxEnergyStored());
return tag;
}
}
Expand Down Expand Up @@ -155,6 +158,18 @@ public List<FluidInfo> getAllTanks(TileEntity te) {
@Override
public NBTTagCompound getCardData(World world, BlockPos pos) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileCell) {
IEnergyStorage storage = ((TileCell) te).getEnergyStorage();
if (storage != null) {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("storage", storage.getEnergyStored());
tag.setInteger("maxStorage", storage.getMaxEnergyStored());
ArrayList values = getHookValues(te);
if (values != null)
tag.setLong(DataHelper.DIFF, ((Long) values.get(0) - (Long) values.get(20)) / 20);
return tag;
}
}
try {
if (te instanceof TileMachineBase) {
NBTTagCompound tag = new NBTTagCompound();
Expand Down Expand Up @@ -209,6 +224,14 @@ public NBTTagCompound getCardData(World world, BlockPos pos) {
return null;
}

@Override
public ArrayList getHookValues(TileEntity te) {
ArrayList values = ThermalExpansionHooks.map.get(te);
if (values == null)
ThermalExpansionHooks.map.put(te, null);
return values;
}

@Override
public void registerItems(Register<Item> event) {
ItemKitMain.register(ItemKitThermalExpansion::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public void registerHooks() {
registerHookContainer("com.zuxelus.energycontrol.hooks.IC2Hooks");
registerHookContainer("com.zuxelus.energycontrol.hooks.IC2ClassicHooks");
registerHookContainer("com.zuxelus.energycontrol.hooks.MekanismHooks");
registerHookContainer("com.zuxelus.energycontrol.hooks.ThermalExpansionHooks");
}
}
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.zuxelus.energycontrol.api.PanelString;
import com.zuxelus.energycontrol.crossmod.CrossModLoader;
import com.zuxelus.energycontrol.crossmod.ModIDs;
import com.zuxelus.energycontrol.utils.DataHelper;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -37,15 +38,24 @@ public CardState update(World world, ICardReader reader, int range, BlockPos pos
@Override
public List<PanelString> getStringData(int settings, ICardReader reader, boolean isServer, boolean showLabels) {
List<PanelString> result = reader.getTitleList();
result.add(new PanelString("msg.ec.InfoPanelPowerUsage", reader.getInt("usage"), showLabels));
result.add(new PanelString("msg.ec.InfoPanelPower", reader.getString("power"), showLabels));
result.add(new PanelString("msg.ec.InfoPanelEnergy", String.format("%s / %s RF",reader.getInt("storage"), reader.getInt("maxStorage")), showLabels));
result.add(new PanelString("msg.ec.InfoPanelRedstoneMode", reader.getString("rsmode"), showLabels));
result.add(new PanelString("msg.ec.InfoPanelAugmentation", "", showLabels));
String[] augmentation = reader.getString("augmentation").split(",");
for (int i = 0; i < augmentation.length; i++)
result.add(new PanelString(" " + augmentation[i]));
addOnOff(result, isServer, reader.getBoolean("active"));
if (reader.hasField("usage"))
result.add(new PanelString("msg.ec.InfoPanelPowerUsage", reader.getInt("usage"), showLabels));
if (reader.hasField("power"))
result.add(new PanelString("msg.ec.InfoPanelPower", reader.getString("power"), showLabels));
if (reader.hasField("storage"))
result.add(new PanelString("msg.ec.InfoPanelEnergy", String.format("%s / %s RF",reader.getInt("storage"), reader.getInt("maxStorage")), showLabels));
if (reader.hasField(DataHelper.DIFF) && (settings & 64) > 0)
result.add(new PanelString("msg.ec.InfoPanelDifference", reader.getLong(DataHelper.DIFF), "RF/t", showLabels));
if (reader.hasField("rsmode"))
result.add(new PanelString("msg.ec.InfoPanelRedstoneMode", reader.getString("rsmode"), showLabels));
if (reader.hasField("augmentation")) {
result.add(new PanelString("msg.ec.InfoPanelAugmentation", "", showLabels));
String[] augmentation = reader.getString("augmentation").split(",");
for (int i = 0; i < augmentation.length; i++)
result.add(new PanelString(" " + augmentation[i]));
}
if (reader.hasField("active"))
addOnOff(result, isServer, reader.getBoolean("active"));
switch (reader.getInt("type")) {
case 2:
result.add(new PanelString(reader.getString("lock")));
Expand Down

0 comments on commit e583c60

Please sign in to comment.