pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.debug;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -38,98 +37,84 @@ import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
public class TileEnergyGenerator extends AEBaseTile implements ITickableTileEntity, IEnergyStorage {
|
||||
/**
|
||||
* The base energy injected each tick. Adjacent TileEnergyGenerators will
|
||||
* increase it to pow(base, #generators).
|
||||
*/
|
||||
private static final int BASE_ENERGY = 8;
|
||||
|
||||
public class TileEnergyGenerator extends AEBaseTile implements ITickableTileEntity, IEnergyStorage
|
||||
{
|
||||
/**
|
||||
* The base energy injected each tick.
|
||||
* Adjacent TileEnergyGenerators will increase it to pow(base, #generators).
|
||||
*/
|
||||
private static final int BASE_ENERGY = 8;
|
||||
public TileEnergyGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public TileEnergyGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
@Override
|
||||
public void tick() {
|
||||
World world = this.getWorld();
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
World world = this.getWorld();
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
int tier = 1;
|
||||
for (Direction facing : Direction.values()) {
|
||||
final TileEntity te = world.getTileEntity(this.getPos().offset(facing));
|
||||
|
||||
int tier = 1;
|
||||
for( Direction facing : Direction.values() )
|
||||
{
|
||||
final TileEntity te = world.getTileEntity( this.getPos().offset( facing ) );
|
||||
if (te instanceof TileEnergyGenerator) {
|
||||
tier++;
|
||||
}
|
||||
}
|
||||
|
||||
if( te instanceof TileEnergyGenerator )
|
||||
{
|
||||
tier++;
|
||||
}
|
||||
}
|
||||
final int energyToInsert = IntMath.pow(BASE_ENERGY, tier);
|
||||
|
||||
final int energyToInsert = IntMath.pow( BASE_ENERGY, tier );
|
||||
for (Direction facing : Direction.values()) {
|
||||
final TileEntity te = this.getWorld().getTileEntity(this.getPos().offset(facing));
|
||||
final LazyOptional<IEnergyStorage> cap = te.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite());
|
||||
|
||||
for( Direction facing : Direction.values() )
|
||||
{
|
||||
final TileEntity te = this.getWorld().getTileEntity( this.getPos().offset( facing ) );
|
||||
final LazyOptional<IEnergyStorage> cap = te.getCapability( CapabilityEnergy.ENERGY, facing.getOpposite() );
|
||||
cap.ifPresent(consumer -> {
|
||||
if (consumer.canReceive()) {
|
||||
consumer.receiveEnergy(energyToInsert, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cap.ifPresent(consumer -> {
|
||||
if (consumer.canReceive()) {
|
||||
consumer.receiveEnergy( energyToInsert, false );
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
if (capability == CapabilityEnergy.ENERGY) {
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this);
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing )
|
||||
{
|
||||
if( capability == CapabilityEnergy.ENERGY )
|
||||
{
|
||||
return (LazyOptional<T>) LazyOptional.of(() ->this);
|
||||
}
|
||||
return super.getCapability( capability, facing );
|
||||
}
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy( int maxReceive, boolean simulate )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
return maxExtract;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy( int maxExtract, boolean simulate )
|
||||
{
|
||||
return maxExtract;
|
||||
}
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored()
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored()
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtract() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtract()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canReceive() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user