diff --git a/extractor/build.gradle.kts b/extractor/build.gradle.kts deleted file mode 100644 index 944a30d35..000000000 --- a/extractor/build.gradle.kts +++ /dev/null @@ -1,103 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - kotlin("jvm") version "2.1.0" - id("fabric-loom") version "1.9-SNAPSHOT" - id("maven-publish") -} - -version = project.property("mod_version") as String -group = project.property("maven_group") as String - -base { - archivesName.set(project.property("archives_base_name") as String) -} - -val targetJavaVersion = 21 -java { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() -} - -loom { - splitEnvironmentSourceSets() - - mods { - register("extractor") { - sourceSet("main") - } - } -} - -repositories { - // Add repositories to retrieve artifacts from in here. - // You should only use this when depending on other mods because - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. - // See https://docs.gradle.org/current/userguide/declaring_repositories.html - // for more information about repositories. -} - -dependencies { - // To change the versions see the gradle.properties file - minecraft("com.mojang:minecraft:${project.property("minecraft_version")}") - mappings("net.fabricmc:yarn:${project.property("yarn_mappings")}:v2") - modImplementation("net.fabricmc:fabric-loader:${project.property("loader_version")}") - modImplementation("net.fabricmc:fabric-language-kotlin:${project.property("kotlin_loader_version")}") - - modImplementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_version")}") - - // To allow for reflection - implementation(kotlin("reflect")) -} - -tasks.processResources { - inputs.property("version", project.version) - inputs.property("minecraft_version", project.property("minecraft_version")) - inputs.property("loader_version", project.property("loader_version")) - filteringCharset = "UTF-8" - - filesMatching("fabric.mod.json") { - expand( - "version" to project.version, - "minecraft_version" to project.property("minecraft_version"), - "loader_version" to project.property("loader_version"), - "kotlin_loader_version" to project.property("kotlin_loader_version") - ) - } -} - -tasks.withType().configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - options.encoding = "UTF-8" - options.release.set(targetJavaVersion) -} - -tasks.withType().configureEach { - compilerOptions.jvmTarget.set(JvmTarget.fromTarget(targetJavaVersion.toString())) -} - - -// configure the maven publication -publishing { - publications { - create("mavenJava") { - artifactId = project.property("archives_base_name") as String - from(components["java"]) - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. - } -} diff --git a/extractor/gradle.properties b/extractor/gradle.properties deleted file mode 100644 index 880c97721..000000000 --- a/extractor/gradle.properties +++ /dev/null @@ -1,14 +0,0 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G -org.gradle.parallel=true -# Fabric Properties -# check these on https://modmuss50.me/fabric.html -minecraft_version=1.21.4 -yarn_mappings=1.21.4+build.2 -loader_version=0.16.9 -kotlin_loader_version=1.13.0+kotlin.2.1.0 -# Mod Properties -mod_version=1.0-SNAPSHOT -maven_group=de.snowii -archives_base_name=extractor -fabric_version=0.113.0+1.21.4 diff --git a/extractor/gradle/wrapper/gradle-wrapper.properties b/extractor/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index cea7a793a..000000000 --- a/extractor/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/extractor/gradlew b/extractor/gradlew deleted file mode 100755 index 057afac53..000000000 --- a/extractor/gradlew +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original 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. -# -# SPDX-License-Identifier: Apache-2.0 -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# 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/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# 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 -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -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 - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - 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 -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-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" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/extractor/gradlew.bat b/extractor/gradlew.bat deleted file mode 100644 index 6a90cee9b..000000000 --- a/extractor/gradlew.bat +++ /dev/null @@ -1,94 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@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 ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -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% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/extractor/settings.gradle.kts b/extractor/settings.gradle.kts deleted file mode 100644 index 05eb23d12..000000000 --- a/extractor/settings.gradle.kts +++ /dev/null @@ -1,8 +0,0 @@ -pluginManagement { - repositories { - maven("https://maven.fabricmc.net/") { - name = "Fabric" - } - gradlePluginPortal() - } -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/Extractor.kt b/extractor/src/main/kotlin/de/snowii/extractor/Extractor.kt deleted file mode 100644 index 2f47fe63c..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/Extractor.kt +++ /dev/null @@ -1,70 +0,0 @@ -package de.snowii.extractor - -import com.google.gson.GsonBuilder -import com.google.gson.JsonElement -import de.snowii.extractor.extractors.* -import net.fabricmc.api.ModInitializer -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents -import net.minecraft.server.MinecraftServer -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import java.io.FileWriter -import java.io.IOException -import java.nio.charset.StandardCharsets -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths - - -class Extractor : ModInitializer { - private val modID: String = "pumpkin_extractor" - private val logger: Logger = LoggerFactory.getLogger(modID) - - override fun onInitialize() { - logger.info("Starting Pumpkin Extractor") - val extractors = arrayOf( - Sounds(), - Recipes(), - Particles(), - SyncedRegistries(), - Packets(), - Screens(), - Tags(), - Entities(), - Items(), - Blocks(), - Tests(), - ) - - val outputDirectory: Path - try { - outputDirectory = Files.createDirectories(Paths.get("pumpkin_extractor_output")) - } catch (e: IOException) { - logger.info("Failed to create output directory.", e) - return - } - - val gson = GsonBuilder().disableHtmlEscaping().create() - - ServerLifecycleEvents.SERVER_STARTED.register(ServerLifecycleEvents.ServerStarted { server: MinecraftServer -> - for (ext in extractors) { - try { - val out = outputDirectory.resolve(ext.fileName()) - val fileWriter = FileWriter(out.toFile(), StandardCharsets.UTF_8) - gson.toJson(ext.extract(server), fileWriter) - fileWriter.close() - logger.info("Wrote " + out.toAbsolutePath()) - } catch (e: java.lang.Exception) { - logger.error(("Extractor for \"" + ext.fileName()) + "\" failed.", e) - } - } - }) - } - - interface Extractor { - fun fileName(): String - - @Throws(Exception::class) - fun extract(server: MinecraftServer): JsonElement - } -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Blocks.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Blocks.kt deleted file mode 100644 index b4d3a82d2..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Blocks.kt +++ /dev/null @@ -1,116 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import de.snowii.extractor.Extractor -import net.minecraft.block.Block -import net.minecraft.registry.Registries -import net.minecraft.server.MinecraftServer -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Box -import net.minecraft.world.EmptyBlockView -import java.util.* - -class Blocks : Extractor.Extractor { - override fun fileName(): String { - return "blocks.json" - } - - override fun extract(server: MinecraftServer): JsonElement { - val topLevelJson = JsonObject() - - val blocksJson = JsonArray() - - val shapes: LinkedHashMap = LinkedHashMap() - - for (block in Registries.BLOCK) { - val blockJson = JsonObject() - blockJson.addProperty("id", Registries.BLOCK.getRawId(block)) - blockJson.addProperty("name", Registries.BLOCK.getId(block).path) - blockJson.addProperty("translation_key", block.translationKey) - blockJson.addProperty("hardness", block.hardness) - blockJson.addProperty("item_id", Registries.ITEM.getRawId(block.asItem())) - - val propsJson = JsonArray() - for (prop in block.stateManager.properties) { - val propJson = JsonObject() - - propJson.addProperty("name", prop.name) - - val valuesJson = JsonArray() - for (value in prop.values) { - valuesJson.add(value.toString().lowercase()) - } - propJson.add("values", valuesJson) - - propsJson.add(propJson) - } - blockJson.add("properties", propsJson) - - val statesJson = JsonArray() - for (state in block.stateManager.states) { - val stateJson = JsonObject() - stateJson.addProperty("id", Block.getRawIdFromState(state)) - stateJson.addProperty("air", state.isAir) - stateJson.addProperty("luminance", state.luminance) - stateJson.addProperty("burnable", state.isBurnable) - if (state.isOpaque) { - stateJson.addProperty("opacity", state.opacity) - } - stateJson.addProperty("sided_transparency", state.hasSidedTransparency()) - stateJson.addProperty("replaceable", state.isReplaceable) - - if (block.defaultState == state) { - blockJson.addProperty("default_state_id", Block.getRawIdFromState(state)) - } - - val collisionShapeIdxsJson = JsonArray() - for (box in state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN).boundingBoxes) { - val idx = shapes.putIfAbsent(box, shapes.size) - collisionShapeIdxsJson.add(Objects.requireNonNullElseGet(idx) { shapes.size - 1 }) - } - - stateJson.add("collision_shapes", collisionShapeIdxsJson) - - for (blockEntity in Registries.BLOCK_ENTITY_TYPE) { - if (blockEntity.supports(state)) { - stateJson.addProperty("block_entity_type", Registries.BLOCK_ENTITY_TYPE.getRawId(blockEntity)) - } - } - - statesJson.add(stateJson) - } - blockJson.add("states", statesJson) - - blocksJson.add(blockJson) - } - - val blockEntitiesJson = JsonArray() - for (blockEntity in Registries.BLOCK_ENTITY_TYPE) { - blockEntitiesJson.add(Registries.BLOCK_ENTITY_TYPE.getId(blockEntity)!!.path) - } - - val shapesJson = JsonArray() - for (shape in shapes.keys) { - val shapeJson = JsonObject() - val min = JsonArray() - min.add(shape.minX) - min.add(shape.minY) - min.add(shape.minZ) - val max = JsonArray() - max.add(shape.maxX) - max.add(shape.maxY) - max.add(shape.maxZ) - shapeJson.add("min", min) - shapeJson.add("max", max) - shapesJson.add(shapeJson) - } - - topLevelJson.add("block_entity_types", blockEntitiesJson) - topLevelJson.add("shapes", shapesJson) - topLevelJson.add("blocks", blocksJson) - - return topLevelJson - } -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Entities.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Entities.kt deleted file mode 100644 index 475047118..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Entities.kt +++ /dev/null @@ -1,42 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import de.snowii.extractor.Extractor -import net.minecraft.entity.LivingEntity -import net.minecraft.entity.SpawnReason -import net.minecraft.registry.Registries -import net.minecraft.server.MinecraftServer - -class Entities : Extractor.Extractor { - override fun fileName(): String { - return "entities.json" - } - - override fun extract(server: MinecraftServer): JsonElement { - val entitiesJson = JsonObject() - for (entityType in Registries.ENTITY_TYPE) { - val entity = entityType.create(server.overworld!!, SpawnReason.NATURAL) ?: continue - val entityJson = JsonObject() - entityJson.addProperty("id", Registries.ENTITY_TYPE.getRawId(entityType)) - if (entity is LivingEntity) { - entityJson.addProperty("max_health", entity.maxHealth) - - } - entityJson.addProperty("attackable", entity.isAttackable) - entityJson.addProperty("summonable", entityType.isSummonable) - entityJson.addProperty("fire_immune", entityType.isFireImmune) - val dimension = JsonArray() - dimension.add(entityType.dimensions.width) - dimension.add(entityType.dimensions.height) - entityJson.add("dimension", dimension) - - entitiesJson.add( - Registries.ENTITY_TYPE.getId(entityType).path, entityJson - ) - } - - return entitiesJson - } -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Items.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Items.kt deleted file mode 100644 index ec76836f5..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Items.kt +++ /dev/null @@ -1,41 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.mojang.serialization.JsonOps -import de.snowii.extractor.Extractor -import net.minecraft.component.ComponentMap -import net.minecraft.item.Item -import net.minecraft.registry.Registries -import net.minecraft.registry.RegistryKeys -import net.minecraft.registry.RegistryOps -import net.minecraft.server.MinecraftServer - - -class Items : Extractor.Extractor { - override fun fileName(): String { - return "items.json" - } - - - override fun extract(server: MinecraftServer): JsonElement { - val itemsJson = JsonObject() - - for (item in server.registryManager.getOrThrow(RegistryKeys.ITEM).streamEntries().toList()) { - val itemJson = JsonObject() - val realItem: Item = item.value() - - itemJson.addProperty("id", Registries.ITEM.getRawId(realItem)) - itemJson.add( - "components", - ComponentMap.CODEC.encodeStart( - RegistryOps.of(JsonOps.INSTANCE, server.registryManager), - realItem.components - ).getOrThrow() - ) - - itemsJson.add(Registries.ITEM.getId(realItem).path, itemJson) - } - return itemsJson - } -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Packets.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Packets.kt deleted file mode 100644 index 548c87a3e..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Packets.kt +++ /dev/null @@ -1,105 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import de.snowii.extractor.Extractor -import io.netty.buffer.ByteBuf -import net.minecraft.network.NetworkPhase -import net.minecraft.network.NetworkState -import net.minecraft.network.PacketByteBuf -import net.minecraft.network.listener.ClientPacketListener -import net.minecraft.network.listener.ServerCrashSafePacketListener -import net.minecraft.network.packet.PacketType -import net.minecraft.network.state.* -import net.minecraft.server.MinecraftServer - - -class Packets : Extractor.Extractor { - override fun fileName(): String { - return "packets.json" - } - - override fun extract(server: MinecraftServer): JsonElement { - val packetsJson = JsonObject() - - val clientBound = arrayOf( - QueryStates.S2C_FACTORY, - LoginStates.S2C_FACTORY, - ConfigurationStates.S2C_FACTORY, - PlayStateFactories.S2C - ) - - val serverBound = arrayOf( - HandshakeStates.C2S_FACTORY, - QueryStates.C2S_FACTORY, - LoginStates.C2S_FACTORY, - ConfigurationStates.C2S_FACTORY, - PlayStateFactories.C2S - ) - val serverBoundJson = serializeServerBound(serverBound) - val clientBoundJson = serializeClientBound(clientBound) - - packetsJson.add("serverbound", serverBoundJson) - packetsJson.add("clientbound", clientBoundJson) - - return packetsJson - } - - - private fun serializeServerBound( - packets: Array> - ): JsonObject { - val handshakeArray = JsonArray() - val statusArray = JsonArray() - val loginArray = JsonArray() - val configArray = JsonArray() - val playArray = JsonArray() - - for (factory in packets) { - factory.forEachPacketType { type: PacketType<*>, _: Int -> - when (factory.phase()!!) { - NetworkPhase.HANDSHAKING -> handshakeArray.add(type.id().path) - NetworkPhase.PLAY -> playArray.add(type.id().path) - NetworkPhase.STATUS -> statusArray.add(type.id().path) - NetworkPhase.LOGIN -> loginArray.add(type.id().path) - NetworkPhase.CONFIGURATION -> configArray.add(type.id().path) - } - } - } - val finalJson = JsonObject() - finalJson.add("handshake", handshakeArray) - finalJson.add("status", statusArray) - finalJson.add("login", loginArray) - finalJson.add("config", configArray) - finalJson.add("play", playArray) - return finalJson - } - - private fun serializeClientBound( - packets: Array> - ): JsonObject { - val statusArray = JsonArray() - val loginArray = JsonArray() - val configArray = JsonArray() - val playArray = JsonArray() - - for (factory in packets) { - factory.forEachPacketType { type: PacketType<*>, _: Int -> - when (factory.phase()!!) { - NetworkPhase.HANDSHAKING -> error("Client bound Packet should have no handshake") - NetworkPhase.PLAY -> playArray.add(type.id().path) - NetworkPhase.STATUS -> statusArray.add(type.id().path) - NetworkPhase.LOGIN -> loginArray.add(type.id().path) - NetworkPhase.CONFIGURATION -> configArray.add(type.id().path) - } - } - } - val finalJson = JsonObject() - finalJson.add("status", statusArray) - finalJson.add("login", loginArray) - finalJson.add("config", configArray) - finalJson.add("play", playArray) - return finalJson - } -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Particles.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Particles.kt deleted file mode 100644 index 26d08d528..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Particles.kt +++ /dev/null @@ -1,25 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import de.snowii.extractor.Extractor -import net.minecraft.registry.Registries -import net.minecraft.server.MinecraftServer - - -class Particles : Extractor.Extractor { - override fun fileName(): String { - return "particles.json" - } - - override fun extract(server: MinecraftServer): JsonElement { - val particlesJson = JsonArray() - for (particle in Registries.PARTICLE_TYPE) { - particlesJson.add( - Registries.PARTICLE_TYPE.getId(particle)!!.path, - ) - } - - return particlesJson - } -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Recipes.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Recipes.kt deleted file mode 100644 index 6e1657df1..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Recipes.kt +++ /dev/null @@ -1,30 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import com.mojang.serialization.JsonOps -import de.snowii.extractor.Extractor -import net.minecraft.recipe.Recipe -import net.minecraft.registry.RegistryOps -import net.minecraft.server.MinecraftServer - -class Recipes : Extractor.Extractor { - override fun fileName(): String { - return "recipes.json" - } - - override fun extract(server: MinecraftServer): JsonElement { - val recipesJson = JsonArray() - - for (recipeRaw in server.recipeManager.values()) { - val recipe = recipeRaw.value - recipesJson.add( - Recipe.CODEC.encodeStart( - RegistryOps.of(JsonOps.INSTANCE, server.registryManager), - recipe - ).getOrThrow() - ) - } - return recipesJson - } -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Screens.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Screens.kt deleted file mode 100644 index d52b90745..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Screens.kt +++ /dev/null @@ -1,24 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import de.snowii.extractor.Extractor -import net.minecraft.registry.Registries -import net.minecraft.server.MinecraftServer - -class Screens : Extractor.Extractor { - override fun fileName(): String { - return "screens.json" - } - - override fun extract(server: MinecraftServer): JsonElement { - val screensJson = JsonArray() - for (screen in Registries.SCREEN_HANDLER) { - screensJson.add( - Registries.SCREEN_HANDLER.getId(screen)!!.path, - ) - } - - return screensJson - } -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Sounds.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Sounds.kt deleted file mode 100644 index 3efdc42c4..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Sounds.kt +++ /dev/null @@ -1,25 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import de.snowii.extractor.Extractor -import net.minecraft.registry.Registries -import net.minecraft.server.MinecraftServer - - -class Sounds : Extractor.Extractor { - override fun fileName(): String { - return "sounds.json" - } - - override fun extract(server: MinecraftServer): JsonElement { - val soundJson = JsonArray() - for (sound in Registries.SOUND_EVENT) { - soundJson.add( - Registries.SOUND_EVENT.getId(sound)!!.path, - ) - } - - return soundJson - } -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/SyncedRegistries.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/SyncedRegistries.kt deleted file mode 100644 index 207adadbb..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/SyncedRegistries.kt +++ /dev/null @@ -1,50 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.mojang.serialization.Codec -import com.mojang.serialization.JsonOps -import de.snowii.extractor.Extractor -import net.minecraft.registry.* -import net.minecraft.server.MinecraftServer -import java.util.stream.Stream - - -class SyncedRegistries : Extractor.Extractor { - override fun fileName(): String { - return "synced_registries.json" - } - - override fun extract(server: MinecraftServer): JsonElement { - val registries: Stream> = RegistryLoader.SYNCED_REGISTRIES.stream() - val json = JsonObject() - registries.forEach { entry -> - json.add( - entry.key().value.path, - mapJson(entry, server.registryManager, server.combinedDynamicRegistries) - ) - } - return json - } - - private fun mapJson( - registryEntry: RegistryLoader.Entry, - registryManager: DynamicRegistryManager.Immutable, - combinedRegistries: CombinedDynamicRegistries - ): JsonObject { - val codec: Codec = registryEntry.elementCodec() - val registry: Registry = registryManager.getOrThrow(registryEntry.key()) - val json = JsonObject() - registry.streamEntries().forEach { entry -> - json.add( - entry.key.orElseThrow().value.path, - codec.encodeStart( - combinedRegistries.combinedRegistryManager.getOps(JsonOps.INSTANCE), - entry.value() - ).getOrThrow() - ) - } - return json - } - -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Tags.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Tags.kt deleted file mode 100644 index 85a9ece13..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Tags.kt +++ /dev/null @@ -1,40 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import de.snowii.extractor.Extractor -import net.minecraft.registry.tag.TagPacketSerializer -import net.minecraft.server.MinecraftServer - - -class Tags : Extractor.Extractor { - override fun fileName(): String { - return "tags.json" - } - - override fun extract(server: MinecraftServer): JsonElement { - val tagsJson = JsonArray() - - val tags = TagPacketSerializer.serializeTags(server.combinedDynamicRegistries) - - for (tag in tags.entries) { - val tagGroupTagsJson = JsonObject() - tagGroupTagsJson.addProperty("name", tag.key.value.path) - val tagValues = - tag.value.toRegistryTags(server.combinedDynamicRegistries.combinedRegistryManager.getOrThrow(tag.key)) - for (value in tagValues.tags) { - val tagGroupTagsJsonArray = JsonArray() - for (tagVal in value.value) { - tagGroupTagsJsonArray.add(tagVal.key.orElseThrow().value.path) - } - tagGroupTagsJson.add(value.key.id.path, tagGroupTagsJsonArray) - } - tagsJson.add(tagGroupTagsJson) - } - - return tagsJson - } - - -} diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Tests.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Tests.kt deleted file mode 100644 index e75a1797d..000000000 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Tests.kt +++ /dev/null @@ -1,137 +0,0 @@ -package de.snowii.extractor.extractors - -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import de.snowii.extractor.Extractor -import net.minecraft.block.Block -import net.minecraft.block.BlockState -import net.minecraft.block.Blocks -import net.minecraft.registry.BuiltinRegistries -import net.minecraft.registry.RegistryKeys -import net.minecraft.server.MinecraftServer -import net.minecraft.util.math.ChunkPos -import net.minecraft.world.gen.chunk.* -import net.minecraft.world.gen.densityfunction.DensityFunction.EachApplier -import net.minecraft.world.gen.densityfunction.DensityFunction.NoisePos -import net.minecraft.world.gen.densityfunction.DensityFunctionTypes -import net.minecraft.world.gen.noise.NoiseConfig -import kotlin.reflect.KFunction -import kotlin.reflect.full.declaredFunctions - -class Tests : Extractor.Extractor { - override fun fileName(): String = "chunk.json" - - private fun createFluidLevelSampler(settings: ChunkGeneratorSettings): AquiferSampler.FluidLevelSampler { - val fluidLevel = AquiferSampler.FluidLevel(-54, Blocks.LAVA.defaultState) - val i = settings.seaLevel() - val fluidLevel2 = AquiferSampler.FluidLevel(i, settings.defaultFluid()) - return AquiferSampler.FluidLevelSampler { _, y, _ -> if (y < Math.min(-54, i)) fluidLevel else fluidLevel2 } - } - - private fun get_index(config: GenerationShapeConfig, x: Int, y: Int, z: Int): Int { - if (x < 0 || y < 0 || z < 0) { - System.err.println("Bad local pos") - System.exit(1) - } - return config.height() * 16 * x + 16 * y + z - } - - // This is basically just what NoiseChunkGenerator is doing - private fun populate_noise( - start_x: Int, - start_z: Int, - sampler: ChunkNoiseSampler, - config: GenerationShapeConfig, - settings: ChunkGeneratorSettings - ): IntArray? { - val result = IntArray(16 * 16 * config.height()) - - for (method: KFunction<*> in sampler::class.declaredFunctions) { - if (method.name.equals("sampleBlockState")) { - sampler.sampleStartDensity() - val k = config.horizontalCellBlockCount() - val l = config.verticalCellBlockCount() - - val m = 16 / k - val n = 16 / k - - val cellHeight = config.height() / l - val minimumCellY = config.minimumY() / l - - for (o in 0.. - topLevelJson.add(state) - } - - return topLevelJson - } -} diff --git a/extractor/src/main/resources/fabric.mod.json b/extractor/src/main/resources/fabric.mod.json deleted file mode 100644 index 695e56e8a..000000000 --- a/extractor/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "schemaVersion": 1, - "id": "extractor", - "version": "${version}", - "name": "pumpkin-extractor", - "description": "", - "authors": [], - "contact": {}, - "license": "MIT", - "environment": "*", - "entrypoints": { - "main": [ - "de.snowii.extractor.Extractor" - ] - }, - "depends": { - "fabricloader": ">=${loader_version}", - "fabric-language-kotlin": ">=${kotlin_loader_version}", - "fabric": "*", - "minecraft": "${minecraft_version}" - } -}