More formatting changes.

This commit is contained in:
drcrazy 2018-06-23 19:00:44 +03:00
parent 52ff6699b4
commit 452932c04e
10 changed files with 159 additions and 158 deletions

View file

@ -52,7 +52,7 @@ public class TileGasTurbine extends TileBaseFluidGenerator implements IContainer
}
@Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
public ItemStack getToolDrop(EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.GAS_TURBINE, 1);
}

View file

@ -61,44 +61,44 @@ public class TileLightningRod extends TilePowerAcceptor implements IToolDrop {
public void update() {
super.update();
if (this.onStatusHoldTicks > 0)
--this.onStatusHoldTicks;
if (onStatusHoldTicks > 0)
--onStatusHoldTicks;
if (this.onStatusHoldTicks == 0 || this.getEnergy() <= 0) {
if (this.getBlockType() instanceof BlockMachineBase)
((BlockMachineBase) this.getBlockType()).setActive(false, this.world, this.pos);
this.onStatusHoldTicks = -1;
if (onStatusHoldTicks == 0 || getEnergy() <= 0) {
if (getBlockType() instanceof BlockMachineBase)
((BlockMachineBase) getBlockType()).setActive(false, world, pos);
onStatusHoldTicks = -1;
}
final float weatherStrength = this.world.getThunderStrength(1.0F);
final float weatherStrength = world.getThunderStrength(1.0F);
if (weatherStrength > 0.2F) {
//lightStrikeChance = (MAX - (CHANCE * WEATHER_STRENGTH)
final float lightStrikeChance = (100F - chanceOfStrike) * 20F;
final float totalChance = lightStrikeChance * this.getLightningStrikeMultiplier() * (1.1F - weatherStrength);
if (this.world.rand.nextInt((int) Math.floor(totalChance)) == 0) {
final float totalChance = lightStrikeChance * getLightningStrikeMultiplier() * (1.1F - weatherStrength);
if (world.rand.nextInt((int) Math.floor(totalChance)) == 0) {
if (!isValidIronFence(pos.up().getY())) {
this.onStatusHoldTicks = 400;
onStatusHoldTicks = 400;
return;
}
final EntityLightningBolt lightningBolt = new EntityLightningBolt(this.world,
this.pos.getX() + 0.5F,
this.world.provider.getAverageGroundLevel(),
this.pos.getZ() + 0.5F, false);
this.world.addWeatherEffect(lightningBolt);
this.world.spawnEntity(lightningBolt);
this.addEnergy(baseEnergyStrike * (0.3F + weatherStrength));
((BlockMachineBase) this.getBlockType()).setActive(true, this.world, this.pos);
this.onStatusHoldTicks = 400;
final EntityLightningBolt lightningBolt = new EntityLightningBolt(world,
pos.getX() + 0.5F,
world.provider.getAverageGroundLevel(),
pos.getZ() + 0.5F, false);
world.addWeatherEffect(lightningBolt);
world.spawnEntity(lightningBolt);
addEnergy(baseEnergyStrike * (0.3F + weatherStrength));
((BlockMachineBase) getBlockType()).setActive(true, world, pos);
onStatusHoldTicks = 400;
}
}
}
public float getLightningStrikeMultiplier() {
final float actualHeight = this.world.provider.getActualHeight();
final float groundLevel = this.world.provider.getAverageGroundLevel();
for (int i = this.pos.getY() + 1; i < actualHeight; i++) {
if (!this.isValidIronFence(i)) {
final float actualHeight = world.provider.getActualHeight();
final float groundLevel = world.provider.getAverageGroundLevel();
for (int i = pos.getY() + 1; i < actualHeight; i++) {
if (!isValidIronFence(i)) {
if (groundLevel >= i)
return 4.3F;
final float max = actualHeight - groundLevel;
@ -109,8 +109,8 @@ public class TileLightningRod extends TilePowerAcceptor implements IToolDrop {
return 4F;
}
public boolean isValidIronFence(final int y) {
final Item itemBlock = Item.getItemFromBlock(this.world.getBlockState(new BlockPos(this.pos.getX(), y, this.pos.getZ())).getBlock());
public boolean isValidIronFence(int y) {
final Item itemBlock = Item.getItemFromBlock(this.world.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock());
for (final ItemStack fence : OreDictionary.getOres("fenceIron")) {
if (fence.getItem() == itemBlock)
return true;
@ -144,7 +144,7 @@ public class TileLightningRod extends TilePowerAcceptor implements IToolDrop {
}
@Override
public ItemStack getToolDrop(final EntityPlayer p0) {
public ItemStack getToolDrop(EntityPlayer playerIn) {
return new ItemStack(ModBlocks.LIGHTNING_ROD);
}
}

View file

@ -52,7 +52,7 @@ public class TilePlasmaGenerator extends TileBaseFluidGenerator implements ICont
}
@Override
public ItemStack getToolDrop(EntityPlayer p0) {
public ItemStack getToolDrop(EntityPlayer playerIn) {
return new ItemStack(ModBlocks.PLASMA_GENERATOR, 1);
}

View file

@ -52,7 +52,7 @@ public class TileSemiFluidGenerator extends TileBaseFluidGenerator implements IC
}
@Override
public ItemStack getToolDrop(final EntityPlayer arg0) {
public ItemStack getToolDrop(EntityPlayer playerIn) {
return new ItemStack(ModBlocks.SEMI_FLUID_GENERATOR, 1);
}

View file

@ -61,31 +61,31 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
@Override
public void update() {
super.update();
if (this.world.isRemote) {
if (world.isRemote) {
return;
}
if (world.getTotalWorldTime() % 20 == 0) {
canSeeSky = this.world.canBlockSeeSky(this.pos.up());
if(lastSate != this.isSunOut()){
this.world.setBlockState(this.getPos(),
this.world.getBlockState(this.getPos()).withProperty(BlockSolarPanel.ACTIVE, this.isSunOut()));
canSeeSky = world.canBlockSeeSky(pos.up());
if(lastSate != isSunOut()){
world.setBlockState(pos,
world.getBlockState(pos).withProperty(BlockSolarPanel.ACTIVE, isSunOut()));
lastSate = isSunOut();
}
}
if (isSunOut()) {
this.powerToAdd = panel.generationRateD;
powerToAdd = panel.generationRateD;
} else if (canSeeSky) {
this.powerToAdd = panel.generationRateN;
powerToAdd = panel.generationRateN;
} else {
this.powerToAdd = 0;
powerToAdd = 0;
}
this.addEnergy(this.powerToAdd);
addEnergy(powerToAdd);
}
public boolean isSunOut() {
return canSeeSky && !this.world.isRaining() && !this.world.isThundering() && this.world.isDaytime();
return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDaytime();
}
@Override
@ -115,7 +115,7 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
@Override
public EnumPowerTier getTier() {
return this.panel.powerTier;
return panel.powerTier;
}
@Override
@ -124,8 +124,8 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
}
@Override
public ItemStack getToolDrop(final EntityPlayer p0) {
return new ItemStack(ModBlocks.SOLAR_PANEL, 1, this.panel.ordinal());
public ItemStack getToolDrop(final EntityPlayer playerIn) {
return new ItemStack(ModBlocks.SOLAR_PANEL, 1, panel.ordinal());
}
@Override

View file

@ -50,7 +50,7 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorMaxOutput", comment = "Solid Fuel Generator Max Output (Value in EU)")
public static int maxOutput = 32;
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorMaxEnergy", comment = "Solid Fuel Generator Max Energy (Value in EU)")
public static int maxEnergy = 10000;
public static int maxEnergy = 10_000;
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorEnergyOutput", comment = "Solid Fuel Generator Energy Output Amount (Value in EU)")
public static int outputAmount = 10;
@ -68,54 +68,55 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
super();
}
public static int getItemBurnTime(final ItemStack stack) {
public static int getItemBurnTime(ItemStack stack) {
return TileEntityFurnace.getItemBurnTime(stack) / 4;
}
@Override
public void update() {
super.update();
if (this.world.isRemote) {
if (world.isRemote) {
return;
}
if (this.getEnergy() < this.getMaxPower()) {
if (this.burnTime > 0) {
this.burnTime--;
this.addEnergy(TileSolidFuelGenerator.outputAmount);
this.isBurning = true;
if (getEnergy() < getMaxPower()) {
if (burnTime > 0) {
burnTime--;
addEnergy(TileSolidFuelGenerator.outputAmount);
isBurning = true;
}
} else {
this.isBurning = false;
isBurning = false;
}
if (this.burnTime == 0) {
this.updateState();
this.burnTime = this.totalBurnTime = TileSolidFuelGenerator.getItemBurnTime(this.getStackInSlot(this.fuelSlot));
if (this.burnTime > 0) {
this.updateState();
this.burnItem = this.getStackInSlot(this.fuelSlot);
if (this.getStackInSlot(this.fuelSlot).getCount() == 1) {
if (this.getStackInSlot(this.fuelSlot).getItem() == Items.LAVA_BUCKET || this.getStackInSlot(this.fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket) {
this.setInventorySlotContents(this.fuelSlot, new ItemStack(Items.BUCKET));
if (burnTime == 0) {
updateState();
burnTime = totalBurnTime = TileSolidFuelGenerator.getItemBurnTime(getStackInSlot(fuelSlot));
if (burnTime > 0) {
updateState();
burnItem = getStackInSlot(fuelSlot);
if (getStackInSlot(fuelSlot).getCount() == 1) {
if (getStackInSlot(fuelSlot).getItem() == Items.LAVA_BUCKET || getStackInSlot(fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket) {
setInventorySlotContents(fuelSlot, new ItemStack(Items.BUCKET));
} else {
this.setInventorySlotContents(this.fuelSlot, ItemStack.EMPTY);
setInventorySlotContents(fuelSlot, ItemStack.EMPTY);
}
} else {
this.decrStackSize(this.fuelSlot, 1);
decrStackSize(fuelSlot, 1);
}
}
}
this.lastTickBurning = this.isBurning;
lastTickBurning = isBurning;
}
public void updateState() {
final IBlockState BlockStateContainer = this.world.getBlockState(this.pos);
final IBlockState BlockStateContainer = world.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != this.burnTime > 0)
blockMachineBase.setActive(this.burnTime > 0, this.world, this.pos);
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != burnTime > 0) {
blockMachineBase.setActive(burnTime > 0, world, pos);
}
}
}
@ -125,12 +126,12 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
}
@Override
public boolean canAcceptEnergy(final EnumFacing direction) {
public boolean canAcceptEnergy(EnumFacing direction) {
return false;
}
@Override
public boolean canProvideEnergy(final EnumFacing direction) {
public boolean canProvideEnergy(EnumFacing direction) {
return true;
}
@ -145,17 +146,17 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
}
@Override
public ItemStack getToolDrop(final EntityPlayer p0) {
public ItemStack getToolDrop(EntityPlayer playerIn) {
return new ItemStack(ModBlocks.SOLID_FUEL_GENEREATOR);
}
@Override
public Inventory getInventory() {
return this.inventory;
return inventory;
}
public int getBurnTime() {
return this.burnTime;
return burnTime;
}
public void setBurnTime(final int burnTime) {
@ -163,7 +164,7 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
}
public int getTotalBurnTime() {
return this.totalBurnTime;
return totalBurnTime;
}
public void setTotalBurnTime(final int totalBurnTime) {
@ -171,7 +172,7 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
}
public int getScaledBurnTime(final int i) {
return (int) ((float) this.burnTime / (float) this.totalBurnTime * i);
return (int) ((float) burnTime / (float) totalBurnTime * i);
}
@Override

View file

@ -52,7 +52,7 @@ public class TileThermalGenerator extends TileBaseFluidGenerator implements ICon
}
@Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
public ItemStack getToolDrop(EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.THERMAL_GENERATOR, 1);
}

View file

@ -57,12 +57,12 @@ public class TileWindMill extends TilePowerAcceptor implements IToolDrop {
@Override
public void update() {
super.update();
if (this.pos.getY() > 64) {
if (pos.getY() > 64) {
int actualPower = baseEnergy;
if (this.world.isThundering()) {
if (world.isThundering()) {
actualPower *= thunderMultiplier;
}
this.addEnergy(actualPower); // Value taken from
addEnergy(actualPower); // Value taken from
// http://wiki.industrial-craft.net/?title=Wind_Mill
// Not worth making more complicated
}
@ -74,12 +74,12 @@ public class TileWindMill extends TilePowerAcceptor implements IToolDrop {
}
@Override
public boolean canAcceptEnergy(final EnumFacing direction) {
public boolean canAcceptEnergy(EnumFacing direction) {
return false;
}
@Override
public boolean canProvideEnergy(final EnumFacing direction) {
public boolean canProvideEnergy(EnumFacing direction) {
return true;
}
@ -94,7 +94,7 @@ public class TileWindMill extends TilePowerAcceptor implements IToolDrop {
}
@Override
public ItemStack getToolDrop(final EntityPlayer p0) {
public ItemStack getToolDrop(EntityPlayer playerIn) {
return new ItemStack(ModBlocks.WIND_MILL);
}
}