2015-06-14 14:35:36 +02:00
|
|
|
package techreborn.tiles.lesu;
|
|
|
|
|
|
|
|
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
|
|
import techreborn.tiles.TileAesu;
|
|
|
|
|
2015-06-14 16:58:49 +02:00
|
|
|
import java.lang.reflect.Field;
|
2015-06-14 14:35:36 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
public class TileLesu extends TileAesu {
|
|
|
|
|
|
|
|
public int baseEU = 1000000000;
|
|
|
|
public int storgeBlockSize = 100000;
|
|
|
|
|
|
|
|
private ArrayList<LesuNetwork> countedNetworks = new ArrayList<LesuNetwork>();
|
|
|
|
public int connectedBlocks = 0;
|
2015-06-14 16:58:49 +02:00
|
|
|
public int currentBlocks = 0;
|
2015-06-14 14:35:36 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateEntity() {
|
|
|
|
if(worldObj.isRemote){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
countedNetworks.clear();
|
|
|
|
connectedBlocks = 0;
|
|
|
|
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS){
|
|
|
|
if(worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ) instanceof TileLesuStorage){
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-14 16:58:49 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2015-06-14 14:35:36 +02:00
|
|
|
}
|
|
|
|
}
|