This commit is contained in:
Boblet 2023-08-28 16:45:17 +02:00
parent 4482e10999
commit edbe256217
3 changed files with 96 additions and 91 deletions

View File

@ -158,85 +158,87 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
this.tanks[0].setType(2, slots);
setupTanks();
for(BlockPos pos : ports) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
BlockPos portPos = pos.offset(dir);
if(tanks[1].getFill() > 0) this.sendFluid(tanks[1], worldObj, portPos.getX(), portPos.getY(), portPos.getZ(), dir);
if(worldObj.getTotalWorldTime() % 20 == 0) this.trySubscribe(tanks[0].getTankType(), worldObj, portPos.getX(), portPos.getY(), portPos.getZ(), dir);
}
}
if((typeLoaded == -1 || amountLoaded <= 0) && slots[0] != null && slots[0].getItem() == ModItems.pwr_fuel) {
typeLoaded = slots[0].getItemDamage();
amountLoaded++;
this.decrStackSize(0, 1);
this.markChanged();
} else if(slots[0] != null && slots[0].getItem() == ModItems.pwr_fuel && slots[0].getItemDamage() == typeLoaded && amountLoaded < rodCount){
amountLoaded++;
this.decrStackSize(0, 1);
this.markChanged();
}
if(this.rodTarget > this.rodLevel) this.rodLevel++;
if(this.rodTarget < this.rodLevel) this.rodLevel--;
int newFlux = this.sourceCount * 20;
if(typeLoaded != -1 && amountLoaded > 0) {
EnumPWRFuel fuel = EnumUtil.grabEnumSafely(EnumPWRFuel.class, typeLoaded);
double usedRods = getTotalProcessMultiplier();
double fluxPerRod = this.flux / this.rodCount;
double outputPerRod = fuel.function.effonix(fluxPerRod);
double totalOutput = outputPerRod * amountLoaded * usedRods;
double totalHeatOutput = totalOutput * fuel.heatEmission;
this.coreHeat += totalHeatOutput;
newFlux += totalOutput;
this.processTime = (int) fuel.yield;
this.progress += totalOutput;
if(this.progress >= this.processTime) {
this.progress -= this.processTime;
if(slots[1] == null) {
slots[1] = new ItemStack(ModItems.pwr_fuel_hot, 1, typeLoaded);
} else if(slots[1].getItem() == ModItems.pwr_fuel_hot && slots[1].getItemDamage() == typeLoaded && slots[1].stackSize < slots[1].getMaxStackSize()) {
slots[1].stackSize++;
if(this.assembled) {
for(BlockPos pos : ports) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
BlockPos portPos = pos.offset(dir);
if(tanks[1].getFill() > 0) this.sendFluid(tanks[1], worldObj, portPos.getX(), portPos.getY(), portPos.getZ(), dir);
if(worldObj.getTotalWorldTime() % 20 == 0) this.trySubscribe(tanks[0].getTankType(), worldObj, portPos.getX(), portPos.getY(), portPos.getZ(), dir);
}
this.amountLoaded--;
}
if((typeLoaded == -1 || amountLoaded <= 0) && slots[0] != null && slots[0].getItem() == ModItems.pwr_fuel) {
typeLoaded = slots[0].getItemDamage();
amountLoaded++;
this.decrStackSize(0, 1);
this.markChanged();
} else if(slots[0] != null && slots[0].getItem() == ModItems.pwr_fuel && slots[0].getItemDamage() == typeLoaded && amountLoaded < rodCount){
amountLoaded++;
this.decrStackSize(0, 1);
this.markChanged();
}
}
if(this.amountLoaded <= 0) {
this.typeLoaded = -1;
}
if(amountLoaded > rodCount) amountLoaded = rodCount;
/* CORE COOLING */
double coreCoolingApproachNum = getXOverE((double) this.heatexCount * 5 / (double) this.rodCount, 2) / 2D;
int averageCoreHeat = (this.coreHeat + this.hullHeat) / 2;
this.coreHeat -= (coreHeat - averageCoreHeat) * coreCoolingApproachNum;
this.hullHeat -= (hullHeat - averageCoreHeat) * coreCoolingApproachNum;
updateCoolant();
this.coreHeat *= 0.999D;
this.hullHeat *= 0.999D;
this.flux = newFlux;
if(tanks[0].getTankType().hasTrait(FT_PWRModerator.class) && tanks[0].getFill() > 0) {
this.flux *= tanks[0].getTankType().getTrait(FT_PWRModerator.class).getMultiplier();
}
if(this.coreHeat > this.coreHeatCapacity) {
meltDown();
if(this.rodTarget > this.rodLevel) this.rodLevel++;
if(this.rodTarget < this.rodLevel) this.rodLevel--;
int newFlux = this.sourceCount * 20;
if(typeLoaded != -1 && amountLoaded > 0) {
EnumPWRFuel fuel = EnumUtil.grabEnumSafely(EnumPWRFuel.class, typeLoaded);
double usedRods = getTotalProcessMultiplier();
double fluxPerRod = this.flux / this.rodCount;
double outputPerRod = fuel.function.effonix(fluxPerRod);
double totalOutput = outputPerRod * amountLoaded * usedRods;
double totalHeatOutput = totalOutput * fuel.heatEmission;
this.coreHeat += totalHeatOutput;
newFlux += totalOutput;
this.processTime = (int) fuel.yield;
this.progress += totalOutput;
if(this.progress >= this.processTime) {
this.progress -= this.processTime;
if(slots[1] == null) {
slots[1] = new ItemStack(ModItems.pwr_fuel_hot, 1, typeLoaded);
} else if(slots[1].getItem() == ModItems.pwr_fuel_hot && slots[1].getItemDamage() == typeLoaded && slots[1].stackSize < slots[1].getMaxStackSize()) {
slots[1].stackSize++;
}
this.amountLoaded--;
this.markChanged();
}
}
if(this.amountLoaded <= 0) {
this.typeLoaded = -1;
}
if(amountLoaded > rodCount) amountLoaded = rodCount;
/* CORE COOLING */
double coreCoolingApproachNum = getXOverE((double) this.heatexCount * 5 / (double) this.rodCount, 2) / 2D;
int averageCoreHeat = (this.coreHeat + this.hullHeat) / 2;
this.coreHeat -= (coreHeat - averageCoreHeat) * coreCoolingApproachNum;
this.hullHeat -= (hullHeat - averageCoreHeat) * coreCoolingApproachNum;
updateCoolant();
this.coreHeat *= 0.999D;
this.hullHeat *= 0.999D;
this.flux = newFlux;
if(tanks[0].getTankType().hasTrait(FT_PWRModerator.class) && tanks[0].getFill() > 0) {
this.flux *= tanks[0].getTankType().getTrait(FT_PWRModerator.class).getMultiplier();
}
if(this.coreHeat > this.coreHeatCapacity) {
meltDown();
}
}
NBTTagCompound data = new NBTTagCompound();

View File

@ -494,6 +494,12 @@ public class TileEntityWatz extends TileEntityMachineBase implements IFluidStand
setBrokenColumn(1, ModBlocks.watz_end, 1, 2, -2);
setBrokenColumn(1, ModBlocks.watz_end, 1, -2, 2);
setBrokenColumn(1, ModBlocks.watz_end, 1, -2, -2);
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5).expand(50, 50, 50));
for(EntityPlayer player : players) {
player.triggerAchievement(MainRegistry.achWatzBoom);
}
}
private void setBrokenColumn(int minHeight, Block b, int meta, int x, int z) {

View File

@ -1,8 +1,6 @@
package com.hbm.tileentity.network;
import com.hbm.tileentity.TileEntityMachineBase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
@ -11,6 +9,7 @@ import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
public abstract class TileEntityCraneBase extends TileEntityMachineBase {
public TileEntityCraneBase(int scount) {
super(scount);
}
@ -19,15 +18,15 @@ public abstract class TileEntityCraneBase extends TileEntityMachineBase {
// for compatibility purposes, normal meta values are still used by default
private ForgeDirection outputOverride = ForgeDirection.UNKNOWN;
// for extra stability in case the screwdriver action doesn't get synced to other clients
@SideOnly(Side.CLIENT)
// for extra stability in case the screwdriver action doesn't get synced to
// other clients
private ForgeDirection cachedOutputOverride = ForgeDirection.UNKNOWN;
@Override
public void updateEntity() {
if (hasWorldObj() && worldObj.isRemote) {
if (cachedOutputOverride != outputOverride) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
if(hasWorldObj() && worldObj.isRemote) {
if(cachedOutputOverride != outputOverride) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
cachedOutputOverride = outputOverride;
}
}
@ -48,12 +47,11 @@ public abstract class TileEntityCraneBase extends TileEntityMachineBase {
public void setOutputOverride(ForgeDirection direction) {
ForgeDirection oldSide = getOutputSide();
if (oldSide == direction)
direction = direction.getOpposite();
if(oldSide == direction) direction = direction.getOpposite();
outputOverride = direction;
if (direction == getInputSide())
if(direction == getInputSide())
setInput(oldSide);
else
onBlockChanged();
@ -63,18 +61,17 @@ public abstract class TileEntityCraneBase extends TileEntityMachineBase {
outputOverride = getOutputSide(); // save the current output, if it isn't saved yet
ForgeDirection oldSide = getInputSide();
if (oldSide == direction)
direction = direction.getOpposite();
if(oldSide == direction) direction = direction.getOpposite();
boolean needSwapOutput = direction == getOutputSide();
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal(), needSwapOutput ? 4 : 3);
if (needSwapOutput)
if(needSwapOutput)
setOutputOverride(oldSide);
}
protected void onBlockChanged() {
if (!hasWorldObj()) return;
if(!hasWorldObj()) return;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlockChange(xCoord, yCoord, zCoord, getBlockType());
markDirty();
@ -95,7 +92,7 @@ public abstract class TileEntityCraneBase extends TileEntityMachineBase {
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
if (nbt.hasKey("CraneOutputOverride", Constants.NBT.TAG_BYTE))
if(nbt.hasKey("CraneOutputOverride", Constants.NBT.TAG_BYTE))
outputOverride = ForgeDirection.getOrientation(nbt.getByte("CraneOutputOverride"));
}