├── .gitattributes ├── .github └── workflows │ └── gradle.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── org │ └── dimdev │ └── jeid │ ├── INewChunk.java │ ├── JEID.java │ ├── JEIDLoadingPlugin.java │ ├── JEIDLogger.java │ ├── biome │ └── BiomeError.java │ ├── config │ └── ConfigHandler.java │ ├── core │ ├── ASMException.java │ ├── JEIDLoadingPlugin.java │ ├── JEIDMixinLoader.java │ └── JEIDTransformer.java │ ├── debug │ ├── DebugBase.java │ ├── DebugBiome.java │ ├── DebugBlock.java │ ├── DebugEnchant.java │ ├── DebugItem.java │ ├── DebugPotion.java │ ├── IDebugClass.java │ ├── NumInstances.java │ └── RegistryDebug.java │ ├── ducks │ ├── ICustomBiomesForGeneration.java │ ├── IModSupportsJEID.java │ ├── INewBlockStateContainer.java │ ├── INewChunk.java │ ├── IStoredEffectInt.java │ └── modsupport │ │ ├── advancedrocketry │ │ └── IStoredBiomeArray.java │ │ └── cubicchunks │ │ └── INewCube.java │ ├── mixin │ ├── core │ │ ├── enchant │ │ │ ├── MixinEnchantmentHelper.java │ │ │ ├── MixinItemEnchantedBook.java │ │ │ └── client │ │ │ │ └── MixinItemEnchantedBook.java │ │ ├── misc │ │ │ ├── MixinBlock.java │ │ │ ├── MixinGameData.java │ │ │ ├── MixinStatList.java │ │ │ └── client │ │ │ │ └── MixinRenderGlobal.java │ │ ├── network │ │ │ ├── MixinPacketBuffer.java │ │ │ ├── MixinPacketUtil.java │ │ │ ├── MixinSPacketChunkData.java │ │ │ └── client │ │ │ │ └── MixinNetHandlerPlayClient.java │ │ ├── potion │ │ │ ├── MixinSPacketEntityEffect.java │ │ │ ├── MixinSPacketRemoveEntityEffect.java │ │ │ └── client │ │ │ │ └── MixinNetHandlerPlayClient.java │ │ └── world │ │ │ ├── MixinAnvilChunkLoader.java │ │ │ ├── MixinBlockStateContainer.java │ │ │ ├── MixinChunk.java │ │ │ ├── MixinChunkPrimer.java │ │ │ ├── MixinChunkProviderServer.java │ │ │ ├── MixinGenLayerVoronoiZoom.java │ │ │ ├── MixinWorldInfo.java │ │ │ └── client │ │ │ ├── MixinChunk.java │ │ │ └── MixinWorldSummary.java │ └── modsupport │ │ ├── abyssalcraft │ │ └── MixinBiomeUtil.java │ │ ├── advancedrocketry │ │ ├── MixinBiomeHandler.java │ │ ├── MixinPacketBiomeIDChange.java │ │ └── client │ │ │ └── MixinPacketBiomeIDChange.java │ │ ├── atum │ │ └── MixinGenLayerAtumRiverMix.java │ │ ├── biomesoplenty │ │ ├── MixinBOPCommand.java │ │ └── MixinModBiomes.java │ │ ├── biomestaff │ │ ├── MixinBiomeStaffUtil.java │ │ └── MixinItemBiomeStaff.java │ │ ├── biometweaker │ │ ├── MixinBiomeColorMappings.java │ │ ├── MixinBiomeHelper.java │ │ └── MixinCommandSetBiome.java │ │ ├── bookshelf │ │ └── MixinWorldUtils.java │ │ ├── chunkpregenerator │ │ └── MixinBiomeEntry.java │ │ ├── compactmachines │ │ └── MixinChunkUtils.java │ │ ├── creepingnether │ │ └── MixinCorruptorAbstract.java │ │ ├── cubicchunks │ │ ├── MixinCube.java │ │ ├── MixinCubePrimer.java │ │ ├── MixinIONbtReader.java │ │ ├── MixinIONbtWriter.java │ │ ├── MixinVanillaCompatibilityGenerator.java │ │ └── MixinWorldEncoder.java │ │ ├── cyclopscore │ │ └── MixinWorldHelpers.java │ │ ├── extrautils2 │ │ ├── MixinBiomeManip.java │ │ └── MixinWorldProviderSpecialDim.java │ │ ├── gaiadimension │ │ └── MixinGenLayerGDRiverMix.java │ │ ├── geographicraft │ │ └── MixinDimensionManager.java │ │ ├── hammercore │ │ └── MixinWorldLocation.java │ │ ├── journeymap │ │ └── MixinChunkMD.java │ │ ├── kathairis │ │ └── MixinChunkGeneratorMystic.java │ │ ├── moreplanets │ │ └── MixinGenLayerRiversMix.java │ │ ├── mystcraft │ │ └── MixinBiomeReplacer.java │ │ ├── naturescompass │ │ └── MixinBiomeUtils.java │ │ ├── realisticterraingen │ │ └── MixinChunkGeneratorRTG.java │ │ ├── scapeandrunparasites │ │ └── MixinSpreadBiome.java │ │ ├── thaumcraft │ │ └── MixinUtils.java │ │ ├── thebetweenlands │ │ ├── MixinBlockSpreadingDeath.java │ │ └── MixinGenLayerVoronoiZoomInstanced.java │ │ ├── tofucraft │ │ ├── MixinGenLayerRiverMix.java │ │ └── MixinGenLayerTofuVoronoiZoom.java │ │ ├── tropicraft │ │ └── MixinGenLayerTropiVoronoiZoom.java │ │ ├── twilightforest │ │ ├── MixinBlockTFMagicLogSpecial.java │ │ └── MixinGenLayerTFRiverMix.java │ │ ├── worldedit │ │ ├── MixinBaseBlock.java │ │ ├── MixinBiomeCommands.java │ │ └── MixinForgeWorld.java │ │ └── wyrmsofnyrus │ │ ├── MixinHiveCreepSpreadFurther.java │ │ └── MixinSpreadingBiome.java │ └── network │ ├── BiomeAreaChangeMessage.java │ ├── BiomeChunkChangeMessage.java │ ├── BiomePositionChangeMessage.java │ └── MessageManager.java └── resources ├── META-INF └── jeid_at.cfg ├── assets ├── jeid │ └── lang │ │ └── en_us.lang └── reid │ └── logo.png ├── mcmod.info ├── mixins.jeid.abyssalcraft.json ├── mixins.jeid.advancedrocketry.client.json ├── mixins.jeid.advancedrocketry.json ├── mixins.jeid.atum.json ├── mixins.jeid.biomesoplenty.json ├── mixins.jeid.biomestaff.json ├── mixins.jeid.biometweaker.json ├── mixins.jeid.bookshelf.json ├── mixins.jeid.chunkpregenerator.json ├── mixins.jeid.compactmachines.json ├── mixins.jeid.core.json ├── mixins.jeid.creepingnether.json ├── mixins.jeid.cubicchunks.json ├── mixins.jeid.cyclopscore.json ├── mixins.jeid.extrautils2.json ├── mixins.jeid.gaiadimension.json ├── mixins.jeid.geographicraft.json ├── mixins.jeid.hammercore.json ├── mixins.jeid.journeymap.json ├── mixins.jeid.kathairis.json ├── mixins.jeid.moreplanets.json ├── mixins.jeid.mystcraft.json ├── mixins.jeid.naturescompass.json ├── mixins.jeid.rtg.json ├── mixins.jeid.srparasites.json ├── mixins.jeid.thaumcraft.json ├── mixins.jeid.thebetweenlands.json ├── mixins.jeid.tofucraft.json ├── mixins.jeid.tropicraft.json ├── mixins.jeid.twilightforest.json ├── mixins.jeid.worldedit.json ├── mixins.jeid.wyrmsofnyrus.json └── pack.mcmeta /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle 3 | 4 | name: Java CI with Gradle 5 | 6 | on: [ push, pull_request ] 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | with: 14 | fetch-depth: 0 15 | - uses: actions/setup-java@v4 16 | with: 17 | distribution: 'zulu' 18 | java-version: '8' 19 | cache: 'gradle' 20 | - name: Grant execute permission for gradlew 21 | run: chmod +x gradlew 22 | - name: Build the mod 23 | run: ./gradlew --no-daemon build 24 | - uses: actions/upload-artifact@v4 25 | with: 26 | name: Download 27 | path: build/libs 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | eclipse 3 | bin 4 | *.launch 5 | .settings 6 | .metadata 7 | .classpath 8 | .project 9 | 10 | # idea 11 | out 12 | classes 13 | *.ipr 14 | *.iws 15 | *.iml 16 | .idea 17 | 18 | # vscode 19 | .vscode 20 | 21 | # gradle 22 | build 23 | .gradle 24 | 25 | #Netbeans 26 | .nb-gradle 27 | .nb-gradle-properties 28 | 29 | # other 30 | run 31 | .DS_Store 32 | Thumbs.db 33 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: openjdk8 3 | 4 | if: tag IS blank 5 | git: 6 | depth: 5 7 | 8 | install: ./gradlew setupCIWorkspace 9 | script: ./gradlew clean build 10 | 11 | before_cache: find $HOME/.gradle/ -name '*.lock' -print -exec rm -f {} \; 12 | cache: 13 | directories: 14 | - $HOME/.gradle/caches/ 15 | - $HOME/.gradle/wrapper/ 16 | 17 | before_deploy: export RELEASE_FILE_LIST=$(ls ./build/libs/* | tr '\n' ', ') 18 | deploy: 19 | skip_cleanup: true 20 | provider: releases 21 | api_key: 22 | secure: ArR73HRTML2+nfEHHcTc824vG3MBgtV2h/naMbpVbgrcD/aRaFvX5RU84BBS0A5KXRs+9/5gkNxffMSmiTD5HlorMh2Qb5eYNs8s43JJ7UlR0hKeVcZb8SbVMooPeNrFbYxQHMgz0VXHYZas4y2vFMd9vwgQOpTcRjnc6wyINkvsR1LtLs5D/w9bKNxz2iv2DNnGZhI/wPrPUkQXzypI6sSG6BbfyzWZ1Z3A2NU2qt6lO5U515/mCwEMVMKxC5BPK+0NCNOMc5oESc/Edmr2XtP2VRVsLI0ouRQniwr8uadoPGFZbj72o/8qGuGInSI0cApi48dS0bT0tUv8AIMseTwxsVNmSAi6PUZ5Mdsoz6yvsezwnD/tyQrCeY5yPZUwLUnwitnPbGcMbv88nioxrbd3nQWRqWNF9v9wdbJLNECfn1jK/iRpv/rw6MYntcMHgENziBM/xq4SQV5vlOsgjnihhGIJ8zQZQ5/RKVKoZj9sOunw7v+OZL6ZeMKIV2/lbwkjeIlTyY0IvZoydG8Lw5RVeMR+vdFULM1dJH1gKLTSl5iEmtX05iSR+LzmqCY+DfOCff7Iyoa+oIN46WuwzxCRz+V7IFUfz+6o4LOQ47vCN6LZvcSlh+qylI9n0YNHO/WMP/KJl9bhcVeCQoe0Zi+lAen9loZa8F2vFdc8DrY= 23 | file_glob: true 24 | file: "{$RELEASE_FILE_LIST}" 25 | on: 26 | repo: DimensionalDevelopment/JustEnoughIDs 27 | branch: master 28 | tags: false 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Dimensional Development 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Downloads 2 | - [ CurseForge](https://curseforge.com/minecraft/mc-mods/reid) 3 | - [ Modrinth](https://modrinth.com/mod/reid) 4 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Sets default memory used for gradle commands. Can be overridden by user or command line properties. 2 | # This is required to provide enough memory for the Minecraft decompilation process. 3 | org.gradle.jvmargs = -Xmx3G 4 | 5 | # Mod Information 6 | maven_group = org.dimdev.jeid 7 | mod_name = JustEnoughIDs 8 | mod_version = 2.2.2 9 | archives_base_name = jeid 10 | 11 | # If any properties changes below this line, run `gradlew setupDecompWorkspace` and refresh gradle again to ensure everything is working correctly. 12 | 13 | # Boilerplate Options 14 | use_mixins = true 15 | use_coremod = true 16 | use_assetmover = false 17 | 18 | # Access Transformer files should be in the root of `resources` folder and with the filename formatted as: `{archives_base_name}_at.cfg` 19 | use_access_transformer = true 20 | 21 | # Coremod Arguments 22 | include_mod = true 23 | coremod_plugin_class_name = org.dimdev.jeid.core.JEIDLoadingPlugin -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerraFirmaCraft-The-Final-Frontier/RoughlyEnoughIDs/6dcd45f6319bf5c993a3aafbdb99006359943e7d/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 87 | 88 | # Use the maximum available, or set MAX_FD != -1 to use that value. 89 | MAX_FD=maximum 90 | 91 | warn () { 92 | echo "$*" 93 | } >&2 94 | 95 | die () { 96 | echo 97 | echo "$*" 98 | echo 99 | exit 1 100 | } >&2 101 | 102 | # OS specific support (must be 'true' or 'false'). 103 | cygwin=false 104 | msys=false 105 | darwin=false 106 | nonstop=false 107 | case "$( uname )" in #( 108 | CYGWIN* ) cygwin=true ;; #( 109 | Darwin* ) darwin=true ;; #( 110 | MSYS* | MINGW* ) msys=true ;; #( 111 | NONSTOP* ) nonstop=true ;; 112 | esac 113 | 114 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 115 | 116 | 117 | # Determine the Java command to use to start the JVM. 118 | if [ -n "$JAVA_HOME" ] ; then 119 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 120 | # IBM's JDK on AIX uses strange locations for the executables 121 | JAVACMD=$JAVA_HOME/jre/sh/java 122 | else 123 | JAVACMD=$JAVA_HOME/bin/java 124 | fi 125 | if [ ! -x "$JAVACMD" ] ; then 126 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 127 | 128 | Please set the JAVA_HOME variable in your environment to match the 129 | location of your Java installation." 130 | fi 131 | else 132 | JAVACMD=java 133 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 134 | 135 | Please set the JAVA_HOME variable in your environment to match the 136 | location of your Java installation." 137 | fi 138 | 139 | # Increase the maximum file descriptors if we can. 140 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 141 | case $MAX_FD in #( 142 | max*) 143 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 144 | # shellcheck disable=SC3045 145 | MAX_FD=$( ulimit -H -n ) || 146 | warn "Could not query maximum file descriptor limit" 147 | esac 148 | case $MAX_FD in #( 149 | '' | soft) :;; #( 150 | *) 151 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 152 | # shellcheck disable=SC3045 153 | ulimit -n "$MAX_FD" || 154 | warn "Could not set maximum file descriptor limit to $MAX_FD" 155 | esac 156 | fi 157 | 158 | # Collect all arguments for the java command, stacking in reverse order: 159 | # * args from the command line 160 | # * the main class name 161 | # * -classpath 162 | # * -D...appname settings 163 | # * --module-path (only if needed) 164 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 165 | 166 | # For Cygwin or MSYS, switch paths to Windows format before running java 167 | if "$cygwin" || "$msys" ; then 168 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 169 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 170 | 171 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 172 | 173 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 174 | for arg do 175 | if 176 | case $arg in #( 177 | -*) false ;; # don't mess with options #( 178 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 179 | [ -e "$t" ] ;; #( 180 | *) false ;; 181 | esac 182 | then 183 | arg=$( cygpath --path --ignore --mixed "$arg" ) 184 | fi 185 | # Roll the args list around exactly as many times as the number of 186 | # args, so each arg winds up back in the position where it started, but 187 | # possibly modified. 188 | # 189 | # NB: a `for` loop captures its iteration list before it begins, so 190 | # changing the positional parameters here affects neither the number of 191 | # iterations, nor the values presented in `arg`. 192 | shift # remove old arg 193 | set -- "$@" "$arg" # push replacement arg 194 | done 195 | fi 196 | 197 | 198 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 199 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 200 | 201 | # Collect all arguments for the java command; 202 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 203 | # shell script including quotes and variable substitutions, so put them in 204 | # double quotes to make sure that they get re-expanded; and 205 | # * put everything else in single quotes, so that it's not re-expanded. 206 | 207 | set -- \ 208 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 209 | -classpath "$CLASSPATH" \ 210 | org.gradle.wrapper.GradleWrapperMain \ 211 | "$@" 212 | 213 | # Stop when "xargs" is not available. 214 | if ! command -v xargs >/dev/null 2>&1 215 | then 216 | die "xargs is not available" 217 | fi 218 | 219 | # Use "xargs" to parse quoted args. 220 | # 221 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 222 | # 223 | # In Bash we could simply go: 224 | # 225 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 226 | # set -- "${ARGS[@]}" "$@" 227 | # 228 | # but POSIX shell has neither arrays nor command substitution, so instead we 229 | # post-process each arg (as a line of input to sed) to backslash-escape any 230 | # character that might be a shell metacharacter, then use eval to reverse 231 | # that process (while maintaining the separation between arguments), and wrap 232 | # the whole thing up as a single "set" statement. 233 | # 234 | # This will of course break if any of these variables contains a newline or 235 | # an unmatched quote. 236 | # 237 | 238 | eval "set -- $( 239 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 240 | xargs -n1 | 241 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 242 | tr '\n' ' ' 243 | )" '"$@"' 244 | 245 | exec "$JAVACMD" "$@" 246 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | // RetroFuturaGradle 5 | name 'GTNH Maven' 6 | url 'https://nexus.gtnewhorizons.com/repository/public/' 7 | mavenContent { 8 | includeGroup 'com.gtnewhorizons' 9 | includeGroup 'com.gtnewhorizons.retrofuturagradle' 10 | } 11 | } 12 | gradlePluginPortal() 13 | mavenCentral() 14 | mavenLocal() 15 | } 16 | } 17 | 18 | plugins { 19 | // Automatic toolchain provisioning 20 | id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' 21 | } 22 | 23 | // Due to an IntelliJ bug, this has to be done 24 | // rootProject.name = archives_base_name 25 | rootProject.name = rootProject.projectDir.getName() 26 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/INewChunk.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid; 2 | 3 | /** 4 | * Dummy interface to act as passthrough for real INewChunk. 5 | * Provided to keep parity with JEID and other mod compat. 6 | * @see org.dimdev.jeid.ducks.INewChunk 7 | */ 8 | public interface INewChunk extends org.dimdev.jeid.ducks.INewChunk { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/JEID.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid; 2 | 3 | import net.minecraftforge.common.MinecraftForge; 4 | import net.minecraftforge.fml.common.Mod; 5 | import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; 6 | import net.minecraftforge.fml.common.registry.ForgeRegistries; 7 | import org.apache.logging.log4j.LogManager; 8 | import org.apache.logging.log4j.Logger; 9 | import org.dimdev.jeid.biome.BiomeError; 10 | import org.dimdev.jeid.debug.RegistryDebug; 11 | import org.dimdev.jeid.jeid.Tags; 12 | import org.dimdev.jeid.network.MessageManager; 13 | 14 | @Mod(modid = JEID.MODID, 15 | name = JEID.NAME, 16 | version = JEID.VERSION, 17 | dependencies = JEID.DEPENDENCIES) 18 | public class JEID { 19 | public static final String MODID = Tags.MOD_ID; 20 | public static final String NAME = Tags.MOD_NAME; 21 | public static final String VERSION = Tags.VERSION; 22 | public static final String DEPENDENCIES = "required:mixinbooter@[8.0,);" 23 | + "after:abyssalcraft;" 24 | + "after:advancedrocketry;" 25 | + "after:atum;" 26 | + "after:biomesoplenty;" 27 | + "after:biometweaker;" 28 | + "after:bookshelf;" 29 | + "after:compactmachines3;" 30 | + "after:creepingnether;" 31 | + "after:cubicchunks@[1.12.2-0.0.1271.0-SNAPSHOT,);" 32 | + "after:cyclopscore;" 33 | + "after:extrautils2;" 34 | + "after:gaiadimension;" 35 | + "after:geographicraft;" 36 | + "after:hammercore;" 37 | + "after:journeymap;" 38 | + "after:moreplanets;" 39 | + "after:mystcraft;" 40 | + "after:srparasites;" 41 | + "after:thaumcraft;" 42 | + "after:thebetweenlands;" 43 | + "after:tofucraft;" 44 | + "after:tropicraft;" 45 | + "after:twilightforest;" 46 | + "after:wyrmsofnyrus;" 47 | + "after:worldedit"; 48 | 49 | @Mod.EventHandler 50 | public void onPreInit(FMLPreInitializationEvent event) { 51 | // Register messages 52 | MessageManager.init(); 53 | // Register Error Biome 54 | BiomeError.createInstance(); 55 | ForgeRegistries.BIOMES.register(BiomeError.getInstance()); 56 | // Debug code 57 | MinecraftForge.EVENT_BUS.register(new RegistryDebug()); 58 | } 59 | } -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/JEIDLoadingPlugin.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid; 2 | 3 | /** 4 | * Dummy class for reflection by other mods. 5 | * @see org.dimdev.jeid.core.JEIDLoadingPlugin 6 | */ 7 | public class JEIDLoadingPlugin { 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/JEIDLogger.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | 6 | import org.dimdev.jeid.jeid.Tags; 7 | 8 | public class JEIDLogger { 9 | public static final Logger LOGGER = LogManager.getLogger(Tags.MOD_NAME); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/biome/BiomeError.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.biome; 2 | 3 | import net.minecraft.world.biome.BiomeVoid; 4 | import org.dimdev.jeid.JEID; 5 | 6 | public class BiomeError extends BiomeVoid { 7 | private static BiomeError INSTANCE; 8 | 9 | private BiomeError(String idName, String propName) { 10 | super(new BiomeProperties(propName)); 11 | this.setRegistryName(JEID.MODID, idName); 12 | } 13 | 14 | public static void createInstance() { 15 | if (INSTANCE == null) { 16 | INSTANCE = new BiomeError("error_biome", "A mod doesn't support extended biome IDs -- report to REID"); 17 | } 18 | } 19 | 20 | public static BiomeError getInstance() { 21 | return BiomeError.INSTANCE; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/config/ConfigHandler.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.config; 2 | 3 | import net.minecraftforge.common.config.Config; 4 | import net.minecraftforge.common.config.ConfigManager; 5 | import net.minecraftforge.fml.client.event.ConfigChangedEvent; 6 | import net.minecraftforge.fml.common.Mod; 7 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 8 | import org.dimdev.jeid.JEID; 9 | 10 | @Config(modid = JEID.MODID, name = "RoughlyEnoughIDs") 11 | @Config.LangKey(value = "cfg.reid.mainTitle") 12 | public class ConfigHandler { 13 | @Config.LangKey("cfg.reid.debug") 14 | @Config.Name("Debug") 15 | public static final DebugCategory DEBUG = new DebugCategory(); 16 | 17 | public static class DebugCategory { 18 | @Config.RequiresMcRestart 19 | @Config.Name("Biomes") 20 | @Config.Comment("Enable this to register extra biomes for debugging/testing.") 21 | public boolean reidDebugBiomesToggle = false; 22 | 23 | @Config.RequiresMcRestart 24 | @Config.Name("Biomes - Amount") 25 | @Config.Comment("The amount of biomes to register.") 26 | public int reidDebugBiomesAmt = 300; 27 | 28 | @Config.RequiresMcRestart 29 | @Config.Name("Blocks") 30 | @Config.Comment("Enable this to register extra blocks for debugging/testing.") 31 | public boolean reidDebugBlocksToggle = false; 32 | 33 | @Config.RequiresMcRestart 34 | @Config.Name("Blocks - Amount") 35 | @Config.Comment("The amount of blocks to register.") 36 | public int reidDebugBlocksAmt = 5_000; 37 | 38 | @Config.RequiresMcRestart 39 | @Config.Name("Enchantments") 40 | @Config.Comment("Enable this to register extra enchantments for debugging/testing.") 41 | public boolean reidDebugEnchantsToggle = false; 42 | 43 | @Config.RequiresMcRestart 44 | @Config.Name("Enchantments - Amount") 45 | @Config.Comment("The amount of enchantments to register.") 46 | public int reidDebugEnchantsAmt = Short.MAX_VALUE; 47 | 48 | @Config.RequiresMcRestart 49 | @Config.Name("Items") 50 | @Config.Comment("Enable this to register extra items for debugging/testing.") 51 | public boolean reidDebugItemsToggle = false; 52 | 53 | @Config.RequiresMcRestart 54 | @Config.Name("Items - Amount") 55 | @Config.Comment("The amount of items to register.") 56 | public int reidDebugItemsAmt = 40_000; 57 | 58 | @Config.RequiresMcRestart 59 | @Config.Name("Potions") 60 | @Config.Comment("Enable this to register extra potions for debugging/testing.") 61 | public boolean reidDebugPotionsToggle = false; 62 | 63 | @Config.RequiresMcRestart 64 | @Config.Name("Potions - Amount") 65 | @Config.Comment("The amount of potions to register.") 66 | public int reidDebugPotionsAmt = 300; 67 | } 68 | 69 | @Mod.EventBusSubscriber(modid = JEID.MODID) 70 | public static class EventHandler { 71 | @SubscribeEvent 72 | public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { 73 | if (event.getModID().equals(JEID.MODID)) { 74 | ConfigManager.sync(JEID.MODID, Config.Type.INSTANCE); 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/core/ASMException.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.core; 2 | 3 | import org.objectweb.asm.tree.*; 4 | 5 | import java.util.Iterator; 6 | 7 | public class ASMException extends RuntimeException { 8 | private static final long serialVersionUID = -8581611883691404427L; 9 | 10 | public ASMException(String message) { 11 | super("JustEnoughIDs - Class transformation error\n"+message); 12 | } 13 | 14 | public ASMException(String message, ClassNode node) { 15 | this(message+"\n"+getStringDescriptor(node)); 16 | } 17 | 18 | public ASMException(String message, MethodNode node) { 19 | this(message+"\n"+getStringDescriptor(node)); 20 | } 21 | 22 | private static String getStringDescriptor(MethodNode node) { 23 | StringBuilder sb = new StringBuilder(); 24 | Iterator i = node.instructions.iterator(); 25 | while (i.hasNext()) { 26 | AbstractInsnNode n = i.next(); 27 | sb.append("["+n.getOpcode()+"] - "+getInsnDesc(n)+"\n"); 28 | } 29 | return sb.toString(); 30 | } 31 | 32 | private static String getInsnDesc(AbstractInsnNode n) { 33 | if (n instanceof LdcInsnNode) { 34 | return "LDC - "+((LdcInsnNode)n).cst.toString(); 35 | } 36 | if (n instanceof LabelNode) { 37 | return "Label - "+((LabelNode)n).getLabel().toString(); 38 | } 39 | if (n instanceof LineNumberNode) { 40 | return "Line - "+((LineNumberNode)n).line; 41 | } 42 | if (n instanceof IntInsnNode) { 43 | return "Int - "+((IntInsnNode)n).operand; 44 | } 45 | if (n instanceof MethodInsnNode) { 46 | MethodInsnNode m = (MethodInsnNode)n; 47 | return "Method - "+m.name+", "+m.desc+", "+m.owner; 48 | } 49 | return n.getClass().getName(); 50 | } 51 | 52 | private static String getStringDescriptor(ClassNode node) { 53 | StringBuilder sb = new StringBuilder(); 54 | node.methods.forEach(m -> sb.append(m.name+": "+m.desc+"\n")); 55 | return sb.toString(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/core/JEIDLoadingPlugin.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.core; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import net.minecraftforge.common.ForgeVersion; 5 | import net.minecraftforge.fml.relauncher.FMLLaunchHandler; 6 | import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; 7 | import zone.rong.mixinbooter.IEarlyMixinLoader; 8 | 9 | import javax.annotation.Nullable; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | @IFMLLoadingPlugin.MCVersion(ForgeVersion.mcVersion) 14 | @IFMLLoadingPlugin.Name("JustEnoughIDs Extension Plugin") 15 | //@IFMLLoadingPlugin.TransformerExclusions("org.dimdev.jeid.") 16 | public class JEIDLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader { 17 | public static final boolean isClient = FMLLaunchHandler.side().isClient(); 18 | public static final boolean isDeobf = FMLLaunchHandler.isDeobfuscatedEnvironment(); 19 | 20 | @Override 21 | public String[] getASMTransformerClass() { 22 | return new String[0]; 23 | } 24 | 25 | @Override 26 | public String getModContainerClass() { 27 | return null; 28 | } 29 | 30 | @Nullable 31 | @Override 32 | public String getSetupClass() { 33 | return null; 34 | } 35 | 36 | @Override 37 | public void injectData(Map data) { 38 | } 39 | 40 | // Guarantees deobf-SRG names are present before transformer loads 41 | @Override 42 | public String getAccessTransformerClass() { 43 | return "org.dimdev.jeid.core.JEIDTransformer"; 44 | } 45 | 46 | @Override 47 | public List getMixinConfigs() { 48 | return ImmutableList.of("mixins.jeid.core.json"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/core/JEIDMixinLoader.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.core; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.minecraftforge.fml.common.Loader; 7 | 8 | import zone.rong.mixinbooter.ILateMixinLoader; 9 | 10 | public class JEIDMixinLoader implements ILateMixinLoader { 11 | public List getMixinConfigs() { 12 | List configs = new ArrayList<>(); 13 | 14 | if (JEIDLoadingPlugin.isClient) { 15 | if (Loader.isModLoaded("advancedrocketry")) { 16 | configs.add("mixins.jeid.advancedrocketry.client.json"); 17 | } 18 | } 19 | if (Loader.isModLoaded("abyssalcraft")) { 20 | configs.add("mixins.jeid.abyssalcraft.json"); 21 | } 22 | if (Loader.isModLoaded("advancedrocketry")) { 23 | configs.add("mixins.jeid.advancedrocketry.json"); 24 | } 25 | if (Loader.isModLoaded("atum")) { 26 | configs.add("mixins.jeid.atum.json"); 27 | } 28 | if (Loader.isModLoaded("biomesoplenty")) { 29 | configs.add("mixins.jeid.biomesoplenty.json"); 30 | } 31 | if (Loader.isModLoaded("biomestaff")) { 32 | configs.add("mixins.jeid.biomestaff.json"); 33 | } 34 | if (Loader.isModLoaded("biometweaker")) { 35 | configs.add("mixins.jeid.biometweaker.json"); 36 | } 37 | if (Loader.isModLoaded("bookshelf")) { 38 | configs.add("mixins.jeid.bookshelf.json"); 39 | } 40 | if (Loader.isModLoaded("compactmachines3")) { 41 | configs.add("mixins.jeid.compactmachines.json"); 42 | } 43 | if (Loader.isModLoaded("creepingnether")) { 44 | configs.add("mixins.jeid.creepingnether.json"); 45 | } 46 | if (Loader.isModLoaded("chunkpregenerator")) { 47 | configs.add("mixins.jeid.chunkpregenerator.json"); 48 | } 49 | if (Loader.isModLoaded("cubicchunks")) { 50 | configs.add("mixins.jeid.cubicchunks.json"); 51 | } 52 | if (Loader.isModLoaded("cyclopscore")) { 53 | configs.add("mixins.jeid.cyclopscore.json"); 54 | } 55 | if (Loader.isModLoaded("extrautils2")) { 56 | configs.add("mixins.jeid.extrautils2.json"); 57 | } 58 | if (Loader.isModLoaded("gaiadimension")) { 59 | configs.add("mixins.jeid.gaiadimension.json"); 60 | } 61 | if (Loader.isModLoaded("geographicraft")) { 62 | configs.add("mixins.jeid.geographicraft.json"); 63 | } 64 | if (Loader.isModLoaded("hammercore")) { 65 | configs.add("mixins.jeid.hammercore.json"); 66 | } 67 | if (Loader.isModLoaded("journeymap")) { 68 | configs.add("mixins.jeid.journeymap.json"); 69 | } 70 | if (Loader.isModLoaded("kathairis")) { 71 | configs.add("mixins.jeid.kathairis.json"); 72 | } 73 | if (Loader.isModLoaded("moreplanets")) { 74 | configs.add("mixins.jeid.moreplanets.json"); 75 | } 76 | if (Loader.isModLoaded("mystcraft")) { 77 | configs.add("mixins.jeid.mystcraft.json"); 78 | } 79 | if (Loader.isModLoaded("naturescompass")) { 80 | configs.add("mixins.jeid.naturescompass.json"); 81 | } 82 | if (Loader.isModLoaded("rtg")) { 83 | configs.add("mixins.jeid.rtg.json"); 84 | } 85 | if (Loader.isModLoaded("srparasites")) { 86 | configs.add("mixins.jeid.srparasites.json"); 87 | } 88 | if (Loader.isModLoaded("thaumcraft")) { 89 | configs.add("mixins.jeid.thaumcraft.json"); 90 | } 91 | if (Loader.isModLoaded("thebetweenlands")) { 92 | configs.add("mixins.jeid.thebetweenlands.json"); 93 | } 94 | if (Loader.isModLoaded("tofucraft")) { 95 | configs.add("mixins.jeid.tofucraft.json"); 96 | } 97 | if (Loader.isModLoaded("tropicraft")) { 98 | configs.add("mixins.jeid.tropicraft.json"); 99 | } 100 | if (Loader.isModLoaded("twilightforest")) { 101 | configs.add("mixins.jeid.twilightforest.json"); 102 | } 103 | if (Loader.isModLoaded("worldedit")) { 104 | configs.add("mixins.jeid.worldedit.json"); 105 | } 106 | if (Loader.isModLoaded("wyrmsofnyrus")) { 107 | configs.add("mixins.jeid.wyrmsofnyrus.json"); 108 | } 109 | return configs; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/core/JEIDTransformer.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.core; 2 | 3 | import net.minecraft.launchwrapper.IClassTransformer; 4 | import net.minecraftforge.fml.relauncher.FMLLaunchHandler; 5 | import org.objectweb.asm.ClassReader; 6 | import org.objectweb.asm.ClassWriter; 7 | import org.objectweb.asm.Opcodes; 8 | import org.objectweb.asm.tree.*; 9 | 10 | import java.util.Iterator; 11 | import java.util.function.Predicate; 12 | 13 | /** 14 | * Since 2.1.0: Cleaned up obfuscated code; converted most transforms to mixins. 15 | *

