Lot of formatting.

This commit is contained in:
drcrazy 2018-06-22 18:22:16 +03:00
parent ec13f82628
commit 1de3fe5dc5
29 changed files with 540 additions and 544 deletions

View file

@ -70,7 +70,7 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
@Override
public void update() {
super.update();
this.ticksSinceLastChange++;
ticksSinceLastChange++;
if(world.isRemote){
return;
@ -78,56 +78,56 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
// Check cells input slot 2 time per second
// Please, keep ticks counting on client also to report progress to GUI
if (this.ticksSinceLastChange >= 10) {
if (!this.inventory.getStackInSlot(0).isEmpty()) {
FluidUtils.drainContainers(this.tank, this.inventory, 0, 1);
FluidUtils.fillContainers(this.tank, this.inventory, 0, 1, this.tank.getFluidType());
if (ticksSinceLastChange >= 10) {
if (!inventory.getStackInSlot(0).isEmpty()) {
FluidUtils.drainContainers(tank, inventory, 0, 1);
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType());
}
tank.setTileEntity(this);
tank.compareAndUpdate();
this.ticksSinceLastChange = 0;
ticksSinceLastChange = 0;
}
if (this.tank.getFluidAmount() > 0) {
if (this.currentRecipe == null || !this.currentRecipe.getFluid().equals(this.tank.getFluidType()))
this.currentRecipe = this.getRecipes().getRecipeForFluid(this.tank.getFluidType()).orElse(null);
if (tank.getFluidAmount() > 0) {
if (currentRecipe == null || !currentRecipe.getFluid().equals(tank.getFluidType()))
currentRecipe = getRecipes().getRecipeForFluid(tank.getFluidType()).orElse(null);
if (this.currentRecipe != null) {
final Integer euPerBucket = this.currentRecipe.getEnergyPerMb() * 1000;
final float millibucketsPerTick = this.euTick * 1000 / (float) euPerBucket;
if (currentRecipe != null) {
final Integer euPerBucket = currentRecipe.getEnergyPerMb() * 1000;
final float millibucketsPerTick = euTick * 1000 / (float) euPerBucket;
if (this.tryAddingEnergy(this.euTick)) {
this.pendingWithdraw += millibucketsPerTick;
final int currentWithdraw = (int) this.pendingWithdraw;
this.pendingWithdraw -= currentWithdraw;
this.tank.drain(currentWithdraw, true);
this.lastOutput = this.world.getTotalWorldTime();
if (tryAddingEnergy(euTick)) {
pendingWithdraw += millibucketsPerTick;
final int currentWithdraw = (int) pendingWithdraw;
pendingWithdraw -= currentWithdraw;
tank.drain(currentWithdraw, true);
lastOutput = world.getTotalWorldTime();
}
}
}
if (this.world.getTotalWorldTime() - this.lastOutput < 30 && !this.isActive())
this.world.setBlockState(this.getPos(), this.world.getBlockState(this.getPos()).withProperty(BlockMachineBase.ACTIVE, true));
else if (this.world.getTotalWorldTime() - this.lastOutput > 30 && this.isActive())
this.world.setBlockState(this.getPos(), this.world.getBlockState(this.getPos()).withProperty(BlockMachineBase.ACTIVE, false));
if (world.getTotalWorldTime() - lastOutput < 30 && !isActive()) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachineBase.ACTIVE, true));
}
else if (world.getTotalWorldTime() - lastOutput > 30 && isActive()) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachineBase.ACTIVE, false));
}
}
public int getProgressScaled(final int scale) {
if (this.isActive()){
return this.ticksSinceLastChange * scale;
public int getProgressScaled(int scale) {
if (isActive()){
return ticksSinceLastChange * scale;
}
return 0;
}
protected boolean tryAddingEnergy(int amount) {
if (this.getMaxPower() - this.getEnergy() >= amount) {
if (getMaxPower() - getEnergy() >= amount) {
addEnergy(amount);
return true;
} else if (this.getMaxPower() - this.getEnergy() > 0) {
addEnergy(this.getMaxPower() - this.getEnergy());
} else if (getMaxPower() - getEnergy() > 0) {
addEnergy(getMaxPower() - getEnergy());
return true;
}
@ -135,8 +135,8 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
}
protected boolean acceptFluid() {
if (!this.getStackInSlot(0).isEmpty()) {
FluidStack stack = FluidUtils.getFluidStackInContainer(this.getStackInSlot(0));
if (!getStackInSlot(0).isEmpty()) {
FluidStack stack = FluidUtils.getFluidStackInContainer(getStackInSlot(0));
if (stack != null)
return recipes.getRecipeForFluid(stack.getFluid()).isPresent();
}

View file

@ -48,7 +48,7 @@ public class TileCreativeSolarPanel extends TilePowerAcceptor implements IToolDr
@Override
public void update() {
super.update();
this.setEnergy(getMaxPower());
setEnergy(getMaxPower());
}
@Override
@ -58,7 +58,7 @@ public class TileCreativeSolarPanel extends TilePowerAcceptor implements IToolDr
@Override
public double getBaseMaxPower() {
return 1000000;
return 1_000_000;
}
@Override
@ -73,7 +73,7 @@ public class TileCreativeSolarPanel extends TilePowerAcceptor implements IToolDr
@Override
public double getBaseMaxOutput() {
return 16192;
return 16_192;
}
@Override

View file

@ -40,7 +40,8 @@ import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileDragonEggSyphon extends TilePowerAcceptor implements IToolDrop, IInventoryProvider {
public class TileDragonEggSyphon extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider {
@ConfigRegistry(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxOutput", comment = "Dragon Egg Siphoner Max Output (Value in EU)")
public static int maxOutput = 128;
@ -55,27 +56,7 @@ public class TileDragonEggSyphon extends TilePowerAcceptor implements IToolDrop,
public TileDragonEggSyphon() {
super();
}
@Override
public void update() {
super.update();
if (!world.isRemote) {
if (world.getBlockState(new BlockPos(getPos().getX(), getPos().getY() + 1, getPos().getZ()))
.getBlock() == Blocks.DRAGON_EGG) {
if (tryAddingEnergy(energyPerTick))
this.lastOutput = this.world.getTotalWorldTime();
}
if (this.world.getTotalWorldTime() - this.lastOutput < 30 && !this.isActive())
this.world.setBlockState(this.getPos(),
this.world.getBlockState(this.getPos()).withProperty(BlockMachineBase.ACTIVE, true));
else if (this.world.getTotalWorldTime() - this.lastOutput > 30 && this.isActive())
this.world.setBlockState(this.getPos(),
this.world.getBlockState(this.getPos()).withProperty(BlockMachineBase.ACTIVE, false));
}
}
private boolean tryAddingEnergy(int amount) {
if (this.getMaxPower() - this.getEnergy() >= amount) {
addEnergy(amount);
@ -86,14 +67,25 @@ public class TileDragonEggSyphon extends TilePowerAcceptor implements IToolDrop,
}
return false;
}
// TilePowerAcceptor
@Override
public ItemStack getToolDrop(EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.DRAGON_EGG_SYPHON, 1);
}
public void update() {
super.update();
public boolean isComplete() {
return false;
if (!world.isRemote) {
if (world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
.getBlock() == Blocks.DRAGON_EGG) {
if (tryAddingEnergy(energyPerTick))
lastOutput = world.getTotalWorldTime();
}
if (world.getTotalWorldTime() - lastOutput < 30 && !isActive()) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachineBase.ACTIVE, true));
} else if (world.getTotalWorldTime() - lastOutput > 30 && isActive()) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachineBase.ACTIVE, false));
}
}
}
@Override
@ -120,7 +112,14 @@ public class TileDragonEggSyphon extends TilePowerAcceptor implements IToolDrop,
public double getBaseMaxInput() {
return 0;
}
// IToolDrop
@Override
public ItemStack getToolDrop(EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.DRAGON_EGG_SYPHON, 1);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
return inventory;