Auto Format code
This commit is contained in:
parent
112b1657cf
commit
796df6c055
503 changed files with 12260 additions and 16291 deletions
|
@ -2,61 +2,48 @@ package techreborn.tiles.lesu;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LesuNetwork
|
||||
{
|
||||
public class LesuNetwork {
|
||||
|
||||
public ArrayList<TileLesuStorage> storages = new ArrayList<>();
|
||||
|
||||
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()
|
||||
{
|
||||
private void rebuild() {
|
||||
master = null;
|
||||
for (TileLesuStorage lesuStorage : storages)
|
||||
{
|
||||
for (TileLesuStorage lesuStorage : storages) {
|
||||
lesuStorage.findAndJoinNetwork(lesuStorage.getWorld(), lesuStorage.getPos().getX(),
|
||||
lesuStorage.getPos().getY(), lesuStorage.getPos().getZ());
|
||||
lesuStorage.getPos().getY(), lesuStorage.getPos().getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public void merge(LesuNetwork network)
|
||||
{
|
||||
if (network != this)
|
||||
{
|
||||
public void merge(LesuNetwork network) {
|
||||
if (network != this) {
|
||||
ArrayList<TileLesuStorage> tileLesuStorages = new ArrayList<>();
|
||||
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)
|
||||
{
|
||||
if (network.master != null && this.master == null) {
|
||||
this.master = network.master;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clear(boolean clearTiles)
|
||||
{
|
||||
if (clearTiles)
|
||||
{
|
||||
for (TileLesuStorage tileLesuStorage : storages)
|
||||
{
|
||||
private void clear(boolean clearTiles) {
|
||||
if (clearTiles) {
|
||||
for (TileLesuStorage tileLesuStorage : storages) {
|
||||
tileLesuStorage.resetNetwork();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@ import techreborn.config.ConfigTechReborn;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileLesu extends TilePowerAcceptor
|
||||
{// TODO wrench
|
||||
public class TileLesu extends TilePowerAcceptor {// TODO wrench
|
||||
|
||||
public int connectedBlocks = 0;
|
||||
public Inventory inventory = new Inventory(2, "TileAesu", 64, this);
|
||||
|
@ -21,38 +20,30 @@ public class TileLesu extends TilePowerAcceptor
|
|||
private int output;
|
||||
private int maxStorage;
|
||||
|
||||
public TileLesu()
|
||||
{
|
||||
public TileLesu() {
|
||||
super(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
countedNetworks.clear();
|
||||
connectedBlocks = 0;
|
||||
for (EnumFacing dir : EnumFacing.values())
|
||||
{
|
||||
for (EnumFacing dir : EnumFacing.values()) {
|
||||
if (worldObj.getTileEntity(
|
||||
new BlockPos(getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ())) instanceof TileLesuStorage)
|
||||
{
|
||||
new BlockPos(getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ())) instanceof TileLesuStorage) {
|
||||
if (((TileLesuStorage) worldObj.getTileEntity(
|
||||
new BlockPos(getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ()))).network != null)
|
||||
{
|
||||
new BlockPos(getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ()))).network != null) {
|
||||
LesuNetwork network = ((TileLesuStorage) worldObj.getTileEntity(new BlockPos(
|
||||
getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ()))).network;
|
||||
if (!countedNetworks.contains(network))
|
||||
{
|
||||
if (network.master == null || network.master == this)
|
||||
{
|
||||
getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(),
|
||||
getPos().getZ() + dir.getFrontOffsetZ()))).network;
|
||||
if (!countedNetworks.contains(network)) {
|
||||
if (network.master == null || network.master == this) {
|
||||
connectedBlocks += network.storages.size();
|
||||
countedNetworks.add(network);
|
||||
network.master = this;
|
||||
|
@ -65,20 +56,16 @@ public class TileLesu extends TilePowerAcceptor
|
|||
maxStorage = ((connectedBlocks + 1) * ConfigTechReborn.LesuStoragePerBlock);
|
||||
output = (connectedBlocks * ConfigTechReborn.ExtraOutputPerLesuBlock) + ConfigTechReborn.BaseLesuOutput;
|
||||
|
||||
if (ticks == ConfigTechReborn.AverageEuOutTickTime)
|
||||
{
|
||||
if (ticks == ConfigTechReborn.AverageEuOutTickTime) {
|
||||
euChange = -1;
|
||||
ticks = 0;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ticks++;
|
||||
if (euChange == -1)
|
||||
{
|
||||
if (euChange == -1) {
|
||||
euChange = 0;
|
||||
}
|
||||
euChange += getEnergy() - euLastTick;
|
||||
if (euLastTick == getEnergy())
|
||||
{
|
||||
if (euLastTick == getEnergy()) {
|
||||
euChange = 0;
|
||||
}
|
||||
}
|
||||
|
@ -86,48 +73,40 @@ public class TileLesu extends TilePowerAcceptor
|
|||
euLastTick = getEnergy();
|
||||
}
|
||||
|
||||
public double getEuChange()
|
||||
{
|
||||
if (euChange == -1)
|
||||
{
|
||||
public double getEuChange() {
|
||||
if (euChange == -1) {
|
||||
return 0;
|
||||
}
|
||||
return (euChange / ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
public double getMaxPower() {
|
||||
return maxStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return direction != getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return direction == getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
public double getMaxOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
public double getMaxInput() {
|
||||
return 8192;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.EXTREME;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,75 +5,59 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import reborncore.common.tile.TileMachineBase;
|
||||
|
||||
public class TileLesuStorage extends TileMachineBase
|
||||
{
|
||||
public class TileLesuStorage extends TileMachineBase {
|
||||
|
||||
public LesuNetwork network;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (network == null)
|
||||
{
|
||||
if (network == null) {
|
||||
findAndJoinNetwork(worldObj, getPos().getX(), getPos().getY(), getPos().getZ());
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
if (network.master != null
|
||||
&& network.master.getWorld().getTileEntity(new BlockPos(network.master.getPos().getX(),
|
||||
network.master.getPos().getY(), network.master.getPos().getZ())) != network.master)
|
||||
{
|
||||
&& network.master.getWorld().getTileEntity(new BlockPos(network.master.getPos().getX(),
|
||||
network.master.getPos().getY(), network.master.getPos().getZ())) != network.master) {
|
||||
network.master = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void findAndJoinNetwork(World world, int x, int y, int z)
|
||||
{
|
||||
public final void findAndJoinNetwork(World world, int x, int y, int z) {
|
||||
network = new LesuNetwork();
|
||||
network.addElement(this);
|
||||
for (EnumFacing direction : EnumFacing.values())
|
||||
{
|
||||
for (EnumFacing direction : EnumFacing.values()) {
|
||||
if (world.getTileEntity(new BlockPos(x + direction.getFrontOffsetX(), y + direction.getFrontOffsetY(),
|
||||
z + direction.getFrontOffsetZ())) instanceof TileLesuStorage)
|
||||
{
|
||||
z + direction.getFrontOffsetZ())) instanceof TileLesuStorage) {
|
||||
TileLesuStorage lesu = (TileLesuStorage) world
|
||||
.getTileEntity(new BlockPos(x + direction.getFrontOffsetX(), y + direction.getFrontOffsetY(),
|
||||
z + direction.getFrontOffsetZ()));
|
||||
if (lesu.network != null)
|
||||
{
|
||||
.getTileEntity(new BlockPos(x + direction.getFrontOffsetX(), y + direction.getFrontOffsetY(),
|
||||
z + direction.getFrontOffsetZ()));
|
||||
if (lesu.network != null) {
|
||||
lesu.network.merge(network);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void setNetwork(LesuNetwork n)
|
||||
{
|
||||
if (n == null)
|
||||
{
|
||||
} else
|
||||
{
|
||||
public final void setNetwork(LesuNetwork n) {
|
||||
if (n == null) {
|
||||
} else {
|
||||
network = n;
|
||||
network.addElement(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final void resetNetwork()
|
||||
{
|
||||
public final void resetNetwork() {
|
||||
network = null;
|
||||
}
|
||||
|
||||
public final void removeFromNetwork()
|
||||
{
|
||||
if (network == null)
|
||||
{
|
||||
public final void removeFromNetwork() {
|
||||
if (network == null) {
|
||||
} else
|
||||
network.removeElement(this);
|
||||
}
|
||||
|
||||
public final void rebuildNetwork()
|
||||
{
|
||||
public final void rebuildNetwork() {
|
||||
this.removeFromNetwork();
|
||||
this.resetNetwork();
|
||||
this.findAndJoinNetwork(worldObj, getPos().getX(), getPos().getY(), getPos().getZ());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue