Finished the lesu

This commit is contained in:
modmuss50 2015-06-14 16:42:03 +01:00
parent 783765676b
commit c9c664352c
8 changed files with 484 additions and 78 deletions

View file

@ -7,6 +7,7 @@ import ic2.core.util.Util;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import techreborn.blocks.storage.EUStorageTile;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.util.Inventory;
@ -14,7 +15,7 @@ import techreborn.util.LogHelper;
import java.lang.reflect.Field;
public class TileAesu extends TileEntityElectricBlock implements IWrenchable {
public class TileAesu extends EUStorageTile implements IWrenchable {
public static final int MAX_OUTPUT = 8192;
public static final int MAX_STORAGE = 1000000000; //One billion!
@ -122,18 +123,7 @@ public class TileAesu extends TileEntityElectricBlock implements IWrenchable {
if(OUTPUT <= -1){
OUTPUT = 0;
}
//TODO make a better way and not use reflection for this.
try {
Field field = getClass().getSuperclass().getDeclaredField("output");
field.setAccessible(true);
field.set(this, OUTPUT);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
output = OUTPUT;
LogHelper.debug("Set output to " + getOutput());
}

View file

@ -6,8 +6,10 @@ public class LesuNetwork {
public ArrayList<TileLesuStorage> storages = new ArrayList<TileLesuStorage>();
public TileLesu master;
public void addElement(TileLesuStorage lesuStorage){
if(!storages.contains(lesuStorage)){
if(!storages.contains(lesuStorage) && storages.size() < 5000){
storages.add(lesuStorage);
}
}

View file

@ -4,7 +4,6 @@ package techreborn.tiles.lesu;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.tiles.TileAesu;
import java.lang.reflect.Field;
import java.util.ArrayList;
public class TileLesu extends TileAesu {
@ -28,24 +27,17 @@ public class TileLesu extends TileAesu {
if(((TileLesuStorage) worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ)).network != null){
LesuNetwork network = ((TileLesuStorage) worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ)).network;
if(!countedNetworks.contains(network)){
connectedBlocks += network.storages.size();
countedNetworks.add(network);
if(network.master == null || network.master == this){
connectedBlocks += network.storages.size();
countedNetworks.add(network);
network.master = this;
}
}
}
}
}
if(currentBlocks != connectedBlocks){
try {
Field field = getClass().getSuperclass().getSuperclass().getDeclaredField("maxStorage");
field.setAccessible(true);
field.set(this, (connectedBlocks * storgeBlockSize) + baseEU);
currentBlocks = connectedBlocks;
System.out.println("set output to " + maxStorage + " using " + connectedBlocks);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
maxStorage = (connectedBlocks * storgeBlockSize) + baseEU;
}
}
}