diff --git a/build.gradle b/build.gradle
index d224a3335..b3f242443 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,94 +1,84 @@
-buildscript {
- repositories {
- jcenter()
- maven { url = "http://files.minecraftforge.net/maven" }
- }
- dependencies {
- classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
- }
-}
-apply plugin: 'net.minecraftforge.gradle.forge'
-//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
-
-
-group= "hunternif.mc.atlas"
-archivesBaseName = "antiqueatlas"
-
-ext.mod_version = "$version_major.$version_minor.$version_patch"
-version = "$mc_version-$mod_version"
-
-sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
-compileJava {
- sourceCompatibility = targetCompatibility = '1.8'
-}
-
-minecraft {
- version = "$mc_version-$forge_version"
- runDir = "run"
-
- // the mappings can be changed at any time, and must be in the following format.
- // snapshot_YYYYMMDD snapshot are built nightly.
- // stable_# stables are built at the discretion of the MCP team.
- // Use non-default mappings at your own risk. they may not always work.
- // simply re-run your setup task after changing the mappings to update your workspace.
- mappings = "stable_39"
- // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
-
- replace '@VERSION@', project.mod_version
-}
-
-dependencies {
- // you may put jars on which you depend on in ./libs
- // or you may define them like so..
- //compile "some.group:artifact:version:classifier"
- //compile "some.group:artifact:version"
-
- // real examples
- //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
- //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
-
- // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
- //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
-
- // the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
- // except that these dependencies get remapped to your current MCP mappings
- //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
- //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
-
- // for more info...
- // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
- // http://www.gradle.org/docs/current/userguide/dependency_management.html
-
- testCompile "junit:junit:4.+"
-}
-
-processResources {
- // this will ensure that this task is redone when the versions change.
- inputs.property "version", project.version
- inputs.property "mcversion", project.minecraft.version
-
- // replace stuff in mcmod.info, nothing else
- from(sourceSets.main.resources.srcDirs) {
- include 'mcmod.info'
-
- // replace version and mcversion
- expand 'version':project.version, 'mcversion':project.minecraft.version
- }
-
- // copy everything else except the mcmod.info
- from(sourceSets.main.resources.srcDirs) {
- exclude 'mcmod.info'
- }
-}
-
-task deobfJar(type: Jar) {
- from sourceSets.main.output
- classifier = 'deobf'
-}
-
-tasks.build.dependsOn('sourceJar', 'deobfJar')
-
-artifacts {
- archives deobfJar
- archives sourceJar
-}
\ No newline at end of file
+plugins {
+ id 'fabric-loom' version '0.2.0-SNAPSHOT'
+ id 'maven-publish'
+}
+
+sourceCompatibility = JavaVersion.VERSION_1_8
+targetCompatibility = JavaVersion.VERSION_1_8
+
+archivesBaseName = project.archives_base_name
+version = project.mod_version
+group = project.maven_group
+
+minecraft {
+}
+
+dependencies {
+ //to change the versions see the gradle.properties file
+ minecraft "com.mojang:minecraft:${project.minecraft_version}"
+ mappings "net.fabricmc:yarn:${project.yarn_mappings}"
+ modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
+
+ // Fabric API. This is technically optional, but you probably want it anyway.
+ modCompile "net.fabricmc:fabric:${project.fabric_version}"
+
+ compile 'com.google.code.findbugs:jsr305:3.0.2'
+}
+
+processResources {
+ // this will ensure that this task is re-run when there's a change
+ inputs.property "version", project.version
+
+ // replace stuff in fabric.mod.json, nothing else
+ from(sourceSets.main.resources.srcDirs) {
+ include "fabric.mod.json"
+
+ // add mod metadata
+ expand "version": project.version
+ }
+
+ // copy everything else, thats not the mcmod.info
+ from(sourceSets.main.resources.srcDirs) {
+ exclude "fabric.mod.json"
+ }
+}
+
+// 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
+tasks.withType(JavaCompile) {
+ options.encoding = "UTF-8"
+}
+
+// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
+// if it is present.
+// If you remove this task, sources will not be generated.
+task sourcesJar(type: Jar, dependsOn: classes) {
+ classifier = "sources"
+ from sourceSets.main.allSource
+}
+
+jar {
+ from "LICENSE"
+}
+
+// configure the maven publication
+publishing {
+ publications {
+ mavenJava(MavenPublication) {
+ // add all the jars that should be included when publishing to maven
+ artifact(jar) {
+ builtBy remapJar
+ }
+ artifact(sourcesJar) {
+ builtBy remapSourcesJar
+ }
+ }
+ }
+
+ // select the repositories you want to publish to
+ repositories {
+ // uncomment to publish to the local maven
+ // mavenLocal()
+ }
+}
diff --git a/gradle.properties b/gradle.properties
index 207439dde..c2152b5d3 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,8 +1,17 @@
-# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
-# This is required to provide enough memory for the Minecraft decompilation process.
-org.gradle.jvmargs=-Xmx3G
-mc_version=1.12.2
-forge_version=14.23.2.2611
-version_major=4
-version_minor=5
-version_patch=0
+# Done to increase the memory available to gradle.
+org.gradle.jvmargs=-Xmx1G
+
+# Fabric Properties
+ # check these on https://fabricmc.net/use
+ minecraft_version=19w08b
+ yarn_mappings=19w08b.4
+ loader_version=0.3.7.109
+
+# Mod Properties
+ mod_version = 5.0.0+fabric
+ maven_group = hunternif.mc.atlas
+ archives_base_name = antiqueatlas
+
+# Dependencies
+ # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric
+ fabric_version=0.2.3.104
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 30d399d8d..29953ea14 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index e18cba72f..e0b3fb8d7 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -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-4.10.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
diff --git a/gradlew b/gradlew
index 91a7e269e..cccdd3d51 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
##############################################################################
##
@@ -6,20 +6,38 @@
##
##############################################################################
-# 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=""
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
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.
@@ -90,7 +89,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
@@ -114,6 +113,7 @@ fi
if $cygwin ; 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`
@@ -154,11 +154,19 @@ if $cygwin ; then
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"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index aec99730b..f9553162f 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,90 +1,84 @@
-@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
-
-@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=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-: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 %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="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!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@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=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@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=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+: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 %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="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!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 000000000..5b60df3d2
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,10 @@
+pluginManagement {
+ repositories {
+ jcenter()
+ maven {
+ name = 'Fabric'
+ url = 'https://maven.fabricmc.net/'
+ }
+ gradlePluginPortal()
+ }
+}
diff --git a/src/main/java/hunternif/mc/atlas/AntiqueAtlasMod.java b/src/main/java/hunternif/mc/atlas/AntiqueAtlasMod.java
index aac225077..395fd1f1e 100644
--- a/src/main/java/hunternif/mc/atlas/AntiqueAtlasMod.java
+++ b/src/main/java/hunternif/mc/atlas/AntiqueAtlasMod.java
@@ -1,6 +1,7 @@
package hunternif.mc.atlas;
import hunternif.mc.atlas.core.AtlasDataHandler;
+import hunternif.mc.atlas.core.GlobalAtlasData;
import hunternif.mc.atlas.core.PlayerEventHandler;
import hunternif.mc.atlas.ext.*;
import hunternif.mc.atlas.ext.watcher.*;
@@ -12,7 +13,8 @@
import hunternif.mc.atlas.marker.NetherPortalWatcher;
import hunternif.mc.atlas.network.PacketDispatcher;
import hunternif.mc.atlas.registry.MarkerTypes;
-import net.minecraft.world.DimensionType;
+import net.minecraft.server.world.ServerWorld;
+import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
@@ -21,6 +23,7 @@
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
+import none.XX_1_13_none_bnu_XX;
@Mod(modid=AntiqueAtlasMod.ID, name=AntiqueAtlasMod.NAME, version=AntiqueAtlasMod.VERSION, dependencies="after:forge@[14.23.2.2611,);")
public class AntiqueAtlasMod {
@@ -32,8 +35,6 @@ public class AntiqueAtlasMod {
@Instance(ID)
public static AntiqueAtlasMod instance;
- public boolean jeidPresent = false;
-
@SidedProxy(clientSide="hunternif.mc.atlas.ClientProxy", serverSide="hunternif.mc.atlas.CommonProxy")
public static CommonProxy proxy;
@@ -43,6 +44,16 @@ public class AntiqueAtlasMod {
public static final ExtBiomeDataHandler extBiomeData = new ExtBiomeDataHandler();
public static final GlobalMarkersDataHandler globalMarkersData = new GlobalMarkersDataHandler();
+ private static final GlobalAtlasData clientAtlasData = new GlobalAtlasData();
+
+ public static GlobalAtlasData getGlobalAtlasData(World world) {
+ if (world instanceof ServerWorld) {
+ return ((ServerWorld) world).getPersistentStateManager().getOrCreate(() -> new GlobalAtlasData("antiqueatlas:global_atlas_data"), "antiqueatlas:global_atlas_data");
+ } else {
+ return clientAtlasData;
+ }
+ }
+
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit(event);
@@ -70,7 +81,7 @@ public void init(FMLInitializationEvent event){
// Structure Watchers
new StructureWatcherVillage();
new StructureWatcherFortress();
- new StructureWatcherGeneric("EndCity", DimensionType.THE_END, MarkerTypes.END_CITY_FAR, "gui.antiqueatlas.marker.endcity").setTileMarker(MarkerTypes.END_CITY, "gui.antiqueatlas.marker.endcity");
+ new StructureWatcherGeneric("EndCity", XX_1_13_none_bnu_XX.c, MarkerTypes.END_CITY_FAR, "gui.antiqueatlas.marker.endcity").setTileMarker(MarkerTypes.END_CITY, "gui.antiqueatlas.marker.endcity");
}
@EventHandler
diff --git a/src/main/java/hunternif/mc/atlas/ClientProxy.java b/src/main/java/hunternif/mc/atlas/ClientProxy.java
index 99f78918b..7abd584d3 100644
--- a/src/main/java/hunternif/mc/atlas/ClientProxy.java
+++ b/src/main/java/hunternif/mc/atlas/ClientProxy.java
@@ -1,7 +1,6 @@
package hunternif.mc.atlas;
import hunternif.mc.atlas.client.*;
-import hunternif.mc.atlas.client.TextureSet;
import hunternif.mc.atlas.client.gui.ExportProgressOverlay;
import hunternif.mc.atlas.client.gui.GuiAtlas;
import hunternif.mc.atlas.ext.ExtTileIdMap;
@@ -11,16 +10,19 @@
import hunternif.mc.atlas.registry.MarkerRegistry;
import hunternif.mc.atlas.registry.MarkerType;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.resources.IReloadableResourceManager;
-import net.minecraft.client.resources.IResourceManager;
-import net.minecraft.client.resources.IResourceManagerReloadListener;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.init.Biomes;
+import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
+import net.minecraft.client.MinecraftClient;
+
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
+import net.minecraft.resource.ReloadableResourceManager;
+import net.minecraft.resource.ResourceManager;
+import net.minecraft.resource.ResourceReloadListener;
import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.IThreadListener;
+import net.minecraft.util.Identifier;
+import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
+import net.minecraft.world.biome.Biomes;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
@@ -29,12 +31,14 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
-
+import none.TODO_1_13_2_none_acv;
import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
import static hunternif.mc.atlas.client.TextureSet.*;
-public class ClientProxy extends CommonProxy implements IResourceManagerReloadListener {
+public class ClientProxy extends CommonProxy implements SimpleSynchronousResourceReloadListener {
private TextureSetMap textureSetMap;
private TextureSetConfig textureSetConfig;
private BiomeTextureMap biomeTextureMap;
@@ -83,8 +87,8 @@ public void preInit(FMLPreInitializationEvent event) {
tileTextureMap.setDirty(false);
registerVanillaCustomTileTextures();
- if(Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) {
- ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(this);
+ if(MinecraftClient.getInstance().getResourceManager() instanceof ReloadableResourceManager) {
+ ((ReloadableResourceManager)MinecraftClient.getInstance().getResourceManager()).registerListener(this);
}
}
@@ -105,7 +109,7 @@ public void init(FMLInitializationEvent event) {
MarkerRegistry.INSTANCE.setDirty(true);
guiAtlas = new GuiAtlas();
- for (MarkerType type : MarkerRegistry.getValues()) {
+ for (MarkerType type : MarkerRegistry.iterable()) {
type.initMips();
}
@@ -135,10 +139,10 @@ public void openAtlasGUI() {
}
private void openAtlasGUI(GuiAtlas gui) {
- Minecraft mc = Minecraft.getMinecraft();
+ MinecraftClient mc = MinecraftClient.getInstance();
if (mc.currentScreen == null) { // In-game screen
guiAtlas.updateL18n();
- mc.displayGuiScreen(gui);
+ mc.openScreen(gui);
}
}
@@ -242,71 +246,71 @@ private void registerDefaultTextureSets(TextureSetMap map) {
* only if the biome was not in the config. This prevents unnecessary
* overwriting, to aid people who manually modify the config. */
private void assignVanillaBiomeTextures() {
- setBiomeTextureIfNone(Biomes.OCEAN, WATER);
- setBiomeTextureIfNone(Biomes.DEEP_OCEAN, WATER);
- setBiomeTextureIfNone(Biomes.RIVER, WATER); //
- setBiomeTextureIfNone(Biomes.FROZEN_OCEAN, ICE);
- setBiomeTextureIfNone(Biomes.FROZEN_RIVER, ICE);
- setBiomeTextureIfNone(Biomes.BEACH, SHORE);
- setBiomeTextureIfNone(Biomes.COLD_BEACH, SHORE);
- setBiomeTextureIfNone(Biomes.STONE_BEACH, ROCK_SHORE);
- setBiomeTextureIfNone(Biomes.DESERT, DESERT);
- setBiomeTextureIfNone(Biomes.MUTATED_DESERT, DESERT);
- setBiomeTextureIfNone(Biomes.DESERT_HILLS, DESERT_HILLS);
- setBiomeTextureIfNone(Biomes.PLAINS, PLAINS);
- setBiomeTextureIfNone(Biomes.MUTATED_PLAINS, SUNFLOWERS);
- setBiomeTextureIfNone(Biomes.ICE_PLAINS, SNOW);
- setBiomeTextureIfNone(Biomes.MUTATED_ICE_FLATS, ICE_SPIKES); // this is a biome mutation
- setBiomeTextureIfNone(Biomes.ICE_MOUNTAINS, SNOW_HILLS);
- setBiomeTextureIfNone(Biomes.EXTREME_HILLS, MOUNTAINS);
- setBiomeTextureIfNone(Biomes.EXTREME_HILLS_EDGE, MOUNTAINS);
- setBiomeTextureIfNone(Biomes.MUTATED_EXTREME_HILLS, MOUNTAINS_SNOW_CAPS);
- setBiomeTextureIfNone(Biomes.EXTREME_HILLS_WITH_TREES, MOUNTAINS_ALL);
- setBiomeTextureIfNone(Biomes.MUTATED_EXTREME_HILLS_WITH_TREES, MOUNTAINS_SNOW_CAPS);
- setBiomeTextureIfNone(Biomes.FOREST, FOREST);
- setBiomeTextureIfNone(Biomes.MUTATED_FOREST, FOREST_FLOWERS);
- setBiomeTextureIfNone(Biomes.FOREST_HILLS, FOREST_HILLS);
- setBiomeTextureIfNone(Biomes.ROOFED_FOREST, DENSE_FOREST);
- setBiomeTextureIfNone(Biomes.MUTATED_ROOFED_FOREST, DENSE_FOREST_HILLS); //TODO roofed forest M has steeper cliffs
- setBiomeTextureIfNone(Biomes.BIRCH_FOREST, BIRCH);
- setBiomeTextureIfNone(Biomes.MUTATED_BIRCH_FOREST, TALL_BIRCH);
- setBiomeTextureIfNone(Biomes.BIRCH_FOREST_HILLS, BIRCH_HILLS);
- setBiomeTextureIfNone(Biomes.MUTATED_BIRCH_FOREST_HILLS, TALL_BIRCH_HILLS);
- setBiomeTextureIfNone(Biomes.JUNGLE, JUNGLE);
- setBiomeTextureIfNone(Biomes.MUTATED_JUNGLE, JUNGLE_CLIFFS);
- setBiomeTextureIfNone(Biomes.JUNGLE_HILLS, JUNGLE_HILLS);
- setBiomeTextureIfNone(Biomes.JUNGLE_EDGE, JUNGLE_EDGE);
- setBiomeTextureIfNone(Biomes.MUTATED_JUNGLE_EDGE, JUNGLE_EDGE_HILLS);
- setBiomeTextureIfNone(Biomes.TAIGA, PINES);
- setBiomeTextureIfNone(Biomes.MUTATED_TAIGA, PINES_HILLS);
- setBiomeTextureIfNone(Biomes.TAIGA_HILLS, PINES_HILLS);
- setBiomeTextureIfNone(Biomes.COLD_TAIGA, SNOW_PINES);
- setBiomeTextureIfNone(Biomes.MUTATED_TAIGA_COLD, SNOW_PINES_HILLS);
- setBiomeTextureIfNone(Biomes.COLD_TAIGA_HILLS, SNOW_PINES_HILLS);
- setBiomeTextureIfNone(Biomes.REDWOOD_TAIGA, MEGA_TAIGA);
- setBiomeTextureIfNone(Biomes.MUTATED_REDWOOD_TAIGA, MEGA_SPRUCE);
- setBiomeTextureIfNone(Biomes.REDWOOD_TAIGA_HILLS, MEGA_TAIGA_HILLS);
- setBiomeTextureIfNone(Biomes.MUTATED_REDWOOD_TAIGA_HILLS, MEGA_SPRUCE_HILLS);
- setBiomeTextureIfNone(Biomes.SWAMPLAND, SWAMP);
- setBiomeTextureIfNone(Biomes.MUTATED_SWAMPLAND, SWAMP_HILLS);
- setBiomeTextureIfNone(Biomes.SKY, SHORE);
- setBiomeTextureIfNone(Biomes.HELL, CAVE_WALLS);
- setBiomeTextureIfNone(Biomes.VOID, END_VOID);
- setBiomeTextureIfNone(Biomes.MUSHROOM_ISLAND, MUSHROOM);
- setBiomeTextureIfNone(Biomes.MUSHROOM_ISLAND_SHORE, SHORE);
- setBiomeTextureIfNone(Biomes.SAVANNA, SAVANNA);
- setBiomeTextureIfNone(Biomes.MUTATED_SAVANNA, SAVANNA_CLIFFS);
- setBiomeTextureIfNone(Biomes.MESA, MESA);
- setBiomeTextureIfNone(Biomes.MUTATED_MESA, BRYCE);
- setBiomeTextureIfNone(Biomes.MESA_CLEAR_ROCK, PLATEAU_MESA);
- setBiomeTextureIfNone(Biomes.MESA_ROCK, PLATEAU_MESA_TREES);
- setBiomeTextureIfNone(Biomes.MUTATED_MESA_CLEAR_ROCK, PLATEAU_MESA_LOW);
- setBiomeTextureIfNone(Biomes.MUTATED_MESA_ROCK, PLATEAU_MESA_TREES_LOW);
- setBiomeTextureIfNone(Biomes.SAVANNA_PLATEAU, PLATEAU_SAVANNA);
- setBiomeTextureIfNone(Biomes.MUTATED_SAVANNA_ROCK, PLATEAU_SAVANNA_M);
+ /* setBiomeTextureIfNone(ays.TODO_1_12_2_a, WATER);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_z, WATER);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_i, WATER); //
+ setBiomeTextureIfNone(ays.TODO_1_12_2_l, ICE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_m, ICE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_r, SHORE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_B, SHORE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_A, ROCK_SHORE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_d, DESERT);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_R, DESERT);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_s, DESERT_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_c, PLAINS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_Q, SUNFLOWERS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_n, SNOW);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_W, ICE_SPIKES); // this is a biome mutation
+ setBiomeTextureIfNone(ays.TODO_1_12_2_o, SNOW_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_e, MOUNTAINS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_v, MOUNTAINS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_S, MOUNTAINS_SNOW_CAPS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_J, MOUNTAINS_ALL);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_af, MOUNTAINS_SNOW_CAPS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_f, FOREST);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_T, FOREST_FLOWERS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_t, FOREST_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_E, DENSE_FOREST);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_ab, DENSE_FOREST_HILLS); //TODO roofed forest M has steeper cliffs
+ setBiomeTextureIfNone(ays.TODO_1_12_2_C, BIRCH);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_Z, TALL_BIRCH);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_D, BIRCH_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_aa, TALL_BIRCH_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_w, JUNGLE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_X, JUNGLE_CLIFFS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_x, JUNGLE_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_y, JUNGLE_EDGE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_Y, JUNGLE_EDGE_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_g, PINES);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_U, PINES_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_u, PINES_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_F, SNOW_PINES);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_ac, SNOW_PINES_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_G, SNOW_PINES_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_H, MEGA_TAIGA);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_ad, MEGA_SPRUCE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_I, MEGA_TAIGA_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_ae, MEGA_SPRUCE_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_h, SWAMP);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_V, SWAMP_HILLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_k, SHORE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_j, CAVE_WALLS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_P, END_VOID);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_p, MUSHROOM);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_q, SHORE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_K, SAVANNA);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_ag, SAVANNA_CLIFFS);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_M, MESA);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_ai, BRYCE);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_O, PLATEAU_MESA);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_N, PLATEAU_MESA_TREES);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_ak, PLATEAU_MESA_LOW);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_aj, PLATEAU_MESA_TREES_LOW);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_L, PLATEAU_SAVANNA);
+ setBiomeTextureIfNone(ays.TODO_1_12_2_ah, PLATEAU_SAVANNA_M); */
// Now let's register every other biome, they'll come from other mods
- for(Biome biome : Biome.REGISTRY) {
+ for (Biome biome : Registry.BIOME) {
BiomeTextureMap.instance().checkRegistration(biome);
}
}
@@ -367,13 +371,13 @@ private void setCustomTileTextureIfNone(String tileName, TextureSet textureSet)
}
@Override
- public EntityPlayer getPlayerEntity(MessageContext ctx) {
- return (ctx.side.isClient() ? Minecraft.getMinecraft().player : super.getPlayerEntity(ctx));
+ public PlayerEntity getPlayerEntity(MessageContext ctx) {
+ return (ctx.side.isClient() ? MinecraftClient.getInstance().player : super.getPlayerEntity(ctx));
}
@Override
- public IThreadListener getThreadFromContext(MessageContext ctx) {
- return (ctx.side.isClient() ? Minecraft.getMinecraft() : super.getThreadFromContext(ctx));
+ public TODO_1_13_2_none_acv getThreadFromContext(MessageContext ctx) {
+ return (ctx.side.isClient() ? MinecraftClient.getInstance() : super.getThreadFromContext(ctx));
}
public File getConfigDir(){
@@ -406,8 +410,13 @@ public void onClientTick(ClientTickEvent event) {
}
@Override
- public void onResourceManagerReload(IResourceManager resourceManager) {
- for (MarkerType type : MarkerRegistry.getValues()) {
+ public Identifier getFabricId() {
+ return new Identifier("antiqueatlas:proxy");
+ }
+
+ @Override
+ public void apply(ResourceManager var1) {
+ for (MarkerType type : MarkerRegistry.iterable()) {
type.initMips();
}
}
diff --git a/src/main/java/hunternif/mc/atlas/CommonProxy.java b/src/main/java/hunternif/mc/atlas/CommonProxy.java
index 99030cf90..1c9d9cf67 100644
--- a/src/main/java/hunternif/mc/atlas/CommonProxy.java
+++ b/src/main/java/hunternif/mc/atlas/CommonProxy.java
@@ -4,10 +4,10 @@
import hunternif.mc.atlas.ext.ExtTileConfig;
import hunternif.mc.atlas.ext.ExtTileIdMap;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.entity.player.EntityPlayer;
+import net.fabricmc.loader.FabricLoader;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.IThreadListener;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.Loader;
@@ -17,7 +17,7 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.server.FMLServerHandler;
-
+import none.XX_1_13_2_none_acv_XX;
import java.io.File;
public class CommonProxy {
@@ -27,7 +27,7 @@ public class CommonProxy {
private ExtTileConfig extTileConfig;
public MinecraftServer getServer() {
- return FMLServerHandler.instance().getServer();
+ return FabricLoader.INSTANCE.getEnvironmentHandler().getServerInstance();
}
public void preInit(FMLPreInitializationEvent event) {
@@ -46,8 +46,6 @@ public void init(FMLInitializationEvent event) {
}
public void postInit(FMLPostInitializationEvent event) {
- AntiqueAtlasMod.instance.jeidPresent = Loader.isModLoaded("jeid");
- BiomeDetectorBase.setBiomeArrayMethod(AntiqueAtlasMod.instance.jeidPresent);
BiomeDetectorBase.scanBiomeTypes();
}
@@ -102,16 +100,16 @@ public File getConfigDir(){
/**
* Returns a side-appropriate EntityPlayer for use during message handling
*/
- public EntityPlayer getPlayerEntity(MessageContext ctx) {
- return ctx.getServerHandler().player;
+ public PlayerEntity getPlayerEntity(MessageContext ctx) {
+ return ctx.getServerHandler().b;
}
/**
* Returns the current thread based on side during message handling,
* used for ensuring that the message is being handled by the main thread
*/
- public IThreadListener getThreadFromContext(MessageContext ctx) {
- return ctx.getServerHandler().player.getServer();
+ public XX_1_13_2_none_acv_XX getThreadFromContext(MessageContext ctx) {
+ return ctx.getServerHandler().b.getServer();
}
/** When a world is saved, so is the custom tile id config. */
diff --git a/src/main/java/hunternif/mc/atlas/RegistrarAntiqueAtlas.java b/src/main/java/hunternif/mc/atlas/RegistrarAntiqueAtlas.java
index ab2604022..815e77307 100644
--- a/src/main/java/hunternif/mc/atlas/RegistrarAntiqueAtlas.java
+++ b/src/main/java/hunternif/mc/atlas/RegistrarAntiqueAtlas.java
@@ -4,12 +4,11 @@
import hunternif.mc.atlas.item.ItemEmptyAtlas;
import hunternif.mc.atlas.item.RecipeAtlasCloning;
import hunternif.mc.atlas.item.RecipeAtlasCombining;
-import net.minecraft.client.renderer.block.model.ModelResourceLocation;
-import net.minecraft.init.Items;
+import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.item.crafting.IRecipe;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.recipe.Recipe;
+
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
@@ -22,10 +21,9 @@
@GameRegistry.ObjectHolder(AntiqueAtlasMod.ID)
public class RegistrarAntiqueAtlas {
- @GameRegistry.ObjectHolder("empty_antique_atlas")
- public static final ItemEmptyAtlas EMPTY_ATLAS = new ItemEmptyAtlas();
- @GameRegistry.ObjectHolder("antique_atlas")
- public static final ItemAtlas ATLAS = new ItemAtlas();
+ // TODO FABRIC itemgroups
+ public static final ItemEmptyAtlas EMPTY_ATLAS = new ItemEmptyAtlas(new Item.Settings());
+ public static final ItemAtlas ATLAS = new ItemAtlas(new Item.Settings().stackSize(1));
@SubscribeEvent
public static void registerItems(RegistryEvent.Register- event) {
@@ -36,30 +34,12 @@ public static void registerItems(RegistryEvent.Register
- event) {
}
@SubscribeEvent
- public static void registerRecipes(RegistryEvent.Register event) {
- if (SettingsConfig.gameplay.itemNeeded) {
- event.getRegistry().register(new ShapelessOreRecipe(new ResourceLocation(AntiqueAtlasMod.ID, "atlas"), new ItemStack(EMPTY_ATLAS), Items.BOOK, Items.COMPASS).setRegistryName("atlas_blank"));
+ public static void registerRecipes(RegistryEvent.Register event) {
+ /* if (SettingsConfig.gameplay.itemNeeded) {
+ event.getRegistry().register(new ShapelessOreRecipe(new Identifier(AntiqueAtlasMod.ID, "atlas"), new ItemStack(EMPTY_ATLAS), aud.XX_1_13_2_aS_XX, aud.XX_1_13_2_aX_XX).setRegistryName("atlas_blank"));
event.getRegistry().register(new RecipeAtlasCloning().setRegistryName("atlas_clone"));
event.getRegistry().register(new RecipeAtlasCombining().setRegistryName("atlas_combine"));
- }
- }
-
- @SubscribeEvent
- public static void registerModels(ModelRegistryEvent event) {
- if (SettingsConfig.gameplay.itemNeeded) {
- ModelLoader.setCustomModelResourceLocation(EMPTY_ATLAS, 0, new ModelResourceLocation(EMPTY_ATLAS.getRegistryName(), "inventory"));
- ModelLoader.setCustomMeshDefinition(ATLAS, stack -> new ModelResourceLocation(ATLAS.getRegistryName(), "inventory"));
- }
- }
-
- // Probably not needed since Forge for 1.12 does not support transfers from earlier than 1.11.2, but just in case
- @SubscribeEvent
- public static void handleMissingMapping(RegistryEvent.MissingMappings
- event) {
- for (RegistryEvent.MissingMappings.Mapping
- mapping : event.getMappings()) {
- if (mapping.key.getPath().equalsIgnoreCase("antiqueatlas"))
- mapping.remap(ATLAS);
- else if (mapping.key.getPath().equalsIgnoreCase("emptyantiqueatlas"))
- mapping.remap(EMPTY_ATLAS);
- }
+ } */
+ // TODO FABRIC
}
}
diff --git a/src/main/java/hunternif/mc/atlas/SettingsConfig.java b/src/main/java/hunternif/mc/atlas/SettingsConfig.java
index bc4a626cf..4918fd3d6 100644
--- a/src/main/java/hunternif/mc/atlas/SettingsConfig.java
+++ b/src/main/java/hunternif/mc/atlas/SettingsConfig.java
@@ -1,80 +1,76 @@
package hunternif.mc.atlas;
-import net.minecraftforge.common.config.Config;
-import net.minecraftforge.common.config.ConfigManager;
-import net.minecraftforge.fml.client.event.ConfigChangedEvent;
-import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+// TODO FABRIC
-@Config(modid = AntiqueAtlasMod.ID, name = "antiqueatlas/antiqueatlas", category = "")
-@Mod.EventBusSubscriber(modid = AntiqueAtlasMod.ID)
+//@Config(modid = AntiqueAtlasMod.ID, name = "antiqueatlas/antiqueatlas", category = "")
+//@Mod.EventBusSubscriber(modid = AntiqueAtlasMod.ID)
public class SettingsConfig {
- @Config.Comment({"These settings will affect how the mod behaves in certain situations and the players' overall gameplay, but generally won't affect performance."})
+ //@Config.Comment({"These settings will affect how the mod behaves in certain situations and the players' overall gameplay, but generally won't affect performance."})
public static Gameplay gameplay = new Gameplay();
- @Config.Comment({"These setting will affect the look and feel of the Atlas' interface."})
+ //@Config.Comment({"These setting will affect the look and feel of the Atlas' interface."})
public static Interface userInterface = new Interface(); // Added a "_" because "interface" is reserved :(
- @Config.Comment({"These settings affect the algorithms for scanning the world, drawing the map etc. Changing them may improve the game's overall stability and performance at the cost of Atlas' functionality."})
+ //@Config.Comment({"These settings affect the algorithms for scanning the world, drawing the map etc. Changing them may improve the game's overall stability and performance at the cost of Atlas' functionality."})
public static Performance performance = new Performance();
//============= Gameplay settings =============
public static class Gameplay {
- @Config.Comment({"Whether to remember last open browsing position and zoom level for each dimension in every atlas.", "If disabled, all dimensions and all atlases will be \"synchronized\" at the same coordinates and zoom level, and map will \"follow\" player by default."})
+ //@Config.Comment({"Whether to remember last open browsing position and zoom level for each dimension in every atlas.", "If disabled, all dimensions and all atlases will be \"synchronized\" at the same coordinates and zoom level, and map will \"follow\" player by default."})
public boolean doSaveBrowsingPos = true;
- @Config.Comment({"Whether to add local marker for the spot where the player died."})
+ //@Config.Comment({"Whether to add local marker for the spot where the player died."})
public boolean autoDeathMarker = true;
- @Config.Comment({"Whether to add global markers for NPC villages."})
+ //@Config.Comment({"Whether to add global markers for NPC villages."})
public boolean autoVillageMarkers = true;
- @Config.Comment({"Whether to add global markers for Nether Portals."})
+ //@Config.Comment({"Whether to add global markers for Nether Portals."})
public boolean autoNetherPortalMarkers = true;
- @Config.Comment({"Player will need to craft atlas item to use atlas."})
- @Config.RequiresMcRestart
+ //@Config.Comment({"Player will need to craft atlas item to use atlas."})
+ //@Config.RequiresMcRestart
public boolean itemNeeded = true;
}
//============ Interface settings =============
public static class Interface {
public boolean doScaleMarkers = false;
- @Config.Comment({"Default zoom level. The number corresponds to the size of a block on the map relative to the size of a GUI pixel. Preferrably a power of 2."})
- @Config.RangeDouble(min = 0.001953125f, max = 16.0f)
+ //@Config.Comment({"Default zoom level. The number corresponds to the size of a block on the map relative to the size of a GUI pixel. Preferrably a power of 2."})
+ //@Config.RangeDouble(min = 0.001953125f, max = 16.0f)
public double defaultScale = 0.5f;
- @Config.Comment({"Minimum zoom level. The number corresponds to the size of a block on the map relative to the size of a GUI pixel. Preferrably a power of 2. Smaller values may decrease performance!"})
- @Config.RangeDouble(min = 0.001953125f, max = 16.0f)
+ //@Config.Comment({"Minimum zoom level. The number corresponds to the size of a block on the map relative to the size of a GUI pixel. Preferrably a power of 2. Smaller values may decrease performance!"})
+ //@Config.RangeDouble(min = 0.001953125f, max = 16.0f)
public double minScale = 1.0 / 32.0;
- @Config.Comment({"Maximum zoom level. The number corresponds to the size of a block on the map relative to the size of a GUI pixel. Preferrably a power of 2."})
- @Config.RangeDouble(min = 0.001953125f, max = 16.0f)
+ //@Config.Comment({"Maximum zoom level. The number corresponds to the size of a block on the map relative to the size of a GUI pixel. Preferrably a power of 2."})
+ //@Config.RangeDouble(min = 0.001953125f, max = 16.0f)
public double maxScale = 4;
- @Config.Comment({"If false (by default), then mousewheel up is zoom in, mousewheel down is zoom out.", "If true, then the direction is reversed."})
+ //@Config.Comment({"If false (by default), then mousewheel up is zoom in, mousewheel down is zoom out.", "If true, then the direction is reversed."})
public boolean doReverseWheelZoom = false;
}
//=========== Performance settings ============
public static class Performance {
- @Config.Comment({"The radius of the area around the player which is scanned by the Atlas at regular intervals.", "Note that this will not force faraway chunks to load, unless force_chunk_loading is enabled.", "Lower value gives better performance."})
+ //@Config.Comment({"The radius of the area around the player which is scanned by the Atlas at regular intervals.", "Note that this will not force faraway chunks to load, unless force_chunk_loading is enabled.", "Lower value gives better performance."})
public int scanRadius = 11;
- @Config.Comment({"Force loading of chunks within scan radius even if it exceeds regular chunk loading distance.", "Enabling this may SEVERELY decrease performance!"})
+ //@Config.Comment({"Force loading of chunks within scan radius even if it exceeds regular chunk loading distance.", "Enabling this may SEVERELY decrease performance!"})
public boolean forceChunkLoading = false;
- @Config.Comment({"Time in seconds between two scans of the area.", "Higher value gives better performance."})
+ //@Config.Comment({"Time in seconds between two scans of the area.", "Higher value gives better performance."})
public float newScanInterval = 1f;
- @Config.Comment({"Whether to rescan chunks in the area that have been previously mapped. This is useful in case of changes in coastline (including small ponds of water and lava), or if land disappears completely (for sky worlds).", "Disable for better performance."})
+ //@Config.Comment({"Whether to rescan chunks in the area that have been previously mapped. This is useful in case of changes in coastline (including small ponds of water and lava), or if land disappears completely (for sky worlds).", "Disable for better performance."})
public boolean doRescan = true;
- @Config.Comment({"The number of area scans between full rescans.", "Higher value gives better performance."})
- @Config.RangeInt(min = 1, max = 1000)
+ //@Config.Comment({"The number of area scans between full rescans.", "Higher value gives better performance."})
+ //@Config.RangeInt(min = 1, max = 1000)
public int rescanRate = 4;
- @Config.Comment({"The maximum number of markers a particular atlas can hold."})
- @Config.RangeInt(min = 0, max = 2147483647)
+ //@Config.Comment({"The maximum number of markers a particular atlas can hold."})
+ //@Config.RangeInt(min = 0, max = 2147483647)
public int markerLimit = 1024;
- @Config.Comment({"Whether to perform additional scanning to locate small ponds of water or lava.", "Disable for better performance."})
+ //@Config.Comment({"Whether to perform additional scanning to locate small ponds of water or lava.", "Disable for better performance."})
public boolean doScanPonds = true;
- @Config.Comment({"Whether to perform additional scanning to locate ravines.", "Disable for better performance."})
+ //@Config.Comment({"Whether to perform additional scanning to locate ravines.", "Disable for better performance."})
public boolean doScanRavines = true;
- @Config.Comment({"If true, map render time will be output."})
+ //@Config.Comment({"If true, map render time will be output."})
public boolean debugRender = false;
}
- @SubscribeEvent
+ /* @SubscribeEvent
public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equals(AntiqueAtlasMod.ID))
ConfigManager.sync(AntiqueAtlasMod.ID, Config.Type.INSTANCE);
- }
+ } */
}
\ No newline at end of file
diff --git a/src/main/java/hunternif/mc/atlas/api/AtlasAPI.java b/src/main/java/hunternif/mc/atlas/api/AtlasAPI.java
index 65e7a2634..158b231f3 100644
--- a/src/main/java/hunternif/mc/atlas/api/AtlasAPI.java
+++ b/src/main/java/hunternif/mc/atlas/api/AtlasAPI.java
@@ -3,11 +3,9 @@
import hunternif.mc.atlas.SettingsConfig;
import hunternif.mc.atlas.api.impl.MarkerApiImpl;
import hunternif.mc.atlas.api.impl.TileApiImpl;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraftforge.fml.common.registry.GameRegistry;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -20,8 +18,7 @@ public class AtlasAPI {
private static final int VERSION = 3;
public static final TileAPI tiles = new TileApiImpl();
public static final MarkerAPI markers = new MarkerApiImpl();
- @GameRegistry.ObjectHolder("antiqueatlas:antique_atlas")
- public static final Item ATLAS_ITEM = new Item();
+ public static Item ATLAS_ITEM; // TODO FABRIC
/** Version of the API, meaning only this particular class. You might
* want to check static field VERSION in the specific API interfaces. */
@@ -41,15 +38,15 @@ public static MarkerAPI getMarkerAPI() {
/** Convenience method that returns a list of atlas IDs for all atlas items
* the player is currently carrying. **/
- public static List getPlayerAtlases(EntityPlayer player) {
+ public static List getPlayerAtlases(PlayerEntity player) {
if (!SettingsConfig.gameplay.itemNeeded) {
- return Collections.singletonList(player.getUniqueID().hashCode());
+ return Collections.singletonList(player.getUuid().hashCode());
}
List list = new ArrayList<>();
- for (ItemStack stack : player.inventory.mainInventory) {
+ for (ItemStack stack : player.inventory.main) {
if (!stack.isEmpty() && stack.getItem() == ATLAS_ITEM) {
- list.add(stack.getItemDamage());
+ list.add(stack.getDamage());
}
}
diff --git a/src/main/java/hunternif/mc/atlas/api/MarkerAPI.java b/src/main/java/hunternif/mc/atlas/api/MarkerAPI.java
index 4de8fb403..65367ade8 100644
--- a/src/main/java/hunternif/mc/atlas/api/MarkerAPI.java
+++ b/src/main/java/hunternif/mc/atlas/api/MarkerAPI.java
@@ -1,13 +1,14 @@
package hunternif.mc.atlas.api;
import hunternif.mc.atlas.marker.Marker;
-import net.minecraft.world.World;
-
import hunternif.mc.atlas.registry.MarkerType;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import net.minecraft.util.Identifier;
+import net.minecraft.world.World;
+
/**
* API for putting custom markers to the atlases. Set the textures on the
* client side, put markers into atlases on the server side.
@@ -18,7 +19,7 @@ public interface MarkerAPI {
/**
* Registers the marker type, this should be called in PreInit, as config file overrides are loaded in Init.
*/
- void registerMarker(MarkerType markerType);
+ void registerMarker(Identifier identifier, MarkerType markerType);
/**
* Put a marker in the specified Atlas instance at specified block
diff --git a/src/main/java/hunternif/mc/atlas/api/TileAPI.java b/src/main/java/hunternif/mc/atlas/api/TileAPI.java
index 0421f4d6f..bc3152fe5 100644
--- a/src/main/java/hunternif/mc/atlas/api/TileAPI.java
+++ b/src/main/java/hunternif/mc/atlas/api/TileAPI.java
@@ -1,13 +1,13 @@
package hunternif.mc.atlas.api;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.world.World;
-import net.minecraft.world.biome.Biome;
+import net.minecraft.util.Identifier;
+import net.minecraft.world.World;
import hunternif.mc.atlas.client.TextureSet;
+import net.minecraft.world.biome.Biome;
/**
* API for biome tiles and custom tiles (i.e. dungeons, towns etc.)
@@ -25,38 +25,24 @@ public interface TileAPI {
* @param textures
* @return the registered texture set
*/
- @SideOnly(Side.CLIENT)
- TextureSet registerTextureSet(String name, ResourceLocation ... textures);
+ @Environment(EnvType.CLIENT)
+ TextureSet registerTextureSet(String name, Identifier ... textures);
// Biome textures ==========================================================
-
- /**
- * Assign one or more texture to biome ID, creating a new texture set.
- * See {@link #registerTextureSet}
- */
- @SideOnly(Side.CLIENT)
- void setBiomeTexture(int biomeID, String textureSetName, ResourceLocation ... textures);
-
+
/**
* Assign one or more texture to biome ID, creating a new texture set.
* See {@link #registerTextureSet}
*/
- @SideOnly(Side.CLIENT)
- void setBiomeTexture(Biome biome, String textureSetName, ResourceLocation ... textures);
-
- /**
- * Assign one or more texture to biome ID, using an existing texture set.
- * See {@link #registerTextureSet}
- */
- @SideOnly(Side.CLIENT)
- void setBiomeTexture(int biomeID, TextureSet textureSet);
-
+ @Environment(EnvType.CLIENT)
+ void setBiomeTexture(Biome biome, String textureSetName, Identifier ... textures);
+
/**
* Assign one or more texture to biome ID, using an existing texture set.
* See {@link #registerTextureSet}
*/
- @SideOnly(Side.CLIENT)
+ @Environment(EnvType.CLIENT)
void setBiomeTexture(Biome biome, TextureSet textureSet);
@@ -67,42 +53,16 @@ public interface TileAPI {
* This creates a new texture set with the same name as the tile.
* See {@link #registerTextureSet}
*/
- @SideOnly(Side.CLIENT)
- void setCustomTileTexture(String uniqueTileName, ResourceLocation ... textures);
+ @Environment(EnvType.CLIENT)
+ void setCustomTileTexture(String uniqueTileName, Identifier ... textures);
/** Assign a texture set to a unique tile name. */
- @SideOnly(Side.CLIENT)
+ @Environment(EnvType.CLIENT)
void setCustomTileTexture(String uniqueTileName, TextureSet textureSet);
// Biome tiles =============================================================
-
- /**
- * Edit the biome ID at the specified chunk in the specified atlas.
- * You only need to call this method once for every chunk, after that
- * the tile will be persisted with the world and loaded when the server
- * starts up.
- *
- * Note that global custom tiles, such as village territory, will override
- * biome IDs at shared chunks.
- *
- *
- * If calling this method on the client, the player must carry the atlas
- * in his inventory, to prevent griefing!
- *
- *
- * For setting custom tiles that don't correspond to biomes, see
- * {@link #putCustomTile}
- *
- * @param world dimension the chunk is located in.
- * @param atlasID the ID of the atlas you want to put marker in. Equal
- * to ItemStack damage for ItemAtlas.
- * @param biomeID
- * @param chunkX x chunk coordinate. (block coordinate >> 4)
- * @param chunkZ z chunk coordinate. (block coordinate >> 4)
- */
- void putBiomeTile(World world, int atlasID, int biomeID, int chunkX, int chunkZ);
-
+
/**
* Edit the biome at the specified chunk in the specified atlas.
* You only need to call this method once for every chunk, after that
diff --git a/src/main/java/hunternif/mc/atlas/api/impl/MarkerApiImpl.java b/src/main/java/hunternif/mc/atlas/api/impl/MarkerApiImpl.java
index 208e3dc66..e80325040 100644
--- a/src/main/java/hunternif/mc/atlas/api/impl/MarkerApiImpl.java
+++ b/src/main/java/hunternif/mc/atlas/api/impl/MarkerApiImpl.java
@@ -1,7 +1,5 @@
package hunternif.mc.atlas.api.impl;
-import net.minecraft.world.World;
-
import hunternif.mc.atlas.AntiqueAtlasMod;
import hunternif.mc.atlas.api.MarkerAPI;
import hunternif.mc.atlas.marker.Marker;
@@ -17,6 +15,9 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import net.minecraft.util.Identifier;
+import net.minecraft.world.World;
+
public class MarkerApiImpl implements MarkerAPI {
/** Used in place of atlasID to signify that the marker is global. */
private static final int GLOBAL = -1;
@@ -33,22 +34,22 @@ public Marker putGlobalMarker(@Nonnull World world, boolean visibleAhead, String
}
private Marker doPutMarker(World world, boolean visibleAhead, int atlasID, String markerType, String label, int x, int z) {
Marker marker = null;
- if (world.isRemote) {
+ if (world.isClient) {
if (atlasID == GLOBAL) {
Log.warn("Client tried to add a global marker!");
} else {
PacketDispatcher.sendToServer(new AddMarkerPacket(atlasID,
- world.provider.getDimension(), markerType, label, x, z, visibleAhead));
+ world.dimension.getType(), markerType, label, x, z, visibleAhead));
}
} else {
if (atlasID == GLOBAL) {
MarkersData data = AntiqueAtlasMod.globalMarkersData.getData();
- marker = data.createAndSaveMarker(markerType, label, world.provider.getDimension(), x, z, visibleAhead);
- PacketDispatcher.sendToAll(new MarkersPacket(world.provider.getDimension(), marker));
+ marker = data.createAndSaveMarker(markerType, label, world.dimension.getType(), x, z, visibleAhead);
+ PacketDispatcher.sendToAll(new MarkersPacket(world.dimension.getType(), marker));
} else {
MarkersData data = AntiqueAtlasMod.markersData.getMarkersData(atlasID, world);
- marker = data.createAndSaveMarker(markerType, label, world.provider.getDimension(), x, z, visibleAhead);
- PacketDispatcher.sendToAll(new MarkersPacket(atlasID, world.provider.getDimension(), marker));
+ marker = data.createAndSaveMarker(markerType, label, world.dimension.getType(), x, z, visibleAhead);
+ PacketDispatcher.sendToAll(new MarkersPacket(atlasID, world.dimension.getType(), marker));
}
}
return marker;
@@ -66,7 +67,7 @@ private void doDeleteMarker(World world, int atlasID, int markerID) {
DeleteMarkerPacket packet = atlasID == GLOBAL ?
new DeleteMarkerPacket(markerID) :
new DeleteMarkerPacket(atlasID, markerID);
- if (world.isRemote) {
+ if (world.isClient) {
if (atlasID == GLOBAL) {
Log.warn("Client tried to delete a global marker!");
} else {
@@ -82,8 +83,8 @@ private void doDeleteMarker(World world, int atlasID, int markerID) {
}
@Override
- public void registerMarker(MarkerType markerType) {
- MarkerRegistry.register(markerType);
+ public void registerMarker(Identifier identifier, MarkerType markerType) {
+ MarkerRegistry.register(identifier, markerType);
}
}
diff --git a/src/main/java/hunternif/mc/atlas/api/impl/TileApiImpl.java b/src/main/java/hunternif/mc/atlas/api/impl/TileApiImpl.java
index 5b88d496c..a2bce128c 100644
--- a/src/main/java/hunternif/mc/atlas/api/impl/TileApiImpl.java
+++ b/src/main/java/hunternif/mc/atlas/api/impl/TileApiImpl.java
@@ -4,22 +4,26 @@
import java.util.Map;
import java.util.Map.Entry;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import hunternif.mc.atlas.core.TileKind;
+import hunternif.mc.atlas.core.TileKindFactory;
+import net.minecraft.client.network.packet.LoginSuccessS2CPacket;
+
+import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.util.Identifier;
+import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
-
+import net.minecraft.world.dimension.DimensionType;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import hunternif.mc.atlas.AntiqueAtlasMod;
import hunternif.mc.atlas.api.TileAPI;
import hunternif.mc.atlas.client.BiomeTextureMap;
import hunternif.mc.atlas.client.TextureSet;
import hunternif.mc.atlas.client.TextureSetMap;
import hunternif.mc.atlas.core.AtlasData;
-import hunternif.mc.atlas.core.Tile;
import hunternif.mc.atlas.ext.ExtBiomeData;
import hunternif.mc.atlas.ext.ExtTileIdMap;
import hunternif.mc.atlas.ext.ExtTileTextureMap;
@@ -57,7 +61,7 @@ public TileApiImpl() {
@Override
- public TextureSet registerTextureSet(String name, ResourceLocation... textures) {
+ public TextureSet registerTextureSet(String name, Identifier... textures) {
TextureSet textureSet = new TextureSet(name, textures);
TextureSetMap.instance().register(textureSet);
return textureSet;
@@ -65,34 +69,24 @@ public TextureSet registerTextureSet(String name, ResourceLocation... textures)
// Biome textures ==========================================================
-
+
@Override
- public void setBiomeTexture(int biomeID, String textureSetName, ResourceLocation... textures) {
+ public void setBiomeTexture(Biome biome, String textureSetName, Identifier... textures) {
TextureSet set = new TextureSet(textureSetName, textures);
TextureSetMap.instance().register(set);
- BiomeTextureMap.instance().setTexture(Biome.getBiomeForId(biomeID), set);
- }
-
- @Override
- public void setBiomeTexture(Biome biome, String textureSetName, ResourceLocation... textures) {
- setBiomeTexture(Biome.getIdForBiome(biome), textureSetName, textures);
+ BiomeTextureMap.instance().setTexture(biome, set);
}
-
- @Override
- public void setBiomeTexture(int biomeID, TextureSet textureSet) {
- BiomeTextureMap.instance().setTexture(Biome.getBiomeForId(biomeID), textureSet);
- }
-
+
@Override
public void setBiomeTexture(Biome biome, TextureSet textureSet) {
- setBiomeTexture(Biome.getIdForBiome(biome), textureSet);
+ BiomeTextureMap.instance().setTexture(biome, textureSet);
}
// Custom tile textures ====================================================
@Override
- public void setCustomTileTexture(String uniqueTileName, ResourceLocation ... textures) {
+ public void setCustomTileTexture(String uniqueTileName, Identifier ... textures) {
TextureSet set = new TextureSet(uniqueTileName, textures);
TextureSetMap.instance().register(set);
setCustomTileTexture(uniqueTileName, set);
@@ -105,28 +99,23 @@ public void setCustomTileTexture(String uniqueTileName, TextureSet textureSet) {
// Biome tiles =============================================================
-
+
@Override
- public void putBiomeTile(World world, int atlasID, int biomeID, int chunkX, int chunkZ) {
- int dimension = world.provider.getDimension();
- PutBiomeTilePacket packet = new PutBiomeTilePacket(atlasID, dimension, chunkX, chunkZ, biomeID);
- if (world.isRemote) {
+ public void putBiomeTile(World world, int atlasID, Biome biome, int chunkX, int chunkZ) {
+ DimensionType dimension = world.dimension.getType();
+ PutBiomeTilePacket packet = new PutBiomeTilePacket(atlasID, dimension, chunkX, chunkZ, biome);
+ if (world.isClient) {
PacketDispatcher.sendToServer(packet);
} else {
AtlasData data = AntiqueAtlasMod.atlasData.getAtlasData(atlasID, world);
- Tile tile = new Tile(biomeID);
+ TileKind tile = TileKindFactory.get(biome);
data.setTile(dimension, chunkX, chunkZ, tile);
- for (EntityPlayer syncedPlayer : data.getSyncedPlayers()) {
- PacketDispatcher.sendTo(new PutBiomeTilePacket(atlasID, dimension, chunkX, chunkZ, biomeID), (EntityPlayerMP)syncedPlayer);
+ for (PlayerEntity syncedPlayer : data.getSyncedPlayers()) {
+ PacketDispatcher.sendTo(new PutBiomeTilePacket(atlasID, dimension, chunkX, chunkZ, biome), (ServerPlayerEntity) syncedPlayer);
}
}
}
- @Override
- public void putBiomeTile(World world, int atlasID, Biome biome, int chunkX, int chunkZ) {
- putBiomeTile(world, atlasID, Biome.getIdForBiome(biome), chunkX, chunkZ);
- }
-
// Custom tiles ============================================================
@@ -136,7 +125,7 @@ public void putCustomTile(World world, int atlasID, String tileName, int chunkX,
Log.error("Attempted to put custom tile with null name");
return;
}
- if (world.isRemote) {
+ if (world.isClient) {
int biomeID = ExtTileIdMap.instance().getPseudoBiomeID(tileName);
if (biomeID != ExtTileIdMap.NOT_FOUND) {
putBiomeTile(world, atlasID, biomeID, chunkX, chunkZ);
@@ -162,14 +151,14 @@ public void putCustomGlobalTile(World world, String tileName, int chunkX, int ch
Log.error("Attempted to put custom global tile with null name");
return;
}
- if (world.isRemote) {
+ if (world.isClient) {
Log.warn("Client attempted to put global tile");
return;
}
boolean isIdRegistered = ExtTileIdMap.instance().getPseudoBiomeID(tileName) != ExtTileIdMap.NOT_FOUND;
int biomeID = ExtTileIdMap.instance().getOrCreatePseudoBiomeID(tileName);
ExtBiomeData data = AntiqueAtlasMod.extBiomeData.getData();
- data.setBiomeIdAt(world.provider.getDimension(), chunkX, chunkZ, biomeID);
+ data.setBiomeIdAt(world.dimension.getType(), chunkX, chunkZ, biomeID);
// Send name-ID packet:
if (!isIdRegistered) {
TileNameIDPacket packet = new TileNameIDPacket();
@@ -177,7 +166,7 @@ public void putCustomGlobalTile(World world, String tileName, int chunkX, int ch
PacketDispatcher.sendToAll(packet);
}
// Send tile packet:
- TilesPacket packet = new TilesPacket(world.provider.getDimension());
+ TilesPacket packet = new TilesPacket(world.dimension.getType());
packet.addTile(chunkX, chunkZ, biomeID);
PacketDispatcher.sendToAll(packet);
}
@@ -196,12 +185,12 @@ public void onTileIdRegistered(TileIdRegisteredEvent event) {
@Override
public void deleteCustomGlobalTile(World world, int chunkX, int chunkZ) {
- if (world.isRemote) {
+ if (world.isClient) {
Log.warn("Client attempted to delete global tile");
return;
}
ExtBiomeData data = AntiqueAtlasMod.extBiomeData.getData();
- int dimension = world.provider.getDimension();
+ DimensionType dimension = world.dimension.getType();
if (data.getBiomeIdAt(dimension, chunkX, chunkZ) != -1) {
data.removeBiomeAt(dimension, chunkX, chunkZ);
PacketDispatcher.sendToAll(new DeleteCustomGlobalTilePacket(dimension, chunkX, chunkZ));
diff --git a/src/main/java/hunternif/mc/atlas/api/package-info.java b/src/main/java/hunternif/mc/atlas/api/package-info.java
index 03a8f0f8e..a5246dc8a 100644
--- a/src/main/java/hunternif/mc/atlas/api/package-info.java
+++ b/src/main/java/hunternif/mc/atlas/api/package-info.java
@@ -1,3 +1 @@
-@API(apiVersion="5.1", owner="antiqueatlas", provides="antiqueatlasapi")
package hunternif.mc.atlas.api;
-import net.minecraftforge.fml.common.API;
\ No newline at end of file
diff --git a/src/main/java/hunternif/mc/atlas/client/BiomeTextureConfig.java b/src/main/java/hunternif/mc/atlas/client/BiomeTextureConfig.java
index d56e75747..78760d861 100644
--- a/src/main/java/hunternif/mc/atlas/client/BiomeTextureConfig.java
+++ b/src/main/java/hunternif/mc/atlas/client/BiomeTextureConfig.java
@@ -6,11 +6,13 @@
import hunternif.mc.atlas.AntiqueAtlasMod;
import hunternif.mc.atlas.util.AbstractJSONConfig;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.util.ResourceLocation;
+
+
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.util.Identifier;
+import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
-import net.minecraftforge.fml.common.registry.ForgeRegistries;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
import java.io.File;
import java.util.ArrayList;
@@ -24,7 +26,7 @@
* Must be loaded after {@link TextureSetConfig}!
* @author Hunternif
*/
-@SideOnly(Side.CLIENT)
+@Environment(EnvType.CLIENT)
public class BiomeTextureConfig extends AbstractJSONConfig {
private static final int VERSION = 2;
private final TextureSetMap textureSetMap;
@@ -52,7 +54,7 @@ protected void loadData(JsonObject json, BiomeTextureMap data, int version) {
return;
}
for (Entry entry : json.entrySet()) {
- Biome biome = ForgeRegistries.BIOMES.getValue(new ResourceLocation(entry.getKey()));
+ Biome biome = Registry.BIOME.get(new Identifier(entry.getKey()));
if (biome == null) {
Log.warn("Unknown biome in texture map: %s", entry.getKey());
continue;
@@ -60,22 +62,22 @@ protected void loadData(JsonObject json, BiomeTextureMap data, int version) {
if (entry.getValue().isJsonArray()) {
// List of textures: (this should be gone as of VERSION > 1)
JsonArray array = entry.getValue().getAsJsonArray();
- ResourceLocation[] textures = new ResourceLocation[array.size()];
+ Identifier[] textures = new Identifier[array.size()];
for (int i = 0; i < array.size(); i++) {
String path = array.get(i).getAsString();
- textures[i] = new ResourceLocation(path);
+ textures[i] = new Identifier(path);
}
data.setTexture(biome, new TextureSet(null, textures));
Log.info("Registered %d custom texture(s) for biome %s",
- textures.length, biome.getRegistryName().toString());
+ textures.length, entry.getKey());
} else {
// Texture set:
String name = entry.getValue().getAsString();
if (textureSetMap.isRegistered(name)) {
data.setTexture(biome, textureSetMap.getByName(name));
- Log.info("Registered texture set %s for biome %s", name, biome.getRegistryName().toString());
+ Log.info("Registered texture set %s for biome %s", name, entry.getKey());
} else {
- Log.warn("Unknown texture set %s for biome %s", name, biome.getRegistryName().toString());
+ Log.warn("Unknown texture set %s for biome %s", name, entry.getKey());
}
}
}
@@ -84,14 +86,11 @@ protected void loadData(JsonObject json, BiomeTextureMap data, int version) {
@Override
protected void saveData(JsonObject json, BiomeTextureMap data) {
// Sort resource locations by name
- List keys = new ArrayList(data.biomeTextureMap.keySet());
- Collections.sort(keys, Comparator.comparing(Biome::getRegistryName));
+ List keys = new ArrayList<>(data.biomeTextureMap.keySet());
+ Collections.sort(keys, Comparator.comparing((b) -> Registry.BIOME.getId(b).toString()));
for(Biome key : keys) {
- int biomeID = Biome.getIdForBiome(key);
- if (biomeID >= 0 && (AntiqueAtlasMod.instance.jeidPresent || biomeID < 256)) {
- json.addProperty(key.getRegistryName().toString(), data.biomeTextureMap.get(key).name);
- }
+ json.addProperty(Registry.BIOME.getId(key).toString(), data.biomeTextureMap.get(key).name);
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/client/BiomeTextureMap.java b/src/main/java/hunternif/mc/atlas/client/BiomeTextureMap.java
index 63d2d3d4d..c4fdf1d7f 100644
--- a/src/main/java/hunternif/mc/atlas/client/BiomeTextureMap.java
+++ b/src/main/java/hunternif/mc/atlas/client/BiomeTextureMap.java
@@ -1,15 +1,16 @@
package hunternif.mc.atlas.client;
-import hunternif.mc.atlas.core.Tile;
+import hunternif.mc.atlas.core.TileKind;
import hunternif.mc.atlas.util.Log;
import hunternif.mc.atlas.util.SaveData;
-import net.minecraft.util.ResourceLocation;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+
+
+import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
+import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
-import net.minecraftforge.common.BiomeDictionary;
-import net.minecraftforge.common.BiomeDictionary.Type;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.*;
import java.util.Map.Entry;
@@ -22,7 +23,7 @@
* putting tile into Atlas.
* @author Hunternif
*/
-@SideOnly(Side.CLIENT)
+@Environment(EnvType.CLIENT)
public class BiomeTextureMap extends SaveData {
private static final BiomeTextureMap INSTANCE = new BiomeTextureMap();
public static BiomeTextureMap instance() {
@@ -40,7 +41,7 @@ public static BiomeTextureMap instance() {
public void setTexture(Biome biome, TextureSet textureSet) {
if (textureSet == null) {
if (biomeTextureMap.remove(biome) != null) {
- Log.warn("Removing old texture for biome %s", biome.getRegistryName());
+ Log.warn("Removing old texture for biome %s", Registry.BIOME.getId(biome));
}
return;
}
@@ -50,7 +51,7 @@ public void setTexture(Biome biome, TextureSet textureSet) {
if (previous == null) {
markDirty();
} else if (!previous.equals(textureSet)) {
- Log.warn("Overwriting texture set for biome %s", biome.getRegistryName());
+ Log.warn("Overwriting texture set for biome %s", Registry.BIOME.getId(biome));
markDirty();
}
}
@@ -81,7 +82,57 @@ private void autoRegister(Biome biome) {
Log.warn("Biome is null");
return;
}
- Set types = BiomeDictionary.getTypes(biome);
+
+ switch (biome.getCategory()) {
+ case SWAMP:
+ setTexture(biome, biome.getScale() >= 0.25f ? SWAMP_HILLS : SWAMP);
+ break;
+ case OCEAN:
+ case RIVER:
+ setTexture(biome, biome.getPrecipitation() == Biome.Precipitation.SNOW ? ICE : WATER);
+ break;
+ case BEACH:
+ setTexture(biome, SHORE); // TODO ROCK_SHORE
+ break;
+ case JUNGLE:
+ setTexture(biome, biome.getScale() >= 0.25f ? JUNGLE_HILLS : JUNGLE); // TODO JUNGLE_CLIFFS
+ break;
+ case SAVANNA:
+ setTexture(biome, biome.getScale() >= 0.25f ? SAVANNA_CLIFFS : SAVANNA);
+ break;
+ case MESA:
+ setTexture(biome, PLATEAU_MESA); // TODO PLATEAU_MESA_TREES
+ break;
+ case FOREST:
+ setTexture(biome, biome.getPrecipitation() == Biome.Precipitation.SNOW ?
+ (biome.getScale() >= 0.25f ? SNOW_PINES_HILLS : SNOW_PINES) :
+ (biome.getScale() >= 0.25f ? FOREST_HILLS : FOREST)
+ );
+ break;
+ case PLAINS:
+ setTexture(biome, biome.getPrecipitation() == Biome.Precipitation.SNOW ?
+ (biome.getScale() >= 0.25f ? SNOW_HILLS : SNOW) :
+ (biome.getScale() >= 0.25f ? HILLS : PLAINS)
+ );
+ break;
+ case ICY:
+ setTexture(biome, ICE_SPIKES); // TODO also snowy mountains/tundra?
+ break;
+ case DESERT:
+ setTexture(biome, biome.getScale() >= 0.25f ? DESERT_HILLS : DESERT);
+ break;
+ case TAIGA:
+ setTexture(biome, SNOW); // TODO
+ break;
+ case EXTREME_HILLS:
+ setTexture(biome, HILLS);
+ break;
+ default:
+ setTexture(biome, defaultTexture);
+ break;
+ }
+
+ /* Set types = BiomeDictionary.getTypes(biome);
// 1. Swamp
if (types.contains(Type.SWAMP)) {
if (types.contains(Type.HILLS)) {
@@ -219,8 +270,9 @@ else if (types.contains(Type.HILLS)) {
}
} else {
setTexture(biome, defaultTexture);
- }
- Log.info("Auto-registered standard texture set for biome %s", biome.getRegistryName().toString());
+ } */
+
+ Log.info("Auto-registered standard texture set for biome %s", Registry.BIOME.getId(biome).toString());
}
/** Auto-registers the biome if it is not registered. */
@@ -247,29 +299,29 @@ public boolean isRegistered(int pseudoID) {
}
/** If unknown biome, auto-registers a texture set. If null, returns default set. */
- public TextureSet getTextureSet(Tile tile) {
+ public TextureSet getTextureSet(TileKind tile) {
if (tile == null) return defaultTexture;
- if (tile.biomeID >= 0) {
- Biome biome = Biome.getBiomeForId(tile.biomeID);
+ Biome biome = tile.getBiome();
+ if (biome != null) {
checkRegistration(biome);
return biomeTextureMap.getOrDefault(biome, defaultTexture);
}
else {
- checkRegistration(tile.biomeID);
- return pseudoBiomeTextureMap.get(tile.biomeID);
+ checkRegistration(tile.getId());
+ return pseudoBiomeTextureMap.get(tile.getId());
}
}
- public ResourceLocation getTexture(Tile tile) {
+ public Identifier getTexture(int x, int y, TileKind tile) {
TextureSet set = getTextureSet(tile);
- int i = MathHelper.floor((float)(tile.getVariationNumber())
+ int i = MathHelper.floor((float)(tile.getVariationNumber(x, y))
/ (float)(Short.MAX_VALUE) * (float)(set.textures.length));
return set.textures[i];
}
- public List getAllTextures() {
- List list = new ArrayList<>(biomeTextureMap.size());
+ public List getAllTextures() {
+ List list = new ArrayList<>(biomeTextureMap.size());
for (Entry entry : biomeTextureMap.entrySet()) {
list.addAll(Arrays.asList(entry.getValue().textures));
}
diff --git a/src/main/java/hunternif/mc/atlas/client/KeyHandler.java b/src/main/java/hunternif/mc/atlas/client/KeyHandler.java
index eadbe4517..88a100583 100644
--- a/src/main/java/hunternif/mc/atlas/client/KeyHandler.java
+++ b/src/main/java/hunternif/mc/atlas/client/KeyHandler.java
@@ -2,12 +2,12 @@
import hunternif.mc.atlas.AntiqueAtlasMod;
import hunternif.mc.atlas.client.gui.GuiAtlas;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.options.KeyBinding;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
+import none.XX_1_12_2_none_blk_XX;
import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
@@ -30,8 +30,8 @@ public static void registerBindings() {
@SubscribeEvent(receiveCanceled = true)
public void onKeyEvent(InputEvent.KeyInputEvent event) {
- if (bindings.get(KEY_ATLAS).isPressed()) {
- GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
+ if (bindings.get(KEY_ATLAS).wasPressed()) {
+ XX_1_12_2_none_blk_XX currentScreen = MinecraftClient.getInstance().XX_1_12_2_m_XX;
if (currentScreen instanceof GuiAtlas) {
((GuiAtlas) currentScreen).close();
} else {
diff --git a/src/main/java/hunternif/mc/atlas/client/SubTile.java b/src/main/java/hunternif/mc/atlas/client/SubTile.java
index c99c3ce40..782748506 100644
--- a/src/main/java/hunternif/mc/atlas/client/SubTile.java
+++ b/src/main/java/hunternif/mc/atlas/client/SubTile.java
@@ -1,6 +1,6 @@
package hunternif.mc.atlas.client;
-import hunternif.mc.atlas.core.Tile;
+import hunternif.mc.atlas.core.TileKind;
/**
* A quarter of a tile, containing the following information:
@@ -16,7 +16,7 @@
* @author Hunternif
*/
public class SubTile {
- public Tile tile;
+ public TileKind tile;
/** coordinates of the subtile on the grid, measured in subtiles,
* starting from (0,0) in the top left corner. */
public int x, y;
diff --git a/src/main/java/hunternif/mc/atlas/client/TextureSet.java b/src/main/java/hunternif/mc/atlas/client/TextureSet.java
index 739712178..df366aa99 100644
--- a/src/main/java/hunternif/mc/atlas/client/TextureSet.java
+++ b/src/main/java/hunternif/mc/atlas/client/TextureSet.java
@@ -1,11 +1,12 @@
package hunternif.mc.atlas.client;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.Identifier;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+
import static hunternif.mc.atlas.client.Textures.*;
public class TextureSet implements Comparable {
@@ -236,7 +237,7 @@ public class TextureSet implements Comparable {
public final String name;
/** The actual textures in this set. */
- public final ResourceLocation[] textures;
+ public final Identifier[] textures;
/** Texture sets that a tile rendered with this set can be stitched to,
* excluding itself. */
@@ -251,17 +252,17 @@ public class TextureSet implements Comparable {
private boolean stitchesToNull = false;
private boolean anisotropicStitching = false;
- private static TextureSet standard(String name, ResourceLocation ... textures) {
+ private static TextureSet standard(String name, Identifier ... textures) {
return new TextureSet(true, name, textures);
}
- private TextureSet(boolean isStandard, String name, ResourceLocation ... textures) {
+ private TextureSet(boolean isStandard, String name, Identifier ... textures) {
this.isStandard = isStandard;
this.name = name;
this.textures = textures;
}
/** Name has to be unique, it is used for equals() tests. */
- public TextureSet(String name, ResourceLocation ... textures) {
+ public TextureSet(String name, Identifier ... textures) {
this(false, name, textures);
}
@@ -324,7 +325,7 @@ public boolean equals(Object obj) {
/** A special texture set that is stitched to everything except water. */
private static class TextureSetShore extends TextureSet {
private final TextureSet water;
- TextureSetShore(String name, TextureSet water, ResourceLocation ... textures) {
+ TextureSetShore(String name, TextureSet water, Identifier... textures) {
super(true, name, textures);
this.water = water;
}
diff --git a/src/main/java/hunternif/mc/atlas/client/TextureSetConfig.java b/src/main/java/hunternif/mc/atlas/client/TextureSetConfig.java
index cfcdf8170..3f4bd3556 100644
--- a/src/main/java/hunternif/mc/atlas/client/TextureSetConfig.java
+++ b/src/main/java/hunternif/mc/atlas/client/TextureSetConfig.java
@@ -8,10 +8,9 @@
import java.util.PriorityQueue;
import java.util.Queue;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.util.Identifier;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -20,7 +19,7 @@
/**
* Saves texture set names with the lists of texture variations.
*/
-@SideOnly(Side.CLIENT)
+@Environment(EnvType.CLIENT)
public class TextureSetConfig extends AbstractJSONConfig {
private static final int VERSION = 1;
@@ -37,10 +36,10 @@ protected void loadData(JsonObject json, TextureSetMap data, int version) {
for (Entry entry : json.entrySet()) {
String name = entry.getKey();
JsonArray array = entry.getValue().getAsJsonArray();
- ResourceLocation[] textures = new ResourceLocation[array.size()];
+ Identifier[] textures = new Identifier[array.size()];
for (int i = 0; i < array.size(); i++) {
String path = array.get(i).getAsString();
- textures[i] = new ResourceLocation(path);
+ textures[i] = new Identifier(path);
}
data.register(new TextureSet(name, textures));
Log.info("Loaded texture set %s with %d custom texture(s)", name, textures.length);
@@ -54,7 +53,7 @@ protected void saveData(JsonObject json, TextureSetMap data) {
while (!queue.isEmpty()) {
TextureSet set = queue.poll();
JsonArray paths = new JsonArray();
- for (ResourceLocation texture : set.textures) {
+ for (Identifier texture : set.textures) {
paths.add(new JsonPrimitive(texture.toString()));
}
json.add(set.name, paths);
diff --git a/src/main/java/hunternif/mc/atlas/client/TextureSetMap.java b/src/main/java/hunternif/mc/atlas/client/TextureSetMap.java
index 6ba7beda7..0d6f29937 100644
--- a/src/main/java/hunternif/mc/atlas/client/TextureSetMap.java
+++ b/src/main/java/hunternif/mc/atlas/client/TextureSetMap.java
@@ -1,6 +1,9 @@
package hunternif.mc.atlas.client;
import hunternif.mc.atlas.util.SaveData;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.util.Identifier;
import java.util.ArrayList;
import java.util.Collection;
@@ -9,15 +12,11 @@
import java.util.Map;
import java.util.UUID;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
/**
* Maps texture sets to their names.
* @author Hunternif
*/
-@SideOnly(Side.CLIENT)
+@Environment(EnvType.CLIENT)
public class TextureSetMap extends SaveData {
private static final TextureSetMap INSTANCE = new TextureSetMap();
public static TextureSetMap instance() {
@@ -36,7 +35,7 @@ public void register(TextureSet set) {
}
/** Legacy support. Creates a new texture set with a UUID-based name. */
- public TextureSet createAndRegister(ResourceLocation ... textures) {
+ public TextureSet createAndRegister(Identifier... textures) {
TextureSet set = new TextureSet(UUID.randomUUID().toString(), textures);
register(set);
return set;
diff --git a/src/main/java/hunternif/mc/atlas/client/Textures.java b/src/main/java/hunternif/mc/atlas/client/Textures.java
index c7b44257d..4413384c3 100644
--- a/src/main/java/hunternif/mc/atlas/client/Textures.java
+++ b/src/main/java/hunternif/mc/atlas/client/Textures.java
@@ -1,7 +1,7 @@
package hunternif.mc.atlas.client;
import hunternif.mc.atlas.AntiqueAtlasMod;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.Identifier;
public class Textures {
private static final String MOD_PREFIX = AntiqueAtlasMod.ID + ":";
@@ -11,7 +11,7 @@ public class Textures {
private static final String GUI_MARKERS = GUI + "markers/";
private static final String GUI_SCALEBAR = GUI + "scalebar/";
- public static final ResourceLocation
+ public static final Identifier
BOOK = gui("book.png"),
EXPORTED_BG = gui("exported_bg.png"),
BOOK_FRAME = gui("book_frame.png"),
@@ -249,19 +249,19 @@ public class Textures {
TILE_NETHER_THRONE = tile("nether_throne.png");
// Constructor helpers:
- private static ResourceLocation gui(String fileName) {
- return new ResourceLocation(GUI + fileName);
+ private static Identifier gui(String fileName) {
+ return new Identifier(GUI + fileName);
}
- private static ResourceLocation scaleBar(String fileName) {
- return new ResourceLocation(GUI_SCALEBAR + fileName);
+ private static Identifier scaleBar(String fileName) {
+ return new Identifier(GUI_SCALEBAR + fileName);
}
- private static ResourceLocation marker(String fileName) {
- return new ResourceLocation(GUI_MARKERS + fileName);
+ private static Identifier marker(String fileName) {
+ return new Identifier(GUI_MARKERS + fileName);
}
- private static ResourceLocation tile(String fileName) {
- return new ResourceLocation(GUI_TILES + fileName);
+ private static Identifier tile(String fileName) {
+ return new Identifier(GUI_TILES + fileName);
}
- private static ResourceLocation icon(String fileName) {
- return new ResourceLocation(GUI_ICONS + fileName);
+ private static Identifier icon(String fileName) {
+ return new Identifier(GUI_ICONS + fileName);
}
}
diff --git a/src/main/java/hunternif/mc/atlas/client/TileRenderIterator.java b/src/main/java/hunternif/mc/atlas/client/TileRenderIterator.java
index a859fee33..651ffadde 100644
--- a/src/main/java/hunternif/mc/atlas/client/TileRenderIterator.java
+++ b/src/main/java/hunternif/mc/atlas/client/TileRenderIterator.java
@@ -3,7 +3,7 @@
import hunternif.mc.atlas.client.SubTile.Part;
import hunternif.mc.atlas.client.SubTile.Shape;
import hunternif.mc.atlas.core.ITileStorage;
-import hunternif.mc.atlas.core.Tile;
+import hunternif.mc.atlas.core.TileKind;
import hunternif.mc.atlas.util.Rect;
import java.util.Iterator;
@@ -11,7 +11,7 @@
/**
* Iterates through a tile storage for the purpose of rendering their textures.
* Returned is an array of 4 {@link SubTile}s which constitute a whole
- * {@link Tile}.
+ * {@link TileKind}.
* The SubTile objects are generated on the fly and not retained in memory.
* May return null!
* @author Hunternif
@@ -55,7 +55,7 @@ public void setScope(Rect scope){
* 'i' is at (x, y).
* The returned array of subtiles represents the corner 'd-e-h-i'
*/
- private Tile a, b, c, d, e, f, g, h, i, j, k, l;
+ private TileKind a, b, c, d, e, f, g, h, i, j, k, l;
/** Shortcuts for the quartet. */
private final SubTile _d = new SubTile(Part.BOTTOM_RIGHT),
@@ -185,7 +185,7 @@ public SubTileQuartet next() {
/** Whether the first tile should be stitched to the 2nd (in any direction)
* (but the opposite is not always true!) */
- private static boolean shouldStitchTo(Tile tile, Tile to) {
+ private static boolean shouldStitchTo(TileKind tile, TileKind to) {
if (tile == null) return false;
TextureSet set = BiomeTextureMap.instance().getTextureSet(tile);
TextureSet toSet = BiomeTextureMap.instance().getTextureSet(to);
@@ -193,7 +193,7 @@ private static boolean shouldStitchTo(Tile tile, Tile to) {
}
/** Whether the first tile should be stitched to the 2nd along the X axis
* (but the opposite is not always true!) */
- private static boolean shouldStitchToHorizontally(Tile tile, Tile to) {
+ private static boolean shouldStitchToHorizontally(TileKind tile, TileKind to) {
if (tile == null) return false;
TextureSet set = BiomeTextureMap.instance().getTextureSet(tile);
TextureSet toSet = BiomeTextureMap.instance().getTextureSet(to);
@@ -201,7 +201,7 @@ private static boolean shouldStitchToHorizontally(Tile tile, Tile to) {
}
/** Whether the first tile should be stitched to the 2nd along the Z axis
* (but the opposite is not always true!) */
- private static boolean shouldStitchToVertically(Tile tile, Tile to) {
+ private static boolean shouldStitchToVertically(TileKind tile, TileKind to) {
if (tile == null) return false;
TextureSet set = BiomeTextureMap.instance().getTextureSet(tile);
TextureSet toSet = BiomeTextureMap.instance().getTextureSet(to);
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/ExportProgressOverlay.java b/src/main/java/hunternif/mc/atlas/client/gui/ExportProgressOverlay.java
index 7202e0942..40123dca9 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/ExportProgressOverlay.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/ExportProgressOverlay.java
@@ -1,45 +1,42 @@
package hunternif.mc.atlas.client.gui;
+import com.mojang.blaze3d.platform.GlStateManager;
import hunternif.mc.atlas.util.ExportImageUtil;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.renderer.BufferBuilder;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-
-import net.minecraftforge.client.event.RenderGameOverlayEvent;
-import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.font.TextRenderer;
+import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.Tessellator;
+import net.minecraft.client.render.VertexFormats;
import org.lwjgl.opengl.GL11;
public enum ExportProgressOverlay {
INSTANCE;
- @SubscribeEvent
- @SideOnly(Side.CLIENT)
+ // TODO FABRIC
+
+ /* @SubscribeEvent
+ @Environment(EnvType.CLIENT)
public void draw(RenderGameOverlayEvent.Post event) {
- int x = event.getResolution().getScaledWidth() - 40, y = event.getResolution().getScaledHeight() - 20, barWidth = 50, barHeight = 2;
+ int x = event.getResolution().a() - 40, y = event.getResolution().b() - 20, barWidth = 50, barHeight = 2;
ExportUpdateListener l = ExportUpdateListener.INSTANCE;
if(event.getType() != ElementType.ALL || !ExportImageUtil.isExporting)
return;
- FontRenderer font = Minecraft.getMinecraft().fontRenderer;
+ TextRenderer font = MinecraftClient.getInstance().textRenderer;
int s = 2;
- GlStateManager.scale(1.0/s, 1.0/s, 1);
+ GlStateManager.scaled(1.0/s, 1.0/s, 1);
int headerWidth = font.getStringWidth(l.header);
- font.drawStringWithShadow(l.header, ( x )*s -headerWidth/2, ( y )*s - 14, 0xffffff);
+ font.draw(l.header, ( x )*s -headerWidth/2, ( y )*s - 14, 0xffffff);
int statusWidth = font.getStringWidth(l.status);
- font.drawStringWithShadow(l.status, ( x )*s -statusWidth/2, ( y )*s, 0xffffff);
+ font.draw(l.status, ( x )*s -statusWidth/2, ( y )*s, 0xffffff);
- GlStateManager.scale(s, s, 1);
+ GlStateManager.texParameter(s, s, 1);
y += 7;
x -= barWidth/2;
@@ -47,26 +44,26 @@ public void draw(RenderGameOverlayEvent.Post event) {
if(l.maxProgress < 0)
p = 0;
- GlStateManager.disableTexture2D();
+ GlStateManager.disableTexture();
Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder vb = tessellator.getBuffer();
+ BufferBuilder vb = tessellator.getBufferBuilder();
- vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
+ vb.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR);
- vb.pos(x, y, 0) .color(0.5f, 0.5f, 0.5f, 1).endVertex();
- vb.pos(x, y+barHeight, 0) .color(0.5f, 0.5f, 0.5f, 1).endVertex();
- vb.pos(x+barWidth, y+barHeight, 0) .color(0.5f, 0.5f, 0.5f, 1).endVertex();
- vb.pos(x+barWidth, y, 0) .color(0.5f, 0.5f, 0.5f, 1).endVertex();
+ vb.vertex(x, y, 0) .color(0.5f, 0.5f, 0.5f, 1).next();
+ vb.vertex(x, y+barHeight, 0) .color(0.5f, 0.5f, 0.5f, 1).next();
+ vb.vertex(x+barWidth, y+barHeight, 0) .color(0.5f, 0.5f, 0.5f, 1).next();
+ vb.vertex(x+barWidth, y, 0) .color(0.5f, 0.5f, 0.5f, 1).next();
- vb.pos(x, y, 0) .color(0.5f, 1, 0.5f, 1).endVertex();
- vb.pos(x, y+barHeight, 0) .color(0.5f, 1, 0.5f, 1).endVertex();
- vb.pos(x+barWidth*p, y+barHeight, 0).color(0.5f, 1, 0.5f, 1).endVertex();
- vb.pos(x+barWidth*p, y, 0) .color(0.5f, 1, 0.5f, 1).endVertex();
+ vb.vertex(x, y, 0) .color(0.5f, 1, 0.5f, 1).next();
+ vb.vertex(x, y+barHeight, 0) .color(0.5f, 1, 0.5f, 1).next();
+ vb.vertex(x+barWidth*p, y+barHeight, 0) .color(0.5f, 1, 0.5f, 1).next();
+ vb.vertex(x+barWidth*p, y, 0) .color(0.5f, 1, 0.5f, 1).next();
tessellator.draw();
- GlStateManager.enableTexture2D();
- }
+ GlStateManager.enableTexture();
+ } */
}
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/ExportUpdateListener.java b/src/main/java/hunternif/mc/atlas/client/gui/ExportUpdateListener.java
index fe2b51494..516254ef2 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/ExportUpdateListener.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/ExportUpdateListener.java
@@ -1,6 +1,6 @@
package hunternif.mc.atlas.client.gui;
-import net.minecraft.client.resources.I18n;
+import net.minecraft.client.resource.language.I18n;
public enum ExportUpdateListener {
INSTANCE;
@@ -12,11 +12,11 @@ public enum ExportUpdateListener {
public String header;
public void setStatusString(String status, Object... data) {
- this.status = I18n.format(status, data);
+ this.status = I18n.translate(status, data);
}
public void setHeaderString(String header, Object... data) {
- this.header = I18n.format(header, data);
+ this.header = I18n.translate(header, data);
}
public void setProgressMax(int max) {
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/GuiArrowButton.java b/src/main/java/hunternif/mc/atlas/client/gui/GuiArrowButton.java
index f4d35d416..75bd2e136 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/GuiArrowButton.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/GuiArrowButton.java
@@ -1,11 +1,10 @@
package hunternif.mc.atlas.client.gui;
+import com.mojang.blaze3d.platform.GlStateManager;
import hunternif.mc.atlas.client.Textures;
import hunternif.mc.atlas.client.gui.core.GuiComponentButton;
import hunternif.mc.atlas.util.AtlasRenderHelper;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.RenderHelper;
-
+import net.minecraft.client.render.GuiLighting;
import org.lwjgl.opengl.GL11;
public class GuiArrowButton extends GuiComponentButton {
@@ -44,20 +43,20 @@ static GuiArrowButton right() {
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTick) {
- RenderHelper.disableStandardItemLighting();
+ public void a(int mouseX, int mouseY, float partialTick) {
+ GuiLighting.disable();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
int x = getGuiX(), y = getGuiY();
if (isMouseOver) {
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
} else {
// Fade out when the mouse is far from them:
int distanceSq = (mouseX - x - getWidth()/2)*(mouseX - x - getWidth()/2) +
(mouseY - y - getHeight()/2)*(mouseY - y - getHeight()/2);
double alpha = distanceSq < 400 ? 0.5 : Math.pow((double)distanceSq, -0.28);
- GlStateManager.color(1, 1, 1, (float)alpha);
+ GlStateManager.color4f(1, 1, 1, (float)alpha);
}
int u = 0, v = 0;
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/GuiAtlas.java b/src/main/java/hunternif/mc/atlas/client/gui/GuiAtlas.java
index 0e2595b95..75c13497a 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/GuiAtlas.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/GuiAtlas.java
@@ -1,5 +1,6 @@
package hunternif.mc.atlas.client.gui;
+import com.mojang.blaze3d.platform.GlStateManager;
import hunternif.mc.atlas.AntiqueAtlasMod;
import hunternif.mc.atlas.SettingsConfig;
import hunternif.mc.atlas.api.AtlasAPI;
@@ -19,19 +20,18 @@
import hunternif.mc.atlas.registry.MarkerRenderInfo;
import hunternif.mc.atlas.registry.MarkerType;
import hunternif.mc.atlas.util.*;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.renderer.BufferBuilder;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.client.settings.KeyBinding;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.options.KeyBinding;
+import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.Tessellator;
+import net.minecraft.client.render.VertexFormats;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.common.MinecraftForge;
+import none.XX_1_12_2_none_bit_XX;
+import none.XX_1_12_2_none_blk_XX;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -81,13 +81,13 @@ public class GuiAtlas extends GuiComponent {
public void onEnterState() {
// Set the button as not selected so that it can be clicked again:
btnShowMarkers.setSelected(false);
- btnShowMarkers.setTitle(I18n.format("gui.antiqueatlas.showMarkers"));
+ btnShowMarkers.setTitle(I18n.translate("gui.antiqueatlas.showMarkers"));
btnShowMarkers.setIconTexture(Textures.ICON_SHOW_MARKERS);
}
@Override
public void onExitState() {
btnShowMarkers.setSelected(false);
- btnShowMarkers.setTitle(I18n.format("gui.antiqueatlas.hideMarkers"));
+ btnShowMarkers.setTitle(I18n.translate("gui.antiqueatlas.hideMarkers"));
btnShowMarkers.setIconTexture(Textures.ICON_HIDE_MARKERS);
}
};
@@ -109,13 +109,13 @@ public void onExitState() {
private final IState DELETING_MARKER = new IState() {
@Override
public void onEnterState() {
- mc.mouseHelper.grabMouseCursor();
+ GuiComponent.v.a();
addChild(eraser);
btnDelMarker.setSelected(true);
}
@Override
public void onExitState() {
- mc.mouseHelper.ungrabMouseCursor();
+ mc.v.b();
removeChild(eraser);
btnDelMarker.setSelected(false);
}
@@ -214,7 +214,7 @@ public void onExitState() {
// Misc stuff ==============================================================
- private EntityPlayer player;
+ private PlayerEntity player;
private ItemStack stack;
private DimensionData biomeData;
@@ -259,7 +259,7 @@ public GuiAtlas() {
} else {
// Navigate once, before enabling pause:
navigateByButton(selectedButton);
- timeButtonPressed = player.getEntityWorld().getTotalWorldTime();
+ timeButtonPressed = player.getEntityWorld().R();
}
};
btnUp.addListener(positionListener);
@@ -268,7 +268,7 @@ public GuiAtlas() {
btnRight.addListener(positionListener);
btnPosition.addListener(positionListener);
- btnExportPng = new GuiBookmarkButton(1, Textures.ICON_EXPORT, I18n.format("gui.antiqueatlas.exportImage")) {
+ btnExportPng = new GuiBookmarkButton(1, Textures.ICON_EXPORT, I18n.translate("gui.antiqueatlas.exportImage")) {
@Override
public boolean isEnabled() {
return !ExportImageUtil.isExporting;
@@ -282,7 +282,7 @@ public boolean isEnabled() {
}
});
- btnMarker = new GuiBookmarkButton(0, Textures.ICON_ADD_MARKER, I18n.format("gui.antiqueatlas.addMarker"));
+ btnMarker = new GuiBookmarkButton(0, Textures.ICON_ADD_MARKER, I18n.translate("gui.antiqueatlas.addMarker"));
addChild(btnMarker).offsetGuiCoords(300, 14);
btnMarker.addListener(button -> {
if (stack != null || !SettingsConfig.gameplay.itemNeeded) {
@@ -294,23 +294,23 @@ public boolean isEnabled() {
state.switchTo(PLACING_MARKER);
// While holding shift, we create a marker on the player's position
- if (GuiScreen.isShiftKeyDown()) {
+ if (XX_1_12_2_none_blk_XX.s()) {
markerFinalizer.setMarkerData(player.getEntityWorld(),
getAtlasID(), player.dimension,
- (int) player.posX, (int) player.posZ);
+ (int) player.x, (int) player.z);
addChild(markerFinalizer);
blinkingIcon.setTexture(markerFinalizer.selectedType.getIcon(),
MARKER_SIZE, MARKER_SIZE);
addChildBehind(markerFinalizer, blinkingIcon)
- .setRelativeCoords(worldXToScreenX((int) player.posX) - getGuiX() - MARKER_SIZE / 2,
- worldZToScreenY((int) player.posZ) - getGuiY() - MARKER_SIZE / 2);
+ .setRelativeCoords(worldXToScreenX((int) player.x) - getGuiX() - MARKER_SIZE / 2,
+ worldZToScreenY((int) player.z) - getGuiY() - MARKER_SIZE / 2);
// Need to intercept keyboard events to type in the label:
setInterceptKeyboard(true);
// Un-press all keys to prevent player from walking infinitely:
- KeyBinding.unPressAllKeys();
+ KeyBinding.unpressAll();
selectedButton = null;
state.switchTo(NORMAL);
@@ -318,7 +318,7 @@ public boolean isEnabled() {
}
}
});
- btnDelMarker = new GuiBookmarkButton(2, Textures.ICON_DELETE_MARKER, I18n.format("gui.antiqueatlas.delMarker"));
+ btnDelMarker = new GuiBookmarkButton(2, Textures.ICON_DELETE_MARKER, I18n.translate("gui.antiqueatlas.delMarker"));
addChild(btnDelMarker).offsetGuiCoords(300, 33);
btnDelMarker.addListener(button -> {
if (stack != null || !SettingsConfig.gameplay.itemNeeded) {
@@ -331,7 +331,7 @@ public boolean isEnabled() {
}
}
});
- btnShowMarkers = new GuiBookmarkButton(3, Textures.ICON_HIDE_MARKERS, I18n.format("gui.antiqueatlas.hideMarkers"));
+ btnShowMarkers = new GuiBookmarkButton(3, Textures.ICON_HIDE_MARKERS, I18n.translate("gui.antiqueatlas.hideMarkers"));
addChild(btnShowMarkers).offsetGuiCoords(300, 52);
btnShowMarkers.addListener(button -> {
if (stack != null || !SettingsConfig.gameplay.itemNeeded) {
@@ -355,7 +355,7 @@ public GuiAtlas prepareToOpen(ItemStack stack) {
}
public GuiAtlas prepareToOpen() {
- this.player = Minecraft.getMinecraft().player;
+ this.player = MinecraftClient.getInstance().player;
updateAtlasData();
if (!followPlayer && SettingsConfig.gameplay.doSaveBrowsingPos) {
loadSavedBrowsingPosition();
@@ -373,19 +373,19 @@ public void loadSavedBrowsingPosition() {
}
@Override
- public void initGui() {
- super.initGui();
+ public void onInitialized() {
+ super.onInitialized();
if(!state.equals(EXPORTING_IMAGE)) {
state.switchTo(NORMAL); //TODO: his causes the Export PNG progress bar to disappear when resizing game window
}
Keyboard.enableRepeatEvents(true);
- screenScale = new ScaledResolution(mc).getScaleFactor();
+ screenScale = new XX_1_12_2_none_bit_XX(mc).e();
setCentered();
}
@Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseState) throws IOException {
+ protected void a(int mouseX, int mouseY, int mouseState) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseState);
if (state.is(EXPORTING_IMAGE)) {
return; // Don't remove the progress bar.
@@ -416,7 +416,7 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseState) throws IOExc
setInterceptKeyboard(true);
// Un-press all keys to prevent player from walking infinitely:
- KeyBinding.unPressAllKeys();
+ KeyBinding.unpressAll();
} else if (state.is(DELETING_MARKER) // If clicked on a marker, delete it:
&& hoveredMarker != null && !hoveredMarker.isGlobal() && isMouseOverMap && mouseState == 0) {
@@ -443,7 +443,7 @@ private void exportImage(int atlasID) {
// Default file name is "Atlas .png"
ExportImageUtil.isExporting = true;
- File screenshot_folder = new File(Minecraft.getMinecraft().gameDir, "screenshots");
+ File screenshot_folder = new File(MinecraftClient.getInstance().runDirectory, "screenshots");
if(!screenshot_folder.isDirectory())
{
screenshot_folder.mkdir();
@@ -473,7 +473,7 @@ private void exportImage(int atlasID) {
Log.error(e2, "Image is STILL too large, how massive is this map?! Answer: (%dx%d)", outWidth, outHeight);
- ExportUpdateListener.INSTANCE.setStatusString(I18n.format("gui.antiqueatlas.export.tooLarge"));
+ ExportUpdateListener.INSTANCE.setStatusString(I18n.translate("gui.antiqueatlas.export.tooLarge"));
ExportImageUtil.isExporting = false;
return; //Don't switch to normal state yet so that the error message can be read.
}
@@ -484,8 +484,8 @@ private void exportImage(int atlasID) {
}
@Override
- public void handleKeyboardInput() throws IOException {
- super.handleKeyboardInput();
+ public void l() throws IOException {
+ super.l();
if (Keyboard.getEventKeyState()) {
int key = Keyboard.getEventKey();
if (key == Keyboard.KEY_UP) {
@@ -500,14 +500,14 @@ public void handleKeyboardInput() throws IOException {
setMapScale(mapScale * 2);
} else if (key == Keyboard.KEY_SUBTRACT || key == Keyboard.KEY_MINUS) {
setMapScale(mapScale / 2);
- } else if (key == mc.gameSettings.keyBindInventory.getKeyCode()){
+ } else if (key == mc.t.aa.j()){
close();
}
// Close the GUI if a hotbar key is pressed
else {
- KeyBinding[] hotbarKeys = mc.gameSettings.keyBindsHotbar;
+ KeyBinding[] hotbarKeys = mc.t.ap;
for (KeyBinding bind : hotbarKeys) {
- if (key == bind.getKeyCode()) {
+ if (key == bind.XX_1_12_2_j_XX()) {
close();
break;
}
@@ -517,8 +517,8 @@ public void handleKeyboardInput() throws IOException {
}
@Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
+ public void k() throws IOException {
+ super.k();
int wheelMove = Mouse.getEventDWheel();
if (wheelMove != 0) {
@@ -527,8 +527,8 @@ public void handleMouseInput() throws IOException {
wheelMove *= -1;
}
- int mouseOffsetX = mc.displayWidth / screenScale / 2 - getMouseX();
- int mouseOffsetY = mc.displayHeight / screenScale / 2 - getMouseY();
+ int mouseOffsetX = mc.d / screenScale / 2 - getMouseX();
+ int mouseOffsetY = mc.e / screenScale / 2 - getMouseY();
double newScale = mapScale * Math.pow(2, wheelMove);
int addOffsetX = 0;
int addOffsetY = 0;
@@ -547,7 +547,7 @@ public void handleMouseInput() throws IOException {
}
@Override
- protected void mouseReleased(int mouseX, int mouseY, int mouseState) {
+ protected void b(int mouseX, int mouseY, int mouseState) {
super.mouseReleased(mouseX, mouseY, mouseState);
if (mouseState != -1) {
selectedButton = null;
@@ -556,7 +556,7 @@ protected void mouseReleased(int mouseX, int mouseY, int mouseState) {
}
@Override
- protected void mouseClickMove(int mouseX, int mouseY, int lastMouseButton, long timeSinceMouseClick) {
+ protected void a(int mouseX, int mouseY, int lastMouseButton, long timeSinceMouseClick) {
super.mouseClickMove(mouseX, mouseY, lastMouseButton, timeSinceMouseClick);
if (isDragging) {
followPlayer = false;
@@ -567,14 +567,14 @@ protected void mouseClickMove(int mouseX, int mouseY, int lastMouseButton, long
}
@Override
- public void updateScreen() {
- super.updateScreen();
+ public void e() {
+ super.e();
if (player == null) return;
if (followPlayer) {
- mapOffsetX = (int)(-player.posX * mapScale);
- mapOffsetY = (int)(-player.posZ * mapScale);
+ mapOffsetX = (int)(-player.x * mapScale);
+ mapOffsetY = (int)(-player.z * mapScale);
}
- if (player.getEntityWorld().getTotalWorldTime() > timeButtonPressed + BUTTON_PAUSE) {
+ if (player.getEntityWorld().R() > timeButtonPressed + BUTTON_PAUSE) {
navigateByButton(selectedButton);
}
@@ -664,7 +664,7 @@ private void setMapScale(double scale, int addOffsetX, int addOffsetY) {
}
@Override
- public void drawScreen(int mouseX, int mouseY, float par3) {
+ public void a(int mouseX, int mouseY, float par3) {
long currentMillis = System.currentTimeMillis();
long deltaMillis = currentMillis - lastUpdateMillis;
lastUpdateMillis = currentMillis;
@@ -681,19 +681,19 @@ public void drawScreen(int mouseX, int mouseY, float par3) {
}
}
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.alphaFunc(GL11.GL_GREATER, 0); // So light detail on tiles is visible
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
+ GlStateManager.texGenMode(GL11.GL_GREATER, 0); // So light detail on tiles is visible
AtlasRenderHelper.drawFullTexture(Textures.BOOK, getGuiX(), getGuiY(), WIDTH, HEIGHT);
if ((stack == null && SettingsConfig.gameplay.itemNeeded) || biomeData == null)
return;
if (state.is(DELETING_MARKER)) {
- GlStateManager.color(1, 1, 1, 0.5f);
+ GlStateManager.color4f(1, 1, 1, 0.5f);
}
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor((getGuiX() + CONTENT_X) * screenScale,
- mc.displayHeight - (getGuiY() + CONTENT_Y + MAP_HEIGHT)*screenScale,
+ mc.e - (getGuiY() + CONTENT_Y + MAP_HEIGHT)*screenScale,
MAP_WIDTH * screenScale, MAP_HEIGHT*screenScale);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
@@ -717,7 +717,7 @@ public void drawScreen(int mouseX, int mouseY, float par3) {
for (SubTile subtile : subtiles) {
if (subtile == null || subtile.tile == null) continue;
AtlasRenderHelper.drawAutotileCorner(
- BiomeTextureMap.instance().getTexture(subtile.tile),
+ BiomeTextureMap.instance().getTexture(subtile.x, subtile.y, subtile.tile),
mapStartScreenX + subtile.x * tileHalfSize,
mapStartScreenY + subtile.y * tileHalfSize,
subtile.getTextureU(), subtile.getTextureV(), tileHalfSize);
@@ -757,7 +757,7 @@ public void drawScreen(int mouseX, int mouseY, float par3) {
GL11.glDisable(GL11.GL_SCISSOR_TEST);
// Overlay the frame so that edges of the map are smooth:
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
AtlasRenderHelper.drawFullTexture(Textures.BOOK_FRAME, getGuiX(), getGuiY(), WIDTH, HEIGHT);
renderScaleOverlay(deltaMillis);
iconScale = getIconScale();
@@ -765,33 +765,33 @@ public void drawScreen(int mouseX, int mouseY, float par3) {
// Draw player icon:
if (!state.is(HIDING_MARKERS)) {
// How much the player has moved from the top left corner of the map, in pixels:
- int playerOffsetX = (int)(player.posX * mapScale) + mapOffsetX;
- int playerOffsetZ = (int)(player.posZ * mapScale) + mapOffsetY;
+ int playerOffsetX = (int)(player.x * mapScale) + mapOffsetX;
+ int playerOffsetZ = (int)(player.z * mapScale) + mapOffsetY;
if (playerOffsetX < -MAP_WIDTH/2) playerOffsetX = -MAP_WIDTH/2;
if (playerOffsetX > MAP_WIDTH/2) playerOffsetX = MAP_WIDTH/2;
if (playerOffsetZ < -MAP_HEIGHT/2) playerOffsetZ = -MAP_HEIGHT/2;
if (playerOffsetZ > MAP_HEIGHT/2 - 2) playerOffsetZ = MAP_HEIGHT/2 - 2;
// Draw the icon:
- GlStateManager.color(1, 1, 1, state.is(PLACING_MARKER) ? 0.5f : 1);
+ GlStateManager.color4f(1, 1, 1, state.is(PLACING_MARKER) ? 0.5f : 1);
GlStateManager.pushMatrix();
- GlStateManager.translate(getGuiX() + WIDTH/2 + playerOffsetX, getGuiY() + HEIGHT/2 + playerOffsetZ, 0);
+ GlStateManager.getTexLevelParameter(getGuiX() + WIDTH/2 + playerOffsetX, getGuiY() + HEIGHT/2 + playerOffsetZ, 0);
float playerRotation = (float) Math.round(player.rotationYaw / 360f * PLAYER_ROTATION_STEPS) / PLAYER_ROTATION_STEPS * 360f;
- GlStateManager.rotate(180 + playerRotation, 0, 0, 1);
- GlStateManager.translate(-PLAYER_ICON_WIDTH/2*iconScale, -PLAYER_ICON_HEIGHT/2*iconScale, 0);
+ GlStateManager.rotatef(180 + playerRotation, 0, 0, 1);
+ GlStateManager.translated(-PLAYER_ICON_WIDTH/2*iconScale, -PLAYER_ICON_HEIGHT/2*iconScale, 0);
AtlasRenderHelper.drawFullTexture(Textures.PLAYER, 0, 0,
(int)Math.round(PLAYER_ICON_WIDTH*iconScale), (int)Math.round(PLAYER_ICON_HEIGHT*iconScale));
GlStateManager.popMatrix();
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
}
// Draw buttons:
- super.drawScreen(mouseX, mouseY, par3);
+ super.a(mouseX, mouseY, par3);
// Draw the semi-transparent marker attached to the cursor when placing a new marker:
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (state.is(PLACING_MARKER)) {
- GlStateManager.color(1, 1, 1, 0.5f);
+ GlStateManager.color4f(1, 1, 1, 0.5f);
markerFinalizer.selectedType.calculateMip(iconScale, mapScale, screenScale);
MarkerRenderInfo renderInfo = markerFinalizer.selectedType.getRenderInfo(iconScale, mapScale, screenScale);
markerFinalizer.selectedType.resetMip();
@@ -799,26 +799,26 @@ public void drawScreen(int mouseX, int mouseY, float par3) {
renderInfo.tex,
mouseX + renderInfo.x, mouseY + renderInfo.y,
renderInfo.width, renderInfo.height);
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
}
// Draw progress overlay:
if (state.is(EXPORTING_IMAGE)) {
- drawDefaultBackground();
+ drawBackground();
progressBar.draw((width - 100)/2, height/2 - 34);
}
}
private void renderScaleOverlay(long deltaMillis) {
if(scaleAlpha > 0) {
- GlStateManager.translate(getGuiX() + WIDTH-13, getGuiY() + 12, 0);
+ GlStateManager.getTexLevelParameter(getGuiX() + WIDTH-13, getGuiY() + 12, 0);
String text;
int textWidth, xWidth;
text = "x";
- xWidth = textWidth = fontRenderer.getStringWidth(text); xWidth++;
- fontRenderer.drawString(text, -textWidth, 0, scaleAlpha << 24);
+ xWidth = textWidth = fontRenderer.a(text); xWidth++;
+ fontRenderer.a(text, -textWidth, 0, scaleAlpha << 24);
text = zoomNames[zoomLevel];
if(text.contains("/")) {
@@ -826,35 +826,35 @@ private void renderScaleOverlay(long deltaMillis) {
String[] parts = text.split("/");
text = parts[0];
- int centerXtranslate = Math.max(fontRenderer.getStringWidth(parts[0]), fontRenderer.getStringWidth(parts[1]) )/2;
- GlStateManager.translate(-xWidth-centerXtranslate, -fontRenderer.FONT_HEIGHT/2, 0);
+ int centerXtranslate = Math.max(fontRenderer.a(parts[0]), fontRenderer.a(parts[1]) )/2;
+ GlStateManager.getTexLevelParameter(-xWidth-centerXtranslate, -fontRenderer.a/2, 0);
- GlStateManager.disableTexture2D();
+ GlStateManager.disableTexture();
Tessellator t = Tessellator.getInstance();
- BufferBuilder vb = t.getBuffer();
- vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
- vb.pos( centerXtranslate, fontRenderer.FONT_HEIGHT - 1, 0.0D).endVertex();
- vb.pos(-centerXtranslate-1, fontRenderer.FONT_HEIGHT - 1, 0.0D).endVertex();
- vb.pos(-centerXtranslate-1, fontRenderer.FONT_HEIGHT , 0.0D).endVertex();
- vb.pos( centerXtranslate, fontRenderer.FONT_HEIGHT , 0.0D).endVertex();
+ BufferBuilder vb = t.getBufferBuilder();
+ vb.begin(GL11.GL_QUADS, VertexFormats.POSITION);
+ vb.vertex( centerXtranslate, fontRenderer.a - 1, 0.0D).d();
+ vb.vertex(-centerXtranslate-1, fontRenderer.a - 1, 0.0D).d();
+ vb.vertex(-centerXtranslate-1, fontRenderer.a , 0.0D).d();
+ vb.vertex( centerXtranslate, fontRenderer.a , 0.0D).d();
t.draw();
- GlStateManager.enableTexture2D();
- textWidth = fontRenderer.getStringWidth(text);
- fontRenderer.drawString(text, -textWidth/2, 0, scaleAlpha << 24);
+ GlStateManager.enableTexture();
+ textWidth = fontRenderer.a(text);
+ fontRenderer.a(text, -textWidth/2, 0, scaleAlpha << 24);
text = parts[1];
- GlStateManager.translate(0, fontRenderer.FONT_HEIGHT + 1, 0);
+ GlStateManager.getTexLevelParameter(0, fontRenderer.a + 1, 0);
- textWidth = fontRenderer.getStringWidth(text);
- fontRenderer.drawString(text, -textWidth/2, 0, scaleAlpha << 24);
+ textWidth = fontRenderer.a(text);
+ fontRenderer.a(text, -textWidth/2, 0, scaleAlpha << 24);
- GlStateManager.translate(xWidth+centerXtranslate, ( -fontRenderer.FONT_HEIGHT/2 ) -2, 0);
+ GlStateManager.getTexLevelParameter(xWidth+centerXtranslate, ( -fontRenderer.a/2 ) -2, 0);
} else {
- textWidth = fontRenderer.getStringWidth(text);
- fontRenderer.drawString(text, -textWidth-xWidth + 1, 1, scaleAlpha << 24);
+ textWidth = fontRenderer.a(text);
+ fontRenderer.a(text, -textWidth-xWidth + 1, 1, scaleAlpha << 24);
}
- GlStateManager.translate(-(getGuiX()+WIDTH-13), -(getGuiY()+12), 0);
+ GlStateManager.getTexLevelParameter(-(getGuiX()+WIDTH-13), -(getGuiY()+12), 0);
int deltaScaleAlpha = (int)(deltaMillis * 0.256);
// because of some crazy high frame rate
@@ -892,22 +892,22 @@ private void renderMarker(Marker marker, double scale) {
type.resetMip();
if (mouseIsOverMarker) {
- GlStateManager.color(0.5f, 0.5f, 0.5f, 1);
+ GlStateManager.color4f(0.5f, 0.5f, 0.5f, 1);
hoveredMarker = marker;
MinecraftForge.EVENT_BUS.post(new MarkerHoveredEvent(player, marker));
} else {
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
if (hoveredMarker == marker) {
hoveredMarker = null;
}
}
if (state.is(PLACING_MARKER)) {
- GlStateManager.color(1, 1, 1, 0.5f);
+ GlStateManager.color4f(1, 1, 1, 0.5f);
} else if (state.is(DELETING_MARKER) && marker.isGlobal()) {
- GlStateManager.color(1, 1, 1, 0.5f);
+ GlStateManager.color4f(1, 1, 1, 0.5f);
} else {
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
}
if (SettingsConfig.performance.debugRender){
@@ -920,18 +920,18 @@ private void renderMarker(Marker marker, double scale) {
markerY + info.y,
info.width, info.height);
if (isMouseOver && mouseIsOverMarker && marker.getLabel().length() > 0) {
- drawTooltip(Collections.singletonList(marker.getLocalizedLabel()), mc.fontRenderer);
+ drawTooltip(Collections.singletonList(marker.getLocalizedLabel()), mc.k);
}
}
@Override
- public boolean doesGuiPauseGame() {
+ public boolean d() {
return false;
}
@Override
- public void onGuiClosed() {
- super.onGuiClosed();
+ public void m() {
+ super.m();
removeChild(markerFinalizer);
removeChild(blinkingIcon);
Keyboard.enableRepeatEvents(false);
@@ -966,8 +966,8 @@ protected void onChildClosed(GuiComponent child) {
/** Update all text labels to current localization. */
public void updateL18n() {
- btnExportPng.setTitle(I18n.format("gui.antiqueatlas.exportImage"));
- btnMarker.setTitle(I18n.format("gui.antiqueatlas.addMarker"));
+ btnExportPng.setTitle(I18n.translate("gui.antiqueatlas.exportImage"));
+ btnMarker.setTitle(I18n.translate("gui.antiqueatlas.addMarker"));
}
/** Returns the scale of markers and player icon at given mapScale. */
@@ -977,6 +977,6 @@ private double getIconScale() {
/** Returns atlas id based on "itemNeeded" option */
private int getAtlasID() {
- return SettingsConfig.gameplay.itemNeeded ? stack.getItemDamage() : player.getUniqueID().hashCode();
+ return SettingsConfig.gameplay.itemNeeded ? stack.getDamage() : player.getUuid().hashCode();
}
}
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/GuiBookmarkButton.java b/src/main/java/hunternif/mc/atlas/client/gui/GuiBookmarkButton.java
index d4f372a67..4a9be7b3a 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/GuiBookmarkButton.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/GuiBookmarkButton.java
@@ -1,14 +1,14 @@
package hunternif.mc.atlas.client.gui;
+import com.mojang.blaze3d.platform.GlStateManager;
import hunternif.mc.atlas.client.Textures;
import hunternif.mc.atlas.client.gui.core.GuiToggleButton;
import hunternif.mc.atlas.util.AtlasRenderHelper;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.RenderHelper;
-import net.minecraft.util.ResourceLocation;
-
import java.util.Collections;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.render.GuiLighting;
+import net.minecraft.util.Identifier;
+
/** Bookmark-button in the journal. When a bookmark is selected, it will not
* bulge on mouseover. */
@@ -21,7 +21,7 @@ public class GuiBookmarkButton extends GuiToggleButton {
private static final int ICON_HEIGHT = 16;
private final int colorIndex;
- private ResourceLocation iconTexture;
+ private Identifier iconTexture;
private String title;
/**
@@ -29,14 +29,14 @@ public class GuiBookmarkButton extends GuiToggleButton {
* @param iconTexture the path to the 16x16 texture to be drawn on top of the bookmark.
* @param title hovering text.
*/
- GuiBookmarkButton(int colorIndex, ResourceLocation iconTexture, String title) {
+ GuiBookmarkButton(int colorIndex, Identifier iconTexture, String title) {
this.colorIndex = colorIndex;
setIconTexture(iconTexture);
setTitle(title);
setSize(WIDTH, HEIGHT);
}
- void setIconTexture(ResourceLocation iconTexture) {
+ void setIconTexture(Identifier iconTexture) {
this.iconTexture = iconTexture;
}
@@ -49,9 +49,9 @@ String getTitle() {
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTick) {
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- RenderHelper.disableStandardItemLighting();
+ public void a(int mouseX, int mouseY, float partialTick) {
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiLighting.disable();
// Render background:
int u = colorIndex * WIDTH;
@@ -64,7 +64,7 @@ public void drawScreen(int mouseX, int mouseY, float partialTick) {
getGuiY() + 1, ICON_WIDTH, ICON_HEIGHT);
if (isMouseOver) {
- drawTooltip(Collections.singletonList(title), Minecraft.getMinecraft().fontRenderer);
+ drawTooltip(Collections.singletonList(title), MinecraftClient.getInstance().textRenderer);
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/GuiMarkerFinalizer.java b/src/main/java/hunternif/mc/atlas/client/gui/GuiMarkerFinalizer.java
index c81921e5c..e523b7adb 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/GuiMarkerFinalizer.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/GuiMarkerFinalizer.java
@@ -8,15 +8,14 @@
import hunternif.mc.atlas.registry.MarkerType;
import hunternif.mc.atlas.registry.MarkerTypes;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiButton;
-import net.minecraft.client.gui.GuiTextField;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.world.World;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.widget.ButtonWidget;
+import net.minecraft.client.gui.widget.TextFieldWidget;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.world.World;
/**
* This GUI is used select marker icon and enter a label.
@@ -40,9 +39,9 @@ public class GuiMarkerFinalizer extends GuiComponent {
private static final int TYPE_SPACING = 1;
private static final int TYPE_BG_FRAME = 4;
- private GuiButton btnDone;
- private GuiButton btnCancel;
- private GuiTextField textField;
+ private ButtonWidget btnDone;
+ private ButtonWidget btnCancel;
+ private TextFieldWidget textField;
private final GuiScrollingContainer scroller;
private ToggleGroup typeRadioGroup;
@@ -76,16 +75,16 @@ void removeAllListeners() {
}
@Override
- public void initGui() {
- buttonList.add(btnDone = new GuiButton(0, this.width/2 - BUTTON_WIDTH - BUTTON_SPACING/2, this.height/2 + 40, BUTTON_WIDTH, 20, I18n.format("gui.done")));
- buttonList.add(btnCancel = new GuiButton(0, this.width/2 + BUTTON_SPACING/2, this.height/2 + 40, BUTTON_WIDTH, 20, I18n.format("gui.cancel")));
- textField = new GuiTextField(0, Minecraft.getMinecraft().fontRenderer, (this.width - 200)/2, this.height/2 - 81, 200, 20);
- textField.setFocused(true);
+ public void b() {
+ buttonList.add(btnDone = new ButtonWidget(0, this.width/2 - BUTTON_WIDTH - BUTTON_SPACING/2, this.height/2 + 40, BUTTON_WIDTH, 20, I18n.translate("gui.done")));
+ buttonList.add(btnCancel = new ButtonWidget(0, this.width/2 + BUTTON_SPACING/2, this.height/2 + 40, BUTTON_WIDTH, 20, I18n.translate("gui.cancel")));
+ textField = new TextFieldWidget(0, MinecraftClient.getInstance().XX_1_12_2_k_XX, (this.width - 200)/2, this.height/2 - 81, 200, 20);
+ textField.XX_1_12_2_b_XX(true);
textField.setText("");
scroller.removeAllContent();
int typeCount = 0;
- for (MarkerType type : MarkerRegistry.getValues()) {
+ for (MarkerType type : MarkerRegistry.iterable()) {
if(!type.isTechnical())
typeCount++;
}
@@ -103,7 +102,7 @@ public void initGui() {
}
});
int contentX = 0;
- for (MarkerType markerType : MarkerRegistry.getValues()) {
+ for (MarkerType markerType : MarkerRegistry.iterable()) {
if(markerType.isTechnical())
continue;
GuiMarkerInList markerGui = new GuiMarkerInList(markerType);
@@ -117,20 +116,20 @@ public void initGui() {
}
@Override
- protected void mouseClicked(int par1, int par2, int par3) throws IOException {
+ protected void a(int par1, int par2, int par3) throws IOException {
super.mouseClicked(par1, par2, par3);
- textField.mouseClicked(par1, par2, par3);
+ textField.XX_1_12_2_a_XX(par1, par2, par3);
}
@Override
- protected void keyTyped(char par1, int par2) throws IOException {
- super.keyTyped(par1, par2);
- textField.textboxKeyTyped(par1, par2);
+ protected void a(char par1, int par2) throws IOException {
+ super.a(par1, par2);
+ textField.XX_1_12_2_a_XX(par1, par2);
}
- protected void actionPerformed(GuiButton button) {
+ protected void a(ButtonWidget button) {
if (button == btnDone) {
- AtlasAPI.markers.putMarker(world, true, atlasID, selectedType.getRegistryName().toString(), textField.getText(), x, z);
+ AtlasAPI.markers.putMarker(world, true, atlasID, MarkerRegistry.getId(selectedType).toString(), textField.getText(), x, z);
Log.info("Put marker in Atlas #%d \"%s\" at (%d, %d)", atlasID, textField.getText(), x, z);
close();
} else if (button == btnCancel) {
@@ -139,18 +138,18 @@ protected void actionPerformed(GuiButton button) {
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTick) {
- drawDefaultBackground();
- drawCenteredString(I18n.format("gui.antiqueatlas.marker.label"), this.height/2 - 97, 0xffffff, true);
- textField.drawTextBox();
- drawCenteredString(I18n.format("gui.antiqueatlas.marker.type"), this.height/2 - 44, 0xffffff, true);
+ public void a(int mouseX, int mouseY, float partialTick) {
+ this.drawBackground();
+ drawCenteredString(I18n.translate("gui.antiqueatlas.marker.label"), this.height/2 - 97, 0xffffff, true);
+ textField.XX_1_12_2_g_XX();
+ drawCenteredString(I18n.translate("gui.antiqueatlas.marker.type"), this.height/2 - 44, 0xffffff, true);
// Darkrer background for marker type selector
drawGradientRect(scroller.getGuiX() - TYPE_BG_FRAME, scroller.getGuiY() - TYPE_BG_FRAME,
scroller.getGuiX() + scroller.getWidth() + TYPE_BG_FRAME,
scroller.getGuiY() + scroller.getHeight() + TYPE_BG_FRAME,
0x88101010, 0x99101010);
- super.drawScreen(mouseX, mouseY, partialTick);
+ super.a(mouseX, mouseY, partialTick);
}
interface IMarkerTypeSelectListener {
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/GuiMarkerInList.java b/src/main/java/hunternif/mc/atlas/client/gui/GuiMarkerInList.java
index 1d43382b5..50598bf8e 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/GuiMarkerInList.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/GuiMarkerInList.java
@@ -1,12 +1,12 @@
package hunternif.mc.atlas.client.gui;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.util.ResourceLocation;
-
+import com.mojang.blaze3d.platform.GlStateManager;
import hunternif.mc.atlas.client.Textures;
import hunternif.mc.atlas.client.gui.core.GuiToggleButton;
import hunternif.mc.atlas.registry.MarkerType;
import hunternif.mc.atlas.util.AtlasRenderHelper;
+import net.minecraft.util.Identifier;
+
public class GuiMarkerInList extends GuiToggleButton {
public static final int FRAME_SIZE = 34;
@@ -23,16 +23,16 @@ public MarkerType getMarkerType() {
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTick) {
- GlStateManager.color(1, 1, 1, 1);
+ public void a(int mouseX, int mouseY, float partialTick) {
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
AtlasRenderHelper.drawFullTexture(
isSelected() ? Textures.MARKER_FRAME_ON : Textures.MARKER_FRAME_OFF,
getGuiX(), getGuiY(), FRAME_SIZE, FRAME_SIZE);
- ResourceLocation texture = markerType.getIcon();
+ Identifier texture = markerType.getIcon();
if (texture != null) {
AtlasRenderHelper.drawFullTexture(texture, getGuiX() + 1, getGuiY() + 1, GuiAtlas.MARKER_SIZE, GuiAtlas.MARKER_SIZE);
}
- super.drawScreen(mouseX, mouseY, partialTick);
+ super.a(mouseX, mouseY, partialTick);
}
}
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/GuiPositionButton.java b/src/main/java/hunternif/mc/atlas/client/gui/GuiPositionButton.java
index a6f7973bc..897ee6289 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/GuiPositionButton.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/GuiPositionButton.java
@@ -1,15 +1,15 @@
package hunternif.mc.atlas.client.gui;
+import com.mojang.blaze3d.platform.GlStateManager;
import hunternif.mc.atlas.client.Textures;
import hunternif.mc.atlas.client.gui.core.GuiComponentButton;
import hunternif.mc.atlas.util.AtlasRenderHelper;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.RenderHelper;
-import net.minecraft.client.resources.I18n;
import org.lwjgl.opengl.GL11;
import java.util.Collections;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.render.GuiLighting;
+import net.minecraft.client.resource.language.I18n;
public class GuiPositionButton extends GuiComponentButton {
private static final int WIDTH = 11;
@@ -20,17 +20,17 @@ public GuiPositionButton() {
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTick) {
+ public void a(int mouseX, int mouseY, float partialTick) {
if (isEnabled()) {
- RenderHelper.disableStandardItemLighting();
+ GuiLighting.disable();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
int x = getGuiX(), y = getGuiY();
if (isMouseOver) {
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
} else {
- GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F);
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 0.5F);
}
AtlasRenderHelper.drawFullTexture(Textures.BTN_POSITION, x, y, WIDTH, HEIGHT);
@@ -38,7 +38,7 @@ public void drawScreen(int mouseX, int mouseY, float partialTick) {
GlStateManager.disableBlend();
if (isMouseOver) {
- drawTooltip(Collections.singletonList(I18n.format("gui.antiqueatlas.followPlayer")), Minecraft.getMinecraft().fontRenderer);
+ drawTooltip(Collections.singletonList(I18n.translate("gui.antiqueatlas.followPlayer")), MinecraftClient.getInstance().textRenderer);
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/GuiScaleBar.java b/src/main/java/hunternif/mc/atlas/client/gui/GuiScaleBar.java
index b4f1d8294..6b7502bb2 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/GuiScaleBar.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/GuiScaleBar.java
@@ -5,12 +5,12 @@
import hunternif.mc.atlas.client.Textures;
import hunternif.mc.atlas.client.gui.core.GuiComponent;
import hunternif.mc.atlas.util.AtlasRenderHelper;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.util.ResourceLocation;
-
import java.util.Collections;
import java.util.Map;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.util.Identifier;
+
/**
* A scale bar that displays pixel-to-block ratio. To fit into the overall
@@ -20,9 +20,9 @@ public class GuiScaleBar extends GuiComponent {
private static final int WIDTH = 20;
private static final int HEIGHT = 8;
- private static final Map textureMap;
+ private static final Map textureMap;
static {
- Builder builder = ImmutableMap.builder();
+ Builder builder = ImmutableMap.builder();
builder.put(0.0625, Textures.SCALEBAR_512);
builder.put(0.125, Textures.SCALEBAR_256);
builder.put(0.25, Textures.SCALEBAR_128);
@@ -45,19 +45,19 @@ void setMapScale(double scale) {
}
/** Returns the background texture depending on the scale. */
- private ResourceLocation getTexture() {
+ private Identifier getTexture() {
return textureMap.get(mapScale);
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTick) {
- ResourceLocation texture = getTexture();
+ public void a(int mouseX, int mouseY, float partialTick) {
+ Identifier texture = getTexture();
if (texture == null) return;
AtlasRenderHelper.drawFullTexture(texture, getGuiX(), getGuiY(), WIDTH, HEIGHT);
if (isMouseOver) {
- drawTooltip(Collections.singletonList(I18n.format("gui.antiqueatlas.scalebar")), Minecraft.getMinecraft().fontRenderer);
+ drawTooltip(Collections.singletonList(I18n.translate("gui.antiqueatlas.scalebar")), MinecraftClient.getInstance().textRenderer);
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/ProgressBarOverlay.java b/src/main/java/hunternif/mc/atlas/client/gui/ProgressBarOverlay.java
index 9ee01ec52..f91f13835 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/ProgressBarOverlay.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/ProgressBarOverlay.java
@@ -1,14 +1,13 @@
package hunternif.mc.atlas.client.gui;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.renderer.BufferBuilder;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import com.mojang.blaze3d.platform.GlStateManager;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.font.TextRenderer;
+import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.Tessellator;
+import net.minecraft.client.render.VertexFormats;
import org.lwjgl.opengl.GL11;
@@ -19,49 +18,49 @@ class ProgressBarOverlay {
/** Total height of the progress bar. */
private final int barHeight;
- private final FontRenderer font;
+ private final TextRenderer font;
- @SideOnly(Side.CLIENT)
+ @Environment(EnvType.CLIENT)
public ProgressBarOverlay(int barWidth, int barHeight) {
this.barWidth = barWidth;
this.barHeight = barHeight;
- font = Minecraft.getMinecraft().fontRenderer;
+ font = MinecraftClient.getInstance().textRenderer;
}
/** Render progress bar on the screen. */
- @SideOnly(Side.CLIENT)
+ @Environment(EnvType.CLIENT)
public void draw(int x, int y) {
ExportUpdateListener l = ExportUpdateListener.INSTANCE;
int headerWidth = font.getStringWidth(l.header);
- font.drawStringWithShadow(l.header, x + (barWidth - headerWidth)/2, y-14, 0xffffff);
+ font.draw(l.header, x + (barWidth - headerWidth)/2, y-14, 0xffffff);
int statusWidth = font.getStringWidth(l.status);
- font.drawStringWithShadow(l.status, x + (barWidth - statusWidth)/2, y, 0xffffff);
+ font.draw(l.status, x + (barWidth - statusWidth)/2, y, 0xffffff);
y += 14;
double p = l.currentProgress/l.maxProgress;
if(l.maxProgress < 0)
p = 0;
- GlStateManager.disableTexture2D();
+ GlStateManager.disableTexture();
Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder vb = tessellator.getBuffer();
+ BufferBuilder vb = tessellator.getBufferBuilder();
- vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
+ vb.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR);
- vb.pos(x, y, 0) .color(0.5f, 0.5f, 0.5f, 1).endVertex();
- vb.pos(x, y+barHeight, 0) .color(0.5f, 0.5f, 0.5f, 1).endVertex();
- vb.pos(x+barWidth, y+barHeight, 0) .color(0.5f, 0.5f, 0.5f, 1).endVertex();
- vb.pos(x+barWidth, y, 0) .color(0.5f, 0.5f, 0.5f, 1).endVertex();
+ vb.vertex(x, y, 0) .color(0.5f, 0.5f, 0.5f, 1).next();
+ vb.vertex(x, y+barHeight, 0) .color(0.5f, 0.5f, 0.5f, 1).next();
+ vb.vertex(x+barWidth, y+barHeight, 0) .color(0.5f, 0.5f, 0.5f, 1).next();
+ vb.vertex(x+barWidth, y, 0) .color(0.5f, 0.5f, 0.5f, 1).next();
- vb.pos(x, y, 0) .color(0.5f, 1, 0.5f, 1).endVertex();
- vb.pos(x, y+barHeight, 0) .color(0.5f, 1, 0.5f, 1).endVertex();
- vb.pos(x+barWidth*p, y+barHeight, 0).color(0.5f, 1, 0.5f, 1).endVertex();
- vb.pos(x+barWidth*p, y, 0) .color(0.5f, 1, 0.5f, 1).endVertex();
+ vb.vertex(x, y, 0) .color(0.5f, 1, 0.5f, 1).next();
+ vb.vertex(x, y+barHeight, 0) .color(0.5f, 1, 0.5f, 1).next();
+ vb.vertex(x+barWidth*p, y+barHeight, 0).color(0.5f, 1, 0.5f, 1).next();
+ vb.vertex(x+barWidth*p, y, 0) .color(0.5f, 1, 0.5f, 1).next();
tessellator.draw();
- GlStateManager.enableTexture2D();
+ GlStateManager.enableTexture();
}
}
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/core/AGuiScrollbar.java b/src/main/java/hunternif/mc/atlas/client/gui/core/AGuiScrollbar.java
index 385187977..edfd438bd 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/core/AGuiScrollbar.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/core/AGuiScrollbar.java
@@ -1,14 +1,13 @@
package hunternif.mc.atlas.client.gui.core;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.util.ResourceLocation;
-import org.lwjgl.input.Mouse;
+import net.minecraft.util.Identifier;
import org.lwjgl.opengl.GL11;
-
+import com.mojang.blaze3d.platform.GlStateManager;
import java.io.IOException;
+
public abstract class AGuiScrollbar extends GuiComponent {
- ResourceLocation texture;
+ Identifier texture;
int textureWidth;
int textureHeight;
/** Length of the non-scaling caps at the beginning and end of the anchor. */
@@ -53,7 +52,7 @@ public abstract class AGuiScrollbar extends GuiComponent {
* @param height height of the texture image
* @param capLength length of the non-scaling caps at the beginning and end of the anchor
*/
- public void setTexture(ResourceLocation texture, int width, int height, int capLength) {
+ public void setTexture(Identifier texture, int width, int height, int capLength) {
this.texture = texture;
this.textureWidth = width;
this.textureHeight = height;
@@ -112,8 +111,8 @@ private void doSetScrollRatio(float scrollRatio) {
}
@Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
+ public void k() throws IOException {
+ super.k();
if (usesWheel) {
int wheelMove = Mouse.getEventDWheel();
if (wheelMove != 0 && this.visible) {
@@ -124,7 +123,7 @@ public void handleMouseInput() throws IOException {
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTick) {
+ public void a(int mouseX, int mouseY, float partialTick) {
// Don't draw the anchor if there's nothing to scroll:
if (!visible) {
isDragged = false;
@@ -148,10 +147,10 @@ public void drawScreen(int mouseX, int mouseY, float partialTick) {
/ (float) (getScrollbarLength() - anchorSize));
}
- GlStateManager.enableTexture2D();
+ GlStateManager.enableTexture();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
drawAnchor();
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/core/GuiBlinkingImage.java b/src/main/java/hunternif/mc/atlas/client/gui/core/GuiBlinkingImage.java
index 0b34d33a3..f155699da 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/core/GuiBlinkingImage.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/core/GuiBlinkingImage.java
@@ -1,8 +1,9 @@
package hunternif.mc.atlas.client.gui.core;
+import com.mojang.blaze3d.platform.GlStateManager;
import hunternif.mc.atlas.util.AtlasRenderHelper;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.util.ResourceLocation;
+
+import net.minecraft.util.Identifier;
import org.lwjgl.opengl.GL11;
/** Displays a texture that changes alpha at regular intervals.
@@ -11,7 +12,7 @@
* @author Hunternif
*/
public class GuiBlinkingImage extends GuiComponent {
- private ResourceLocation texture;
+ private Identifier texture;
/** The number of milliseconds the icon spends visible or invisible. */
private long blinkTime = 500;
private float visibleAlpha = 1;
@@ -21,7 +22,7 @@ public class GuiBlinkingImage extends GuiComponent {
/** The flag that switches value every "blink". */
private boolean isVisible;
- public void setTexture(ResourceLocation texture, int width, int height) {
+ public void setTexture(Identifier texture, int width, int height) {
this.texture = texture;
setSize(width, height);
// Set up the timer so that the image appears visible at the first moment:
@@ -43,13 +44,13 @@ public void setInvisibleAlpha(float invisibleAlpha) {
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTick) {
+ public void a(int mouseX, int mouseY, float partialTick) {
long currentTime = System.currentTimeMillis();
if (lastTickTime + blinkTime < currentTime) {
lastTickTime = currentTime;
isVisible = !isVisible;
}
- GlStateManager.color(1, 1, 1, isVisible ? visibleAlpha : invisibleAlpha);
+ GlStateManager.color4f(1, 1, 1, isVisible ? visibleAlpha : invisibleAlpha);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
drawImage();
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/core/GuiComponent.java b/src/main/java/hunternif/mc/atlas/client/gui/core/GuiComponent.java
index 38ad7eb3e..b6bfd6350 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/core/GuiComponent.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/core/GuiComponent.java
@@ -1,11 +1,16 @@
package hunternif.mc.atlas.client.gui.core;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.GuiScreen;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.font.TextRenderer;
+import net.minecraft.client.gui.Screen;
+import net.minecraft.client.gui.ScreenComponent;
import net.minecraftforge.fml.client.config.GuiUtils;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+
+
+import none.XX_1_12_2_none_bip_XX;
+import none.XX_1_12_2_none_blk_XX;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -21,8 +26,8 @@
* keyboard events, window resize and will be moved around together with the
* parent component.
*/
-@SideOnly(Side.CLIENT)
-public class GuiComponent extends GuiScreen {
+@Environment(EnvType.CLIENT)
+public class GuiComponent extends Screen {
private GuiComponent parent = null;
private final List children = new CopyOnWriteArrayList<>();
@@ -178,7 +183,7 @@ private void doAddChild(GuiComponent inFrontOf, GuiComponent child, GuiComponent
child.parent = this;
child.setGuiCoords(guiX, guiY);
if (mc != null) {
- child.setWorldAndResolution(mc, width, height);
+ child.a(mc, width, height);
}
invalidateSize();
}
@@ -218,26 +223,26 @@ protected void setInterceptKeyboard(boolean value) {
}
@Override
- public void handleInput() throws IOException {
+ public void q() throws IOException {
// Traverse children backwards, because the topmost child should be the
// first to process input:
ListIterator iter = children.listIterator(children.size());
while(iter.hasPrevious()) {
GuiComponent child = iter.previous();
if (child.blocksScreen) {
- child.handleInput();
+ child.q();
isMouseOver = false;
return;
}
}
if (interceptsMouse) {
while (Mouse.next()) {
- this.handleMouseInput();
+ this.k();
}
}
if (interceptsKeyboard) {
while (Keyboard.next()) {
- this.handleKeyboardInput();
+ this.l();
}
}
}
@@ -262,7 +267,7 @@ protected void setBlocksScreen(boolean value) {
/** Handle mouse input for this GUI and its children. */
@Override
- public void handleMouseInput() throws IOException {
+ public void k() throws IOException {
boolean handled = false;
isMouseOver = false;
// Traverse children backwards, because the topmost child should be the
@@ -270,7 +275,7 @@ public void handleMouseInput() throws IOException {
ListIterator iter = children.listIterator(children.size());
while(iter.hasPrevious()) {
GuiComponent child = iter.previous();
- child.handleMouseInput();
+ child.k();
if (child.hasHandledMouse) {
child.hasHandledMouse = false;
handled = true;
@@ -278,20 +283,20 @@ public void handleMouseInput() throws IOException {
}
if (!handled) {
isMouseOver = isMouseInRegion(getGuiX(), getGuiY(), getWidth(), getHeight());
- super.handleMouseInput();
+ super.k();
}
}
/** Handle keyboard input for this GUI and its children. */
@Override
- public void handleKeyboardInput() throws IOException {
+ public void l() throws IOException {
boolean handled = false;
// Traverse children backwards, because the topmost child should be the
// first to process input:
ListIterator iter = children.listIterator(children.size());
while(iter.hasPrevious()) {
GuiComponent child = iter.previous();
- child.handleKeyboardInput();
+ child.l();
if (child.hasHandledKeyboard) {
child.hasHandledKeyboard = false;
handled = true;
@@ -299,31 +304,31 @@ public void handleKeyboardInput() throws IOException {
}
if (!handled) {
if (Keyboard.getEventKeyState()) {
- this.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+ this.a(Keyboard.getEventCharacter(), Keyboard.getEventKey());
}
}
}
@Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- if (keyCode == 1 && mc.currentScreen != null)
+ protected void a(char typedChar, int keyCode) throws IOException {
+ if (keyCode == 1 && mc.m != null)
{
- this.mc.displayGuiScreen((GuiScreen)null);
+ this.client.openScreen(null);
- if (this.mc.currentScreen == null)
+ if (this.mc.m == null)
{
- this.mc.setIngameFocus();
+ this.mc.o();
}
}
}
/** Render this GUI and its children. */
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTick) {
- super.drawScreen(mouseX, mouseY, partialTick);
+ public void a(int mouseX, int mouseY, float partialTick) {
+ super.a(mouseX, mouseY, partialTick);
for (GuiComponent child : children) {
if (!child.isClipped) {
- child.drawScreen(mouseX, mouseY, partialTick);
+ child.a(mouseX, mouseY, partialTick);
}
}
// Draw any hovering text requested by child components:
@@ -335,32 +340,32 @@ public void drawScreen(int mouseX, int mouseY, float partialTick) {
/** Called when the GUI is unloaded, called for each child as well. */
@Override
- public void onGuiClosed() {
+ public void m() {
for (GuiComponent child : children) {
- child.onGuiClosed();
+ child.m();
}
- super.onGuiClosed();
+ super.m();
}
/** Called each in-game tick for this GUI and its children. If this GUI's
* size has been invalidated, it will be validated on the next update. */
@Override
- public void updateScreen() {
+ public void e() {
for (GuiComponent child : children) {
- child.updateScreen();
+ child.e();
}
- super.updateScreen();
+ super.e();
if (sizeIsInvalid) {
validateSize();
}
}
@Override
- public void setWorldAndResolution(Minecraft mc, int width, int height) {
- super.setWorldAndResolution(mc, width, height);
+ public void a(MinecraftClient mc, int width, int height) {
+ super.a(mc, width, height);
for (GuiComponent child : children) {
- child.setWorldAndResolution(mc, width, height);
+ child.a(mc, width, height);
}
}
@@ -440,7 +445,7 @@ protected boolean isMouseInRadius(int x, int y, int radius) {
/** Draws a standard Minecraft hovering text window, constrained by this
* component's dimensions (i.e. if it won't fit in when drawn to the left
* of the cursor, it will be drawn to the right instead). */
- private void drawHoveringText2(List lines, int x, int y, FontRenderer font) {
+ private void drawHoveringText2(List lines, int x, int y, XX_1_12_2_none_bip_XX font) {
boolean stencilEnabled = GL11.glIsEnabled(GL11.GL_STENCIL_TEST);
if (stencilEnabled) GL11.glDisable(GL11.GL_STENCIL_TEST);
@@ -472,7 +477,7 @@ private GuiComponent getTopLevelParent() {
* from several components which occupy the same position on the screen.
*
* */
- protected void drawTooltip(List lines, FontRenderer font) {
+ protected void drawTooltip(List lines, TextRenderer font) {
GuiComponent topLevel = getTopLevelParent();
topLevel.hoveringTextInfo.lines = lines;
topLevel.hoveringTextInfo.x = getMouseX();
@@ -488,7 +493,7 @@ protected void drawTooltip(List lines, FontRenderer font) {
private static class HoveringTextInfo {
List lines;
int x, y;
- FontRenderer font;
+ TextRenderer font;
/** Whether to draw this hovering text during rendering current frame.
* This flag is reset to false after rendering finishes. */
boolean shouldDraw = false;
@@ -499,7 +504,7 @@ public void close() {
if (parent != null) {
parent.removeChild(this); // This sets parent to null
} else {
- Minecraft.getMinecraft().displayGuiScreen(null);
+ MinecraftClient.getInstance().openScreen(null);
}
}
@@ -508,14 +513,14 @@ protected void onChildClosed(GuiComponent child) {}
/** Draw a text string centered horizontally, using this GUI's FontRenderer. */
protected void drawCenteredString(String text, int y, int color, boolean dropShadow) {
- int length = fontRenderer.getStringWidth(text);
- fontRenderer.drawString(text, (this.width - length)/2, y, color, dropShadow);
+ int length = fontRenderer.a(text);
+ fontRenderer.a(text, (this.width - length)/2, y, color, dropShadow);
}
protected int getMouseX() {
- return Mouse.getX() * width / mc.displayWidth;
+ return Mouse.getX() * width / mc.d;
}
protected int getMouseY() {
- return height - Mouse.getY() * height / mc.displayHeight - 1;
+ return height - Mouse.getY() * height / mc.e - 1;
}
}
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/core/GuiComponentButton.java b/src/main/java/hunternif/mc/atlas/client/gui/core/GuiComponentButton.java
index 88b079e8f..2be67707c 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/core/GuiComponentButton.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/core/GuiComponentButton.java
@@ -1,12 +1,11 @@
package hunternif.mc.atlas.client.gui.core;
-import net.minecraft.client.audio.PositionedSoundRecord;
-import net.minecraft.init.SoundEvents;
-import net.minecraft.util.SoundEvent;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import net.minecraft.client.audio.PositionedSoundInstance;
+import net.minecraft.sound.SoundEvent;
+import net.minecraft.sound.SoundEvents;
/** A GuiComponent that can act like a button. */
public class GuiComponentButton extends GuiComponent {
@@ -31,7 +30,7 @@ public void mute() {
}
@Override
- protected void mouseClicked(int x, int y, int mouseButton) throws IOException {
+ protected void a(int x, int y, int mouseButton) throws IOException {
super.mouseClicked(x, y, mouseButton);
if (mouseButton == 0 /*left-click*/ && enabled && isMouseOver) {
onClick();
@@ -43,7 +42,8 @@ protected void mouseClicked(int x, int y, int mouseButton) throws IOException {
@SuppressWarnings("unchecked")
void onClick() {
if (clickSound != null) {
- mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(clickSound, 1.0F));//.playSound(new PositionedSoundRecord(clickSound, 1.0F));
+ // TODO FABRIC gui instead of master??
+ client.getSoundLoader().play(PositionedSoundInstance.master(clickSound, 1.0F));
}
for (IButtonListener listener : listeners) {
listener.onClick(this);
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/core/GuiCursor.java b/src/main/java/hunternif/mc/atlas/client/gui/core/GuiCursor.java
index 6b4f3d5b4..ae5a22fdc 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/core/GuiCursor.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/core/GuiCursor.java
@@ -1,7 +1,8 @@
package hunternif.mc.atlas.client.gui.core;
import hunternif.mc.atlas.util.AtlasRenderHelper;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.Identifier;
+
/**
* A GUI element that follows the mouse cursor and is meant to replace it.
@@ -9,7 +10,7 @@
*/
public class GuiCursor extends GuiComponent {
- private ResourceLocation texture;
+ private Identifier texture;
private int textureWidth, textureHeight;
/** Coordinates of the cursor point on the texture. */
private int pointX, pointY;
@@ -21,7 +22,7 @@ public class GuiCursor extends GuiComponent {
* @param pointX X of the cursor point on the image
* @param pointY Y of the cursor point on the image
*/
- public void setTexture(ResourceLocation texture, int width, int height, int pointX, int pointY) {
+ public void setTexture(Identifier texture, int width, int height, int pointX, int pointY) {
this.texture = texture;
this.textureWidth = width;
this.textureHeight = height;
@@ -40,7 +41,7 @@ public int getHeight() {
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTick) {
+ public void a(int mouseX, int mouseY, float partialTick) {
AtlasRenderHelper.drawFullTexture(texture, mouseX - pointX, mouseY - pointY, textureWidth, textureHeight);
}
}
diff --git a/src/main/java/hunternif/mc/atlas/client/gui/core/GuiViewport.java b/src/main/java/hunternif/mc/atlas/client/gui/core/GuiViewport.java
index c85559aea..678c76db2 100644
--- a/src/main/java/hunternif/mc/atlas/client/gui/core/GuiViewport.java
+++ b/src/main/java/hunternif/mc/atlas/client/gui/core/GuiViewport.java
@@ -1,9 +1,9 @@
package hunternif.mc.atlas.client.gui.core;
-import net.minecraft.client.gui.ScaledResolution;
import org.lwjgl.opengl.GL11;
import java.io.IOException;
+import none.XX_1_12_2_none_bit_XX;
/**
* The children of this component are rendered and process input only inside
@@ -35,28 +35,28 @@ public void removeAllContent() {
}
@Override
- public void initGui() {
- super.initGui();
- screenScale = new ScaledResolution(mc).getScaleFactor();
+ public void onInitialized() {
+ super.onInitialized();
+ screenScale = new XX_1_12_2_none_bit_XX(mc).e();
}
@Override
- public void drawScreen(int mouseX, int mouseY, float par3) {
+ public void a(int mouseX, int mouseY, float par3) {
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor( getGuiX()*screenScale,
- mc.displayHeight - (getGuiY() + properHeight)*screenScale,
+ mc.e - (getGuiY() + properHeight)*screenScale,
properWidth*screenScale, properHeight*screenScale);
// Draw the content (child GUIs):
- super.drawScreen(mouseX, mouseY, par3);
+ super.a(mouseX, mouseY, par3);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
@Override
- public void handleMouseInput() throws IOException {
+ public void k() throws IOException {
if (isMouseInRegion(getGuiX(), getGuiY(), properWidth, properHeight)) {
- super.handleMouseInput();
+ super.k();
}
}
diff --git a/src/main/java/hunternif/mc/atlas/core/AtlasData.java b/src/main/java/hunternif/mc/atlas/core/AtlasData.java
index a066b6173..3874cae45 100644
--- a/src/main/java/hunternif/mc/atlas/core/AtlasData.java
+++ b/src/main/java/hunternif/mc/atlas/core/AtlasData.java
@@ -7,20 +7,25 @@
import hunternif.mc.atlas.network.server.BrowsingPositionPacket;
import hunternif.mc.atlas.util.Log;
import hunternif.mc.atlas.util.ShortVec2;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
+import net.fabricmc.fabric.api.util.NbtType;
+import net.minecraft.client.network.packet.LoginSuccessS2CPacket;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.PersistentState;
+import net.minecraft.world.ViewableWorld;
+import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
-import net.minecraft.world.storage.WorldSavedData;
-import net.minecraftforge.common.util.Constants;
-
+import net.minecraft.world.dimension.DimensionType;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
-public class AtlasData extends WorldSavedData {
+public class AtlasData extends PersistentState {
public static final int VERSION = 3;
public static final String TAG_VERSION = "aaVersion";
public static final String TAG_DIMENSION_MAP_LIST = "qDimensionMap";
@@ -33,7 +38,7 @@ public class AtlasData extends WorldSavedData {
public static final String TAG_BROWSING_ZOOM = "qBrowseZoom";
/** Maps dimension ID to biomeAnalyzer. */
- private final Map biomeAnalyzers = new HashMap<>();
+ private final Map biomeAnalyzers = new HashMap<>();
private final BiomeDetectorBase biomeDetectorOverworld = new BiomeDetectorBase();
private final BiomeDetectorNether biomeDetectorNether = new BiomeDetectorNether();
private final BiomeDetectorEnd biomeDetectorEnd = new BiomeDetectorEnd();
@@ -41,108 +46,119 @@ public class AtlasData extends WorldSavedData {
/** This map contains, for each dimension, a map of chunks the player
* has seen. This map is thread-safe.
* CAREFUL! Don't modify chunk coordinates that are already put in the map! */
- private final Map dimensionMap =
+ private final Map dimensionMap =
new ConcurrentHashMap<>(2, 0.75f, 2);
/** Set of players this Atlas data has been sent to. */
- private final Set playersSentTo = new HashSet<>();
+ private final Set playersSentTo = new HashSet<>();
- private NBTTagCompound nbt;
+ private CompoundTag nbt;
public AtlasData(String key) {
super(key);
biomeDetectorOverworld.setScanPonds(SettingsConfig.performance.doScanPonds);
biomeDetectorOverworld.setScanRavines(SettingsConfig.performance.doScanRavines);
- setBiomeDetectorForDimension(0, biomeDetectorOverworld);
- setBiomeDetectorForDimension(-1, biomeDetectorNether);
- setBiomeDetectorForDimension(1, biomeDetectorEnd);
+ setBiomeDetectorForDimension(DimensionType.OVERWORLD, biomeDetectorOverworld);
+ setBiomeDetectorForDimension(DimensionType.THE_NETHER, biomeDetectorNether);
+ setBiomeDetectorForDimension(DimensionType.THE_END, biomeDetectorEnd);
}
@Override
- public void readFromNBT(NBTTagCompound compound) {
+ public void fromTag(CompoundTag compound) {
this.nbt = compound;
- int version = compound.getInteger(TAG_VERSION);
+ int version = compound.getInt(TAG_VERSION);
if (version < VERSION) {
Log.warn("Outdated atlas data format! Was %d but current is %d. Updating.", version, VERSION);
readFromNBT2(compound);
return;
}
- NBTTagList dimensionMapList = compound.getTagList(TAG_DIMENSION_MAP_LIST, Constants.NBT.TAG_COMPOUND);
- for (int d = 0; d < dimensionMapList.tagCount(); d++) {
- NBTTagCompound dimTag = dimensionMapList.getCompoundTagAt(d);
- int dimensionID = dimTag.getInteger(TAG_DIMENSION_ID);
- NBTTagList dimensionTag = (NBTTagList) dimTag.getTag(TAG_VISITED_CHUNKS);
+ ListTag dimensionMapList = compound.getList(TAG_DIMENSION_MAP_LIST, NbtType.COMPOUND);
+ for (int d = 0; d < dimensionMapList.size(); d++) {
+ CompoundTag dimTag = dimensionMapList.getCompoundTag(d);
+ DimensionType dimensionID;
+ if (dimTag.containsKey(TAG_DIMENSION_ID, NbtType.NUMBER)) {
+ dimensionID = Registry.DIMENSION.get(dimTag.getInt(TAG_DIMENSION_ID));
+ } else {
+ dimensionID = Registry.DIMENSION.get(new Identifier(dimTag.getString(TAG_DIMENSION_ID)));
+ }
+ ListTag dimensionTag = (ListTag) dimTag.getTag(TAG_VISITED_CHUNKS);
DimensionData dimData = getDimensionData(dimensionID);
dimData.readFromNBT(dimensionTag);
- double zoom = (double)dimTag.getInteger(TAG_BROWSING_ZOOM) / BrowsingPositionPacket.ZOOM_SCALE_FACTOR;
+ double zoom = (double)dimTag.getInt(TAG_BROWSING_ZOOM) / BrowsingPositionPacket.ZOOM_SCALE_FACTOR;
if (zoom == 0) zoom = 0.5;
- dimData.setBrowsingPosition(dimTag.getInteger(TAG_BROWSING_X),
- dimTag.getInteger(TAG_BROWSING_Y), zoom);
+ dimData.setBrowsingPosition(dimTag.getInt(TAG_BROWSING_X),
+ dimTag.getInt(TAG_BROWSING_Y), zoom);
}
}
/**Reads from NBT version 2. This is designed to allow easy upgrading to version 3.*/
- public void readFromNBT2(NBTTagCompound compound) {
+ public void readFromNBT2(CompoundTag compound) {
this.nbt = compound;
- int version = compound.getInteger(TAG_VERSION);
+ int version = compound.getInt(TAG_VERSION);
if (version < 2) {
Log.warn("Loading map with version 2 failed");
this.markDirty();
return;
}
- NBTTagList dimensionMapList = compound.getTagList(TAG_DIMENSION_MAP_LIST, Constants.NBT.TAG_COMPOUND);
- for (int d = 0; d < dimensionMapList.tagCount(); d++) {
- NBTTagCompound dimTag = dimensionMapList.getCompoundTagAt(d);
- int dimensionID = dimTag.getInteger(TAG_DIMENSION_ID);
+ ListTag dimensionMapList = compound.getList(TAG_DIMENSION_MAP_LIST, NbtType.COMPOUND);
+ for (int d = 0; d < dimensionMapList.size(); d++) {
+ CompoundTag dimTag = dimensionMapList.getCompoundTag(d);
+ DimensionType dimensionID;
+ if (dimTag.containsKey(TAG_DIMENSION_ID, NbtType.NUMBER)) {
+ dimensionID = Registry.DIMENSION.get(dimTag.getInt(TAG_DIMENSION_ID));
+ } else {
+ dimensionID = Registry.DIMENSION.get(new Identifier(dimTag.getString(TAG_DIMENSION_ID)));
+ }
int[] intArray = dimTag.getIntArray(TAG_VISITED_CHUNKS);
DimensionData dimData = getDimensionData(dimensionID);
for (int i = 0; i < intArray.length; i += 3) {
if (dimData.getTile(intArray[i], intArray[i+1]) != null){
Log.warn("Duplicate tile at "+ intArray[i] + ", " + intArray[i]);
}
- dimData.setTile(intArray[i], intArray[i+1], new Tile(intArray[i+2]));
+ // TODO FABRIC remove int
+ dimData.setTile(intArray[i], intArray[i+1], TileKindFactory.get(intArray[i + 2]));
}
Log.info("Updated " + intArray.length/3 + " chunks");
- double zoom = (double)dimTag.getInteger(TAG_BROWSING_ZOOM) / BrowsingPositionPacket.ZOOM_SCALE_FACTOR;
+ double zoom = (double)dimTag.getInt(TAG_BROWSING_ZOOM) / BrowsingPositionPacket.ZOOM_SCALE_FACTOR;
if (zoom == 0) zoom = 0.5;
- dimData.setBrowsingPosition(dimTag.getInteger(TAG_BROWSING_X),
- dimTag.getInteger(TAG_BROWSING_Y), zoom);
+ dimData.setBrowsingPosition(dimTag.getInt(TAG_BROWSING_X),
+ dimTag.getInt(TAG_BROWSING_Y), zoom);
}
}
@Override
- public NBTTagCompound writeToNBT(NBTTagCompound compound) {
+ public CompoundTag toTag(CompoundTag compound) {
return writeToNBT(compound, true);
}
- public NBTTagCompound writeToNBT(NBTTagCompound compound, boolean includeTileData) {
- NBTTagList dimensionMapList = new NBTTagList();
- compound.setInteger(TAG_VERSION, VERSION);
- for (Entry dimensionEntry : dimensionMap.entrySet()) {
- NBTTagCompound dimTag = new NBTTagCompound();
- dimTag.setInteger(TAG_DIMENSION_ID, dimensionEntry.getKey());
+ public CompoundTag writeToNBT(CompoundTag compound, boolean includeTileData) {
+ ListTag dimensionMapList = new ListTag();
+ compound.putInt(TAG_VERSION, VERSION);
+ for (Entry dimensionEntry : dimensionMap.entrySet()) {
+ CompoundTag dimTag = new CompoundTag();
+ dimTag.putString(TAG_DIMENSION_ID, Registry.DIMENSION.getId(dimensionEntry.getKey()).toString());
DimensionData dimData = dimensionEntry.getValue();
if (includeTileData){
- dimTag.setTag(TAG_VISITED_CHUNKS, dimData.writeToNBT());
+ dimTag.put(TAG_VISITED_CHUNKS, dimData.writeToNBT());
}
- dimTag.setInteger(TAG_BROWSING_X, dimData.getBrowsingX());
- dimTag.setInteger(TAG_BROWSING_Y, dimData.getBrowsingY());
- dimTag.setInteger(TAG_BROWSING_ZOOM, (int)Math.round(dimData.getBrowsingZoom() * BrowsingPositionPacket.ZOOM_SCALE_FACTOR));
- dimensionMapList.appendTag(dimTag);
+ dimTag.putInt(TAG_BROWSING_X, dimData.getBrowsingX());
+ dimTag.putInt(TAG_BROWSING_Y, dimData.getBrowsingY());
+ dimTag.putInt(TAG_BROWSING_ZOOM, (int)Math.round(dimData.getBrowsingZoom() * BrowsingPositionPacket.ZOOM_SCALE_FACTOR));
+ dimensionMapList.add(dimTag);
}
- compound.setTag(TAG_DIMENSION_MAP_LIST, dimensionMapList);
+ compound.put(TAG_DIMENSION_MAP_LIST, dimensionMapList);
return compound;
}
- private void setBiomeDetectorForDimension(int dimension, IBiomeDetector biomeAnalyzer) {
+ private void setBiomeDetectorForDimension(DimensionType dimension, IBiomeDetector biomeAnalyzer) {
biomeAnalyzers.put(dimension, biomeAnalyzer);
}
/** If not found, returns the analyzer for overworld. */
- private IBiomeDetector getBiomeDetectorForDimension(int dimension) {
+ private IBiomeDetector getBiomeDetectorForDimension(DimensionType dimension) {
IBiomeDetector biomeAnalyzer = biomeAnalyzers.get(dimension);
return biomeAnalyzer == null ? biomeDetectorOverworld : biomeAnalyzer;
@@ -151,23 +167,23 @@ private IBiomeDetector getBiomeDetectorForDimension(int dimension) {
/**Updates map data around player
*
* @return A set of the new tiles, mostly so the server can synch those with relavent clients.*/
- public ArrayList updateMapAroundPlayer(EntityPlayer player) {
+ public ArrayList updateMapAroundPlayer(PlayerEntity player) {
// Update the actual map only so often:
ArrayList updatedTiles = new ArrayList();
int newScanInterval = Math.round(SettingsConfig.performance.newScanInterval * 20);
int rescanInterval = newScanInterval * SettingsConfig.performance.rescanRate;
- if (player.ticksExisted % newScanInterval != 0) {
+ if (player.getEntityWorld().getTime() % newScanInterval != 0) {
return updatedTiles;//no new tiles
}
- int playerX = MathHelper.floor(player.posX) >> 4;
- int playerZ = MathHelper.floor(player.posZ) >> 4;
+ int playerX = MathHelper.floor(player.x) >> 4;
+ int playerZ = MathHelper.floor(player.z) >> 4;
ITileStorage seenChunks = this.getDimensionData(player.dimension);
IBiomeDetector biomeDetector = getBiomeDetectorForDimension(player.dimension);
int scanRadius = SettingsConfig.performance.scanRadius;
- final boolean rescanRequired = SettingsConfig.performance.doRescan && player.ticksExisted % rescanInterval == 0;
+ final boolean rescanRequired = SettingsConfig.performance.doRescan && player.getEntityWorld().getTime() % rescanInterval == 0;
// Look at chunks around in a circular area:
for (double dx = -scanRadius; dx <= scanRadius; dx++) {
@@ -178,25 +194,29 @@ public ArrayList updateMapAroundPlayer(EntityPlayer player) {
int x = (int)(playerX + dx);
int z = (int)(playerZ + dz);
- Tile oldTile = seenChunks.getTile(x, z);
+ TileKind oldTile = seenChunks.getTile(x, z);
+ TileKind tile = null;
// Check if there's a custom tile at the location:
- int biomeId = AntiqueAtlasMod.extBiomeData.getData().getBiomeIdAt(player.dimension, x, z);
// Custom tiles overwrite even the chunks already seen.
+ int customTileId = AntiqueAtlasMod.extBiomeData.getData().getBiomeAt(player.dimension, x, z);
+ if (customTileId != -1) {
+ tile = TileKindFactory.get(customTileId);
+ }
// If there's no custom tile, check the actual chunk:
- if (biomeId == -1) {
+ if (tile == null) {
// If the chunk has been scanned previously, only re-scan it so often:
if (oldTile != null && !rescanRequired) {
continue;
}
- Chunk chunk = player.getEntityWorld().getChunkProvider().getLoadedChunk(x, z);
+ Chunk chunk = player.getEntityWorld().getChunk(x, z);
// Force loading of chunk, if required:
-
- if (SettingsConfig.performance.forceChunkLoading && chunk == null) {
- chunk = player.getEntityWorld().getChunkProvider().provideChunk(x, z);
- }
+ // TODO FABRIC
+ /* if (SettingsConfig.performance.forceChunkLoading && chunk == null) {
+ chunk = player.getEntityWorld().B().c(x, z);
+ } */
// Skip chunk if it hasn't loaded yet:
if (chunk == null) {
@@ -204,29 +224,29 @@ public ArrayList updateMapAroundPlayer(EntityPlayer player) {
}
if (oldTile != null) {
- biomeId = biomeDetector.getBiomeID(chunk);
+ tile = biomeDetector.getBiomeID(chunk);
- if (biomeId == IBiomeDetector.NOT_FOUND) {
+ if (tile == null) {
// If the new tile is empty, remove the old one:
this.removeTile(player.dimension, x, z);
- } else if (oldTile.biomeID != biomeId) {
+ } else if (oldTile != tile) {
// Only update if the old tile's biome ID doesn't match the new one:
- this.setTile(player.dimension, x, z, new Tile(biomeId));
- updatedTiles.add(new TileInfo(x, z, biomeId));
+ this.setTile(player.dimension, x, z, tile);
+ updatedTiles.add(new TileInfo(x, z, tile));
}
} else {
// Scanning new chunk:
- biomeId = biomeDetector.getBiomeID(chunk);
- if (biomeId != IBiomeDetector.NOT_FOUND) {
- this.setTile(player.dimension, x, z, new Tile(biomeId));
- updatedTiles.add(new TileInfo(x, z, biomeId));
+ tile = biomeDetector.getBiomeID(chunk);
+ if (tile != null) {
+ this.setTile(player.dimension, x, z, tile);
+ updatedTiles.add(new TileInfo(x, z, tile));
}
}
} else {
// Only update the custom tile if it doesn't rewrite itself:
- if (oldTile == null || oldTile.biomeID != biomeId) {
- this.setTile(player.dimension, x, z, new Tile(biomeId));
- updatedTiles.add(new TileInfo(x, z, biomeId));
+ if (oldTile == null || oldTile != tile) {
+ this.setTile(player.dimension, x, z, tile);
+ updatedTiles.add(new TileInfo(x, z, tile));
this.markDirty();
}
}
@@ -238,58 +258,58 @@ public ArrayList updateMapAroundPlayer(EntityPlayer player) {
/** Puts a given tile into given map at specified coordinates and,
* if tileStitcher is present, sets appropriate sectors on adjacent tiles. */
- public void setTile(int dimension, int x, int y, Tile tile) {
+ public void setTile(DimensionType dimension, int x, int y, TileKind tile) {
DimensionData dimData = getDimensionData(dimension);
dimData.setTile(x, y, tile);
}
/** Returns the Tile previously set at given coordinates. */
- private Tile removeTile(int dimension, int x, int y) {
+ private TileKind removeTile(DimensionType dimension, int x, int y) {
DimensionData dimData = getDimensionData(dimension);
return dimData.removeTile(x, y);
}
- public Set getVisitedDimensions() {
+ public Set getVisitedDimensions() {
return dimensionMap.keySet();
}
/* TODO: Packet Rework
* Dimension data should check the server for updates*/
/** If this dimension is not yet visited, empty DimensionData will be created. */
- public DimensionData getDimensionData(int dimension) {
+ public DimensionData getDimensionData(DimensionType dimension) {
return dimensionMap.computeIfAbsent(dimension, k -> new DimensionData(this, dimension));
}
- public Map getSeenChunksInDimension(int dimension) {
+ public Map getSeenChunksInDimension(DimensionType dimension) {
return getDimensionData(dimension).getSeenChunks();
}
/** The set of players this AtlasData has already been sent to. */
- public Collection getSyncedPlayers() {
+ public Collection getSyncedPlayers() {
return Collections.unmodifiableCollection(playersSentTo);
}
/** Whether this AtlasData has already been sent to the specified player. */
- public boolean isSyncedOnPlayer(EntityPlayer player) {
+ public boolean isSyncedOnPlayer(PlayerEntity player) {
return playersSentTo.contains(player);
}
/** Send all data to the player in several zipped packets. Called once
* during the first run of ItemAtals.onUpdate(). */
- public void syncOnPlayer(int atlasID, EntityPlayer player) {
+ public void syncOnPlayer(int atlasID, PlayerEntity player) {
if (nbt == null) {
- nbt = new NBTTagCompound();
+ nbt = new CompoundTag();
}
// Before syncing make sure the changes are written to the nbt.
// Do not include dimension tile data. This will happen later.
writeToNBT(nbt, false);
- PacketDispatcher.sendTo(new MapDataPacket(atlasID, nbt), (EntityPlayerMP) player);
+ PacketDispatcher.sendTo(new MapDataPacket(atlasID, nbt), (ServerPlayerEntity) player);
- for (Integer i: dimensionMap.keySet()){
+ for (DimensionType i : dimensionMap.keySet()){
dimensionMap.get(i).syncOnPlayer(atlasID, player);
}
- Log.info("Sent Atlas #%d data to player %s", atlasID, player.getName());
+ Log.info("Sent Atlas #%d data to player %s", atlasID, player.getCommandSource().getName());
playersSentTo.add(player);
}
@@ -301,8 +321,9 @@ public boolean isEmpty() {
public boolean equals(Object obj) {
if (!(obj instanceof AtlasData)) return false;
AtlasData other = (AtlasData) obj;
+ // TODO: This doesn't handle disjoint DimensionType keysets of equal size
if (other.dimensionMap.size()!=dimensionMap.size()) return false;
- for (Integer key: dimensionMap.keySet()){
+ for (DimensionType key : dimensionMap.keySet()){
if (!dimensionMap.get(key).equals(other.dimensionMap.get(key))) return false;
}
return true;
diff --git a/src/main/java/hunternif/mc/atlas/core/AtlasDataHandler.java b/src/main/java/hunternif/mc/atlas/core/AtlasDataHandler.java
index b0eea99d7..b881407b5 100644
--- a/src/main/java/hunternif/mc/atlas/core/AtlasDataHandler.java
+++ b/src/main/java/hunternif/mc/atlas/core/AtlasDataHandler.java
@@ -2,10 +2,9 @@
import hunternif.mc.atlas.RegistrarAntiqueAtlas;
import net.minecraft.item.ItemStack;
+import net.minecraft.server.world.ServerWorld;
+import net.minecraft.world.PersistentStateManager;
import net.minecraft.world.World;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent;
-
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -23,7 +22,7 @@ public class AtlasDataHandler {
/** Loads data for the given atlas ID or creates a new one. */
public AtlasData getAtlasData(ItemStack stack, World world) {
if (stack.getItem() == RegistrarAntiqueAtlas.ATLAS) {
- return getAtlasData(stack.getItemDamage(), world);
+ return getAtlasData(stack.getDamage(), world);
} else {
return null;
}
@@ -32,20 +31,14 @@ public AtlasData getAtlasData(ItemStack stack, World world) {
/** Loads data for the given atlas or creates a new one. */
public AtlasData getAtlasData(int atlasID, World world) {
String key = getAtlasDataKey(atlasID);
- AtlasData data = null;
- if (world.isRemote) {
+ AtlasData data;
+ if (world.isClient) {
// Since atlas data doesn't really belong to a single world-dimension,
// it can be cached. This should fix #67
- data = atlasDataClientCache.get(key);
- }
-
- if (data == null) {
- data = (AtlasData) world.loadData(AtlasData.class, key);
- if (data == null) {
- data = new AtlasData(key);
- world.setData(key, data);
- }
- if (world.isRemote) atlasDataClientCache.put(key, data);
+ data = atlasDataClientCache.computeIfAbsent(key, AtlasData::new);
+ } else {
+ PersistentStateManager manager = ((ServerWorld) world).getPersistentStateManager();
+ data = manager.getOrCreate(() -> new AtlasData(key), key);
}
return data;
}
diff --git a/src/main/java/hunternif/mc/atlas/core/BiomeDetectorBase.java b/src/main/java/hunternif/mc/atlas/core/BiomeDetectorBase.java
index cada6aa75..039fcd6ce 100644
--- a/src/main/java/hunternif/mc/atlas/core/BiomeDetectorBase.java
+++ b/src/main/java/hunternif/mc/atlas/core/BiomeDetectorBase.java
@@ -3,14 +3,18 @@
import hunternif.mc.atlas.ext.ExtTileIdMap;
import hunternif.mc.atlas.util.ByteUtil;
import net.minecraft.block.Block;
-import net.minecraft.init.Biomes;
-import net.minecraft.init.Blocks;
+
+import net.minecraft.block.Blocks;
+import net.minecraft.util.Identifier;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.ViewableWorld;
+import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
+import net.minecraft.world.biome.Biomes;
import net.minecraft.world.chunk.Chunk;
-import net.minecraftforge.common.BiomeDictionary;
-import net.minecraftforge.common.BiomeDictionary.Type;
-import net.minecraftforge.fml.relauncher.ReflectionHelper;
-
+import net.minecraft.world.chunk.WorldChunk;
+import net.minecraft.world.gen.Heightmap;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
@@ -26,7 +30,7 @@ public class BiomeDetectorBase implements IBiomeDetector {
private boolean doScanRavines = true;
/** Biome used for occasional pools of water. */
- private static final int waterPoolBiomeID = Biome.getIdForBiome(Biomes.RIVER);
+ private static final Biome waterPoolBiome = null; // TODO FABRIC
/** Increment the counter for water biomes by this much during iteration.
* This is done so that water pools are more visible. */
private static final int priorityRavine = 12, priorityWaterPool = 3, prioritylavaPool = 6;
@@ -41,28 +45,14 @@ public class BiomeDetectorBase implements IBiomeDetector {
private static final Set swampBiomes = new HashSet<>();
-
- protected static Method biomeArrayMethod;
-
/** Scan all registered biomes to mark biomes of certain types that will be
* given higher priority when identifying mean biome ID for a chunk.
* (Currently WATER, BEACH and SWAMP) */
public static void scanBiomeTypes() {
- waterBiomes.addAll(BiomeDictionary.getBiomes(Type.WATER));
+ // TODO FABRIC
+ /* waterBiomes.addAll(BiomeDictionary.getBiomes(Type.WATER));
beachBiomes.addAll(BiomeDictionary.getBiomes(Type.BEACH));
- swampBiomes.addAll(BiomeDictionary.getBiomes(Type.SWAMP));
- }
-
- public static void setBiomeArrayMethod(boolean jeidPresent) {
- try {
- if (jeidPresent) {
- biomeArrayMethod = Chunk.class.getMethod("getIntBiomeArray");
- }
- else {
- biomeArrayMethod = ReflectionHelper.findMethod(Chunk.class, "getBiomeArray", "func_76605_m");
- }
- }
- catch (NoSuchMethodException e) { throw new RuntimeException(e); }
+ swampBiomes.addAll(BiomeDictionary.getBiomes(Type.SWAMP)); */
}
public void setScanPonds(boolean value) {
@@ -83,19 +73,11 @@ int priorityForBiome(Biome biome) {
}
}
- /** If no valid biome ID is found, returns {@link IBiomeDetector#NOT_FOUND}. */
+ /** If no valid biome ID is found, returns null. */
@Override
- public int getBiomeID(Chunk chunk) {
- int biomeCount = Biome.REGISTRY.getKeys().size();
-
- int[] chunkBiomes;
- try {
- chunkBiomes = ByteUtil.unsignedByteToIntArray(biomeArrayMethod.invoke(chunk));
- }
- catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); }
-
-
- Map biomeOccurrences = new HashMap<>(biomeCount);
+ public TileKind getBiomeID(Chunk chunk) {
+ Biome[] chunkBiomes = chunk.getBiomeArray();
+ Map biomeOccurrences = new HashMap<>(Registry.BIOME.getIds().size());
// The following important pseudo-biomes don't have IDs:
int lavaOccurrences = 0;
@@ -103,51 +85,52 @@ public int getBiomeID(Chunk chunk) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
- int biomeID = chunkBiomes[x << 4 | z];
+ Biome biomeID = chunkBiomes[x << 4 | z];
if (doScanPonds) {
- int y = chunk.getHeightValue(x, z);
+ int y = chunk instanceof WorldChunk ? ((WorldChunk) chunk).getHeightmap(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES).get(x, z) : chunk.getHeight() - 1;
if (y > 0) {
- Block topBlock = chunk.getBlockState(x, y-1, z).getBlock();
+ // TODO FABRIC
+ Block topBlock = chunk.getBlockState(new BlockPos(x, y-1, z)).getBlock();
// For some reason lava doesn't count in height value
// TODO: check if 1.8 fixes this!
- Block topBlock2 = chunk.getBlockState(x, y, z).getBlock();
+ Block topBlock2 = chunk.getBlockState(new BlockPos(x, y, z)).getBlock();
// Check if there's surface of water at (x, z), but not swamp
- if (topBlock == Blocks.WATER && !swampBiomes.contains(Biome.getBiomeForId(biomeID))) {
- int occurrence = biomeOccurrences.getOrDefault(waterPoolBiomeID, 0) + priorityWaterPool;
- biomeOccurrences.put(waterPoolBiomeID, occurrence);
+ if (topBlock == Blocks.WATER && !swampBiomes.contains(biomeID)) {
+ int occurrence = biomeOccurrences.getOrDefault(waterPoolBiome, 0) + priorityWaterPool;
+ biomeOccurrences.put(waterPoolBiome, occurrence);
} else if (topBlock2 == Blocks.LAVA) {
lavaOccurrences += prioritylavaPool;
}
}
}
if (doScanRavines) {
- if(chunk.getHeightValue(x, z) < chunk.getWorld().provider.getAverageGroundLevel() - ravineMinDepth) {
+ // TODO FABRIC
+ /* if(chunk.XX_1_12_2_b_XX(x, z) < chunk.XX_1_12_2_q_XX().t.XX_1_12_2_i_XX() - ravineMinDepth) {
ravineOccurences += priorityRavine;
- }
- }
- if (biomeID >= 0 && Biome.getBiomeForId(biomeID) != null) {
- int occurrence = biomeOccurrences.getOrDefault(biomeID, 0) + priorityForBiome(Biome.getBiomeForId(biomeID));
- biomeOccurrences.put(biomeID, occurrence);
+ } */
}
+
+ int occurrence = biomeOccurrences.getOrDefault(biomeID, 0) + priorityForBiome(biomeID);
+ biomeOccurrences.put(biomeID, occurrence);
}
}
try {
- Map.Entry meanBiome = Collections.max(biomeOccurrences.entrySet(), Comparator.comparingInt(Map.Entry::getValue));
- int meanBiomeId = meanBiome.getKey();
+ Map.Entry meanBiome = Collections.max(biomeOccurrences.entrySet(), Comparator.comparingInt(Map.Entry::getValue));
+ Biome meanBiomeId = meanBiome.getKey();
int meanBiomeOccurrences = meanBiome.getValue();
// The following important pseudo-biomes don't have IDs:
if (meanBiomeOccurrences < ravineOccurences) {
- return ExtTileIdMap.instance().getPseudoBiomeID(ExtTileIdMap.TILE_RAVINE);
+ return TileKindFactory.get(ExtTileIdMap.TILE_RAVINE);
}
if (meanBiomeOccurrences < lavaOccurrences) {
- return ExtTileIdMap.instance().getPseudoBiomeID(ExtTileIdMap.TILE_LAVA);
+ return TileKindFactory.get(ExtTileIdMap.TILE_LAVA);
}
- return meanBiomeId;
+ return TileKindFactory.get(meanBiomeId);
} catch(NoSuchElementException e){
- return Biome.getIdForBiome(Biomes.DEFAULT);
+ return TileKindFactory.get(Biomes.DEFAULT);
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/core/BiomeDetectorEnd.java b/src/main/java/hunternif/mc/atlas/core/BiomeDetectorEnd.java
index 3d7356fbb..7293e3928 100644
--- a/src/main/java/hunternif/mc/atlas/core/BiomeDetectorEnd.java
+++ b/src/main/java/hunternif/mc/atlas/core/BiomeDetectorEnd.java
@@ -1,16 +1,24 @@
package hunternif.mc.atlas.core;
import hunternif.mc.atlas.AntiqueAtlasMod;
-import net.minecraft.block.Block;
-import net.minecraft.init.Biomes;
-import net.minecraft.init.Blocks;
-import net.minecraft.world.biome.Biome;
-import net.minecraft.world.chunk.Chunk;
-
import hunternif.mc.atlas.ext.ExtTileIdMap;
import hunternif.mc.atlas.util.ByteUtil;
import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.minecraft.block.Block;
+
+import net.minecraft.block.BlockState;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.ViewableWorld;
+import net.minecraft.world.biome.Biome;
+import net.minecraft.world.biome.Biomes;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraft.world.chunk.WorldChunk;
+import net.minecraft.world.gen.Heightmap;
/**
* Detects seas of lava, cave ground and cave walls in the Nether.
@@ -19,65 +27,63 @@
public class BiomeDetectorEnd extends BiomeDetectorBase implements IBiomeDetector {
@Override
- public int getBiomeID(Chunk chunk) {
- int biomesCount = Biome.REGISTRY.getKeys().size();
- int[] chunkBiomes;
- try {
- chunkBiomes = ByteUtil.unsignedByteToIntArray(biomeArrayMethod.invoke(chunk));
- }
- catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); }
- int[] biomeOccurrences = new int[biomesCount];
+ public TileKind getBiomeID(Chunk chunk) {
+ Biome[] chunkBiomes = chunk.getBiomeArray();
+ Map biomeOccurrences = new HashMap<>(Registry.BIOME.getIds().size());
// The following pseudo-biomes don't have IDs:
int islandOccurences = 0;
int plantOccurences = 0;
int voidOccurences = 0;
- int endID = Biome.getIdForBiome(Biomes.SKY);
+ Biome endID = Biomes.THE_END;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
- int biomeID = chunkBiomes[x << 4 | z];
+ Biome biomeID = chunkBiomes[x << 4 | z];
if (biomeID == endID) {
// The End!
- int top = chunk.getHeightValue(x, z);
- Block topBlock = chunk.getBlockState(x, top-1, z).getBlock();
+ // TODO FABRIC
+ int top = ((WorldChunk) chunk).getHeightmap(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES).get(x, z);
+ BlockState topBlock = chunk.getBlockState(new BlockPos(x, top-1, z));
- if(topBlock == Blocks.END_STONE) {
+ /* if(topBlock == bdy.XX_1_13_2_eg_XX) {
islandOccurences++;
- Block rootBlock = chunk.getBlockState(x, top, z).getBlock();
- if(rootBlock == Blocks.CHORUS_FLOWER || rootBlock == Blocks.CHORUS_PLANT) {
+ Block rootBlock = chunk.XX_1_12_2_a_XX(x, top, z).c();
+ if(rootBlock == bdy.XX_1_13_2_hZ_XX || rootBlock == bdy.XX_1_13_2_hY_XX) {
plantOccurences++;
}
- }
- if(topBlock == Blocks.AIR) {
+ } */
+ if(topBlock.isAir()) {
voidOccurences++;
}
} else {
// In case there are custom biomes "modded in":
- if (biomeID >= 0 && biomeID < biomesCount && Biome.getBiomeForId(biomeID) != null) {
- biomeOccurrences[biomeID] += priorityForBiome(Biome.getBiomeForId(biomeID));
- }
+ biomeOccurrences.put(biomeID,
+ biomeOccurrences.getOrDefault(biomeID, 0) + priorityForBiome(biomeID)
+ );
}
}
}
- int meanBiomeId = NOT_FOUND;
+
+ TileKind meanBiomeId = null;
int meanBiomeOccurences = 0;
- for (int i = 0; i < biomeOccurrences.length; i++) {
- if (biomeOccurrences[i] > meanBiomeOccurences) {
- meanBiomeId = i;
- meanBiomeOccurences = biomeOccurrences[i];
+ for (Biome biome : biomeOccurrences.keySet()) {
+ int occ = biomeOccurrences.get(biome);
+ if (biomeOccurrences.get(biome) > meanBiomeOccurences) {
+ meanBiomeId = TileKindFactory.get(biome);
+ meanBiomeOccurences = occ;
}
}
// The following important pseudo-biomes don't have IDs:
if (meanBiomeOccurences < islandOccurences) {
if(plantOccurences == 0)
- meanBiomeId = ExtTileIdMap.instance().getPseudoBiomeID(ExtTileIdMap.TILE_END_ISLAND);
+ meanBiomeId = TileKindFactory.get(ExtTileIdMap.TILE_END_ISLAND);
else
- meanBiomeId = ExtTileIdMap.instance().getPseudoBiomeID(ExtTileIdMap.TILE_END_ISLAND_PLANTS);
+ meanBiomeId = TileKindFactory.get(ExtTileIdMap.TILE_END_ISLAND_PLANTS);
} else if (meanBiomeOccurences < voidOccurences) {
- meanBiomeId = ExtTileIdMap.instance().getPseudoBiomeID(ExtTileIdMap.TILE_END_VOID);
+ meanBiomeId = TileKindFactory.get(ExtTileIdMap.TILE_END_VOID);
}
return meanBiomeId;
diff --git a/src/main/java/hunternif/mc/atlas/core/BiomeDetectorNether.java b/src/main/java/hunternif/mc/atlas/core/BiomeDetectorNether.java
index d84a0c3ab..a242518a3 100644
--- a/src/main/java/hunternif/mc/atlas/core/BiomeDetectorNether.java
+++ b/src/main/java/hunternif/mc/atlas/core/BiomeDetectorNether.java
@@ -1,16 +1,23 @@
package hunternif.mc.atlas.core;
import hunternif.mc.atlas.AntiqueAtlasMod;
-import net.minecraft.block.Block;
-import net.minecraft.init.Biomes;
-import net.minecraft.init.Blocks;
-import net.minecraft.world.biome.Biome;
-import net.minecraft.world.chunk.Chunk;
-
import hunternif.mc.atlas.ext.ExtTileIdMap;
import hunternif.mc.atlas.util.ByteUtil;
import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.minecraft.block.Block;
+
+import net.minecraft.block.BlockState;
+import net.minecraft.block.Blocks;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.ViewableWorld;
+import net.minecraft.world.biome.Biome;
+import net.minecraft.world.biome.Biomes;
+import net.minecraft.world.chunk.Chunk;
/**
* Detects seas of lava, cave ground and cave walls in the Nether.
@@ -27,59 +34,60 @@ public class BiomeDetectorNether extends BiomeDetectorBase implements IBiomeDete
private static final int priorityLava = 1;
@Override
- public int getBiomeID(Chunk chunk) {
- int biomesCount = Biome.REGISTRY.getKeys().size();
- int[] chunkBiomes;
- try {
- chunkBiomes = ByteUtil.unsignedByteToIntArray(biomeArrayMethod.invoke(chunk));
- }
- catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); }
- int[] biomeOccurrences = new int[biomesCount];
+ public TileKind getBiomeID(Chunk chunk) {
+ int biomesCount = Registry.BIOME.getIds().size();
+ Biome[] chunkBiomes = chunk.getBiomeArray();
+ Map biomeOccurrences = new HashMap<>(Registry.BIOME.getIds().size());
// The following important pseudo-biomes don't have IDs:
int lavaOccurences = 0;
int groundOccurences = 0;
- int hellID = Biome.getIdForBiome(Biomes.HELL);
-
+ Biome hellID = Biomes.NETHER;
+
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
- int biomeID = chunkBiomes[x << 4 | z];
+ Biome biomeID = chunkBiomes[x << 4 | z];
if (biomeID == hellID) {
// The Nether!
- Block netherBlock = chunk.getBlockState(x, lavaSeaLevel, z).getBlock();
+ Block netherBlock = chunk.getBlockState(new BlockPos(x, lavaSeaLevel, z)).getBlock();
if (netherBlock == Blocks.LAVA) {
lavaOccurences += priorityLava;
} else {
- netherBlock = chunk.getBlockState(x, airProbeLevel, z).getBlock();
- if (netherBlock == null || netherBlock == Blocks.AIR) {
+ BlockState netherBlockState = chunk.getBlockState(new BlockPos(x, airProbeLevel, z));
+ if (netherBlockState.isAir()) {
groundOccurences ++; // ground
} else {
- biomeOccurrences[biomeID] ++; // cave walls
+ // cave walls
+ biomeOccurrences.put(biomeID,
+ biomeOccurrences.getOrDefault(biomeID, 0) + 1
+ );
}
}
} else {
// In case there are custom biomes "modded in":
- if (biomeID >= 0 && biomeID < biomesCount && Biome.getBiomeForId(biomeID) != null) {
- biomeOccurrences[biomeID] += priorityForBiome(Biome.getBiomeForId(biomeID));
- }
+ biomeOccurrences.put(biomeID,
+ biomeOccurrences.getOrDefault(biomeID, 0) + priorityForBiome(biomeID)
+ );
}
}
}
- int meanBiomeId = NOT_FOUND;
+
+ TileKind meanBiomeId = null;
int meanBiomeOccurences = 0;
- for (int i = 0; i < biomeOccurrences.length; i++) {
- if (biomeOccurrences[i] > meanBiomeOccurences) {
- meanBiomeId = i;
- meanBiomeOccurences = biomeOccurrences[i];
+ for (Biome biome : biomeOccurrences.keySet()) {
+ int occ = biomeOccurrences.get(biome);
+ if (biomeOccurrences.get(biome) > meanBiomeOccurences) {
+ meanBiomeId = TileKindFactory.get(biome);
+ meanBiomeOccurences = occ;
}
}
// The following important pseudo-biomes don't have IDs:
if (meanBiomeOccurences < lavaOccurences) {
- meanBiomeId = ExtTileIdMap.instance().getPseudoBiomeID(ExtTileIdMap.TILE_LAVA);
+ meanBiomeId = TileKindFactory.get(ExtTileIdMap.TILE_LAVA);
} else if (meanBiomeOccurences < groundOccurences) {
- meanBiomeId = ExtTileIdMap.instance().getPseudoBiomeID(ExtTileIdMap.TILE_LAVA_SHORE);
+ meanBiomeId = TileKindFactory.get(ExtTileIdMap.TILE_LAVA_SHORE);
}
return meanBiomeId;
diff --git a/src/main/java/hunternif/mc/atlas/core/DimensionData.java b/src/main/java/hunternif/mc/atlas/core/DimensionData.java
index fa57db449..4631a20db 100644
--- a/src/main/java/hunternif/mc/atlas/core/DimensionData.java
+++ b/src/main/java/hunternif/mc/atlas/core/DimensionData.java
@@ -6,20 +6,21 @@
import hunternif.mc.atlas.util.Log;
import hunternif.mc.atlas.util.Rect;
import hunternif.mc.atlas.util.ShortVec2;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-
import java.util.ArrayList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
+import net.minecraft.client.network.packet.LoginSuccessS2CPacket;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.world.dimension.DimensionType;
/** All tiles seen in dimension. Thread-safe (probably) */
public class DimensionData implements ITileStorage {
public final AtlasData parent;
- public final int dimension;
+ public final DimensionType dimension;
private int browsingX, browsingY;
private double browsingZoom = 0.5;
@@ -40,7 +41,7 @@ public class DimensionData implements ITileStorage {
/** Limits of explored area, in chunks. */
private final Rect scope = new Rect();
- public DimensionData(AtlasData parent, int dimension) {
+ public DimensionData(AtlasData parent, DimensionType dimension) {
this.parent = parent;
this.dimension = dimension;
}
@@ -48,9 +49,9 @@ public DimensionData(AtlasData parent, int dimension) {
/**
* This function has to create a new map on each call since the packet rework
*/
- public Map getSeenChunks() {
- Map chunks = new ConcurrentHashMap(2, 0.75f, 2);
- Tile t = null;
+ public Map getSeenChunks() {
+ Map chunks = new ConcurrentHashMap(2, 0.75f, 2);
+ TileKind t = null;
for (Map.Entry entry: tileGroups.entrySet()){
int basex = entry.getValue().getScope().minX;
int basey = entry.getValue().getScope().minY;
@@ -96,7 +97,7 @@ private ShortVec2 getKey() {
}
@Override
- public void setTile(int x, int y, Tile tile) {
+ public void setTile(int x, int y, TileKind tile) {
ShortVec2 groupPos = getKey().set((int)Math.floor(x / (float) TileGroup.CHUNK_STEP),
(int)Math.floor(y / (float) TileGroup.CHUNK_STEP));
TileGroup tg = tileGroups.get(groupPos);
@@ -117,7 +118,7 @@ public void putTileGroup(TileGroup t){
}
@Override
- public Tile removeTile(int x, int y) {
+ public TileKind removeTile(int x, int y) {
//TODO
// since scope is not modified, I assume this was never really used
// Tile oldTile = tileGroups.remove(getKey().set(x, y));
@@ -127,7 +128,7 @@ public Tile removeTile(int x, int y) {
}
@Override
- public Tile getTile(int x, int y) {
+ public TileKind getTile(int x, int y) {
ShortVec2 groupPos = getKey().set((int)Math.floor(x / (float) TileGroup.CHUNK_STEP),
(int)Math.floor(y / (float) TileGroup.CHUNK_STEP));
TileGroup tg = tileGroups.get(groupPos);
@@ -162,19 +163,19 @@ public void addData(DimensionData other){
Rect s = group.getScope();
for (int x = s.minX; x <= s.maxX; x++){
for (int y = s.minY; y <= s.maxY; y++){
- Tile tile = group.getTile(x, y);
+ TileKind tile = group.getTile(x, y);
if (tile != null) setTile(x, y, tile);
}
}
}
}
- public NBTTagList writeToNBT() {
- NBTTagList tileGroupList = new NBTTagList();
+ public ListTag writeToNBT() {
+ ListTag tileGroupList = new ListTag();
for (Entry entry : tileGroups.entrySet()) {
- NBTTagCompound newbie = new NBTTagCompound();
+ CompoundTag newbie = new CompoundTag();
entry.getValue().writeToNBT(newbie);
- tileGroupList.appendTag(newbie);
+ tileGroupList.add(newbie);
}
return tileGroupList;
}
@@ -189,19 +190,19 @@ private void extendToTileGroup(TileGroup tg){
}
}
- public void readFromNBT(NBTTagList me){
+ public void readFromNBT(ListTag me){
if (me == null){
return;
}
- for (int d = 0; d < me.tagCount(); d++) {
- NBTTagCompound tgTag = me.getCompoundTagAt(d);
+ for (int d = 0; d < me.size(); d++) {
+ CompoundTag tgTag = me.getCompoundTag(d);
TileGroup tg = new TileGroup(0, 0);
tg.readFromNBT(tgTag);
putTileGroup(tg);
}
}
- public void syncOnPlayer(int atlasID, EntityPlayer player){
+ public void syncOnPlayer(int atlasID, PlayerEntity player){
Log.info("Sending dimension #%d", dimension);
ArrayList tgs = new ArrayList(TileGroupsPacket.TILE_GROUPS_PER_PACKET);
int count = 0;
@@ -212,14 +213,14 @@ public void syncOnPlayer(int atlasID, EntityPlayer player){
total++;
if (count >= TileGroupsPacket.TILE_GROUPS_PER_PACKET){
TileGroupsPacket p = new TileGroupsPacket(tgs, atlasID, dimension);
- PacketDispatcher.sendTo(p, (EntityPlayerMP) player);
+ PacketDispatcher.sendTo(p, (ServerPlayerEntity) player);
tgs.clear();
count = 0;
}
}
if (count > 0){
TileGroupsPacket p = new TileGroupsPacket(tgs, atlasID, dimension);
- PacketDispatcher.sendTo(p, (EntityPlayerMP) player);
+ PacketDispatcher.sendTo(p, (ServerPlayerEntity) player);
}
Log.info("Sent dimension #%d (%d tiles)", dimension, total);
}
diff --git a/src/main/java/hunternif/mc/atlas/core/GlobalAtlasData.java b/src/main/java/hunternif/mc/atlas/core/GlobalAtlasData.java
new file mode 100644
index 000000000..9338fbdea
--- /dev/null
+++ b/src/main/java/hunternif/mc/atlas/core/GlobalAtlasData.java
@@ -0,0 +1,33 @@
+package hunternif.mc.atlas.core;
+
+import net.fabricmc.fabric.api.util.NbtType;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.world.PersistentState;
+
+public class GlobalAtlasData extends PersistentState {
+ public static final String TAG_NEXT_ID = "aaNextID";
+ private int nextId = 1;
+
+ public GlobalAtlasData(String key) {
+ super(key);
+ }
+
+ public int getNextAtlasId() {
+ return nextId++;
+ }
+
+ @Override
+ public void fromTag(CompoundTag compound) {
+ if (compound.containsKey(TAG_NEXT_ID, NbtType.NUMBER)) {
+ nextId = compound.getInt(TAG_NEXT_ID);
+ } else {
+ nextId = 1;
+ }
+ }
+
+ @Override
+ public CompoundTag toTag(CompoundTag var1) {
+ var1.putInt(TAG_NEXT_ID, nextId);
+ return var1;
+ }
+}
diff --git a/src/main/java/hunternif/mc/atlas/core/IBiomeDetector.java b/src/main/java/hunternif/mc/atlas/core/IBiomeDetector.java
index ded230bd8..4a3749309 100644
--- a/src/main/java/hunternif/mc/atlas/core/IBiomeDetector.java
+++ b/src/main/java/hunternif/mc/atlas/core/IBiomeDetector.java
@@ -1,14 +1,17 @@
package hunternif.mc.atlas.core;
+import net.minecraft.world.ViewableWorld;
+import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
+import javax.annotation.Nullable;
+
/**
* Finds the biome ID to be used for a given chunk.
* @author Hunternif
*/
interface IBiomeDetector {
- int NOT_FOUND = -1;
-
/** Finds the biome ID to be used for a given chunk. */
- int getBiomeID(Chunk chunk);
+ @Nullable
+ TileKind getBiomeID(Chunk chunk);
}
diff --git a/src/main/java/hunternif/mc/atlas/core/ITileStorage.java b/src/main/java/hunternif/mc/atlas/core/ITileStorage.java
index 9d42a1101..18f9eefee 100644
--- a/src/main/java/hunternif/mc/atlas/core/ITileStorage.java
+++ b/src/main/java/hunternif/mc/atlas/core/ITileStorage.java
@@ -3,10 +3,10 @@
import hunternif.mc.atlas.util.Rect;
public interface ITileStorage {
- void setTile(int x, int y, Tile tile);
+ void setTile(int x, int y, TileKind tile);
/** Returns the Tile previously set at given coordinates. */
- Tile removeTile(int x, int y);
- Tile getTile(int x, int y);
+ TileKind removeTile(int x, int y);
+ TileKind getTile(int x, int y);
boolean hasTileAt(int x, int y);
Rect getScope();
}
diff --git a/src/main/java/hunternif/mc/atlas/core/PlayerEventHandler.java b/src/main/java/hunternif/mc/atlas/core/PlayerEventHandler.java
index ee749872a..d9ef25ccf 100644
--- a/src/main/java/hunternif/mc/atlas/core/PlayerEventHandler.java
+++ b/src/main/java/hunternif/mc/atlas/core/PlayerEventHandler.java
@@ -2,7 +2,7 @@
import hunternif.mc.atlas.AntiqueAtlasMod;
import hunternif.mc.atlas.marker.MarkersData;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
@@ -11,7 +11,7 @@
public class PlayerEventHandler {
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
- EntityPlayer player = event.player;
+ PlayerEntity player = event.player;
World world = player.world;
int atlasID = player.getUniqueID().hashCode();
diff --git a/src/main/java/hunternif/mc/atlas/core/Tile.java b/src/main/java/hunternif/mc/atlas/core/Tile.java
deleted file mode 100644
index 29718ed71..000000000
--- a/src/main/java/hunternif/mc/atlas/core/Tile.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package hunternif.mc.atlas.core;
-
-import java.util.Random;
-
-/**
- * Contains information about the biome and - on the client - the variation
- * number of the biome's texture set.
- * @author Hunternif
- */
-public class Tile {
- public final int biomeID;
-
- private static final Random RANDOM = new Random();
-
- /** Used for randomizing textures.
- * Takes on values from 0 to {@link Short#MAX_VALUE} - 1. */
- private transient short variationNumber;
-
- public Tile(int biomeID) {
- this(biomeID, (byte)0);
- randomizeTexture();
- }
- private Tile(int biomeID, byte variationNumber) {
- this.biomeID = biomeID;
- this.variationNumber = variationNumber;
- }
-
- /** Set variation number to a random byte. */
- private void randomizeTexture() {
- this.variationNumber = (short) RANDOM.nextInt(Short.MAX_VALUE);
- }
-
- public short getVariationNumber() {
- return variationNumber;
- }
-
- @Override
- public String toString() {
- return "tile" + biomeID;
- }
-
- @Override
- public boolean equals(Object obj) {
- return (obj instanceof Tile) && ((Tile)obj).biomeID == biomeID;
- }
-}
diff --git a/src/main/java/hunternif/mc/atlas/core/TileGroup.java b/src/main/java/hunternif/mc/atlas/core/TileGroup.java
index 4c6a4fd47..6af15da66 100644
--- a/src/main/java/hunternif/mc/atlas/core/TileGroup.java
+++ b/src/main/java/hunternif/mc/atlas/core/TileGroup.java
@@ -2,7 +2,7 @@
import hunternif.mc.atlas.util.Log;
import hunternif.mc.atlas.util.Rect;
-import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.CompoundTag;
/** Represents a group of tiles that may be sent/stored as a single NBT */
public class TileGroup implements ITileStorage {
@@ -17,7 +17,7 @@ public class TileGroup implements ITileStorage {
Rect scope = new Rect(0, 0, CHUNK_STEP, CHUNK_STEP);
/** The tiles in this scope */
- Tile[][] tiles = new Tile[CHUNK_STEP][CHUNK_STEP];
+ TileKind[][] tiles = new TileKind[CHUNK_STEP][CHUNK_STEP];
public TileGroup(int x, int y) {
scope.minX = x;
@@ -26,7 +26,7 @@ public TileGroup(int x, int y) {
scope.maxY = scope.minY + CHUNK_STEP - 1;
}
- public void readFromNBT(NBTTagCompound compound) {
+ public void readFromNBT(CompoundTag compound) {
scope.minX = compound.getIntArray(TAG_POSITION)[0];
scope.minY = compound.getIntArray(TAG_POSITION)[1];
scope.maxX = scope.minX + CHUNK_STEP - 1;
@@ -41,13 +41,13 @@ public void readFromNBT(NBTTagCompound compound) {
if (tileArray[x + y * CHUNK_STEP] == -1) {
tiles[x][y] = null;
} else {
- tiles[x][y] = new Tile(tileArray[x + y * CHUNK_STEP]);
+ tiles[x][y] = TileKindFactory.get(tileArray[x + y * CHUNK_STEP]);
}
}
}
}
- public NBTTagCompound writeToNBT(NBTTagCompound compound) {
+ public CompoundTag writeToNBT(CompoundTag compound) {
int[] tileArray = new int[CHUNK_STEP * CHUNK_STEP];
int[] pos = { scope.minX, scope.minY };
for (int y = 0; y < CHUNK_STEP; y++) {
@@ -59,17 +59,17 @@ public NBTTagCompound writeToNBT(NBTTagCompound compound) {
if (tiles[x][y] == null) {
tileArray[x + y * CHUNK_STEP] = -1;
} else {
- tileArray[x + y * CHUNK_STEP] = tiles[x][y].biomeID;
+ tileArray[x + y * CHUNK_STEP] = tiles[x][y].getId();
}
}
}
- compound.setIntArray(TAG_POSITION, pos);
- compound.setIntArray(TAG_TILES, tileArray);
+ compound.putIntArray(TAG_POSITION, pos);
+ compound.putIntArray(TAG_TILES, tileArray);
return compound;
}
@Override
- public void setTile(int x, int y, Tile tile) {
+ public void setTile(int x, int y, TileKind tile) {
if (x >= scope.minX && y >= scope.minY && x <= scope.maxX && y <= scope.maxY) {
int rx = x - scope.minX;
int ry = y - scope.minY;
@@ -82,14 +82,14 @@ public void setTile(int x, int y, Tile tile) {
}
@Override
- public Tile removeTile(int x, int y) {
- Tile tmp = getTile(x,y);
+ public TileKind removeTile(int x, int y) {
+ TileKind tmp = getTile(x,y);
setTile(x,y,null);
return tmp;
}
@Override
- public Tile getTile(int x, int y) {
+ public TileKind getTile(int x, int y) {
if (x >= scope.minX && y >= scope.minY && x <= scope.maxX && y <= scope.maxY) {
int rx = x - scope.minX;
int ry = y - scope.minY;
@@ -119,8 +119,8 @@ public boolean equals(Object obj) {
int b;
for (int y = 0; y < CHUNK_STEP; y++) {
for (int x = 0; x < CHUNK_STEP; x++) {
- a = (this.tiles[x][y] == null)? -1:this.tiles[x][y].biomeID;
- b = (other.tiles[x][y] == null)? -1:other.tiles[x][y].biomeID;
+ a = (this.tiles[x][y] == null)? -1:this.tiles[x][y].getId();
+ b = (other.tiles[x][y] == null)? -1:other.tiles[x][y].getId();
if (a!=b)
return false;
}
diff --git a/src/main/java/hunternif/mc/atlas/core/TileInfo.java b/src/main/java/hunternif/mc/atlas/core/TileInfo.java
index 59468b8dd..938957ae8 100644
--- a/src/main/java/hunternif/mc/atlas/core/TileInfo.java
+++ b/src/main/java/hunternif/mc/atlas/core/TileInfo.java
@@ -1,11 +1,14 @@
package hunternif.mc.atlas.core;
+import net.minecraft.world.biome.Biome;
+
public class TileInfo {
- public int x, z, biome;
+ public int x, z;
+ public TileKind biome;
public TileInfo(){}
- public TileInfo(int x, int z, int biome){
+ public TileInfo(int x, int z, TileKind biome){
this.x = x;
this.z = z;
this.biome = biome;
diff --git a/src/main/java/hunternif/mc/atlas/core/TileKind.java b/src/main/java/hunternif/mc/atlas/core/TileKind.java
new file mode 100644
index 000000000..fe7653e4b
--- /dev/null
+++ b/src/main/java/hunternif/mc/atlas/core/TileKind.java
@@ -0,0 +1,18 @@
+package hunternif.mc.atlas.core;
+
+import net.minecraft.util.math.MathHelper;
+import net.minecraft.world.biome.Biome;
+
+import javax.annotation.Nullable;
+
+public interface TileKind {
+ int getId();
+ @Nullable
+ Biome getBiome();
+ @Nullable
+ String getExtTile();
+
+ default short getVariationNumber(int x, int y) {
+ return (short) (MathHelper.hashCode(x, y, 0) % 32767);
+ }
+}
diff --git a/src/main/java/hunternif/mc/atlas/core/TileKindFactory.java b/src/main/java/hunternif/mc/atlas/core/TileKindFactory.java
new file mode 100644
index 000000000..7c937f31a
--- /dev/null
+++ b/src/main/java/hunternif/mc/atlas/core/TileKindFactory.java
@@ -0,0 +1,102 @@
+package hunternif.mc.atlas.core;
+
+import hunternif.mc.atlas.ext.ExtTileIdMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.biome.Biome;
+
+import javax.annotation.Nullable;
+import java.util.IdentityHashMap;
+import java.util.Map;
+
+public final class TileKindFactory {
+ private static final Map biomeKinds = new IdentityHashMap<>();
+ private static final Int2ObjectMap extKinds = new Int2ObjectOpenHashMap<>();
+
+ private TileKindFactory() {
+
+ }
+
+ public static TileKind get(int id) {
+ if (id < 0) {
+ return extKinds.get(id);
+ } else {
+ Biome biome = Registry.BIOME.get(id);
+ if (biome != null) {
+ return get(biome);
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public static TileKind get(Biome biome) {
+ return biomeKinds.computeIfAbsent(biome, BiomeKind::new);
+ }
+
+ public static TileKind get(String extTile) {
+ int id = ExtTileIdMap.instance().getOrCreatePseudoBiomeID(extTile);
+ return extKinds.computeIfAbsent(id, ExtKind::new);
+ }
+
+ private static class ExtKind implements TileKind {
+ private final int id;
+
+ ExtKind(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public int getId() {
+ return id;
+ }
+
+ @Nullable
+ @Override
+ public Biome getBiome() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public String getExtTile() {
+ return ExtTileIdMap.instance().getPseudoBiomeName(id);
+ }
+
+ @Override
+ public String toString() {
+ return "ExtTile{" + getExtTile() + "}";
+ }
+ }
+
+ private static class BiomeKind implements TileKind {
+ private final Biome biome;
+
+ BiomeKind(Biome biome) {
+ this.biome = biome;
+ }
+
+ @Override
+ public int getId() {
+ return Registry.BIOME.getRawId(biome);
+ }
+
+ @Nullable
+ @Override
+ public net.minecraft.world.biome.Biome getBiome() {
+ return biome;
+ }
+
+ @Nullable
+ @Override
+ public String getExtTile() {
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return "BiomeTile{" + Registry.BIOME.getId(biome) + "}";
+ }
+ }
+}
diff --git a/src/main/java/hunternif/mc/atlas/event/MarkerClickedEvent.java b/src/main/java/hunternif/mc/atlas/event/MarkerClickedEvent.java
index 67ceb5495..7a4350eb9 100644
--- a/src/main/java/hunternif/mc/atlas/event/MarkerClickedEvent.java
+++ b/src/main/java/hunternif/mc/atlas/event/MarkerClickedEvent.java
@@ -1,18 +1,18 @@
package hunternif.mc.atlas.event;
import hunternif.mc.atlas.marker.Marker;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
@Cancelable
public class MarkerClickedEvent extends Event {
- public EntityPlayer player;
+ public PlayerEntity player;
public Marker marker;
public int mouseState;
- public MarkerClickedEvent(EntityPlayer player, Marker marker, int mouseState) {
+ public MarkerClickedEvent(PlayerEntity player, Marker marker, int mouseState) {
this.player = player;
this.marker = marker;
this.mouseState = mouseState;
diff --git a/src/main/java/hunternif/mc/atlas/event/MarkerHoveredEvent.java b/src/main/java/hunternif/mc/atlas/event/MarkerHoveredEvent.java
index 0f2001174..5e0b11137 100644
--- a/src/main/java/hunternif/mc/atlas/event/MarkerHoveredEvent.java
+++ b/src/main/java/hunternif/mc/atlas/event/MarkerHoveredEvent.java
@@ -2,15 +2,15 @@
import hunternif.mc.atlas.marker.Marker;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.fml.common.eventhandler.Event;
public class MarkerHoveredEvent extends Event {
- public EntityPlayer player;
+ public PlayerEntity player;
public Marker marker;
- public MarkerHoveredEvent(EntityPlayer player, Marker marker) {
+ public MarkerHoveredEvent(PlayerEntity player, Marker marker) {
this.player = player;
this.marker = marker;
}
diff --git a/src/main/java/hunternif/mc/atlas/ext/ExtBiomeData.java b/src/main/java/hunternif/mc/atlas/ext/ExtBiomeData.java
index f4cf1f0bc..0f28e1bf2 100644
--- a/src/main/java/hunternif/mc/atlas/ext/ExtBiomeData.java
+++ b/src/main/java/hunternif/mc/atlas/ext/ExtBiomeData.java
@@ -4,13 +4,18 @@
import hunternif.mc.atlas.network.client.TilesPacket;
import hunternif.mc.atlas.util.Log;
import hunternif.mc.atlas.util.ShortVec2;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraft.world.storage.WorldSavedData;
+import net.fabricmc.fabric.api.util.NbtType;
+import net.minecraft.client.network.packet.LoginSuccessS2CPacket;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.util.Identifier;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.PersistentState;
+import net.minecraft.world.biome.Biome;
+import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.util.Constants;
-
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
@@ -20,7 +25,7 @@
* Atlases check with it when updating themselves.
* @author Hunternif
*/
-public class ExtBiomeData extends WorldSavedData {
+public class ExtBiomeData extends PersistentState {
private static final int VERSION = 1;
private static final String TAG_VERSION = "aaVersion";
private static final String TAG_DIMENSION_MAP_LIST = "dimMap";
@@ -31,38 +36,42 @@ public ExtBiomeData(String key) {
super(key);
}
- private final Map> dimensionMap =
+ private final Map> dimensionMap =
new ConcurrentHashMap<>(2, 0.75f, 2);
private final ShortVec2 tempCoords = new ShortVec2(0, 0);
@Override
- public void readFromNBT(NBTTagCompound compound) {
- int version = compound.getInteger(TAG_VERSION);
+ public void fromTag(CompoundTag compound) {
+ int version = compound.getInt(TAG_VERSION);
if (version < VERSION) {
Log.warn("Outdated atlas data format! Was %d but current is %d", version, VERSION);
this.markDirty();
}
- NBTTagList dimensionMapList = compound.getTagList(TAG_DIMENSION_MAP_LIST, Constants.NBT.TAG_COMPOUND);
- for (int d = 0; d < dimensionMapList.tagCount(); d++) {
- NBTTagCompound tag = dimensionMapList.getCompoundTagAt(d);
- int dimensionID = tag.getInteger(TAG_DIMENSION_ID);
+ ListTag dimensionMapList = compound.getList(TAG_DIMENSION_MAP_LIST, NbtType.COMPOUND);
+ for (int d = 0; d < dimensionMapList.size(); d++) {
+ CompoundTag tag = dimensionMapList.getCompoundTag(d);
+ DimensionType dimensionID;
+ if (tag.containsKey(TAG_DIMENSION_ID, NbtType.NUMBER)) {
+ dimensionID = Registry.DIMENSION.get(tag.getInt(TAG_DIMENSION_ID));
+ } else {
+ dimensionID = Registry.DIMENSION.get(new Identifier(tag.getString(TAG_DIMENSION_ID)));
+ }
Map biomeMap = getBiomesInDimension(dimensionID);
int[] intArray = tag.getIntArray(TAG_BIOME_IDS);
for (int i = 0; i < intArray.length; i += 3) {
ShortVec2 coords = new ShortVec2(intArray[i], intArray[i+1]);
biomeMap.put(coords, intArray[i + 2]);
- }
- }
+ }}
}
@Override
- public NBTTagCompound writeToNBT(NBTTagCompound compound) {
- compound.setInteger(TAG_VERSION, VERSION);
- NBTTagList dimensionMapList = new NBTTagList();
- for (Integer dimension : dimensionMap.keySet()) {
- NBTTagCompound tag = new NBTTagCompound();
- tag.setInteger(TAG_DIMENSION_ID, dimension);
+ public CompoundTag toTag(CompoundTag compound) {
+ compound.putInt(TAG_VERSION, VERSION);
+ ListTag dimensionMapList = new ListTag();
+ for (DimensionType dimension : dimensionMap.keySet()) {
+ CompoundTag tag = new CompoundTag();
+ tag.putString(TAG_DIMENSION_ID, Registry.DIMENSION.getId(dimension).toString());
Map biomeMap = getBiomesInDimension(dimension);
int[] intArray = new int[biomeMap.size()*3];
int i = 0;
@@ -71,47 +80,47 @@ public NBTTagCompound writeToNBT(NBTTagCompound compound) {
intArray[i++] = entry.getKey().y;
intArray[i++] = entry.getValue();
}
- tag.setIntArray(TAG_BIOME_IDS, intArray);
- dimensionMapList.appendTag(tag);
+ tag.putIntArray(TAG_BIOME_IDS, intArray);
+ dimensionMapList.add(tag);
}
- compound.setTag(TAG_DIMENSION_MAP_LIST, dimensionMapList);
+ compound.put(TAG_DIMENSION_MAP_LIST, dimensionMapList);
return compound;
}
- private Map getBiomesInDimension(int dimension) {
+ private Map getBiomesInDimension(DimensionType dimension) {
return dimensionMap.computeIfAbsent(dimension,
k -> new ConcurrentHashMap<>(2, 0.75f, 2));
}
/** If no custom tile is set at the specified coordinates, returns -1. */
- public int getBiomeIdAt(int dimension, int x, int z) {
- Integer biomeID = getBiomesInDimension(dimension).get(tempCoords.set(x, z));
- return biomeID == null ? -1 : biomeID;
+ public int getBiomeAt(DimensionType dimension, int x, int z) {
+ Integer i = getBiomesInDimension(dimension).get(tempCoords.set(x, z));
+ return i != null ? i : -1;
}
/** If setting biome on the server, a packet should be sent to all players. */
- public void setBiomeIdAt(int dimension, int x, int z, int biomeID) {
- getBiomesInDimension(dimension).put(new ShortVec2(x, z), biomeID);
+ public void setBiomeAt(DimensionType dimension, int x, int z, int biome) {
+ getBiomesInDimension(dimension).put(new ShortVec2(x, z), biome);
markDirty();
}
- public void removeBiomeAt(int dimension, int x, int z) {
+ public void removeBiomeAt(DimensionType dimension, int x, int z) {
getBiomesInDimension(dimension).remove(tempCoords.set(x, z));
markDirty();
}
/** Send all data to player in several zipped packets. */
- public void syncOnPlayer(EntityPlayer player) {
- for (Integer dimension : dimensionMap.keySet()) {
+ public void syncOnPlayer(PlayerEntity player) {
+ for (DimensionType dimension : dimensionMap.keySet()) {
TilesPacket packet = new TilesPacket(dimension);
Map biomes = getBiomesInDimension(dimension);
for (Entry entry : biomes.entrySet()) {
packet.addTile(entry.getKey().x, entry.getKey().y, entry.getValue());
}
- PacketDispatcher.sendTo(packet, (EntityPlayerMP) player);
+ PacketDispatcher.sendTo(packet, (ServerPlayerEntity) player);
}
- Log.info("Sent custom biome data to player %s", player.getName());
+ Log.info("Sent custom biome data to player %s", player.getCommandSource().getName());
}
}
diff --git a/src/main/java/hunternif/mc/atlas/ext/ExtBiomeDataHandler.java b/src/main/java/hunternif/mc/atlas/ext/ExtBiomeDataHandler.java
index 19a7b5c44..9114d6f9d 100644
--- a/src/main/java/hunternif/mc/atlas/ext/ExtBiomeDataHandler.java
+++ b/src/main/java/hunternif/mc/atlas/ext/ExtBiomeDataHandler.java
@@ -12,12 +12,12 @@ public class ExtBiomeDataHandler {
@SubscribeEvent(priority=EventPriority.HIGHEST)
public void onWorldLoad(WorldEvent.Load event) {
- if (!event.getWorld().isRemote) {
- data = (ExtBiomeData) event.getWorld().loadData(ExtBiomeData.class, DATA_KEY);
+ if (!event.getWorld().G) {
+ data = (ExtBiomeData) event.getWorld().a(ExtBiomeData.class, DATA_KEY);
if (data == null) {
data = new ExtBiomeData(DATA_KEY);
data.markDirty();
- event.getWorld().setData(DATA_KEY, data);
+ event.getWorld().a(DATA_KEY, data);
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/ext/ExtTileIdMap.java b/src/main/java/hunternif/mc/atlas/ext/ExtTileIdMap.java
index 77c017c0c..3f2011133 100644
--- a/src/main/java/hunternif/mc/atlas/ext/ExtTileIdMap.java
+++ b/src/main/java/hunternif/mc/atlas/ext/ExtTileIdMap.java
@@ -5,10 +5,9 @@
import hunternif.mc.atlas.network.PacketDispatcher;
import hunternif.mc.atlas.network.client.TileNameIDPacket;
import hunternif.mc.atlas.util.SaveData;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-
import java.util.Map;
+import net.minecraft.client.network.packet.LoginSuccessS2CPacket;
+import net.minecraft.entity.player.PlayerEntity;
/** Maps unique names of external tiles to pseudo-biome IDs. Set on the server,
@@ -110,7 +109,7 @@ Map getMap() {
}
/** Send all name-biomeID pairs to the player. */
- public void syncOnPlayer(EntityPlayer player) {
- PacketDispatcher.sendTo(new TileNameIDPacket(nameToIdMap), (EntityPlayerMP) player);
+ public void syncOnPlayer(PlayerEntity player) {
+ PacketDispatcher.sendTo(new TileNameIDPacket(nameToIdMap), (LoginSuccessS2CPacket) player);
}
}
diff --git a/src/main/java/hunternif/mc/atlas/ext/ExtTileTextureConfig.java b/src/main/java/hunternif/mc/atlas/ext/ExtTileTextureConfig.java
index 81f493eb8..655e6d3da 100644
--- a/src/main/java/hunternif/mc/atlas/ext/ExtTileTextureConfig.java
+++ b/src/main/java/hunternif/mc/atlas/ext/ExtTileTextureConfig.java
@@ -6,8 +6,8 @@
import hunternif.mc.atlas.client.TextureSetMap;
import hunternif.mc.atlas.util.AbstractJSONConfig;
import hunternif.mc.atlas.util.Log;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+
+
import java.io.File;
import java.util.Map.Entry;
@@ -19,7 +19,7 @@
* Must be loaded after {@link TextureSetConfig}!
* @author Hunternif
*/
-@SideOnly(Side.CLIENT)
+@Environment(EnvType.CLIENT)
public class ExtTileTextureConfig extends AbstractJSONConfig {
private static final int VERSION = 1;
private final TextureSetMap textureSetMap;
diff --git a/src/main/java/hunternif/mc/atlas/ext/ExtTileTextureMap.java b/src/main/java/hunternif/mc/atlas/ext/ExtTileTextureMap.java
index 487f140d3..6b32ccde8 100644
--- a/src/main/java/hunternif/mc/atlas/ext/ExtTileTextureMap.java
+++ b/src/main/java/hunternif/mc/atlas/ext/ExtTileTextureMap.java
@@ -4,8 +4,8 @@
import hunternif.mc.atlas.client.TextureSet;
import hunternif.mc.atlas.util.Log;
import hunternif.mc.atlas.util.SaveData;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+
+
import java.util.HashMap;
import java.util.Map;
@@ -16,7 +16,7 @@
* re-registered into {@link BiomeTextureMap}.
* @author Hunternif
*/
-@SideOnly(Side.CLIENT)
+@Environment(EnvType.CLIENT)
public class ExtTileTextureMap extends SaveData {
private static final ExtTileTextureMap INSTANCE = new ExtTileTextureMap();
public static ExtTileTextureMap instance() {
diff --git a/src/main/java/hunternif/mc/atlas/ext/watcher/DeathWatcher.java b/src/main/java/hunternif/mc/atlas/ext/watcher/DeathWatcher.java
index 9d54b78b4..9eba79bf5 100644
--- a/src/main/java/hunternif/mc/atlas/ext/watcher/DeathWatcher.java
+++ b/src/main/java/hunternif/mc/atlas/ext/watcher/DeathWatcher.java
@@ -2,8 +2,9 @@
import hunternif.mc.atlas.SettingsConfig;
import hunternif.mc.atlas.api.AtlasAPI;
+import hunternif.mc.atlas.registry.MarkerRegistry;
import hunternif.mc.atlas.registry.MarkerTypes;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -14,12 +15,12 @@
public class DeathWatcher {
@SubscribeEvent
public void onPlayerDeath(LivingDeathEvent event) {
- if (event.getEntity() instanceof EntityPlayer && SettingsConfig.gameplay.autoDeathMarker) {
- EntityPlayer player = (EntityPlayer) event.getEntity();
+ if (event.getEntity() instanceof PlayerEntity && SettingsConfig.gameplay.autoDeathMarker) {
+ PlayerEntity player = (PlayerEntity) event.getEntity();
for (int atlasID : AtlasAPI.getPlayerAtlases(player)) {
- AtlasAPI.markers.putMarker(player.getEntityWorld(), true, atlasID, MarkerTypes.TOMB.getRegistryName().toString(),
- "gui.antiqueatlas.marker.tomb " + player.getName(),
- (int)player.posX, (int)player.posZ);
+ AtlasAPI.markers.putMarker(player.getEntityWorld(), true, atlasID, MarkerRegistry.getId(MarkerTypes.TOMB).toString(),
+ "gui.antiqueatlas.marker.tomb " + player.XX_1_12_2_h__XX(),
+ (int)player.x, (int)player.z);
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/ext/watcher/IStructureWatcher.java b/src/main/java/hunternif/mc/atlas/ext/watcher/IStructureWatcher.java
index 9e2ab4e46..1a888182d 100644
--- a/src/main/java/hunternif/mc/atlas/ext/watcher/IStructureWatcher.java
+++ b/src/main/java/hunternif/mc/atlas/ext/watcher/IStructureWatcher.java
@@ -1,12 +1,12 @@
package hunternif.mc.atlas.ext.watcher;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.world.DimensionType;
-import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.world.World;
+import none.XX_1_13_none_bnu_XX;
import java.util.Set;
public interface IStructureWatcher {
@@ -22,7 +22,7 @@ public interface IStructureWatcher {
/**
* @return if the dimension is valid for this watcher
*/
- boolean isDimensionValid(DimensionType type);
+ boolean isDimensionValid(XX_1_13_none_bnu_XX type);
/**
* Return null if a structure should not be attempted to be visited.
@@ -32,7 +32,7 @@ public interface IStructureWatcher {
* @return the NBT tag to read structure data from
*/
@Nullable
- NBTTagCompound getStructureData(@Nonnull World world);
+ CompoundTag getStructureData(@Nonnull World world);
/**
* Called when a world is loaded or a chunk is populated. The return value is used to log what has been visited and where.
@@ -42,5 +42,5 @@ public interface IStructureWatcher {
* @return the locations that have been visited along with a name for it.
*/
@Nonnull
- Set> visitStructure(@Nonnull World world, @Nonnull NBTTagCompound structureTag);
+ Set> visitStructure(@Nonnull World world, @Nonnull CompoundTag structureTag);
}
diff --git a/src/main/java/hunternif/mc/atlas/ext/watcher/StructureWatcher.java b/src/main/java/hunternif/mc/atlas/ext/watcher/StructureWatcher.java
index e7da16739..bb4446d28 100644
--- a/src/main/java/hunternif/mc/atlas/ext/watcher/StructureWatcher.java
+++ b/src/main/java/hunternif/mc/atlas/ext/watcher/StructureWatcher.java
@@ -2,7 +2,7 @@
import com.google.common.collect.Sets;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
@@ -34,16 +34,16 @@ public void onPopulateChunk(PopulateChunkEvent.Post event) {
}
private void handlePotential(World world) {
- if (world.isRemote)
+ if (world.isClient)
return;
for (IStructureWatcher watcher : structureWatchers)
- if (watcher.isDimensionValid(world.provider.getDimensionType())) {
- NBTTagCompound structureData = watcher.getStructureData(world);
+ if (watcher.isDimensionValid(world.dimension.XX_1_13_q_XX())) {
+ CompoundTag structureData = watcher.getStructureData(world);
if (structureData != null) {
Set> visited = watcher.visitStructure(world, structureData);
for (Pair visit : visited)
- Log.info("Visited %s in dimension %d at %s", visit.getRight(), world.provider.getDimension(), visit.getLeft().toString());
+ Log.info("Visited %s in dimension %d at %s", visit.getRight(), world.dimension.getType(), visit.getLeft().toString());
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/ext/watcher/WatcherPos.java b/src/main/java/hunternif/mc/atlas/ext/watcher/WatcherPos.java
index 0dd65b08a..fbf6d8e05 100644
--- a/src/main/java/hunternif/mc/atlas/ext/watcher/WatcherPos.java
+++ b/src/main/java/hunternif/mc/atlas/ext/watcher/WatcherPos.java
@@ -1,9 +1,8 @@
package hunternif.mc.atlas.ext.watcher;
-import net.minecraft.util.math.BlockPos;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import net.minecraft.util.math.BlockPos;
public class WatcherPos {
diff --git a/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherFortress.java b/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherFortress.java
index cec7c3251..39e3f85b9 100644
--- a/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherFortress.java
+++ b/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherFortress.java
@@ -8,16 +8,17 @@
import hunternif.mc.atlas.ext.watcher.StructureWatcher;
import hunternif.mc.atlas.ext.watcher.WatcherPos;
import hunternif.mc.atlas.util.MathUtil;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraft.world.DimensionType;
-import net.minecraft.world.World;
-import net.minecraft.world.gen.structure.MapGenStructureData;
-import net.minecraft.world.gen.structure.StructureBoundingBox;
+import net.minecraft.server.world.ServerWorld;
import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.util.math.MutableIntBoundingBox;
+import net.minecraft.world.World;
+import none.XX_1_12_2_none_bbw_XX;
+import none.XX_1_13_none_bnu_XX;
import java.util.HashSet;
import java.util.Set;
@@ -58,32 +59,32 @@ public Set getVisited() {
}
@Override
- public boolean isDimensionValid(DimensionType type) {
- return type.getId() == -1; // Only nether
+ public boolean isDimensionValid(XX_1_13_none_bnu_XX type) {
+ return type.a() == -1; // Only nether
}
@Nullable
@Override
- public NBTTagCompound getStructureData(@Nonnull World world) {
- MapGenStructureData data = (MapGenStructureData)world.getPerWorldStorage().getOrLoadData(MapGenStructureData.class, "Fortress");
+ public CompoundTag getStructureData(@Nonnull World world) {
+ XX_1_12_2_none_bbw_XX data = ((ServerWorld) world).getPersistentStateManager().a(XX_1_12_2_none_bbw_XX.class, "Fortress");
if (data == null)
return null;
- return data.getTagCompound();
+ return data.a();
}
@Nonnull
@Override
- public Set> visitStructure(@Nonnull World world, @Nonnull NBTTagCompound structureTag) {
+ public Set> visitStructure(@Nonnull World world, @Nonnull CompoundTag structureTag) {
Set> visits = Sets.newHashSet();
- Set tagSet = structureTag.getKeySet();
+ Set tagSet = structureTag.getKeys();
for (String coords : tagSet) {
if (!WatcherPos.POS_PATTERN.matcher(coords).matches())
continue; // Some other kind of data got stuffed in here. It's irrelevant to us
WatcherPos pos = new WatcherPos(coords);
if (!visited.contains(pos)) {
- NBTTagCompound tag = structureTag.getCompoundTag(coords);
+ CompoundTag tag = structureTag.getCompound(coords);
visitFortress(world, tag);
visited.add(pos);
visits.add(Pair.of(pos, "Nether Fortress"));
@@ -94,14 +95,14 @@ public Set> visitStructure(@Nonnull World world, @Nonnu
}
/** Put all child parts of the fortress on the map as global custom tiles. */
- private void visitFortress(World world, NBTTagCompound tag) {
- NBTTagList children = tag.getTagList("Children", 10);
- for (int i = 0; i < children.tagCount(); i++) {
- NBTTagCompound child = children.getCompoundTagAt(i);
+ private void visitFortress(World world, CompoundTag tag) {
+ ListTag children = tag.getList("Children", 10);
+ for (int i = 0; i < children.size(); i++) {
+ CompoundTag child = children.getCompoundTag(i);
String childID = child.getString("id");
- StructureBoundingBox boundingBox = new StructureBoundingBox(child.getIntArray("BB"));
+ MutableIntBoundingBox boundingBox = new MutableIntBoundingBox(child.getIntArray("BB"));
if (BRIDGE.equals(childID)) { // Straight open bridge segment. Is allowed to span several chunks.
- if (boundingBox.getXSize() > 16) {
+ if (boundingBox.getBlockCountX() > 16) {
String tileName = ExtTileIdMap.TILE_NETHER_BRIDGE_X;
int chunkZ = MathUtil.getCenter(boundingBox).getZ() >> 4;
@@ -125,7 +126,7 @@ private void visitFortress(World world, NBTTagCompound tag) {
} else if (BRIDGE_END.equals(childID)) { // End of a straight open bridge segment
String tileName;
int chunkX, chunkZ;
- if (boundingBox.getXSize() > boundingBox.getZSize()) {
+ if (boundingBox.getBlockCountX() > boundingBox.getBlockCountZ()) {
tileName = ExtTileIdMap.TILE_NETHER_BRIDGE_END_X;
chunkX = boundingBox.minX >> 4;
chunkZ = MathUtil.getCenter(boundingBox).getZ() >> 4;
@@ -170,6 +171,6 @@ private void visitFortress(World world, NBTTagCompound tag) {
}
private static boolean noTileAt(World world, int chunkX, int chunkZ) {
- return AntiqueAtlasMod.extBiomeData.getData().getBiomeIdAt(world.provider.getDimension(), chunkX, chunkZ) == -1;
+ return AntiqueAtlasMod.extBiomeData.getData().getBiomeAt(world.dimension.getType(), chunkX, chunkZ) == -1;
}
}
diff --git a/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherGeneric.java b/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherGeneric.java
index afb981502..b04b77fb7 100644
--- a/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherGeneric.java
+++ b/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherGeneric.java
@@ -9,13 +9,15 @@
import hunternif.mc.atlas.ext.watcher.WatcherPos;
import hunternif.mc.atlas.marker.Marker;
import hunternif.mc.atlas.marker.MarkersData;
+import hunternif.mc.atlas.registry.MarkerRegistry;
import hunternif.mc.atlas.registry.MarkerType;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.world.DimensionType;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
-import net.minecraft.world.gen.structure.MapGenStructureData;
import net.minecraftforge.common.DimensionManager;
+import none.XX_1_12_2_none_bbw_XX;
+import none.XX_1_13_none_bnu_XX;
import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nonnull;
@@ -32,9 +34,9 @@ public class StructureWatcherGeneric implements IStructureWatcher {
private MarkerType tileMarker;
private String markerLabel;
private String tileMarkerLabel;
- private final DimensionType dimension;
+ private final XX_1_13_none_bnu_XX dimension;
- public StructureWatcherGeneric(String datFileName, DimensionType dimType, MarkerType marker, String label) {
+ public StructureWatcherGeneric(String datFileName, XX_1_13_none_bnu_XX dimType, MarkerType marker, String label) {
this.marker = marker;
this.markerLabel = label;
this.dimension = dimType;
@@ -54,32 +56,32 @@ public Set getVisited() {
}
@Override
- public boolean isDimensionValid(DimensionType type) {
- return type.getId() == dimension.getId(); // Only in provided dimension
+ public boolean isDimensionValid(XX_1_13_none_bnu_XX type) {
+ return type.a() == dimension.a(); // Only in provided dimension
}
@Nullable
@Override
- public NBTTagCompound getStructureData(@Nonnull World world) {
- MapGenStructureData data = (MapGenStructureData)world.getPerWorldStorage().getOrLoadData(MapGenStructureData.class, datFileName);
+ public CompoundTag getStructureData(@Nonnull World world) {
+ XX_1_12_2_none_bbw_XX data = ((ServerWorld) world).getPersistentStateManager().a(XX_1_12_2_none_bbw_XX.class, datFileName);
if (data == null)
return null;
- return data.getTagCompound();
+ return data.a();
}
@Nonnull
@Override
- public Set> visitStructure(@Nonnull World world, @Nonnull NBTTagCompound structureTag) {
+ public Set> visitStructure(@Nonnull World world, @Nonnull CompoundTag structureTag) {
Set> visits = Sets.newHashSet();
- Set tagSet = structureTag.getKeySet();
+ Set tagSet = structureTag.getKeys();
for (String coords : tagSet) {
if (!WatcherPos.POS_PATTERN.matcher(coords).matches())
continue; // Some other kind of data got stuffed in here. It's irrelevant to us
WatcherPos pos = new WatcherPos(coords);
if (!visited.contains(pos)) {
- NBTTagCompound tag = structureTag.getCompoundTag(coords);
+ CompoundTag tag = structureTag.getCompound(coords);
visit(world, tag);
visited.add(pos);
visits.add(Pair.of(pos, datFileName));
@@ -94,14 +96,14 @@ public StructureWatcherGeneric setTileMarker(MarkerType type, String label) {
return this;
}
- private void visit(World world, NBTTagCompound tag) {
- int chunkX = tag.getInteger("ChunkX");
- int chunkZ = tag.getInteger("ChunkZ");
+ private void visit(World world, CompoundTag tag) {
+ int chunkX = tag.getInt("ChunkX");
+ int chunkZ = tag.getInt("ChunkZ");
boolean foundMarker = false;
boolean foundTileMarker = false;
List markers = AntiqueAtlasMod.globalMarkersData.getData()
- .getMarkersAtChunk(world.provider.getDimension(), chunkX / MarkersData.CHUNK_STEP, chunkZ / MarkersData.CHUNK_STEP);
+ .getMarkersAtChunk(world.dimension.getType(), chunkX / MarkersData.CHUNK_STEP, chunkZ / MarkersData.CHUNK_STEP);
if (markers != null) {
for (Marker marker : markers) {
if (!foundMarker && marker.getChunkX() == chunkX && marker.getChunkZ() == chunkZ &&
@@ -117,9 +119,9 @@ private void visit(World world, NBTTagCompound tag) {
if (SettingsConfig.gameplay.autoVillageMarkers) {
if(!foundMarker)
- AtlasAPI.markers.putGlobalMarker(world, false, marker.getRegistryName().toString(), markerLabel, (chunkX << 4) + 8, (chunkZ << 4) + 8);
+ AtlasAPI.markers.putGlobalMarker(world, false, MarkerRegistry.getId(marker).toString(), markerLabel, (chunkX << 4) + 8, (chunkZ << 4) + 8);
if(tileMarker != null && !foundTileMarker)
- AtlasAPI.markers.putGlobalMarker(world, false, tileMarker.getRegistryName().toString(), tileMarkerLabel, (chunkX << 4) + 8, (chunkZ << 4) + 8);
+ AtlasAPI.markers.putGlobalMarker(world, false, MarkerRegistry.getId(tileMarker).toString(), tileMarkerLabel, (chunkX << 4) + 8, (chunkZ << 4) + 8);
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherVillage.java b/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherVillage.java
index 35c213bfc..f70d29fee 100644
--- a/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherVillage.java
+++ b/src/main/java/hunternif/mc/atlas/ext/watcher/impl/StructureWatcherVillage.java
@@ -15,16 +15,18 @@
import hunternif.mc.atlas.registry.MarkerTypes;
import hunternif.mc.atlas.util.Log;
import hunternif.mc.atlas.util.MathUtil;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraft.world.DimensionType;
-import net.minecraft.world.World;
-import net.minecraft.world.gen.structure.MapGenStructureData;
-import net.minecraft.world.gen.structure.StructureBoundingBox;
+import net.minecraft.server.world.ServerWorld;
+import net.minecraft.world.dimension.DimensionType;
import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.util.math.MutableIntBoundingBox;
+import net.minecraft.world.World;
+import none.XX_1_12_2_none_bbw_XX;
+import none.XX_1_13_none_bnu_XX;
import java.util.*;
public class StructureWatcherVillage implements IStructureWatcher {
@@ -99,24 +101,24 @@ public Set getVisited() {
}
@Override
- public boolean isDimensionValid(DimensionType type) {
- return type.getId() == 0; // Only overworld
+ public boolean isDimensionValid(XX_1_13_none_bnu_XX type) {
+ return type.a() == 0; // Only overworld
}
@Nullable
@Override
- public NBTTagCompound getStructureData(@Nonnull World world) {
- MapGenStructureData data = (MapGenStructureData)world.getPerWorldStorage().getOrLoadData(MapGenStructureData.class, "Village");
+ public CompoundTag getStructureData(@Nonnull World world) {
+ XX_1_12_2_none_bbw_XX data = ((ServerWorld) world).getPersistentStateManager().a(XX_1_12_2_none_bbw_XX.class, "Village");
if (data == null)
return null;
- return data.getTagCompound();
+ return data.a();
}
@Nonnull
@Override
- public Set> visitStructure(@Nonnull World world, @Nonnull NBTTagCompound structureTag) {
- Set tagSet = structureTag.getKeySet();
+ public Set> visitStructure(@Nonnull World world, @Nonnull CompoundTag structureTag) {
+ Set tagSet = structureTag.getKeys();
Set> visits = Sets.newHashSet();
for (String coords : tagSet) {
if (!WatcherPos.POS_PATTERN.matcher(coords).matches())
@@ -124,7 +126,7 @@ public Set> visitStructure(@Nonnull World world, @Nonnu
WatcherPos pos = new WatcherPos(coords);
if (!visited.contains(pos)) {
- NBTTagCompound tag = structureTag.getCompoundTag(coords);
+ CompoundTag tag = structureTag.getCompound(coords);
visitVillage(world, tag);
visited.add(pos);
visits.add(Pair.of(pos, "Village"));
@@ -134,18 +136,18 @@ public Set> visitStructure(@Nonnull World world, @Nonnu
}
/** Put all child parts of the fortress on the map as global custom tiles. */
- private void visitVillage(World world, NBTTagCompound tag) {
+ private void visitVillage(World world, CompoundTag tag) {
if (!tag.getBoolean("Valid")) {
// The village was not actually generated and should not be mapped.
// Remove legacy marker and custom tile:
removeVillage(world, tag);
return;
}
- NBTTagList children = tag.getTagList("Children", 10);
- for (int i = 0; i < children.tagCount(); i++) {
- NBTTagCompound child = children.getCompoundTagAt(i);
+ ListTag children = tag.getList("Children", 10);
+ for (int i = 0; i < children.size(); i++) {
+ CompoundTag child = children.getCompoundTag(i);
String childID = child.getString("id");
- StructureBoundingBox boundingBox = new StructureBoundingBox(child.getIntArray("BB"));
+ MutableIntBoundingBox boundingBox = new MutableIntBoundingBox(child.getIntArray("BB"));
int x = MathUtil.getCenter(boundingBox).getX();
int z = MathUtil.getCenter(boundingBox).getZ();
int chunkX = x >> 4;
@@ -158,7 +160,7 @@ private void visitVillage(World world, NBTTagCompound tag) {
for (int j = -1; j <= 1; j++) {
for (int k = -1; k <= 1; k++) {
List markers = AntiqueAtlasMod.globalMarkersData.getData()
- .getMarkersAtChunk(world.provider.getDimension(), j + chunkX / MarkersData.CHUNK_STEP, k + chunkZ / MarkersData.CHUNK_STEP);
+ .getMarkersAtChunk(world.dimension.getType(), j + chunkX / MarkersData.CHUNK_STEP, k + chunkZ / MarkersData.CHUNK_STEP);
if (markers != null) {
for (Marker marker : markers) {
if (marker.getType().equals(MarkerTypes.VILLAGE)) {
@@ -170,7 +172,7 @@ private void visitVillage(World world, NBTTagCompound tag) {
}
}
if (!foundMarker && SettingsConfig.gameplay.autoVillageMarkers) {
- AtlasAPI.markers.putGlobalMarker(world, false, MarkerTypes.VILLAGE.getRegistryName().toString(), "gui.antiqueatlas.marker.village", x, z);
+ AtlasAPI.markers.putGlobalMarker(world, false, MarkerTypes.VILLAGE.getRegistryName().XX_1_12_2_toString_XX(), "gui.antiqueatlas.marker.village", x, z);
}
}
// String tileName = null;
@@ -200,24 +202,24 @@ private void visitVillage(World world, NBTTagCompound tag) {
}
private static String tileAt(int chunkX, int chunkZ) {
- int biomeID = AntiqueAtlasMod.extBiomeData.getData().getBiomeIdAt(0, chunkX, chunkZ);
+ int biomeID = AntiqueAtlasMod.extBiomeData.getData().getBiomeAt(DimensionType.OVERWORLD, chunkX, chunkZ);
return ExtTileIdMap.instance().getPseudoBiomeName(biomeID);
}
/** Delete the marker and custom tile data about the village. */
- private static void removeVillage(World world, NBTTagCompound tag) {
- NBTTagList children = tag.getTagList("Children", 10);
- for (int i = 0; i < children.tagCount(); i++) {
- NBTTagCompound child = children.getCompoundTagAt(i);
+ private static void removeVillage(World world, CompoundTag tag) {
+ ListTag children = tag.getList("Children", 10);
+ for (int i = 0; i < children.size(); i++) {
+ CompoundTag child = children.getCompoundTag(i);
String childID = child.getString("id");
- StructureBoundingBox boundingBox = new StructureBoundingBox(child.getIntArray("BB"));
+ MutableIntBoundingBox boundingBox = new MutableIntBoundingBox(child.getIntArray("BB"));
int x = MathUtil.getCenter(boundingBox).getX();
int z = MathUtil.getCenter(boundingBox).getZ();
int chunkX = x >> 4;
int chunkZ = z >> 4;
if (START.equals(childID)) {
List markers = AntiqueAtlasMod.globalMarkersData.getData()
- .getMarkersAtChunk(world.provider.getDimension(), chunkX / MarkersData.CHUNK_STEP, chunkZ / MarkersData.CHUNK_STEP);
+ .getMarkersAtChunk(world.dimension.getType(), chunkX / MarkersData.CHUNK_STEP, chunkZ / MarkersData.CHUNK_STEP);
if (markers != null) {
for (Marker marker : markers) {
if (marker.getType().equals(MarkerTypes.VILLAGE)) {
diff --git a/src/main/java/hunternif/mc/atlas/item/ItemAtlas.java b/src/main/java/hunternif/mc/atlas/item/ItemAtlas.java
index 8e6be662b..22b31c49a 100644
--- a/src/main/java/hunternif/mc/atlas/item/ItemAtlas.java
+++ b/src/main/java/hunternif/mc/atlas/item/ItemAtlas.java
@@ -1,70 +1,72 @@
package hunternif.mc.atlas.item;
import java.util.ArrayList;
-
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ActionResult;
+import net.minecraft.util.Hand;
+import net.minecraft.util.TypedActionResult;
+import net.minecraft.world.World;
import hunternif.mc.atlas.AntiqueAtlasMod;
import hunternif.mc.atlas.core.AtlasData;
import hunternif.mc.atlas.core.TileInfo;
import hunternif.mc.atlas.marker.MarkersData;
import hunternif.mc.atlas.network.PacketDispatcher;
import hunternif.mc.atlas.network.client.DimensionUpdatePacket;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.ActionResult;
-import net.minecraft.util.EnumActionResult;
-import net.minecraft.util.EnumHand;
-import net.minecraft.world.World;
public class ItemAtlas extends Item {
static final String WORLD_ATLAS_DATA_ID = "aAtlas";
- public ItemAtlas() {
- setTranslationKey("antiqueAtlas");
- setHasSubtypes(true);
+ public ItemAtlas(Item.Settings settings) {
+ super(settings);
}
- @Override
- public String getItemStackDisplayName(ItemStack stack) {
- return super.getItemStackDisplayName(stack) + " #" + stack.getItemDamage();
+ public int getAtlasID(ItemStack stack) {
+ return stack.getOrCreateTag().getInt("atlasID");
}
+ /* @Override
+ public String i(ItemStack stack) {
+ return super.XX_1_13_i_XX(stack) + " #" + stack.getDamage();
+ } */
+
@Override
- public ActionResult onItemRightClick(World world, EntityPlayer playerIn,
- EnumHand hand) {
- ItemStack stack = playerIn.getHeldItem(hand);
+ public TypedActionResult use(World world, PlayerEntity playerIn,
+ Hand hand) {
+ ItemStack stack = playerIn.getStackInHand(hand);
- if (world.isRemote) {
+ if (world.isClient) {
AntiqueAtlasMod.proxy.openAtlasGUI(stack);
}
- return new ActionResult<>(EnumActionResult.SUCCESS, stack);
+ return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
@Override
- public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isEquipped) {
+ public void onEntityTick(ItemStack stack, World world, Entity entity, int slot, boolean isEquipped) {
AtlasData data = AntiqueAtlasMod.atlasData.getAtlasData(stack, world);
- if (data == null || !(entity instanceof EntityPlayer)) return;
+ if (data == null || !(entity instanceof PlayerEntity)) return;
// On the first run send the map from the server to the client:
- EntityPlayer player = (EntityPlayer) entity;
- if (!world.isRemote && !data.isSyncedOnPlayer(player) && !data.isEmpty()) {
- data.syncOnPlayer(stack.getItemDamage(), player);
+ PlayerEntity player = (PlayerEntity) entity;
+ if (!world.isClient && !data.isSyncedOnPlayer(player) && !data.isEmpty()) {
+ data.syncOnPlayer(stack.getDamage(), player);
}
// Same thing with the local markers:
MarkersData markers = AntiqueAtlasMod.markersData.getMarkersData(stack, world);
- if (!world.isRemote && !markers.isSyncedOnPlayer(player) && !markers.isEmpty()) {
- markers.syncOnPlayer(stack.getItemDamage(), player);
+ if (!world.isClient && !markers.isSyncedOnPlayer(player) && !markers.isEmpty()) {
+ markers.syncOnPlayer(stack.getDamage(), player);
}
// Updating map around player
ArrayList newTiles = data.updateMapAroundPlayer(player);
- if (!world.isRemote) {
+ if (!world.isClient) {
if (newTiles.size() > 0) {
- DimensionUpdatePacket packet = new DimensionUpdatePacket(stack.getItemDamage(), player.dimension);
+ DimensionUpdatePacket packet = new DimensionUpdatePacket(stack.getDamage(), player.dimension);
for (TileInfo t : newTiles) {
packet.addTile(t.x, t.z, t.biome);
}
diff --git a/src/main/java/hunternif/mc/atlas/item/ItemEmptyAtlas.java b/src/main/java/hunternif/mc/atlas/item/ItemEmptyAtlas.java
index e9ab635fb..35c725571 100644
--- a/src/main/java/hunternif/mc/atlas/item/ItemEmptyAtlas.java
+++ b/src/main/java/hunternif/mc/atlas/item/ItemEmptyAtlas.java
@@ -5,52 +5,52 @@
import hunternif.mc.atlas.SettingsConfig;
import hunternif.mc.atlas.core.AtlasData;
import hunternif.mc.atlas.marker.MarkersData;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
+import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
-import net.minecraft.util.EnumActionResult;
-import net.minecraft.util.EnumHand;
+import net.minecraft.util.Hand;
+import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
-import net.minecraftforge.common.ForgeHooks;
public class ItemEmptyAtlas extends Item {
-
- public ItemEmptyAtlas() {
- setTranslationKey("emptyAntiqueAtlas");
- setCreativeTab(CreativeTabs.TOOLS);
+ public ItemEmptyAtlas(Item.Settings settings) {
+ super(settings);
}
@Override
- public ActionResult onItemRightClick(World world, EntityPlayer player,
- EnumHand hand) {
- ItemStack stack = player.getHeldItem(hand);
- if (world.isRemote)
- return new ActionResult<>(EnumActionResult.SUCCESS, stack);
-
- int atlasID = world.getUniqueDataId(ItemAtlas.WORLD_ATLAS_DATA_ID);
- ItemStack atlasStack = new ItemStack(RegistrarAntiqueAtlas.ATLAS, 1, atlasID);
+ public TypedActionResult use(World world, PlayerEntity player,
+ Hand hand) {
+ ItemStack stack = player.getStackInHand(hand);
+ if (world.isClient)
+ return new TypedActionResult<>(ActionResult.SUCCESS, stack);
+
+ int atlasID = AntiqueAtlasMod.getGlobalAtlasData(world).getNextAtlasId();
+ ItemStack atlasStack = new ItemStack(RegistrarAntiqueAtlas.ATLAS);
+
+ atlasStack.getOrCreateTag().putInt("atlasID", atlasID);
AtlasData atlasData = AntiqueAtlasMod.atlasData.getAtlasData(atlasID, world);
atlasData.getDimensionData(player.dimension).setBrowsingPosition(
- (int)Math.round(-player.posX * SettingsConfig.userInterface.defaultScale),
- (int)Math.round(-player.posZ * SettingsConfig.userInterface.defaultScale),
+ (int)Math.round(-player.x * SettingsConfig.userInterface.defaultScale),
+ (int)Math.round(-player.z * SettingsConfig.userInterface.defaultScale),
SettingsConfig.userInterface.defaultScale);
atlasData.markDirty();
MarkersData markersData = AntiqueAtlasMod.markersData.getMarkersData(atlasID, world);
markersData.markDirty();
- stack.shrink(1);
+ stack.subtractAmount(1);
if (stack.isEmpty()) {
- return new ActionResult<>(EnumActionResult.SUCCESS, atlasStack);
+ return new TypedActionResult<>(ActionResult.SUCCESS, atlasStack);
} else {
- if (!player.inventory.addItemStackToInventory(atlasStack.copy())) {
- ForgeHooks.onPlayerTossEvent(player, atlasStack, false);
+ if (!player.inventory.insertStack(atlasStack.copy())) {
+ // TODO FABRIC
+ // ForgeHooks.onPlayerTossEvent(player, atlasStack, false);
}
- return new ActionResult<>(EnumActionResult.SUCCESS, stack);
+ return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/item/RecipeAtlasCloning.java b/src/main/java/hunternif/mc/atlas/item/RecipeAtlasCloning.java
index 6bebb1db2..98a9dca92 100644
--- a/src/main/java/hunternif/mc/atlas/item/RecipeAtlasCloning.java
+++ b/src/main/java/hunternif/mc/atlas/item/RecipeAtlasCloning.java
@@ -1,19 +1,30 @@
package hunternif.mc.atlas.item;
import hunternif.mc.atlas.RegistrarAntiqueAtlas;
-import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.inventory.CraftingInventory;
+import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
+import net.minecraft.recipe.RecipeSerializer;
+import net.minecraft.recipe.RecipeType;
+import net.minecraft.recipe.SpecialRecipeSerializer;
+import net.minecraft.util.Identifier;
import net.minecraft.world.World;
public class RecipeAtlasCloning extends RecipeBase {
+ public static final RecipeSerializer> SERIALIZER = new SpecialRecipeSerializer<>(RecipeAtlasCloning::new);
+ private final Identifier id;
+
+ public RecipeAtlasCloning(Identifier identifier) {
+ this.id = identifier;
+ }
@Override
- public boolean matches(InventoryCrafting inv, World world) {
+ public boolean matches(Inventory inv, World world) {
int i = 0; // number of empty atlases
ItemStack filledAtlas = ItemStack.EMPTY;
- for (int j = 0; j < inv.getSizeInventory(); ++j) {
- ItemStack stack = inv.getStackInSlot(j);
+ for (int j = 0; j < inv.getInvSize(); ++j) {
+ ItemStack stack = inv.getInvStack(j);
if (!stack.isEmpty()) {
if (stack.getItem() == RegistrarAntiqueAtlas.ATLAS) {
@@ -34,12 +45,12 @@ public boolean matches(InventoryCrafting inv, World world) {
}
@Override
- public ItemStack getCraftingResult(InventoryCrafting inv) {
+ public ItemStack craft(Inventory inv) {
int i = 0; // number of new copies
ItemStack filledAtlas = ItemStack.EMPTY;
- for (int j = 0; j < inv.getSizeInventory(); ++j) {
- ItemStack stack = inv.getStackInSlot(j);
+ for (int j = 0; j < inv.getInvSize(); ++j) {
+ ItemStack stack = inv.getInvStack(j);
if (!stack.isEmpty()) {
if (stack.getItem() == RegistrarAntiqueAtlas.ATLAS) {
@@ -57,10 +68,11 @@ public ItemStack getCraftingResult(InventoryCrafting inv) {
}
if (!filledAtlas.isEmpty() && i >= 1) {
- ItemStack newAtlas = new ItemStack(RegistrarAntiqueAtlas.ATLAS, i + 1, filledAtlas.getItemDamage());
+ ItemStack newAtlas = new ItemStack(RegistrarAntiqueAtlas.ATLAS, i + 1);
+ newAtlas.getOrCreateTag().putInt("atlasID", RegistrarAntiqueAtlas.ATLAS.getAtlasID(filledAtlas));
if (filledAtlas.hasDisplayName()) {
- newAtlas.setStackDisplayName(filledAtlas.getDisplayName());
+ newAtlas.setDisplayName(filledAtlas.getDisplayName());
}
return newAtlas;
@@ -70,12 +82,27 @@ public ItemStack getCraftingResult(InventoryCrafting inv) {
}
@Override
- public boolean canFit(int width, int height) {
+ public boolean fits(int width, int height) {
return true;
}
@Override
- public ItemStack getRecipeOutput() {
+ public ItemStack getOutput() {
return ItemStack.EMPTY;
}
+
+ @Override
+ public Identifier getId() {
+ return id;
+ }
+
+ @Override
+ public RecipeSerializer> getSerializer() {
+ return SERIALIZER;
+ }
+
+ @Override
+ public RecipeType> getType() {
+ return RecipeType.CRAFTING;
+ }
}
diff --git a/src/main/java/hunternif/mc/atlas/item/RecipeAtlasCombining.java b/src/main/java/hunternif/mc/atlas/item/RecipeAtlasCombining.java
index 57592632b..739835190 100644
--- a/src/main/java/hunternif/mc/atlas/item/RecipeAtlasCombining.java
+++ b/src/main/java/hunternif/mc/atlas/item/RecipeAtlasCombining.java
@@ -5,14 +5,17 @@
import hunternif.mc.atlas.core.AtlasData;
import hunternif.mc.atlas.marker.Marker;
import hunternif.mc.atlas.marker.MarkersData;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.inventory.CraftingInventory;
+import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
+import net.minecraft.recipe.RecipeSerializer;
+import net.minecraft.recipe.RecipeType;
+import net.minecraft.recipe.SpecialRecipeSerializer;
+import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
-
import java.util.ArrayList;
import java.util.List;
@@ -22,20 +25,22 @@
* @author Hunternif
*/
public class RecipeAtlasCombining extends RecipeBase {
+ public static final RecipeSerializer SERIALIZER = new SpecialRecipeSerializer<>(RecipeAtlasCombining::new);
+ private final Identifier id;
- public RecipeAtlasCombining() {
- MinecraftForge.EVENT_BUS.register(this);
+ public RecipeAtlasCombining(Identifier id) {
+ this.id = id;
}
@Override
- public boolean matches(InventoryCrafting inv, World world) {
+ public boolean matches(Inventory inv, World world) {
return matches(inv);
}
- private boolean matches(IInventory inv) {
+ private boolean matches(Inventory inv) {
int atlasesFound = 0;
- for (int i = 0; i < inv.getSizeInventory(); ++i) {
- ItemStack stack = inv.getStackInSlot(i);
+ for (int i = 0; i < inv.getInvSize(); ++i) {
+ ItemStack stack = inv.getInvStack(i);
if (!stack.isEmpty()) {
if (stack.getItem() == RegistrarAntiqueAtlas.ATLAS) {
atlasesFound++;
@@ -46,17 +51,17 @@ private boolean matches(IInventory inv) {
}
@Override
- public ItemStack getCraftingResult(InventoryCrafting inv) {
+ public ItemStack craft(Inventory inv) {
ItemStack firstAtlas = ItemStack.EMPTY;
List atlasIds = new ArrayList<>(9);
- for (int i = 0; i < inv.getSizeInventory(); ++i) {
- ItemStack stack = inv.getStackInSlot(i);
+ for (int i = 0; i < inv.getInvSize(); ++i) {
+ ItemStack stack = inv.getInvStack(i);
if (!stack.isEmpty()) {
if (stack.getItem() == RegistrarAntiqueAtlas.ATLAS) {
if (firstAtlas.isEmpty()) {
firstAtlas = stack;
} else {
- atlasIds.add(stack.getItemDamage());
+ atlasIds.add(stack.getDamage());
}
}
}
@@ -64,33 +69,43 @@ public ItemStack getCraftingResult(InventoryCrafting inv) {
return atlasIds.size() < 1 ? ItemStack.EMPTY : firstAtlas.copy();
}
- @Override
- public boolean canFit(int width, int height) {
+ @Override
+ public boolean fits(int width, int height) {
return true;
}
- @Override
- public ItemStack getRecipeOutput() {
- return ItemStack.EMPTY;
+ @Override
+ public Identifier getId() {
+ return id;
+ }
+
+ @Override
+ public RecipeSerializer> getSerializer() {
+ return SERIALIZER;
+ }
+
+ @Override
+ public RecipeType> getType() {
+ return RecipeType.CRAFTING;
}
@SubscribeEvent
public void onCrafted(ItemCraftedEvent event) {
// Make sure it's the same recipe:
- if (event.crafting.getItem() != RegistrarAntiqueAtlas.ATLAS || !matches(event.craftMatrix)) {
+ if (event.crafting.c() != RegistrarAntiqueAtlas.ATLAS || !matches(event.craftMatrix)) {
return;
}
World world = event.player.getEntityWorld();
- if (world.isRemote) return;
+ if (world.isClient) return;
// Until the first update, on the client the returned atlas ID is the same as the first Atlas on the crafting grid.
- int atlasID = world.getUniqueDataId(ItemAtlas.WORLD_ATLAS_DATA_ID);
+ int atlasID = world.XX_1_13_b_XX(ItemAtlas.WORLD_ATLAS_DATA_ID);
AtlasData destBiomes = AntiqueAtlasMod.atlasData.getAtlasData(atlasID, world);
destBiomes.markDirty();
MarkersData destMarkers = AntiqueAtlasMod.markersData.getMarkersData(atlasID, world);
destMarkers.markDirty();
- for (int i = 0; i < event.craftMatrix.getSizeInventory(); ++i) {
- ItemStack stack = event.craftMatrix.getStackInSlot(i);
+ for (int i = 0; i < event.craftMatrix.w_(); ++i) {
+ ItemStack stack = event.craftMatrix.a(i);
if (stack.isEmpty()) continue;
AtlasData srcBiomes = AntiqueAtlasMod.atlasData.getAtlasData(stack, world);
if (destBiomes != null && srcBiomes != null && destBiomes != srcBiomes) {
@@ -111,6 +126,6 @@ public void onCrafted(ItemCraftedEvent event) {
// Set item damage last, because otherwise we wouldn't be able copy the
// data from the atlas which was used as a placeholder for the result.
- event.crafting.setItemDamage(atlasID);
+ event.crafting.b(atlasID);
}
}
diff --git a/src/main/java/hunternif/mc/atlas/item/RecipeBase.java b/src/main/java/hunternif/mc/atlas/item/RecipeBase.java
index 4ac259924..89d9c2d3f 100644
--- a/src/main/java/hunternif/mc/atlas/item/RecipeBase.java
+++ b/src/main/java/hunternif/mc/atlas/item/RecipeBase.java
@@ -1,23 +1,12 @@
package hunternif.mc.atlas.item;
import hunternif.mc.atlas.AntiqueAtlasMod;
-import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
-import net.minecraft.item.crafting.IRecipe;
-import net.minecraft.util.NonNullList;
-import net.minecraftforge.registries.IForgeRegistryEntry;
-
-abstract class RecipeBase extends IForgeRegistryEntry.Impl implements IRecipe {
- @Override
- public NonNullList getRemainingItems(InventoryCrafting inv) {
- NonNullList aitemstack = NonNullList.create();
- for (int i = 0; i < inv.getSizeInventory(); ++i) {
- ItemStack itemstack = inv.getStackInSlot(i);
- aitemstack.add(net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack));
- }
- return aitemstack;
- }
+import net.minecraft.recipe.Recipe;
+import net.minecraft.util.DefaultedList;
+abstract class RecipeBase implements Recipe {
// @Override
// public boolean isHidden() {
// return true;
diff --git a/src/main/java/hunternif/mc/atlas/marker/DimensionMarkersData.java b/src/main/java/hunternif/mc/atlas/marker/DimensionMarkersData.java
index 37f9ac473..89a90d416 100644
--- a/src/main/java/hunternif/mc/atlas/marker/DimensionMarkersData.java
+++ b/src/main/java/hunternif/mc/atlas/marker/DimensionMarkersData.java
@@ -2,6 +2,7 @@
import hunternif.mc.atlas.util.ListMapValueIterator;
import hunternif.mc.atlas.util.ShortVec2;
+import net.minecraft.world.dimension.DimensionType;
import java.util.AbstractCollection;
import java.util.Collection;
@@ -13,7 +14,7 @@
public class DimensionMarkersData {
private final MarkersData parent;
- private final int dimension;
+ private final DimensionType dimension;
private int size = 0;
@@ -30,12 +31,12 @@ private ShortVec2 getKey() {
return thread2KeyMap.computeIfAbsent(Thread.currentThread(), k -> new ShortVec2(0, 0));
}
- public DimensionMarkersData(MarkersData parent, int dimension) {
+ public DimensionMarkersData(MarkersData parent, DimensionType dimension) {
this.parent = parent;
this.dimension = dimension;
}
- public int getDimension() {
+ public DimensionType getDimension() {
return dimension;
}
diff --git a/src/main/java/hunternif/mc/atlas/marker/GlobalMarkersData.java b/src/main/java/hunternif/mc/atlas/marker/GlobalMarkersData.java
index 17f1bebc6..fd3fe5f4c 100644
--- a/src/main/java/hunternif/mc/atlas/marker/GlobalMarkersData.java
+++ b/src/main/java/hunternif/mc/atlas/marker/GlobalMarkersData.java
@@ -2,7 +2,7 @@
import hunternif.mc.atlas.network.client.MarkersPacket;
import hunternif.mc.atlas.registry.MarkerType;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.PlayerEntity;
/** Holds global markers, i.e. ones that appear in all atlases. */
public class GlobalMarkersData extends MarkersData {
@@ -22,7 +22,7 @@ public Marker loadMarker(Marker marker) {
}
/** Send all data to the player in several packets. */
- void syncOnPlayer(EntityPlayer player) {
+ void syncOnPlayer(PlayerEntity player) {
syncOnPlayer(-1, player);
}
diff --git a/src/main/java/hunternif/mc/atlas/marker/GlobalMarkersDataHandler.java b/src/main/java/hunternif/mc/atlas/marker/GlobalMarkersDataHandler.java
index 9c73b012c..5190364cb 100644
--- a/src/main/java/hunternif/mc/atlas/marker/GlobalMarkersDataHandler.java
+++ b/src/main/java/hunternif/mc/atlas/marker/GlobalMarkersDataHandler.java
@@ -25,12 +25,12 @@ public class GlobalMarkersDataHandler {
@SubscribeEvent(priority=EventPriority.HIGHEST)
public void onWorldLoad(WorldEvent.Load event) {
- if (!event.getWorld().isRemote && event.getWorld().provider.getDimension() == 0) {
- data = (GlobalMarkersData) event.getWorld().loadData(GlobalMarkersData.class, DATA_KEY);
+ if (!event.getWorld().G && event.getWorld().s.getType() == 0) {
+ data = (GlobalMarkersData) event.getWorld().a(GlobalMarkersData.class, DATA_KEY);
if (data == null) {
data = new GlobalMarkersData(DATA_KEY);
data.markDirty();
- event.getWorld().setData(DATA_KEY, data);
+ event.getWorld().a(DATA_KEY, data);
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/marker/Marker.java b/src/main/java/hunternif/mc/atlas/marker/Marker.java
index 8f0f0f995..8aabc261b 100644
--- a/src/main/java/hunternif/mc/atlas/marker/Marker.java
+++ b/src/main/java/hunternif/mc/atlas/marker/Marker.java
@@ -2,7 +2,8 @@
import hunternif.mc.atlas.util.Log;
import hunternif.mc.atlas.util.ShortVec2;
-import net.minecraft.client.resources.I18n;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.world.dimension.DimensionType;
/**
* Marker on the map in an atlas. Has a type and a text label.
@@ -20,13 +21,14 @@ public class Marker {
private final int id;
private final String type;
private final String label;
- private final int dim, x, z;
+ private final DimensionType dim;
+ private final int x, z;
private final boolean visibleAhead;
private boolean isGlobal;
//TODO make an option for the marker to disappear at a certain scale.
- public Marker(int id, String type, String label, int dimension, int x, int z, boolean visibleAhead) {
+ public Marker(int id, String type, String label, DimensionType dimension, int x, int z, boolean visibleAhead) {
this.id = id;
if (type.length() > TYPE_LIMIT){
type = type.substring(0, TYPE_LIMIT);
@@ -64,20 +66,20 @@ public String getLocalizedLabel() {
// string parameter, i.e. player's name.
int whitespaceIndex = label.indexOf(' ');
if (whitespaceIndex == -1) {
- return I18n.format(label);
+ return I18n.translate(label);
} else {
String key = label.substring(0, whitespaceIndex);
String param = label.substring(whitespaceIndex + 1);
- String translated = I18n.format(key);
+ String translated = I18n.translate(key);
if (!key.equals(translated)) { // Make sure translation succeeded
- return String.format(I18n.format(key), param);
+ return String.format(I18n.translate(key), param);
} else {
return label;
}
}
}
- public int getDimension() {
+ public DimensionType getDimension() {
return dim;
}
diff --git a/src/main/java/hunternif/mc/atlas/marker/MarkerTextureConfig.java b/src/main/java/hunternif/mc/atlas/marker/MarkerTextureConfig.java
index 771929564..e71ec5a8e 100644
--- a/src/main/java/hunternif/mc/atlas/marker/MarkerTextureConfig.java
+++ b/src/main/java/hunternif/mc/atlas/marker/MarkerTextureConfig.java
@@ -8,11 +8,9 @@
import java.util.PriorityQueue;
import java.util.Queue;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-import net.minecraft.util.ResourceLocation;
-
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.util.Identifier;
import org.apache.commons.io.IOUtils;
import com.google.gson.JsonElement;
@@ -28,7 +26,7 @@
* Maps marker type to texture.
* @author Hunternif
*/
-@SideOnly(Side.CLIENT)
+@Environment(EnvType.CLIENT)
public class MarkerTextureConfig extends AbstractJSONConfig {
private static final int VERSION = 1;
@@ -64,26 +62,26 @@ protected void loadData(JsonObject json, MarkerRegistry data, int version) {
}
JsonObject object = (JsonObject) entry.getValue();
- ResourceLocation key = MarkerRegistry.getLoc(markerType);
+ Identifier key = MarkerRegistry.getLoc(markerType);
if(MarkerRegistry.hasKey(key)) {
MarkerRegistry.find(key).getJSONData().readFrom(object);
} else {
MarkerType type = new MarkerType(key);
type.getJSONData().readFrom(object);
type.setIsFromJson(true);
- MarkerRegistry.register(type);
+ MarkerRegistry.register(key, type);
}
}
}
@Override
protected void saveData(JsonObject json, MarkerRegistry data) {
- Queue queue = new PriorityQueue<>(Comparator.comparing(ResourceLocation::toString));
+ Queue queue = new PriorityQueue<>(Comparator.comparing(Identifier::toString));
queue.addAll(MarkerRegistry.getKeys());
json.add(EXAMPLE_LOC, EXAMPLE_JSON);
while (!queue.isEmpty()) {
- ResourceLocation key = queue.poll();
+ Identifier key = queue.poll();
JsonObject value = new JsonObject();
MarkerRegistry.find(key).getJSONData().saveTo(value);
json.add(key.toString(), value);
diff --git a/src/main/java/hunternif/mc/atlas/marker/MarkersData.java b/src/main/java/hunternif/mc/atlas/marker/MarkersData.java
index b625738ce..4c1cf9691 100644
--- a/src/main/java/hunternif/mc/atlas/marker/MarkersData.java
+++ b/src/main/java/hunternif/mc/atlas/marker/MarkersData.java
@@ -5,13 +5,15 @@
import hunternif.mc.atlas.network.PacketDispatcher;
import hunternif.mc.atlas.network.client.MarkersPacket;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraft.world.storage.WorldSavedData;
-import net.minecraftforge.common.util.Constants;
-
+import net.fabricmc.fabric.api.util.NbtType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.util.Identifier;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.PersistentState;
+import net.minecraft.world.dimension.DimensionType;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
@@ -26,7 +28,7 @@
*
* @author Hunternif
*/
-public class MarkersData extends WorldSavedData {
+public class MarkersData extends PersistentState {
private static final int VERSION = 3;
private static final String TAG_VERSION = "aaVersion";
private static final String TAG_DIMENSION_MAP_LIST = "dimMap";
@@ -44,7 +46,7 @@ public class MarkersData extends WorldSavedData {
public static final int CHUNK_STEP = 8;
/** Set of players this data has been sent to, only once after they connect. */
- private final Set playersSentTo = new HashSet<>();
+ private final Set playersSentTo = new HashSet<>();
private final AtomicInteger largestID = new AtomicInteger(0);
@@ -63,7 +65,7 @@ private int getNewID() {
* TODO: consider using Quad-tree. At small zoom levels iterating through
* chunks to render markers gets very slow.
*/
- private final Map dimensionMap =
+ private final Map dimensionMap =
new ConcurrentHashMap<>(2, 0.75f, 2);
public MarkersData(String key) {
@@ -72,19 +74,24 @@ public MarkersData(String key) {
@Override
- public void readFromNBT(NBTTagCompound compound) {
- int version = compound.getInteger(TAG_VERSION);
+ public void fromTag(CompoundTag compound) {
+ int version = compound.getInt(TAG_VERSION);
if (version < VERSION) {
Log.warn("Outdated atlas data format! Was %d but current is %d", version, VERSION);
this.markDirty();
}
- NBTTagList dimensionMapList = compound.getTagList(TAG_DIMENSION_MAP_LIST, Constants.NBT.TAG_COMPOUND);
- for (int d = 0; d < dimensionMapList.tagCount(); d++) {
- NBTTagCompound tag = dimensionMapList.getCompoundTagAt(d);
- int dimensionID = tag.getInteger(TAG_DIMENSION_ID);
- NBTTagList tagList = tag.getTagList(TAG_MARKERS, Constants.NBT.TAG_COMPOUND);
- for (int i = 0; i < tagList.tagCount(); i++) {
- NBTTagCompound markerTag = tagList.getCompoundTagAt(i);
+ ListTag dimensionMapList = compound.getList(TAG_DIMENSION_MAP_LIST, NbtType.COMPOUND);
+ for (int d = 0; d < dimensionMapList.size(); d++) {
+ CompoundTag tag = dimensionMapList.getCompoundTag(d);
+ DimensionType dimensionID;
+ if (tag.containsKey(TAG_DIMENSION_ID, NbtType.NUMBER)) {
+ dimensionID = Registry.DIMENSION.get(tag.getInt(TAG_DIMENSION_ID));
+ } else {
+ dimensionID = Registry.DIMENSION.get(new Identifier(tag.getString(TAG_DIMENSION_ID)));
+ }
+ ListTag tagList = tag.getList(TAG_MARKERS, NbtType.COMPOUND);
+ for (int i = 0; i < tagList.size(); i++) {
+ CompoundTag markerTag = tagList.getCompoundTag(i);
boolean visibleAhead = true;
if (version < 2) {
Log.warn("Marker is visible ahead by default");
@@ -95,7 +102,7 @@ public void readFromNBT(NBTTagCompound compound) {
if (version < 3) {
id = getNewID();
} else {
- id = markerTag.getInteger(TAG_MARKER_ID);
+ id = markerTag.getInt(TAG_MARKER_ID);
if (getMarkerByID(id) != null) {
Log.warn("Loading marker with duplicate id %d. Getting new id", id);
id = getNewID();
@@ -111,8 +118,8 @@ public void readFromNBT(NBTTagCompound compound) {
markerTag.getString(TAG_MARKER_TYPE),
markerTag.getString(TAG_MARKER_LABEL),
dimensionID,
- markerTag.getInteger(TAG_MARKER_X),
- markerTag.getInteger(TAG_MARKER_Y),
+ markerTag.getInt(TAG_MARKER_X),
+ markerTag.getInt(TAG_MARKER_Y),
visibleAhead);
loadMarker(marker);
}
@@ -120,50 +127,50 @@ public void readFromNBT(NBTTagCompound compound) {
}
@Override
- public NBTTagCompound writeToNBT(NBTTagCompound compound) {
+ public CompoundTag toTag(CompoundTag compound) {
Log.info("Saving local markers data to NBT");
- compound.setInteger(TAG_VERSION, VERSION);
- NBTTagList dimensionMapList = new NBTTagList();
- for (Integer dimension : dimensionMap.keySet()) {
- NBTTagCompound tag = new NBTTagCompound();
- tag.setInteger(TAG_DIMENSION_ID, dimension);
+ compound.putInt(TAG_VERSION, VERSION);
+ ListTag dimensionMapList = new ListTag();
+ for (DimensionType dimension : dimensionMap.keySet()) {
+ CompoundTag tag = new CompoundTag();
+ tag.putString(TAG_DIMENSION_ID, Registry.DIMENSION.getId(dimension).toString());
DimensionMarkersData data = getMarkersDataInDimension(dimension);
- NBTTagList tagList = new NBTTagList();
+ ListTag tagList = new ListTag();
for (Marker marker : data.getAllMarkers()) {
- NBTTagCompound markerTag = new NBTTagCompound();
- markerTag.setInteger(TAG_MARKER_ID, marker.getId());
- markerTag.setString(TAG_MARKER_TYPE, marker.getType());
- markerTag.setString(TAG_MARKER_LABEL, marker.getLabel());
- markerTag.setInteger(TAG_MARKER_X, marker.getX());
- markerTag.setInteger(TAG_MARKER_Y, marker.getZ());
- markerTag.setBoolean(TAG_MARKER_VISIBLE_AHEAD, marker.isVisibleAhead());
- tagList.appendTag(markerTag);
+ CompoundTag markerTag = new CompoundTag();
+ markerTag.putInt(TAG_MARKER_ID, marker.getId());
+ markerTag.putString(TAG_MARKER_TYPE, marker.getType());
+ markerTag.putString(TAG_MARKER_LABEL, marker.getLabel());
+ markerTag.putInt(TAG_MARKER_X, marker.getX());
+ markerTag.putInt(TAG_MARKER_Y, marker.getZ());
+ markerTag.putBoolean(TAG_MARKER_VISIBLE_AHEAD, marker.isVisibleAhead());
+ tagList.add(markerTag);
}
- tag.setTag(TAG_MARKERS, tagList);
- dimensionMapList.appendTag(tag);
+ tag.put(TAG_MARKERS, tagList);
+ dimensionMapList.add(tag);
}
- compound.setTag(TAG_DIMENSION_MAP_LIST, dimensionMapList);
+ compound.put(TAG_DIMENSION_MAP_LIST, dimensionMapList);
return compound;
}
- public Set getVisitedDimensions() {
+ public Set getVisitedDimensions() {
return dimensionMap.keySet();
}
/** This method is rather inefficient, use it sparingly. */
- public Collection getMarkersInDimension(int dimension) {
+ public Collection getMarkersInDimension(DimensionType dimension) {
return getMarkersDataInDimension(dimension).getAllMarkers();
}
/** Creates a new instance of {@link DimensionMarkersData}, if necessary. */
- public DimensionMarkersData getMarkersDataInDimension(int dimension) {
+ public DimensionMarkersData getMarkersDataInDimension(DimensionType dimension) {
return dimensionMap.computeIfAbsent(dimension, k -> new DimensionMarkersData(this, dimension));
}
/** The "chunk" here is {@link MarkersData#CHUNK_STEP} times larger than the
* Minecraft 16x16 chunk! May return null. */
- public List getMarkersAtChunk(int dimension, int x, int z) {
+ public List getMarkersAtChunk(DimensionType dimension, int x, int z) {
return getMarkersDataInDimension(dimension).getMarkersAtChunk(x, z);
}
@@ -183,7 +190,7 @@ public Marker removeMarker(int id) {
/** For internal use. Use the {@link MarkerAPI} to put markers! This method
* creates a new marker from the given data, saves and returns it.
* Server side only! */
- public Marker createAndSaveMarker(String type, String label, int dimension, int x, int z, boolean visibleAhead) {
+ public Marker createAndSaveMarker(String type, String label, DimensionType dimension, int x, int z, boolean visibleAhead) {
Marker marker = new Marker(getNewID(), type, label, dimension, x, z, visibleAhead);
Log.info("Created new marker %s", marker.toString());
idMap.put(marker.getId(), marker);
@@ -201,7 +208,7 @@ public Marker loadMarker(Marker marker) {
if (!idMap.containsKey(marker.getId())) {
idMap.put(marker.getId(), marker);
int totalMarkers = 0;
- for (Entry e: dimensionMap.entrySet()){
+ for (Entry e: dimensionMap.entrySet()){
totalMarkers += e.getValue().getAllMarkers().size();
}
if (totalMarkers < SettingsConfig.performance.markerLimit){
@@ -213,27 +220,27 @@ public Marker loadMarker(Marker marker) {
return marker;
}
- public boolean isSyncedOnPlayer(EntityPlayer player) {
+ public boolean isSyncedOnPlayer(PlayerEntity player) {
return playersSentTo.contains(player);
}
/** Send all data to the player in several packets. Called once during the
* first run of ItemAtals.onUpdate(). */
- public void syncOnPlayer(int atlasID, EntityPlayer player) {
- for (Integer dimension : dimensionMap.keySet()) {
+ public void syncOnPlayer(int atlasID, PlayerEntity player) {
+ for (DimensionType dimension : dimensionMap.keySet()) {
MarkersPacket packet = newMarkersPacket(atlasID, dimension);
DimensionMarkersData data = getMarkersDataInDimension(dimension);
for (Marker marker : data.getAllMarkers()) {
packet.putMarker(marker);
}
- PacketDispatcher.sendTo(packet, (EntityPlayerMP) player);
+ PacketDispatcher.sendTo(packet, (ServerPlayerEntity) player);
}
- Log.info("Sent markers data #%d to player %s", atlasID, player.getName());
+ Log.info("Sent markers data #%d to player %s", atlasID, player.getCommandSource().getName());
playersSentTo.add(player);
}
/** To be overridden in GlobalMarkersData. */
- MarkersPacket newMarkersPacket(int atlasID, int dimension) {
+ MarkersPacket newMarkersPacket(int atlasID, DimensionType dimension) {
return new MarkersPacket(atlasID, dimension);
}
diff --git a/src/main/java/hunternif/mc/atlas/marker/MarkersDataHandler.java b/src/main/java/hunternif/mc/atlas/marker/MarkersDataHandler.java
index 3f7e9825e..44917d929 100644
--- a/src/main/java/hunternif/mc/atlas/marker/MarkersDataHandler.java
+++ b/src/main/java/hunternif/mc/atlas/marker/MarkersDataHandler.java
@@ -23,7 +23,7 @@ public class MarkersDataHandler {
/** Loads data for the given atlas or creates a new one. */
public MarkersData getMarkersData(ItemStack stack, World world) {
if (stack.getItem() == RegistrarAntiqueAtlas.ATLAS) {
- return getMarkersData(stack.getItemDamage(), world);
+ return getMarkersData(stack.getDamage(), world);
} else {
return null;
}
@@ -33,18 +33,18 @@ public MarkersData getMarkersData(ItemStack stack, World world) {
public MarkersData getMarkersData(int atlasID, World world) {
String key = getMarkersDataKey(atlasID);
MarkersData data = null;
- if (world.isRemote) {
+ if (world.isClient) {
// Since atlas data doesn't really belong to a single world-dimension,
// it can be cached. This should fix #67
data = markersDataClientCache.get(key);
}
if (data == null) {
- data = (MarkersData) world.loadData(MarkersData.class, key);
+ data = (MarkersData) world.XX_1_12_2_a_XX(MarkersData.class, key);
if (data == null) {
data = new MarkersData(key);
- world.setData(key, data);
+ world.XX_1_13_a_XX(key, data);
}
- if (world.isRemote) markersDataClientCache.put(key, data);
+ if (world.isClient) markersDataClientCache.put(key, data);
}
return data;
}
diff --git a/src/main/java/hunternif/mc/atlas/marker/NetherPortalWatcher.java b/src/main/java/hunternif/mc/atlas/marker/NetherPortalWatcher.java
index 698b5ed8b..3550b2c38 100644
--- a/src/main/java/hunternif/mc/atlas/marker/NetherPortalWatcher.java
+++ b/src/main/java/hunternif/mc/atlas/marker/NetherPortalWatcher.java
@@ -4,19 +4,19 @@
import hunternif.mc.atlas.RegistrarAntiqueAtlas;
import hunternif.mc.atlas.SettingsConfig;
import hunternif.mc.atlas.api.AtlasAPI;
+import hunternif.mc.atlas.registry.MarkerRegistry;
import hunternif.mc.atlas.registry.MarkerTypes;
-import hunternif.mc.atlas.util.DummyWorldAccess;
+import hunternif.mc.atlas.util.DummyBlockView;
import hunternif.mc.atlas.util.Log;
import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
-import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
+import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
-
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -26,8 +26,8 @@
* marker in the atlases he is carrying.
* @author Hunternif
*/
-public class NetherPortalWatcher extends DummyWorldAccess {
- private static final String[] inPortalFieldNames = {"inPortal", "field_71087_bX", "bX"};
+public class NetherPortalWatcher extends DummyBlockView {
+ private static final String[] inPortalFieldNames = {"bX"};
/**
* When a player teleports, he is removed from the source dimension, where
@@ -40,32 +40,32 @@ public class NetherPortalWatcher extends DummyWorldAccess {
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
- if (!event.getWorld().isRemote) {
- event.getWorld().addEventListener(this);
+ if (!event.getWorld().G) {
+ event.getWorld().a(this);
}
}
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event) {
- if (!event.getWorld().isRemote) {
- event.getWorld().removeEventListener(this);
+ if (!event.getWorld().G) {
+ event.getWorld().b(this);
}
}
@Override
- public void onEntityAdded(Entity entity) {
- if (entity instanceof EntityPlayer) {
- EntityPlayer player = (EntityPlayer) entity;
- if (teleportingPlayersOrigin.containsKey(entity.getEntityId())) {
- int origin = teleportingPlayersOrigin.remove(entity.getEntityId());
+ public void a(Entity entity) {
+ if (entity instanceof PlayerEntity) {
+ PlayerEntity player = (PlayerEntity) entity;
+ if (teleportingPlayersOrigin.containsKey(entity.Q())) {
+ int origin = teleportingPlayersOrigin.remove(entity.Q());
Log.info("Entering");
// player.dimension is the destination dimension
- int dimension = player.dimension;
+ DimensionType dimension = player.dimension;
// Only look for portals into and out of the Nether
- if(origin == DimensionType.NETHER.getId() || dimension == DimensionType.NETHER.getId()) {
- Log.info("Player %s teleported to the %s", player.getGameProfile().getName(),
- DimensionType.getById(dimension).getName());
+ if(origin == bnu.b.a() || dimension == bnu.b.a()) {
+ Log.info("Player %s teleported to the %s", player.getCommandSource().getName(),
+ bnu.a(dimension).b());
addPortalMarkerIfNone(player, dimension);
}
}
@@ -73,16 +73,16 @@ public void onEntityAdded(Entity entity) {
}
@Override
- public void onEntityRemoved(Entity entity) {
- if (entity instanceof EntityPlayer) {
- EntityPlayer player = (EntityPlayer) entity;
+ public void b(Entity entity) {
+ if (entity instanceof PlayerEntity) {
+ PlayerEntity player = (PlayerEntity) entity;
if (isEntityInPortal(entity)) {
Log.info("Exiting");
// player.worldObj.provider.dimensionId is the dimension of origin
- int originDimension = player.getEntityWorld().provider.getDimension();
- Log.info("Player %s left the %s", player.getGameProfile().getName(),
- DimensionType.getById(originDimension).getName());
- teleportingPlayersOrigin.put(entity.getEntityId(), originDimension);
+ int originDimension = player.getEntityWorld().s.getType();
+ Log.info("Player %s left the %s", player.getCommandSource().getName(),
+ bnu.a(originDimension).b());
+ teleportingPlayersOrigin.put(entity.Q(), originDimension);
// TODO Check what is the target dimension
addPortalMarkerIfNone(player, originDimension);
}
@@ -91,34 +91,34 @@ public void onEntityRemoved(Entity entity) {
/** Put the Portal marker at the player's current coordinates into all
* atlases that he is carrying, if the same marker is not already there. */
- private void addPortalMarkerIfNone(EntityPlayer player, int dimension) {
+ private void addPortalMarkerIfNone(PlayerEntity player, DimensionType dimension) {
if(!SettingsConfig.gameplay.autoNetherPortalMarkers) {
return;
}
// Due to switching dimensions this player entity's worldObj is lagging.
// We need the very specific dimension each time.
- World world = AntiqueAtlasMod.proxy.getServer().getWorld(dimension);
+ World world = AntiqueAtlasMod.proxy.getServer().getDim(dimension);
if (!SettingsConfig.gameplay.itemNeeded) {
- addPortalMarkerIfNone(player, world, dimension, player.getUniqueID().hashCode());
+ addPortalMarkerIfNone(player, world, dimension, player.getUuid().hashCode());
return;
}
- for (ItemStack stack : player.inventory.mainInventory) {
+ for (ItemStack stack : player.inventory.main) {
if (stack == null || stack.getItem() != RegistrarAntiqueAtlas.ATLAS) continue;
- addPortalMarkerIfNone(player, world, dimension, stack.getItemDamage());
+ addPortalMarkerIfNone(player, world, dimension, stack.getDamage());
}
}
- private void addPortalMarkerIfNone(EntityPlayer player, World world, int dimension, int atlasID) {
+ private void addPortalMarkerIfNone(PlayerEntity player, World world, int dimension, int atlasID) {
// Can't use entity.dimension here, because its value has already been updated!
DimensionMarkersData data = AntiqueAtlasMod.markersData.getMarkersData(atlasID, world)
.getMarkersDataInDimension(dimension);
- int x = (int)player.posX;
- int z = (int)player.posZ;
+ int x = (int)player.x;
+ int z = (int)player.z;
// Check if the marker already exists:
List markers = data.getMarkersAtChunk((x >> 4) / MarkersData.CHUNK_STEP, (z >> 4) / MarkersData.CHUNK_STEP);
@@ -132,7 +132,7 @@ private void addPortalMarkerIfNone(EntityPlayer player, World world, int dimensi
}
// Marker not found, place new one:
- AtlasAPI.markers.putMarker(world, false, atlasID, MarkerTypes.NETHER_PORTAL.getRegistryName().toString(), "gui.antiqueatlas.marker.netherPortal", x, z);
+ AtlasAPI.markers.putMarker(world, false, atlasID, MarkerRegistry.getId(MarkerTypes.NETHER_PORTAL).toString(), "gui.antiqueatlas.marker.netherPortal", x, z);
}
private static boolean isEntityInPortal(Entity entity) {
diff --git a/src/main/java/hunternif/mc/atlas/network/AbstractMessage.java b/src/main/java/hunternif/mc/atlas/network/AbstractMessage.java
index 33b48e0ed..2df4dc358 100644
--- a/src/main/java/hunternif/mc/atlas/network/AbstractMessage.java
+++ b/src/main/java/hunternif/mc/atlas/network/AbstractMessage.java
@@ -20,49 +20,44 @@
import com.google.common.base.Throwables;
import hunternif.mc.atlas.AntiqueAtlasMod;
import io.netty.buffer.ByteBuf;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.network.PacketBuffer;
-import net.minecraft.util.IThreadListener;
-import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
-import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
-import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
-import net.minecraftforge.fml.relauncher.Side;
-
+import net.fabricmc.api.EnvType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.util.PacketByteBuf;
import java.io.IOException;
/**
*
* A wrapper much like the vanilla packet class, allowing use of PacketBuffer's many
* useful methods as well as implementing a final version of IMessageHandler which
- * calls {@link #process(EntityPlayer, Side)} on each received message, letting the
+ * calls {@link #process(PlayerEntity, EnvType)} on each received message, letting the
* message handle itself rather than having to add an extra class in each one.
*
*/
-public abstract class AbstractMessage> implements IMessage, IMessageHandler
+public abstract class AbstractMessage>
{
/**
* Some PacketBuffer methods throw IOException - default handling propagates the exception.
* If an IOException is expected but should not be fatal, handle it within this method.
*/
- protected abstract void read(PacketBuffer buffer) throws IOException;
+ protected abstract void read(PacketByteBuf buffer) throws IOException;
/**
* Some PacketBuffer methods throw IOException - default handling propagates the exception.
* If an IOException is expected but should not be fatal, handle it within this method.
*/
- protected abstract void write(PacketBuffer buffer) throws IOException;
+ protected abstract void write(PacketByteBuf buffer) throws IOException;
/**
* Called on whichever side the message is received;
* for bidirectional packets, be sure to check side
*/
- protected abstract void process(EntityPlayer player, Side side);
+ protected abstract void process(PlayerEntity player, EnvType side);
/**
* If message is sent to the wrong side, an exception will be thrown during handling
* @return True if the message is allowed to be handled on the given side
*/
- boolean isValidOnSide(Side side) {
+ boolean isValidOnSide(EnvType side) {
return true;
}
@@ -74,24 +69,24 @@ boolean requiresMainThread() {
return true;
}
- @Override
public void fromBytes(ByteBuf buffer) {
try {
- read(new PacketBuffer(buffer));
+ read(new PacketByteBuf(buffer));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
- @Override
public void toBytes(ByteBuf buffer) {
try {
- write(new PacketBuffer(buffer));
+ write(new PacketByteBuf(buffer));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
+ // TODO FABRIC
+ /*
@Override
public final IMessage onMessage(T msg, MessageContext ctx) {
if (!msg.isValidOnSide(ctx.side)) {
@@ -102,25 +97,26 @@ public final IMessage onMessage(T msg, MessageContext ctx) {
msg.process(AntiqueAtlasMod.proxy.getPlayerEntity(ctx), ctx.side);
}
return null;
- }
+ } */
/**
* Ensures that the message is being handled on the main thread
*/
+ /*
private static > void checkThreadAndEnqueue(final AbstractMessage msg, final MessageContext ctx) {
- IThreadListener thread = AntiqueAtlasMod.proxy.getThreadFromContext(ctx);
- if (!thread.isCallingFromMinecraftThread()) {
- thread.addScheduledTask(() -> msg.process(AntiqueAtlasMod.proxy.getPlayerEntity(ctx), ctx.side));
+ XX_1_13_2_none_acv_XX thread = AntiqueAtlasMod.proxy.getThreadFromContext(ctx);
+ if (!thread.av()) {
+ thread.a(() -> msg.process(AntiqueAtlasMod.proxy.getPlayerEntity(ctx), ctx.side));
}
- }
+ } */
/**
* Messages that can only be sent from the server to the client should use this class
*/
public static abstract class AbstractClientMessage> extends AbstractMessage {
@Override
- protected final boolean isValidOnSide(Side side) {
- return side.isClient();
+ protected final boolean isValidOnSide(EnvType side) {
+ return side == EnvType.CLIENT;
}
}
@@ -129,8 +125,8 @@ protected final boolean isValidOnSide(Side side) {
*/
public static abstract class AbstractServerMessage> extends AbstractMessage {
@Override
- protected final boolean isValidOnSide(Side side) {
- return side.isServer();
+ protected final boolean isValidOnSide(EnvType side) {
+ return side == EnvType.SERVER;
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/network/PacketDispatcher.java b/src/main/java/hunternif/mc/atlas/network/PacketDispatcher.java
index bbc6b007a..2dc7ab546 100644
--- a/src/main/java/hunternif/mc/atlas/network/PacketDispatcher.java
+++ b/src/main/java/hunternif/mc/atlas/network/PacketDispatcher.java
@@ -7,14 +7,9 @@
import hunternif.mc.atlas.network.server.AddMarkerPacket;
import hunternif.mc.atlas.network.server.BrowsingPositionPacket;
import hunternif.mc.atlas.network.server.RegisterTileIdPacket;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
-import net.minecraftforge.fml.common.network.NetworkRegistry;
-import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
-import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
-import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
-import net.minecraftforge.fml.relauncher.Side;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.server.network.ServerPlayerEntity;
+
/**
*
@@ -56,7 +51,7 @@ public static void registerPackets() {
/**
* Registers an {@link AbstractMessage} to the appropriate side(s)
*/
- private static & IMessageHandler> void registerMessage(Class clazz) {
+ private static > void registerMessage(Class clazz) {
if (AbstractMessage.AbstractClientMessage.class.isAssignableFrom(clazz)) {
PacketDispatcher.dispatcher.registerMessage(clazz, clazz, packetId++, Side.CLIENT);
} else if (AbstractMessage.AbstractServerMessage.class.isAssignableFrom(clazz)) {
@@ -69,55 +64,55 @@ private static & IMessageHandler> voi
/**
* Send this message to everyone.
- * See {@link SimpleNetworkWrapper#sendToAll(IMessage)}
+ * See {@link SimpleNetworkWrapper#sendToAll(AbstractMessage>)}
*/
- public static void sendToAll(IMessage message) {
+ public static void sendToAll(AbstractMessage> message) {
PacketDispatcher.dispatcher.sendToAll(message);
}
/**
* Send this message to the specified player.
- * See {@link SimpleNetworkWrapper#sendTo(IMessage, EntityPlayerMP)}
+ * See {@link SimpleNetworkWrapper#sendTo(AbstractMessage>, ServerPlayerEntity)}
*/
- public static void sendTo(IMessage message, EntityPlayerMP player) {
+ public static void sendTo(AbstractMessage> message, ServerPlayerEntity player) {
PacketDispatcher.dispatcher.sendTo(message, player);
}
/**
* Send this message to everyone within a certain range of a point.
- * See {@link SimpleNetworkWrapper#sendToAllAround(IMessage, NetworkRegistry.TargetPoint)}
+ * See {@link SimpleNetworkWrapper#sendToAllAround(AbstractMessage>, NetworkRegistry.TargetPoint)}
*/
- private static void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) {
+ private static void sendToAllAround(AbstractMessage> message, NetworkRegistry.TargetPoint point) {
PacketDispatcher.dispatcher.sendToAllAround(message, point);
}
/**
* Sends a message to everyone within a certain range of the coordinates in the same dimension.
*/
- private static void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range) {
+ private static void sendToAllAround(AbstractMessage> message, int dimension, double x, double y, double z, double range) {
PacketDispatcher.sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range));
}
/**
* Sends a message to everyone within a certain range of the player provided.
*/
- public static void sendToAllAround(IMessage message, EntityPlayer player, double range) {
- PacketDispatcher.sendToAllAround(message, player.getEntityWorld().provider.getDimension(), player.posX, player.posY, player.posZ, range);
+ public static void sendToAllAround(AbstractMessage> message, PlayerEntity player, double range) {
+ PacketDispatcher.sendToAllAround(message, player.getEntityWorld().s.getType(), player.x, player.y, player.z, range);
}
/**
* Send this message to everyone within the supplied dimension.
- * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, int)}
+ * See {@link SimpleNetworkWrapper#sendToDimension(AbstractMessage>, int)}
*/
- public static void sendToDimension(IMessage message, int dimensionId) {
+ public static void sendToDimension(AbstractMessage> message, int dimensionId) {
PacketDispatcher.dispatcher.sendToDimension(message, dimensionId);
}
/**
* Send this message to the server.
- * See {@link SimpleNetworkWrapper#sendToServer(IMessage)}
+ * See {@link SimpleNetworkWrapper#sendToServer(AbstractMessage>)}
*/
- public static void sendToServer(IMessage message) {
+ public static void sendToServer(AbstractMessage> message) {
PacketDispatcher.dispatcher.sendToServer(message);
}
}
diff --git a/src/main/java/hunternif/mc/atlas/network/bidirectional/DeleteMarkerPacket.java b/src/main/java/hunternif/mc/atlas/network/bidirectional/DeleteMarkerPacket.java
index b8498adba..d2349d25a 100644
--- a/src/main/java/hunternif/mc/atlas/network/bidirectional/DeleteMarkerPacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/bidirectional/DeleteMarkerPacket.java
@@ -7,10 +7,9 @@
import hunternif.mc.atlas.marker.MarkersData;
import hunternif.mc.atlas.network.AbstractMessage;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.relauncher.Side;
+import net.fabricmc.api.EnvType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.util.PacketByteBuf;
import java.io.IOException;
@@ -40,13 +39,13 @@ public DeleteMarkerPacket(int markerID) {
}
@Override
- public void read(PacketBuffer buffer) throws IOException {
+ public void read(PacketByteBuf buffer) throws IOException {
atlasID = buffer.readVarInt();
markerID = buffer.readVarInt();
}
@Override
- public void write(PacketBuffer buffer) throws IOException {
+ public void write(PacketByteBuf buffer) throws IOException {
buffer.writeVarInt(atlasID);
buffer.writeVarInt(markerID);
}
@@ -56,13 +55,12 @@ private boolean isGlobal() {
}
@Override
- protected void process(EntityPlayer player, Side side) {
- if (side.isServer()) {
+ protected void process(PlayerEntity player, EnvType side) {
+ if (side == EnvType.SERVER) {
// Make sure it's this player's atlas :^)
- if (side.isServer() && SettingsConfig.gameplay.itemNeeded
- && !player.inventory.hasItemStack(new ItemStack(RegistrarAntiqueAtlas.ATLAS, 1, atlasID))) {
+ if (SettingsConfig.gameplay.itemNeeded && !player.bB.h(new ata(RegistrarAntiqueAtlas.ATLAS, 1, atlasID))) {
Log.warn("Player %s attempted to delete marker from someone else's Atlas #%d",
- player.getGameProfile().getName(), atlasID);
+ player.getCommandSource().getName(), atlasID);
return;
}
if (isGlobal()) {
diff --git a/src/main/java/hunternif/mc/atlas/network/bidirectional/PutBiomeTilePacket.java b/src/main/java/hunternif/mc/atlas/network/bidirectional/PutBiomeTilePacket.java
index 89cadba42..80c5cf6f4 100644
--- a/src/main/java/hunternif/mc/atlas/network/bidirectional/PutBiomeTilePacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/bidirectional/PutBiomeTilePacket.java
@@ -1,17 +1,18 @@
package hunternif.mc.atlas.network.bidirectional;
import hunternif.mc.atlas.AntiqueAtlasMod;
-import hunternif.mc.atlas.RegistrarAntiqueAtlas;
import hunternif.mc.atlas.SettingsConfig;
import hunternif.mc.atlas.api.AtlasAPI;
import hunternif.mc.atlas.core.AtlasData;
-import hunternif.mc.atlas.core.Tile;
+import hunternif.mc.atlas.core.TileKindFactory;
import hunternif.mc.atlas.network.AbstractMessage;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.relauncher.Side;
+import net.fabricmc.api.EnvType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.util.PacketByteBuf;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.biome.Biome;
+import net.minecraft.world.dimension.DimensionType;
import java.io.IOException;
@@ -21,11 +22,13 @@
* @author Hunternif
*/
public class PutBiomeTilePacket extends AbstractMessage {
- private int atlasID, dimension, x, z, biomeID;
+ private int atlasID, x, z;
+ private DimensionType dimension;
+ private Biome biomeID;
public PutBiomeTilePacket() {}
- public PutBiomeTilePacket(int atlasID, int dimension, int x, int z, int biomeID) {
+ public PutBiomeTilePacket(int atlasID, DimensionType dimension, int x, int z, Biome biomeID) {
this.atlasID = atlasID;
this.dimension = dimension;
this.x = x;
@@ -34,37 +37,38 @@ public PutBiomeTilePacket(int atlasID, int dimension, int x, int z, int biomeID)
}
@Override
- protected void read(PacketBuffer buffer) throws IOException {
+ protected void read(PacketByteBuf buffer) throws IOException {
atlasID = buffer.readVarInt();
- dimension = buffer.readVarInt();
+ dimension = Registry.DIMENSION.get(buffer.readVarInt());
x = buffer.readVarInt();
z = buffer.readVarInt();
- biomeID = buffer.readVarInt();
+ biomeID = Registry.BIOME.get(buffer.readVarInt());
}
@Override
- protected void write(PacketBuffer buffer) throws IOException {
+ protected void write(PacketByteBuf buffer) throws IOException {
buffer.writeVarInt(atlasID);
- buffer.writeVarInt(dimension);
+ buffer.writeVarInt(Registry.DIMENSION.getRawId(dimension));
buffer.writeVarInt(x);
buffer.writeVarInt(z);
- buffer.writeVarInt(biomeID);
+ buffer.writeVarInt(Registry.BIOME.getRawId(biomeID));
}
@Override
- protected void process(EntityPlayer player, Side side) {
- if (side.isServer()) {
+ protected void process(PlayerEntity player, EnvType side) {
+ if (side == EnvType.SERVER) {
// Make sure it's this player's atlas :^)
- if (SettingsConfig.gameplay.itemNeeded &&
- !player.inventory.hasItemStack(new ItemStack(RegistrarAntiqueAtlas.ATLAS, 1, atlasID))) {
+ // TODO Fabric
+ if (SettingsConfig.gameplay.itemNeeded /* &&
+ !player.bB.h(new ata(RegistrarAntiqueAtlas.ATLAS, 1, atlasID)) */) {
Log.warn("Player %s attempted to modify someone else's Atlas #%d",
- player.getGameProfile().getName(), atlasID);
+ player.getCommandSource().getName(), atlasID);
return;
}
AtlasAPI.tiles.putBiomeTile(player.getEntityWorld(), atlasID, biomeID, x, z);
} else {
AtlasData data = AntiqueAtlasMod.atlasData.getAtlasData(atlasID, player.getEntityWorld());
- data.setTile(dimension, x, z, new Tile(biomeID));
+ data.setTile(dimension, x, z, TileKindFactory.get(biomeID));
}
}
diff --git a/src/main/java/hunternif/mc/atlas/network/client/DeleteCustomGlobalTilePacket.java b/src/main/java/hunternif/mc/atlas/network/client/DeleteCustomGlobalTilePacket.java
index e2c63e93f..ab205ab9d 100644
--- a/src/main/java/hunternif/mc/atlas/network/client/DeleteCustomGlobalTilePacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/client/DeleteCustomGlobalTilePacket.java
@@ -6,9 +6,12 @@
import java.io.IOException;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.relauncher.Side;
+import net.fabricmc.api.EnvType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.util.PacketByteBuf;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.dimension.DimensionType;
+
/**
* Sent from server to client to remove a custom global tile.
@@ -16,32 +19,33 @@
*/
public class DeleteCustomGlobalTilePacket extends AbstractClientMessage {
- private int dimension, chunkX, chunkZ;
+ private DimensionType dimension;
+ private int chunkX, chunkZ;
public DeleteCustomGlobalTilePacket() {}
- public DeleteCustomGlobalTilePacket(int dimension, int chunkX, int chunkZ) {
+ public DeleteCustomGlobalTilePacket(DimensionType dimension, int chunkX, int chunkZ) {
this.dimension = dimension;
this.chunkX = chunkX;
this.chunkZ = chunkZ;
}
@Override
- protected void read(PacketBuffer buffer) throws IOException {
- dimension = buffer.readInt();
+ protected void read(PacketByteBuf buffer) throws IOException {
+ dimension = Registry.DIMENSION.get(buffer.readVarInt());
chunkX = buffer.readInt();
chunkZ = buffer.readInt();
}
@Override
- protected void write(PacketBuffer buffer) throws IOException {
- buffer.writeInt(dimension);
+ protected void write(PacketByteBuf buffer) throws IOException {
+ buffer.writeVarInt(Registry.DIMENSION.getRawId(dimension));
buffer.writeInt(chunkX);
buffer.writeInt(chunkZ);
}
@Override
- protected void process(EntityPlayer player, Side side) {
+ protected void process(PlayerEntity player, EnvType side) {
ExtBiomeData data = AntiqueAtlasMod.extBiomeData.getData();
data.removeBiomeAt(dimension, chunkX, chunkZ);
}
diff --git a/src/main/java/hunternif/mc/atlas/network/client/DimensionUpdatePacket.java b/src/main/java/hunternif/mc/atlas/network/client/DimensionUpdatePacket.java
index c44ae664a..fdcfabd4b 100644
--- a/src/main/java/hunternif/mc/atlas/network/client/DimensionUpdatePacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/client/DimensionUpdatePacket.java
@@ -4,35 +4,39 @@
import hunternif.mc.atlas.AntiqueAtlasMod;
import hunternif.mc.atlas.core.AtlasData;
-import hunternif.mc.atlas.core.Tile;
+import hunternif.mc.atlas.core.TileKind;
+import hunternif.mc.atlas.core.TileKindFactory;
import hunternif.mc.atlas.network.AbstractMessage.AbstractClientMessage;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.relauncher.Side;
+import net.fabricmc.api.EnvType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.util.PacketByteBuf;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.dimension.DimensionType;
+
public class DimensionUpdatePacket extends AbstractClientMessage{
/** Size of one entry in the map in bytes. */
- private static final int ENTRY_SIZE_BYTES = 2 + 2 + 2;
+ private static final int ENTRY_SIZE_BYTES = 2 + 2 + 4;
private int atlasID;
- private int dimension;
+ private DimensionType dimension;
private int tileCount;
private ByteBuf tileData;
public DimensionUpdatePacket() {}
- public DimensionUpdatePacket(int atlasID, int dimension) {
+ public DimensionUpdatePacket(int atlasID, DimensionType dimension) {
this.dimension = dimension;
tileCount = 0;
tileData = Unpooled.buffer();
}
- public DimensionUpdatePacket addTile(int x, int y, int biomeID) {
+ public DimensionUpdatePacket addTile(int x, int y, TileKind biomeID) {
tileData.writeShort(x);
tileData.writeShort(y);
- tileData.writeShort(biomeID);
+ tileData.writeInt(biomeID.getId());
tileCount++;
return this;
}
@@ -42,26 +46,31 @@ public boolean isEmpty() {
}
@Override
- public void read(PacketBuffer buffer) throws IOException {
+ public void read(PacketByteBuf buffer) throws IOException {
atlasID = buffer.readVarInt();
- dimension = buffer.readVarInt();
+ dimension = Registry.DIMENSION.get(buffer.readIdentifier());
tileCount = buffer.readVarInt();
tileData = buffer.readBytes(tileCount * ENTRY_SIZE_BYTES);
}
@Override
- public void write(PacketBuffer buffer) throws IOException {
+ public void write(PacketByteBuf buffer) throws IOException {
buffer.writeVarInt(atlasID);
- buffer.writeVarInt(dimension);
+ buffer.writeIdentifier(Registry.DIMENSION.getId(dimension));
buffer.writeVarInt(tileCount);
buffer.writeBytes(tileData);
}
@Override
- protected void process(EntityPlayer player, Side side) {
+ protected void process(PlayerEntity player, EnvType side) {
+ if (dimension == null) {
+ // TODO FABRIC
+ return;
+ }
+
AtlasData data = AntiqueAtlasMod.atlasData.getAtlasData(atlasID, player.world);
for (int i = 0; i < tileCount; i++) {
- data.getDimensionData(dimension).setTile(tileData.readShort(), tileData.readShort(), new Tile(tileData.readShort()));
+ data.getDimensionData(dimension).setTile(tileData.readShort(), tileData.readShort(), TileKindFactory.get(tileData.readInt()));
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/network/client/MapDataPacket.java b/src/main/java/hunternif/mc/atlas/network/client/MapDataPacket.java
index 69faa319f..eae596b5b 100644
--- a/src/main/java/hunternif/mc/atlas/network/client/MapDataPacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/client/MapDataPacket.java
@@ -5,13 +5,13 @@
import hunternif.mc.atlas.client.gui.GuiAtlas;
import hunternif.mc.atlas.core.AtlasData;
import hunternif.mc.atlas.network.AbstractMessage.AbstractClientMessage;
-import net.minecraft.client.Minecraft;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.common.network.ByteBufUtils;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.util.PacketByteBuf;
+
import java.io.IOException;
@@ -21,38 +21,38 @@
*/
public class MapDataPacket extends AbstractClientMessage {
private int atlasID;
- private NBTTagCompound data;
+ private CompoundTag data;
public MapDataPacket() {}
- public MapDataPacket(int atlasID, NBTTagCompound data) {
+ public MapDataPacket(int atlasID, CompoundTag data) {
this.atlasID = atlasID;
this.data = data;
}
@Override
- public void read(PacketBuffer buffer) throws IOException {
+ public void read(PacketByteBuf buffer) throws IOException {
atlasID = buffer.readVarInt();
- data = ByteBufUtils.readTag(buffer);
+ data = buffer.readCompoundTag();
}
@Override
- public void write(PacketBuffer buffer) throws IOException {
+ public void write(PacketByteBuf buffer) throws IOException {
buffer.writeVarInt(atlasID);
- ByteBufUtils.writeTag(buffer, data);
+ buffer.writeCompoundTag(data);
}
@Override
- @SideOnly(Side.CLIENT)
- protected void process(EntityPlayer player, Side side) {
+ @Environment(EnvType.CLIENT)
+ protected void process(PlayerEntity player, EnvType side) {
if (data == null) return; // Atlas is empty
AtlasData atlasData = AntiqueAtlasMod.atlasData.getAtlasData(atlasID, player.getEntityWorld());
- atlasData.readFromNBT(data);
+ atlasData.fromTag(data);
// GuiAtlas may already be opened at (0, 0) browsing position, force load saved position:
if (SettingsConfig.gameplay.doSaveBrowsingPos &&
- Minecraft.getMinecraft().currentScreen instanceof GuiAtlas) {
- ((GuiAtlas)Minecraft.getMinecraft().currentScreen).loadSavedBrowsingPosition();
+ MinecraftClient.getInstance().currentScreen instanceof GuiAtlas) {
+ ((GuiAtlas)MinecraftClient.getInstance().currentScreen).loadSavedBrowsingPosition();
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/network/client/MarkersPacket.java b/src/main/java/hunternif/mc/atlas/network/client/MarkersPacket.java
index 72791172c..91dcbf5f7 100644
--- a/src/main/java/hunternif/mc/atlas/network/client/MarkersPacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/client/MarkersPacket.java
@@ -6,10 +6,11 @@
import hunternif.mc.atlas.marker.Marker;
import hunternif.mc.atlas.marker.MarkersData;
import hunternif.mc.atlas.network.AbstractMessage.AbstractClientMessage;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.common.network.ByteBufUtils;
-import net.minecraftforge.fml.relauncher.Side;
+import net.fabricmc.api.EnvType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.util.PacketByteBuf;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.dimension.DimensionType;
import java.io.IOException;
import java.util.List;
@@ -25,13 +26,13 @@ public class MarkersPacket extends AbstractClientMessage {
/** Used in place of atlasID to signify that the marker is global. */
private static final int GLOBAL = -1;
private int atlasID;
- private int dimension;
+ private DimensionType dimension;
private final ListMultimap markersByType = ArrayListMultimap.create();
public MarkersPacket() {}
/** Use this constructor when creating a local marker. */
- public MarkersPacket(int atlasID, int dimension, Marker... markers) {
+ public MarkersPacket(int atlasID, DimensionType dimension, Marker... markers) {
this.atlasID = atlasID;
this.dimension = dimension;
for (Marker marker : markers) {
@@ -40,7 +41,7 @@ public MarkersPacket(int atlasID, int dimension, Marker... markers) {
}
/** Use this constructor when creating a global marker. */
- public MarkersPacket(int dimension, Marker... markers) {
+ public MarkersPacket(DimensionType dimension, Marker... markers) {
this(GLOBAL, dimension, markers);
}
@@ -54,16 +55,16 @@ private boolean isGlobal() {
}
@Override
- public void read(PacketBuffer buffer) throws IOException {
+ public void read(PacketByteBuf buffer) throws IOException {
atlasID = buffer.readVarInt();
- dimension = buffer.readVarInt();
+ dimension = Registry.DIMENSION.get(buffer.readVarInt());
int typesLength = buffer.readVarInt();
for (int i = 0; i < typesLength; i++) {
- String type = ByteBufUtils.readUTF8String(buffer);
+ String type = buffer.readString(512);
int markersLength = buffer.readVarInt();
for (int j = 0; j < markersLength; j++) {
Marker marker = new Marker(buffer.readVarInt(),
- type, ByteBufUtils.readUTF8String(buffer),
+ type, buffer.readString(512),
dimension, buffer.readInt(), buffer.readInt(),
buffer.readBoolean());
markersByType.put(type, marker);
@@ -72,18 +73,18 @@ public void read(PacketBuffer buffer) throws IOException {
}
@Override
- public void write(PacketBuffer buffer) throws IOException {
+ public void write(PacketByteBuf buffer) throws IOException {
buffer.writeVarInt(atlasID);
- buffer.writeVarInt(dimension);
+ buffer.writeVarInt(Registry.DIMENSION.getRawId(dimension));
Set types = markersByType.keySet();
buffer.writeVarInt(types.size());
for (String type : types) {
- ByteBufUtils.writeUTF8String(buffer, type);
+ buffer.writeString(type);
List markers = markersByType.get(type);
buffer.writeVarInt(markers.size());
for (Marker marker : markers) {
buffer.writeVarInt(marker.getId());
- ByteBufUtils.writeUTF8String(buffer, marker.getLabel());
+ buffer.writeString(marker.getLabel());
buffer.writeInt(marker.getX());
buffer.writeInt(marker.getZ());
buffer.writeBoolean(marker.isVisibleAhead());
@@ -92,7 +93,7 @@ public void write(PacketBuffer buffer) throws IOException {
}
@Override
- protected void process(EntityPlayer player, Side side) {
+ protected void process(PlayerEntity player, EnvType side) {
MarkersData markersData = isGlobal() ?
AntiqueAtlasMod.globalMarkersData.getData() :
AntiqueAtlasMod.markersData.getMarkersData(atlasID, player.getEntityWorld());
diff --git a/src/main/java/hunternif/mc/atlas/network/client/TileGroupsPacket.java b/src/main/java/hunternif/mc/atlas/network/client/TileGroupsPacket.java
index bb1f7d874..93953f463 100644
--- a/src/main/java/hunternif/mc/atlas/network/client/TileGroupsPacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/client/TileGroupsPacket.java
@@ -8,15 +8,18 @@
import hunternif.mc.atlas.core.DimensionData;
import hunternif.mc.atlas.core.TileGroup;
import hunternif.mc.atlas.network.AbstractMessage.AbstractClientMessage;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.common.network.ByteBufUtils;
-import net.minecraftforge.fml.relauncher.Side;
+import net.fabricmc.api.EnvType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.util.PacketByteBuf;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.dimension.DimensionType;
+
public class TileGroupsPacket extends AbstractClientMessage {
- public int atlasID, dimension;
+ public int atlasID;
+ public DimensionType dimension;
public ArrayList tileGroups;
public static final int TILE_GROUPS_PER_PACKET = 100;
@@ -25,39 +28,39 @@ public TileGroupsPacket(){
tileGroups = new ArrayList();
}
- public TileGroupsPacket(ArrayList tileGroups, int atlasID, int dimension) {
+ public TileGroupsPacket(ArrayList tileGroups, int atlasID, DimensionType dimension) {
this.tileGroups = tileGroups;
this.atlasID = atlasID;
this.dimension = dimension;
}
@Override
- protected void read(PacketBuffer buffer) throws IOException {
+ protected void read(PacketByteBuf buffer) throws IOException {
atlasID = buffer.readVarInt();
- dimension = buffer.readVarInt();
+ dimension = Registry.DIMENSION.get(buffer.readVarInt());
int length = buffer.readVarInt();
tileGroups = new ArrayList(length);
for (int i = 0; i < length; i++) {
TileGroup newbie = new TileGroup(0, 0);
- newbie.readFromNBT(ByteBufUtils.readTag(buffer));
+ newbie.readFromNBT(buffer.readCompoundTag());
tileGroups.add(newbie);
}
}
@Override
- protected void write(PacketBuffer buffer) throws IOException {
+ protected void write(PacketByteBuf buffer) throws IOException {
buffer.writeVarInt(atlasID);
- buffer.writeVarInt(dimension);
+ buffer.writeVarInt(Registry.DIMENSION.getRawId(dimension));
buffer.writeVarInt(tileGroups.size());
for (TileGroup t : tileGroups) {
- NBTTagCompound me = new NBTTagCompound();
+ CompoundTag me = new CompoundTag();
t.writeToNBT(me);
- ByteBufUtils.writeTag(buffer, me);
+ buffer.writeCompoundTag(me);
}
}
@Override
- protected void process(EntityPlayer player, Side side) {
+ protected void process(PlayerEntity player, EnvType side) {
AtlasData atlasData = AntiqueAtlasMod.atlasData.getAtlasData(atlasID, player.world);
DimensionData dimData = atlasData.getDimensionData(dimension);
for (TileGroup t : tileGroups) {
diff --git a/src/main/java/hunternif/mc/atlas/network/client/TileNameIDPacket.java b/src/main/java/hunternif/mc/atlas/network/client/TileNameIDPacket.java
index 887bb3e99..f8e90a6a1 100644
--- a/src/main/java/hunternif/mc/atlas/network/client/TileNameIDPacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/client/TileNameIDPacket.java
@@ -6,13 +6,13 @@
import hunternif.mc.atlas.ext.ExtTileTextureMap;
import hunternif.mc.atlas.ext.TileIdRegisteredEvent;
import hunternif.mc.atlas.network.AbstractMessage.AbstractClientMessage;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.network.PacketBuffer;
-import net.minecraft.world.biome.Biome;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.common.network.ByteBufUtils;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.util.PacketByteBuf;
+import net.minecraft.util.registry.Registry;
+
import java.io.IOException;
import java.util.HashMap;
@@ -42,10 +42,10 @@ public TileNameIDPacket put(String name, int biomeID) {
}
@Override
- public void read(PacketBuffer buffer) throws IOException {
+ public void read(PacketByteBuf buffer) throws IOException {
int size = buffer.readVarInt();
for (int i = 0; i < size; i++) {
- String name = ByteBufUtils.readUTF8String(buffer);
+ String name = buffer.readString(512);
// Reading negative value to save on traffic, because custom biome
// IDs are always negative.
int biomeID = -buffer.readVarInt();
@@ -54,10 +54,10 @@ public void read(PacketBuffer buffer) throws IOException {
}
@Override
- public void write(PacketBuffer buffer) throws IOException {
+ public void write(PacketByteBuf buffer) throws IOException {
buffer.writeVarInt(nameToIdMap.size());
for (Entry entry : nameToIdMap.entrySet()) {
- ByteBufUtils.writeUTF8String(buffer, entry.getKey());
+ buffer.writeString(entry.getKey());
// Writing negative value to save on traffic, because custom biome
// IDs are always negative.
buffer.writeVarInt(-entry.getValue());
@@ -65,21 +65,22 @@ public void write(PacketBuffer buffer) throws IOException {
}
@Override
- @SideOnly(Side.CLIENT)
- protected void process(EntityPlayer player, Side side) {
+ @Environment(EnvType.CLIENT)
+ protected void process(PlayerEntity player, EnvType side) {
for (Entry entry : nameToIdMap.entrySet()) {
String tileName = entry.getKey();
int id = entry.getValue();
// Remove old texture mapping
int oldID = ExtTileIdMap.instance().getPseudoBiomeID(tileName);
if (oldID != ExtTileIdMap.NOT_FOUND && oldID != id) {
- BiomeTextureMap.instance().setTexture(Biome.getBiomeForId(oldID), null);
+ BiomeTextureMap.instance().setTexture(Registry.BIOME.get(oldID), null);
}
ExtTileIdMap.instance().setPseudoBiomeID(tileName, id);
// Register new texture mapping
TextureSet texture = ExtTileTextureMap.instance().getTexture(tileName);
BiomeTextureMap.instance().setTexture(id, texture);
}
- MinecraftForge.EVENT_BUS.post(new TileIdRegisteredEvent(nameToIdMap));
+ // TODO FABRIC
+ // MinecraftForge.EVENT_BUS.post(new TileIdRegisteredEvent(nameToIdMap));
}
}
diff --git a/src/main/java/hunternif/mc/atlas/network/client/TilesPacket.java b/src/main/java/hunternif/mc/atlas/network/client/TilesPacket.java
index 1a8e8b7ad..32ab903e4 100644
--- a/src/main/java/hunternif/mc/atlas/network/client/TilesPacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/client/TilesPacket.java
@@ -5,9 +5,11 @@
import hunternif.mc.atlas.network.AbstractMessage.AbstractClientMessage;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.relauncher.Side;
+import net.fabricmc.api.EnvType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.util.PacketByteBuf;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.dimension.DimensionType;
import java.io.IOException;
@@ -17,15 +19,15 @@
*/
public class TilesPacket extends AbstractClientMessage {
/** Size of one entry in the map in bytes. */
- private static final int ENTRY_SIZE_BYTES = 2 + 2 + 2;
+ private static final int ENTRY_SIZE_BYTES = 2 + 2 + 4;
- private int dimension;
+ private DimensionType dimension;
private int tileCount;
private ByteBuf tileData;
public TilesPacket() {}
- public TilesPacket(int dimension) {
+ public TilesPacket(DimensionType dimension) {
this.dimension = dimension;
tileCount = 0;
tileData = Unpooled.buffer();
@@ -34,7 +36,7 @@ public TilesPacket(int dimension) {
public TilesPacket addTile(int x, int y, int biomeID) {
tileData.writeShort(x);
tileData.writeShort(y);
- tileData.writeShort(biomeID);
+ tileData.writeInt(biomeID);
tileCount++;
return this;
}
@@ -44,24 +46,29 @@ public boolean isEmpty() {
}
@Override
- public void read(PacketBuffer buffer) throws IOException {
- dimension = buffer.readVarInt();
+ public void read(PacketByteBuf buffer) throws IOException {
+ dimension = Registry.DIMENSION.get(buffer.readVarInt());
tileCount = buffer.readVarInt();
tileData = buffer.readBytes(tileCount * ENTRY_SIZE_BYTES);
}
@Override
- public void write(PacketBuffer buffer) throws IOException {
- buffer.writeVarInt(dimension);
+ public void write(PacketByteBuf buffer) throws IOException {
+ buffer.writeVarInt(Registry.DIMENSION.getRawId(dimension));
buffer.writeVarInt(tileCount);
buffer.writeBytes(tileData);
}
@Override
- protected void process(EntityPlayer player, Side side) {
+ protected void process(PlayerEntity player, EnvType side) {
+ if (dimension == null) {
+ // TODO FABRIC
+ return;
+ }
+
ExtBiomeData data = AntiqueAtlasMod.extBiomeData.getData();
for (int i = 0; i < tileCount; i++) {
- data.setBiomeIdAt(dimension, tileData.readShort(), tileData.readShort(), tileData.readShort());
+ data.setBiomeAt(dimension, tileData.readShort(), tileData.readShort(), tileData.readInt());
}
}
}
diff --git a/src/main/java/hunternif/mc/atlas/network/server/AddMarkerPacket.java b/src/main/java/hunternif/mc/atlas/network/server/AddMarkerPacket.java
index c1900ebfb..29c50c280 100644
--- a/src/main/java/hunternif/mc/atlas/network/server/AddMarkerPacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/server/AddMarkerPacket.java
@@ -9,11 +9,12 @@
import hunternif.mc.atlas.network.PacketDispatcher;
import hunternif.mc.atlas.network.client.MarkersPacket;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.entity.player.EntityPlayer;
+import net.fabricmc.api.EnvType;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.common.network.ByteBufUtils;
-import net.minecraftforge.fml.relauncher.Side;
+import net.minecraft.util.PacketByteBuf;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.dimension.DimensionType;
import java.io.IOException;
@@ -24,7 +25,7 @@
*/
public class AddMarkerPacket extends AbstractServerMessage {
private int atlasID;
- private int dimension;
+ private DimensionType dimension;
private String type;
private String label;
private int x, y;
@@ -33,7 +34,7 @@ public class AddMarkerPacket extends AbstractServerMessage {
public AddMarkerPacket() {}
/** Use this constructor when creating a local marker. */
- public AddMarkerPacket(int atlasID, int dimension, String type, String label, int x, int y, boolean visibleAhead) {
+ public AddMarkerPacket(int atlasID, DimensionType dimension, String type, String label, int x, int y, boolean visibleAhead) {
this.atlasID = atlasID;
this.dimension = dimension;
this.type = type;
@@ -44,33 +45,34 @@ public AddMarkerPacket(int atlasID, int dimension, String type, String label, in
}
@Override
- public void read(PacketBuffer buffer) throws IOException {
+ public void read(PacketByteBuf buffer) throws IOException {
atlasID = buffer.readVarInt();
- dimension = buffer.readVarInt();
- type = ByteBufUtils.readUTF8String(buffer);
- label = ByteBufUtils.readUTF8String(buffer);
+ dimension = Registry.DIMENSION.get(buffer.readVarInt());
+ type = buffer.readString(512);
+ label = buffer.readString(512);
x = buffer.readInt();
y = buffer.readInt();
visibleAhead = buffer.readBoolean();
}
@Override
- public void write(PacketBuffer buffer) throws IOException {
+ public void write(PacketByteBuf buffer) throws IOException {
buffer.writeVarInt(atlasID);
- buffer.writeVarInt(dimension);
- ByteBufUtils.writeUTF8String(buffer, type);
- ByteBufUtils.writeUTF8String(buffer, label);
+ buffer.writeVarInt(Registry.DIMENSION.getRawId(dimension));
+ buffer.writeString(type);
+ buffer.writeString(label);
buffer.writeInt(x);
buffer.writeInt(y);
buffer.writeBoolean(visibleAhead);
}
@Override
- protected void process(EntityPlayer player, Side side) {
+ protected void process(PlayerEntity player, EnvType side) {
// Make sure it's this player's atlas :^)
- if (SettingsConfig.gameplay.itemNeeded && !player.inventory.hasItemStack(new ItemStack(RegistrarAntiqueAtlas.ATLAS, 1, atlasID))) {
+ // TODO Fabric
+ if (SettingsConfig.gameplay.itemNeeded /* */&& !player.inventory.containsStack(new ItemStack(RegistrarAntiqueAtlas.ATLAS, 1, atlasID))) {
Log.warn("Player %s attempted to put marker into someone else's Atlas #%d",
- player.getGameProfile().getName(), atlasID);
+ player.getCommandSource().getName(), atlasID);
return;
}
MarkersData markersData = AntiqueAtlasMod.markersData.getMarkersData(atlasID, player.getEntityWorld());
diff --git a/src/main/java/hunternif/mc/atlas/network/server/BrowsingPositionPacket.java b/src/main/java/hunternif/mc/atlas/network/server/BrowsingPositionPacket.java
index 33e33d8fd..696739052 100644
--- a/src/main/java/hunternif/mc/atlas/network/server/BrowsingPositionPacket.java
+++ b/src/main/java/hunternif/mc/atlas/network/server/BrowsingPositionPacket.java
@@ -5,10 +5,11 @@
import hunternif.mc.atlas.SettingsConfig;
import hunternif.mc.atlas.network.AbstractMessage.AbstractServerMessage;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.network.PacketBuffer;
-import net.minecraftforge.fml.relauncher.Side;
+import net.fabricmc.api.EnvType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.util.PacketByteBuf;
+import net.minecraft.util.registry.Registry;
+import net.minecraft.world.dimension.DimensionType;
import java.io.IOException;
@@ -20,13 +21,13 @@ public class BrowsingPositionPacket extends AbstractServerMessage registry;
+ private final MutableRegistry registry;
private MarkerRegistry() {
- registry = new MarkerRegistryImpl<>(DEFAULT_LOC);
- }
-
- public static void register(ResourceLocation location, MarkerType type) {
- type.setRegistryName(location);
- register(type);
+ registry = new DefaultedRegistry<>("antiqueatlas:red_x_small");
}
- public static void register(MarkerType type) {
- INSTANCE.registry.register(type);
- INSTANCE.markDirty();
+ public static void register(Identifier location, MarkerType type) {
+ INSTANCE.registry.add(location, type);
}
- public static ResourceLocation getLoc(String type) {
+ public static Identifier getLoc(String type) {
if(!type.contains(":"))
type = AntiqueAtlasMod.ID + ":" + type;
- return new ResourceLocation(type);
+ return new Identifier(type);
}
public static MarkerType find(String type) {
return find(getLoc(type));
}
- public static MarkerType find(ResourceLocation type) {
- return INSTANCE.registry.getObject(type);
+ public static MarkerType find(Identifier type) {
+ return INSTANCE.registry.get(type);
}
public static boolean hasKey(String type) {
return hasKey(getLoc(type));
}
- public static boolean hasKey(ResourceLocation loc) {
- return INSTANCE.registry.containsKey(loc);
+ public static boolean hasKey(Identifier loc) {
+ return INSTANCE.registry.containsId(loc);
}
- public static List getValues() {
- return INSTANCE.registry.getValues();
+ public static Iterable iterable() {
+ return INSTANCE.registry;
}
- public static Set getKeys() {
- return INSTANCE.registry.getKeys();
+ public static Set getKeys() {
+ return INSTANCE.registry.getIds();
+ }
+
+ public static Identifier getId(MarkerType type) {
+ return INSTANCE.registry.getId(type);
}
}
diff --git a/src/main/java/hunternif/mc/atlas/registry/MarkerRegistryImpl.java b/src/main/java/hunternif/mc/atlas/registry/MarkerRegistryImpl.java
deleted file mode 100644
index 0af09ba4f..000000000
--- a/src/main/java/hunternif/mc/atlas/registry/MarkerRegistryImpl.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package hunternif.mc.atlas.registry;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.registry.IRegistry;
-import org.apache.commons.lang3.Validate;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import javax.annotation.Nullable;
-import java.util.*;
-
-class MarkerRegistryImpl implements IRegistry
-{
- private static final Logger LOGGER = LogManager.getLogger();
- private final Map registryObjects = this.createUnderlyingMap();
- private List values;
-
- private final ResourceLocation defaultKey;
-
- public MarkerRegistryImpl(ResourceLocation defaultKey) {
- this.defaultKey = defaultKey;
- }
-
- private Map createUnderlyingMap()
- {
- return Maps.newHashMap();
- }
-
- @Nullable
- public V getObject(@Nullable ResourceLocation name)
- {
- V value = this.registryObjects.get(name);
- if(value == null) {
- value = this.registryObjects.get(defaultKey);
- }
- return value;
- }
-
- public void putObject(ResourceLocation key, V value)
- {
- Validate.notNull(key);
- Validate.notNull(value);
- this.values = null;
-
- if (this.registryObjects.containsKey(key))
- {
- LOGGER.debug("Adding duplicate key \'" + key + "\' to registry");
- }
-
- this.registryObjects.put(key, value);
- }
-
- /**
- * Register an object on this registry.
- */
- public void register(V value)
- {
- ResourceLocation key = value.getRegistryName();
-
- putObject(key, value);
- }
-
- public Set getKeys()
- {
- return Collections.unmodifiableSet(this.registryObjects.keySet());
- }
-
- @Nullable
- public V getRandomObject(Random random)
- {
- getValues();
-
- return this.values.get( random.nextInt(this.values.size()) );
- }
-
- @SuppressWarnings("unchecked")
- public List getValues() {
- if (this.values == null)
- {
- Collection> collection = this.registryObjects.values();
-
- if (collection.isEmpty())
- {
- this.values = ImmutableList.of();
- } else {
- this.values = ImmutableList.copyOf((Collection extends V>) collection);
- }
- }
- return this.values;
- }
-
- /**
- * Does this registry contain an entry for the given key?
- */
- public boolean containsKey(ResourceLocation key)
- {
- return this.registryObjects.containsKey(key);
- }
-
- public Iterator iterator()
- {
- return this.registryObjects.values().iterator();
- }
-}
diff --git a/src/main/java/hunternif/mc/atlas/registry/MarkerRenderInfo.java b/src/main/java/hunternif/mc/atlas/registry/MarkerRenderInfo.java
index 1f4c0a0e3..d0f1ed41c 100644
--- a/src/main/java/hunternif/mc/atlas/registry/MarkerRenderInfo.java
+++ b/src/main/java/hunternif/mc/atlas/registry/MarkerRenderInfo.java
@@ -1,13 +1,14 @@
package hunternif.mc.atlas.registry;
-import net.minecraft.util.ResourceLocation;
+
+import net.minecraft.util.Identifier;
public class MarkerRenderInfo {
- public final ResourceLocation tex;
+ public final Identifier tex;
public final double x, y;
public final int width, height;
- public MarkerRenderInfo(ResourceLocation tex, double x, double y, int width, int height) {
+ public MarkerRenderInfo(Identifier tex, double x, double y, int width, int height) {
this.tex = tex;
this.x = x; this.y = y;
this.width = width; this.height = height;
diff --git a/src/main/java/hunternif/mc/atlas/registry/MarkerType.java b/src/main/java/hunternif/mc/atlas/registry/MarkerType.java
index 5b8d7c391..1ff00c997 100644
--- a/src/main/java/hunternif/mc/atlas/registry/MarkerType.java
+++ b/src/main/java/hunternif/mc/atlas/registry/MarkerType.java
@@ -6,21 +6,21 @@
import com.google.gson.JsonPrimitive;
import hunternif.mc.atlas.util.BitMatrix;
import hunternif.mc.atlas.util.Log;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.texture.TextureMap;
-import net.minecraft.client.renderer.texture.TextureUtil;
-import net.minecraft.client.resources.IResource;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.client.texture.SpriteAtlasTexture;
+import net.minecraft.client.texture.TextureManager;
+import net.minecraft.util.Identifier;
import org.apache.commons.io.IOUtils;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.resource.Resource;
-public class MarkerType extends IRegistryEntry.Impl {
+public class MarkerType {
- private ResourceLocation[] icons;
+ private Identifier[] icons;
private BitMatrix[] iconPixels;
private int[] iconSizes = null;
@@ -39,9 +39,7 @@ public class MarkerType extends IRegistryEntry.Impl {
private final JSONData data = new JSONData(this);
- public MarkerType(ResourceLocation loc, ResourceLocation... icons) {
- if (loc == null) throw new IllegalArgumentException("MarkerType registry name can't be null");
- setRegistryName(loc);
+ public MarkerType(Identifier... icons) {
this.icons = icons;
}
@@ -115,11 +113,11 @@ private double getCenterY() {
/**
* Get the icon for the marker
*/
- public ResourceLocation getIcon() {
- return icons.length == 0 || iconIndex < 0 ? TextureMap.LOCATION_MISSING_TEXTURE : icons[iconIndex];
+ public Identifier getIcon() {
+ return icons.length == 0 || iconIndex < 0 ? new Identifier("missingno") /* TODO FABRIC */ : icons[iconIndex];
}
- public ResourceLocation[] getAllIcons() {
+ public Identifier[] getAllIcons() {
return icons;
}
@@ -162,7 +160,7 @@ public MarkerRenderInfo getRenderInfo(double scale, double mapScale, double scre
int x = -(int) (size * getCenterX());
int y = -(int) (size * getCenterY());
- ResourceLocation icon = getIcon();
+ Identifier icon = getIcon();
return new MarkerRenderInfo(icon, x, y, size, size);
}
@@ -174,13 +172,13 @@ public void initMips() {
for (int i = 0; i < icons.length; i++) {
iconSizes[i] = -1;
if (icons[i] == null) {
- Log.warn("Marker %s -- Texture location is null at index %d!", getRegistryName().toString(), i);
+ Log.warn("Marker %s -- Texture location is null at index %d!", MarkerRegistry.getId(this).toString(), i);
}
- IResource iresource = null;
+ Resource iresource = null;
try {
- iresource = Minecraft.getMinecraft().getResourceManager().getResource(icons[i]);
- BufferedImage bufferedimage = TextureUtil.readBufferedImage(iresource.getInputStream());
+ iresource = MinecraftClient.getInstance().getResourceManager().getResource(icons[i]);
+ BufferedImage bufferedimage = TODO.a(iresource.getInputStream());
iconSizes[i] = Math.min(bufferedimage.getWidth(), bufferedimage.getHeight());
BitMatrix matrix = new BitMatrix(bufferedimage.getWidth(), bufferedimage.getHeight(), false);
@@ -211,7 +209,7 @@ public void initMips() {
} catch (IOException e) {
Log.warn(e, "Marker %s -- Error getting texture size data for index %d - %s",
- getRegistryName().toString(), i, icons[i].toString());
+ MarkerRegistry.getId(this).toString(), i, icons[i].toString());
} finally {
IOUtils.closeQuietly(iresource);
}
@@ -278,7 +276,7 @@ public static class JSONData {
private final MarkerType type;
- ResourceLocation[] icons;
+ Identifier[] icons;
Integer viewSize = null, clipMin = null, clipMax = null;
Boolean alwaysShow = null, isTile = null, isTechnical = null;
Double centerX = null, centerY = null;
@@ -292,7 +290,7 @@ public void saveTo(JsonObject object) {
JsonArray arr = new JsonArray();
- for (ResourceLocation loc : icons) {
+ for (Identifier loc : icons) {
arr.add(new JsonPrimitive(loc.toString()));
}
@@ -336,22 +334,22 @@ public void readFrom(JsonObject object) {
if(object.entrySet().size() == 0)
return;
- String typeName = type.getRegistryName().toString();
+ String typeName = MarkerRegistry.getId(type).toString();
String workingOn = NONE;
try {
if(object.has(ICONS) && object.get(ICONS).isJsonArray()) {
workingOn = ICONS;
- List list = new ArrayList<>();
+ List list = new ArrayList<>();
int i = 0;
for (JsonElement elem : object.get(ICONS).getAsJsonArray()) {
if (elem.isJsonPrimitive()) {
- list.add(new ResourceLocation(elem.getAsString()));
+ list.add(new Identifier(elem.getAsString()));
} else {
Log.warn("Loading marker %s from JSON: Texture item %d isn't a primitive", typeName, i);
}
i++;
}
- icons = list.toArray(new ResourceLocation[0]);
+ icons = list.toArray(new Identifier[0]);
workingOn = NONE;
}
diff --git a/src/main/java/hunternif/mc/atlas/registry/MarkerTypes.java b/src/main/java/hunternif/mc/atlas/registry/MarkerTypes.java
index 55400d269..2869297b6 100644
--- a/src/main/java/hunternif/mc/atlas/registry/MarkerTypes.java
+++ b/src/main/java/hunternif/mc/atlas/registry/MarkerTypes.java
@@ -2,7 +2,8 @@
import hunternif.mc.atlas.AntiqueAtlasMod;
import hunternif.mc.atlas.client.Textures;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.Identifier;
+
public class MarkerTypes {
@@ -47,14 +48,10 @@ private MarkerTypes() {
END_CITY_FAR.setSize(1).setClip(-1000, -2).setIsTechnical(true);
}
- private MarkerType marker(String name, ResourceLocation... textures) {
- MarkerType type = new MarkerType(new ResourceLocation(AntiqueAtlasMod.ID, name), textures);
- reg(type);
+ private MarkerType marker(String name, Identifier... textures) {
+ MarkerType type = new MarkerType(textures);
+ MarkerRegistry.register(new Identifier(AntiqueAtlasMod.ID, name), type);
return type;
}
-
- private void reg(MarkerType type) {
- MarkerRegistry.register(type);
- }
}
diff --git a/src/main/java/hunternif/mc/atlas/util/AtlasRenderHelper.java b/src/main/java/hunternif/mc/atlas/util/AtlasRenderHelper.java
index 14d2b5267..6474366d8 100644
--- a/src/main/java/hunternif/mc/atlas/util/AtlasRenderHelper.java
+++ b/src/main/java/hunternif/mc/atlas/util/AtlasRenderHelper.java
@@ -1,16 +1,17 @@
package hunternif.mc.atlas.util;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.BufferBuilder;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraft.util.ResourceLocation;
+import com.mojang.blaze3d.platform.GlStateManager;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.Tessellator;
+
+import net.minecraft.client.render.VertexFormats;
+import net.minecraft.util.Identifier;
import org.lwjgl.opengl.GL11;
public class AtlasRenderHelper {
- public static void drawTexturedRect(ResourceLocation texture, double x, double y, double u, double v, int width, int height, int imageWidth, int imageHeight, double scaleX, double scaleY) {
- Minecraft.getMinecraft().renderEngine.bindTexture(texture);
+ public static void drawTexturedRect(Identifier texture, double x, double y, double u, double v, int width, int height, int imageWidth, int imageHeight, double scaleX, double scaleY) {
+ MinecraftClient.getInstance().getTextureManager().bindTexture(texture);
double minU = u / imageWidth;
double maxU = (u + width) / imageWidth;
double minV = v / imageHeight;
@@ -18,40 +19,40 @@ public static void drawTexturedRect(ResourceLocation texture, double x, double y
// After testing, there is no noticeable time difference between raw OpenGL rendering,
// and using the WorldRenderere
Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder renderer = tessellator.getBuffer();
- renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
- renderer.pos((int)(x + scaleX*width), (int)(y + scaleY*height), 0).tex(maxU, maxV).endVertex();
- renderer.pos((int)(x + scaleX*width), (int)y, 0).tex(maxU, minV).endVertex();
- renderer.pos((int)x, (int)y, 0).tex(minU, minV).endVertex();
- renderer.pos((int)x, (int)(y + scaleY*height), 0).tex(minU, maxV).endVertex();
+ BufferBuilder renderer = tessellator.getBufferBuilder();
+ renderer.begin(GL11.GL_QUADS, VertexFormats.POSITION_UV);
+ renderer.vertex((int)(x + scaleX*width), (int)(y + scaleY*height), 0).texture(maxU, maxV).next();
+ renderer.vertex((int)(x + scaleX*width), (int)y, 0).texture(maxU, minV).next();
+ renderer.vertex((int)x, (int)y, 0).texture(minU, minV).next();
+ renderer.vertex((int)x, (int)(y + scaleY*height), 0).texture(minU, maxV).next();
tessellator.draw();
}
- public static void drawTexturedRect(ResourceLocation texture, double x, double y, int u, int v, int width, int height, int imageWidth, int imageHeight) {
+ public static void drawTexturedRect(Identifier texture, double x, double y, int u, int v, int width, int height, int imageWidth, int imageHeight) {
drawTexturedRect(texture, x, y, u, v, width, height, imageWidth, imageHeight, 1, 1);
}
- private static void drawFullTexture(ResourceLocation texture, double x, double y, int width, int height, double scaleX, double scaleY) {
+ private static void drawFullTexture(Identifier texture, double x, double y, int width, int height, double scaleX, double scaleY) {
drawTexturedRect(texture, x, y, 0, 0, width, height, width, height, scaleX, scaleY);
}
- public static void drawFullTexture(ResourceLocation texture, double x, double y, int width, int height) {
+ public static void drawFullTexture(Identifier texture, double x, double y, int width, int height) {
drawFullTexture(texture, x, y, width, height, 1, 1);
}
- public static void drawAutotileCorner(ResourceLocation texture, int x, int y, double u, double v, int tileHalfSize) {
- Minecraft.getMinecraft().renderEngine.bindTexture(texture);
+ public static void drawAutotileCorner(Identifier texture, int x, int y, double u, double v, int tileHalfSize) {
+ MinecraftClient.getInstance().getTextureManager().bindTexture(texture);
double minU = u / 4;
double maxU = (u + 1) / 4;
double minV = v / 6;
double maxV = (v + 1) / 6;
Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder renderer = tessellator.getBuffer();
- renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
- renderer.pos((x + tileHalfSize), (y + tileHalfSize), 0).tex(maxU, maxV).endVertex();
- renderer.pos((x + tileHalfSize), y, 0).tex(maxU, minV).endVertex();
- renderer.pos( x, y, 0).tex(minU, minV).endVertex();
- renderer.pos( x, (y + tileHalfSize), 0).tex(minU, maxV).endVertex();
+ BufferBuilder renderer = tessellator.getBufferBuilder();
+ renderer.begin(GL11.GL_QUADS, VertexFormats.POSITION_UV);
+ renderer.vertex((x + tileHalfSize), (y + tileHalfSize), 0).texture(maxU, maxV).next();
+ renderer.vertex((x + tileHalfSize), y, 0).texture(maxU, minV).next();
+ renderer.vertex( x, y, 0).texture(minU, minV).next();
+ renderer.vertex( x, (y + tileHalfSize), 0).texture(minU, maxV).next();
tessellator.draw();
}
@@ -59,6 +60,6 @@ public static void setGLColor(int color, float alpha) {
float r = (float)(color >> 16 & 0xff)/256f;
float g = (float)(color >> 8 & 0xff)/256f;
float b = (float)(color & 0xff)/256f;
- GlStateManager.color(r, g, b, alpha);
+ GlStateManager.color4f(r, g, b, alpha);
}
}
diff --git a/src/main/java/hunternif/mc/atlas/util/DummyBlockView.java b/src/main/java/hunternif/mc/atlas/util/DummyBlockView.java
new file mode 100644
index 000000000..36c7fef7e
--- /dev/null
+++ b/src/main/java/hunternif/mc/atlas/util/DummyBlockView.java
@@ -0,0 +1,33 @@
+package hunternif.mc.atlas.util;
+
+import net.minecraft.block.BlockState;
+import net.minecraft.block.Blocks;
+import net.minecraft.block.entity.BlockEntity;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.fluid.FluidState;
+import net.minecraft.fluid.Fluids;
+import net.minecraft.sound.SoundCategory;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.BlockView;
+import net.minecraft.world.World;
+
+import javax.annotation.Nullable;
+
+public class DummyBlockView implements BlockView {
+ @Nullable
+ @Override
+ public BlockEntity getBlockEntity(BlockPos var1) {
+ return null;
+ }
+
+ @Override
+ public BlockState getBlockState(BlockPos var1) {
+ return Blocks.AIR.getDefaultState();
+ }
+
+ @Override
+ public FluidState getFluidState(BlockPos var1) {
+ return Fluids.EMPTY.getDefaultState();
+ }
+}
diff --git a/src/main/java/hunternif/mc/atlas/util/DummyWorldAccess.java b/src/main/java/hunternif/mc/atlas/util/DummyWorldAccess.java
deleted file mode 100644
index 6faaf137a..000000000
--- a/src/main/java/hunternif/mc/atlas/util/DummyWorldAccess.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package hunternif.mc.atlas.util;
-
-import net.minecraft.block.state.IBlockState;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.util.SoundCategory;
-import net.minecraft.util.SoundEvent;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.IWorldEventListener;
-import net.minecraft.world.World;
-
-public class DummyWorldAccess implements IWorldEventListener {
-
- @Override
- public void notifyLightSet(BlockPos pos) {}
-
- @Override
- public void markBlockRangeForRenderUpdate(int p_147585_1_, int p_147585_2_,
- int p_147585_3_, int p_147585_4_, int p_147585_5_, int p_147585_6_) {}
-
- @Override
- public void spawnParticle(int particleID, boolean ignoreRange, double xCoord,
- double yCoord, double zCoord, double xOffset, double yOffset,
- double zOffset, int ... p_180442_15_) {}
-
- @Override
- public void spawnParticle(int id, boolean ignoreRange, boolean p_190570_3_, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int... parameters) {}
-
- @Override
- public void onEntityAdded(Entity entity) {}
-
- @Override
- public void onEntityRemoved(Entity entity) {}
-
- @Override
- public void broadcastSound(int p_82746_1_, BlockPos pos, int p_82746_5_) {}
-
-
- @Override
- public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {}
-
- @Override
- public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, IBlockState newState, int flags) {}
-
- @Override
- public void playSoundToAllNearExcept(EntityPlayer player, SoundEvent soundIn, SoundCategory category, double x,
- double y, double z, float volume, float pitch) {}
-
- @Override
- public void playRecord(SoundEvent soundIn, BlockPos pos) {}
-
- @Override
- public void playEvent(EntityPlayer player, int type, BlockPos blockPosIn, int data) {}
-
-}
diff --git a/src/main/java/hunternif/mc/atlas/util/ExportImageUtil.java b/src/main/java/hunternif/mc/atlas/util/ExportImageUtil.java
index d55d0d360..8e320cf13 100644
--- a/src/main/java/hunternif/mc/atlas/util/ExportImageUtil.java
+++ b/src/main/java/hunternif/mc/atlas/util/ExportImageUtil.java
@@ -9,12 +9,12 @@
import hunternif.mc.atlas.registry.MarkerRegistry;
import hunternif.mc.atlas.registry.MarkerRenderInfo;
import hunternif.mc.atlas.registry.MarkerType;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.util.Identifier;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
@@ -28,7 +28,7 @@
import java.util.*;
import java.util.List;
-@SideOnly(Side.CLIENT)
+@Environment(EnvType.CLIENT)
public class ExportImageUtil {
public static final int TILE_SIZE = 16;
public static final int MARKER_SIZE = 32;
@@ -41,7 +41,7 @@ private static ExportUpdateListener getListener() {
}
static {
- chooser.setDialogTitle(I18n.format("gui.antiqueatlas.exportImage"));
+ chooser.setDialogTitle(I18n.translate("gui.antiqueatlas.exportImage"));
chooser.setSelectedFile(new File("Atlas.png"));
chooser.setFileFilter(new FileFilter() {
@Override
@@ -112,24 +112,24 @@ public static void exportPngImage(DimensionData biomeData, DimensionMarkersData
getListener().setStatusString("gui.antiqueatlas.export.loadingtextures");
getListener().setProgressMax(-1);
BufferedImage bg = null;
- Map textureImageMap = new HashMap<>();
+ Map textureImageMap = new HashMap<>();
try {
- InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(Textures.EXPORTED_BG).getInputStream();
+ InputStream is = MinecraftClient.getInstance().getResourceManager().getResource(Textures.EXPORTED_BG).getInputStream();
bg = ImageIO.read(is);
is.close();
// Biome & Marker textures:
- List allTextures = new ArrayList<>(64);
+ List allTextures = new ArrayList<>(64);
allTextures.addAll(BiomeTextureMap.instance().getAllTextures());
if (showMarkers) {
- for (MarkerType type : MarkerRegistry.getValues()) {
+ for (MarkerType type : MarkerRegistry.iterable()) {
allTextures.addAll(Arrays.asList( type.getAllIcons() ));
// allTextures.add(type.getIcon());
}
}
- for (ResourceLocation texture : allTextures) {
+ for (Identifier texture : allTextures) {
try {
- is = Minecraft.getMinecraft().getResourceManager().getResource(texture).getInputStream();
+ is = MinecraftClient.getInstance().getResourceManager().getResource(texture).getInputStream();
BufferedImage tileImage = ImageIO.read(is);
is.close();
textureImageMap.put(texture, tileImage);
@@ -182,24 +182,24 @@ public static void exportPngImageTooLarge(final DimensionData biomeData, final D
getListener().setStatusString("gui.antiqueatlas.export.loadingtextures");
getListener().setProgressMax(-1);
BufferedImage bg = null;
- final Map textureImageMap = new HashMap<>();
+ final Map textureImageMap = new HashMap<>();
try {
- InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(Textures.EXPORTED_BG).getInputStream();
+ InputStream is = MinecraftClient.getInstance().getResourceManager().getResource(Textures.EXPORTED_BG).getInputStream();
bg = ImageIO.read(is);
is.close();
// Biome & Marker textures:
- List allTextures = new ArrayList<>(64);
+ List allTextures = new ArrayList<>(64);
allTextures.addAll(BiomeTextureMap.instance().getAllTextures());
if (showMarkers) {
- for (MarkerType type : MarkerRegistry.getValues()) {
+ for (MarkerType type : MarkerRegistry.iterable()) {
allTextures.addAll(Arrays.asList( type.getAllIcons() ));
// allTextures.add(type.getIcon());
}
}
- for (ResourceLocation texture : allTextures) {
+ for (Identifier texture : allTextures) {
try {
- is = Minecraft.getMinecraft().getResourceManager().getResource(texture).getInputStream();
+ is = MinecraftClient.getInstance().getResourceManager().getResource(texture).getInputStream();
BufferedImage tileImage = ImageIO.read(is);
is.close();
textureImageMap.put(texture, tileImage);
@@ -272,7 +272,7 @@ private static long getAvailableMemory() {
private static void drawMapToGraphics(Graphics2D graphics,
int bgTilesX, int bgTilesY, int outWidth, int outHeight,
- DimensionData biomeData, Map textureImageMap,
+ DimensionData biomeData, Map textureImageMap,
DimensionMarkersData globalMarkers, DimensionMarkersData localMarkers,
boolean showMarkers, int minX, int minY,
int scale, BufferedImage bg) {
@@ -347,7 +347,7 @@ private static void drawMapToGraphics(Graphics2D graphics,
if (subtile == null || subtile.tile == null) continue;
// Load tile texture
- ResourceLocation texture = BiomeTextureMap.instance().getTexture(subtile.tile);
+ Identifier texture = BiomeTextureMap.instance().getTexture(subtile.x, subtile.y, subtile.tile);
BufferedImage tileImage = textureImageMap.get(texture);
if (tileImage == null) continue;
@@ -414,7 +414,7 @@ private static void drawMapToGraphics(Graphics2D graphics,
type.resetMip();
// Load marker texture
- ResourceLocation texture = info.tex;
+ Identifier texture = info.tex;
BufferedImage markerImage = textureImageMap.get(texture);
if (markerImage == null)
continue;
diff --git a/src/main/java/hunternif/mc/atlas/util/FileUtil.java b/src/main/java/hunternif/mc/atlas/util/FileUtil.java
index ee80897f6..5769e6fb2 100644
--- a/src/main/java/hunternif/mc/atlas/util/FileUtil.java
+++ b/src/main/java/hunternif/mc/atlas/util/FileUtil.java
@@ -6,7 +6,7 @@
class FileUtil {
private static final JsonParser parser = new JsonParser();
- private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ private static final com.google.gson.Gson gson = new GsonBuilder().setPrettyPrinting().create();
/** Parse the specified file. Returns null if the file is not found or
* cannot be parsed correctly. */
diff --git a/src/main/java/hunternif/mc/atlas/util/MathUtil.java b/src/main/java/hunternif/mc/atlas/util/MathUtil.java
index 9a689709e..f938fc7c3 100644
--- a/src/main/java/hunternif/mc/atlas/util/MathUtil.java
+++ b/src/main/java/hunternif/mc/atlas/util/MathUtil.java
@@ -1,8 +1,8 @@
package hunternif.mc.atlas.util;
-import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.gen.structure.StructureBoundingBox;
+import net.minecraft.util.math.BoundingBox;
+import net.minecraft.util.math.MutableIntBoundingBox;
public class MathUtil {
/** Returns the nearest number to a multiple of a given number. */
@@ -20,11 +20,11 @@ public static int ceilAbsToBase(int a, int base) {
}
}
- public static AxisAlignedBB toAABB(StructureBoundingBox box) {
- return new AxisAlignedBB(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
+ public static BoundingBox toAABB(MutableIntBoundingBox box) {
+ return new BoundingBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
}
- public static BlockPos getCenter(StructureBoundingBox box) {
- return new BlockPos(box.minX + (box.getXSize() / 2), box.minY + (box.getYSize() / 2), box.minZ + (box.getZSize() / 2));
+ public static BlockPos getCenter(MutableIntBoundingBox box) {
+ return new BlockPos(box.minX + (box.getBlockCountX() / 2), box.minY + (box.getBlockCountY() / 2), box.minZ + (box.getBlockCountZ() / 2));
}
}
diff --git a/src/main/java/hunternif/mc/atlas/util/WorldUtil.java b/src/main/java/hunternif/mc/atlas/util/WorldUtil.java
index 6791e85cd..eec89d753 100644
--- a/src/main/java/hunternif/mc/atlas/util/WorldUtil.java
+++ b/src/main/java/hunternif/mc/atlas/util/WorldUtil.java
@@ -1,25 +1,27 @@
package hunternif.mc.atlas.util;
+import java.util.List;
import net.minecraft.util.math.BlockPos;
-import net.minecraft.village.Village;
-import net.minecraft.village.VillageDoorInfo;
+import net.minecraft.village.VillageDoor;
+import net.minecraft.village.VillageProperties;
+import net.minecraft.world.ViewableWorld;
+import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
-import java.util.List;
-
class WorldUtil {
/**
* Returns the village if the specified chunk overlays its territory.
*/
- public static Village getVillageInChunk(Chunk chunk) {
- int centerX = (chunk.x << 4) + 8;
- int centerZ = (chunk.z << 4) + 8;
- List villages = chunk.getWorld().villageCollection.getVillageList();
- for (Village village : villages) {
+ public static VillageProperties getVillageInChunk(World world, Chunk chunk) {
+ int centerX = (chunk.getPos().x << 4) + 8;
+ int centerZ = (chunk.getPos().z << 4) + 8;
+ // TODO FABRIC: Optimize? No more per-chunk villages...
+ List villages = world.getVillageManager().getVillages();
+ for (VillageProperties village : villages) {
BlockPos coords = village.getCenter();
if ((centerX - coords.getX())*(centerX - coords.getX()) + (centerZ - coords.getZ())*(centerZ - coords.getZ())
- <= village.getVillageRadius()*village.getVillageRadius()) {
+ <= village.getRadius()*village.getRadius()) {
return village;
}
}
@@ -29,14 +31,14 @@ public static Village getVillageInChunk(Chunk chunk) {
/**
* Returns true if the village has a door in the specified chunk.
*/
- public static boolean isVillageDoorInChunk(Village village, Chunk chunk) {
- int centerX = (chunk.x << 4) + 8;
- int centerZ = (chunk.z << 4) + 8;
- if (village.isAnnihilated()) {
+ public static boolean isVillageDoorInChunk(VillageProperties village, Chunk chunk) {
+ int centerX = (chunk.getPos().x << 4) + 8;
+ int centerZ = (chunk.getPos().z << 4) + 8;
+ if (village.hasNoDoors()) {
return true;
}
- for (Object doorInfo : village.getVillageDoorInfoList()) {
- BlockPos door = ((VillageDoorInfo) doorInfo).getDoorBlockPos();
+ for (Object doorInfo : village.getDoors()) {
+ BlockPos door = ((VillageDoor) doorInfo).getPosition();
if ((centerX - door.getX())*(centerX - door.getX()) + (centerZ - door.getZ())*(centerZ - door.getZ())
<= 10*10) {
return true;
diff --git a/src/main/java/kenkron/antiqueatlasoverlay/AAOConfig.java b/src/main/java/kenkron/antiqueatlasoverlay/AAOConfig.java
deleted file mode 100644
index 92865a7c8..000000000
--- a/src/main/java/kenkron/antiqueatlasoverlay/AAOConfig.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package kenkron.antiqueatlasoverlay;
-
-import hunternif.mc.atlas.client.gui.GuiAtlas;
-import net.minecraftforge.common.config.Config;
-import net.minecraftforge.common.config.ConfigManager;
-import net.minecraftforge.fml.client.event.ConfigChangedEvent;
-import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-
-@Config(modid = AntiqueAtlasOverlayMod.MODID, name = "antiqueatlas/atlas_overlay", category = "")
-@Mod.EventBusSubscriber(modid = AntiqueAtlasOverlayMod.MODID)
-public class AAOConfig {
-
- @Config.Comment({ "These settings change the location and size." })
- public static Position position = new Position();
- @Config.Comment({ "These settings change what the map shows, or how it is shown." })
- public static Appearance appearance = new Appearance();
-
- public static class Position {
- @Config.Comment({ "If true, the map position's x axis will align 0 to the right", "of the screen, increasing towards the left." })
- public boolean alignRight = true;
- @Config.Comment({ "If true, the map position's y axis will align 0 to the bottom", "of the screen, increasing towards the top." })
- public boolean alignBottom = false;
- @Config.Comment({ "Map's minimum position along the x axis in GUI pixels.", "Note that this will change with Minecraft's GUI scale configuration." })
- @Config.RangeInt
- public int xPosition = 2;
- @Config.Comment({ "Map's minimum position along the y axis in GUI pixels.", "Note that this will change with Minecraft's GUI scale configuration." })
- @Config.RangeInt
- public int yPosition = 2;
- @Config.Comment({ "Map's width in GUI pixels.", "Note that this will change with Minecraft's GUI scale configuration." })
- @Config.RangeInt(min = 0)
- public int width = GuiAtlas.WIDTH / 2;
- @Config.Comment({ "Map's height in GUI pixels.", "Note that this will change with Minecraft's GUI scale configuration." })
- @Config.RangeInt(min = 0)
- public int height = GuiAtlas.HEIGHT / 2;
- }
-
- public static class Appearance {
- @Config.Comment({ "The size (in GUI pixels) of a map's tile.", "Note that this will change with Minecraft's GUI scale configuration.", "When using a small gui scale, the map may look better with a TILE_SIZE of 16 or more." })
- @Config.RangeInt(min = 1)
- public int tileSize = 8;
- @Config.Comment({ "The size (in GUI pixels) of a marker on the map.", "Note that this will change with Minecraft's GUI scale configuration." })
- @Config.RangeInt(min = 0)
- public int markerSize = GuiAtlas.MARKER_SIZE / 2;
- @Config.Comment({ "The width (in GUI pixels) of the player's icon." })
- @Config.RangeInt(min = 0)
- public int playerIconWidth = 7;
- @Config.Comment({ "The height (in GUI pixels) of the player's icon." })
- @Config.RangeInt(min = 0)
- public int playerIconHeight = 8;
- @Config.Comment({ "The width of the map border on the left and right sides of the minimap tiles.", "Represented as a fraction of the image width.", "Below a certain threshold, this border will be overtaken by the map border graphic." })
- @Config.RangeDouble(min = 0.0F, max = 0.5F)
- public float borderX = 0.0F;
- @Config.Comment({ "The width of the map border on the top and bottom sides of the minimap tiles.", "Represented as a fraction of the image width.", "Below a certain threshold, this border will be overtaken by the map border graphic.\n" })
- @Config.RangeDouble(min = 0.0F, max = 0.5F)
- public float borderY = 0.0F;
- @Config.Comment({ "If true, the minimap will show the map of an atlas only while it is held.", "If false, the minimap will show the map of the first atlas in the hotbar." })
- public boolean requiresHold = true;
- @Config.Comment({ "Set false to disable minimap" })
- public boolean enabled = true;
- }
-
- // TODO - Remove when Forge fixes it's own syncing
- @SubscribeEvent
- public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
- if (event.getModID().equals(AntiqueAtlasOverlayMod.MODID))
- ConfigManager.sync(AntiqueAtlasOverlayMod.MODID, Config.Type.INSTANCE);
- }
-}
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
new file mode 100644
index 000000000..4b9af9f4e
--- /dev/null
+++ b/src/main/resources/fabric.mod.json
@@ -0,0 +1,17 @@
+{
+ "id": "modid",
+ "name": "Example Mod",
+ "description": "This is an example description! Tell everyone what your mod is about!",
+ "version": "${version}",
+ "side": "universal",
+ "initializers": [
+ "net.fabricmc.example.ExampleMod"
+ ],
+ "requires": {
+ "fabric": "*"
+ },
+ "mixins": {
+ "client": "modid.client.json",
+ "common": "modid.common.json"
+ }
+}
diff --git a/src/main/resources/modid.client.json b/src/main/resources/modid.client.json
new file mode 100644
index 000000000..7e8bcc443
--- /dev/null
+++ b/src/main/resources/modid.client.json
@@ -0,0 +1,11 @@
+{
+ "required": true,
+ "package": "net.fabricmc.example.mixin",
+ "compatibilityLevel": "JAVA_8",
+ "mixins": [
+ "ExampleMixin"
+ ],
+ "injectors": {
+ "defaultRequire": 1
+ }
+}
diff --git a/src/main/resources/modid.common.json b/src/main/resources/modid.common.json
new file mode 100644
index 000000000..b26285fe0
--- /dev/null
+++ b/src/main/resources/modid.common.json
@@ -0,0 +1,10 @@
+{
+ "required": true,
+ "package": "net.fabricmc.example.mixin",
+ "compatibilityLevel": "JAVA_8",
+ "mixins": [
+ ],
+ "injectors": {
+ "defaultRequire": 1
+ }
+}
diff --git a/todo/antiqueatlasoverlay/AAOConfig.java b/todo/antiqueatlasoverlay/AAOConfig.java
new file mode 100644
index 000000000..ce1ae1651
--- /dev/null
+++ b/todo/antiqueatlasoverlay/AAOConfig.java
@@ -0,0 +1,66 @@
+package kenkron.antiqueatlasoverlay;
+
+import hunternif.mc.atlas.client.gui.GuiAtlas;
+
+// TODO FABRIC
+
+//@Config(modid = AntiqueAtlasOverlayMod.MODID, name = "antiqueatlas/atlas_overlay", category = "")
+//@Mod.EventBusSubscriber(modid = AntiqueAtlasOverlayMod.MODID)
+public class AAOConfig {
+
+ //@Config.Comment({ "These settings change the location and size." })
+ public static Position position = new Position();
+ //@Config.Comment({ "These settings change what the map shows, or how it is shown." })
+ public static Appearance appearance = new Appearance();
+
+ public static class Position {
+ //@Config.Comment({ "If true, the map position's x axis will align 0 to the right", "of the screen, increasing towards the left." })
+ public boolean alignRight = true;
+ //@Config.Comment({ "If true, the map position's y axis will align 0 to the bottom", "of the screen, increasing towards the top." })
+ public boolean alignBottom = false;
+ //@Config.Comment({ "Map's minimum position along the x axis in GUI pixels.", "Note that this will change with Minecraft's GUI scale configuration." })
+ //@Config.RangeInt
+ public int xPosition = 2;
+ //@Config.Comment({ "Map's minimum position along the y axis in GUI pixels.", "Note that this will change with Minecraft's GUI scale configuration." })
+ //@Config.RangeInt
+ public int yPosition = 2;
+ //@Config.Comment({ "Map's width in GUI pixels.", "Note that this will change with Minecraft's GUI scale configuration." })
+ //@Config.RangeInt(min = 0)
+ public int width = GuiAtlas.WIDTH / 2;
+ //@Config.Comment({ "Map's height in GUI pixels.", "Note that this will change with Minecraft's GUI scale configuration." })
+ //@Config.RangeInt(min = 0)
+ public int height = GuiAtlas.HEIGHT / 2;
+ }
+
+ public static class Appearance {
+ //@Config.Comment({ "The size (in GUI pixels) of a map's tile.", "Note that this will change with Minecraft's GUI scale configuration.", "When using a small gui scale, the map may look better with a TILE_SIZE of 16 or more." })
+ //@Config.RangeInt(min = 1)
+ public int tileSize = 8;
+ //@Config.Comment({ "The size (in GUI pixels) of a marker on the map.", "Note that this will change with Minecraft's GUI scale configuration." })
+ //@Config.RangeInt(min = 0)
+ public int markerSize = GuiAtlas.MARKER_SIZE / 2;
+ //@Config.Comment({ "The width (in GUI pixels) of the player's icon." })
+ //@Config.RangeInt(min = 0)
+ public int playerIconWidth = 7;
+ //@Config.Comment({ "The height (in GUI pixels) of the player's icon." })
+ //@Config.RangeInt(min = 0)
+ public int playerIconHeight = 8;
+ //@Config.Comment({ "The width of the map border on the left and right sides of the minimap tiles.", "Represented as a fraction of the image width.", "Below a certain threshold, this border will be overtaken by the map border graphic." })
+ //@Config.RangeDouble(min = 0.0F, max = 0.5F)
+ public float borderX = 0.0F;
+ //@Config.Comment({ "The width of the map border on the top and bottom sides of the minimap tiles.", "Represented as a fraction of the image width.", "Below a certain threshold, this border will be overtaken by the map border graphic.\n" })
+ //@Config.RangeDouble(min = 0.0F, max = 0.5F)
+ public float borderY = 0.0F;
+ //@Config.Comment({ "If true, the minimap will show the map of an atlas only while it is held.", "If false, the minimap will show the map of the first atlas in the hotbar." })
+ public boolean requiresHold = true;
+ //@Config.Comment({ "Set false to disable minimap" })
+ public boolean enabled = true;
+ }
+
+ // TODO - Remove when Forge fixes it's own syncing
+ //@SubscribeEvent
+ public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
+ if (event.getModID().equals(AntiqueAtlasOverlayMod.MODID))
+ ConfigManager.sync(AntiqueAtlasOverlayMod.MODID, Config.Type.INSTANCE);
+ }
+}
diff --git a/src/main/java/kenkron/antiqueatlasoverlay/AAORenderEventReceiver.java b/todo/antiqueatlasoverlay/AAORenderEventReceiver.java
similarity index 86%
rename from src/main/java/kenkron/antiqueatlasoverlay/AAORenderEventReceiver.java
rename to todo/antiqueatlasoverlay/AAORenderEventReceiver.java
index d200289eb..54ca6178f 100644
--- a/src/main/java/kenkron/antiqueatlasoverlay/AAORenderEventReceiver.java
+++ b/todo/antiqueatlasoverlay/AAORenderEventReceiver.java
@@ -1,5 +1,6 @@
package kenkron.antiqueatlasoverlay;
+import com.mojang.blaze3d.platform.GlStateManager;
import hunternif.mc.atlas.AntiqueAtlasMod;
import hunternif.mc.atlas.RegistrarAntiqueAtlas;
import hunternif.mc.atlas.SettingsConfig;
@@ -14,17 +15,16 @@
import hunternif.mc.atlas.registry.MarkerType;
import hunternif.mc.atlas.util.AtlasRenderHelper;
import hunternif.mc.atlas.util.Rect;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.EntityPlayerSP;
-import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import none.XX_1_12_2_none_bit_XX;
import org.lwjgl.opengl.GL11;
import java.util.List;
@@ -42,27 +42,27 @@ public class AAORenderEventReceiver {
*/
private static int screenScale = 1;
- private static ScaledResolution res;
+ private static XX_1_12_2_none_bit_XX res;
/**
* Convenience method that returns the first atlas ID for all atlas items
* the player is currently carrying in the hotbar/offhand. Returns null if
* there are none. Offhand gets priority.
**/
- private static Integer getPlayerAtlas(EntityPlayer player) {
+ private static Integer getPlayerAtlas(PlayerEntity player) {
if (!SettingsConfig.gameplay.itemNeeded) {
return player.getUniqueID().hashCode();
}
ItemStack stack = player.getHeldItemOffhand();
if (!stack.isEmpty() && stack.getItem() == RegistrarAntiqueAtlas.ATLAS) {
- return stack.getItemDamage();
+ return stack.getDamage();
}
for (int i = 0; i < 9; i++) {
- stack = player.inventory.getStackInSlot(i);
+ stack = player.inventory.getInvStack(i);
if (!stack.isEmpty() && stack.getItem() == RegistrarAntiqueAtlas.ATLAS) {
- return stack.getItemDamage();
+ return stack.getDamage();
}
}
@@ -80,11 +80,11 @@ public static void eventHandler(RenderGameOverlayEvent.Post event) {
}
// Overlay must close if Atlas GUI is opened
- if (Minecraft.getMinecraft().currentScreen instanceof GuiAtlas) {
+ if (MinecraftClient.getInstance().XX_1_12_2_m_XX instanceof GuiAtlas) {
return;
}
- EntityPlayerSP player = Minecraft.getMinecraft().player;
+ ClientPlayerEntity player = MinecraftClient.getInstance().player;
Integer atlas = null;
if (AAOConfig.appearance.requiresHold) {
@@ -92,17 +92,17 @@ public static void eventHandler(RenderGameOverlayEvent.Post event) {
ItemStack stack2 = player.getHeldItemOffhand();
if (!stack.isEmpty() && stack.getItem() == RegistrarAntiqueAtlas.ATLAS) {
- atlas = stack.getItemDamage();
+ atlas = stack.getDamage();
} else if (!stack2.isEmpty() && stack2.getItem() == RegistrarAntiqueAtlas.ATLAS) {
- atlas = stack2.getItemDamage();
+ atlas = stack2.getDamage();
}
} else {
atlas = getPlayerAtlas(player);
}
if (atlas != null) {
- int gameWidth = event.getResolution().getScaledWidth();
- int gameHeight = event.getResolution().getScaledHeight();
+ int gameWidth = event.getResolution().a();
+ int gameHeight = event.getResolution().b();
// remember, y=0 is at the top
Rect bounds = new Rect().setOrigin(AAOConfig.position.xPosition, AAOConfig.position.yPosition);
if (AAOConfig.position.alignRight) {
@@ -120,10 +120,10 @@ public static void eventHandler(RenderGameOverlayEvent.Post event) {
private static void drawMinimap(Rect shape, int atlasID, Vec3d position, float rotation,
int dimension) {
- screenScale = new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor();
- GlStateManager.color(1, 1, 1, 1);
+ screenScale = new XX_1_12_2_none_bit_XX(MinecraftClient.getInstance()).e();
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
GlStateManager.enableBlend();
- GlStateManager.alphaFunc(GL11.GL_GREATER, 0); // So light detail on tiles is
+ GlStateManager.texGenMode(GL11.GL_GREATER, 0); // So light detail on tiles is
// visible
AtlasRenderHelper.drawFullTexture(Textures.BOOK, shape.minX,
shape.minY, shape.getWidth(), shape.getHeight());
@@ -143,7 +143,7 @@ private static void drawMinimap(Rect shape, int atlasID, Vec3d position, float r
}
// Overlay the frame so that edges of the map are smooth:
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
AtlasRenderHelper.drawFullTexture(Textures.BOOK_FRAME, shape.minX,
shape.minY, shape.getWidth(), shape.getHeight());
GlStateManager.disableBlend();
@@ -159,7 +159,7 @@ private static void drawTiles(Rect shape, int atlasID, Vec3d position,
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
DimensionData biomeData = AntiqueAtlasMod.atlasData.getAtlasData(
- atlasID, Minecraft.getMinecraft().world).getDimensionData(dimension);
+ atlasID, MinecraftClient.getInstance().XX_1_12_2_f_XX).getDimensionData(dimension);
TileRenderIterator iter = new TileRenderIterator(biomeData);
Rect iteratorScope = getChunkCoverage(position, shape);
@@ -199,7 +199,7 @@ private static void drawTiles(Rect shape, int atlasID, Vec3d position,
renderer.draw();
// get GL back to normal
GL11.glDisable(GL11.GL_SCISSOR_TEST);
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
}
private static void drawMarkers(Rect shape, int atlasID, Vec3d position,
@@ -212,7 +212,7 @@ private static void drawMarkers(Rect shape, int atlasID, Vec3d position,
// biomeData needed to prevent undiscovered markers from appearing
DimensionData biomeData = AntiqueAtlasMod.atlasData.getAtlasData(
- atlasID, Minecraft.getMinecraft().world).getDimensionData(
+ atlasID, MinecraftClient.getInstance().XX_1_12_2_f_XX).getDimensionData(
dimension);
DimensionMarkersData globalMarkersData = AntiqueAtlasMod.globalMarkersData
.getData().getMarkersDataInDimension(dimension);
@@ -221,7 +221,7 @@ private static void drawMarkers(Rect shape, int atlasID, Vec3d position,
drawMarkersData(globalMarkersData, shape, biomeData, position);
MarkersData markersData = AntiqueAtlasMod.markersData.getMarkersData(
- atlasID, Minecraft.getMinecraft().world);
+ atlasID, MinecraftClient.getInstance().XX_1_12_2_f_XX);
DimensionMarkersData localMarkersData = null;
if (markersData != null) {
localMarkersData = markersData.getMarkersDataInDimension(dimension);
@@ -232,19 +232,19 @@ private static void drawMarkers(Rect shape, int atlasID, Vec3d position,
// get GL back to normal
GL11.glDisable(GL11.GL_SCISSOR_TEST);
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
}
private static void drawPlayer(float x, float y, float rotation) {
// Draw player icon:
GlStateManager.pushMatrix();
- GlStateManager.translate(x, y, 0);
- GlStateManager.rotate(180 + rotation, 0, 0, 1);
- GlStateManager.translate(-AAOConfig.appearance.playerIconWidth / 2, -AAOConfig.appearance.playerIconHeight / 2, 0);
+ GlStateManager.translatef(x, y, 0);
+ GlStateManager.rotatef(180 + rotation, 0, 0, 1);
+ GlStateManager.getTexLevelParameter(-AAOConfig.appearance.playerIconWidth / 2, -AAOConfig.appearance.playerIconHeight / 2, 0);
AtlasRenderHelper.drawFullTexture(Textures.PLAYER, 0, 0, AAOConfig.appearance.playerIconWidth, AAOConfig.appearance.playerIconHeight);
GlStateManager.popMatrix();
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
}
private static void drawMarkersData(DimensionMarkersData markersData,
@@ -292,7 +292,7 @@ private static void renderMarker(Marker marker, int x, int y,
&& !biomeData.hasTileAt(marker.getChunkX(), marker.getChunkZ())) {
return;
}
- GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.texCoordPointer(1, 1, 1, 1);
MarkerType m = MarkerRegistry.find(marker.getType());
if (m == null){
AntiqueAtlasOverlayMod.LOGGER.warn("Could not find marker type for {}", marker.getId());
@@ -324,10 +324,10 @@ private static Rect getChunkCoverage(Vec3d position, Rect windowShape) {
private static void glScissorGUI(Rect shape) {
// glScissor uses the default window coordinates,
// the display window does not. We need to fix this
- int mcHeight = Minecraft.getMinecraft().displayHeight;
- float scissorScaleX = Minecraft.getMinecraft().displayWidth * 1.0f
- / res.getScaledWidth();
- float scissorScaleY = mcHeight * 1.0f / res.getScaledHeight();
+ int mcHeight = MinecraftClient.getInstance().XX_1_12_2_e_XX;
+ float scissorScaleX = MinecraftClient.getInstance().XX_1_12_2_d_XX * 1.0f
+ / res.a();
+ float scissorScaleY = mcHeight * 1.0f / res.b();
GL11.glScissor((int) (shape.minX * scissorScaleX),
(int) (mcHeight - shape.maxY * scissorScaleY),
(int) (shape.getWidth() * scissorScaleX),
diff --git a/src/main/java/kenkron/antiqueatlasoverlay/AntiqueAtlasOverlayMod.java b/todo/antiqueatlasoverlay/AntiqueAtlasOverlayMod.java
similarity index 100%
rename from src/main/java/kenkron/antiqueatlasoverlay/AntiqueAtlasOverlayMod.java
rename to todo/antiqueatlasoverlay/AntiqueAtlasOverlayMod.java
diff --git a/src/main/java/kenkron/antiqueatlasoverlay/SetTileRenderer.java b/todo/antiqueatlasoverlay/SetTileRenderer.java
similarity index 60%
rename from src/main/java/kenkron/antiqueatlasoverlay/SetTileRenderer.java
rename to todo/antiqueatlasoverlay/SetTileRenderer.java
index f21ff7cb1..5195fc869 100644
--- a/src/main/java/kenkron/antiqueatlasoverlay/SetTileRenderer.java
+++ b/todo/antiqueatlasoverlay/SetTileRenderer.java
@@ -1,14 +1,13 @@
package kenkron.antiqueatlasoverlay;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.BufferBuilder;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.HashMap;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.Tessellator;
+import net.minecraft.server.network.packet.ResourcePackStatusC2SPacket;
/**
* The minimap render is a bit slow. The function that really takes time is
@@ -18,27 +17,27 @@
*/
class SetTileRenderer {
- private final HashMap> subjects = new HashMap<>();
+ private final HashMap> subjects = new HashMap<>();
private int tileHalfSize = 8;
public SetTileRenderer(int tileHalfSize) {
this.tileHalfSize = tileHalfSize;
}
- public void addTileCorner(ResourceLocation texture, int x, int y, int u, int v) {
+ public void addTileCorner(ResourcePackStatusC2SPacket texture, int x, int y, int u, int v) {
ArrayList set = subjects.computeIfAbsent(texture, k -> new ArrayList<>());
set.add(new TileCorner(x, y, u, v));
}
public void draw() {
- for (ResourceLocation key : subjects.keySet()) {
+ for (ResourcePackStatusC2SPacket key : subjects.keySet()) {
ArrayList tca = subjects.get(key);
//Effectively a call to GL11.glBindTexture(GL11.GL_TEXTURE_2D, p_94277_0_);
- Minecraft.getMinecraft().renderEngine.bindTexture(key);
+ MinecraftClient.getInstance().textureManager.XX_1_12_2_a_XX(key);
Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder renderer = tessellator.getBuffer();
- renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
+ BufferBuilder renderer = tessellator.getBufferBuilder();
+ renderer.begin(GL11.GL_QUADS, ddk.XX_1_12_2_g_XX);
for (TileCorner tc : tca) {
drawInlineAutotileCorner(tc.x, tc.y, tc.u, tc.v);
}
@@ -52,11 +51,11 @@ private void drawInlineAutotileCorner(int x, int y, int u, int v) {
float minV = v / 6f;
float maxV = (v + 1) / 6f;
Tessellator tessellator = Tessellator.getInstance();
- BufferBuilder renderer = tessellator.getBuffer();
- renderer.pos(x + tileHalfSize, y + tileHalfSize, 0).tex(maxU, maxV).endVertex();
- renderer.pos(x + tileHalfSize, y, 0).tex(maxU, minV).endVertex();
- renderer.pos(x, y, 0).tex(minU, minV).endVertex();
- renderer.pos(x, y + tileHalfSize, 0).tex(minU, maxV).endVertex();
+ BufferBuilder renderer = tessellator.getBufferBuilder();
+ renderer.postNormal(x + tileHalfSize, y + tileHalfSize, 0).a(maxU, maxV).d();
+ renderer.postNormal(x + tileHalfSize, y, 0).a(maxU, minV).d();
+ renderer.postNormal(x, y, 0).a(minU, minV).d();
+ renderer.postNormal(x, y + tileHalfSize, 0).a(minU, maxV).d();
}
public class TileCorner {
diff --git a/src/test/java/hunternif/mc/atlas/TestListMapValueIterator.java b/todo/test/java/hunternif/mc/atlas/TestListMapValueIterator.java
similarity index 100%
rename from src/test/java/hunternif/mc/atlas/TestListMapValueIterator.java
rename to todo/test/java/hunternif/mc/atlas/TestListMapValueIterator.java
diff --git a/src/test/java/hunternif/mc/atlas/TestMath.java b/todo/test/java/hunternif/mc/atlas/TestMath.java
similarity index 100%
rename from src/test/java/hunternif/mc/atlas/TestMath.java
rename to todo/test/java/hunternif/mc/atlas/TestMath.java
diff --git a/src/test/java/hunternif/mc/atlas/TestNBT.java b/todo/test/java/hunternif/mc/atlas/TestNBT.java
similarity index 100%
rename from src/test/java/hunternif/mc/atlas/TestNBT.java
rename to todo/test/java/hunternif/mc/atlas/TestNBT.java
diff --git a/src/test/java/hunternif/mc/atlas/TestSubTileUV.java b/todo/test/java/hunternif/mc/atlas/TestSubTileUV.java
similarity index 100%
rename from src/test/java/hunternif/mc/atlas/TestSubTileUV.java
rename to todo/test/java/hunternif/mc/atlas/TestSubTileUV.java