More formatting changes.
This commit is contained in:
parent
52ff6699b4
commit
452932c04e
10 changed files with 159 additions and 158 deletions
|
@ -96,13 +96,13 @@ public class TileCable extends TileEntity
|
||||||
@Override
|
@Override
|
||||||
public SPacketUpdateTileEntity getUpdatePacket() {
|
public SPacketUpdateTileEntity getUpdatePacket() {
|
||||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||||
this.writeToNBT(nbtTag);
|
writeToNBT(nbtTag);
|
||||||
return new SPacketUpdateTileEntity(getPos(), 1, nbtTag);
|
return new SPacketUpdateTileEntity(getPos(), 1, nbtTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||||
this.readFromNBT(packet.getNbtCompound());
|
readFromNBT(packet.getNbtCompound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -131,9 +131,9 @@ public class TileCable extends TileEntity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.cableType == null ){
|
if (cableType == null ){
|
||||||
this.cableType = getCableType();
|
cableType = getCableType();
|
||||||
this.transferRate = this.cableType.transferRate * RebornCoreConfig.euPerFU;
|
transferRate = cableType.transferRate * RebornCoreConfig.euPerFU;
|
||||||
}
|
}
|
||||||
|
|
||||||
ticksSinceLastChange++;
|
ticksSinceLastChange++;
|
||||||
|
@ -206,12 +206,12 @@ public class TileCable extends TileEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyStored() {
|
public int getEnergyStored() {
|
||||||
return this.power;
|
return power;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxEnergyStored() {
|
public int getMaxEnergyStored() {
|
||||||
return this.transferRate * 5;
|
return transferRate * 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
* @return boolean Return true if coils are present
|
* @return boolean Return true if coils are present
|
||||||
*/
|
*/
|
||||||
public boolean checkCoils() {
|
public boolean checkCoils() {
|
||||||
List<BlockPos> coils = Torus.generate(getPos(), size);
|
List<BlockPos> coils = Torus.generate(pos, size);
|
||||||
for(BlockPos coilPos : coils){
|
for(BlockPos coilPos : coils){
|
||||||
if (!isCoil(coilPos)) {
|
if (!isCoil(coilPos)) {
|
||||||
coilCount = 0;
|
coilCount = 0;
|
||||||
|
@ -104,19 +104,19 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
* @param pos coordinate for block
|
* @param pos coordinate for block
|
||||||
* @return boolean Returns true if block is fusion coil
|
* @return boolean Returns true if block is fusion coil
|
||||||
*/
|
*/
|
||||||
public boolean isCoil(final BlockPos pos) {
|
public boolean isCoil(BlockPos pos) {
|
||||||
return this.world.getBlockState(pos).getBlock() == ModBlocks.FUSION_COIL;
|
return world.getBlockState(pos).getBlock() == ModBlocks.FUSION_COIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets crafter progress and recipe
|
* Resets crafter progress and recipe
|
||||||
*/
|
*/
|
||||||
private void resetCrafter() {
|
private void resetCrafter() {
|
||||||
this.currentRecipe = null;
|
currentRecipe = null;
|
||||||
this.crafingTickTime = 0;
|
crafingTickTime = 0;
|
||||||
this.finalTickTime = 0;
|
finalTickTime = 0;
|
||||||
this.neededPower = 0;
|
neededPower = 0;
|
||||||
this.hasStartedCrafting = false;
|
hasStartedCrafting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,16 +128,16 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
* @param oreDic boolean Should we use ore dictionary
|
* @param oreDic boolean Should we use ore dictionary
|
||||||
* @return boolean Returns true if ItemStack will fit into slot
|
* @return boolean Returns true if ItemStack will fit into slot
|
||||||
*/
|
*/
|
||||||
public boolean canFitStack(final ItemStack stack, final int slot, final boolean oreDic) {// Checks to see if it can
|
public boolean canFitStack(ItemStack stack, int slot, boolean oreDic) {// Checks to see if it can
|
||||||
// fit the stack
|
// fit the stack
|
||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this.inventory.getStackInSlot(slot).isEmpty()) {
|
if (inventory.getStackInSlot(slot).isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ItemUtils.isItemEqual(this.inventory.getStackInSlot(slot), stack, true, true, oreDic)) {
|
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic)) {
|
||||||
if (stack.getCount() + this.inventory.getStackInSlot(slot).getCount() <= stack.getMaxStackSize()) {
|
if (stack.getCount() + inventory.getStackInSlot(slot).getCount() <= stack.getMaxStackSize()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,8 +151,8 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
* @return int Scale of progress
|
* @return int Scale of progress
|
||||||
*/
|
*/
|
||||||
public int getProgressScaled(int scale) {
|
public int getProgressScaled(int scale) {
|
||||||
if (this.crafingTickTime != 0 && this.finalTickTime != 0) {
|
if (crafingTickTime != 0 && finalTickTime != 0) {
|
||||||
return this.crafingTickTime * scale / this.finalTickTime;
|
return crafingTickTime * scale / finalTickTime;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -163,11 +163,11 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
private void updateCurrentRecipe() {
|
private void updateCurrentRecipe() {
|
||||||
for (final FusionReactorRecipe reactorRecipe : FusionReactorRecipeHelper.reactorRecipes) {
|
for (final FusionReactorRecipe reactorRecipe : FusionReactorRecipeHelper.reactorRecipes) {
|
||||||
if (validateReactorRecipe(reactorRecipe)) {
|
if (validateReactorRecipe(reactorRecipe)) {
|
||||||
this.currentRecipe = reactorRecipe;
|
currentRecipe = reactorRecipe;
|
||||||
this.crafingTickTime = 0;
|
crafingTickTime = 0;
|
||||||
this.finalTickTime = this.currentRecipe.getTickTime();
|
finalTickTime = currentRecipe.getTickTime();
|
||||||
this.neededPower = (int) this.currentRecipe.getStartEU();
|
neededPower = (int) currentRecipe.getStartEU();
|
||||||
this.hasStartedCrafting = false;
|
hasStartedCrafting = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.canFitStack(recipe.getOutput(), outputStackSlot, true)) {
|
if (canFitStack(recipe.getOutput(), outputStackSlot, true)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,77 +202,77 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
|
|
||||||
if (this.world.isRemote) {
|
if (world.isRemote) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force check every second
|
// Force check every second
|
||||||
if (this.world.getTotalWorldTime() % 20 == 0) {
|
if (world.getTotalWorldTime() % 20 == 0) {
|
||||||
this.checkCoils();
|
checkCoils();
|
||||||
this.inventory.hasChanged = true;
|
inventory.hasChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.coilCount == 0) {
|
if (coilCount == 0) {
|
||||||
this.resetCrafter();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.currentRecipe == null && this.inventory.hasChanged == true) {
|
|
||||||
updateCurrentRecipe();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.currentRecipe != null) {
|
|
||||||
if (!hasStartedCrafting && this.inventory.hasChanged && !validateReactorRecipe(this.currentRecipe)) {
|
|
||||||
resetCrafter();
|
resetCrafter();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.hasStartedCrafting) {
|
if (currentRecipe == null && inventory.hasChanged == true) {
|
||||||
// Ignition!
|
updateCurrentRecipe();
|
||||||
if (this.canUseEnergy(this.currentRecipe.getStartEU())) {
|
|
||||||
this.useEnergy(this.currentRecipe.getStartEU());
|
|
||||||
this.hasStartedCrafting = true;
|
|
||||||
this.decrStackSize(this.topStackSlot, this.currentRecipe.getTopInput().getCount());
|
|
||||||
if (!this.currentRecipe.getBottomInput().isEmpty()) {
|
|
||||||
this.decrStackSize(this.bottomStackSlot, this.currentRecipe.getBottomInput().getCount());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasStartedCrafting && this.crafingTickTime < this.finalTickTime) {
|
|
||||||
this.crafingTickTime++;
|
|
||||||
// Power gen
|
|
||||||
if (this.currentRecipe.getEuTick() > 0) {
|
|
||||||
// Waste power if it has no where to go
|
|
||||||
this.addEnergy(this.currentRecipe.getEuTick() * getPowerMultiplier());
|
|
||||||
this.powerChange = this.currentRecipe.getEuTick() * getPowerMultiplier();
|
|
||||||
} else { // Power user
|
|
||||||
if (this.canUseEnergy(this.currentRecipe.getEuTick() * -1)) {
|
|
||||||
this.setEnergy(this.getEnergy() - this.currentRecipe.getEuTick() * -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (this.crafingTickTime >= this.finalTickTime) {
|
|
||||||
if (this.canFitStack(this.currentRecipe.getOutput(), this.outputStackSlot, true)) {
|
|
||||||
if (this.getStackInSlot(this.outputStackSlot).isEmpty()) {
|
|
||||||
this.setInventorySlotContents(this.outputStackSlot, this.currentRecipe.getOutput().copy());
|
|
||||||
} else {
|
|
||||||
this.decrStackSize(this.outputStackSlot, -this.currentRecipe.getOutput().getCount());
|
|
||||||
}
|
|
||||||
if (this.validateReactorRecipe(this.currentRecipe)) {
|
|
||||||
this.crafingTickTime = 0;
|
|
||||||
this.decrStackSize(this.topStackSlot, this.currentRecipe.getTopInput().getCount());
|
|
||||||
if (!this.currentRecipe.getBottomInput().isEmpty()) {
|
|
||||||
this.decrStackSize(this.bottomStackSlot, this.currentRecipe.getBottomInput().getCount());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.resetCrafter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.markDirty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.inventory.hasChanged) {
|
if (currentRecipe != null) {
|
||||||
this.inventory.hasChanged = false;
|
if (!hasStartedCrafting && inventory.hasChanged && !validateReactorRecipe(currentRecipe)) {
|
||||||
|
resetCrafter();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasStartedCrafting) {
|
||||||
|
// Ignition!
|
||||||
|
if (canUseEnergy(currentRecipe.getStartEU())) {
|
||||||
|
useEnergy(currentRecipe.getStartEU());
|
||||||
|
hasStartedCrafting = true;
|
||||||
|
decrStackSize(topStackSlot, currentRecipe.getTopInput().getCount());
|
||||||
|
if (!currentRecipe.getBottomInput().isEmpty()) {
|
||||||
|
decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().getCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasStartedCrafting && crafingTickTime < finalTickTime) {
|
||||||
|
crafingTickTime++;
|
||||||
|
// Power gen
|
||||||
|
if (currentRecipe.getEuTick() > 0) {
|
||||||
|
// Waste power if it has no where to go
|
||||||
|
addEnergy(currentRecipe.getEuTick() * getPowerMultiplier());
|
||||||
|
powerChange = currentRecipe.getEuTick() * getPowerMultiplier();
|
||||||
|
} else { // Power user
|
||||||
|
if (canUseEnergy(currentRecipe.getEuTick() * -1)) {
|
||||||
|
setEnergy(getEnergy() - currentRecipe.getEuTick() * -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (crafingTickTime >= finalTickTime) {
|
||||||
|
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) {
|
||||||
|
if (getStackInSlot(outputStackSlot).isEmpty()) {
|
||||||
|
setInventorySlotContents(outputStackSlot, currentRecipe.getOutput().copy());
|
||||||
|
} else {
|
||||||
|
decrStackSize(outputStackSlot, -currentRecipe.getOutput().getCount());
|
||||||
|
}
|
||||||
|
if (validateReactorRecipe(this.currentRecipe)) {
|
||||||
|
crafingTickTime = 0;
|
||||||
|
decrStackSize(topStackSlot, currentRecipe.getTopInput().getCount());
|
||||||
|
if (!currentRecipe.getBottomInput().isEmpty()) {
|
||||||
|
decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().getCount());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resetCrafter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inventory.hasChanged) {
|
||||||
|
inventory.hasChanged = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,18 +289,18 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(final EnumFacing direction) {
|
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||||
return !(direction == EnumFacing.DOWN || direction == EnumFacing.UP);
|
return !(direction == EnumFacing.DOWN || direction == EnumFacing.UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(final EnumFacing direction) {
|
public boolean canProvideEnergy(EnumFacing direction) {
|
||||||
return direction == EnumFacing.DOWN || direction == EnumFacing.UP;
|
return direction == EnumFacing.DOWN || direction == EnumFacing.UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
if (!this.hasStartedCrafting) {
|
if (!hasStartedCrafting) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return Integer.MAX_VALUE / RebornCoreConfig.euPerFU;
|
return Integer.MAX_VALUE / RebornCoreConfig.euPerFU;
|
||||||
|
@ -308,7 +308,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public double getBaseMaxInput() {
|
||||||
if (this.hasStartedCrafting) {
|
if (hasStartedCrafting) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return maxInput;
|
return maxInput;
|
||||||
|
@ -360,14 +360,14 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
|
|
||||||
// IToolDrop
|
// IToolDrop
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(EntityPlayer p0) {
|
public ItemStack getToolDrop(EntityPlayer playerIn) {
|
||||||
return new ItemStack(ModBlocks.FUSION_CONTROL_COMPUTER, 1);
|
return new ItemStack(ModBlocks.FUSION_CONTROL_COMPUTER, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInventoryProvider
|
// IInventoryProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return this.inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IContainerProvider
|
// IContainerProvider
|
||||||
|
@ -384,34 +384,34 @@ public class TileFusionControlComputer extends TilePowerAcceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCoilStatus() {
|
public int getCoilStatus() {
|
||||||
return this.coilCount;
|
return coilCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCoilStatus(final int coilStatus) {
|
public void setCoilStatus(int coilStatus) {
|
||||||
this.coilCount = coilStatus;
|
this.coilCount = coilStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCrafingTickTime() {
|
public int getCrafingTickTime() {
|
||||||
return this.crafingTickTime;
|
return crafingTickTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCrafingTickTime(final int crafingTickTime) {
|
public void setCrafingTickTime(int crafingTickTime) {
|
||||||
this.crafingTickTime = crafingTickTime;
|
this.crafingTickTime = crafingTickTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFinalTickTime() {
|
public int getFinalTickTime() {
|
||||||
return this.finalTickTime;
|
return finalTickTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFinalTickTime(final int finalTickTime) {
|
public void setFinalTickTime(int finalTickTime) {
|
||||||
this.finalTickTime = finalTickTime;
|
this.finalTickTime = finalTickTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNeededPower() {
|
public int getNeededPower() {
|
||||||
return this.neededPower;
|
return neededPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNeededPower(final int neededPower) {
|
public void setNeededPower(int neededPower) {
|
||||||
this.neededPower = neededPower;
|
this.neededPower = neededPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class TileGasTurbine extends TileBaseFluidGenerator implements IContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
public ItemStack getToolDrop(EntityPlayer entityPlayer) {
|
||||||
return new ItemStack(ModBlocks.GAS_TURBINE, 1);
|
return new ItemStack(ModBlocks.GAS_TURBINE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,44 +61,44 @@ public class TileLightningRod extends TilePowerAcceptor implements IToolDrop {
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
|
|
||||||
if (this.onStatusHoldTicks > 0)
|
if (onStatusHoldTicks > 0)
|
||||||
--this.onStatusHoldTicks;
|
--onStatusHoldTicks;
|
||||||
|
|
||||||
if (this.onStatusHoldTicks == 0 || this.getEnergy() <= 0) {
|
if (onStatusHoldTicks == 0 || getEnergy() <= 0) {
|
||||||
if (this.getBlockType() instanceof BlockMachineBase)
|
if (getBlockType() instanceof BlockMachineBase)
|
||||||
((BlockMachineBase) this.getBlockType()).setActive(false, this.world, this.pos);
|
((BlockMachineBase) getBlockType()).setActive(false, world, pos);
|
||||||
this.onStatusHoldTicks = -1;
|
onStatusHoldTicks = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
final float weatherStrength = this.world.getThunderStrength(1.0F);
|
final float weatherStrength = world.getThunderStrength(1.0F);
|
||||||
if (weatherStrength > 0.2F) {
|
if (weatherStrength > 0.2F) {
|
||||||
//lightStrikeChance = (MAX - (CHANCE * WEATHER_STRENGTH)
|
//lightStrikeChance = (MAX - (CHANCE * WEATHER_STRENGTH)
|
||||||
final float lightStrikeChance = (100F - chanceOfStrike) * 20F;
|
final float lightStrikeChance = (100F - chanceOfStrike) * 20F;
|
||||||
final float totalChance = lightStrikeChance * this.getLightningStrikeMultiplier() * (1.1F - weatherStrength);
|
final float totalChance = lightStrikeChance * getLightningStrikeMultiplier() * (1.1F - weatherStrength);
|
||||||
if (this.world.rand.nextInt((int) Math.floor(totalChance)) == 0) {
|
if (world.rand.nextInt((int) Math.floor(totalChance)) == 0) {
|
||||||
if (!isValidIronFence(pos.up().getY())) {
|
if (!isValidIronFence(pos.up().getY())) {
|
||||||
this.onStatusHoldTicks = 400;
|
onStatusHoldTicks = 400;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final EntityLightningBolt lightningBolt = new EntityLightningBolt(this.world,
|
final EntityLightningBolt lightningBolt = new EntityLightningBolt(world,
|
||||||
this.pos.getX() + 0.5F,
|
pos.getX() + 0.5F,
|
||||||
this.world.provider.getAverageGroundLevel(),
|
world.provider.getAverageGroundLevel(),
|
||||||
this.pos.getZ() + 0.5F, false);
|
pos.getZ() + 0.5F, false);
|
||||||
this.world.addWeatherEffect(lightningBolt);
|
world.addWeatherEffect(lightningBolt);
|
||||||
this.world.spawnEntity(lightningBolt);
|
world.spawnEntity(lightningBolt);
|
||||||
this.addEnergy(baseEnergyStrike * (0.3F + weatherStrength));
|
addEnergy(baseEnergyStrike * (0.3F + weatherStrength));
|
||||||
((BlockMachineBase) this.getBlockType()).setActive(true, this.world, this.pos);
|
((BlockMachineBase) getBlockType()).setActive(true, world, pos);
|
||||||
this.onStatusHoldTicks = 400;
|
onStatusHoldTicks = 400;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getLightningStrikeMultiplier() {
|
public float getLightningStrikeMultiplier() {
|
||||||
final float actualHeight = this.world.provider.getActualHeight();
|
final float actualHeight = world.provider.getActualHeight();
|
||||||
final float groundLevel = this.world.provider.getAverageGroundLevel();
|
final float groundLevel = world.provider.getAverageGroundLevel();
|
||||||
for (int i = this.pos.getY() + 1; i < actualHeight; i++) {
|
for (int i = pos.getY() + 1; i < actualHeight; i++) {
|
||||||
if (!this.isValidIronFence(i)) {
|
if (!isValidIronFence(i)) {
|
||||||
if (groundLevel >= i)
|
if (groundLevel >= i)
|
||||||
return 4.3F;
|
return 4.3F;
|
||||||
final float max = actualHeight - groundLevel;
|
final float max = actualHeight - groundLevel;
|
||||||
|
@ -109,8 +109,8 @@ public class TileLightningRod extends TilePowerAcceptor implements IToolDrop {
|
||||||
return 4F;
|
return 4F;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValidIronFence(final int y) {
|
public boolean isValidIronFence(int y) {
|
||||||
final Item itemBlock = Item.getItemFromBlock(this.world.getBlockState(new BlockPos(this.pos.getX(), y, this.pos.getZ())).getBlock());
|
final Item itemBlock = Item.getItemFromBlock(this.world.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock());
|
||||||
for (final ItemStack fence : OreDictionary.getOres("fenceIron")) {
|
for (final ItemStack fence : OreDictionary.getOres("fenceIron")) {
|
||||||
if (fence.getItem() == itemBlock)
|
if (fence.getItem() == itemBlock)
|
||||||
return true;
|
return true;
|
||||||
|
@ -144,7 +144,7 @@ public class TileLightningRod extends TilePowerAcceptor implements IToolDrop {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(final EntityPlayer p0) {
|
public ItemStack getToolDrop(EntityPlayer playerIn) {
|
||||||
return new ItemStack(ModBlocks.LIGHTNING_ROD);
|
return new ItemStack(ModBlocks.LIGHTNING_ROD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class TilePlasmaGenerator extends TileBaseFluidGenerator implements ICont
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(EntityPlayer p0) {
|
public ItemStack getToolDrop(EntityPlayer playerIn) {
|
||||||
return new ItemStack(ModBlocks.PLASMA_GENERATOR, 1);
|
return new ItemStack(ModBlocks.PLASMA_GENERATOR, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class TileSemiFluidGenerator extends TileBaseFluidGenerator implements IC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(final EntityPlayer arg0) {
|
public ItemStack getToolDrop(EntityPlayer playerIn) {
|
||||||
return new ItemStack(ModBlocks.SEMI_FLUID_GENERATOR, 1);
|
return new ItemStack(ModBlocks.SEMI_FLUID_GENERATOR, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,31 +61,31 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
if (this.world.isRemote) {
|
if (world.isRemote) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (world.getTotalWorldTime() % 20 == 0) {
|
if (world.getTotalWorldTime() % 20 == 0) {
|
||||||
canSeeSky = this.world.canBlockSeeSky(this.pos.up());
|
canSeeSky = world.canBlockSeeSky(pos.up());
|
||||||
if(lastSate != this.isSunOut()){
|
if(lastSate != isSunOut()){
|
||||||
this.world.setBlockState(this.getPos(),
|
world.setBlockState(pos,
|
||||||
this.world.getBlockState(this.getPos()).withProperty(BlockSolarPanel.ACTIVE, this.isSunOut()));
|
world.getBlockState(pos).withProperty(BlockSolarPanel.ACTIVE, isSunOut()));
|
||||||
lastSate = isSunOut();
|
lastSate = isSunOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (isSunOut()) {
|
if (isSunOut()) {
|
||||||
this.powerToAdd = panel.generationRateD;
|
powerToAdd = panel.generationRateD;
|
||||||
} else if (canSeeSky) {
|
} else if (canSeeSky) {
|
||||||
this.powerToAdd = panel.generationRateN;
|
powerToAdd = panel.generationRateN;
|
||||||
} else {
|
} else {
|
||||||
this.powerToAdd = 0;
|
powerToAdd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addEnergy(this.powerToAdd);
|
addEnergy(powerToAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSunOut() {
|
public boolean isSunOut() {
|
||||||
return canSeeSky && !this.world.isRaining() && !this.world.isThundering() && this.world.isDaytime();
|
return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDaytime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,7 +115,7 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumPowerTier getTier() {
|
public EnumPowerTier getTier() {
|
||||||
return this.panel.powerTier;
|
return panel.powerTier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -124,8 +124,8 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(final EntityPlayer p0) {
|
public ItemStack getToolDrop(final EntityPlayer playerIn) {
|
||||||
return new ItemStack(ModBlocks.SOLAR_PANEL, 1, this.panel.ordinal());
|
return new ItemStack(ModBlocks.SOLAR_PANEL, 1, panel.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -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)")
|
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorMaxOutput", comment = "Solid Fuel Generator Max Output (Value in EU)")
|
||||||
public static int maxOutput = 32;
|
public static int maxOutput = 32;
|
||||||
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorMaxEnergy", comment = "Solid Fuel Generator Max Energy (Value in EU)")
|
@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)")
|
@ConfigRegistry(config = "generators", category = "generator", key = "GeneratorEnergyOutput", comment = "Solid Fuel Generator Energy Output Amount (Value in EU)")
|
||||||
public static int outputAmount = 10;
|
public static int outputAmount = 10;
|
||||||
|
|
||||||
|
@ -68,54 +68,55 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getItemBurnTime(final ItemStack stack) {
|
public static int getItemBurnTime(ItemStack stack) {
|
||||||
return TileEntityFurnace.getItemBurnTime(stack) / 4;
|
return TileEntityFurnace.getItemBurnTime(stack) / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
if (this.world.isRemote) {
|
if (world.isRemote) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.getEnergy() < this.getMaxPower()) {
|
if (getEnergy() < getMaxPower()) {
|
||||||
if (this.burnTime > 0) {
|
if (burnTime > 0) {
|
||||||
this.burnTime--;
|
burnTime--;
|
||||||
this.addEnergy(TileSolidFuelGenerator.outputAmount);
|
addEnergy(TileSolidFuelGenerator.outputAmount);
|
||||||
this.isBurning = true;
|
isBurning = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.isBurning = false;
|
isBurning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.burnTime == 0) {
|
if (burnTime == 0) {
|
||||||
this.updateState();
|
updateState();
|
||||||
this.burnTime = this.totalBurnTime = TileSolidFuelGenerator.getItemBurnTime(this.getStackInSlot(this.fuelSlot));
|
burnTime = totalBurnTime = TileSolidFuelGenerator.getItemBurnTime(getStackInSlot(fuelSlot));
|
||||||
if (this.burnTime > 0) {
|
if (burnTime > 0) {
|
||||||
this.updateState();
|
updateState();
|
||||||
this.burnItem = this.getStackInSlot(this.fuelSlot);
|
burnItem = getStackInSlot(fuelSlot);
|
||||||
if (this.getStackInSlot(this.fuelSlot).getCount() == 1) {
|
if (getStackInSlot(fuelSlot).getCount() == 1) {
|
||||||
if (this.getStackInSlot(this.fuelSlot).getItem() == Items.LAVA_BUCKET || this.getStackInSlot(this.fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket) {
|
if (getStackInSlot(fuelSlot).getItem() == Items.LAVA_BUCKET || getStackInSlot(fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket) {
|
||||||
this.setInventorySlotContents(this.fuelSlot, new ItemStack(Items.BUCKET));
|
setInventorySlotContents(fuelSlot, new ItemStack(Items.BUCKET));
|
||||||
} else {
|
} else {
|
||||||
this.setInventorySlotContents(this.fuelSlot, ItemStack.EMPTY);
|
setInventorySlotContents(fuelSlot, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.decrStackSize(this.fuelSlot, 1);
|
decrStackSize(fuelSlot, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastTickBurning = this.isBurning;
|
lastTickBurning = isBurning;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateState() {
|
public void updateState() {
|
||||||
final IBlockState BlockStateContainer = this.world.getBlockState(this.pos);
|
final IBlockState BlockStateContainer = world.getBlockState(pos);
|
||||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
|
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
|
||||||
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
|
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
|
||||||
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != this.burnTime > 0)
|
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != burnTime > 0) {
|
||||||
blockMachineBase.setActive(this.burnTime > 0, this.world, this.pos);
|
blockMachineBase.setActive(burnTime > 0, world, pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,12 +126,12 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(final EnumFacing direction) {
|
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(final EnumFacing direction) {
|
public boolean canProvideEnergy(EnumFacing direction) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,17 +146,17 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(final EntityPlayer p0) {
|
public ItemStack getToolDrop(EntityPlayer playerIn) {
|
||||||
return new ItemStack(ModBlocks.SOLID_FUEL_GENEREATOR);
|
return new ItemStack(ModBlocks.SOLID_FUEL_GENEREATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return this.inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBurnTime() {
|
public int getBurnTime() {
|
||||||
return this.burnTime;
|
return burnTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBurnTime(final int burnTime) {
|
public void setBurnTime(final int burnTime) {
|
||||||
|
@ -163,7 +164,7 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalBurnTime() {
|
public int getTotalBurnTime() {
|
||||||
return this.totalBurnTime;
|
return totalBurnTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotalBurnTime(final int totalBurnTime) {
|
public void setTotalBurnTime(final int totalBurnTime) {
|
||||||
|
@ -171,7 +172,7 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getScaledBurnTime(final int i) {
|
public int getScaledBurnTime(final int i) {
|
||||||
return (int) ((float) this.burnTime / (float) this.totalBurnTime * i);
|
return (int) ((float) burnTime / (float) totalBurnTime * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class TileThermalGenerator extends TileBaseFluidGenerator implements ICon
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
public ItemStack getToolDrop(EntityPlayer entityPlayer) {
|
||||||
return new ItemStack(ModBlocks.THERMAL_GENERATOR, 1);
|
return new ItemStack(ModBlocks.THERMAL_GENERATOR, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,12 +57,12 @@ public class TileWindMill extends TilePowerAcceptor implements IToolDrop {
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
if (this.pos.getY() > 64) {
|
if (pos.getY() > 64) {
|
||||||
int actualPower = baseEnergy;
|
int actualPower = baseEnergy;
|
||||||
if (this.world.isThundering()) {
|
if (world.isThundering()) {
|
||||||
actualPower *= thunderMultiplier;
|
actualPower *= thunderMultiplier;
|
||||||
}
|
}
|
||||||
this.addEnergy(actualPower); // Value taken from
|
addEnergy(actualPower); // Value taken from
|
||||||
// http://wiki.industrial-craft.net/?title=Wind_Mill
|
// http://wiki.industrial-craft.net/?title=Wind_Mill
|
||||||
// Not worth making more complicated
|
// Not worth making more complicated
|
||||||
}
|
}
|
||||||
|
@ -74,12 +74,12 @@ public class TileWindMill extends TilePowerAcceptor implements IToolDrop {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(final EnumFacing direction) {
|
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(final EnumFacing direction) {
|
public boolean canProvideEnergy(EnumFacing direction) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public class TileWindMill extends TilePowerAcceptor implements IToolDrop {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(final EntityPlayer p0) {
|
public ItemStack getToolDrop(EntityPlayer playerIn) {
|
||||||
return new ItemStack(ModBlocks.WIND_MILL);
|
return new ItemStack(ModBlocks.WIND_MILL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue