Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extractor 1.21 #641

Merged
merged 12 commits into from
Aug 24, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "17"
java-version: "21"

- name: Test Build
run: ./gradlew build
Expand Down
8 changes: 4 additions & 4 deletions extractor/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand All @@ -28,7 +28,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
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.21
yarn_mappings=1.21+build.9
loader_version=0.15.11
# 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.100.7+1.21
Binary file modified extractor/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 4 additions & 2 deletions 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.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package rs.valence.extractor;

import java.io.Serializable;
import java.util.Comparator;

/**
* Compare Class objects by their simple names lexicographically.
*/
public class ClassComparator implements Comparator<Class<?>> {
public class ClassComparator implements Comparator<Class<?>>, Serializable {
public ClassComparator() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ public class DummyPlayerEntity extends PlayerEntity {
static {
INSTANCE = Main.magicallyInstantiate(DummyPlayerEntity.class);

try {
var dataTrackerField = Entity.class.getDeclaredField("dataTracker");
dataTrackerField.setAccessible(true);
dataTrackerField.set(INSTANCE, new DataTracker(INSTANCE));

INSTANCE.initDataTracker();
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
INSTANCE.initDataTracker(new DataTracker.Builder(INSTANCE));
}

private DummyPlayerEntity(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) {
public DummyPlayerEntity(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) {
super(world, pos, yaw, gameProfile);
}

Expand Down
64 changes: 28 additions & 36 deletions extractor/src/main/java/rs/valence/extractor/DummyWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.component.type.MapIdComponent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.map.MapState;
import net.minecraft.recipe.BrewingRecipeRegistry;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.resource.featuretoggle.FeatureFlags;
Expand All @@ -30,6 +33,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,20 +94,25 @@ public Entity getEntityById(int id) {
return null;
}

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

@Nullable
@Override
public MapState getMapState(String id) {
public MapState getMapState(MapIdComponent id) {
return null;
}

@Override
public void putMapState(String id, MapState state) {
public void putMapState(MapIdComponent id, MapState state) {

}

@Override
public int getNextMapId() {
return 0;
public MapIdComponent increaseAndGetMapId() {
return null;
}

@Override
Expand All @@ -118,7 +127,7 @@ public Scoreboard getScoreboard() {

@Override
public RecipeManager getRecipeManager() {
return new RecipeManager();
return null;
}

@Override
Expand Down Expand Up @@ -147,12 +156,18 @@ public void syncWorldEvent(@Nullable PlayerEntity player, int eventId, BlockPos
}

@Override
public void emitGameEvent(GameEvent event, Vec3d emitterPos, GameEvent.Emitter emitter) {
public void emitGameEvent(RegistryEntry<GameEvent> event, Vec3d emitterPos, GameEvent.Emitter emitter) {

}


@Override
public DynamicRegistryManager getRegistryManager() {
return DynamicRegistryManager.of(Registries.REGISTRIES);
}

@Override
public BrewingRecipeRegistry getBrewingRecipeRegistry() {
return null;
}

Expand All @@ -178,45 +193,17 @@ public RegistryEntry<Biome> getGeneratorStoredBiome(int biomeX, int biomeY, int

private static class DummyMutableWorldProperties implements MutableWorldProperties {

@Override
public int getSpawnX() {
return 0;
}

@Override
public void setSpawnX(int spawnX) {

}

@Override
public int getSpawnY() {
return 0;
}

@Override
public void setSpawnY(int spawnY) {

}

@Override
public int getSpawnZ() {
return 0;
}

@Override
public void setSpawnZ(int spawnZ) {

public BlockPos getSpawnPos() {
return null;
}

@Override
public float getSpawnAngle() {
return 0;
}

@Override
public void setSpawnAngle(float spawnAngle) {

}

@Override
public long getTime() {
Expand Down Expand Up @@ -262,5 +249,10 @@ public Difficulty getDifficulty() {
public boolean isDifficultyLocked() {
return false;
}

@Override
public void setSpawnPos(BlockPos pos, float angle) {

}
}
}
28 changes: 13 additions & 15 deletions extractor/src/main/java/rs/valence/extractor/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ public void onInitialize() {
new Attributes(),
new Blocks(),
new Effects(),
new Enchants(),
new Entities(),
new Misc(),
new Items(),
new Packets(),
new Sounds(),
new TranslationKeys(),
Expand Down Expand Up @@ -75,27 +72,28 @@ public void onInitialize() {
}
}

ServerLifecycleEvents.SERVER_STARTING.register(server -> {
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
LOGGER.info("Server starting, Running startup extractors...");
// TODO: make `Codec` implement `Extractor`
var codecExtractor = new Codec(server);
// TODO: the way to get Codex has changed, this is not working anymore
var packetRegistryExtractor = new PacketRegistries(server);
try {
var out = outputDirectory.resolve(codecExtractor.fileName());
var compound = codecExtractor.extract();
// read the compound byte-wise and write it to the file
try {
NbtIo.write(compound, out.toFile());
} catch (IOException var3) {
throw new EncoderException(var3);
}
var out = outputDirectory.resolve(packetRegistryExtractor.fileName());
var fileWriter = new FileWriter(out.toFile(), StandardCharsets.UTF_8);
gson.toJson(packetRegistryExtractor.extract(), fileWriter);
fileWriter.close();

LOGGER.info("Wrote " + out.toAbsolutePath());
} catch (Exception e) {
LOGGER.error("Extractor for \"" + codecExtractor.fileName() + "\" failed.", e);
LOGGER.error("Extractor for \"" + packetRegistryExtractor.fileName() + "\" failed.", e);
}

var startupExtractors = new Extractor[]{
new Tags(server),
new Paintings(server),
new Enchants(server),
new Entities(server),
new Items(server),
};

for (var ext : startupExtractors) {
Expand All @@ -111,7 +109,7 @@ public void onInitialize() {
}

LOGGER.info("Done.");
server.shutdown();
server.stop(false);
});
}

Expand Down
Loading
Loading