Reformatted all the code using the default intelji formatting options.

This commit is contained in:
modmuss50 2015-08-09 11:05:32 +01:00
parent 2f63a24070
commit e0ab0af822
363 changed files with 20524 additions and 23016 deletions

View file

@ -8,41 +8,41 @@ public class LesuNetwork {
public TileLesu master;
public void addElement(TileLesuStorage lesuStorage){
if(!storages.contains(lesuStorage) && storages.size() < 5000){
public void addElement(TileLesuStorage lesuStorage) {
if (!storages.contains(lesuStorage) && storages.size() < 5000) {
storages.add(lesuStorage);
}
}
public void removeElement(TileLesuStorage lesuStorage){
public void removeElement(TileLesuStorage lesuStorage) {
storages.remove(lesuStorage);
rebuild();
}
private void rebuild(){
master = null;
for(TileLesuStorage lesuStorage : storages){
private void rebuild() {
master = null;
for (TileLesuStorage lesuStorage : storages) {
lesuStorage.findAndJoinNetwork(lesuStorage.getWorldObj(), lesuStorage.xCoord, lesuStorage.yCoord, lesuStorage.zCoord);
}
}
public void merge(LesuNetwork network){
if(network != this){
public void merge(LesuNetwork network) {
if (network != this) {
ArrayList<TileLesuStorage> tileLesuStorages = new ArrayList<TileLesuStorage>();
tileLesuStorages.addAll(network.storages);
network.clear(false);
for(TileLesuStorage lesuStorage : tileLesuStorages){
for (TileLesuStorage lesuStorage : tileLesuStorages) {
lesuStorage.setNetwork(this);
}
if(network.master != null && this.master == null){
this.master = network.master;
}
if (network.master != null && this.master == null) {
this.master = network.master;
}
}
}
private void clear(boolean clearTiles) {
if (clearTiles) {
for(TileLesuStorage tileLesuStorage : storages){
for (TileLesuStorage tileLesuStorage : storages) {
tileLesuStorage.resetNetwork();
}
}

View file

@ -9,7 +9,7 @@ import techreborn.util.Inventory;
import java.util.ArrayList;
public class TileLesu extends TilePowerAcceptor {//TODO wrench
public class TileLesu extends TilePowerAcceptor {//TODO wrench
private ArrayList<LesuNetwork> countedNetworks = new ArrayList<LesuNetwork>();
public int connectedBlocks = 0;
@ -18,8 +18,8 @@ public class TileLesu extends TilePowerAcceptor {//TODO wrench
private double euLastTick = 0;
private double euChange;
private int ticks;
private int output;
private int maxStorage;
private int output;
private int maxStorage;
public Inventory inventory = new Inventory(2, "TileAesu", 64);
@ -30,41 +30,41 @@ public class TileLesu extends TilePowerAcceptor {//TODO wrench
@Override
public void updateEntity() {
super.updateEntity();
if(worldObj.isRemote){
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){
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)){
if(network.master == null || network.master == this){
if (!countedNetworks.contains(network)) {
if (network.master == null || network.master == this) {
connectedBlocks += network.storages.size();
countedNetworks.add(network);
network.master = this;
break;
break;
}
}
}
}
}
if(currentBlocks != connectedBlocks){
if (currentBlocks != connectedBlocks) {
maxStorage = ((connectedBlocks + 1) * ConfigTechReborn.lesuStoragePerBlock);
output = (connectedBlocks * ConfigTechReborn.extraOutputPerLesuBlock) + ConfigTechReborn.baseLesuOutput;
}
if(ticks == ConfigTechReborn.aveargeEuOutTickTime){
if (ticks == ConfigTechReborn.aveargeEuOutTickTime) {
euChange = -1;
ticks = 0;
} else {
ticks ++;
if(euChange == -1){
ticks++;
if (euChange == -1) {
euChange = 0;
}
euChange += getEnergy() - euLastTick;
if(euLastTick == getEnergy()){
if (euLastTick == getEnergy()) {
euChange = 0;
}
}
@ -73,35 +73,35 @@ public class TileLesu extends TilePowerAcceptor {//TODO wrench
}
public double getEuChange(){
if(euChange == -1){
public double getEuChange() {
if (euChange == -1) {
return 0;
}
return (euChange / ticks);
}
@Override
public double getMaxPower() {
return maxStorage;
}
@Override
public double getMaxPower() {
return maxStorage;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return Functions.getIntDirFromDirection(direction) != worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return Functions.getIntDirFromDirection(direction) != worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return Functions.getIntDirFromDirection(direction) == worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
}
}
@Override
public double getMaxOutput() {
return output;
}
@Override
public double getMaxOutput() {
return output;
}
@Override
public double getMaxInput() {
return 8192;
}
@Override
public double getMaxInput() {
return 8192;
}
}

View file

@ -11,22 +11,22 @@ public class TileLesuStorage extends TileMachineBase {
@Override
public void updateEntity() {
super.updateEntity();
if(network == null){
if (network == null) {
findAndJoinNetwork(worldObj, xCoord, yCoord, zCoord);
} else {
if(network.master != null && network.master.getWorldObj().getTileEntity(network.master.xCoord, network.master.yCoord, network.master.zCoord) != network.master){
network.master = null;
}
if (network.master != null && network.master.getWorldObj().getTileEntity(network.master.xCoord, network.master.yCoord, network.master.zCoord) != network.master) {
network.master = null;
}
}
}
public final void findAndJoinNetwork(World world, int x, int y, int z) {
network = new LesuNetwork();
network.addElement(this);
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){
if(world.getTileEntity(x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ) instanceof TileLesuStorage){
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (world.getTileEntity(x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ) instanceof TileLesuStorage) {
TileLesuStorage lesu = (TileLesuStorage) world.getTileEntity(x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ);
if(lesu.network != null){
if (lesu.network != null) {
lesu.network.merge(network);
}
}