From 577d9876f3632cc75013b8b94aec356e4c01967b Mon Sep 17 00:00:00 2001 From: yuesha-yc Date: Thu, 2 Jan 2025 19:40:23 +0800 Subject: [PATCH] Renaming for heat endpoints --- .../bootstrap/common/FHCapabilities.java | 2 +- .../heatdevice/generator/GeneratorData.java | 4 +- .../heatdevice/radiator/RadiatorLogic.java | 2 +- .../heatdevice/radiator/RadiatorState.java | 2 +- .../incubator/HeatIncubatorTileEntity.java | 2 +- .../content/incubator/IncubatorT2Screen.java | 4 +- .../steamenergy/HeatCapacityEndpoint.java | 48 +++++++++ .../HeatConsumerEndpoint.java | 31 +++--- .../{capabilities => }/HeatEndpoint.java | 99 ++++++++----------- .../steamenergy/HeatEnergyNetwork.java | 11 +-- .../steamenergy/HeatProviderEndPoint.java | 95 ++++++++++++++++++ .../capabilities/HeatCapabilities.java | 1 + .../capabilities/HeatPowerEndpoint.java | 57 ----------- .../capabilities/HeatProviderEndPoint.java | 87 ---------------- .../charger/ChargerTileEntity.java | 2 +- .../debug/DebugHeaterTileEntity.java | 2 +- .../fountain/FountainTileEntity.java | 4 +- .../steamenergy/sauna/SaunaTileEntity.java | 4 +- .../steamcore/SteamCoreTileEntity.java | 2 +- .../content/town/house/HouseBlockEntity.java | 4 +- .../town/hunting/HuntingBaseBlockEntity.java | 4 +- 21 files changed, 224 insertions(+), 243 deletions(-) create mode 100644 src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatCapacityEndpoint.java rename src/main/java/com/teammoeg/frostedheart/content/steamenergy/{capabilities => }/HeatConsumerEndpoint.java (76%) rename src/main/java/com/teammoeg/frostedheart/content/steamenergy/{capabilities => }/HeatEndpoint.java (55%) create mode 100644 src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatProviderEndPoint.java delete mode 100644 src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatPowerEndpoint.java delete mode 100644 src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatProviderEndPoint.java diff --git a/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHCapabilities.java b/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHCapabilities.java index 4b7804089..98f531507 100644 --- a/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHCapabilities.java +++ b/src/main/java/com/teammoeg/frostedheart/bootstrap/common/FHCapabilities.java @@ -19,7 +19,7 @@ import com.teammoeg.frostedheart.content.research.inspire.EnergyCore; import com.teammoeg.frostedheart.content.robotics.logistics.RobotChunk; import com.teammoeg.frostedheart.content.scenario.runner.ScenarioConductor; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatEndpoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatEndpoint; import com.teammoeg.frostedheart.content.water.capability.WaterLevelCapability; import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatStorageCapability; import com.teammoeg.frostedheart.content.town.ChunkTownResourceCapability; diff --git a/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/generator/GeneratorData.java b/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/generator/GeneratorData.java index bf620ea84..2ffe6310a 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/generator/GeneratorData.java +++ b/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/generator/GeneratorData.java @@ -27,7 +27,7 @@ import com.teammoeg.frostedheart.base.team.SpecialDataHolder; import com.teammoeg.frostedheart.base.team.SpecialDataTypes; import com.teammoeg.frostedheart.content.research.data.ResearchVariant; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatProviderEndPoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatProviderEndPoint; import com.teammoeg.frostedheart.util.FHUtils; import com.teammoeg.frostedheart.util.io.CodecUtil; @@ -195,7 +195,7 @@ public void tick(Level w) { isActive = tickFuelProcess(w); tickHeatedProcess(w); if (isActive && power > 0) - ep.setPower((float) (power * getHeatEfficiency())); + ep.setHeat((float) (power * getHeatEfficiency())); } public void tickHeatedProcess(Level world) { diff --git a/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/radiator/RadiatorLogic.java b/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/radiator/RadiatorLogic.java index a04f23cd0..0466403f0 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/radiator/RadiatorLogic.java +++ b/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/radiator/RadiatorLogic.java @@ -48,7 +48,7 @@ protected boolean tickFuel(IMultiblockContext ctx) { RadiatorState state = ctx.getState(); boolean hasFuel; if (state.network.tryDrainHeat(4)) { - state.setTempLevel(state.network.getTemperatureLevel()); + state.setTempLevel(state.network.getTempLevel()); state.setRangeLevel(0.5f); state.setActive(true); hasFuel = true; diff --git a/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/radiator/RadiatorState.java b/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/radiator/RadiatorState.java index 86d44208f..5f41c3a28 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/radiator/RadiatorState.java +++ b/src/main/java/com/teammoeg/frostedheart/content/climate/heatdevice/radiator/RadiatorState.java @@ -20,7 +20,7 @@ package com.teammoeg.frostedheart.content.climate.heatdevice.radiator; import com.teammoeg.frostedheart.content.climate.heatdevice.generator.HeatingState; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatConsumerEndpoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatConsumerEndpoint; import net.minecraft.nbt.CompoundTag; import net.minecraftforge.common.util.LazyOptional; diff --git a/src/main/java/com/teammoeg/frostedheart/content/incubator/HeatIncubatorTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/incubator/HeatIncubatorTileEntity.java index 1d1edff2a..7cffecb42 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/incubator/HeatIncubatorTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/incubator/HeatIncubatorTileEntity.java @@ -23,7 +23,7 @@ import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; import com.teammoeg.frostedheart.bootstrap.common.FHCapabilities; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatConsumerEndpoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatConsumerEndpoint; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/com/teammoeg/frostedheart/content/incubator/IncubatorT2Screen.java b/src/main/java/com/teammoeg/frostedheart/content/incubator/IncubatorT2Screen.java index f03343821..bfc8a3b5a 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/incubator/IncubatorT2Screen.java +++ b/src/main/java/com/teammoeg/frostedheart/content/incubator/IncubatorT2Screen.java @@ -60,8 +60,8 @@ public void drawContainerBackgroundPre(@Nonnull GuiGraphics transform, float par int w = (int) (14 * (tile.process / (float) tile.processMax)); transform.blit(TEXTURE, leftPos + 107, topPos + 28, 176, 0, 14 - w, 29); } - if (tile.network.getPower() > 0) { - float v = tile.network.getPower() / tile.network.getMaxPower(); + if (tile.network.getHeat() > 0) { + float v = tile.network.getHeat() / tile.network.getCapacity(); boolean a = false, b = false; if (v > 0.75) { a = b = true; diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatCapacityEndpoint.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatCapacityEndpoint.java new file mode 100644 index 000000000..13893c083 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatCapacityEndpoint.java @@ -0,0 +1,48 @@ +package com.teammoeg.frostedheart.content.steamenergy; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import net.minecraft.nbt.CompoundTag; + +/** + * Defines a HeatEndpoint with a capacity to store, provide, and receive heat. + */ +@Getter +@ToString(callSuper = true) +public abstract class HeatCapacityEndpoint extends HeatEndpoint { + /** The max capacity to store heat. */ + protected final float capacity; + /** + * Detach priority. + * Consumer priority, if power is low, endpoint with lower priority would detach first + */ + protected final int priority; + /** Current heat stored. */ + @Setter + protected float heat; + + public HeatCapacityEndpoint(int priority, float capacity) { + this.capacity = capacity; + this.priority = priority; + } + + public void load(CompoundTag nbt,boolean isPacket) { + heat = nbt.getFloat("net_power"); + } + + public void save(CompoundTag nbt,boolean isPacket) { + nbt.putFloat("net_power", heat); + } + + @Override + public boolean canReceiveHeat() { + return heat < capacity; + } + + @Override + public boolean canProvideHeat() { + return heat > 0; + } + +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatConsumerEndpoint.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatConsumerEndpoint.java similarity index 76% rename from src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatConsumerEndpoint.java rename to src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatConsumerEndpoint.java index a758f62b9..a9561b4fc 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatConsumerEndpoint.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatConsumerEndpoint.java @@ -17,7 +17,9 @@ * */ -package com.teammoeg.frostedheart.content.steamenergy.capabilities; +package com.teammoeg.frostedheart.content.steamenergy; + +import lombok.ToString; /** * Class SteamNetworkConsumer. @@ -25,7 +27,8 @@ * Integrated power cache manager for power devices * A device should properly "request" power from the network */ -public class HeatConsumerEndpoint extends HeatPowerEndpoint{ +@ToString(callSuper = true) +public class HeatConsumerEndpoint extends HeatCapacityEndpoint { /** * The max intake value.
*/ @@ -44,8 +47,7 @@ public HeatConsumerEndpoint(int priority, float maxPower, float maxIntake) { } /** * Instantiates a new SteamNetworkConsumer with recommended cache value.
- * MaxIntake defaults 4 times maxIntake.
- * @param priority consumer priority, if power is low, endpoint with lower priority would detach first + * maxPower defaults to four times maxIntake.
* @param maxIntake the max heat requested from network
*/ public HeatConsumerEndpoint(float maxIntake) { @@ -60,21 +62,21 @@ public HeatConsumerEndpoint(float maxIntake) { * @return the heat actually drain */ public float drainHeat(float val) { - float drained = Math.min(power, val); - power -= drained; + float drained = Math.min(heat, val); + heat -= drained; return drained; } - public float sendHeat(float filled,int level) { - float required=Math.min(maxIntake, maxPower-power); + public float receiveHeat(float filled, int level) { + float required=Math.min(maxIntake, capacity - heat); tempLevel=level; if(required>0) { if(filled>=required) { filled-=required; - power+=required; + heat +=required; return filled; } - power+=filled; + heat +=filled; return 0; } return filled; @@ -89,8 +91,8 @@ public float sendHeat(float filled,int level) { * @return true, if the heat value can all drained */ public boolean tryDrainHeat(float val) { - if (power >= val) { - power -= val; + if (heat >= val) { + heat -= val; return true; } return false; @@ -98,10 +100,7 @@ public boolean tryDrainHeat(float val) { public boolean canProvideHeat() { return false; } - @Override - public String toString() { - return "SteamNetworkConsumer [maxPower=" + maxPower + ", maxIntake=" + maxIntake + ", power=" + power + ", persist=" + persist + ", dist=" + distance + "]"; - } + @Override public float provideHeat() { return 0; diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatEndpoint.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatEndpoint.java similarity index 55% rename from src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatEndpoint.java rename to src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatEndpoint.java index b1bbacaad..b60cb27d6 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatEndpoint.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatEndpoint.java @@ -1,8 +1,9 @@ -package com.teammoeg.frostedheart.content.steamenergy.capabilities; +package com.teammoeg.frostedheart.content.steamenergy; -import com.teammoeg.frostedheart.content.steamenergy.HeatEnergyNetwork; import com.teammoeg.frostedheart.util.io.NBTSerializable; +import lombok.Getter; +import lombok.ToString; import net.minecraft.core.Direction; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; @@ -11,48 +12,29 @@ * The Endpoint base for heat network. * */ -public abstract class HeatEndpoint implements NBTSerializable{ +@Getter +@ToString() +public abstract class HeatEndpoint implements NBTSerializable { /** - * The main network.
+ * The main network. */ + @ToString.Exclude protected HeatEnergyNetwork network; - @Override - public String toString() { - return "HeatEndpoint [distance=" + distance + ", tempLevel=" + tempLevel + "]"; - } - /** - * The distance.
+ * The distance to center. */ protected int distance=-1; - /** The temp level. */ - protected int tempLevel; - - /** Is constant supply even unload. */ - public boolean persist; - - /** - * Gets the whole network. + /** + * Temperature level of the network. * - * @return the network + * This is normally defined by the Generator, or a Heat Debugger. */ - public HeatEnergyNetwork getNetwork() { - return network; - } + protected int tempLevel; /** - * Gets the distance to central. - * - * @return the distance - */ - public int getDistance() { - return distance; - } - - /** * Recive connection from network. * * @param w current world @@ -86,53 +68,51 @@ public void clearConnection() { } /** - * Can receive heat from network. + * Can receive heat from the network. + *

* The network would call this to check if this is a consumer. * If this returns true, this endpoint would be added to the consumer list with or without actually consume. * The network may also put heat into this network. - * This should only called by network, You should not call this method. + *

+ * This should be only called by the network, You should not call this method. * * @return true, if successful */ - public abstract boolean canSendHeat(); + protected abstract boolean canReceiveHeat(); /** - * The network calls this to put heat into this endpoint. + * Receive heat from the network. + *

* If the heat provided lesser than max intake then the heat statistics would show red - * This should only called by network, You should not call this method. + *

+ * This should be only called by the network, You should not call this method. * - * @param filled the network fills heat to this endpoint - * @param level the actual heat level - * @return the heat actually filled + * @param filled the amount of heat that the network fills to this endpoint + * @param level the actual temperature level, which my differ from HeatEndpoint#tempLevel + * @return the amount of heat actually filled */ - public abstract float sendHeat(float filled,int level); - - /** - * Get the temperature level. - * - * @return the temperature level - */ - public int getTemperatureLevel() { - return tempLevel; - } + protected abstract float receiveHeat(float filled, int level); /** - * Can draw heat from network. + * Whether this endpoint can provide heat to the network. + *

* The network would call this to check if this is a provider. * If this returns true, this endpoint would be added to the generator list with or without actually generate. - * This should only called by network, You should not call this method. + *

+ * This should be only called by the network, You should not call this method. * * @return true, if successful */ - public abstract boolean canProvideHeat(); + protected abstract boolean canProvideHeat(); /** * Provide heat to the network. - * This should only called by network, You should not call this method. + *

+ * This should be only called by the network, You should not call this method. * - * @return heat provided to the network + * @return the amount of heat actually provided */ - public abstract float provideHeat(); + protected abstract float provideHeat(); /** * Checks if the network valid. @@ -140,15 +120,20 @@ public int getTemperatureLevel() { * @return true, if successful */ public boolean hasValidNetwork() { - return network!=null; + return network != null; } /** - * Gets the max intake. + * The maximum heat to receive from the network. * * @return the max intake */ public abstract float getMaxIntake(); + /** + * Gets the detach priority. + * + * @return the priority to detatch + */ public abstract int getPriority(); } diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatEnergyNetwork.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatEnergyNetwork.java index e36a60ccb..d1c165da7 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatEnergyNetwork.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatEnergyNetwork.java @@ -25,12 +25,9 @@ import java.util.Map; import java.util.PriorityQueue; import java.util.Set; -import java.util.function.BiConsumer; import java.util.function.Consumer; import com.teammoeg.frostedheart.bootstrap.common.FHCapabilities; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatEndpoint; -import com.teammoeg.frostedheart.content.steamenergy.debug.DebugHeaterTileEntity; import com.teammoeg.frostedheart.util.FHUtils; import com.teammoeg.frostedheart.util.RegistryUtils; import com.teammoeg.frostedheart.util.lang.Lang; @@ -218,19 +215,19 @@ public void tick(Level level) { float provided=endpoint.provideHeat(); data.get(endpoint).intake=provided; value+=provided; - tlevel=Math.max(endpoint.getTemperatureLevel(), tlevel); + tlevel=Math.max(endpoint.getTempLevel(), tlevel); } } boolean shouldFill=true; while(shouldFill) { shouldFill=false; for(HeatEndpoint endpoint:endpoints) { - if(endpoint.canSendHeat()) { + if(endpoint.canReceiveHeat()) { float oldval=value; - value=endpoint.sendHeat(value,tlevel); + value=endpoint.receiveHeat(value,tlevel); data.get(endpoint).applyOutput(oldval-value,endpoint.getMaxIntake()); - shouldFill|=endpoint.canSendHeat(); + shouldFill|=endpoint.canReceiveHeat(); } } diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatProviderEndPoint.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatProviderEndPoint.java new file mode 100644 index 000000000..411da5a20 --- /dev/null +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/HeatProviderEndPoint.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024 TeamMoeg + * + * This file is part of Frosted Heart. + * + * Frosted Heart is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * Frosted Heart is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Frosted Heart. If not, see . + * + */ + +package com.teammoeg.frostedheart.content.steamenergy; + +import lombok.ToString; + +/** + * Integrated power cache manager for power generating devices + * A device should properly "gives" power from the network + */ +@ToString(callSuper = true) +public class HeatProviderEndPoint extends HeatCapacityEndpoint { + + /** + * The maximum heat output of this provider.
+ */ + public final float maxOutput; + + /** + * Instantiates HeatProviderEndPoint.
+ * + * @param priority if power is low, endpoint with lower priority would detach first + * @param capacity the max power to store
+ * @param maxOutput the max heat put to network
+ */ + public HeatProviderEndPoint(int priority, float capacity, float maxOutput) { + super(priority, Math.max(capacity, maxOutput)); + this.maxOutput = maxOutput; + } + + /** + * Instantiates with default heat capacity.
+ */ + public HeatProviderEndPoint(float maxOutput) { + super(0, maxOutput * 4); + this.maxOutput = maxOutput; + } + + public HeatProviderEndPoint(float capacity, float maxOutput) { + super(0, capacity); + this.maxOutput = maxOutput; + } + + public boolean canReceiveHeat() { + return false; + } + + @Override + public float receiveHeat(float filled, int level) { + return filled; + } + + /** + * Adds heat to the endpoint, if capacity exceed, tbe remaining would be disposed. + * The heat actually added to the endpoint still depends on the generation. + */ + public void addHeat(float added) { + heat = Math.min(capacity, heat + added); + } + + /** + * Provide heat bounded by the maximum output. + * + * @return the amount of heat actually provided + */ + @Override + public float provideHeat() { + float provided = Math.min(heat, maxOutput); + heat -= provided; + return provided; + } + + // Not possible to receive heat + @Override + public float getMaxIntake() { + return 0; + } +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatCapabilities.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatCapabilities.java index ca6c836cd..d4a72b13f 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatCapabilities.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatCapabilities.java @@ -1,6 +1,7 @@ package com.teammoeg.frostedheart.content.steamenergy.capabilities; import com.teammoeg.frostedheart.bootstrap.common.FHCapabilities; +import com.teammoeg.frostedheart.content.steamenergy.HeatEndpoint; import com.teammoeg.frostedheart.content.steamenergy.HeatEnergyNetwork; import com.teammoeg.frostedheart.content.steamenergy.INetworkConsumer; import com.teammoeg.frostedheart.util.FHUtils; diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatPowerEndpoint.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatPowerEndpoint.java deleted file mode 100644 index 67d42af75..000000000 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatPowerEndpoint.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.teammoeg.frostedheart.content.steamenergy.capabilities; - -import net.minecraft.nbt.CompoundTag; - -/** - * The Class HeatPowerEndpoint. - * Basic class for heat power endpoint with power action - */ -public abstract class HeatPowerEndpoint extends HeatEndpoint { - public final float maxPower; - public final int priority; - protected float power; - /** - * @param priority consumer priority, if power is low, endpoint with lower priority would detach first - * - * */ - public HeatPowerEndpoint(int priority,float maxPower) { - super(); - this.maxPower = maxPower; - this.priority = priority; - } - - public float getMaxPower() { - return maxPower; - } - - public float getPower() { - return power; - } - - public void load(CompoundTag nbt,boolean isPacket) { - power = nbt.getFloat("net_power"); - } - - public void save(CompoundTag nbt,boolean isPacket) { - nbt.putFloat("net_power", power); - } - - public void setPower(float power) { - this.power = power; - } - - @Override - public boolean canSendHeat() { - return power0; - } - - public int getPriority() { - return priority; - } - -} diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatProviderEndPoint.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatProviderEndPoint.java deleted file mode 100644 index efd86e73c..000000000 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/capabilities/HeatProviderEndPoint.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2024 TeamMoeg - * - * This file is part of Frosted Heart. - * - * Frosted Heart is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3. - * - * Frosted Heart is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Frosted Heart. If not, see . - * - */ - -package com.teammoeg.frostedheart.content.steamenergy.capabilities; - -/** - * Class HeatProviderEndPoint. - *

- * Integrated power cache manager for power generating devices - * A device should properly "gives" power from the network - */ -public class HeatProviderEndPoint extends HeatPowerEndpoint{ - - - /** - * The max generate.
- */ - public final float maxGenerate; - /** - * Is constant supply even unload - * */ - public boolean persist; - - - /** - * Instantiates HeatProviderEndPoint.
- * - * @param priority consumer priority, if power is low, endpoint with lower priority would detach first - * @param maxPower the max power to store
- * @param maxGenerate the max heat put to network
- */ - public HeatProviderEndPoint(int priority, float maxPower, float maxGenerate) { - super(priority, Math.max(maxPower, maxGenerate)); - this.maxGenerate = maxGenerate; - - } - /** - * Instantiates HeatProviderEndPoint with recommended cache value.
- * - * @param priority consumer priority, if power is low, endpoint with lower priority would detach first - * @param maxGenerate the max heat put to network
- */ - public HeatProviderEndPoint(float maxGenerate) { - super(0, maxGenerate*4); - this.maxGenerate = maxGenerate; - } - public boolean canSendHeat() { - return false; - } - @Override - public float sendHeat(float filled, int level) { - return filled; - } - /** - * Adds heat to the endpoint, if cache exceed, tbe remaining would be disposed. - * The heat actually added to the endpoint still depends on the max generation - * */ - public void addHeat(float np) { - power=Math.min(maxPower, power+np); - } - @Override - public float provideHeat() { - float provided=Math.min(power, maxGenerate); - power-=provided; - return provided; - } - @Override - public float getMaxIntake() { - return 0; - } -} diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/charger/ChargerTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/charger/ChargerTileEntity.java index 52dc6a6eb..b35d21a9a 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/charger/ChargerTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/charger/ChargerTileEntity.java @@ -28,7 +28,7 @@ import com.teammoeg.frostedheart.bootstrap.common.FHCapabilities; import com.teammoeg.frostedheart.content.climate.recipe.CampfireDefrostRecipe; import com.teammoeg.frostedheart.content.steamenergy.IChargable; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatConsumerEndpoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatConsumerEndpoint; import com.teammoeg.frostedheart.util.FHUtils; import com.teammoeg.frostedheart.util.client.ClientUtils; diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/debug/DebugHeaterTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/debug/DebugHeaterTileEntity.java index b72a1ae53..66e5c368b 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/debug/DebugHeaterTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/debug/DebugHeaterTileEntity.java @@ -23,7 +23,7 @@ import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; import com.teammoeg.frostedheart.bootstrap.common.FHCapabilities; import com.teammoeg.frostedheart.content.steamenergy.HeatEnergyNetwork; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatProviderEndPoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatProviderEndPoint; import blusunrize.immersiveengineering.common.blocks.IEBaseBlockEntity; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/fountain/FountainTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/fountain/FountainTileEntity.java index 5adc37a95..8f1e34f87 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/fountain/FountainTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/fountain/FountainTileEntity.java @@ -32,7 +32,7 @@ import com.teammoeg.frostedheart.content.climate.heatdevice.chunkheatdata.ChunkHeatData; import com.teammoeg.frostedheart.content.steamenergy.INetworkConsumer; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatConsumerEndpoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatConsumerEndpoint; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; @@ -243,7 +243,7 @@ public void writeCustomNBT(CompoundTag nbt, boolean descPacket) { } private void adjustHeat(int range) { - float networkTemp = network.getTemperatureLevel(); + float networkTemp = network.getTempLevel(); if (lastTemp == networkTemp && heatAdjusted && range == heatRange) return; lastTemp = networkTemp; diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/sauna/SaunaTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/sauna/SaunaTileEntity.java index efd538f9f..eb18bb882 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/sauna/SaunaTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/sauna/SaunaTileEntity.java @@ -34,7 +34,7 @@ import com.teammoeg.frostedheart.base.block.FHBlockInterfaces; import com.teammoeg.frostedheart.base.block.FHTickableBlockEntity; import com.teammoeg.frostedheart.content.research.inspire.EnergyCore; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatConsumerEndpoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatConsumerEndpoint; import com.teammoeg.frostedheart.util.FHUtils; import com.teammoeg.frostedheart.util.lang.Lang; import com.teammoeg.frostedheart.util.client.ClientUtils; @@ -156,7 +156,7 @@ public NonNullList getInventory() { } public float getPowerFraction() { - return network.getPower() / network.getMaxPower(); + return network.getHeat() / network.getCapacity(); } @Override diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/steamcore/SteamCoreTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/steamcore/SteamCoreTileEntity.java index c8230bba4..786d9880a 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/steamcore/SteamCoreTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/steamcore/SteamCoreTileEntity.java @@ -8,7 +8,7 @@ import com.teammoeg.frostedheart.base.block.FHBlockInterfaces; import com.teammoeg.frostedheart.base.block.FHTickableBlockEntity; import com.teammoeg.frostedheart.bootstrap.common.FHCapabilities; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatConsumerEndpoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatConsumerEndpoint; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/com/teammoeg/frostedheart/content/town/house/HouseBlockEntity.java b/src/main/java/com/teammoeg/frostedheart/content/town/house/HouseBlockEntity.java index e35007a41..d58f3ebfc 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/town/house/HouseBlockEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/town/house/HouseBlockEntity.java @@ -21,7 +21,7 @@ import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; import com.teammoeg.frostedheart.bootstrap.common.FHCapabilities; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatConsumerEndpoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatConsumerEndpoint; import com.teammoeg.frostedheart.content.town.AbstractTownWorkerBlockEntity; import com.teammoeg.frostedheart.content.town.TownWorkerState; import com.teammoeg.frostedheart.content.town.TownWorkerType; @@ -265,7 +265,7 @@ public void tick() { assert level != null; if (!level.isClientSide) { if (endpoint.tryDrainHeat(1)) { - temperatureModifier = Math.max(endpoint.getTemperatureLevel() * 10, COMFORTABLE_TEMP_HOUSE); + temperatureModifier = Math.max(endpoint.getTempLevel() * 10, COMFORTABLE_TEMP_HOUSE); if (setActive(true)) { setChanged(); } diff --git a/src/main/java/com/teammoeg/frostedheart/content/town/hunting/HuntingBaseBlockEntity.java b/src/main/java/com/teammoeg/frostedheart/content/town/hunting/HuntingBaseBlockEntity.java index 73490480c..e3b87828b 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/town/hunting/HuntingBaseBlockEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/town/hunting/HuntingBaseBlockEntity.java @@ -2,7 +2,7 @@ import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; import com.teammoeg.frostedheart.bootstrap.common.FHCapabilities; -import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatConsumerEndpoint; +import com.teammoeg.frostedheart.content.steamenergy.HeatConsumerEndpoint; import com.teammoeg.frostedheart.content.town.*; import com.teammoeg.frostedheart.content.town.house.HouseBlockScanner; import com.teammoeg.frostedheart.content.town.house.HouseBlockEntity; @@ -139,7 +139,7 @@ public void tick() { assert level != null; if (!level.isClientSide) { if (endpoint.tryDrainHeat(1)) { - temperatureModifier = Math.max(endpoint.getTemperatureLevel() * 10, HouseBlockEntity.COMFORTABLE_TEMP_HOUSE); + temperatureModifier = Math.max(endpoint.getTempLevel() * 10, HouseBlockEntity.COMFORTABLE_TEMP_HOUSE); if (setActive(true)) { setChanged(); }