Skip to content

Commit

Permalink
Release 2.0.6 (#13)
Browse files Browse the repository at this point in the history
* Update IC2 maven to one that actually works

* Update IC2 maven link in the main project as well.

Being fair, I just forgot about this one ^^"

* Patches for fixing #6

Will resolve Patch request #6

* Update IC2 Version extraction to log extracted version. Should now return cached version

* Update Base Patches for 164

* Fix Batch Crafter dupes... at least most of them

* Fix Batteries being ghost items when inserted into the discharge slot

Fix battery-like items being ghost items when trying to be inserted into the battery slots in machines with lower energy tier, but containing Transformer upgrades.

* Update Gradle to 7.5, Update ForgeGradle to 5.1.+.

* Make Dev Env runs work \o/, Update Maven for FancyGradle

* Create task that patches compiled jar of Patched IC2 so it boots.

This task is meant to be launched only on prepareRuns, and it replaces entries complying to the regex rules with entries from the original IC2 Jar. Mainly used for assets, but also for networking classes.

Note: Literally just before this commit I realized there is old patch that just comments out entirety of IC2 Networking code and that was the cause of the crashes lmao, but this is still going to be useful for... some time until I decide to replace this with actual non-corrupted asset extraction and fix the networking base code so it's not entirely commented out and is stable enough to launch the game.

* Fix Networking classes so replacement of those isn't necessary anymore

* Bit of base code cleanup for actual patch

* Add Support to DataEncoder for copying arrays.

This fixes an issue with ghost items when using JEI Transfer handler for Batch Crafter.
Should not have any negative side-effects, as it technically does the same thing as before, but without changing the reference of the original object.

* Fix Batch Crafter Container Shift-Clicking.

* Update ic2patches.pack.lzma

* Port 164 patches to 222

* Update Bin patches for 221+

* Update README.md
  • Loading branch information
Kanzaji authored Dec 10, 2023
1 parent 9cf7c02 commit 8c6f7f1
Show file tree
Hide file tree
Showing 35 changed files with 952 additions and 2,947 deletions.
74 changes: 44 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,58 @@
# IC2 Patcher
Fixes several bugs in IndustrialCraft2 using [binary patches](http://javaxdelta.sourceforge.net).

Note that you **may NOT distribute** any decompiled code generated by this tool.
Note that you **may NOT distribute** any decompiled code generated by this tool.
For more information, see [IC2's license](https://forum.industrial-craft.net/thread/9843-mc-1-7-ic%C2%B2-v-2-1-x-2-2-x-experimental/).

### List of patches
- Fixed issue [0002205](https://bt.industrial-craft.net/view.php?id=2205): Jetpack mode on Quantum Suit not disableable
To toggle the jetpack, press the *mode switch key* while *sneaking*
- Corrected the Near-Depleted Uranium Cell's recipe output size to 8
- Fixed issue [0002749](https://bt.industrial-craft.net/view.php?id=2749): Batch Crafter Dupe
- Fixed issue [0002745](https://bt.industrial-craft.net/view.php?id=2745): Crash the world with Electrolyzer, Fluid Pulling Upgrade and Pump Attachment
- Fixed issue [0002717](https://bt.industrial-craft.net/view.php?id=2717): Client crashed when connect a bronze fluid pipe with an ie fluid pipe
- Fixed issue [0002586](https://bt.industrial-craft.net/view.php?id=2586): Nightvision Goggles can break
- Night vision goggles now clear their effect immediately after disabling
- Corrected the specs of the Energy and Lapotron crystals in the classic profile
- Fixed a bug which displayed all non-fluid classic cell recipes in the [same recipe category](https://imgur.com/a/qkECYYD)
- Fixed issue [0002752](https://bt.industrial-craft.net/view.php?id=2752): Bug with Industrial Craft 2 textures
Obscuration now replaces textures instead of rendering another layer over them
- Fixed issue [0002701](https://bt.industrial-craft.net/view.php?id=2701): Crop-Matron and Crop Harvester ignoring Transformer Upgrades

### Creating patches

#### Setting up
1. Clone the repository
2. Run the `setup` gradle task
This will set up both `IC2-Base` and `IC2-Patched` projects, which contain clean and patched code respectively.
Note that while this code will compile, it's *highly unstable* and not suitable for playing.
You can find lists of patches for each supported IC2 Version [here]().

#### Currently supported versions:
- IC2-2.8.221 and above
- IC2-2.8.164

#### Generating patches
After making changes to the code, run the `generatePatches` task of the `IC2-Patched` project to generate the patches.
This has to be done **manually** every time you make changes.
# Contribution

#### Building & Exporting
Run `gradlew build`to build the patcher. The resulting jar will be located in the `build/libs` folder.
Remember that the jar build by the `jar` task **will NOT work** outside the dev environment.
### Setting up the dev environment
1. Clone the repository.
2. Run the `setup` gradle task found in `env setup`.
This will set up both `IC2-Base` and `IC2-Patched` projects, which contain clean and patched code respectively.
Note that while this code will compile, it's *highly unstable* and might not work on your OS / IDE.
<hr>

### Generating patches for currently supported versions of IC2
After making changes to the code, run the `generatePatches` task of the `IC2-Patched` project to generate the patches for currently set IC2 version. This has to be done **manually** every time you make changes.
<hr>

### Generating patches for non-supported versions of IC2
To add support for a new version of IC2:
1. Change IC2 version in `gradle.properties` file.
2. Create a new Folder in root of project 'IC2-Base' and 'IC2-Patched' with name in the following format:<br>
`patches[minVersion,maxVersion]` where:
- minVersion - Minimum version of IC2 that those patches are meant to be applied to, inclusive.
- maxVersion - Maximum version of IC2 that those patches are meant to be applied to, exclusive.

Example: `patches[2.8.164, 2.8.165]` -> Folder for patches for IC2 version 2.8.164-exp112
It's recommended to copy over patches from the closest supported version and resolve issues from there.
3. Run the `setup` gradle task found in `env setup`.
1. If `IC2-Base` project fails to compile, resolve all issues generated by Compiler and run the `generatePatches` gradle task found in `IC2-Base` project.
This will generate patches that will be applied after IC2-Base de-compilation step.
Take note that while this process will allow the code to compile, the code might have been decompiled incorrectly in the first place, and cause the dev env game to not launch successfully. It's recommended to use the other decompilation tool to diagnose and correct the mistake.
2. If `IC2-Patched` project fails to compile, remove patches that aren't getting applied properly, and if relevant, port them to the currently used IC2 version.
4. After making changes to the code, run `generatePatches` task of the `IC2-Patched` project to generate the patches.
<hr>

### Building & Exporting
1. Run the `generateBinPatches` task of the IC2-Patched project for each version you have done changes to.
1. Make sure there aren't overlapping folders from previously generated patches!
2. Run `gradlew build`to build the patcher.
The resulting jar will be located in the `build/libs` folder.
Remember that the jar build by the `jar` task **will NOT work** outside the dev environment.

<div>
<img src="https://upload.wikimedia.org/wikipedia/commons/e/eb/PD-icon-black.svg" align="right" width="50" alt="The Unlicense Logo">
</div>
<h3 align="left">Licensing</h3>
<h2 align="left">Licensing</h2>

All code is licensed under **The Unlicense**, except for `mods.su5ed.ic2patcher.asm.BinPatchManager`, which is a modified version
All code is licensed under **The Unlicense**, except for `mods.su5ed.ic2patcher.asm.BinPatchManager`, which is a modified version
of MinecraftForge's [ClassPatchManager](https://github.com/MinecraftForge/MinecraftForge/blob/1.12.x/src/main/java/net/minecraftforge/fml/common/patcher/ClassPatchManager.java) class, and is licensed under the **GNU Lesser General Public License version 2.1**
36 changes: 20 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import fr.brouillard.oss.jgitver.GitVersionCalculator
import fr.brouillard.oss.jgitver.Strategies
import net.minecraftforge.gradle.common.util.RunConfig
import wtf.gofancy.fancygradle.script.extensions.deobf
import net.minecraftforge.gradle.patcher.task.GenerateBinPatches
import wtf.gofancy.fancygradle.patch.Patch
import net.minecraftforge.gradle.patcher.tasks.GenerateBinPatches

buildscript {
dependencies {
Expand All @@ -15,7 +14,7 @@ plugins {
`java-library`
`maven-publish`
idea
id("net.minecraftforge.gradle") version "5.0.11"
id("net.minecraftforge.gradle") version "5.1.+"
id("de.undercouch.download") version "4.1.1"
id("wtf.gofancy.fancygradle") version "1.1.+"
}
Expand Down Expand Up @@ -57,10 +56,11 @@ minecraft {

fancyGradle {
patches {
Patch.RESOURCES
Patch.COREMODS
Patch.CODE_CHICKEN_LIB
Patch.ASM
asm
codeChickenLib
coremods
resources
mergetool
}
}

Expand All @@ -78,16 +78,16 @@ repositories {
maven {
// IC2 Repository
name = "ic2"
url = uri("https://maven.ic2.player.to/")
url = uri("https://maven2.ic2.player.to/")
}
}

dependencies {
minecraft(group = "net.minecraftforge", name = "forge", version = "1.12.2-${versionForge}")

implementation(project(":IC2-Patched"))
// implementation(fg.deobf(group = "mezz.jei", name = "jei_1.12.2", version = versionJEI))
compileOnly(fg.deobf(group = "mezz.jei", name = "jei_1.12.2", version = versionJEI))
implementation(fg.deobf(group = "mezz.jei", name = "jei_1.12.2", version = versionJEI))
// compileOnly(fg.deobf(group = "mezz.jei", name = "jei_1.12.2", version = versionJEI))
}

tasks {
Expand Down Expand Up @@ -116,22 +116,22 @@ tasks {
exclude("patches");
}
from(generateDevBinPatches.output)
manifest {

manifest {
attributes(
"FMLCorePlugin" to "mods.su5ed.ic2patcher.asm.PatcherFMLPlugin",
"FMLCorePluginContainsFMLMod" to true
)
}
}

register<Jar>("releaseJar") {
archiveClassifier.set("")
val generateBinPatches = project(":IC2-Patched").tasks.getByName<GenerateBinPatches>("generateBinPatches")
dependsOn(generateBinPatches)

from(sourceSets.main.get().output)
manifest {
manifest {
attributes(
"FMLCorePlugin" to "mods.su5ed.ic2patcher.asm.PatcherFMLPlugin",
"FMLCorePluginContainsFMLMod" to true
Expand All @@ -146,7 +146,11 @@ tasks {

whenTaskAdded {
if (name.startsWith("prepareRun")) {
dependsOn(project(":IC2-Patched").tasks.getByName("patchRunJar"))
dependsOn("devJar")
dependsOn("patchModifyClassPath")
dependsOn("patchGenerateObfToSrg")
dependsOn("patchExtractMappingsZip")
}
}
}
Expand All @@ -157,7 +161,7 @@ reobf {
}
}

artifacts {
artifacts {
archives(tasks.getByName("releaseJar"))
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
119 changes: 70 additions & 49 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,25 +1,59 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand All @@ -30,43 +64,25 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
MSYS* | MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand All @@ -90,7 +106,7 @@ location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
Expand All @@ -110,11 +126,13 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
Expand All @@ -138,27 +156,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"
Loading

0 comments on commit 8c6f7f1

Please sign in to comment.