Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ jobs:
if-no-files-found: error
retention-days: 30
path: |
build/libs/SteamAdvantage-2.2.1.112021.jar
build/libs/SteamAdvantage-2.2.1.112021-sources.jar
build/libs/SteamAdvantage-2.2.1.112021-javadoc.jar
build/libs/SteamAdvantage-2.2.2.112021.jar
build/libs/SteamAdvantage-2.2.2.112021-sources.jar
build/libs/SteamAdvantage-2.2.2.112021-javadoc.jar
build/release/SHA256SUMS
CHANGELOG.txt

Expand Down
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@
/replay_pid*.log

/secret.json
# Nested local tooling and generated output
AGENTS.md
AGENT.md
CLAUDE.md
GEMINI.md
ARCHITECT.md
agent-notes/
.codex/
.agent/
.agents/
.claude/
.gemini/
.cursor/
agent-*.md
codex-*.md
*.log
*.class
__pycache__/
*.pyc
/.DS_Store
/README.txt
/forge-*-changelog.txt
7 changes: 7 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Steam Advantage 2.2.2.112021

- Retain unfinished drill progress when rebuilding the mining target after a world or chunk reload.
- Clear stale deferred target data when loading an untargeted tile; clamp restored progress to current target hardness.
- Refresh the drill's redstone state before its first resumed tick so saved work is not discarded by an uninitialized control cache.
- Preserve registry identities, saved target coordinates, inventories, energy and the existing progress NBT key.

Steam Advantage 2.2.1.112021

- Move the Minecraft 1.12.2 build to ForgeGradle 7 and Gradle 9.6.1.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Steam Advantage adds steam-powered machines and infrastructure to Power Advantage for Minecraft 1.12.2.

## Drill Reload Fix

Version `2.2.2.112021` keeps unfinished drill work when a chunk or world reloads.
Existing inventories, energy, orientation and saved-world names are unchanged.
The regression tests cover resumed progress and full server restarts.

## Building Minecraft 1.12.2

The `master-1.12.2` build uses ForgeGradle 7.0.34 and Gradle 9.6.1. Run Gradle with Java 17; Gradle resolves the Java 8 toolchain used for compilation.
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ dependencies {
// PowerAdvantage is required at runtime but remains a separate mod jar.
compileOnly files(powerAdvantageDeobfJar)
runtimeOnly files(powerAdvantageDeobfJar)
testImplementation files(powerAdvantageDeobfJar)
testImplementation 'junit:junit:4.13.2'
}

tasks.named('processResources', ProcessResources) {
Expand Down Expand Up @@ -298,7 +300,7 @@ tasks.register('verifyReleaseConfiguration') {
group = 'verification'
description = 'Validates release identity, target metadata, and dependency policy.'
doLast {
if (project.mod_version != '2.2.1.112021') {
if (project.mod_version != '2.2.2.112021') {
throw new GradleException("Unexpected SteamAdvantage release version: ${project.mod_version}")
}
if (project.minecraft_version != '1.12.2'
Expand Down Expand Up @@ -341,7 +343,7 @@ tasks.register('verifyReleaseConfiguration') {
String mainSource = file(
'src/main/java/com/mcmoddev/steamadvantage/SteamAdvantage.java').getText('UTF-8')
if (!mainSource.contains('MODID = "steamadvantage"')
|| !mainSource.contains('VERSION = "2.2.1.112021"')
|| !mainSource.contains('VERSION = "2.2.2.112021"')
|| !mainSource.contains('dependencies = "required-after:poweradvantage;after:basemetals"')) {
throw new GradleException('SteamAdvantage source identity or dependency policy changed')
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ curseforge_project_id=240984
mod_id=steamadvantage
mod_name=Steam Advantage
mod_license=GPL-3.0-only
mod_version=2.2.1.112021
mod_version=2.2.2.112021
mod_group=com.mcmoddev.steamadvantage
mod_authors=DrCyano
mod_description=Steam-powered machines and infrastructure for the Power Advantage platform.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class SteamAdvantage
/** The display name for this mod */
public static final String NAME = "Steam Advantage";
/** The version of this mod, in the format major.minor.update */
public static final String VERSION = "2.2.1.112021";
public static final String VERSION = "2.2.2.112021";

public static float MUSKET_DAMAGE = 20;
public static int MUSKET_RELOAD = 20*5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public SteamDrillTileEntity() {
public void tickUpdate(boolean isServerWorld) {
if(isServerWorld){
if(deferred){
targetBlock(targetBlockCoord);
restoreTargetBlock();
}
EnumFacing face = this.getFacing();
if(oldDir == null){
Expand Down Expand Up @@ -226,7 +226,7 @@ public void onDataFieldUpdate() {
private int oldProgress = 0;
@Override public void powerUpdate(){
if(deferred){
targetBlock(targetBlockCoord);
restoreTargetBlock();
}
super.powerUpdate();
boolean flagSync = progress != oldProgress || oldEnergy != getEnergy(Power.steam_power);
Expand Down Expand Up @@ -334,12 +334,21 @@ private void targetBlock (BlockPos n){
deferred = false;
}

private void restoreTargetBlock(){
int savedProgress = progress;
// Rebuild transient drops and hardness without discarding saved work.
targetBlock(targetBlockCoord);
progress = Math.max(0, Math.min(savedProgress, progressGoal));
redstone = hasRedstoneSignal();
}

private void deferredTargetBlock (BlockPos n){
targetBlockCoord = n;
deferred = true;
}

private void untargetBlock(){
deferred = false;
progress = 0;
progressGoal = 0;
targetBlockCoord = null;
Expand Down Expand Up @@ -453,6 +462,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound tagRoot){
@Override
public void readFromNBT(NBTTagCompound tagRoot){
super.readFromNBT(tagRoot);
untargetBlock();
if(tagRoot.hasKey("Facing")){
int facingIndex = tagRoot.getByte("Facing");
if(facingIndex >= 0 && facingIndex < EnumFacing.values().length){
Expand All @@ -470,7 +480,8 @@ public void readFromNBT(NBTTagCompound tagRoot){
if(powerAdvantageWorld() == null){
this.deferredTargetBlock(new BlockPos(x,y,z));
} else {
this.targetBlock(new BlockPos(x,y,z));
this.deferredTargetBlock(new BlockPos(x,y,z));
this.restoreTargetBlock();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.mcmoddev.steamadvantage.machines;

import net.minecraft.nbt.NBTTagCompound;
import org.junit.Test;

import static org.junit.Assert.*;

public class SteamDrillPersistenceTest {
@Test public void retainsLegacyProgressBeforeWorldAttachment() {
SteamDrillTileEntity drill = new SteamDrillTileEntity();
drill.readFromNBT(target(17));
drill.prepareDataFieldsForSync();
assertEquals(17, drill.getDataFieldArray()[1]);
}

@Test public void untargetedDataClearsPendingWork() throws Exception {
SteamDrillTileEntity drill = new SteamDrillTileEntity();
drill.readFromNBT(target(17));
drill.readFromNBT(new NBTTagCompound());
drill.prepareDataFieldsForSync();
assertEquals(0, drill.getDataFieldArray()[1]);
java.lang.reflect.Field target = SteamDrillTileEntity.class.getDeclaredField("targetBlockCoord");
target.setAccessible(true);
assertNull(target.get(drill));
}

private static NBTTagCompound target(int progress) {
NBTTagCompound tag = new NBTTagCompound();
tag.setShort("progress", (short) progress);
tag.setInteger("targetX", 2048);
tag.setInteger("targetY", 80);
tag.setInteger("targetZ", 2049);
return tag;
}
}
Loading