Skip to content

Commit

Permalink
bug fix for incorrect minComputation special value calculation
Browse files Browse the repository at this point in the history
- updated dependencies to GTNH 2.7.0
  • Loading branch information
Taskeren committed Jan 4, 2025
1 parent 74e2ae7 commit e1921e0
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 19 deletions.
3 changes: 3 additions & 0 deletions addon.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test {
useJUnitPlatform()
}
27 changes: 17 additions & 10 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,26 @@ dependencies {

implementation("com.github.GTNewHorizons:GT5-Unofficial:5.09.50.103:dev")

implementation("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
implementation("com.github.GTNewHorizons:Botania:1.11.6-GTNH:dev")
// implementation("com.github.GTNewHorizons:GTNEIOrePlugin:1.3.2:dev")

implementation("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") { transitive = false }
implementation("com.github.GTNewHorizons:Botania:1.11.6-GTNH:dev") { transitive = false }
// implementation("com.github.GTNewHorizons:GTNEIOrePlugin:1.3.3:dev")
implementation("com.github.GTNewHorizons:GTNH-Intergalactic:1.4.30:dev")
implementation("com.github.GTNewHorizons:Galaxy-Space-GTNH:1.1.97-GTNH:dev")
implementation("com.github.GTNewHorizons:Galaxy-Space-GTNH:1.1.97-GTNH:dev") { transitive = false }

implementation("com.github.GTNewHorizons:Railcraft:9.15.15:dev")
implementation("com.github.GTNewHorizons:Railcraft:9.15.15:dev") { transitive = false }


// runtimeOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-423-GTNH:dev")
// runtimeOnly("com.github.GTNewHorizons:AE2FluidCraft-Rework:1.3.21-gtnh:dev")
// runtimeOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-518-GTNH:dev")
// runtimeOnly("com.github.GTNewHorizons:AE2FluidCraft-Rework:1.4.10-gtnh:dev")
// runtimeOnly("com.github.GTNewHorizons:Baubles-Expanded:2.0.3:dev")
runtimeOnly("com.github.GTNewHorizons:waila:1.8.2:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:EnderCore:0.4.6:dev")
runtimeOnly("com.github.GTNewHorizons:waila:1.8.2:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:EnderCore:0.4.6:dev") { transitive = false }

// runtimeOnlyNonPublishable("com.github.Nxer:Twist-Space-Technology-Mod:0.6.2:dev") { transitive = false }
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:BloodMagic:1.7.0")
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:Electro-Magic-Tools:1.6.2")

testImplementation(platform("org.junit:junit-bom:5.11.4"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,4 @@ disableCheckstyle = true
# Whether IDEA should run spotless checks when pressing the Build button.
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
4 changes: 3 additions & 1 deletion repositories.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Add any additional repositories for your dependencies here.

repositories {

maven {
url = "https://jitpack.io"
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.26'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.30'
}
37 changes: 36 additions & 1 deletion src/main/java/cn/elytra/gtnh/cutcorners/CutCorners.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
import cn.elytra.gtnh.cutcorners.init.VanillaRecipeInit;
import cn.elytra.gtnh.cutcorners.strate.ICutCornerStrategy;
import cn.elytra.gtnh.cutcorners.strate.impl.event.CutCornersEventDispatchHelper;
import gregtech.api.enums.GTValues;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GTRecipeConstants;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.launchwrapper.Launch;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -41,7 +49,7 @@ public static ICutCornerStrategy getStrategy() {
}

// called in LoadComplete event
public static void init() {
public static void loadComplete() {
if (initialized) {
CutCornersEventDispatchHelper.checkReinitializeCompatibility();
}
Expand All @@ -65,4 +73,31 @@ public static void registerListener(Object listener) {
public static void unregisterListener(Object listener) {
CutCornersEventDispatchHelper.unregisterListener(listener);
}

private static boolean isDevEnvironment() {
return (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
}

public static void postInit() {
if(isDevEnvironment()) {
LOG.info("Development Environment detected, adding Testing Recipes");

GTValues.RA.stdBuilder()
.metadata(GTRecipeConstants.RESEARCH_ITEM, new ItemStack(Items.apple))
.metadata(GTRecipeConstants.RESEARCH_TIME, 1)
.itemInputs(
ItemList.AdvDebugStructureWriter.get(1),
new Object[] {OrePrefixes.circuit.get(Materials.UXV), 16},
new Object[] {OrePrefixes.circuit.get(Materials.UXV), 16},
new Object[] {OrePrefixes.circuit.get(Materials.UXV), 16}
)
.fluidInputs(
Materials.Lubricant.getFluid(1000)
)
.itemOutputs(new ItemStack(Items.stick))
.eut(1)
.duration(1)
.addTo(GTRecipeConstants.AssemblyLine);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static int getMinComputation(int specialValue) {
}

public static int getSpecialValueAtMinComputation(int specialValue, int minComputation) {
return (specialValue & MASK) | (minComputation & MASK << 16);
return (specialValue & MASK) | ((minComputation & MASK) << 16);
}

}
6 changes: 4 additions & 2 deletions src/main/java/com/github/wohaopa/GTNHModify/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public void preInit(FMLPreInitializationEvent event) {
public void init(FMLInitializationEvent event) {}

// postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed)
public void postInit(FMLPostInitializationEvent event) {}
public void postInit(FMLPostInitializationEvent event) {
CutCorners.postInit();
}

public void loadComplete(FMLLoadCompleteEvent event) {
CutCorners.LOG.info("Cutting and initializing all recipes");
CutCorners.init();
CutCorners.loadComplete();
}

// register server commands in this event handler (Remove if not needed)
Expand Down
33 changes: 33 additions & 0 deletions src/test/java/TestSpecialValueAccessors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import cn.elytra.gtnh.cutcorners.strate.util.ResearchStationHelper;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
* Test cases for complicated special values.
*/
public class TestSpecialValueAccessors {

@Test
public void testResearchStationSV() {
int value = 0;

Assertions.assertEquals(0, ResearchStationHelper.getAmp(value));
Assertions.assertEquals(0, ResearchStationHelper.getMinComputation(value));

value += 100 << 16; // set 100 to min computation

Assertions.assertEquals(0, ResearchStationHelper.getAmp(value));
Assertions.assertEquals(100, ResearchStationHelper.getMinComputation(value));

value += 200;

Assertions.assertEquals(200, ResearchStationHelper.getAmp(value));
Assertions.assertEquals(100, ResearchStationHelper.getMinComputation(value));

// value = (minComp) 100 & (amp) 200

Assertions.assertEquals((((value >> 16) << 16) + 12), ResearchStationHelper.getSpecialValueAtAmp(value, 12));
Assertions.assertEquals(((99 << 16) | 200), ResearchStationHelper.getSpecialValueAtMinComputation(value, 99));
}

}

0 comments on commit e1921e0

Please sign in to comment.