Skip to content

Commit

Permalink
lower steam cost
Browse files Browse the repository at this point in the history
  • Loading branch information
khjxiaogu committed Jan 9, 2025
1 parent e5c99ee commit b8f943f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,27 @@ public static HeatEndpoint readNetwork(FriendlyByteBuf pb) {
}

public void load(CompoundTag nbt, boolean isPacket) {
heat = nbt.getFloat("net_power");
//pos = BlockPos.of(nbt.getLong("pos"));
//blk = RegistryUtils.getBlock(new ResourceLocation(nbt.getString("block")));
}

public void save(CompoundTag nbt, boolean isPacket) {
nbt.putFloat("net_power", heat);
//nbt.putLong("pos", pos.asLong());
//nbt.putString("block", RegistryUtils.getRegistryName(blk).toString());
}
public void loadNetwork(CompoundTag nbt, boolean isPacket) {
heat = nbt.getFloat("net_power");
pos = BlockPos.of(nbt.getLong("pos"));
blk = RegistryUtils.getBlock(new ResourceLocation(nbt.getString("block")));
}

public void save(CompoundTag nbt, boolean isPacket) {
public void saveNetwork(CompoundTag nbt, boolean isPacket) {
nbt.putFloat("net_power", heat);
nbt.putLong("pos", pos.asLong());
nbt.putString("block", RegistryUtils.getRegistryName(blk).toString());
}

@Override
public HeatNetwork getNetwork() {
return network;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,20 @@ public void tick(Level level) {
HeatEndpoint endpoint=lep.orElse(null);
if(endpoint!=null)
if (endpoint.canReceiveHeatFromNetwork()) {
// logic
float received = endpoint.receiveHeatFromNetwork(accumulated, tlevel);
totalEndpointIntake += received;
accumulated -= received;
//first distribute
float received =0;
if(accumulated!=0) {
received=endpoint.receiveHeatFromNetwork(accumulated, tlevel);
totalEndpointIntake += received;
accumulated -= received;
}
endpoint.intake = received;
if(received!=0&&accumulated!=0) {//maximum 2 times input
received = endpoint.receiveHeatFromNetwork(accumulated, tlevel);
totalEndpointIntake += received;
accumulated -= received;
endpoint.intake += received;
}
}
//if(accumulated <= 0)
// break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void tick() {
if (!level.isClientSide) {
float actual = network.drainHeat(Math.min(200, (getMaxPower() - power) / 0.8F));
if (actual > 0) {
power += (float) (actual * 0.8);
power += (float) (actual * 8);
this.setActive(true);
setChanged();
this.markContainingBlockForUpdate(null);
Expand Down

0 comments on commit b8f943f

Please sign in to comment.