16 | * This class was borrowed from Zabi94's MaxPotionIDExtender 17 | * under MIT License and with full help of Zabi. All credit in this class goes to Zabi 18 | * and his incredible work on figuring out how to make this work and helping out. 19 | *

20 | * MaxPotionIDExtender by Zabi94 21 | */ 22 | public class JEIDTransformer implements IClassTransformer { 23 | @Override 24 | public byte[] transform(String name, String transformedName, byte[] basicClass) { 25 | if (transformedName.equals("net.minecraft.item.ItemStack")) { 26 | return transformItemStack(basicClass); 27 | } 28 | if (transformedName.equals("net.minecraft.potion.PotionEffect")) { 29 | return transformPotionEffect(basicClass); 30 | } 31 | return basicClass; 32 | } 33 | 34 | private static MethodNode locateMethod(ClassNode cn, String desc, String... namesIn) { 35 | return cn.methods.stream() 36 | .filter(n -> n.desc.equals(desc) && anyMatch(namesIn, n.name)) 37 | .findAny().orElseThrow(() -> new ASMException(getNames(namesIn) + ": " + desc + " cannot be found in " + cn.name, cn)); 38 | } 39 | 40 | private static boolean anyMatch(String[] pool, String match) { 41 | for (String s : pool) { 42 | if (s.equals(match)) { 43 | return true; 44 | } 45 | } 46 | return false; 47 | } 48 | 49 | private static String getNames(String[] pool) { 50 | StringBuilder sb = new StringBuilder(); 51 | for (String s : pool) { 52 | sb.append(s); 53 | sb.append(" "); 54 | } 55 | return sb.toString().trim(); 56 | } 57 | 58 | private static AbstractInsnNode locateTargetInsn(MethodNode mn, Predicate filter) { 59 | AbstractInsnNode target = null; 60 | Iterator i = mn.instructions.iterator(); 61 | while (i.hasNext() && target == null) { 62 | AbstractInsnNode n = i.next(); 63 | if (filter.test(n)) { 64 | target = n; 65 | } 66 | } 67 | if (target == null) { 68 | throw new ASMException("Can't locate target instruction in " + mn.name, mn); 69 | } 70 | return target; 71 | } 72 | 73 | private byte[] transformItemStack(byte[] basicClass) { 74 | ClassReader cr = new ClassReader(basicClass); 75 | ClassNode cn = new ClassNode(); 76 | cr.accept(cn, 0); 77 | 78 | String enchantment = "net/minecraft/enchantment/Enchantment"; 79 | String nbtTagCompound = "net/minecraft/nbt/NBTTagCompound"; 80 | // Remove short cast 81 | MethodNode mn = locateMethod(cn, "(L" + enchantment + ";I)V", "addEnchantment", "func_77966_a"); 82 | mn.instructions.remove(locateTargetInsn(mn, n -> n.getOpcode() == Opcodes.I2S)); 83 | 84 | // Redirect setShort to setInt 85 | AbstractInsnNode target2 = locateTargetInsn(mn, n -> n.getOpcode() == Opcodes.INVOKEVIRTUAL && n.getPrevious().getPrevious().getPrevious().getOpcode() == Opcodes.LDC && ((LdcInsnNode) n.getPrevious().getPrevious().getPrevious()).cst.toString().equals("id")); 86 | mn.instructions.insertBefore(target2, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, nbtTagCompound, (JEIDLoadingPlugin.isDeobf ? "setInteger" : "func_74768_a"), "(Ljava/lang/String;I)V", false)); 87 | mn.instructions.remove(target2); 88 | 89 | // Redirect getShort to getInt 90 | if (FMLLaunchHandler.side().isClient()) { 91 | MethodNode mn2 = locateMethod(cn, "(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/client/util/ITooltipFlag;)Ljava/util/List;", "getTooltip", "func_82840_a"); 92 | AbstractInsnNode target = locateTargetInsn(mn2, n -> n.getOpcode() == Opcodes.INVOKEVIRTUAL && n.getPrevious().getOpcode() == Opcodes.LDC && ((LdcInsnNode) n.getPrevious()).cst.toString().equals("id")); 93 | mn.instructions.insertBefore(target, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, nbtTagCompound, (JEIDLoadingPlugin.isDeobf ? "getInteger" : "func_74762_e"), "(Ljava/lang/String;)I", false)); 94 | mn.instructions.remove(target); 95 | } 96 | 97 | ClassWriter cw = new ClassWriter(0); 98 | cn.accept(cw); 99 | return cw.toByteArray(); 100 | } 101 | 102 | private byte[] transformPotionEffect(byte[] basicClass) { 103 | ClassReader cr = new ClassReader(basicClass); 104 | ClassNode cn = new ClassNode(); 105 | cr.accept(cn, 0); 106 | 107 | String nbtTagCompound = "net/minecraft/nbt/NBTTagCompound"; 108 | String potionEffect = "net/minecraft/potion/PotionEffect"; 109 | MethodNode mn = locateMethod(cn, "(L" + nbtTagCompound + ";)L" + nbtTagCompound + ";", "writeCustomPotionEffectToNBT", "func_82719_a"); 110 | AbstractInsnNode ant = locateTargetInsn(mn, n -> n.getOpcode() == Opcodes.I2B); 111 | MethodInsnNode call = new MethodInsnNode(Opcodes.INVOKEVIRTUAL, nbtTagCompound, (JEIDLoadingPlugin.isDeobf ? "setInteger" : "func_74768_a"), "(Ljava/lang/String;I)V", false); 112 | // Redirect setByte to setInteger 113 | mn.instructions.remove(ant.getNext()); 114 | mn.instructions.insert(ant, call); 115 | // Remove byte cast 116 | mn.instructions.remove(ant); 117 | 118 | MethodNode mn2 = locateMethod(cn, "(L" + nbtTagCompound + ";)L" + potionEffect + ";", "readCustomPotionEffectFromNBT", "func_82722_b"); 119 | AbstractInsnNode ant2 = locateTargetInsn(mn2, n -> n.getOpcode() == Opcodes.INVOKEVIRTUAL); 120 | // Remove bitwise operation 121 | mn2.instructions.remove(ant2.getNext()); 122 | mn2.instructions.remove(ant2.getNext()); 123 | // Redirect getByte to getInteger 124 | mn2.instructions.insert(ant2, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, nbtTagCompound, (JEIDLoadingPlugin.isDeobf ? "getInteger" : "func_74762_e"), "(Ljava/lang/String;)I", false)); 125 | mn2.instructions.remove(ant2); 126 | 127 | ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); 128 | cn.accept(cw); 129 | return cw.toByteArray(); 130 | } 131 | } 132 | 133 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/debug/DebugBase.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.debug; 2 | 3 | import net.minecraftforge.registries.IForgeRegistry; 4 | import net.minecraftforge.registries.IForgeRegistryEntry; 5 | 6 | public abstract class DebugBase> implements IDebugClass { 7 | private final int numInstances; 8 | protected IForgeRegistry registry; 9 | 10 | public DebugBase(int numInstances, IForgeRegistry registry) { 11 | this.numInstances = numInstances; 12 | this.registry = registry; 13 | } 14 | 15 | @Override 16 | public int getNumInstances() { 17 | return numInstances; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/debug/DebugBiome.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.debug; 2 | 3 | import net.minecraft.util.ResourceLocation; 4 | import net.minecraft.world.biome.Biome; 5 | import net.minecraftforge.registries.IForgeRegistry; 6 | import org.dimdev.jeid.JEID; 7 | import org.dimdev.jeid.config.ConfigHandler; 8 | 9 | public class DebugBiome extends DebugBase { 10 | public DebugBiome(int numInstances, IForgeRegistry registry) { 11 | super(numInstances, registry); 12 | } 13 | 14 | @Override 15 | public void makeInstance(int id) { 16 | Biome instance = new Biome(new Biome.BiomeProperties("Biome " + id)) { 17 | } 18 | .setRegistryName(new ResourceLocation(JEID.MODID, "biome_" + id)); 19 | registry.register(instance); 20 | } 21 | 22 | @Override 23 | public boolean shouldDebug() { 24 | return ConfigHandler.DEBUG.reidDebugBiomesToggle; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/debug/DebugBlock.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.debug; 2 | 3 | import net.minecraft.block.Block; 4 | import net.minecraft.block.material.Material; 5 | import net.minecraft.creativetab.CreativeTabs; 6 | import net.minecraft.item.Item; 7 | import net.minecraft.item.ItemBlock; 8 | import net.minecraft.util.ResourceLocation; 9 | import net.minecraftforge.fml.common.registry.GameRegistry; 10 | import net.minecraftforge.registries.IForgeRegistry; 11 | import org.dimdev.jeid.JEID; 12 | import org.dimdev.jeid.config.ConfigHandler; 13 | 14 | public class DebugBlock extends DebugBase { 15 | // For easy registration of ItemBlock 16 | private final IForgeRegistry itemRegistry; 17 | 18 | public DebugBlock(int numInstances, IForgeRegistry registry) { 19 | super(numInstances, registry); 20 | itemRegistry = GameRegistry.findRegistry(Item.class); 21 | } 22 | 23 | @Override 24 | public void makeInstance(int id) { 25 | ResourceLocation loc = new ResourceLocation(JEID.MODID, "block_" + id); 26 | Block instance = new Block(Material.GROUND) 27 | .setCreativeTab(CreativeTabs.BUILDING_BLOCKS) 28 | .setRegistryName(loc); 29 | registry.register(instance); 30 | itemRegistry.register(new ItemBlock(instance).setRegistryName(loc)); 31 | } 32 | 33 | @Override 34 | public boolean shouldDebug() { 35 | return ConfigHandler.DEBUG.reidDebugBlocksToggle; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/debug/DebugEnchant.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.debug; 2 | 3 | import net.minecraft.enchantment.Enchantment; 4 | import net.minecraft.enchantment.EnumEnchantmentType; 5 | import net.minecraft.inventory.EntityEquipmentSlot; 6 | import net.minecraft.util.ResourceLocation; 7 | import net.minecraftforge.registries.IForgeRegistry; 8 | import org.dimdev.jeid.JEID; 9 | import org.dimdev.jeid.config.ConfigHandler; 10 | 11 | public class DebugEnchant extends DebugBase { 12 | public DebugEnchant(int numInstances, IForgeRegistry registry) { 13 | super(numInstances, registry); 14 | } 15 | 16 | @Override 17 | public void makeInstance(int id) { 18 | Enchantment instance = new EnchantTest(id) 19 | .setRegistryName(new ResourceLocation(JEID.MODID, "enchant_" + id)); 20 | registry.register(instance); 21 | } 22 | 23 | @Override 24 | public boolean shouldDebug() { 25 | return ConfigHandler.DEBUG.reidDebugEnchantsToggle; 26 | } 27 | 28 | private static class EnchantTest extends Enchantment { 29 | 30 | public EnchantTest(int i) { 31 | super(Rarity.COMMON, EnumEnchantmentType.BOW, new EntityEquipmentSlot[EntityEquipmentSlot.CHEST.getIndex()]); 32 | this.setName("Test Enchantment #" + i); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/debug/DebugItem.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.debug; 2 | 3 | import net.minecraft.creativetab.CreativeTabs; 4 | import net.minecraft.item.Item; 5 | import net.minecraft.util.ResourceLocation; 6 | import net.minecraftforge.registries.IForgeRegistry; 7 | import org.dimdev.jeid.JEID; 8 | import org.dimdev.jeid.config.ConfigHandler; 9 | 10 | public class DebugItem extends DebugBase { 11 | public DebugItem(int numInstances, IForgeRegistry registry) { 12 | super(numInstances, registry); 13 | } 14 | 15 | @Override 16 | public void makeInstance(int id) { 17 | Item instance = new Item() 18 | .setCreativeTab(CreativeTabs.FOOD) 19 | .setRegistryName(new ResourceLocation(JEID.MODID, "item_" + id)); 20 | registry.register(instance); 21 | } 22 | 23 | @Override 24 | public boolean shouldDebug() { 25 | return ConfigHandler.DEBUG.reidDebugItemsToggle; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/debug/DebugPotion.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.debug; 2 | 3 | import net.minecraft.potion.Potion; 4 | import net.minecraft.potion.PotionEffect; 5 | import net.minecraft.potion.PotionType; 6 | import net.minecraft.util.ResourceLocation; 7 | import net.minecraftforge.fml.common.registry.GameRegistry; 8 | import net.minecraftforge.registries.IForgeRegistry; 9 | import org.dimdev.jeid.JEID; 10 | import org.dimdev.jeid.config.ConfigHandler; 11 | 12 | import java.util.Random; 13 | 14 | public class DebugPotion extends DebugBase { 15 | // For easy registration of PotionType 16 | private final IForgeRegistry typeRegistry; 17 | 18 | public DebugPotion(int numInstances, IForgeRegistry registry) { 19 | super(numInstances, registry); 20 | typeRegistry = GameRegistry.findRegistry(PotionType.class); 21 | } 22 | 23 | @Override 24 | public void makeInstance(int id) { 25 | Potion instance = new PotionTest(id) 26 | .setRegistryName(new ResourceLocation(JEID.MODID, "potion_" + id)); 27 | PotionType instanceType = new PotionType(new PotionEffect(instance, 2000, 0, false, true)) 28 | .setRegistryName(new ResourceLocation(JEID.MODID, "potiontype_" + id)); 29 | registry.register(instance); 30 | typeRegistry.register(instanceType); 31 | } 32 | 33 | @Override 34 | public boolean shouldDebug() { 35 | return ConfigHandler.DEBUG.reidDebugPotionsToggle; 36 | } 37 | 38 | private static class PotionTest extends Potion { 39 | 40 | private static final Random r = new Random(); 41 | private final String nm; 42 | 43 | protected PotionTest(int id) { 44 | super(false, 0xFFFFFF & r.nextInt(Integer.MAX_VALUE)); 45 | nm = "Test Potion #" + id; 46 | } 47 | 48 | @Override 49 | public String getName() { 50 | return nm; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/debug/IDebugClass.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.debug; 2 | 3 | /** 4 | * Interface to help register an arbitrary number of instances of a class 5 | * 6 | * @author jchung01 7 | */ 8 | public interface IDebugClass { 9 | /** 10 | * @return number of instances of this class to make and register 11 | */ 12 | int getNumInstances(); 13 | 14 | /** 15 | * Makes and registers an instance of the class. 16 | * 17 | * @param id id to append to the instance's name 18 | */ 19 | void makeInstance(int id); 20 | 21 | /** 22 | * @return true if instances of this class should be made for debugging, 23 | * false otherwise. 24 | */ 25 | boolean shouldDebug(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/debug/NumInstances.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.debug; 2 | 3 | import org.dimdev.jeid.config.ConfigHandler; 4 | 5 | /** 6 | * Enum to specify number of instances of each type to register. 7 | *

8 | * Edit values here to increase/decrease number of instances registered. 9 | */ 10 | public enum NumInstances { 11 | BIOME(ConfigHandler.DEBUG.reidDebugBiomesAmt), 12 | BLOCK(ConfigHandler.DEBUG.reidDebugBlocksAmt), 13 | ENCHANT(ConfigHandler.DEBUG.reidDebugEnchantsAmt), 14 | ITEM(ConfigHandler.DEBUG.reidDebugItemsAmt), 15 | POTION(ConfigHandler.DEBUG.reidDebugPotionsAmt); 16 | 17 | public final int value; 18 | 19 | NumInstances(int val) { 20 | this.value = val; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/debug/RegistryDebug.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.debug; 2 | 3 | import net.minecraft.block.Block; 4 | import net.minecraft.enchantment.Enchantment; 5 | import net.minecraft.item.Item; 6 | import net.minecraft.potion.Potion; 7 | import net.minecraft.world.biome.Biome; 8 | import net.minecraftforge.event.RegistryEvent; 9 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 10 | 11 | public class RegistryDebug { 12 | @SubscribeEvent 13 | public void registerBlocks(RegistryEvent.Register event) { 14 | IDebugClass debugBlocks = new DebugBlock(NumInstances.BLOCK.value, event.getRegistry()); 15 | if (debugBlocks.shouldDebug()) makeAllInstances(debugBlocks); 16 | } 17 | 18 | @SubscribeEvent 19 | public void registerItems(RegistryEvent.Register event) { 20 | IDebugClass debugItems = new DebugItem(NumInstances.ITEM.value, event.getRegistry()); 21 | if (debugItems.shouldDebug()) makeAllInstances(debugItems); 22 | } 23 | 24 | @SubscribeEvent 25 | public void registerBiomes(RegistryEvent.Register event) { 26 | IDebugClass debugBiomes = new DebugBiome(NumInstances.BIOME.value, event.getRegistry()); 27 | if (debugBiomes.shouldDebug()) makeAllInstances(debugBiomes); 28 | } 29 | 30 | @SubscribeEvent 31 | public void registerPotions(RegistryEvent.Register event) { 32 | IDebugClass debugPotions = new DebugPotion(NumInstances.POTION.value, event.getRegistry()); 33 | if (debugPotions.shouldDebug()) makeAllInstances(debugPotions); 34 | } 35 | 36 | @SubscribeEvent 37 | public void registerEnchants(RegistryEvent.Register event) { 38 | IDebugClass debugEnchants = new DebugEnchant(NumInstances.ENCHANT.value, event.getRegistry()); 39 | if (debugEnchants.shouldDebug()) makeAllInstances(debugEnchants); 40 | } 41 | 42 | private void makeAllInstances(IDebugClass debugClass) { 43 | for (int i = 0; i < debugClass.getNumInstances(); ++i) { 44 | debugClass.makeInstance(i); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/ducks/ICustomBiomesForGeneration.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.ducks; 2 | 3 | import net.minecraft.world.biome.Biome; 4 | 5 | /** 6 | * Duck interface for mixins into certain mods with custom chunk generators. 7 | * If your mod uses a custom chunk generator and modifies the biome array returned by: 8 | *

{@code this.world.getBiomeProvider().getBiomes(...)},

9 | * implement this in your IChunkGenerator. 10 | */ 11 | public interface ICustomBiomesForGeneration { 12 | /** 13 | * Returns the modified biome array (usually called {@code biomesForGeneration}). 14 | * 15 | * @return the modified biome array 16 | */ 17 | Biome[] getBiomesForGeneration(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/ducks/IModSupportsJEID.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.ducks; 2 | 3 | /** 4 | * Duck interface for any mod that already sets up the Chunk's intBiomeArray 5 | * in {@link net.minecraft.world.gen.IChunkGenerator#generateChunk}. 6 | * If your mod uses a custom chunk generator and has explicit compat with JEID, 7 | * implement this in your IChunkGenerator. 8 | */ 9 | public interface IModSupportsJEID { 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/ducks/INewBlockStateContainer.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.ducks; 2 | 3 | import net.minecraft.world.chunk.NibbleArray; 4 | 5 | /** 6 | * Duck interface for BlockStateContainer mixin. 7 | */ 8 | public interface INewBlockStateContainer { 9 | void setTemporaryPalette(int[] temporaryPalette); 10 | int[] getTemporaryPalette(); 11 | void setLegacyAdd2(NibbleArray add2); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/ducks/INewChunk.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.ducks; 2 | 3 | /** 4 | * Duck interface for Chunk mixins. 5 | */ 6 | public interface INewChunk { 7 | int[] getIntBiomeArray(); 8 | void setIntBiomeArray(int[] intBiomeArray); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/ducks/IStoredEffectInt.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.ducks; 2 | 3 | /** 4 | * Duck interface for SPacketEntityEffect mixin. 5 | */ 6 | public interface IStoredEffectInt { 7 | int getEffectInt(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/ducks/modsupport/advancedrocketry/IStoredBiomeArray.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.ducks.modsupport.advancedrocketry; 2 | 3 | public interface IStoredBiomeArray { 4 | int[] getBiomeArray(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/ducks/modsupport/cubicchunks/INewCube.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.ducks.modsupport.cubicchunks; 2 | 3 | public interface INewCube { 4 | int[] getBiomeArray(); 5 | void setBiomeArray(int[] biomeArray); 6 | } -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/enchant/MixinEnchantmentHelper.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.enchant; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.enchantment.Enchantment; 5 | import net.minecraft.enchantment.EnchantmentHelper; 6 | import net.minecraft.nbt.NBTTagCompound; 7 | import net.minecraft.nbt.NBTTagList; 8 | import org.dimdev.jeid.JEID; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.ModifyArg; 12 | import org.spongepowered.asm.mixin.injection.ModifyVariable; 13 | import org.spongepowered.asm.mixin.injection.Redirect; 14 | 15 | @Mixin(EnchantmentHelper.class) 16 | public class MixinEnchantmentHelper { 17 | @ModifyArg(method = "getEnchantmentLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/Enchantment;getEnchantmentByID(I)Lnet/minecraft/enchantment/Enchantment;")) 18 | private static int reid$getIntEnchIdForLevel(int original, @Local NBTTagCompound nbtTagCompound) { 19 | return nbtTagCompound.getInteger("id"); 20 | } 21 | 22 | @ModifyArg(method = "getEnchantments", at = @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/Enchantment;getEnchantmentByID(I)Lnet/minecraft/enchantment/Enchantment;")) 23 | private static int reid$getIntEnchIdForMap(int id, @Local NBTTagCompound nbtTagCompound) { 24 | return nbtTagCompound.getInteger("id"); 25 | } 26 | 27 | @Redirect(method = "setEnchantments", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setShort(Ljava/lang/String;S)V", ordinal = 0)) 28 | private static void reid$setIntEnchId(NBTTagCompound instance, String key, short value, @Local Enchantment enchant, @Local NBTTagCompound nbtTagCompound) { 29 | if (!key.equals("id")) throw new AssertionError(JEID.MODID + " :: Ordinal 0 of setEnchantments isn't \"id\""); 30 | nbtTagCompound.setInteger("id", Enchantment.getEnchantmentID(enchant)); 31 | } 32 | 33 | @ModifyVariable(method = "applyEnchantmentModifier", at = @At(value = "STORE"), ordinal = 1) 34 | private static int reid$getIntEnchIdForModifier(int id, @Local NBTTagList nbtTagList, @Local(ordinal = 0) int index) { 35 | // Ints on LVT: (ordinal = 0) = int i, (ordinal = 1) = int j 36 | return nbtTagList.getCompoundTagAt(index).getInteger("id"); 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/enchant/MixinItemEnchantedBook.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.enchant; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.enchantment.Enchantment; 5 | import net.minecraft.enchantment.EnchantmentData; 6 | import net.minecraft.item.ItemEnchantedBook; 7 | import net.minecraft.nbt.NBTBase; 8 | import net.minecraft.nbt.NBTTagCompound; 9 | import org.dimdev.jeid.JEID; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.ModifyArg; 13 | 14 | @Mixin(ItemEnchantedBook.class) 15 | public class MixinItemEnchantedBook { 16 | @ModifyArg(method = "addEnchantment", at = @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/Enchantment;getEnchantmentByID(I)Lnet/minecraft/enchantment/Enchantment;")) 17 | private static int reid$getIntEnchIdForAdd(int original, @Local(ordinal = 0) NBTTagCompound nbtTagCompound) { 18 | return nbtTagCompound.getInteger("id"); 19 | } 20 | 21 | // LVT gets modified by above mixin, let's just remove the short, add the int id 22 | @ModifyArg(method = "addEnchantment", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagList;appendTag(Lnet/minecraft/nbt/NBTBase;)V", ordinal = 0)) 23 | private static NBTBase reid$setIntEnchIdForAdd(NBTBase nbt, @Local(argsOnly = true) EnchantmentData data) { 24 | if (!(nbt instanceof NBTTagCompound)) { 25 | throw new AssertionError(JEID.MODID + " :: NBTTagList#appendTag argument of addEnchantment isn't \"NBTTagCompound\""); 26 | } 27 | NBTTagCompound nbtTagCompound = (NBTTagCompound) nbt; 28 | nbtTagCompound.removeTag("id"); 29 | nbtTagCompound.setInteger("id", Enchantment.getEnchantmentID(data.enchantment)); 30 | return nbtTagCompound; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/enchant/client/MixinItemEnchantedBook.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.enchant.client; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.item.ItemEnchantedBook; 5 | import net.minecraft.nbt.NBTTagCompound; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.ModifyArg; 9 | 10 | @Mixin(value = ItemEnchantedBook.class) 11 | public class MixinItemEnchantedBook { 12 | @ModifyArg(method = "addInformation", at = @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/Enchantment;getEnchantmentByID(I)Lnet/minecraft/enchantment/Enchantment;")) 13 | private int reid$getIntEnchIdForInfo(int original, @Local NBTTagCompound nbtTagCompound) { 14 | return nbtTagCompound.getInteger("id"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/misc/MixinBlock.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.misc; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.block.Block; 5 | import net.minecraft.block.state.IBlockState; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Shadow; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.ModifyArg; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | 13 | @Mixin(Block.class) 14 | public class MixinBlock { 15 | @Shadow 16 | public static int getIdFromBlock(Block blockIn) { 17 | return 0; 18 | } 19 | 20 | /** 21 | * @reason Use JustEnoughIDs ID format (id, meta rather than meta, id) for 22 | * blocks with an ID larger than 4096. 23 | **/ 24 | // @ModifyReturnValue doesn't seem to work here 25 | @Inject(method = "getStateId", at = @At(value = "RETURN"), cancellable = true) 26 | private static void reid$getJEIDStateId(IBlockState state, CallbackInfoReturnable cir, @Local Block block) { 27 | // Block block = state.getBlock(); 28 | int id = getIdFromBlock(block); 29 | int meta = block.getMetaFromState(state); 30 | if ((id & 0xfffff000) == 0) { 31 | // Use vanilla 4 bit meta + 12 bit ID 32 | return; 33 | } 34 | // Use JEID 28 bit ID + 4 bit meta 35 | cir.setReturnValue((id << 4) + meta); 36 | } 37 | 38 | /** 39 | * @reason Use JustEnoughIDs ID format (id, meta rather than meta, id) for blocks with 40 | * an ID larger than 4096 stored in JEID format (state ID is larger than 65536) 41 | */ 42 | @ModifyArg(method = "getStateById", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getBlockById(I)Lnet/minecraft/block/Block;"), index = 0) 43 | private static int reid$useJEIDId(int vanillaId, @Local(ordinal = 0, argsOnly = true) int stateId) { 44 | if ((stateId & 0xffff0000) == 0) { 45 | return vanillaId; 46 | } else { 47 | return stateId >> 4; 48 | } 49 | } 50 | 51 | /** 52 | * @reason See {@link #reid$useJEIDId} 53 | */ 54 | @ModifyArg(method = "getStateById", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getStateFromMeta(I)Lnet/minecraft/block/state/IBlockState;"), index = 0) 55 | private static int reid$useJEIDMeta(int vanillaMeta, @Local(ordinal = 0, argsOnly = true) int stateId) { 56 | if ((stateId & 0xffff0000) == 0) { 57 | return vanillaMeta; 58 | } else { 59 | return stateId & 0xF; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/misc/MixinGameData.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.misc; 2 | 3 | import net.minecraftforge.registries.GameData; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | /** 9 | * Removes ID limits from forge registries. These are @ModifyConstants since javac 10 | * automatically inlines all static final fields that are constant expressions 11 | * (https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.28) 12 | */ 13 | @Mixin(value = GameData.class, priority = 500) 14 | public abstract class MixinGameData { 15 | /** 16 | * @reason Removes the block ID limit. 17 | */ 18 | @ModifyConstant(method = "init", constant = @Constant(intValue = 4095, ordinal = 0), remap = false) 19 | private static int reid$getBlockIDLimit(int value) { 20 | return Integer.MAX_VALUE - 1; 21 | } 22 | 23 | /** 24 | * @reason Removes the item ID limit. 25 | */ 26 | @ModifyConstant(method = "init", constant = @Constant(intValue = 31999, ordinal = 0), remap = false) 27 | private static int reid$getItemIDLimit(int value) { 28 | return Integer.MAX_VALUE - 1; 29 | } 30 | 31 | /** 32 | * @reason Removes the potion ID limit. 33 | */ 34 | @ModifyConstant(method = "init", constant = @Constant(intValue = 255, ordinal = 0), remap = false) 35 | private static int reid$getPotionIDLimit(int value) { 36 | return Integer.MAX_VALUE - 1; 37 | } 38 | 39 | /** 40 | * @reason Removes the biome ID limit. 41 | */ 42 | @ModifyConstant(method = "init", constant = @Constant(intValue = 255, ordinal = 1), remap = false) 43 | private static int reid$getBiomeIDLimit(int value) { 44 | return Integer.MAX_VALUE - 1; 45 | } 46 | 47 | /** 48 | * @reason Removes the enchantment ID limit. 49 | */ 50 | @ModifyConstant(method = "init", constant = @Constant(intValue = Short.MAX_VALUE - 1, ordinal = 0), remap = false) 51 | private static int reid$getEnchantmentIDLimit(int value) { 52 | return Integer.MAX_VALUE - 1; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/misc/client/MixinRenderGlobal.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.misc.client; 2 | 3 | import net.minecraft.block.Block; 4 | import net.minecraft.block.SoundType; 5 | import net.minecraft.block.material.Material; 6 | import net.minecraft.block.state.IBlockState; 7 | import net.minecraft.client.Minecraft; 8 | import net.minecraft.client.multiplayer.WorldClient; 9 | import net.minecraft.client.renderer.RenderGlobal; 10 | import net.minecraft.entity.player.EntityPlayer; 11 | import net.minecraft.util.SoundCategory; 12 | import net.minecraft.util.math.BlockPos; 13 | import org.spongepowered.asm.mixin.Final; 14 | import org.spongepowered.asm.mixin.Mixin; 15 | import org.spongepowered.asm.mixin.Shadow; 16 | import org.spongepowered.asm.mixin.injection.At; 17 | import org.spongepowered.asm.mixin.injection.Inject; 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 19 | 20 | @Mixin(RenderGlobal.class) 21 | public class MixinRenderGlobal { 22 | @Shadow 23 | @Final 24 | private Minecraft mc; 25 | @Shadow 26 | private WorldClient world; 27 | 28 | @Inject(method = "playEvent", at = @At("HEAD"), cancellable = true) 29 | private void reid$onPlayEvent(EntityPlayer player, int type, BlockPos blockPosIn, int data, CallbackInfo ci) { 30 | if (type == 2001) { 31 | IBlockState state = Block.getStateById(data); 32 | if (state.getMaterial() != Material.AIR) { 33 | SoundType soundtype = state.getBlock().getSoundType(Block.getStateById(data), world, blockPosIn, null); 34 | world.playSound(blockPosIn, soundtype.getBreakSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F, false); 35 | } 36 | mc.effectRenderer.addBlockDestroyEffects(blockPosIn, state); 37 | 38 | ci.cancel(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/network/MixinPacketBuffer.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.network; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.minecraft.network.PacketBuffer; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.Shadow; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.ModifyVariable; 9 | import org.spongepowered.asm.mixin.injection.Redirect; 10 | 11 | @Mixin(PacketBuffer.class) 12 | public abstract class MixinPacketBuffer { 13 | @Shadow 14 | public abstract int readVarInt(); 15 | 16 | @Shadow 17 | public abstract PacketBuffer writeVarInt(int input); 18 | 19 | @Redirect(method = "writeItemStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;", ordinal = 0)) 20 | private ByteBuf reid$writeIntItemId(PacketBuffer packetBuffer, int p_writeShort_1_) { 21 | return writeVarInt(p_writeShort_1_); 22 | } 23 | 24 | @Redirect(method = "writeItemStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;", ordinal = 1)) 25 | private ByteBuf reid$writeIntItemId1(PacketBuffer packetBuffer, int p_writeShort_1_) { 26 | return writeVarInt(p_writeShort_1_); 27 | } 28 | 29 | /** 30 | * @reason Disable default id read logic to prevent advancing readerIndex. 31 | */ 32 | @Redirect(method = "readItemStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;readShort()S", ordinal = 0)) 33 | private short reid$defaultReadId(PacketBuffer instance) { 34 | return 0; 35 | } 36 | 37 | @ModifyVariable(method = "readItemStack", at = @At(value = "STORE"), ordinal = 0) 38 | private int reid$readIntId(int original) { 39 | return readVarInt(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/network/MixinPacketUtil.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.network; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.minecraft.network.PacketBuffer; 5 | import net.minecraftforge.common.util.PacketUtil; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Redirect; 9 | 10 | @Mixin(PacketUtil.class) 11 | public abstract class MixinPacketUtil { 12 | @Redirect(method = "writeItemStackFromClientToServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;", ordinal = 0)) 13 | private static ByteBuf reid$writeIntItemId(PacketBuffer packetBuffer, int p_writeShort_1_) { 14 | return packetBuffer.writeVarInt(p_writeShort_1_); 15 | } 16 | 17 | @Redirect(method = "writeItemStackFromClientToServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;writeShort(I)Lio/netty/buffer/ByteBuf;", ordinal = 1)) 18 | private static ByteBuf reid$writeIntItemId1(PacketBuffer packetBuffer, int p_writeShort_1_) { 19 | return packetBuffer.writeVarInt(p_writeShort_1_); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/network/MixinSPacketChunkData.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.network; 2 | 3 | import com.llamalad7.mixinextras.injector.ModifyReturnValue; 4 | import net.minecraft.network.PacketBuffer; 5 | import net.minecraft.network.play.server.SPacketChunkData; 6 | import net.minecraft.world.chunk.Chunk; 7 | import org.dimdev.jeid.ducks.INewChunk; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | import org.spongepowered.asm.mixin.Unique; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.Redirect; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 15 | 16 | @Mixin(SPacketChunkData.class) 17 | public abstract class MixinSPacketChunkData { 18 | @Shadow 19 | public abstract boolean isFullChunk(); 20 | 21 | /** 22 | * @reason Write the biome int array. 23 | **/ 24 | @Inject(method = "extractChunkData", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/SPacketChunkData;isFullChunk()Z", ordinal = 1)) 25 | public void reid$writeBiomeArray(PacketBuffer buf, Chunk chunk, boolean writeSkylight, int changedSectionFilter, CallbackInfoReturnable cir) { 26 | if (isFullChunk()) { 27 | buf.writeVarIntArray(((INewChunk) chunk).getIntBiomeArray()); 28 | } 29 | } 30 | 31 | /** 32 | * @reason Disable writing biome byte array. 33 | **/ 34 | @Redirect(method = "extractChunkData", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/SPacketChunkData;isFullChunk()Z", ordinal = 1)) 35 | public boolean reid$getIsFullChunk(SPacketChunkData packet) { 36 | return false; 37 | } 38 | 39 | /** 40 | * @reason Disable adding biome byte array size. 41 | **/ 42 | @Redirect(method = "calculateChunkSize", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/SPacketChunkData;isFullChunk()Z", ordinal = 1)) 43 | public boolean reid$getIsFullChunk1(SPacketChunkData packet) { 44 | return false; 45 | } 46 | 47 | @ModifyReturnValue(method = "calculateChunkSize", at = @At(value = "RETURN")) 48 | public int reid$addIntBiomeArraySize(int originalSize, Chunk chunkIn) { 49 | if (isFullChunk()) { 50 | return originalSize + this.getVarIntArraySize(((INewChunk) chunkIn).getIntBiomeArray()); 51 | } 52 | return originalSize; 53 | } 54 | 55 | @Unique 56 | private int getVarIntArraySize(int[] array) { 57 | int size = PacketBuffer.getVarIntSize(array.length); 58 | for (int i : array) { 59 | size += PacketBuffer.getVarIntSize(i); 60 | } 61 | return size; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/network/client/MixinNetHandlerPlayClient.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.network.client; 2 | 3 | import net.minecraft.client.network.NetHandlerPlayClient; 4 | 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Constant; 8 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 9 | import org.spongepowered.asm.mixin.injection.Slice; 10 | 11 | @Mixin(value = NetHandlerPlayClient.class) 12 | public class MixinNetHandlerPlayClient { 13 | /** 14 | * @reason Account for JEID blockstate format (32 bits, not 16). 15 | */ 16 | @ModifyConstant(method = "handleSpawnObject", 17 | slice = @Slice( 18 | id = "fallingBlock", 19 | from = @At(value = "NEW", target = "(Lnet/minecraft/world/World;DDDLnet/minecraft/block/state/IBlockState;)Lnet/minecraft/entity/item/EntityFallingBlock;"), 20 | to = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getStateById(I)Lnet/minecraft/block/state/IBlockState;") 21 | ), constant = @Constant(intValue = 0xFFFF, slice = "fallingBlock")) 22 | private int reid$getJEIDBlockstate(int constant) { 23 | return 0xFFFFFFFF; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/potion/MixinSPacketEntityEffect.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.potion; 2 | 3 | import net.minecraft.network.PacketBuffer; 4 | import net.minecraft.network.play.server.SPacketEntityEffect; 5 | import net.minecraft.potion.Potion; 6 | import net.minecraft.potion.PotionEffect; 7 | import org.dimdev.jeid.ducks.IStoredEffectInt; 8 | import org.spongepowered.asm.mixin.Final; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.Unique; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | 15 | /** 16 | * Mixin to read/write effect ids as ints. Converted from JEIDTransformer#transformSPacketEntityEffect 17 | * 18 | * @see org.dimdev.jeid.core.JEIDTransformer 19 | */ 20 | @Mixin(value = SPacketEntityEffect.class) 21 | public class MixinSPacketEntityEffect implements IStoredEffectInt { 22 | @Unique 23 | private int reid$effectInt = 0; 24 | 25 | @Final 26 | @Inject(method = "(ILnet/minecraft/potion/PotionEffect;)V", at = @At(value = "RETURN")) 27 | private void reid$initEffectInt(int entityIdIn, PotionEffect effect, CallbackInfo ci) { 28 | reid$effectInt = Potion.getIdFromPotion(effect.getPotion()); 29 | } 30 | 31 | @Final 32 | @Inject(method = "readPacketData", at = @At(value = "TAIL")) 33 | private void reid$readEffectInt(PacketBuffer buf, CallbackInfo ci) { 34 | reid$effectInt = buf.readVarInt(); 35 | } 36 | 37 | @Final 38 | @Inject(method = "writePacketData", at = @At(value = "TAIL")) 39 | private void reid$writeEffectInt(PacketBuffer buf, CallbackInfo ci) { 40 | buf.writeVarInt(reid$effectInt); 41 | } 42 | 43 | @Override 44 | public int getEffectInt() { 45 | return reid$effectInt; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/potion/MixinSPacketRemoveEntityEffect.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.potion; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import io.netty.buffer.ByteBuf; 5 | import net.minecraft.network.PacketBuffer; 6 | import net.minecraft.network.play.server.SPacketRemoveEntityEffect; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.ModifyArg; 11 | import org.spongepowered.asm.mixin.injection.Redirect; 12 | 13 | /** 14 | * Mixin to read potion ids as ints. Converted from JEIDTransformer#transformSPacketRemoveEntityEffect 15 | * 16 | * @see org.dimdev.jeid.core.JEIDTransformer 17 | */ 18 | @Mixin(value = SPacketRemoveEntityEffect.class) 19 | public class MixinSPacketRemoveEntityEffect { 20 | /** 21 | * @reason Disable default id read logic to prevent advancing readerIndex. 22 | */ 23 | @Final 24 | @Redirect(method = "readPacketData", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;readUnsignedByte()S", ordinal = 0, remap = false)) 25 | private short reid$defaultReadId(PacketBuffer instance) 26 | { 27 | return 0; 28 | } 29 | 30 | @Final 31 | @ModifyArg(method = "readPacketData", at = @At(value = "INVOKE", target = "Lnet/minecraft/potion/Potion;getPotionById(I)Lnet/minecraft/potion/Potion;"), index = 0) 32 | private int reid$readIntPotionId(int original, @Local(argsOnly = true) PacketBuffer buf) { 33 | return buf.readInt(); 34 | } 35 | 36 | @Final 37 | @Redirect(method = "writePacketData", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;")) 38 | private ByteBuf reid$writeIntPotionId(PacketBuffer instance, int potionId) { 39 | return instance.writeInt(potionId); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/potion/client/MixinNetHandlerPlayClient.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.potion.client; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.client.network.NetHandlerPlayClient; 5 | import net.minecraft.network.play.server.SPacketEntityEffect; 6 | import org.dimdev.jeid.ducks.IStoredEffectInt; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.ModifyArg; 11 | 12 | /** 13 | * Mixin to read stored effect id as int. Converted from JEIDTransformer#transformNetHandlerPlayClient 14 | * 15 | * @see org.dimdev.jeid.core.JEIDTransformer 16 | */ 17 | @Mixin(value = NetHandlerPlayClient.class) 18 | public class MixinNetHandlerPlayClient { 19 | @Final 20 | @ModifyArg(method = "handleEntityEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/potion/Potion;getPotionById(I)Lnet/minecraft/potion/Potion;"), index = 0) 21 | private int reid$getIntEffectId(int potionID, @Local(argsOnly = true) SPacketEntityEffect packetIn) { 22 | return ((IStoredEffectInt) packetIn).getEffectInt(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/world/MixinAnvilChunkLoader.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.world; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.nbt.NBTTagCompound; 5 | import net.minecraft.world.World; 6 | import net.minecraft.world.chunk.Chunk; 7 | import net.minecraft.world.chunk.NibbleArray; 8 | import net.minecraft.world.chunk.storage.AnvilChunkLoader; 9 | import net.minecraft.world.chunk.storage.ExtendedBlockStorage; 10 | import org.dimdev.jeid.JEID; 11 | import org.dimdev.jeid.ducks.INewBlockStateContainer; 12 | import org.dimdev.jeid.ducks.INewChunk; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.Redirect; 17 | import org.spongepowered.asm.mixin.injection.Slice; 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 19 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 20 | 21 | @Mixin(AnvilChunkLoader.class) 22 | public class MixinAnvilChunkLoader { 23 | /** 24 | * @reason Read palette from NBT for JustEnoughIDs BlockStateContainers. 25 | */ 26 | @Inject(method = "readChunkFromNBT", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;getByteArray(Ljava/lang/String;)[B", ordinal = 0)) 27 | private void reid$readPaletteNBT(CallbackInfoReturnable cir, @Local(ordinal = 1) NBTTagCompound storageNBT, @Local ExtendedBlockStorage extendedBlockStorage) { 28 | int[] palette = storageNBT.hasKey("Palette", 11) ? storageNBT.getIntArray("Palette") : null; 29 | ((INewBlockStateContainer) extendedBlockStorage.getData()).setTemporaryPalette(palette); 30 | NibbleArray add2 = storageNBT.hasKey("Add2", 7) ? new NibbleArray(storageNBT.getByteArray("Add2")) : null; 31 | ((INewBlockStateContainer) extendedBlockStorage.getData()).setLegacyAdd2(add2); 32 | } 33 | 34 | /** 35 | * @reason Write palette to NBT for JustEnoughIDs BlockStateContainers. 36 | */ 37 | @Inject(method = "writeChunkToNBT", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/chunk/BlockStateContainer;getDataForNBT([BLnet/minecraft/world/chunk/NibbleArray;)Lnet/minecraft/world/chunk/NibbleArray;", ordinal = 0)) 38 | private void reid$writePaletteNBT(CallbackInfo ci, @Local ExtendedBlockStorage extendedBlockStorage, @Local(ordinal = 1) NBTTagCompound storageNBT) { 39 | int[] palette = ((INewBlockStateContainer) extendedBlockStorage.getData()).getTemporaryPalette(); 40 | if (palette != null) storageNBT.setIntArray("Palette", palette); 41 | } 42 | 43 | /** 44 | * @reason Read int biome array from NBT if it's there. 45 | */ 46 | @Inject(method = "readChunkFromNBT", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;hasKey(Ljava/lang/String;I)Z", ordinal = 1)) 47 | private void reid$readBiomeArray(World world, NBTTagCompound nbt, CallbackInfoReturnable cir, @Local Chunk chunk) { 48 | INewChunk newChunk = (INewChunk) chunk; 49 | if (nbt.hasKey("Biomes", 11)) { 50 | newChunk.setIntBiomeArray(nbt.getIntArray("Biomes")); 51 | } else { 52 | // Convert old chunks 53 | int[] intBiomeArray = new int[256]; 54 | int index = 0; 55 | for (byte b : nbt.getByteArray("Biomes")) { 56 | intBiomeArray[index++] = b & 0xFF; 57 | } 58 | newChunk.setIntBiomeArray(intBiomeArray); 59 | } 60 | } 61 | 62 | /** 63 | * @reason Save the correct biome array type 64 | */ 65 | @Redirect(method = "writeChunkToNBT", 66 | slice = @Slice( 67 | id = "nbtBiomes", 68 | from = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setTag(Ljava/lang/String;Lnet/minecraft/nbt/NBTBase;)V"), 69 | to = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;setHasEntities(Z)V") 70 | ), at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setByteArray(Ljava/lang/String;[B)V", ordinal = 0, slice = "nbtBiomes")) 71 | private void reid$writeBiomeArray(NBTTagCompound instance, String key, byte[] value, Chunk chunkIn) { 72 | if (!key.equals("Biomes")) { 73 | throw new AssertionError(JEID.MODID + " :: Sliced target setByteArray isn't \"Biomes\""); 74 | } 75 | instance.setIntArray(key, ((INewChunk) chunkIn).getIntBiomeArray()); 76 | } 77 | 78 | /** 79 | * @reason Disable default biome array save logic. 80 | */ 81 | @Redirect(method = "writeChunkToNBT", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B", ordinal = 0)) 82 | private byte[] reid$defaultWriteBiomeArray(Chunk chunk) { 83 | return new byte[0]; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/world/MixinBlockStateContainer.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.world; 2 | 3 | import it.unimi.dsi.fastutil.objects.Reference2IntMap; 4 | import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; 5 | import net.minecraft.block.Block; 6 | import net.minecraft.block.state.IBlockState; 7 | import net.minecraft.init.Blocks; 8 | import net.minecraft.world.chunk.BlockStateContainer; 9 | import net.minecraft.world.chunk.NibbleArray; 10 | import org.dimdev.jeid.ducks.INewBlockStateContainer; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Shadow; 13 | import org.spongepowered.asm.mixin.Unique; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 17 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 18 | 19 | @Mixin(BlockStateContainer.class) 20 | public abstract class MixinBlockStateContainer implements INewBlockStateContainer { 21 | @Unique 22 | private int[] temporaryPalette; // index -> state id 23 | @Unique 24 | private NibbleArray add2; // NEID format 25 | 26 | @Shadow 27 | protected abstract IBlockState get(int index); 28 | 29 | @Shadow 30 | protected abstract void set(int index, IBlockState state); 31 | 32 | @Override 33 | public int[] getTemporaryPalette() { 34 | return temporaryPalette; 35 | } 36 | 37 | @Override 38 | public void setTemporaryPalette(int[] temporaryPalette) { 39 | this.temporaryPalette = temporaryPalette; 40 | } 41 | 42 | @Override 43 | public void setLegacyAdd2(NibbleArray add2) { 44 | this.add2 = add2; 45 | } 46 | 47 | /** 48 | * @reason If this BlockStateContainer should be saved in JustEnoughIDs format, 49 | * store palette IDs rather than block IDs in the container's "Blocks" and 50 | * "Data" arrays. 51 | */ 52 | @SuppressWarnings("deprecation") 53 | @Inject(method = "getDataForNBT", at = @At("HEAD"), cancellable = true) 54 | private void reid$newGetDataForNBT(byte[] blockIds, NibbleArray data, CallbackInfoReturnable cir) { 55 | Reference2IntMap stateIDMap = new Reference2IntOpenHashMap<>(); 56 | int nextID = 0; 57 | for (int index = 0; index < 4096; ++index) { 58 | IBlockState state = get(index); 59 | int paletteID = stateIDMap.getOrDefault(state, -1); 60 | if (paletteID == -1) { 61 | paletteID = nextID; 62 | ++nextID; 63 | stateIDMap.put(state, paletteID); 64 | } 65 | 66 | int x = index & 15; 67 | int y = index >> 8 & 15; 68 | int z = index >> 4 & 15; 69 | 70 | blockIds[index] = (byte) (paletteID >> 4 & 255); 71 | data.set(x, y, z, paletteID & 15); 72 | } 73 | 74 | temporaryPalette = new int[nextID]; 75 | for (final Reference2IntMap.Entry entry : stateIDMap.reference2IntEntrySet()) { 76 | temporaryPalette[entry.getIntValue()] = Block.BLOCK_STATE_IDS.get(entry.getKey()); 77 | } 78 | 79 | cir.setReturnValue(null); 80 | cir.cancel(); 81 | } 82 | 83 | /** 84 | * @reason If this BlockStateContainer is saved in JustEnoughIDs format, treat 85 | * the "Blocks" and "Data" arrays as palette IDs. 86 | */ 87 | @SuppressWarnings("deprecation") 88 | @Inject(method = "setDataFromNBT", at = @At("HEAD"), cancellable = true) 89 | private void reid$newSetDataFromNBT(byte[] blockIds, NibbleArray data, NibbleArray blockIdExtension, CallbackInfo ci) { 90 | if (temporaryPalette == null) { // Read containers in palette format only if the container has a palette (has a palette) 91 | for (int index = 0; index < 4096; ++index) { 92 | int x = index & 15; 93 | int y = index >> 8 & 15; 94 | int z = index >> 4 & 15; 95 | int toAdd = (blockIdExtension == null) ? 0 : blockIdExtension.get(x, y, z); 96 | if (add2 != null) { 97 | toAdd = ((toAdd & 0xF) | add2.get(x, y, z) << 4); 98 | } 99 | final int id = toAdd << 12 | (blockIds[index] & 0xFF) << 4 | (data.get(x, y, z) & 0xF); 100 | IBlockState bs = (id == 0) ? Blocks.AIR.getDefaultState() : Block.BLOCK_STATE_IDS.getByValue(id); 101 | set(index, bs); 102 | } 103 | } else { 104 | for (int index = 0; index < 4096; ++index) { 105 | int x = index & 15; 106 | int y = index >> 8 & 15; 107 | int z = index >> 4 & 15; 108 | int paletteID = (blockIds[index] & 255) << 4 | data.get(x, y, z); 109 | 110 | set(index, Block.BLOCK_STATE_IDS.getByValue(temporaryPalette[paletteID])); 111 | } 112 | 113 | temporaryPalette = null; 114 | } 115 | ci.cancel(); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/world/MixinChunk.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.world; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.world.biome.Biome; 5 | import net.minecraft.world.chunk.Chunk; 6 | import org.dimdev.jeid.INewChunk; 7 | import org.dimdev.jeid.biome.BiomeError; 8 | import org.objectweb.asm.Opcodes; 9 | import org.spongepowered.asm.mixin.Dynamic; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.Unique; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Constant; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 16 | import org.spongepowered.asm.mixin.injection.ModifyVariable; 17 | import org.spongepowered.asm.mixin.injection.Redirect; 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 19 | 20 | import java.util.Arrays; 21 | 22 | @Mixin(Chunk.class) 23 | public class MixinChunk implements INewChunk { 24 | @Unique 25 | private static final byte ERROR_BIOME_ID = (byte) Biome.REGISTRY.getIDForObject(BiomeError.getInstance()); 26 | @Unique 27 | private static final byte[] EMPTY_BLOCK_BIOME_ARRAY = new byte[256]; 28 | @Unique 29 | private final int[] intBiomeArray = generateIntBiomeArray(); 30 | 31 | @Unique 32 | private static int[] generateIntBiomeArray() { 33 | int[] arr = new int[256]; 34 | Arrays.fill(arr, -1); 35 | return arr; 36 | } 37 | 38 | @Override 39 | public int[] getIntBiomeArray() { 40 | return intBiomeArray; 41 | } 42 | 43 | @Override 44 | public void setIntBiomeArray(int[] intBiomeArray) { 45 | System.arraycopy(intBiomeArray, 0, this.intBiomeArray, 0, this.intBiomeArray.length); 46 | } 47 | 48 | @Inject(method = "getBiomeArray", at = @At(value = "RETURN"), cancellable = true) 49 | private void reid$returnErrorBiomeArray(CallbackInfoReturnable cir) { 50 | byte[] arr = new byte[256]; 51 | Arrays.fill(arr, ERROR_BIOME_ID); 52 | cir.setReturnValue(arr); 53 | } 54 | 55 | @Dynamic("Read biome id from int biome array to int k") 56 | @ModifyVariable(method = "getBiome", at = @At(value = "STORE", ordinal = 0), name = "k") 57 | private int reid$fromIntBiomeArray(int original, @Local(name = "i") int i, @Local(name = "j") int j) { 58 | return this.intBiomeArray[j << 4 | i]; 59 | } 60 | 61 | /** 62 | * Compatibility for mods that don't initialize the chunk's biome array on generation (e.g. Chunk-Pregenerator) 63 | * 64 | * @reason Use intBiomeArray's default value. 65 | */ 66 | @ModifyConstant(method = "getBiome", constant = @Constant(intValue = 255, ordinal = 1)) 67 | private int reid$modifyDefaultId(int original) { 68 | return -1; 69 | } 70 | 71 | @Inject(method = "getBiome", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/biome/Biome;getIdForBiome(Lnet/minecraft/world/biome/Biome;)I")) 72 | private void reid$toIntBiomeArray(CallbackInfoReturnable cir, @Local(name = "i") int i, @Local(name = "j") int j, @Local(name = "k") int k) { 73 | this.intBiomeArray[j << 4 | i] = k; 74 | } 75 | 76 | /** 77 | * @reason Disable default biome array write logic. 78 | */ 79 | @Redirect(method = "getBiome", at = @At(value = "FIELD", target = "Lnet/minecraft/world/chunk/Chunk;blockBiomeArray:[B", opcode = Opcodes.GETFIELD, ordinal = 1)) 80 | private byte[] reid$defaultWriteBiomeArray(Chunk instance) { 81 | return EMPTY_BLOCK_BIOME_ARRAY; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/world/MixinChunkPrimer.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.world; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.block.Block; 5 | import net.minecraft.block.state.IBlockState; 6 | import net.minecraft.world.chunk.ChunkPrimer; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | import org.spongepowered.asm.mixin.Unique; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.ModifyArg; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | 15 | @Mixin(ChunkPrimer.class) 16 | public class MixinChunkPrimer { 17 | @Unique 18 | private final int[] intData = new int[65536]; 19 | 20 | @Shadow 21 | private static int getBlockIndex(int x, int y, int z) { 22 | return 0; 23 | } 24 | 25 | @ModifyArg(method = "getBlockState", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ObjectIntIdentityMap;getByValue(I)Ljava/lang/Object;")) 26 | private int reid$getIntDataForBlockState(int original, @Local(argsOnly = true, ordinal = 0) int x, @Local(argsOnly = true, ordinal = 1) int y, @Local(argsOnly = true, ordinal = 2) int z) { 27 | return intData[getBlockIndex(x, y, z)]; 28 | } 29 | 30 | @SuppressWarnings("deprecation") 31 | @Inject(method = "setBlockState", at = @At(value = "FIELD", target = "Lnet/minecraft/world/chunk/ChunkPrimer;data:[C"), cancellable = true) 32 | private void reid$setIntBlockState(int x, int y, int z, IBlockState state, CallbackInfo ci) { 33 | intData[getBlockIndex(x, y, z)] = Block.BLOCK_STATE_IDS.get(state); 34 | ci.cancel(); 35 | } 36 | 37 | @ModifyArg(method = "findGroundBlockIdx", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ObjectIntIdentityMap;getByValue(I)Ljava/lang/Object;")) 38 | private int reid$getIntDataForGroundBlock(int original, @Local(ordinal = 2) int i, @Local(ordinal = 3) int j) { 39 | return intData[i + j]; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/world/MixinChunkProviderServer.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.world; 2 | 3 | import net.minecraft.world.WorldServer; 4 | import net.minecraft.world.biome.Biome; 5 | import net.minecraft.world.chunk.Chunk; 6 | import net.minecraft.world.gen.ChunkProviderServer; 7 | import net.minecraft.world.gen.IChunkGenerator; 8 | 9 | import com.llamalad7.mixinextras.sugar.Local; 10 | import org.dimdev.jeid.ducks.ICustomBiomesForGeneration; 11 | import org.dimdev.jeid.ducks.IModSupportsJEID; 12 | import org.dimdev.jeid.ducks.INewChunk; 13 | import org.spongepowered.asm.mixin.Final; 14 | import org.spongepowered.asm.mixin.Mixin; 15 | import org.spongepowered.asm.mixin.Shadow; 16 | import org.spongepowered.asm.mixin.Unique; 17 | import org.spongepowered.asm.mixin.injection.At; 18 | import org.spongepowered.asm.mixin.injection.Inject; 19 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 20 | 21 | @Mixin(ChunkProviderServer.class) 22 | public class MixinChunkProviderServer { 23 | @Unique 24 | private final Biome[] reusableBiomeList = new Biome[256]; 25 | @Shadow 26 | @Final 27 | public IChunkGenerator chunkGenerator; 28 | @Shadow 29 | @Final 30 | public WorldServer world; 31 | 32 | /** 33 | * @reason Initialize biome array after any calls to {@link net.minecraft.world.gen.IChunkGenerator#generateChunk}. 34 | * This guarantees the correct biomes even for modded chunk generators. 35 | */ 36 | @Inject(method = "provideChunk", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/gen/IChunkGenerator;generateChunk(II)Lnet/minecraft/world/chunk/Chunk;")) 37 | private void reid$initializeBiomeArray(int x, int z, CallbackInfoReturnable cir, @Local Chunk chunk) { 38 | if (this.chunkGenerator instanceof IModSupportsJEID) { 39 | return; 40 | } 41 | Biome[] biomes; 42 | if (this.chunkGenerator instanceof ICustomBiomesForGeneration) { 43 | // Some chunk generators modify the biomes beyond those returned by the BiomeProvider. 44 | biomes = ((ICustomBiomesForGeneration) this.chunkGenerator).getBiomesForGeneration(); 45 | } 46 | else { 47 | biomes = world.getBiomeProvider().getBiomes(reusableBiomeList, x * 16, z * 16, 16, 16); 48 | } 49 | INewChunk newChunk = (INewChunk) chunk; 50 | int[] intBiomeArray = newChunk.getIntBiomeArray(); 51 | for (int i = 0; i < intBiomeArray.length; ++i) { 52 | intBiomeArray[i] = Biome.getIdForBiome(biomes[i]); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/world/MixinGenLayerVoronoiZoom.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.world; 2 | 3 | import net.minecraft.world.gen.layer.GenLayerVoronoiZoom; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(GenLayerVoronoiZoom.class) 9 | public abstract class MixinGenLayerVoronoiZoom { 10 | @ModifyConstant(method = "getInts", constant = @Constant(intValue = 255)) 11 | private int reid$getBitMask(int oldValue) { 12 | return 0xFFFFFFFF; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/world/MixinWorldInfo.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.world; 2 | 3 | import net.minecraft.world.storage.WorldInfo; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(WorldInfo.class) 9 | public class MixinWorldInfo { 10 | @ModifyConstant(method = "updateTagCompound", constant = @Constant(stringValue = "1.12.2", ordinal = 0)) 11 | private String reid$versionName(String currentValue) { 12 | return "1.13-JEID"; 13 | } 14 | 15 | @ModifyConstant(method = "updateTagCompound", constant = @Constant(intValue = 1343, ordinal = 0)) 16 | private int reid$versionId(int currentValue) { 17 | return Integer.MAX_VALUE / 2; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/world/client/MixinChunk.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.world.client; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.minecraft.network.PacketBuffer; 5 | import net.minecraft.world.chunk.Chunk; 6 | import org.dimdev.jeid.INewChunk; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Redirect; 10 | 11 | @Mixin(Chunk.class) 12 | public abstract class MixinChunk implements INewChunk { 13 | @Redirect(method = "read", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;readBytes([B)Lio/netty/buffer/ByteBuf;", ordinal = 2)) 14 | private ByteBuf reid$readBiomeByteArray(PacketBuffer buf, byte[] dst) { 15 | setIntBiomeArray(buf.readVarIntArray()); 16 | return buf; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/core/world/client/MixinWorldSummary.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.core.world.client; 2 | 3 | import net.minecraft.world.storage.WorldSummary; 4 | import org.spongepowered.asm.mixin.Final; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.Shadow; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 10 | 11 | @Mixin(WorldSummary.class) 12 | public class MixinWorldSummary { 13 | @Shadow 14 | @Final 15 | private int versionId; 16 | 17 | // @ModifyReturnValue doesn't seem to work here 18 | @Inject(method = "askToOpenWorld", at = @At(value = "RETURN"), cancellable = true) 19 | private void reid$checkVersionId(CallbackInfoReturnable cir) { 20 | cir.setReturnValue(cir.getReturnValue() && (versionId != Integer.MAX_VALUE / 2)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/abyssalcraft/MixinBiomeUtil.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.abyssalcraft; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import com.shinoow.abyssalcraft.common.util.BiomeUtil; 5 | import net.minecraft.util.math.BlockPos; 6 | import net.minecraft.world.World; 7 | import net.minecraft.world.chunk.Chunk; 8 | import org.dimdev.jeid.ducks.INewChunk; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Mixin(value = BiomeUtil.class, remap = false) 15 | public class MixinBiomeUtil { 16 | @Inject(method = "updateBiome(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;IZ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;setModified(Z)V", remap = true)) 17 | private static void reid$toIntBiomeArray(World worldIn, BlockPos pos, int b, boolean batched, CallbackInfo ci, @Local Chunk chunk) { 18 | // Method calls setModified(true), same as markDirty() 19 | ((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = b; 20 | // Method sends packet 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/advancedrocketry/MixinBiomeHandler.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.advancedrocketry; 2 | 3 | import net.minecraft.util.math.BlockPos; 4 | import net.minecraft.world.World; 5 | import net.minecraft.world.biome.Biome; 6 | import net.minecraft.world.chunk.Chunk; 7 | import org.dimdev.jeid.ducks.INewChunk; 8 | import org.spongepowered.asm.mixin.Dynamic; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Group; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; 15 | import zmaster587.advancedRocketry.util.BiomeHandler; 16 | 17 | @SuppressWarnings("target") 18 | @Mixin(value = BiomeHandler.class, remap = false) 19 | public class MixinBiomeHandler { 20 | // Do not use @Local sugar for these injectors, it doesn't handle invalid targets well! 21 | 22 | @Dynamic("Use int biome array for AR 1.7.0") 23 | @Group(name = "versionAgnosticAR", min = 1, max = 2) 24 | @Inject(method = "changeBiome(Lnet/minecraft/world/World;ILnet/minecraft/util/math/BlockPos;)V", at = @At(value = "INVOKE", target = "Lzmaster587/libVulpes/network/PacketHandler;sendToNearby(Lzmaster587/libVulpes/network/BasePacket;ILnet/minecraft/util/math/BlockPos;D)V"), locals = LocalCapture.CAPTURE_FAILHARD, require = 0) 25 | private static void reid$toIntBiomeArray1_7_0(World world, int biomeId, BlockPos pos, CallbackInfo ci, Chunk chunk) { 26 | ((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = biomeId; 27 | chunk.markDirty(); 28 | // Method sends packet 29 | } 30 | 31 | @Dynamic("Overload for AR 1.7.0") 32 | @Group(name = "versionAgnosticAR", min = 1, max = 2) 33 | @Inject(method = "changeBiome(Lnet/minecraft/world/World;ILnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;)V", at = @At(value = "HEAD"), cancellable = true, require = 0) 34 | private static void reid$toIntBiomeArray1_7_0Chunk(World world, int biomeId, Chunk chunk, BlockPos pos, CallbackInfo ci) { 35 | BiomeHandler.changeBiome(world, biomeId, pos); 36 | ci.cancel(); 37 | } 38 | 39 | @Dynamic("Use int biome array for AR 2.0.0") 40 | @Group(name = "versionAgnosticAR", min = 1, max = 2) 41 | @Inject(method = "changeBiome(Lnet/minecraft/world/World;Lnet/minecraft/world/biome/Biome;Lnet/minecraft/util/math/BlockPos;)V", at = @At(value = "INVOKE", target = "Lzmaster587/libVulpes/network/PacketHandler;sendToNearby(Lzmaster587/libVulpes/network/BasePacket;ILnet/minecraft/util/math/BlockPos;D)V"), locals = LocalCapture.CAPTURE_FAILHARD, require = 0) 42 | private static void reid$toIntBiomeArray2_0_0(World world, Biome biomeId, BlockPos pos, CallbackInfo ci, Chunk chunk) { 43 | ((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = Biome.getIdForBiome(biomeId); 44 | chunk.markDirty(); 45 | // Method sends packet 46 | } 47 | 48 | @Dynamic("Use int biome array for AR-Reworked (Fork by OberToffel)") 49 | @Group(name = "versionAgnosticAR", min = 1, max = 2) 50 | @Inject(method = "changeBiome(Lnet/minecraft/world/World;Lnet/minecraft/world/biome/Biome;Lnet/minecraft/util/math/BlockPos;Z)V", at = @At(value = "INVOKE", target = "sendToNearby(Lzmaster587/libVulpes/network/BasePacket;ILnet/minecraft/util/math/BlockPos;D)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD, require = 0) 51 | private static void reid$toIntBiomeArrayFork(World world, Biome biomeId, BlockPos pos, boolean regen_vegetation, CallbackInfo ci, Chunk chunk) { 52 | ((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = Biome.getIdForBiome(biomeId); 53 | chunk.markDirty(); 54 | // Method sends packet 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/advancedrocketry/MixinPacketBiomeIDChange.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.advancedrocketry; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.minecraft.world.chunk.Chunk; 5 | import org.dimdev.jeid.ducks.INewChunk; 6 | import org.dimdev.jeid.ducks.modsupport.advancedrocketry.IStoredBiomeArray; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | import org.spongepowered.asm.mixin.Unique; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | import zmaster587.advancedRocketry.network.PacketBiomeIDChange; 14 | 15 | @Mixin(value = PacketBiomeIDChange.class, remap = false) 16 | public class MixinPacketBiomeIDChange implements IStoredBiomeArray { 17 | @Shadow 18 | Chunk chunk; 19 | @Unique 20 | int[] reid$intArray; 21 | 22 | @Inject(method = "()V", at = @At("RETURN")) 23 | public void onConstructed(CallbackInfo ci) { 24 | reid$intArray = new int[256]; 25 | } 26 | 27 | @Inject(method = "write", at = @At(value = "INVOKE", target = "Lio/netty/buffer/ByteBuf;writeBytes([B)Lio/netty/buffer/ByteBuf;"), cancellable = true) 28 | private void reid$writeIntBiomeIds(ByteBuf out, CallbackInfo ci) { 29 | for (int biomeId : ((INewChunk) chunk).getIntBiomeArray()) { 30 | out.writeInt(biomeId); 31 | } 32 | ci.cancel(); 33 | } 34 | 35 | @Inject(method = "readClient", at = @At(value = "INVOKE", target = "Lio/netty/buffer/ByteBuf;readBytes([B)Lio/netty/buffer/ByteBuf;"), cancellable = true) 36 | private void reid$readIntBiomeIds(ByteBuf in, CallbackInfo ci) { 37 | for (int i = 0; i < 256; i++) { 38 | int biomeId = in.readInt(); 39 | reid$intArray[i] = biomeId; 40 | } 41 | ci.cancel(); 42 | } 43 | 44 | @Override 45 | public int[] getBiomeArray() { 46 | return reid$intArray; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/advancedrocketry/client/MixinPacketBiomeIDChange.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.advancedrocketry.client; 2 | 3 | import net.minecraft.world.chunk.Chunk; 4 | import org.dimdev.jeid.ducks.INewChunk; 5 | import org.dimdev.jeid.ducks.modsupport.advancedrocketry.IStoredBiomeArray; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Redirect; 9 | import zmaster587.advancedRocketry.network.PacketBiomeIDChange; 10 | 11 | @Mixin(value = PacketBiomeIDChange.class) 12 | public abstract class MixinPacketBiomeIDChange implements IStoredBiomeArray { 13 | @Redirect(method = "executeClient", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;setBiomeArray([B)V", remap = true), remap = false) 14 | private void reid$setIntBiomeIdsClient(Chunk chunk, byte[] biomeArray) { 15 | ((INewChunk) chunk).setIntBiomeArray(getBiomeArray()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/atum/MixinGenLayerAtumRiverMix.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.atum; 2 | 3 | import com.teammetallurgy.atum.world.gen.layer.GenLayerAtumRiverMix; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(value = GenLayerAtumRiverMix.class) 9 | public class MixinGenLayerAtumRiverMix 10 | { 11 | @ModifyConstant(method = "getInts", constant = @Constant(intValue = 255)) 12 | private int getBitMask(int oldValue) { 13 | return 0xFFFFFFFF; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/biomesoplenty/MixinBOPCommand.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.biomesoplenty; 2 | 3 | import biomesoplenty.common.command.BOPCommand; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(value = BOPCommand.class, remap = false) 9 | public abstract class MixinBOPCommand { 10 | @ModifyConstant(method = "teleportFoundBiome", constant = @Constant(intValue = 255)) 11 | private int reid$getMaxBiomeId(int oldValue) { 12 | return Integer.MAX_VALUE - 1; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/biomesoplenty/MixinModBiomes.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.biomesoplenty; 2 | 3 | import biomesoplenty.common.init.ModBiomes; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(value = ModBiomes.class, remap = false) 9 | public abstract class MixinModBiomes { 10 | @ModifyConstant(method = "getNextFreeBiomeId", constant = @Constant(intValue = 256)) 11 | private static int reid$getLoopUpperLimit(int oldValue) { 12 | return Integer.MAX_VALUE; 13 | } 14 | 15 | @ModifyConstant(method = "getNextFreeBiomeId", constant = @Constant(intValue = 255)) 16 | private static int reid$getMaxBiomeId(int oldValue) { 17 | return Integer.MAX_VALUE - 1; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/biomestaff/MixinBiomeStaffUtil.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.biomestaff; 2 | 3 | import net.minecraft.item.ItemStack; 4 | import net.minecraft.nbt.NBTTagCompound; 5 | import net.minecraft.world.biome.Biome; 6 | 7 | import net.minecraftforge.common.util.Constants; 8 | 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 13 | import p455w0rd.biomestaff.item.ItemBiomeStaff; 14 | import p455w0rd.biomestaff.util.BiomeStaffUtil; 15 | 16 | @Mixin(value = BiomeStaffUtil.class, remap = false) 17 | public class MixinBiomeStaffUtil { 18 | /** 19 | * @reason Rewrite to get int biome id from NBT. 20 | */ 21 | @SuppressWarnings("ConstantConditions") 22 | @Inject(method = "getBiomeFromStaff", at = @At(value = "HEAD"), cancellable = true) 23 | private static void reid$getIntBiome(ItemStack staff, CallbackInfoReturnable cir) { 24 | if (staff.hasTagCompound() && staff.getTagCompound().hasKey(ItemBiomeStaff.TAG_BIOME, Constants.NBT.TAG_INT)) { 25 | Biome biome = Biome.getBiome(staff.getTagCompound().getInteger(ItemBiomeStaff.TAG_BIOME)); 26 | cir.setReturnValue(biome); 27 | return; 28 | } 29 | cir.setReturnValue(null); 30 | } 31 | 32 | /** 33 | * @reason Rewrite to construct NBT based on int biome id. 34 | */ 35 | @Inject(method = "createTagForBiome", at = @At(value = "HEAD"), cancellable = true) 36 | private static void reid$createIntTag(Biome biome, CallbackInfoReturnable cir) { 37 | NBTTagCompound tag = new NBTTagCompound(); 38 | int biomeId = Biome.getIdForBiome(biome); 39 | tag.setInteger(ItemBiomeStaff.TAG_BIOME, biomeId); 40 | cir.setReturnValue(tag); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/biomestaff/MixinItemBiomeStaff.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.biomestaff; 2 | 3 | import net.minecraft.entity.player.EntityPlayer; 4 | import net.minecraft.entity.player.EntityPlayerMP; 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraft.nbt.NBTTagCompound; 7 | import net.minecraft.util.EnumActionResult; 8 | import net.minecraft.util.EnumFacing; 9 | import net.minecraft.util.EnumHand; 10 | import net.minecraft.util.math.BlockPos; 11 | import net.minecraft.world.World; 12 | import net.minecraft.world.chunk.Chunk; 13 | import net.minecraftforge.common.util.Constants; 14 | 15 | import com.llamalad7.mixinextras.sugar.Local; 16 | import org.dimdev.jeid.ducks.INewChunk; 17 | import org.dimdev.jeid.network.MessageManager; 18 | import org.spongepowered.asm.mixin.Mixin; 19 | import org.spongepowered.asm.mixin.injection.At; 20 | import org.spongepowered.asm.mixin.injection.Inject; 21 | import org.spongepowered.asm.mixin.injection.ModifyArg; 22 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 23 | import p455w0rd.biomestaff.init.ModNetworking; 24 | import p455w0rd.biomestaff.item.ItemBiomeStaff; 25 | import p455w0rd.biomestaff.network.PacketSyncBiomeStaff; 26 | 27 | @Mixin(value = ItemBiomeStaff.class) 28 | public class MixinItemBiomeStaff { 29 | @ModifyArg(method = "onItemRightClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;hasKey(Ljava/lang/String;I)Z"), index = 1) 30 | private int reid$checkIntNBTKey(int original) { 31 | return Constants.NBT.TAG_INT; 32 | } 33 | 34 | /** 35 | * @reason Rewrite sneak use logic to save int biome id. 36 | */ 37 | @Inject(method = "onItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunk(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/chunk/Chunk;", ordinal = 0), cancellable = true) 38 | private void reid$sneakUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ, CallbackInfoReturnable cir, 39 | @Local ItemStack heldStack, @Local NBTTagCompound tag) { 40 | Chunk chunk = world.getChunk(pos); 41 | int biomeId = ((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | (pos.getX() & 0xF)]; 42 | if (!tag.hasKey(ItemBiomeStaff.TAG_BIOME, Constants.NBT.TAG_INT) || tag.getInteger(ItemBiomeStaff.TAG_BIOME) != biomeId) { 43 | tag.setInteger(ItemBiomeStaff.TAG_BIOME, biomeId); 44 | heldStack.setTagCompound(tag); 45 | ModNetworking.getInstance().sendTo(new PacketSyncBiomeStaff(heldStack.getTagCompound()), (EntityPlayerMP)player); 46 | } 47 | cir.setReturnValue(EnumActionResult.SUCCESS); 48 | } 49 | 50 | /** 51 | * @reason Rewrite biome application logic to use int biome id. 52 | */ 53 | @Inject(method = "onItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;getByte(Ljava/lang/String;)B", ordinal = 1), cancellable = true) 54 | private void reid$applyBiome(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ, CallbackInfoReturnable cir, 55 | @Local ItemStack heldStack, @Local NBTTagCompound tag, @Local(ordinal = 1) int rad) { 56 | int toBiomeId = tag.getInteger(ItemBiomeStaff.TAG_BIOME); 57 | for(int ix = pos.getX() - rad; ix <= pos.getX() + rad; ++ix) { 58 | for(int iz = pos.getZ() - rad; iz <= pos.getZ() + rad; ++iz) { 59 | Chunk chunk = world.getChunk(new BlockPos(ix, pos.getY(), iz)); 60 | int[] biomeArray = ((INewChunk) chunk).getIntBiomeArray(); 61 | int biomeIdAtPos = biomeArray[(iz & 0xF) << 4 | (ix & 0xF)]; 62 | if (biomeIdAtPos != toBiomeId) { 63 | chunk.markDirty(); 64 | biomeArray[(iz & 0xF) << 4 | (ix & 0xF)] = toBiomeId; 65 | } 66 | } 67 | } 68 | MessageManager.sendClientsBiomeAreaChange(world, pos, rad, toBiomeId); 69 | cir.setReturnValue(EnumActionResult.SUCCESS); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/biometweaker/MixinBiomeColorMappings.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.biometweaker; 2 | 3 | import me.superckl.biometweaker.util.BiomeColorMappings; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(value = BiomeColorMappings.class, remap = false) 9 | public class MixinBiomeColorMappings { 10 | @ModifyConstant(method = "getColorForBiome", constant = @Constant(intValue = 0xFF)) 11 | private static int reid$getBitMask(int oldValue) { 12 | return 0xFFFFFFFF; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/biometweaker/MixinBiomeHelper.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.biometweaker; 2 | 3 | import me.superckl.biometweaker.util.BiomeHelper; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(value = BiomeHelper.class, remap = false) 9 | public class MixinBiomeHelper { 10 | @ModifyConstant(method = "getNextFreeBiomeId", constant = @Constant(intValue = 256)) 11 | private static int reid$getLoopUpperLimit(int oldValue) { 12 | return Integer.MAX_VALUE; 13 | } 14 | 15 | @ModifyConstant(method = "getNextFreeBiomeId", constant = @Constant(intValue = 255)) 16 | private static int reid$getMaxBiomeId(int oldValue) { 17 | return Integer.MAX_VALUE - 1; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/biometweaker/MixinCommandSetBiome.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.biometweaker; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import com.llamalad7.mixinextras.sugar.Share; 5 | import com.llamalad7.mixinextras.sugar.ref.LocalRef; 6 | import me.superckl.biometweaker.server.command.CommandSetBiome; 7 | import net.minecraft.command.ICommandSender; 8 | import net.minecraft.server.MinecraftServer; 9 | import net.minecraft.util.math.BlockPos; 10 | import net.minecraft.world.World; 11 | import net.minecraft.world.chunk.Chunk; 12 | import org.dimdev.jeid.JEIDLogger; 13 | import org.dimdev.jeid.ducks.INewChunk; 14 | import org.dimdev.jeid.network.MessageManager; 15 | import org.spongepowered.asm.mixin.Mixin; 16 | import org.spongepowered.asm.mixin.injection.At; 17 | import org.spongepowered.asm.mixin.injection.Inject; 18 | import org.spongepowered.asm.mixin.injection.Redirect; 19 | import org.spongepowered.asm.mixin.injection.Slice; 20 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 21 | 22 | import java.util.Arrays; 23 | 24 | @Mixin(CommandSetBiome.class) 25 | public class MixinCommandSetBiome { 26 | @Inject(method = "execute", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B")) 27 | private void reid$setBiomeArrayElement(MinecraftServer server, ICommandSender sender, String[] args, CallbackInfo ci, 28 | @Local BlockPos coord, @Local World world, @Local(ordinal = 0) int id, 29 | @Local(ordinal = 2) int x, @Local(ordinal = 3) int z, @Local Chunk chunk) { 30 | JEIDLogger.LOGGER.info("setting biome at {}, {}", x, z); 31 | // Method calls markDirty() 32 | ((INewChunk) chunk).getIntBiomeArray()[(z & 0xF) << 4 | x & 0xF] = id; 33 | } 34 | 35 | @Inject(method = "execute", 36 | slice = @Slice( 37 | from = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/BlockPos;getX()I", ordinal = 0), 38 | to = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/BlockPos;getX()I", ordinal = 2) 39 | ), 40 | at = @At(value = "INVOKE", target = "Lnet/minecraft/command/ICommandSender;sendMessage(Lnet/minecraft/util/text/ITextComponent;)V")) 41 | private void reid$sendBiomeAreaChange(MinecraftServer server, ICommandSender sender, String[] args, CallbackInfo ci, 42 | @Local BlockPos coord, @Local World world, @Local Integer radius, 43 | @Local(ordinal = 0) int id) { 44 | MessageManager.sendClientsBiomeAreaChange(world, coord, radius, id); 45 | } 46 | 47 | @Inject(method = "execute", at = @At(value = "INVOKE", target = "Ljava/util/Arrays;fill([BB)V", remap = false)) 48 | private void reid$initBiomeArray(CallbackInfo ci, @Local(ordinal = 0) int id, @Share("intBiomeArray") LocalRef intBiomeArray) { 49 | final int[] arr = new int[256]; 50 | Arrays.fill(arr, id); 51 | intBiomeArray.set(arr); 52 | } 53 | 54 | @Redirect(method = "execute", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;setBiomeArray([B)V")) 55 | private void reid$setBiomeArray(Chunk instance, byte[] biomeArray, 56 | @Local BlockPos coord, @Local World world, @Local(ordinal = 4) int chunkX, 57 | @Local(ordinal = 5) int chunkZ, @Share("intBiomeArray") LocalRef intBiomeArray) { 58 | // Method calls markDirty() 59 | int posX = chunkX << 4; 60 | int posZ = chunkZ << 4; 61 | ((INewChunk) world.getChunk(chunkX, chunkZ)).setIntBiomeArray(Arrays.copyOf(intBiomeArray.get(), intBiomeArray.get().length)); 62 | MessageManager.sendClientsBiomeChunkChange(world, new BlockPos(posX, coord.getY(), posZ), Arrays.copyOf(intBiomeArray.get(), intBiomeArray.get().length)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/bookshelf/MixinWorldUtils.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.bookshelf; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.darkhax.bookshelf.util.WorldUtils; 5 | import net.minecraft.util.math.BlockPos; 6 | import net.minecraft.world.World; 7 | import net.minecraft.world.biome.Biome; 8 | import net.minecraft.world.chunk.Chunk; 9 | import org.dimdev.jeid.ducks.INewChunk; 10 | import org.dimdev.jeid.network.MessageManager; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | import java.util.Arrays; 17 | 18 | @Mixin(value = WorldUtils.class, remap = false) 19 | public class MixinWorldUtils { 20 | @Inject(method = "setBiomes", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;markDirty()V", remap = true)) 21 | private static void reid$setBiomeArray(World world, BlockPos pos, Biome biome, CallbackInfo ci, @Local Chunk chunk) { 22 | final int[] biomeArray = ((INewChunk) chunk).getIntBiomeArray(); 23 | // Method calls getDirty() 24 | Arrays.fill(biomeArray, Biome.getIdForBiome(biome)); 25 | if (!world.isRemote) { 26 | MessageManager.sendClientsBiomeChunkChange(world, pos, Arrays.copyOf(biomeArray, biomeArray.length)); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/chunkpregenerator/MixinBiomeEntry.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.chunkpregenerator; 2 | 3 | import net.minecraft.world.biome.Biome; 4 | import net.minecraft.world.chunk.Chunk; 5 | 6 | import com.llamalad7.mixinextras.sugar.Local; 7 | import org.dimdev.jeid.ducks.INewChunk; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Unique; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Redirect; 12 | import pregenerator.impl.tracking.types.BaseWorldEntry; 13 | import pregenerator.impl.tracking.types.BiomeEntry; 14 | 15 | @Mixin(value = BiomeEntry.class, remap = false) 16 | public class MixinBiomeEntry { 17 | @Unique 18 | private static final byte[] SKIP_BIOME_ARRAY = new byte[0]; 19 | 20 | @Redirect(method = "getChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B", remap = true)) 21 | private static byte[] reid$countIntBiomes(Chunk instance, @Local BaseWorldEntry.Counter counter) { 22 | final int[] biomeArray = ((INewChunk) instance).getIntBiomeArray(); 23 | for (int id : biomeArray) { 24 | Biome biome = Biome.getBiome(id); 25 | if (biome != null) counter.add(biome); 26 | } 27 | // empty byte[], skips original biome counting 28 | return SKIP_BIOME_ARRAY; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/compactmachines/MixinChunkUtils.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.compactmachines; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.nbt.NBTTagCompound; 5 | import net.minecraft.world.World; 6 | import net.minecraft.world.chunk.Chunk; 7 | import net.minecraft.world.chunk.storage.ExtendedBlockStorage; 8 | import org.dave.compactmachines3.utility.ChunkUtils; 9 | import org.dimdev.jeid.JEID; 10 | import org.dimdev.jeid.ducks.INewBlockStateContainer; 11 | import org.dimdev.jeid.ducks.INewChunk; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.Redirect; 16 | import org.spongepowered.asm.mixin.injection.Slice; 17 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 18 | 19 | @Mixin(value = ChunkUtils.class, remap = false) 20 | public class MixinChunkUtils { 21 | @Inject(method = "writeChunkToNBT", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setByteArray(Ljava/lang/String;[B)V", ordinal = 0, remap = true)) 22 | private static void reid$setNBTPalette(CallbackInfoReturnable cir, @Local(ordinal = 1) NBTTagCompound nbtTagCompound, @Local ExtendedBlockStorage extendedBlockStorage) { 23 | int[] palette = ((INewBlockStateContainer) extendedBlockStorage.getData()).getTemporaryPalette(); 24 | nbtTagCompound.setIntArray("Palette", palette); 25 | } 26 | 27 | @Redirect(method = "writeChunkToNBT", 28 | slice = @Slice( 29 | from = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setTag(Ljava/lang/String;Lnet/minecraft/nbt/NBTBase;)V", ordinal = 0, remap = true), 30 | to = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;setHasEntities(Z)V", remap = true) 31 | ), 32 | at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;setByteArray(Ljava/lang/String;[B)V", remap = true) 33 | ) 34 | private static void reid$setNBTBiomeArray(NBTTagCompound instance, String key, byte[] value, Chunk chunkIn) { 35 | if (!key.equals("Biomes")) { 36 | throw new AssertionError(JEID.MODID + " :: NBTTagCompound#setByteArray key of writeChunkToNBT isn't \"Biomes\""); 37 | } 38 | instance.setIntArray(key, ((INewChunk) chunkIn).getIntBiomeArray()); 39 | } 40 | 41 | @Inject(method = "readChunkFromNBT", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;getByteArray(Ljava/lang/String;)[B", ordinal = 0, remap = true)) 42 | private static void reid$setTempPalette(CallbackInfoReturnable cir, @Local(ordinal = 1) NBTTagCompound nbtTagCompound, @Local ExtendedBlockStorage extendedBlockStorage) { 43 | int[] palette = nbtTagCompound.hasKey("Palette", 11) ? nbtTagCompound.getIntArray("Palette") : null; 44 | ((INewBlockStateContainer) extendedBlockStorage.getData()).setTemporaryPalette(palette); 45 | } 46 | 47 | @Redirect(method = "readChunkFromNBT", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;setBiomeArray([B)V", remap = true)) 48 | private static void reid$setBiomeArray(Chunk instance, byte[] original, World worldIn, NBTTagCompound compound) { 49 | ((INewChunk) instance).setIntBiomeArray(compound.getIntArray("Biomes")); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/creepingnether/MixinCorruptorAbstract.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.creepingnether; 2 | 3 | import com.cutievirus.creepingnether.entity.CorruptorAbstract; 4 | import com.llamalad7.mixinextras.sugar.Local; 5 | import net.minecraft.util.math.BlockPos; 6 | import net.minecraft.world.World; 7 | import net.minecraft.world.biome.Biome; 8 | import net.minecraft.world.chunk.Chunk; 9 | import org.dimdev.jeid.ducks.INewChunk; 10 | import org.dimdev.jeid.network.MessageManager; 11 | import org.objectweb.asm.Opcodes; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.Shadow; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.Redirect; 17 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 18 | 19 | @Mixin(value = CorruptorAbstract.class, remap = false) 20 | public abstract class MixinCorruptorAbstract { 21 | @Shadow 22 | public abstract Biome getBiome(); 23 | 24 | @Inject(method = "corruptBiome", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;isRemote:Z", opcode = Opcodes.GETFIELD, remap = true)) 25 | private void reid$toIntBiomeArray(World world, BlockPos pos, CallbackInfo ci, @Local Chunk chunk) { 26 | ((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 15) << 4 | pos.getX() & 15] = Biome.getIdForBiome(getBiome()); 27 | chunk.markDirty(); 28 | } 29 | 30 | @Redirect(method = "corruptBiome", at = @At(value = "INVOKE", target = "Lcom/cutievirus/creepingnether/entity/MessageCorruptBiome;sendMessage(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lcom/cutievirus/creepingnether/entity/CorruptorAbstract;)V")) 31 | private void reid$sendBiomeMessage(World world, BlockPos pos, CorruptorAbstract corruptor) { 32 | MessageManager.sendClientsBiomePosChange(world, pos, Biome.getIdForBiome(getBiome())); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/cubicchunks/MixinCube.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.cubicchunks; 2 | 3 | import io.github.opencubicchunks.cubicchunks.api.util.Coords; 4 | import io.github.opencubicchunks.cubicchunks.api.world.IColumn; 5 | import io.github.opencubicchunks.cubicchunks.core.CubicChunks; 6 | import io.github.opencubicchunks.cubicchunks.core.util.AddressTools; 7 | import io.github.opencubicchunks.cubicchunks.core.world.cube.Cube; 8 | import net.minecraft.util.math.BlockPos; 9 | import net.minecraft.world.World; 10 | import net.minecraft.world.biome.Biome; 11 | import net.minecraft.world.chunk.Chunk; 12 | import org.dimdev.jeid.biome.BiomeError; 13 | import org.dimdev.jeid.ducks.modsupport.cubicchunks.INewCube; 14 | import org.spongepowered.asm.mixin.Final; 15 | import org.spongepowered.asm.mixin.Implements; 16 | import org.spongepowered.asm.mixin.Interface; 17 | import org.spongepowered.asm.mixin.Mixin; 18 | import org.spongepowered.asm.mixin.Overwrite; 19 | import org.spongepowered.asm.mixin.Shadow; 20 | import org.spongepowered.asm.mixin.Unique; 21 | import org.spongepowered.asm.mixin.injection.At; 22 | import org.spongepowered.asm.mixin.injection.Inject; 23 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 24 | 25 | import javax.annotation.Nonnull; 26 | import javax.annotation.Nullable; 27 | import java.util.Arrays; 28 | 29 | @Mixin(value = Cube.class, remap = false) 30 | @Implements(@Interface(iface = INewCube.class, prefix = "int$")) 31 | public abstract class MixinCube { 32 | @Shadow 33 | @Final 34 | private World world; 35 | @Unique 36 | private static final byte ERROR_BIOME_ID = (byte) Biome.REGISTRY.getIDForObject(BiomeError.getInstance()); 37 | @Unique 38 | @Nullable 39 | private int[] intBiomeArray; 40 | 41 | @SuppressWarnings("deprecation") 42 | @Shadow 43 | public abstract T getColumn(); 44 | 45 | /** 46 | * @author Exsolutus 47 | * @reason Support int biome ids 48 | */ 49 | @Overwrite 50 | public Biome getBiome(BlockPos pos) { 51 | if (this.intBiomeArray == null) { 52 | return this.getColumn().getBiome(pos, world.getBiomeProvider()); 53 | } 54 | int biomeX = Coords.blockToLocalBiome3d(pos.getX()); 55 | int biomeY = Coords.blockToLocalBiome3d(pos.getY()); 56 | int biomeZ = Coords.blockToLocalBiome3d(pos.getZ()); 57 | int biomeId = this.intBiomeArray[AddressTools.getBiomeAddress3d(biomeX, biomeY, biomeZ)]; 58 | return Biome.getBiome(biomeId); 59 | } 60 | 61 | @Inject(method = "getBiomeArray", at = @At(value = "RETURN"), cancellable = true) 62 | private void reid$returnErrorBiomeArray(CallbackInfoReturnable cir) { 63 | byte[] arr = new byte[256]; 64 | Arrays.fill(arr, ERROR_BIOME_ID); 65 | cir.setReturnValue(arr); 66 | } 67 | 68 | /** 69 | * @author Exsolutus 70 | * @reason Support int biome ids 71 | */ 72 | @Overwrite 73 | public void setBiome(int localBiomeX, int localBiomeY, int localBiomeZ, Biome biome) { 74 | if (this.intBiomeArray == null) 75 | this.intBiomeArray = new int[64]; 76 | 77 | this.intBiomeArray[AddressTools.getBiomeAddress3d(localBiomeX, localBiomeY, localBiomeZ)] = Biome.REGISTRY.getIDForObject(biome); 78 | } 79 | 80 | @Nullable 81 | public int[] int$getBiomeArray() { 82 | return this.intBiomeArray; 83 | } 84 | 85 | public void int$setBiomeArray(int[] biomeArray) { 86 | if (this.intBiomeArray == null) 87 | this.intBiomeArray = biomeArray; 88 | 89 | if (this.intBiomeArray.length != biomeArray.length) { 90 | CubicChunks.LOGGER.warn("Could not set level cube biomes, array length is {} instead of {}", biomeArray.length, this.intBiomeArray.length); 91 | } else { 92 | System.arraycopy(biomeArray, 0, this.intBiomeArray, 0, this.intBiomeArray.length); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/cubicchunks/MixinCubePrimer.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.cubicchunks; 2 | 3 | import io.github.opencubicchunks.cubicchunks.api.worldgen.CubePrimer; 4 | import net.minecraft.block.Block; 5 | import net.minecraft.block.state.IBlockState; 6 | import org.spongepowered.asm.mixin.Final; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Overwrite; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | import org.spongepowered.asm.mixin.Unique; 11 | 12 | import javax.annotation.Nonnull; 13 | 14 | @Mixin(value = CubePrimer.class, remap = false) 15 | @SuppressWarnings("deprecation") 16 | public class MixinCubePrimer { 17 | @Shadow 18 | @Final 19 | public static IBlockState DEFAULT_STATE; 20 | @Shadow 21 | @Final 22 | private char[] data; 23 | @Unique 24 | private char[] extIntData = null; 25 | 26 | @Shadow 27 | private static int getBlockIndex(int x, int y, int z) { 28 | return 0; 29 | } 30 | 31 | /** 32 | * @author Exsolutus 33 | * @reason Support int biome ids 34 | */ 35 | @Overwrite 36 | public IBlockState getBlockState(int x, int y, int z) { 37 | int idx = getBlockIndex(x, y, z); 38 | int block = this.data[idx]; 39 | if (extIntData != null) { 40 | block |= extIntData[idx] << 16; 41 | } 42 | IBlockState iblockstate = Block.BLOCK_STATE_IDS.getByValue(block); 43 | return iblockstate == null ? DEFAULT_STATE : iblockstate; 44 | } 45 | 46 | /** 47 | * @author Exsolutus 48 | * @reason Support int biome ids 49 | */ 50 | @Overwrite 51 | public void setBlockState(int x, int y, int z, @Nonnull IBlockState state) { 52 | int value = Block.BLOCK_STATE_IDS.get(state); 53 | char lsb = (char) value; 54 | int idx = getBlockIndex(x, y, z); 55 | this.data[idx] = lsb; 56 | if (value > 0xFFFF) { 57 | if (extIntData == null) { 58 | extIntData = new char[4096]; 59 | } 60 | extIntData[idx] = (char) (value >>> 16); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/cubicchunks/MixinIONbtReader.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.cubicchunks; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import io.github.opencubicchunks.cubicchunks.core.server.chunkio.IONbtReader; 5 | import io.github.opencubicchunks.cubicchunks.core.util.AddressTools; 6 | import io.github.opencubicchunks.cubicchunks.core.world.cube.Cube; 7 | import net.minecraft.nbt.NBTTagCompound; 8 | import net.minecraft.world.World; 9 | import net.minecraft.world.chunk.Chunk; 10 | import net.minecraft.world.chunk.NibbleArray; 11 | import net.minecraft.world.chunk.storage.ExtendedBlockStorage; 12 | import org.dimdev.jeid.ducks.INewBlockStateContainer; 13 | import org.dimdev.jeid.ducks.INewChunk; 14 | import org.dimdev.jeid.ducks.modsupport.cubicchunks.INewCube; 15 | import org.spongepowered.asm.mixin.Mixin; 16 | import org.spongepowered.asm.mixin.Overwrite; 17 | import org.spongepowered.asm.mixin.Shadow; 18 | import org.spongepowered.asm.mixin.Unique; 19 | import org.spongepowered.asm.mixin.injection.At; 20 | import org.spongepowered.asm.mixin.injection.Constant; 21 | import org.spongepowered.asm.mixin.injection.Inject; 22 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 23 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 24 | 25 | @Mixin(value = IONbtReader.class, remap = false) 26 | public class MixinIONbtReader { 27 | @Inject(method = "readBlocks", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;getByteArray(Ljava/lang/String;)[B", ordinal = 0, remap = true)) 28 | private static void reid$setTempPalette(NBTTagCompound nbt, World world, Cube cube, CallbackInfo ci, @Local ExtendedBlockStorage ebs) { 29 | int[] palette = nbt.hasKey("Palette", 11) ? nbt.getIntArray("Palette") : null; 30 | //JEID.LOGGER.info("cube at {}, {} palette size {}", cube.getCoords().getX(), cube.getCoords().getZ(), palette.length); 31 | ((INewBlockStateContainer) ebs.getData()).setTemporaryPalette(palette); 32 | } 33 | 34 | @ModifyConstant(method = "readBlocks", constant = @Constant(intValue = 4096)) 35 | private static int reid$setBlockStateContainerData(int oldValue, @Local ExtendedBlockStorage ebs, @Local byte[] abyte, 36 | @Local(ordinal = 0) NibbleArray data, @Local(ordinal = 1) NibbleArray add) { 37 | ebs.getData().setDataFromNBT(abyte, data, add); 38 | return 0; 39 | } 40 | 41 | /** 42 | * @author Exsolutus 43 | * @reason Support int biome ids 44 | */ 45 | @Overwrite 46 | private static void readBiomes(NBTTagCompound nbt, Chunk column) {// column biomes 47 | System.arraycopy(nbt.getIntArray("Biomes"), 0, ((INewChunk) column).getIntBiomeArray(), 0, Cube.SIZE * Cube.SIZE); 48 | } 49 | 50 | /** 51 | * @author Exsolutus 52 | * @reason Support int biome ids 53 | */ 54 | @Overwrite 55 | private static void readBiomes(Cube cube, NBTTagCompound nbt) {// cube biomes 56 | if (nbt.hasKey("Biomes3D")) { 57 | ((INewCube) cube).setBiomeArray(nbt.getIntArray("Biomes3D")); 58 | } 59 | if (nbt.hasKey("Biomes")) { 60 | ((INewCube) cube).setBiomeArray(convertFromOldCubeBiomes(nbt.getIntArray("Biomes"))); 61 | } 62 | } 63 | 64 | @Unique 65 | private static int[] convertFromOldCubeBiomes(int[] biomes) { 66 | int[] newBiomes = new int[64]; 67 | 68 | for (int x = 0; x < 4; ++x) { 69 | for (int y = 0; y < 4; ++y) { 70 | for (int z = 0; z < 4; ++z) { 71 | newBiomes[AddressTools.getBiomeAddress3d(x, y, z)] = biomes[getOldBiomeAddress(x << 1 | y & 1, z << 1 | y >> 1 & 1)]; 72 | } 73 | } 74 | } 75 | 76 | return newBiomes; 77 | } 78 | 79 | @Shadow 80 | public static int getOldBiomeAddress(int biomeX, int biomeZ) { 81 | return 0; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/cubicchunks/MixinIONbtWriter.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.cubicchunks; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import com.llamalad7.mixinextras.sugar.ref.LocalRef; 5 | import io.github.opencubicchunks.cubicchunks.core.world.cube.Cube; 6 | import net.minecraft.nbt.NBTTagCompound; 7 | import net.minecraft.world.chunk.Chunk; 8 | import net.minecraft.world.chunk.NibbleArray; 9 | import net.minecraft.world.chunk.storage.ExtendedBlockStorage; 10 | import org.dimdev.jeid.ducks.INewBlockStateContainer; 11 | import org.dimdev.jeid.ducks.INewChunk; 12 | import org.dimdev.jeid.ducks.modsupport.cubicchunks.INewCube; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.Overwrite; 15 | import org.spongepowered.asm.mixin.injection.At; 16 | import org.spongepowered.asm.mixin.injection.Constant; 17 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 18 | import org.spongepowered.asm.mixin.injection.Slice; 19 | 20 | @Mixin(targets = "io.github.opencubicchunks.cubicchunks.core.server.chunkio.IONbtWriter", remap = false) 21 | public class MixinIONbtWriter { 22 | /** 23 | * @author Exsolutus 24 | * @reason Support int biome ids 25 | */ 26 | @Overwrite 27 | private static void writeBiomes(Chunk column, NBTTagCompound nbt) {// column biomes 28 | nbt.setIntArray("Biomes", ((INewChunk) column).getIntBiomeArray()); 29 | } 30 | 31 | /** 32 | * @author Exsolutus 33 | * @reason Support int biome ids 34 | */ 35 | @Overwrite 36 | private static void writeBiomes(Cube cube, NBTTagCompound nbt) {// cube biomes 37 | int[] biomes = ((INewCube) cube).getBiomeArray(); 38 | if (biomes != null) 39 | nbt.setIntArray("Biomes", biomes); 40 | } 41 | 42 | @ModifyConstant(method = "writeBlocks", 43 | slice = @Slice( 44 | id = "loopCondition", 45 | from = @At(value = "NEW", target = "()Lnet/minecraft/world/chunk/NibbleArray;", remap = true) 46 | ), constant = @Constant(intValue = 4096, slice = "loopCondition")) 47 | private static int reid$setNBTPalette(int oldValue, @Local ExtendedBlockStorage ebs, @Local(ordinal = 1) NBTTagCompound section, 48 | @Local byte[] abyte, @Local(ordinal = 0) NibbleArray data, 49 | @Local(ordinal = 1) LocalRef add) { 50 | add.set(ebs.getData().getDataForNBT(abyte, data)); 51 | 52 | int[] palette = ((INewBlockStateContainer) ebs.getData()).getTemporaryPalette(); 53 | //JEID.LOGGER.info("cube at {}, {} palette size {}", cube.getCoords().getX(), cube.getCoords().getZ(), palette.length); 54 | if (palette != null) section.setIntArray("Palette", palette); 55 | return 0; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/cubicchunks/MixinVanillaCompatibilityGenerator.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.cubicchunks; 2 | 3 | import io.github.opencubicchunks.cubicchunks.api.util.Coords; 4 | import io.github.opencubicchunks.cubicchunks.core.world.cube.Cube; 5 | import io.github.opencubicchunks.cubicchunks.core.worldgen.generator.vanilla.VanillaCompatibilityGenerator; 6 | import net.minecraft.world.World; 7 | import net.minecraft.world.biome.Biome; 8 | import net.minecraft.world.chunk.Chunk; 9 | import org.dimdev.jeid.ducks.INewChunk; 10 | import org.spongepowered.asm.mixin.Final; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Overwrite; 13 | import org.spongepowered.asm.mixin.Shadow; 14 | 15 | import javax.annotation.Nonnull; 16 | 17 | @Mixin(value = VanillaCompatibilityGenerator.class, remap = false) 18 | public class MixinVanillaCompatibilityGenerator { 19 | @Shadow 20 | private Biome[] biomes; 21 | @Shadow 22 | @Final 23 | @Nonnull 24 | private World world; 25 | 26 | /** 27 | * @author Exsolutus 28 | * @reason Support int biome ids 29 | */ 30 | @Overwrite 31 | public void generateColumn(Chunk column) { 32 | this.biomes = this.world.getBiomeProvider() 33 | .getBiomes(this.biomes, 34 | Coords.cubeToMinBlock(column.x), 35 | Coords.cubeToMinBlock(column.z), 36 | Cube.SIZE, Cube.SIZE); 37 | 38 | INewChunk newColumn = (INewChunk) column; 39 | int[] aint = newColumn.getIntBiomeArray(); 40 | for (int i = 0; i < aint.length; ++i) { 41 | aint[i] = Biome.getIdForBiome(this.biomes[i]); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/cubicchunks/MixinWorldEncoder.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.cubicchunks; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; 5 | import io.github.opencubicchunks.cubicchunks.api.util.Coords; 6 | import io.github.opencubicchunks.cubicchunks.core.world.cube.Cube; 7 | import io.netty.buffer.ByteBuf; 8 | import net.minecraft.network.PacketBuffer; 9 | import net.minecraft.world.chunk.Chunk; 10 | import org.dimdev.jeid.ducks.INewChunk; 11 | import org.dimdev.jeid.ducks.modsupport.cubicchunks.INewCube; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.Overwrite; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.Redirect; 17 | import org.spongepowered.asm.mixin.injection.Slice; 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 19 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 20 | 21 | import java.util.Iterator; 22 | import java.util.List; 23 | 24 | @Mixin(targets = "io.github.opencubicchunks.cubicchunks.core.network.WorldEncoder", remap = false) 25 | public class MixinWorldEncoder { 26 | @Redirect(method = "lambda$encodeCubes$0", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/core/world/cube/Cube;getBiomeArray()[B")) 27 | private static byte[] reid$encodeCheckEmptiness(Cube instance) { 28 | if (((INewCube) instance).getBiomeArray() != null) { 29 | return new byte[0]; 30 | } 31 | return null; 32 | } 33 | 34 | @Inject(method = "lambda$encodeCubes$5", at = @At(value = "HEAD"), cancellable = true) 35 | private static void reid$encodeBiomes(PacketBuffer out, Cube cube, CallbackInfo ci) { 36 | int[] biomes = ((INewCube) cube).getBiomeArray(); 37 | if (biomes != null) { 38 | for (int biome : biomes) { 39 | out.writeInt(biome); 40 | } 41 | } 42 | ci.cancel(); 43 | } 44 | 45 | @Redirect(method = "encodeColumn", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;writeBytes([B)Lio/netty/buffer/ByteBuf;", remap = true)) 46 | private static ByteBuf reid$writeColumnBiomeArray(PacketBuffer instance, byte[] oldBiomeArray, PacketBuffer out, Chunk column) { 47 | int[] biomes = ((INewChunk) column).getIntBiomeArray(); 48 | //JEID.LOGGER.info("current biome: {}", biomes[128]); 49 | for (int i = 0; i < 256; i++) { 50 | out.writeInt(biomes[i]); 51 | } 52 | return out; 53 | } 54 | 55 | @Redirect(method = "decodeColumn", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketBuffer;readBytes([B)Lio/netty/buffer/ByteBuf;", remap = true)) 56 | private static ByteBuf reid$readColumnBiomeArray(PacketBuffer instance, byte[] oldBiomeArray, PacketBuffer in, Chunk column) { 57 | int[] biomes = new int[256]; 58 | for (int i = 0; i < 256; i++) { 59 | biomes[i] = in.readInt(); 60 | } 61 | ((INewChunk) column).setIntBiomeArray(biomes); 62 | return in; 63 | } 64 | 65 | @Inject(method = "decodeCube", 66 | slice = @Slice( 67 | id = "lastLoop", 68 | from = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;recalculateRefCounts()V", remap = true) 69 | ), at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/List;get(I)Ljava/lang/Object;", slice = "lastLoop"), cancellable = true 70 | ) 71 | private static void reid$decodeBiomes(PacketBuffer in, List cubes, CallbackInfo ci, @Local(ordinal = 0) int i) { 72 | int[] blockBiomeArray = new int[Coords.BIOMES_PER_CUBE]; 73 | for (int j = 0; j < 64; j++) 74 | blockBiomeArray[j] = in.readInt(); 75 | ((INewCube) cubes.get(i)).setBiomeArray(blockBiomeArray); 76 | ci.cancel(); 77 | } 78 | 79 | /** 80 | * @author Exsolutus 81 | * @reason Encode int array size 82 | */ 83 | @Overwrite 84 | static int getEncodedSize(Chunk column) { 85 | // Could probably just inline the length 86 | return (((INewChunk) column).getIntBiomeArray().length * Integer.BYTES) + (Cube.SIZE * Cube.SIZE * Integer.BYTES); 87 | } 88 | 89 | /** 90 | * Intercepts iterator of for-each loop 91 | * 92 | * @reason Encode int array sizes for each cube 93 | */ 94 | // 95 | @Inject(method = "getEncodedSize(Ljava/util/Collection;)I", at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/Collection;iterator()Ljava/util/Iterator;", ordinal = 1)) 96 | private static void reid$encodeCubeBiomeSizes(CallbackInfoReturnable cir, @Local LocalIntRef size, @Local Iterator iterator) { 97 | while (iterator.hasNext()) { 98 | Cube cube = iterator.next(); 99 | int[] biomeArray = ((INewCube) cube).getBiomeArray(); 100 | if (biomeArray == null) 101 | continue; 102 | size.set(size.get() + (Integer.BYTES * biomeArray.length)); 103 | } 104 | // Original for-each will now be skipped as iterator has been consumed 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/cyclopscore/MixinWorldHelpers.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.cyclopscore; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.util.math.BlockPos; 5 | import net.minecraft.world.World; 6 | import net.minecraft.world.biome.Biome; 7 | import net.minecraft.world.chunk.Chunk; 8 | import net.minecraft.world.chunk.IChunkProvider; 9 | import org.cyclops.cyclopscore.helper.WorldHelpers; 10 | import org.dimdev.jeid.ducks.INewChunk; 11 | import org.dimdev.jeid.network.MessageManager; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 16 | 17 | @Mixin(value = WorldHelpers.class, remap = false) 18 | public class MixinWorldHelpers { 19 | @Inject(method = "setBiome", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;markDirty()V", remap = true)) 20 | private static void reid$toIntBiomeArray(World world, BlockPos pos, Biome biome, CallbackInfo ci, @Local Chunk chunk) { 21 | // Method calls markDirty() 22 | ((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = Biome.getIdForBiome(biome); 23 | } 24 | 25 | /** 26 | * @reason Sync clients and don't call unnecessary methods - {@link IChunkProvider#provideChunk} and {@link World#markBlockRangeForRenderUpdate} 27 | */ 28 | @Inject(method = "setBiome", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunkProvider()Lnet/minecraft/world/chunk/IChunkProvider;", remap = true), cancellable = true) 29 | private static void reid$sendBiomeMessage(World world, BlockPos pos, Biome biome, CallbackInfo ci) { 30 | if (!world.isRemote) { 31 | MessageManager.sendClientsBiomePosChange(world, pos, Biome.getIdForBiome(biome)); 32 | } 33 | ci.cancel(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/extrautils2/MixinBiomeManip.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.extrautils2; 2 | 3 | import com.rwtema.extrautils2.biome.BiomeManip; 4 | import net.minecraft.util.math.BlockPos; 5 | import net.minecraft.world.World; 6 | import net.minecraft.world.biome.Biome; 7 | import net.minecraft.world.chunk.Chunk; 8 | import org.dimdev.jeid.ducks.INewChunk; 9 | import org.dimdev.jeid.network.MessageManager; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | 15 | @Mixin(value = BiomeManip.class, remap = false) 16 | public class MixinBiomeManip { 17 | /** 18 | * @author ZombieHDGaming 19 | * @reason Support int biome ids and rewrite because it's unnecessarily complicated 20 | */ 21 | @Inject(method = "setBiome", at = @At(value = "HEAD"), cancellable = true) 22 | private static void reid$rewriteSetBiome(World world, Biome biome, BlockPos pos, CallbackInfo ci) { 23 | Chunk chunk = world.getChunk(pos); 24 | ((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = Biome.getIdForBiome(biome); 25 | chunk.markDirty(); 26 | if (!world.isRemote) { 27 | MessageManager.sendClientsBiomePosChange(world, pos, Biome.getIdForBiome(biome)); 28 | } 29 | ci.cancel(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/extrautils2/MixinWorldProviderSpecialDim.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.extrautils2; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import com.rwtema.extrautils2.dimensions.workhousedim.WorldProviderSpecialDim; 5 | import net.minecraft.world.biome.Biome; 6 | import net.minecraft.world.chunk.Chunk; 7 | import org.dimdev.jeid.ducks.INewChunk; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | import java.util.Arrays; 15 | 16 | @Mixin(value = WorldProviderSpecialDim.class, remap = false) 17 | public class MixinWorldProviderSpecialDim { 18 | @Shadow 19 | public static Biome biome; 20 | 21 | @Inject(method = "generate", at = @At(target = "Lnet/minecraft/world/chunk/Chunk;setTerrainPopulated(Z)V", value = "INVOKE", ordinal = 0, remap = true)) 22 | private static void reid$setBiomeArray(CallbackInfo ci, @Local Chunk chunk) { 23 | Arrays.fill(((INewChunk) chunk).getIntBiomeArray(), Biome.getIdForBiome(biome)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/gaiadimension/MixinGenLayerGDRiverMix.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.gaiadimension; 2 | 3 | import androsa.gaiadimension.world.layer.GenLayerGDRiverMix; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(GenLayerGDRiverMix.class) 9 | public class MixinGenLayerGDRiverMix { 10 | @ModifyConstant(method = "getInts", constant = @Constant(intValue = 255)) 11 | private int getBitMask(int oldValue) { 12 | return 0xFFFFFFFF; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/geographicraft/MixinDimensionManager.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.geographicraft; 2 | 3 | import net.minecraft.init.Biomes; 4 | import net.minecraft.world.biome.Biome; 5 | import net.minecraft.world.chunk.Chunk; 6 | 7 | import climateControl.DimensionManager; 8 | import org.dimdev.jeid.ducks.INewChunk; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 13 | 14 | @Mixin(value = DimensionManager.class, remap = false) 15 | public class MixinDimensionManager { 16 | /** 17 | * @author Runemoro 18 | * @reason Support int biome ids and rewrite because of var types 19 | */ 20 | @Inject(method = "hasOnlySea", at = @At(value = "HEAD"), cancellable = true) 21 | private void reid$rewriteHasOnlySea(Chunk tested, CallbackInfoReturnable cir) { 22 | for (int biome : ((INewChunk) tested).getIntBiomeArray()) { 23 | if (biome != 0 && biome != Biome.getIdForBiome(Biomes.DEEP_OCEAN)) { 24 | cir.setReturnValue(false); 25 | } 26 | } 27 | cir.setReturnValue(true); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/hammercore/MixinWorldLocation.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.hammercore; 2 | 3 | import com.zeitheron.hammercore.net.HCNet; 4 | import com.zeitheron.hammercore.net.IPacket; 5 | import com.zeitheron.hammercore.utils.WorldLocation; 6 | import net.minecraft.util.math.BlockPos; 7 | import net.minecraft.world.World; 8 | import net.minecraft.world.biome.Biome; 9 | import net.minecraft.world.chunk.Chunk; 10 | import net.minecraftforge.fml.common.network.NetworkRegistry; 11 | import org.dimdev.jeid.ducks.INewChunk; 12 | import org.dimdev.jeid.network.MessageManager; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.Shadow; 15 | import org.spongepowered.asm.mixin.injection.At; 16 | import org.spongepowered.asm.mixin.injection.Redirect; 17 | 18 | @Mixin(value = WorldLocation.class, remap = false) 19 | public class MixinWorldLocation { 20 | @Shadow 21 | private World world; 22 | @Shadow 23 | private BlockPos pos; 24 | 25 | @Redirect(method = "setBiome", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;setBiomeArray([B)V", remap = true)) 26 | private void reid$toIntBiomeArray(Chunk instance, byte[] biomeArray, Biome biome) { 27 | ((INewChunk) instance).getIntBiomeArray()[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = Biome.getIdForBiome(biome); 28 | instance.markDirty(); 29 | } 30 | 31 | @Redirect(method = "setBiome", at = @At(value = "INVOKE", target = "Lcom/zeitheron/hammercore/net/HCNet;sendToAllAround(Lcom/zeitheron/hammercore/net/IPacket;Lnet/minecraftforge/fml/common/network/NetworkRegistry$TargetPoint;)V")) 32 | private void reid$sendBiomeMessage(HCNet instance, IPacket packet, NetworkRegistry.TargetPoint point, Biome biome) { 33 | MessageManager.sendClientsBiomePosChange(world, pos, Biome.getIdForBiome(biome)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/journeymap/MixinChunkMD.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.journeymap; 2 | 3 | import journeymap.client.model.ChunkMD; 4 | import net.minecraft.util.math.BlockPos; 5 | import net.minecraft.world.biome.Biome; 6 | import net.minecraft.world.chunk.Chunk; 7 | import org.dimdev.jeid.ducks.INewChunk; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 13 | 14 | @Mixin(value = ChunkMD.class, remap = false) 15 | public abstract class MixinChunkMD { 16 | @Shadow 17 | public abstract Chunk getChunk(); 18 | 19 | /** 20 | * @author Runemoro, ZombieHDGaming 21 | * @reason Support int biome ids and rewrite because ModifyVariable can't find target 22 | */ 23 | @Inject(method = "getBiome", at = @At(value = "HEAD"), cancellable = true) 24 | private void reid$rewriteGetBiome(BlockPos pos, CallbackInfoReturnable cir) { 25 | Chunk chunk = this.getChunk(); 26 | int[] biomeArray = ((INewChunk) chunk).getIntBiomeArray(); 27 | int biomeId = biomeArray[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF]; 28 | if (biomeId == 0xFFFFFFFF) { 29 | Biome biome = chunk.getWorld().getBiomeProvider().getBiome(pos, null); 30 | 31 | if (biome == null) { 32 | cir.setReturnValue(null); 33 | } 34 | biomeId = Biome.getIdForBiome(biome); 35 | // Client-side only 36 | biomeArray[(pos.getZ() & 0xF) << 4 | pos.getX() & 0xF] = biomeId; 37 | } 38 | 39 | cir.setReturnValue(Biome.getBiome(biomeId)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/kathairis/MixinChunkGeneratorMystic.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.kathairis; 2 | 3 | import net.minecraft.world.biome.Biome; 4 | 5 | import mod.krevik.world.dimension.ChunkGeneratorMystic; 6 | import org.dimdev.jeid.ducks.ICustomBiomesForGeneration; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | 10 | @Mixin(value = ChunkGeneratorMystic.class, remap = false) 11 | public class MixinChunkGeneratorMystic implements ICustomBiomesForGeneration { 12 | @Shadow 13 | private Biome[] biomesForGeneration; 14 | 15 | @Override 16 | public Biome[] getBiomesForGeneration() { 17 | return biomesForGeneration; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/moreplanets/MixinGenLayerRiversMix.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.moreplanets; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.Constant; 5 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 6 | import stevekung.mods.moreplanets.planets.chalos.world.gen.biome.layer.GenLayerSlimelyStreamMix; 7 | import stevekung.mods.moreplanets.planets.fronos.world.gen.biome.layer.GenLayerFronosRiverMix; 8 | import stevekung.mods.moreplanets.planets.nibiru.world.gen.biome.layer.GenLayerNibiruRiverMix; 9 | 10 | @Mixin(value = {GenLayerFronosRiverMix.class, GenLayerNibiruRiverMix.class, GenLayerSlimelyStreamMix.class}) 11 | public class MixinGenLayerRiversMix { 12 | @ModifyConstant(method = "getInts", constant = @Constant(intValue = 255)) 13 | private int getBitMask(int oldValue) { 14 | return 0xFFFFFFFF; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/mystcraft/MixinBiomeReplacer.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.mystcraft; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import com.xcompwiz.mystcraft.symbol.symbols.SymbolFloatingIslands; 5 | import net.minecraft.world.biome.Biome; 6 | import net.minecraft.world.chunk.Chunk; 7 | import org.dimdev.jeid.ducks.INewChunk; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Mixin(value = SymbolFloatingIslands.BiomeReplacer.class, remap = false) 15 | public class MixinBiomeReplacer { 16 | @Shadow 17 | private Biome biome; 18 | 19 | @Inject(method = "finalizeChunk", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/biome/Biome;getIdForBiome(Lnet/minecraft/world/biome/Biome;)I", remap = true)) 20 | private void reid$toIntBiomeArray(Chunk chunk, int chunkX, int chunkZ, CallbackInfo ci, @Local(ordinal = 2) int coords) { 21 | ((INewChunk) chunk).getIntBiomeArray()[coords] = Biome.getIdForBiome(biome); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/naturescompass/MixinBiomeUtils.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.naturescompass; 2 | 3 | import com.chaosthedude.naturescompass.util.BiomeUtils; 4 | import com.llamalad7.mixinextras.injector.ModifyReturnValue; 5 | import net.minecraft.world.biome.Biome; 6 | import org.dimdev.jeid.biome.BiomeError; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | 10 | @Mixin(value = BiomeUtils.class, remap = false) 11 | public class MixinBiomeUtils { 12 | @ModifyReturnValue(method = "biomeIsBlacklisted", at = @At(value = "RETURN")) 13 | private static boolean reid$hideErrorBiome(boolean original, Biome biome) { 14 | return (biome instanceof BiomeError) || original; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/realisticterraingen/MixinChunkGeneratorRTG.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.realisticterraingen; 2 | 3 | import org.dimdev.jeid.ducks.IModSupportsJEID; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import rtg.world.gen.ChunkGeneratorRTG; 6 | 7 | @Mixin(value = ChunkGeneratorRTG.class, remap = false) 8 | public class MixinChunkGeneratorRTG implements IModSupportsJEID { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/scapeandrunparasites/MixinSpreadBiome.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.scapeandrunparasites; 2 | 3 | import com.dhanantry.scapeandrunparasites.init.SRPBiomes; 4 | import com.dhanantry.scapeandrunparasites.util.ParasiteEventWorld; 5 | import net.minecraft.init.Biomes; 6 | import net.minecraft.util.math.BlockPos; 7 | import net.minecraft.world.World; 8 | import net.minecraft.world.biome.Biome; 9 | import net.minecraft.world.chunk.Chunk; 10 | 11 | import net.minecraftforge.fml.common.network.simpleimpl.IMessage; 12 | import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; 13 | 14 | import com.llamalad7.mixinextras.sugar.Local; 15 | import org.dimdev.jeid.ducks.INewChunk; 16 | import org.dimdev.jeid.network.MessageManager; 17 | import org.spongepowered.asm.mixin.Mixin; 18 | import org.spongepowered.asm.mixin.injection.At; 19 | import org.spongepowered.asm.mixin.injection.Inject; 20 | import org.spongepowered.asm.mixin.injection.Redirect; 21 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 22 | 23 | @Mixin(value = ParasiteEventWorld.class, remap = false) 24 | public class MixinSpreadBiome { 25 | /** 26 | * @reason Use REID message to immediately re-render changes on client 27 | */ 28 | @Redirect(method = "SpreadBiome", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/network/simpleimpl/SimpleNetworkWrapper;sendToDimension(Lnet/minecraftforge/fml/common/network/simpleimpl/IMessage;I)V")) 29 | private static void reid$sendSpreadBiomeChange(SimpleNetworkWrapper instance, IMessage message, int dimensionId, World worldIn, BlockPos pos, 30 | @Local(ordinal = 1) BlockPos convertPos) { 31 | MessageManager.sendClientsBiomePosChange(worldIn, convertPos, Biome.getIdForBiome(SRPBiomes.biomeInfested)); 32 | } 33 | 34 | /** 35 | * @reason Use REID message to immediately re-render changes on client 36 | */ 37 | @Redirect(method = "killBiome", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/network/simpleimpl/SimpleNetworkWrapper;sendToDimension(Lnet/minecraftforge/fml/common/network/simpleimpl/IMessage;I)V")) 38 | private static void reid$sendKillBiomeChange(SimpleNetworkWrapper instance, IMessage message, int dimensionId, World worldIn, BlockPos pos, 39 | @Local(ordinal = 1) BlockPos convertPos) { 40 | Biome original = worldIn.getBiomeProvider().getBiome(pos, Biomes.PLAINS); 41 | MessageManager.sendClientsBiomePosChange(worldIn, convertPos, Biome.getIdForBiome(original)); 42 | } 43 | 44 | /** 45 | * @author roguetictac, jchung01 46 | * @reason Support int biome id for spreading infected biome. 47 | */ 48 | @Inject(method = "positionToParasiteBiome", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunk(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/chunk/Chunk;", remap = true), cancellable = true) 49 | private static void reid$parasiteToIntBiomeArray(World worldIn, BlockPos pos, CallbackInfo ci, 50 | @Local(ordinal = 0) int inChunkX, @Local(ordinal = 1) int inChunkZ) { 51 | Chunk chunk = worldIn.getChunk(pos); 52 | chunk.markDirty(); 53 | ((INewChunk) chunk).getIntBiomeArray()[inChunkZ << 4 | inChunkX] = Biome.getIdForBiome(SRPBiomes.biomeInfested); 54 | ci.cancel(); 55 | } 56 | 57 | /** 58 | * @author roguetictac, jchung01 59 | * @reason Support int biome id for resetting infected biome. 60 | */ 61 | @Inject(method = "positionToBiome", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunk(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/chunk/Chunk;", remap = true), cancellable = true) 62 | private static void reid$plainsToIntBiomeArray(World worldIn, BlockPos pos, CallbackInfo ci, 63 | @Local(ordinal = 0) int inChunkX, @Local(ordinal = 1) int inChunkZ) { 64 | // Get the originally generated biome. 65 | Biome original = worldIn.getBiomeProvider().getBiome(pos, Biomes.PLAINS); 66 | Chunk chunk = worldIn.getChunk(pos); 67 | chunk.markDirty(); 68 | ((INewChunk) chunk).getIntBiomeArray()[inChunkZ << 4 | inChunkX] = Biome.getIdForBiome(original); 69 | ci.cancel(); 70 | } 71 | } -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/thaumcraft/MixinUtils.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.thaumcraft; 2 | 3 | import net.minecraft.util.math.BlockPos; 4 | import net.minecraft.world.World; 5 | import net.minecraft.world.biome.Biome; 6 | import net.minecraft.world.chunk.Chunk; 7 | import net.minecraftforge.fml.common.network.NetworkRegistry; 8 | import net.minecraftforge.fml.common.network.simpleimpl.IMessage; 9 | import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; 10 | import org.dimdev.jeid.ducks.INewChunk; 11 | import org.dimdev.jeid.network.MessageManager; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Redirect; 15 | import thaumcraft.common.lib.utils.Utils; 16 | 17 | @Mixin(value = Utils.class, remap = false) 18 | public class MixinUtils { 19 | @Redirect(method = "setBiomeAt(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/biome/Biome;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;setBiomeArray([B)V", remap = true)) 20 | private static void reid$toIntBiomeArray(Chunk instance, byte[] biomeArray, World world, BlockPos pos, Biome biome) { 21 | int[] array = ((INewChunk) instance).getIntBiomeArray(); 22 | array[(pos.getX() & 15) << 4 | pos.getZ() & 15] = Biome.getIdForBiome(biome); 23 | instance.markDirty(); 24 | } 25 | 26 | @Redirect(method = "setBiomeAt(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/biome/Biome;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/network/simpleimpl/SimpleNetworkWrapper;sendToAllAround(Lnet/minecraftforge/fml/common/network/simpleimpl/IMessage;Lnet/minecraftforge/fml/common/network/NetworkRegistry$TargetPoint;)V")) 27 | private static void reid$sendBiomeMessage(SimpleNetworkWrapper instance, IMessage message, NetworkRegistry.TargetPoint point, World world, BlockPos pos, Biome biome) { 28 | MessageManager.sendClientsBiomePosChange(world, pos, Biome.getIdForBiome(biome)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/thebetweenlands/MixinBlockSpreadingDeath.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.thebetweenlands; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.util.math.BlockPos; 5 | import net.minecraft.world.World; 6 | import net.minecraft.world.biome.Biome; 7 | import net.minecraft.world.chunk.Chunk; 8 | import org.dimdev.jeid.ducks.INewChunk; 9 | import org.dimdev.jeid.network.MessageManager; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Redirect; 13 | import thebetweenlands.common.block.terrain.BlockSpreadingDeath; 14 | 15 | @Mixin(value = BlockSpreadingDeath.class, remap = false) 16 | public class MixinBlockSpreadingDeath { 17 | @Redirect(method = "convertBiome", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;setBiomeArray([B)V", remap = true)) 18 | private void reid$toIntBiomeArray(Chunk instance, byte[] biomeArray, World world, BlockPos pos, Biome biome, @Local Chunk chunk) { 19 | // Method calls markDirty() 20 | ((INewChunk) chunk).getIntBiomeArray()[(pos.getZ() & 15) << 4 | pos.getX() & 15] = Biome.getIdForBiome(biome); 21 | if (!world.isRemote) { 22 | MessageManager.sendClientsBiomePosChange(world, pos, Biome.getIdForBiome(biome)); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/thebetweenlands/MixinGenLayerVoronoiZoomInstanced.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.thebetweenlands; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.Constant; 5 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 6 | import thebetweenlands.common.world.gen.layer.GenLayerVoronoiZoomInstanced; 7 | 8 | @Mixin(GenLayerVoronoiZoomInstanced.class) 9 | public abstract class MixinGenLayerVoronoiZoomInstanced { 10 | @ModifyConstant(method = "getInts", constant = @Constant(intValue = 255)) 11 | private int getBitMask(int oldValue) { 12 | return 0xFFFFFFFF; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/tofucraft/MixinGenLayerRiverMix.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.tofucraft; 2 | 3 | import cn.mcmod.tofucraft.world.gen.layer.GenLayerRiverMix; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(GenLayerRiverMix.class) 9 | public class MixinGenLayerRiverMix { 10 | @ModifyConstant(method = "getInts", constant = @Constant(intValue = 255)) 11 | private int getBitMask(int oldValue) { 12 | return 0xFFFFFFFF; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/tofucraft/MixinGenLayerTofuVoronoiZoom.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.tofucraft; 2 | 3 | import cn.mcmod.tofucraft.world.gen.layer.GenLayerTofuVoronoiZoom; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(GenLayerTofuVoronoiZoom.class) 9 | public class MixinGenLayerTofuVoronoiZoom { 10 | @ModifyConstant(method = "getInts", constant = @Constant(intValue = 255)) 11 | private int getBitMask(int oldValue) { 12 | return 0xFFFFFFFF; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/tropicraft/MixinGenLayerTropiVoronoiZoom.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.tropicraft; 2 | 3 | import net.tropicraft.core.common.worldgen.genlayer.GenLayerTropiVoronoiZoom; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(GenLayerTropiVoronoiZoom.class) 9 | public class MixinGenLayerTropiVoronoiZoom { 10 | @ModifyConstant(method = "getInts", constant = @Constant(intValue = 255)) 11 | private int getBitMask(int oldValue) { 12 | return 0xFFFFFFFF; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/twilightforest/MixinBlockTFMagicLogSpecial.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.twilightforest; 2 | 3 | import com.llamalad7.mixinextras.sugar.Local; 4 | import net.minecraft.util.math.BlockPos; 5 | import net.minecraft.world.World; 6 | import net.minecraft.world.biome.Biome; 7 | import net.minecraft.world.chunk.Chunk; 8 | import org.dimdev.jeid.ducks.INewChunk; 9 | import org.dimdev.jeid.network.MessageManager; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | import twilightforest.biomes.TFBiomes; 15 | import twilightforest.block.BlockTFMagicLogSpecial; 16 | 17 | @Mixin(value = BlockTFMagicLogSpecial.class, remap = false) 18 | public class MixinBlockTFMagicLogSpecial { 19 | /** 20 | * @reason For versions 3.9 and later 21 | */ 22 | @Inject(method = "sendChangedBiome", at = @At(value = "HEAD"), cancellable = true) 23 | private void reid$rewriteSendChangedBiome(World world, BlockPos pos, Biome biome, CallbackInfo ci) { 24 | MessageManager.sendClientsBiomePosChange(world, pos, Biome.getIdForBiome(biome)); 25 | ci.cancel(); 26 | } 27 | 28 | @Inject(method = "doTreeOfTransformationEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B", remap = true)) 29 | private void reid$toIntBiomeArray(CallbackInfo ci, @Local(ordinal = 1) BlockPos dPos, @Local Chunk chunk) { 30 | ((INewChunk) chunk).getIntBiomeArray()[(dPos.getZ() & 15) << 4 | (dPos.getX() & 15)] = Biome.getIdForBiome(TFBiomes.enchantedForest); 31 | chunk.markDirty(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/twilightforest/MixinGenLayerTFRiverMix.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.twilightforest; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.injection.Constant; 5 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 6 | import twilightforest.world.layer.GenLayerTFRiverMix; 7 | 8 | @Mixin(GenLayerTFRiverMix.class) 9 | public class MixinGenLayerTFRiverMix { 10 | @ModifyConstant(method = "getInts", constant = @Constant(intValue = 255)) 11 | private int getBitMask(int oldValue) { 12 | return 0xFFFFFFFF; 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/worldedit/MixinBaseBlock.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.worldedit; 2 | 3 | import com.sk89q.worldedit.blocks.BaseBlock; 4 | import org.objectweb.asm.Opcodes; 5 | import org.spongepowered.asm.mixin.Dynamic; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Unique; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Constant; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 12 | import org.spongepowered.asm.mixin.injection.ModifyVariable; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 14 | 15 | @Mixin(value = BaseBlock.class, remap = false) 16 | public class MixinBaseBlock { 17 | @Unique 18 | private int reid$intId = 0; 19 | 20 | @Inject(method = "getId", at = @At(value = "RETURN"), cancellable = true) 21 | private void reid$getIntId(CallbackInfoReturnable cir) { 22 | cir.setReturnValue(reid$intId); 23 | } 24 | 25 | @ModifyConstant(method = "internalSetId", constant = @Constant(intValue = 4095)) 26 | private int reid$getMaxBlockId(int oldValue) { 27 | return Integer.MAX_VALUE - 1; 28 | } 29 | 30 | @Dynamic("Set block id as int and set short id 0") 31 | @ModifyVariable(method = "internalSetId", at = @At(value = "FIELD", ordinal = 0, opcode = Opcodes.PUTFIELD), argsOnly = true) 32 | private int reid$setIntId(int id) { 33 | reid$intId = id; 34 | return 0; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/worldedit/MixinBiomeCommands.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.worldedit; 2 | 3 | import java.util.Set; 4 | 5 | import net.minecraft.util.math.BlockPos; 6 | import net.minecraft.world.chunk.Chunk; 7 | 8 | import com.llamalad7.mixinextras.sugar.Local; 9 | import com.sk89q.worldedit.EditSession; 10 | import com.sk89q.worldedit.LocalSession; 11 | import com.sk89q.worldedit.Vector2D; 12 | import com.sk89q.worldedit.command.BiomeCommands; 13 | import com.sk89q.worldedit.entity.Player; 14 | import com.sk89q.worldedit.forge.ForgeWorld; 15 | import com.sk89q.worldedit.function.visitor.FlatRegionVisitor; 16 | import com.sk89q.worldedit.regions.Region; 17 | import com.sk89q.worldedit.world.World; 18 | import com.sk89q.worldedit.world.biome.BaseBiome; 19 | import org.dimdev.jeid.ducks.INewChunk; 20 | import org.dimdev.jeid.network.MessageManager; 21 | import org.spongepowered.asm.mixin.Mixin; 22 | import org.spongepowered.asm.mixin.injection.At; 23 | import org.spongepowered.asm.mixin.injection.Inject; 24 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 25 | 26 | @Mixin(value = BiomeCommands.class, remap = false) 27 | public class MixinBiomeCommands { 28 | /** 29 | * @reason Send per-chunk packets (instead of per-position in {@link ForgeWorld}) to client to reduce network usage. 30 | */ 31 | @Inject(method = "setBiome", at = @At(value = "INVOKE", target = "Lcom/sk89q/worldedit/entity/Player;print(Ljava/lang/String;)V"), cancellable = true) 32 | private void reid$sendBiomeChunksChange(Player player, LocalSession session, EditSession editSession, BaseBiome target, boolean atPosition, CallbackInfo ci, 33 | @Local World world, @Local Region region, @Local FlatRegionVisitor visitor) { 34 | if (!(world instanceof ForgeWorld)) return; 35 | net.minecraft.world.World trueWorld = ((ForgeWorld) world).getWorld(); 36 | Set chunks = region.getChunks(); 37 | for (Vector2D chunkPos : chunks) { 38 | BlockPos pos = new BlockPos(chunkPos.getBlockX() << 4, 0.0D, chunkPos.getBlockZ() << 4); 39 | Chunk chunk = trueWorld.getChunk(chunkPos.getBlockX(), chunkPos.getBlockZ()); 40 | chunk.markDirty(); 41 | // Using chunks instead of area because WorldEdit allows non-cuboid regions. 42 | MessageManager.sendClientsBiomeChunkChange(trueWorld, pos, ((INewChunk) chunk).getIntBiomeArray()); 43 | } 44 | // Changes are immediately reflected on client. 45 | player.print("Biomes were changed in " + visitor.getAffected() + " columns."); 46 | ci.cancel(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/worldedit/MixinForgeWorld.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.worldedit; 2 | 3 | import net.minecraft.world.chunk.Chunk; 4 | 5 | import com.llamalad7.mixinextras.sugar.Local; 6 | import com.sk89q.worldedit.Vector2D; 7 | import com.sk89q.worldedit.forge.ForgeWorld; 8 | import com.sk89q.worldedit.world.biome.BaseBiome; 9 | import org.dimdev.jeid.ducks.INewChunk; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 14 | 15 | @Mixin(value = ForgeWorld.class, remap = false) 16 | public class MixinForgeWorld { 17 | @Inject(method = "setBiome", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B", remap = true)) 18 | private void reid$toIntBiomeArray(Vector2D position, BaseBiome biome, CallbackInfoReturnable cir, 19 | @Local Chunk chunk) { 20 | ((INewChunk) chunk).getIntBiomeArray()[(position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF] = biome.getId(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinHiveCreepSpreadFurther.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.wyrmsofnyrus; 2 | 3 | import net.minecraft.util.math.BlockPos; 4 | import net.minecraft.world.World; 5 | import net.minecraft.world.biome.Biome; 6 | import net.minecraftforge.fml.common.network.simpleimpl.IMessage; 7 | import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; 8 | 9 | import com.llamalad7.mixinextras.sugar.Local; 10 | import com.vetpetmon.wyrmsofnyrus.invasion.HiveCreepSpreadFurther; 11 | import com.vetpetmon.wyrmsofnyrus.world.biome.BiomeRegistry; 12 | import org.dimdev.jeid.network.MessageManager; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Redirect; 16 | 17 | @Mixin(value = HiveCreepSpreadFurther.class, remap = false) 18 | public class MixinHiveCreepSpreadFurther { 19 | /** 20 | * @reason Use REID message to immediately re-render changes on client 21 | */ 22 | @Redirect(method = "decay", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/network/simpleimpl/SimpleNetworkWrapper;sendToDimension(Lnet/minecraftforge/fml/common/network/simpleimpl/IMessage;I)V")) 23 | private static void reid$sendSpreadBiomeChange(SimpleNetworkWrapper instance, IMessage message, int dimensionId, BlockPos pos, World world, 24 | @Local(ordinal = 2) BlockPos spreadPos) { 25 | MessageManager.sendClientsBiomePosChange(world, spreadPos, Biome.getIdForBiome(BiomeRegistry.CREEPLANDS)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/mixin/modsupport/wyrmsofnyrus/MixinSpreadingBiome.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.mixin.modsupport.wyrmsofnyrus; 2 | 3 | import net.minecraft.util.math.BlockPos; 4 | import net.minecraft.world.World; 5 | import net.minecraft.world.biome.Biome; 6 | import net.minecraft.world.chunk.Chunk; 7 | 8 | import com.vetpetmon.wyrmsofnyrus.world.biome.BiomeRegistry; 9 | import com.vetpetmon.wyrmsofnyrus.world.biome.SpreadingBiome; 10 | import org.dimdev.jeid.ducks.INewChunk; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; 16 | 17 | @Mixin(value = SpreadingBiome.class, remap = false) 18 | public class MixinSpreadingBiome { 19 | // I would natively implement this considering it doesn't even need anything fancy, 20 | // but I must agree that making a one-off patch is much more performant than making the game 21 | // check for REID, though I am concerned if people are using JEID and don't know about REID... 22 | // 23 | // In 0.6 or a later 0.5.x release I'll probably figure out a way to make a native patch. 24 | // 25 | // WoN's biome alteration code is similar to Thaumcraft's and SRP's biome alteration, 26 | // so these patches are based on those mods' patches. 27 | // I keep calling Mixins patches. I see no difference. 28 | // Can you believe this is the first Mixin I made that actually works? -Modrome, official WoN dev 29 | /** 30 | * @author Modrome, jchung01 31 | * @reason Patches Wyrms of Nyrus's Biome Spread compatible for 0.5.x 32 | */ 33 | @Inject(method = "setBiome(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/biome/Biome;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunk(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/world/chunk/Chunk;", remap = true), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) 34 | private static void reid$toIntBiomeArray(World w, BlockPos pos, Biome biome, CallbackInfo ci, 35 | int convX, int convZ) { 36 | Chunk chunk = w.getChunk(pos); 37 | chunk.markDirty(); 38 | ((INewChunk) chunk).getIntBiomeArray()[convZ << 4 | convX] = Biome.getIdForBiome(biome); 39 | ci.cancel(); 40 | } 41 | 42 | /** 43 | * @reason Overload for WoN 0.5.x 44 | */ 45 | @Inject(method = "setBiome(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V", at = @At(value = "HEAD"), cancellable = true) 46 | private static void reid$creeplandsToIntBiomeArray(World w, BlockPos pos, CallbackInfo ci) { 47 | SpreadingBiome.setBiome(w, pos, BiomeRegistry.CREEPLANDS); 48 | ci.cancel(); 49 | } 50 | 51 | // TODO: Add mixin for 0.6 if necessary (annotate with @Group and @Dynamic, see AR MixinBiomeHandler for example) 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/network/BiomeAreaChangeMessage.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.network; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.multiplayer.WorldClient; 5 | import net.minecraft.network.PacketBuffer; 6 | import net.minecraft.util.math.BlockPos; 7 | import net.minecraft.world.chunk.Chunk; 8 | import net.minecraftforge.fml.common.network.simpleimpl.IMessage; 9 | import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; 10 | import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; 11 | 12 | import io.netty.buffer.ByteBuf; 13 | import org.dimdev.jeid.ducks.INewChunk; 14 | 15 | public class BiomeAreaChangeMessage implements IMessage { 16 | private int x; 17 | private int z; 18 | private int radius; 19 | private int biomeId; 20 | 21 | public BiomeAreaChangeMessage() {} 22 | 23 | public BiomeAreaChangeMessage(int x, int z, int radius, int biomeId) { 24 | this.x = x; 25 | this.z = z; 26 | this.radius = radius; 27 | this.biomeId = biomeId; 28 | } 29 | 30 | @Override 31 | public void fromBytes(ByteBuf byteBuf) { 32 | PacketBuffer packetBuffer = new PacketBuffer(byteBuf); 33 | x = packetBuffer.readVarInt(); 34 | z = packetBuffer.readVarInt(); 35 | radius = packetBuffer.readVarInt(); 36 | biomeId = packetBuffer.readVarInt(); 37 | } 38 | 39 | @Override 40 | public void toBytes(ByteBuf byteBuf) { 41 | PacketBuffer packetBuffer = new PacketBuffer(byteBuf); 42 | packetBuffer.writeVarInt(x); 43 | packetBuffer.writeVarInt(z); 44 | packetBuffer.writeVarInt(radius); 45 | packetBuffer.writeVarInt(biomeId); 46 | } 47 | 48 | public static class Handler implements IMessageHandler { 49 | @Override 50 | public IMessage onMessage(BiomeAreaChangeMessage message, MessageContext ctx) { 51 | Minecraft.getMinecraft().addScheduledTask(() -> { 52 | WorldClient world = Minecraft.getMinecraft().world; 53 | int x = message.x; 54 | int z = message.z; 55 | int rad = message.radius; 56 | for(int ix = x - rad; ix <= x + rad; ++ix) { 57 | for(int iz = z - rad; iz <= z + rad; ++iz) { 58 | Chunk chunk = world.getChunk(new BlockPos(ix, 0, iz)); 59 | int[] biomeArray = ((INewChunk) chunk).getIntBiomeArray(); 60 | int biomeIdAtPos = biomeArray[(iz & 0xF) << 4 | (ix & 0xF)]; 61 | if (biomeIdAtPos != message.biomeId) { 62 | biomeArray[(iz & 0xF) << 4 | (ix & 0xF)] = message.biomeId; 63 | } 64 | } 65 | } 66 | world.markBlockRangeForRenderUpdate(new BlockPos(x - rad, 0, z - rad), new BlockPos(x + rad, world.getHeight(), z + rad)); 67 | }); 68 | return null; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/network/BiomeChunkChangeMessage.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.network; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.multiplayer.WorldClient; 6 | import net.minecraft.network.PacketBuffer; 7 | import net.minecraft.util.math.BlockPos; 8 | import net.minecraft.world.chunk.Chunk; 9 | import net.minecraftforge.fml.common.network.simpleimpl.IMessage; 10 | import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; 11 | import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; 12 | import org.dimdev.jeid.ducks.INewChunk; 13 | 14 | public class BiomeChunkChangeMessage implements IMessage { 15 | private int chunkX; 16 | private int chunkZ; 17 | private int[] biomeArray; 18 | 19 | public BiomeChunkChangeMessage() {} 20 | 21 | public BiomeChunkChangeMessage(int chunkX, int chunkZ, int[] biomeArray) { 22 | this.chunkX = chunkX; 23 | this.chunkZ = chunkZ; 24 | this.biomeArray = biomeArray; 25 | } 26 | 27 | @Override 28 | public void fromBytes(ByteBuf byteBuf) { 29 | PacketBuffer packetBuffer = new PacketBuffer(byteBuf); 30 | chunkX = packetBuffer.readVarInt(); 31 | chunkZ = packetBuffer.readVarInt(); 32 | biomeArray = packetBuffer.readVarIntArray(); 33 | } 34 | 35 | @Override 36 | public void toBytes(ByteBuf byteBuf) { 37 | PacketBuffer packetBuffer = new PacketBuffer(byteBuf); 38 | packetBuffer.writeVarInt(chunkX); 39 | packetBuffer.writeVarInt(chunkZ); 40 | packetBuffer.writeVarIntArray(biomeArray); 41 | } 42 | 43 | public static class Handler implements IMessageHandler { 44 | @Override 45 | public IMessage onMessage(BiomeChunkChangeMessage message, MessageContext ctx) { 46 | Minecraft.getMinecraft().addScheduledTask(() -> { 47 | WorldClient world = Minecraft.getMinecraft().world; 48 | Chunk chunk = world.getChunk(message.chunkX, message.chunkZ); 49 | ((INewChunk) chunk).setIntBiomeArray(message.biomeArray); 50 | world.markBlockRangeForRenderUpdate(new BlockPos(chunk.getPos().getXStart(), 0, chunk.getPos().getZStart()), new BlockPos(chunk.getPos().getXEnd(), world.getHeight(), chunk.getPos().getZEnd())); 51 | }); 52 | return null; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/network/BiomePositionChangeMessage.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.network; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.multiplayer.WorldClient; 6 | import net.minecraft.network.PacketBuffer; 7 | import net.minecraft.util.math.BlockPos; 8 | import net.minecraft.world.chunk.Chunk; 9 | import net.minecraftforge.fml.common.network.simpleimpl.IMessage; 10 | import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; 11 | import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; 12 | import org.dimdev.jeid.ducks.INewChunk; 13 | 14 | public class BiomePositionChangeMessage implements IMessage { 15 | private int x; 16 | private int z; 17 | private int biomeId; 18 | 19 | public BiomePositionChangeMessage() {} 20 | 21 | public BiomePositionChangeMessage(int x, int z, int biomeId) { 22 | this.x = x; 23 | this.z = z; 24 | this.biomeId = biomeId; 25 | } 26 | 27 | @Override 28 | public void fromBytes(ByteBuf byteBuf) { 29 | PacketBuffer packetBuffer = new PacketBuffer(byteBuf); 30 | x = packetBuffer.readVarInt(); 31 | z = packetBuffer.readVarInt(); 32 | biomeId = packetBuffer.readVarInt(); 33 | } 34 | 35 | @Override 36 | public void toBytes(ByteBuf byteBuf) { 37 | PacketBuffer packetBuffer = new PacketBuffer(byteBuf); 38 | packetBuffer.writeVarInt(x); 39 | packetBuffer.writeVarInt(z); 40 | packetBuffer.writeVarInt(biomeId); 41 | } 42 | 43 | public static class Handler implements IMessageHandler { 44 | @Override 45 | public IMessage onMessage(BiomePositionChangeMessage message, MessageContext ctx) { 46 | Minecraft.getMinecraft().addScheduledTask(() -> { 47 | WorldClient world = Minecraft.getMinecraft().world; 48 | Chunk chunk = world.getChunk(new BlockPos(message.x, 0, message.z)); 49 | ((INewChunk) chunk).getIntBiomeArray()[(message.z & 15) << 4 | message.x & 15] = message.biomeId; 50 | world.markBlockRangeForRenderUpdate(new BlockPos(message.x, 0, message.z), new BlockPos(message.x, world.getHeight(), message.z)); 51 | }); 52 | return null; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/dimdev/jeid/network/MessageManager.java: -------------------------------------------------------------------------------- 1 | package org.dimdev.jeid.network; 2 | 3 | import net.minecraft.util.math.BlockPos; 4 | import net.minecraft.world.World; 5 | import net.minecraftforge.fml.common.network.NetworkRegistry; 6 | import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; 7 | import net.minecraftforge.fml.relauncher.Side; 8 | import org.dimdev.jeid.JEID; 9 | 10 | public class MessageManager { 11 | public static final SimpleNetworkWrapper CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(JEID.MODID); 12 | 13 | public static void init() { 14 | CHANNEL.registerMessage(BiomeChunkChangeMessage.Handler.class, BiomeChunkChangeMessage.class, 0, Side.CLIENT); 15 | CHANNEL.registerMessage(BiomePositionChangeMessage.Handler.class, BiomePositionChangeMessage.class, 1, Side.CLIENT); 16 | CHANNEL.registerMessage(BiomeAreaChangeMessage.Handler.class, BiomeAreaChangeMessage.class, 2, Side.CLIENT); 17 | } 18 | 19 | public static void sendClientsBiomePosChange(World world, BlockPos pos, int biomeId) { 20 | MessageManager.CHANNEL.sendToAllTracking( 21 | new BiomePositionChangeMessage(pos.getX(), pos.getZ(), biomeId), 22 | new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 0.0D) // Range ignored 23 | ); 24 | } 25 | 26 | public static void sendClientsBiomeAreaChange(World world, BlockPos pos, int radius, int biomeId) { 27 | MessageManager.CHANNEL.sendToAllTracking( 28 | new BiomeAreaChangeMessage(pos.getX(), pos.getZ(), radius, biomeId), 29 | new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 0.0D) // Range ignored 30 | ); 31 | } 32 | 33 | public static void sendClientsBiomeChunkChange(World world, BlockPos pos, int[] biomeArr) { 34 | MessageManager.CHANNEL.sendToAllTracking( 35 | new BiomeChunkChangeMessage(pos.getX() >> 4, pos.getZ() >> 4, biomeArr), // Expects chunkX/Z 36 | new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 0.0D) // Range ignored 37 | ); 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/jeid_at.cfg: -------------------------------------------------------------------------------- 1 | # Enchantment IDs 2 | public net.minecraft.enchantment.EnchantmentHelper$IModifier -------------------------------------------------------------------------------- /src/main/resources/assets/jeid/lang/en_us.lang: -------------------------------------------------------------------------------- 1 | cfg.reid.mainTitle=RoughlyEnoughIDs Config 2 | cfg.reid.debug=Debug -------------------------------------------------------------------------------- /src/main/resources/assets/reid/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerraFirmaCraft-The-Final-Frontier/RoughlyEnoughIDs/6dcd45f6319bf5c993a3aafbdb99006359943e7d/src/main/resources/assets/reid/logo.png -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | { 2 | "modListVersion": 2, 3 | "modList": [ 4 | { 5 | "modid": "jeid", 6 | "name": "RoughlyEnoughIDs", 7 | "description": "Use the 1.13 chunk format in 1.12 to remove block, item, and biome ID limits.\n\nThanks to zabi94 for helping getting potions and enchants extended.", 8 | "version": "${version}", 9 | "mcversion": "1.12.2", 10 | "url": "https://minecraft.curseforge.com/projects/reid", 11 | "authorList": [ 12 | "Runemoro", 13 | "ZombieHDGaming" 14 | ], 15 | "logoFile": "/assets/reid/logo.png", 16 | "parent": "", 17 | "screenshots": [], 18 | "dependencies": ["mixinbooter"] 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.abyssalcraft.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.abyssalcraft", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": ["MixinBiomeUtil"] 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.advancedrocketry.client.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.advancedrocketry.client", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "client": ["MixinPacketBiomeIDChange"] 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.advancedrocketry.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.advancedrocketry", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBiomeHandler", 9 | "MixinPacketBiomeIDChange" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.atum.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.atum", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinGenLayerAtumRiverMix" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.biomesoplenty.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.biomesoplenty", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBOPCommand", 9 | "MixinModBiomes" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.biomestaff.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.biomestaff", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBiomeStaffUtil", 9 | "MixinItemBiomeStaff" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.biometweaker.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.biometweaker", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBiomeColorMappings", 9 | "MixinBiomeHelper", 10 | "MixinCommandSetBiome" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.bookshelf.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.bookshelf", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinWorldUtils" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.chunkpregenerator.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.chunkpregenerator", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBiomeEntry" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.compactmachines.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.compactmachines", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinChunkUtils" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.core.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.core", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "enchant.MixinEnchantmentHelper", 9 | "enchant.MixinItemEnchantedBook", 10 | "misc.MixinBlock", 11 | "misc.MixinGameData", 12 | "misc.MixinStatList", 13 | "network.MixinPacketBuffer", 14 | "network.MixinPacketUtil", 15 | "network.MixinSPacketChunkData", 16 | "potion.MixinSPacketEntityEffect", 17 | "potion.MixinSPacketRemoveEntityEffect", 18 | "world.MixinAnvilChunkLoader", 19 | "world.MixinBlockStateContainer", 20 | "world.MixinChunk", 21 | "world.MixinChunkPrimer", 22 | "world.MixinChunkProviderServer", 23 | "world.MixinGenLayerVoronoiZoom", 24 | "world.MixinWorldInfo" 25 | ], 26 | "client": [ 27 | "enchant.client.MixinItemEnchantedBook", 28 | "misc.client.MixinRenderGlobal", 29 | "network.client.MixinNetHandlerPlayClient", 30 | "potion.client.MixinNetHandlerPlayClient", 31 | "world.client.MixinChunk", 32 | "world.client.MixinWorldSummary" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.creepingnether.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.creepingnether", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinCorruptorAbstract" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.cubicchunks.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.cubicchunks", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinCube", 9 | "MixinCubePrimer", 10 | "MixinIONbtReader", 11 | "MixinIONbtWriter", 12 | "MixinVanillaCompatibilityGenerator", 13 | "MixinWorldEncoder" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.cyclopscore.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.cyclopscore", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinWorldHelpers" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.extrautils2.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.extrautils2", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBiomeManip", 9 | "MixinWorldProviderSpecialDim" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.gaiadimension.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.gaiadimension", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinGenLayerGDRiverMix" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.geographicraft.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.geographicraft", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinDimensionManager" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.hammercore.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.hammercore", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinWorldLocation" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.journeymap.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.journeymap", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinChunkMD" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.kathairis.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.kathairis", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinChunkGeneratorMystic" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.moreplanets.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.moreplanets", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinGenLayerRiversMix" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.mystcraft.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.mystcraft", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBiomeReplacer" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.naturescompass.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.naturescompass", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBiomeUtils" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.rtg.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.realisticterraingen", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinChunkGeneratorRTG" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.srparasites.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.scapeandrunparasites", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinSpreadBiome" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.thaumcraft.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.thaumcraft", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinUtils" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.thebetweenlands.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.thebetweenlands", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBlockSpreadingDeath", 9 | "MixinGenLayerVoronoiZoomInstanced" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.tofucraft.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.tofucraft", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinGenLayerRiverMix", 9 | "MixinGenLayerTofuVoronoiZoom" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.tropicraft.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.tropicraft", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinGenLayerTropiVoronoiZoom" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.twilightforest.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.twilightforest", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBlockTFMagicLogSpecial", 9 | "MixinGenLayerTFRiverMix" 10 | ] 11 | } -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.worldedit.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.worldedit", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinBaseBlock", 9 | "MixinBiomeCommands", 10 | "MixinForgeWorld" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/mixins.jeid.wyrmsofnyrus.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "org.dimdev.jeid.mixin.modsupport.wyrmsofnyrus", 3 | "required": true, 4 | "refmap": "mixins.jeid.refmap.json", 5 | "minVersion": "0.8", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "MixinSpreadingBiome", 9 | "MixinHiveCreepSpreadFurther" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "pack_format": 3, 4 | "description": "JustEnoughIDs" 5 | } 6 | } 7 | --------------------------------------------------------------------------------