Skip to content

Commit

Permalink
Update extractor to 1.20.4
Browse files Browse the repository at this point in the history
Changes taken from #594

Co-authored-by: Bafbi <[email protected]>
  • Loading branch information
rj00a and Bafbi committed Feb 10, 2024
1 parent 06da07c commit c25c6ab
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 30 deletions.
2 changes: 1 addition & 1 deletion extractor/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
}

sourceCompatibility = JavaVersion.VERSION_17
Expand Down
8 changes: 4 additions & 4 deletions extractor/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.1
loader_version=0.14.21
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.6
# Mod Properties
mod_version=1.0.0
maven_group=dev.00a
archives_base_name=valence-extractor
# Dependencies
fabric_version=0.83.0+1.20.1
fabric_version=0.95.0+1.20.4
Binary file modified extractor/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion extractor/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 22 additions & 13 deletions extractor/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/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 All @@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${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"'
# 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

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# 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"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
1 change: 1 addition & 0 deletions extractor/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
8 changes: 7 additions & 1 deletion extractor/src/main/java/rs/valence/extractor/DummyWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.minecraft.world.entity.EntityLookup;
import net.minecraft.world.event.GameEvent;
import net.minecraft.world.tick.QueryableTickScheduler;
import net.minecraft.world.tick.TickManager;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.function.Supplier;
Expand Down Expand Up @@ -90,6 +91,11 @@ public Entity getEntityById(int id) {
return null;
}

@Override
public TickManager getTickManager() {
return null;
}

@Nullable
@Override
public MapState getMapState(String id) {
Expand Down Expand Up @@ -158,7 +164,7 @@ public DynamicRegistryManager getRegistryManager() {

@Override
public FeatureSet getEnabledFeatures() {
return FeatureSet.of(FeatureFlags.VANILLA, FeatureFlags.BUNDLE);
return FeatureSet.of(FeatureFlags.VANILLA, FeatureFlags.BUNDLE, FeatureFlags.UPDATE_1_21);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion extractor/src/main/java/rs/valence/extractor/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void onInitialize() {
var compound = codecExtractor.extract();
// read the compound byte-wise and write it to the file
try {
NbtIo.write(compound, out.toFile());
NbtIo.write(compound, out);
} catch (IOException var3) {
throw new EncoderException(var3);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.registry.Registries;
import rs.valence.extractor.Main;
import rs.valence.extractor.ValenceUtils;
Expand Down Expand Up @@ -35,10 +36,11 @@ public JsonElement extract() {
for (var entry : effect.getAttributeModifiers().entrySet()) {
var attributeModifierJson = new JsonObject();

var attributeModidier = entry.getValue().createAttributeModifier(0);
attributeModifierJson.addProperty("attribute", Registries.ATTRIBUTE.getRawId(entry.getKey()));
attributeModifierJson.addProperty("operation", entry.getValue().getOperation().getId());
attributeModifierJson.addProperty("value", entry.getValue().getValue());
attributeModifierJson.addProperty("uuid", entry.getValue().getId().toString());
attributeModifierJson.addProperty("operation", attributeModidier.getOperation().getId());
attributeModifierJson.addProperty("base_value", attributeModidier.getValue());
attributeModifierJson.addProperty("uuid", entry.getValue().getUuid().toString());

attributeModifiersJson.add(attributeModifierJson);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,11 @@ public JsonElement extract() throws IllegalAccessException, NoSuchFieldException
// the data tracker field from the base entity class.
// We also handle player entities specially since they cannot be spawned with
// EntityType#create.
final var entityInstance = entityType.equals(EntityType.PLAYER) ? DummyPlayerEntity.INSTANCE
final var entityInstance = entityType.equals(EntityType.PLAYER)
? DummyPlayerEntity.INSTANCE
: entityType.create(DummyWorld.INSTANCE);

final var dataTracker = (DataTracker) dataTrackerField.get(entityInstance);
final var dataTracker = entityInstance.getDataTracker();

while (entitiesMap.get(entityClass) == null) {
var entityJson = new JsonObject();
Expand Down Expand Up @@ -281,9 +282,9 @@ public JsonElement extract() throws IllegalAccessException, NoSuchFieldException
if (bb != null && entityType != null) {
var boundingBoxJson = new JsonObject();

boundingBoxJson.addProperty("size_x", bb.getXLength());
boundingBoxJson.addProperty("size_y", bb.getYLength());
boundingBoxJson.addProperty("size_z", bb.getZLength());
boundingBoxJson.addProperty("size_x", bb.getLengthX());
boundingBoxJson.addProperty("size_y", bb.getLengthY());
boundingBoxJson.addProperty("size_z", bb.getLengthZ());

entityJson.add("default_bounding_box", boundingBoxJson);
}
Expand Down
2 changes: 1 addition & 1 deletion extractor/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"depends": {
"fabricloader": ">=0.14.6",
"minecraft": "~1.20.1",
"minecraft": "~1.20.4",
"java": ">=17"
},
"suggests": {
Expand Down

0 comments on commit c25c6ab

Please sign in to comment.