diff --git a/build.gradle b/build.gradle index 167c356..4727e68 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1+', changing: true } } apply plugin: 'net.minecraftforge.gradle' @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.16.3-2.23' +version = '1.16.3-2.24' group = 'nl.requios.effortlessbuilding' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'effortlessbuilding' @@ -25,7 +25,7 @@ minecraft { // stable_# Stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'snapshot', version: '20201028-1.16.3' + mappings channel: 'official', version: '1.16.5' accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 949819d..ffed3a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/gradlew b/gradlew index cccdd3d..b4f908a 100644 --- a/gradlew +++ b/gradlew @@ -1,4 +1,20 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## ## @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -56,7 +72,7 @@ case "`uname`" in Darwin* ) darwin=true ;; - MINGW* ) + MSYS* | MINGW* ) msys=true ;; NONSTOP* ) @@ -66,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,35 +156,28 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") +ARGV=("$@") +eval set -- $DEFAULT_JVM_OPTS -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +IFS=$' +' read -rd '' -a JAVA_OPTS_ARR <<< "$(echo $JAVA_OPTS | xargs -n1)" +IFS=$' +' read -rd '' -a GRADLE_OPTS_ARR <<< "$(echo $GRADLE_OPTS | xargs -n1)" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" +exec "$JAVACMD" "$@" "${JAVA_OPTS_ARR[@]}" "${GRADLE_OPTS_ARR[@]}" "-Dorg.gradle.appname=$APP_BASE_NAME" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "${ARGV[@]}" diff --git a/gradlew.bat b/gradlew.bat index f955316..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/main/java/nl/requios/effortlessbuilding/EffortlessBuilding.java b/src/main/java/nl/requios/effortlessbuilding/EffortlessBuilding.java index 8967864..b658ff9 100644 --- a/src/main/java/nl/requios/effortlessbuilding/EffortlessBuilding.java +++ b/src/main/java/nl/requios/effortlessbuilding/EffortlessBuilding.java @@ -100,7 +100,7 @@ public class EffortlessBuilding { } public static void log(PlayerEntity player, String msg, boolean actionBar) { - player.sendStatusMessage(new StringTextComponent(msg), actionBar); + player.displayClientMessage(new StringTextComponent(msg), actionBar); } //Log with translation supported, call either on client or server (which then sends a message) @@ -147,6 +147,6 @@ public class EffortlessBuilding { @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { - CommandReach.register(event.getServer().getCommandManager().getDispatcher()); + CommandReach.register(event.getServer().getCommands().getDispatcher()); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/EventHandler.java b/src/main/java/nl/requios/effortlessbuilding/EventHandler.java index 9f5551f..ac51a93 100644 --- a/src/main/java/nl/requios/effortlessbuilding/EventHandler.java +++ b/src/main/java/nl/requios/effortlessbuilding/EventHandler.java @@ -61,7 +61,7 @@ public class EventHandler { @SubscribeEvent //Only called serverside (except with lilypads...) public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) { - if (event.getWorld().isRemote()) return; + if (event.getWorld().isClientSide()) return; if (!(event.getEntity() instanceof PlayerEntity)) return; @@ -96,7 +96,7 @@ public class EventHandler { @SubscribeEvent public static void onBlockBroken(BlockEvent.BreakEvent event) { - if (event.getWorld().isRemote()) return; + if (event.getWorld().isClientSide()) return; if (event.getPlayer() instanceof FakePlayer) return; @@ -115,7 +115,7 @@ public class EventHandler { if (event.getPlayer() instanceof ServerPlayerEntity && event.getState() != null && event.getPos() != null) { PacketDistributor.PacketTarget packetTarget = PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) event.getPlayer()); if (packetTarget != null) - PacketHandler.INSTANCE.send(packetTarget, new AddUndoMessage(event.getPos(), event.getState(), Blocks.AIR.getDefaultState())); + PacketHandler.INSTANCE.send(packetTarget, new AddUndoMessage(event.getPos(), event.getState(), Blocks.AIR.defaultBlockState())); } } } @@ -128,12 +128,12 @@ public class EventHandler { if (event.getPlayer() instanceof FakePlayer) return; PlayerEntity player = event.getPlayer(); - World world = player.world; + World world = player.level; BlockPos pos = event.getPos(); //EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed())); - float originalBlockHardness = event.getState().getBlockHardness(world, pos); + float originalBlockHardness = event.getState().getDestroySpeed(world, pos); if (originalBlockHardness < 0) return; //Dont break bedrock float totalBlockHardness = 0; //get coordinates @@ -144,7 +144,7 @@ public class EventHandler { BlockState blockState = world.getBlockState(coordinate); //add hardness for each blockstate, if can break if (SurvivalHelper.canBreak(world, player, coordinate)) - totalBlockHardness += blockState.getBlockHardness(world, coordinate); + totalBlockHardness += blockState.getDestroySpeed(world, coordinate); } //Grabbing percentage from config @@ -171,7 +171,7 @@ public class EventHandler { public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) { if (event.getPlayer() instanceof FakePlayer) return; PlayerEntity player = event.getPlayer(); - if (player.getEntityWorld().isRemote) return; + if (player.getCommandSenderWorld().isClientSide) return; UndoRedo.clear(player); PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new ClearUndoMessage()); @@ -189,7 +189,7 @@ public class EventHandler { public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) { if (event.getPlayer() instanceof FakePlayer) return; PlayerEntity player = event.getPlayer(); - if (player.getEntityWorld().isRemote) return; + if (player.getCommandSenderWorld().isClientSide) return; //Set build mode to normal ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player); diff --git a/src/main/java/nl/requios/effortlessbuilding/ModClientEventHandler.java b/src/main/java/nl/requios/effortlessbuilding/ModClientEventHandler.java index e88a05b..71968f2 100644 --- a/src/main/java/nl/requios/effortlessbuilding/ModClientEventHandler.java +++ b/src/main/java/nl/requios/effortlessbuilding/ModClientEventHandler.java @@ -37,10 +37,10 @@ public class ModClientEventHandler { } public static TextureAtlasSprite getBuildModeIcon(BuildModes.BuildModeEnum mode) { - return Minecraft.getInstance().getModelManager().getAtlasTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).getSprite(buildModeIcons.get(mode)); + return Minecraft.getInstance().getModelManager().getAtlas(AtlasTexture.LOCATION_BLOCKS).getSprite(buildModeIcons.get(mode)); } public static TextureAtlasSprite getModeOptionIcon(ModeOptions.ActionEnum action) { - return Minecraft.getInstance().getModelManager().getAtlasTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).getSprite(modeOptionIcons.get(action)); + return Minecraft.getInstance().getModelManager().getAtlas(AtlasTexture.LOCATION_BLOCKS).getSprite(modeOptionIcons.get(action)); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmode/BaseBuildMode.java b/src/main/java/nl/requios/effortlessbuilding/buildmode/BaseBuildMode.java index bbbcfd5..9ff2fb9 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmode/BaseBuildMode.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmode/BaseBuildMode.java @@ -20,20 +20,20 @@ public abstract class BaseBuildMode implements IBuildMode { @Override public void initialize(PlayerEntity player) { - rightClickClientTable.put(player.getUniqueID(), 0); - rightClickServerTable.put(player.getUniqueID(), 0); - firstPosTable.put(player.getUniqueID(), BlockPos.ZERO); - sideHitTable.put(player.getUniqueID(), Direction.UP); - hitVecTable.put(player.getUniqueID(), Vector3d.ZERO); + rightClickClientTable.put(player.getUUID(), 0); + rightClickServerTable.put(player.getUUID(), 0); + firstPosTable.put(player.getUUID(), BlockPos.ZERO); + sideHitTable.put(player.getUUID(), Direction.UP); + hitVecTable.put(player.getUUID(), Vector3d.ZERO); } @Override public Direction getSideHit(PlayerEntity player) { - return sideHitTable.get(player.getUniqueID()); + return sideHitTable.get(player.getUUID()); } @Override public Vector3d getHitVec(PlayerEntity player) { - return hitVecTable.get(player.getUniqueID()); + return hitVecTable.get(player.getUUID()); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmode/BuildModes.java b/src/main/java/nl/requios/effortlessbuilding/buildmode/BuildModes.java index db0bf3a..fad04d3 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmode/BuildModes.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmode/BuildModes.java @@ -35,7 +35,7 @@ public class BuildModes { public static void onBlockPlacedMessage(PlayerEntity player, BlockPlacedMessage message) { //Check if not in the middle of breaking - Dictionary currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer; + Dictionary currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer; if (currentlyBreaking.get(player) != null && currentlyBreaking.get(player)) { //Cancel breaking initializeMode(player); @@ -53,20 +53,20 @@ public class BuildModes { //Offset in direction of sidehit if not quickreplace and not replaceable //TODO 1.13 replaceable - boolean replaceable = player.world.getBlockState(startPos).getMaterial().isReplaceable(); + boolean replaceable = player.level.getBlockState(startPos).getMaterial().isReplaceable(); boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, message.getSideHit()); if (!modifierSettings.doQuickReplace() && !replaceable && !becomesDoubleSlab) { - startPos = startPos.offset(message.getSideHit()); + startPos = startPos.relative(message.getSideHit()); } //Get under tall grass and other replaceable blocks if (modifierSettings.doQuickReplace() && replaceable) { - startPos = startPos.down(); + startPos = startPos.below(); } //Check if player reach does not exceed startpos int maxReach = ReachHelper.getMaxReach(player); - if (buildMode != BuildModeEnum.NORMAL && player.getPosition().distanceSq(startPos) > maxReach * maxReach) { + if (buildMode != BuildModeEnum.NORMAL && player.blockPosition().distSqr(startPos) > maxReach * maxReach) { EffortlessBuilding.log(player, "Placement exceeds your reach."); return; } @@ -110,7 +110,7 @@ public class BuildModes { public static void onBlockBroken(PlayerEntity player, BlockPos startPos, boolean breakStartPos) { //Check if not in the middle of placing - Dictionary currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer; + Dictionary currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer; if (currentlyBreaking.get(player) != null && !currentlyBreaking.get(player)) { //Cancel placing initializeMode(player); @@ -154,25 +154,25 @@ public class BuildModes { public static void initializeMode(PlayerEntity player) { //Resetting mode, so not placing or breaking - Dictionary currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer; + Dictionary currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer; currentlyBreaking.remove(player); ModeSettingsManager.getModeSettings(player).getBuildMode().instance.initialize(player); } public static boolean isCurrentlyPlacing(PlayerEntity player) { - Dictionary currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer; + Dictionary currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer; return currentlyBreaking.get(player) != null && !currentlyBreaking.get(player); } public static boolean isCurrentlyBreaking(PlayerEntity player) { - Dictionary currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer; + Dictionary currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer; return currentlyBreaking.get(player) != null && currentlyBreaking.get(player); } //Either placing or breaking public static boolean isActive(PlayerEntity player) { - Dictionary currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer; + Dictionary currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer; return currentlyBreaking.get(player) != null; } @@ -206,7 +206,7 @@ public class BuildModes { //Use this instead of player.getLookVec() in any buildmodes code public static Vector3d getPlayerLookVec(PlayerEntity player) { - Vector3d lookVec = player.getLookVec(); + Vector3d lookVec = player.getLookAngle(); double x = lookVec.x; double y = lookVec.y; double z = lookVec.z; @@ -234,12 +234,12 @@ public class BuildModes { if (!skipRaytrace) { //collision within a 1 block radius to selected is fine RayTraceContext rayTraceContext = new RayTraceContext(start, lineBound, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player); - RayTraceResult rayTraceResult = player.world.rayTraceBlocks(rayTraceContext); + RayTraceResult rayTraceResult = player.level.clip(rayTraceContext); intersects = rayTraceResult != null && rayTraceResult.getType() == RayTraceResult.Type.BLOCK && - planeBound.subtract(rayTraceResult.getHitVec()).lengthSquared() > 4; + planeBound.subtract(rayTraceResult.getLocation()).lengthSqr() > 4; } - return planeBound.subtract(start).dotProduct(look) > 0 && + return planeBound.subtract(start).dot(look) > 0 && distToPlayerSq > 2 && distToPlayerSq < reach * reach && !intersects; } diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmode/ModeOptions.java b/src/main/java/nl/requios/effortlessbuilding/buildmode/ModeOptions.java index 1bdc4ff..eed4c76 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmode/ModeOptions.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmode/ModeOptions.java @@ -77,11 +77,11 @@ public class ModeOptions { modifierSettings.doQuickReplace() ? "on" : "off"), true); break; case OPEN_MODIFIER_SETTINGS: - if (player.world.isRemote) + if (player.level.isClientSide) ClientProxy.openModifierSettings(); break; case OPEN_PLAYER_SETTINGS: - if (player.world.isRemote) + if (player.level.isClientSide) ClientProxy.openPlayerSettings(); break; @@ -129,7 +129,7 @@ public class ModeOptions { break; } - if (player.world.isRemote && + if (player.level.isClientSide && action != ActionEnum.REPLACE && action != ActionEnum.OPEN_MODIFIER_SETTINGS && action != ActionEnum.OPEN_PLAYER_SETTINGS) { diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmode/ModeSettingsManager.java b/src/main/java/nl/requios/effortlessbuilding/buildmode/ModeSettingsManager.java index 5999a70..b41d3db 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmode/ModeSettingsManager.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmode/ModeSettingsManager.java @@ -70,7 +70,7 @@ public class ModeSettingsManager { getModeSettings(player); //Only on server - if (!player.world.isRemote) { + if (!player.level.isClientSide) { //Send to client ModeSettingsMessage msg = new ModeSettingsMessage(getModeSettings(player)); PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), msg); diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmode/ThreeClicksBuildMode.java b/src/main/java/nl/requios/effortlessbuilding/buildmode/ThreeClicksBuildMode.java index 94dc23a..248898d 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmode/ThreeClicksBuildMode.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmode/ThreeClicksBuildMode.java @@ -14,7 +14,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode { //Finds height after floor has been chosen in buildmodes with 3 clicks public static BlockPos findHeight(PlayerEntity player, BlockPos secondPos, boolean skipRaytrace) { Vector3d look = BuildModes.getPlayerLookVec(player); - Vector3d start = new Vector3d(player.getPosX(), player.getPosY() + player.getEyeHeight(), player.getPosZ()); + Vector3d start = new Vector3d(player.getX(), player.getY() + player.getEyeHeight(), player.getZ()); List criteriaList = new ArrayList<>(3); @@ -58,46 +58,46 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode { @Override public void initialize(PlayerEntity player) { super.initialize(player); - secondPosTable.put(player.getUniqueID(), BlockPos.ZERO); + secondPosTable.put(player.getUUID(), BlockPos.ZERO); } @Override public List onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vector3d hitVec, boolean skipRaytrace) { List list = new ArrayList<>(); - Dictionary rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable; - int rightClickNr = rightClickTable.get(player.getUniqueID()); + Dictionary rightClickTable = player.level.isClientSide ? rightClickClientTable : rightClickServerTable; + int rightClickNr = rightClickTable.get(player.getUUID()); rightClickNr++; - rightClickTable.put(player.getUniqueID(), rightClickNr); + rightClickTable.put(player.getUUID(), rightClickNr); if (rightClickNr == 1) { //If clicking in air, reset and try again if (blockPos == null) { - rightClickTable.put(player.getUniqueID(), 0); + rightClickTable.put(player.getUUID(), 0); return list; } //First click, remember starting position - firstPosTable.put(player.getUniqueID(), blockPos); - sideHitTable.put(player.getUniqueID(), sideHit); - hitVecTable.put(player.getUniqueID(), hitVec); + firstPosTable.put(player.getUUID(), blockPos); + sideHitTable.put(player.getUUID(), sideHit); + hitVecTable.put(player.getUUID(), hitVec); //Keep list empty, dont place any blocks yet } else if (rightClickNr == 2) { //Second click, find other floor point - BlockPos firstPos = firstPosTable.get(player.getUniqueID()); + BlockPos firstPos = firstPosTable.get(player.getUUID()); BlockPos secondPos = findSecondPos(player, firstPos, true); if (secondPos == null) { - rightClickTable.put(player.getUniqueID(), 1); + rightClickTable.put(player.getUUID(), 1); return list; } - secondPosTable.put(player.getUniqueID(), secondPos); + secondPosTable.put(player.getUUID(), secondPos); } else { //Third click, place diagonal wall with height list = findCoordinates(player, blockPos, skipRaytrace); - rightClickTable.put(player.getUniqueID(), 0); + rightClickTable.put(player.getUUID(), 0); } return list; @@ -106,14 +106,14 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode { @Override public List findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace) { List list = new ArrayList<>(); - Dictionary rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable; - int rightClickNr = rightClickTable.get(player.getUniqueID()); + Dictionary rightClickTable = player.level.isClientSide ? rightClickClientTable : rightClickServerTable; + int rightClickNr = rightClickTable.get(player.getUUID()); if (rightClickNr == 0) { if (blockPos != null) list.add(blockPos); } else if (rightClickNr == 1) { - BlockPos firstPos = firstPosTable.get(player.getUniqueID()); + BlockPos firstPos = firstPosTable.get(player.getUUID()); BlockPos secondPos = findSecondPos(player, firstPos, true); if (secondPos == null) return list; @@ -137,8 +137,8 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode { list.addAll(getIntermediateBlocks(player, x1, y1, z1, x2, y2, z2)); } else { - BlockPos firstPos = firstPosTable.get(player.getUniqueID()); - BlockPos secondPos = secondPosTable.get(player.getUniqueID()); + BlockPos firstPos = firstPosTable.get(player.getUUID()); + BlockPos secondPos = secondPosTable.get(player.getUUID()); BlockPos thirdPos = findThirdPos(player, firstPos, secondPos, skipRaytrace); if (thirdPos == null) return list; @@ -193,8 +193,8 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode { HeightCriteria(Vector3d planeBound, BlockPos secondPos, Vector3d start) { this.planeBound = planeBound; this.lineBound = toLongestLine(this.planeBound, secondPos); - this.distToLineSq = this.lineBound.subtract(this.planeBound).lengthSquared(); - this.distToPlayerSq = this.planeBound.subtract(start).lengthSquared(); + this.distToLineSq = this.lineBound.subtract(this.planeBound).lengthSqr(); + this.distToPlayerSq = this.planeBound.subtract(start).lengthSqr(); } //Make it from a plane into a line, on y axis only diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmode/TwoClicksBuildMode.java b/src/main/java/nl/requios/effortlessbuilding/buildmode/TwoClicksBuildMode.java index 816710e..e4a36f1 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmode/TwoClicksBuildMode.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmode/TwoClicksBuildMode.java @@ -17,27 +17,27 @@ public abstract class TwoClicksBuildMode extends BaseBuildMode { public List onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vector3d hitVec, boolean skipRaytrace) { List list = new ArrayList<>(); - Dictionary rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable; - int rightClickNr = rightClickTable.get(player.getUniqueID()); + Dictionary rightClickTable = player.level.isClientSide ? rightClickClientTable : rightClickServerTable; + int rightClickNr = rightClickTable.get(player.getUUID()); rightClickNr++; - rightClickTable.put(player.getUniqueID(), rightClickNr); + rightClickTable.put(player.getUUID(), rightClickNr); if (rightClickNr == 1) { //If clicking in air, reset and try again if (blockPos == null) { - rightClickTable.put(player.getUniqueID(), 0); + rightClickTable.put(player.getUUID(), 0); return list; } //First click, remember starting position - firstPosTable.put(player.getUniqueID(), blockPos); - sideHitTable.put(player.getUniqueID(), sideHit); - hitVecTable.put(player.getUniqueID(), hitVec); + firstPosTable.put(player.getUUID(), blockPos); + sideHitTable.put(player.getUUID(), sideHit); + hitVecTable.put(player.getUUID(), hitVec); //Keep list empty, dont place any blocks yet } else { //Second click, place blocks list = findCoordinates(player, blockPos, skipRaytrace); - rightClickTable.put(player.getUniqueID(), 0); + rightClickTable.put(player.getUUID(), 0); } return list; @@ -46,9 +46,9 @@ public abstract class TwoClicksBuildMode extends BaseBuildMode { @Override public List findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace) { List list = new ArrayList<>(); - Dictionary rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable; - int rightClickNr = rightClickTable.get(player.getUniqueID()); - BlockPos firstPos = firstPosTable.get(player.getUniqueID()); + Dictionary rightClickTable = player.level.isClientSide ? rightClickClientTable : rightClickServerTable; + int rightClickNr = rightClickTable.get(player.getUUID()); + BlockPos firstPos = firstPosTable.get(player.getUUID()); if (rightClickNr == 0) { if (blockPos != null) diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Floor.java b/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Floor.java index 7d8571c..e5a705b 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Floor.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Floor.java @@ -15,7 +15,7 @@ public class Floor extends TwoClicksBuildMode { public static BlockPos findFloor(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) { Vector3d look = BuildModes.getPlayerLookVec(player); - Vector3d start = new Vector3d(player.getPosX(), player.getPosY() + player.getEyeHeight(), player.getPosZ()); + Vector3d start = new Vector3d(player.getX(), player.getY() + player.getEyeHeight(), player.getZ()); List criteriaList = new ArrayList<>(3); @@ -81,7 +81,7 @@ public class Floor extends TwoClicksBuildMode { Criteria(Vector3d planeBound, Vector3d start) { this.planeBound = planeBound; - this.distToPlayerSq = this.planeBound.subtract(start).lengthSquared(); + this.distToPlayerSq = this.planeBound.subtract(start).lengthSqr(); } //check if its not behind the player and its not too close and not too far diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Line.java b/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Line.java index 4032bd6..d3bec06 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Line.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Line.java @@ -14,7 +14,7 @@ public class Line extends TwoClicksBuildMode { public static BlockPos findLine(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) { Vector3d look = BuildModes.getPlayerLookVec(player); - Vector3d start = new Vector3d(player.getPosX(), player.getPosY() + player.getEyeHeight(), player.getPosZ()); + Vector3d start = new Vector3d(player.getX(), player.getY() + player.getEyeHeight(), player.getZ()); List criteriaList = new ArrayList<>(3); @@ -112,8 +112,8 @@ public class Line extends TwoClicksBuildMode { Criteria(Vector3d planeBound, BlockPos firstPos, Vector3d start) { this.planeBound = planeBound; this.lineBound = toLongestLine(this.planeBound, firstPos); - this.distToLineSq = this.lineBound.subtract(this.planeBound).lengthSquared(); - this.distToPlayerSq = this.planeBound.subtract(start).lengthSquared(); + this.distToLineSq = this.lineBound.subtract(this.planeBound).lengthSqr(); + this.distToPlayerSq = this.planeBound.subtract(start).lengthSqr(); } //Make it from a plane into a line diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Wall.java b/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Wall.java index fdc4d08..3f5cb5e 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Wall.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmode/buildmodes/Wall.java @@ -15,7 +15,7 @@ public class Wall extends TwoClicksBuildMode { public static BlockPos findWall(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) { Vector3d look = BuildModes.getPlayerLookVec(player); - Vector3d start = new Vector3d(player.getPosX(), player.getPosY() + player.getEyeHeight(), player.getPosZ()); + Vector3d start = new Vector3d(player.getX(), player.getY() + player.getEyeHeight(), player.getZ()); List criteriaList = new ArrayList<>(3); @@ -120,8 +120,8 @@ public class Wall extends TwoClicksBuildMode { Criteria(Vector3d planeBound, BlockPos firstPos, Vector3d start, Vector3d look) { this.planeBound = planeBound; - this.distToPlayerSq = this.planeBound.subtract(start).lengthSquared(); - Vector3d wall = this.planeBound.subtract(Vector3d.copy(firstPos)); + this.distToPlayerSq = this.planeBound.subtract(start).lengthSqr(); + Vector3d wall = this.planeBound.subtract(Vector3d.atLowerCornerOf(firstPos)); this.angle = wall.x * look.x + wall.z * look.z; //dot product ignoring y (looking up/down should not affect this angle) } diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/Array.java b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/Array.java index 7c8e321..aa57236 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/Array.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/Array.java @@ -27,7 +27,7 @@ public class Array { Vector3i offset = new Vector3i(a.offset.getX(), a.offset.getY(), a.offset.getZ()); for (int i = 0; i < a.count; i++) { - pos = pos.add(offset); + pos = pos.offset(offset); coordinates.add(pos); } @@ -51,7 +51,7 @@ public class Array { } for (int i = 0; i < a.count; i++) { - pos = pos.add(offset); + pos = pos.offset(offset); //Randomizer bag synergy if (bagInventory != null) { diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/BuildModifiers.java b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/BuildModifiers.java index 4789b28..a87fca2 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/BuildModifiers.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/BuildModifiers.java @@ -29,7 +29,7 @@ public class BuildModifiers { //Called from BuildModes public static void onBlockPlaced(PlayerEntity player, List startCoordinates, Direction sideHit, Vector3d hitVec, boolean placeStartPos) { - World world = player.world; + World world = player.level; ItemRandomizerBag.renewRandomness(); //Format hitvec to 0.x @@ -50,7 +50,7 @@ public class BuildModifiers { previousBlockStates.add(world.getBlockState(coordinate)); } - if (world.isRemote) { + if (world.isClientSide) { BlockPreviewRenderer.onBlocksPlaced(); @@ -64,7 +64,7 @@ public class BuildModifiers { BlockState blockState = blockStates.get(i); ItemStack itemStack = itemStacks.get(i); - if (world.isBlockPresent(blockPos)) { + if (world.isLoaded(blockPos)) { //check itemstack empty if (itemStack.isEmpty()) { //try to find new stack, otherwise continue @@ -83,11 +83,11 @@ public class BuildModifiers { //Set first previousBlockState to empty if in NORMAL mode, to make undo/redo work //(Block is placed by the time it gets here, and unplaced after this) - if (!placeStartPos) previousBlockStates.set(0, Blocks.AIR.getDefaultState()); + if (!placeStartPos) previousBlockStates.set(0, Blocks.AIR.defaultBlockState()); //If all new blockstates are air then no use in adding it, no block was actually placed //Can happen when e.g. placing one block in yourself - if (Collections.frequency(newBlockStates, Blocks.AIR.getDefaultState()) != newBlockStates.size()) { + if (Collections.frequency(newBlockStates, Blocks.AIR.defaultBlockState()) != newBlockStates.size()) { //add to undo stack BlockPos firstPos = startCoordinates.get(0); BlockPos secondPos = startCoordinates.get(startCoordinates.size() - 1); @@ -96,7 +96,7 @@ public class BuildModifiers { } public static void onBlockBroken(PlayerEntity player, List startCoordinates, boolean breakStartPos) { - World world = player.world; + World world = player.level; List coordinates = findCoordinates(player, startCoordinates); @@ -109,25 +109,25 @@ public class BuildModifiers { previousBlockStates.add(world.getBlockState(coordinate)); } - if (world.isRemote) { + if (world.isClientSide) { BlockPreviewRenderer.onBlocksBroken(); //list of air blockstates for (int i = 0; i < coordinates.size(); i++) { - newBlockStates.add(Blocks.AIR.getDefaultState()); + newBlockStates.add(Blocks.AIR.defaultBlockState()); } } else { //If the player is going to instabreak grass or a plant, only break other instabreaking things boolean onlyInstaBreaking = !player.isCreative() && - world.getBlockState(startCoordinates.get(0)).getBlockHardness(world, startCoordinates.get(0)) == 0f; + world.getBlockState(startCoordinates.get(0)).getDestroySpeed(world, startCoordinates.get(0)) == 0f; //break all those blocks for (int i = breakStartPos ? 0 : 1; i < coordinates.size(); i++) { BlockPos coordinate = coordinates.get(i); - if (world.isBlockPresent(coordinate) && !world.isAirBlock(coordinate)) { - if (!onlyInstaBreaking || world.getBlockState(coordinate).getBlockHardness(world, coordinate) == 0f) { + if (world.isLoaded(coordinate) && !world.isEmptyBlock(coordinate)) { + if (!onlyInstaBreaking || world.getBlockState(coordinate).getDestroySpeed(world, coordinate) == 0f) { SurvivalHelper.breakBlock(world, player, coordinate, false); } } @@ -141,7 +141,7 @@ public class BuildModifiers { //Set first newBlockState to empty if in NORMAL mode, to make undo/redo work //(Block isn't broken yet by the time it gets here, and broken after this) - if (!breakStartPos) newBlockStates.set(0, Blocks.AIR.getDefaultState()); + if (!breakStartPos) newBlockStates.set(0, Blocks.AIR.defaultBlockState()); //add to undo stack BlockPos firstPos = startCoordinates.get(0); @@ -181,9 +181,9 @@ public class BuildModifiers { itemStacks.clear(); //Get itemstack - ItemStack itemStack = player.getHeldItem(Hand.MAIN_HAND); + ItemStack itemStack = player.getItemInHand(Hand.MAIN_HAND); if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) { - itemStack = player.getHeldItem(Hand.OFF_HAND); + itemStack = player.getItemInHand(Hand.OFF_HAND); } if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) { return blockStates; @@ -240,7 +240,7 @@ public class BuildModifiers { } public static BlockState getBlockStateFromItem(ItemStack itemStack, PlayerEntity player, BlockPos blockPos, Direction facing, Vector3d hitVec, Hand hand) { - return Block.getBlockFromItem(itemStack.getItem()).getStateForPlacement(new BlockItemUseContext(new ItemUseContext(player, hand, new BlockRayTraceResult(hitVec, facing, blockPos, false)))); + return Block.byItem(itemStack.getItem()).getStateForPlacement(new BlockItemUseContext(new ItemUseContext(player, hand, new BlockRayTraceResult(hitVec, facing, blockPos, false)))); } //Returns true if equal (or both null) diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/Mirror.java b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/Mirror.java index afd1002..dcd8f5d 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/Mirror.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/Mirror.java @@ -160,39 +160,39 @@ public class Mirror { private static BlockState getVerticalMirror(BlockState blockState) { //Stairs if (blockState.getBlock() instanceof StairsBlock) { - if (blockState.get(StairsBlock.HALF) == Half.BOTTOM) { - return blockState.with(StairsBlock.HALF, Half.TOP); + if (blockState.getValue(StairsBlock.HALF) == Half.BOTTOM) { + return blockState.setValue(StairsBlock.HALF, Half.TOP); } else { - return blockState.with(StairsBlock.HALF, Half.BOTTOM); + return blockState.setValue(StairsBlock.HALF, Half.BOTTOM); } } //Slabs if (blockState.getBlock() instanceof SlabBlock) { - if (blockState.get(SlabBlock.TYPE) == SlabType.DOUBLE) { + if (blockState.getValue(SlabBlock.TYPE) == SlabType.DOUBLE) { return blockState; - } else if (blockState.get(SlabBlock.TYPE) == SlabType.BOTTOM) { - return blockState.with(SlabBlock.TYPE, SlabType.TOP); + } else if (blockState.getValue(SlabBlock.TYPE) == SlabType.BOTTOM) { + return blockState.setValue(SlabBlock.TYPE, SlabType.TOP); } else { - return blockState.with(SlabBlock.TYPE, SlabType.BOTTOM); + return blockState.setValue(SlabBlock.TYPE, SlabType.BOTTOM); } } //Buttons, endrod, observer, piston if (blockState.getBlock() instanceof DirectionalBlock) { - if (blockState.get(DirectionalBlock.FACING) == Direction.DOWN) { - return blockState.with(DirectionalBlock.FACING, Direction.UP); - } else if (blockState.get(DirectionalBlock.FACING) == Direction.UP) { - return blockState.with(DirectionalBlock.FACING, Direction.DOWN); + if (blockState.getValue(DirectionalBlock.FACING) == Direction.DOWN) { + return blockState.setValue(DirectionalBlock.FACING, Direction.UP); + } else if (blockState.getValue(DirectionalBlock.FACING) == Direction.UP) { + return blockState.setValue(DirectionalBlock.FACING, Direction.DOWN); } } //Dispenser, dropper if (blockState.getBlock() instanceof DispenserBlock) { - if (blockState.get(DispenserBlock.FACING) == Direction.DOWN) { - return blockState.with(DispenserBlock.FACING, Direction.UP); - } else if (blockState.get(DispenserBlock.FACING) == Direction.UP) { - return blockState.with(DispenserBlock.FACING, Direction.DOWN); + if (blockState.getValue(DispenserBlock.FACING) == Direction.DOWN) { + return blockState.setValue(DispenserBlock.FACING, Direction.UP); + } else if (blockState.getValue(DispenserBlock.FACING) == Direction.UP) { + return blockState.setValue(DispenserBlock.FACING, Direction.DOWN); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/ModifierSettingsManager.java b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/ModifierSettingsManager.java index 3d5fc12..9050a8b 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/ModifierSettingsManager.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/ModifierSettingsManager.java @@ -115,7 +115,7 @@ public class ModifierSettingsManager { getModifierSettings(player); //Only on server - if (!player.world.isRemote) { + if (!player.level.isClientSide) { //Send to client ModifierSettingsMessage msg = new ModifierSettingsMessage(getModifierSettings(player)); PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), msg); diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/RadialMirror.java b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/RadialMirror.java index ce4efd7..bd3c066 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/RadialMirror.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/RadialMirror.java @@ -43,7 +43,7 @@ public class RadialMirror { curAngle = curAngle - startAngleInSlice + (sliceAngle - startAngleInSlice); } - Vector3d relNewVec = relStartVec.rotateYaw((float) curAngle); + Vector3d relNewVec = relStartVec.yRot((float) curAngle); BlockPos newBlockPos = new BlockPos(r.position.add(relNewVec)); if (!coordinates.contains(newBlockPos) && !newBlockPos.equals(startPos)) coordinates.add(newBlockPos); } @@ -89,7 +89,7 @@ public class RadialMirror { curAngle = curAngle - startAngleInSlice + (sliceAngle - startAngleInSlice); } - Vector3d relNewVec = relStartVec.rotateYaw((float) curAngle); + Vector3d relNewVec = relStartVec.yRot((float) curAngle); BlockPos newBlockPos = new BlockPos(r.position.add(relNewVec)); if (coordinates.contains(newBlockPos) || newBlockPos.equals(startPos)) continue; //filter out duplicates coordinates.add(newBlockPos); @@ -159,7 +159,7 @@ public class RadialMirror { public static boolean isEnabled(RadialMirrorSettings r, BlockPos startPos) { if (r == null || !r.enabled) return false; - return !(new Vector3d(startPos.getX() + 0.5, startPos.getY() + 0.5, startPos.getZ() + 0.5).subtract(r.position).lengthSquared() > + return !(new Vector3d(startPos.getX() + 0.5, startPos.getY() + 0.5, startPos.getZ() + 0.5).subtract(r.position).lengthSqr() > r.radius * r.radius); } diff --git a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/UndoRedo.java b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/UndoRedo.java index 72c334f..e6a58ea 100644 --- a/src/main/java/nl/requios/effortlessbuilding/buildmodifier/UndoRedo.java +++ b/src/main/java/nl/requios/effortlessbuilding/buildmodifier/UndoRedo.java @@ -30,7 +30,7 @@ public class UndoRedo { //add to undo stack public static void addUndo(PlayerEntity player, BlockSet blockSet) { - Map> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer; + Map> undoStacks = player.level.isClientSide ? undoStacksClient : undoStacksServer; //Assert coordinates is as long as previous and new blockstate lists if (blockSet.getCoordinates().size() != blockSet.getPreviousBlockStates().size() || @@ -49,32 +49,32 @@ public class UndoRedo { // } //If no stack exists, make one - if (!undoStacks.containsKey(player.getUniqueID())) { - undoStacks.put(player.getUniqueID(), new FixedStack<>(new BlockSet[BuildConfig.survivalBalancers.undoStackSize.get()])); + if (!undoStacks.containsKey(player.getUUID())) { + undoStacks.put(player.getUUID(), new FixedStack<>(new BlockSet[BuildConfig.survivalBalancers.undoStackSize.get()])); } - undoStacks.get(player.getUniqueID()).push(blockSet); + undoStacks.get(player.getUUID()).push(blockSet); } private static void addRedo(PlayerEntity player, BlockSet blockSet) { - Map> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer; + Map> redoStacks = player.level.isClientSide ? redoStacksClient : redoStacksServer; //(No asserts necessary, it's private) //If no stack exists, make one - if (!redoStacks.containsKey(player.getUniqueID())) { - redoStacks.put(player.getUniqueID(), new FixedStack<>(new BlockSet[BuildConfig.survivalBalancers.undoStackSize.get()])); + if (!redoStacks.containsKey(player.getUUID())) { + redoStacks.put(player.getUUID(), new FixedStack<>(new BlockSet[BuildConfig.survivalBalancers.undoStackSize.get()])); } - redoStacks.get(player.getUniqueID()).push(blockSet); + redoStacks.get(player.getUUID()).push(blockSet); } public static boolean undo(PlayerEntity player) { - Map> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer; + Map> undoStacks = player.level.isClientSide ? undoStacksClient : undoStacksServer; - if (!undoStacks.containsKey(player.getUniqueID())) return false; + if (!undoStacks.containsKey(player.getUUID())) return false; - FixedStack undoStack = undoStacks.get(player.getUniqueID()); + FixedStack undoStack = undoStacks.get(player.getUUID()); if (undoStack.isEmpty()) return false; @@ -87,7 +87,7 @@ public class UndoRedo { //Find up to date itemstacks in player inventory List itemStacks = findItemStacksInInventory(player, previousBlockStates); - if (player.world.isRemote) { + if (player.level.isClientSide) { BlockPreviewRenderer.onBlocksBroken(coordinates, itemStacks, newBlockStates, blockSet.getSecondPos(), blockSet.getFirstPos()); } else { //break all those blocks, reset to what they were @@ -98,27 +98,27 @@ public class UndoRedo { if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue; //get blockstate from itemstack - BlockState previousBlockState = Blocks.AIR.getDefaultState(); + BlockState previousBlockState = Blocks.AIR.defaultBlockState(); if (itemStack.getItem() instanceof BlockItem) { - previousBlockState = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState(); + previousBlockState = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState(); } - if (player.world.isBlockPresent(coordinate)) { + if (player.level.isLoaded(coordinate)) { //check itemstack empty if (itemStack.isEmpty()) { itemStack = findItemStackInInventory(player, previousBlockStates.get(i)); //get blockstate from new itemstack if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) { - previousBlockState = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState(); + previousBlockState = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState(); } else { if (previousBlockStates.get(i).getBlock() != Blocks.AIR) - EffortlessBuilding.logTranslate(player, "", previousBlockStates.get(i).getBlock().getTranslationKey(), " not found in inventory", true); - previousBlockState = Blocks.AIR.getDefaultState(); + EffortlessBuilding.logTranslate(player, "", previousBlockStates.get(i).getBlock().getDescriptionId(), " not found in inventory", true); + previousBlockState = Blocks.AIR.defaultBlockState(); } } - if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.world, player, coordinate, true); + if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.level, player, coordinate, true); //if previousBlockState is air, placeBlock will set it to air - SurvivalHelper.placeBlock(player.world, player, coordinate, previousBlockState, itemStack, Direction.UP, hitVec, true, false, false); + SurvivalHelper.placeBlock(player.level, player, coordinate, previousBlockState, itemStack, Direction.UP, hitVec, true, false, false); } } } @@ -130,11 +130,11 @@ public class UndoRedo { } public static boolean redo(PlayerEntity player) { - Map> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer; + Map> redoStacks = player.level.isClientSide ? redoStacksClient : redoStacksServer; - if (!redoStacks.containsKey(player.getUniqueID())) return false; + if (!redoStacks.containsKey(player.getUUID())) return false; - FixedStack redoStack = redoStacks.get(player.getUniqueID()); + FixedStack redoStack = redoStacks.get(player.getUUID()); if (redoStack.isEmpty()) return false; @@ -147,7 +147,7 @@ public class UndoRedo { //Find up to date itemstacks in player inventory List itemStacks = findItemStacksInInventory(player, newBlockStates); - if (player.world.isRemote) { + if (player.level.isClientSide) { BlockPreviewRenderer.onBlocksPlaced(coordinates, itemStacks, newBlockStates, blockSet.getFirstPos(), blockSet.getSecondPos()); } else { //place blocks @@ -158,26 +158,26 @@ public class UndoRedo { if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue; //get blockstate from itemstack - BlockState newBlockState = Blocks.AIR.getDefaultState(); + BlockState newBlockState = Blocks.AIR.defaultBlockState(); if (itemStack.getItem() instanceof BlockItem) { - newBlockState = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState(); + newBlockState = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState(); } - if (player.world.isBlockPresent(coordinate)) { + if (player.level.isLoaded(coordinate)) { //check itemstack empty if (itemStack.isEmpty()) { itemStack = findItemStackInInventory(player, newBlockStates.get(i)); //get blockstate from new itemstack if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) { - newBlockState = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState(); + newBlockState = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState(); } else { if (newBlockStates.get(i).getBlock() != Blocks.AIR) - EffortlessBuilding.logTranslate(player, "", newBlockStates.get(i).getBlock().getTranslationKey(), " not found in inventory", true); - newBlockState = Blocks.AIR.getDefaultState(); + EffortlessBuilding.logTranslate(player, "", newBlockStates.get(i).getBlock().getDescriptionId(), " not found in inventory", true); + newBlockState = Blocks.AIR.defaultBlockState(); } } - if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.world, player, coordinate, true); - SurvivalHelper.placeBlock(player.world, player, coordinate, newBlockState, itemStack, Direction.UP, hitVec, true, false, false); + if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.level, player, coordinate, true); + SurvivalHelper.placeBlock(player.level, player, coordinate, newBlockState, itemStack, Direction.UP, hitVec, true, false, false); } } } @@ -189,13 +189,13 @@ public class UndoRedo { } public static void clear(PlayerEntity player) { - Map> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer; - Map> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer; - if (undoStacks.containsKey(player.getUniqueID())) { - undoStacks.get(player.getUniqueID()).clear(); + Map> undoStacks = player.level.isClientSide ? undoStacksClient : undoStacksServer; + Map> redoStacks = player.level.isClientSide ? redoStacksClient : redoStacksServer; + if (undoStacks.containsKey(player.getUUID())) { + undoStacks.get(player.getUUID()).clear(); } - if (redoStacks.containsKey(player.getUniqueID())) { - redoStacks.get(player.getUniqueID()).clear(); + if (redoStacks.containsKey(player.getUUID())) { + redoStacks.get(player.getUUID()).clear(); } } @@ -220,8 +220,8 @@ public class UndoRedo { //then anything it drops if (itemStack.isEmpty()) { //Cannot check drops on clientside because loot tables are server only - if (!player.world.isRemote) { - List itemsDropped = Block.getDrops(blockState, (ServerWorld) player.world, BlockPos.ZERO, null); + if (!player.level.isClientSide) { + List itemsDropped = Block.getDrops(blockState, (ServerWorld) player.level, BlockPos.ZERO, null); for (ItemStack itemStackDropped : itemsDropped) { if (itemStackDropped.getItem() instanceof BlockItem) { Block block = ((BlockItem) itemStackDropped.getItem()).getBlock(); diff --git a/src/main/java/nl/requios/effortlessbuilding/capability/ModeCapabilityManager.java b/src/main/java/nl/requios/effortlessbuilding/capability/ModeCapabilityManager.java index a590a66..90b1a54 100644 --- a/src/main/java/nl/requios/effortlessbuilding/capability/ModeCapabilityManager.java +++ b/src/main/java/nl/requios/effortlessbuilding/capability/ModeCapabilityManager.java @@ -17,6 +17,8 @@ import javax.annotation.Nullable; import static nl.requios.effortlessbuilding.buildmode.ModeSettingsManager.ModeSettings; +import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager.ModeSettings; + @Mod.EventBusSubscriber public class ModeCapabilityManager { diff --git a/src/main/java/nl/requios/effortlessbuilding/capability/ModifierCapabilityManager.java b/src/main/java/nl/requios/effortlessbuilding/capability/ModifierCapabilityManager.java index b7a5d53..dff6072 100644 --- a/src/main/java/nl/requios/effortlessbuilding/capability/ModifierCapabilityManager.java +++ b/src/main/java/nl/requios/effortlessbuilding/capability/ModifierCapabilityManager.java @@ -21,6 +21,8 @@ import javax.annotation.Nullable; import static nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings; +import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings; + @Mod.EventBusSubscriber public class ModifierCapabilityManager { diff --git a/src/main/java/nl/requios/effortlessbuilding/command/CommandReach.java b/src/main/java/nl/requios/effortlessbuilding/command/CommandReach.java index 0edd2e5..08aa649 100644 --- a/src/main/java/nl/requios/effortlessbuilding/command/CommandReach.java +++ b/src/main/java/nl/requios/effortlessbuilding/command/CommandReach.java @@ -16,9 +16,9 @@ public class CommandReach { public static void register(CommandDispatcher dispatcher) { dispatcher.register(Commands.literal("reach").then(Commands.literal("set").then(Commands.argument("level", IntegerArgumentType.integer(0, 3)).executes((context) -> { - return setReachLevel(context.getSource().asPlayer(), IntegerArgumentType.getInteger(context, "level")); + return setReachLevel(context.getSource().getPlayerOrException(), IntegerArgumentType.getInteger(context, "level")); }))).then(Commands.literal("get").executes((context -> { - return getReachLevel(context.getSource().asPlayer()); + return getReachLevel(context.getSource().getPlayerOrException()); })))); } @@ -29,7 +29,7 @@ public class CommandReach { //Send to client PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new ModifierSettingsMessage(modifierSettings)); - player.sendMessage(new StringTextComponent("Reach level of " + player.getName().getString() + " set to " + modifierSettings.getReachUpgrade()), player.getUniqueID()); + player.sendMessage(new StringTextComponent("Reach level of " + player.getName().getString() + " set to " + modifierSettings.getReachUpgrade()), player.getUUID()); return 1; } diff --git a/src/main/java/nl/requios/effortlessbuilding/compatibility/CompatHelper.java b/src/main/java/nl/requios/effortlessbuilding/compatibility/CompatHelper.java index 6fa642b..775aa68 100644 --- a/src/main/java/nl/requios/effortlessbuilding/compatibility/CompatHelper.java +++ b/src/main/java/nl/requios/effortlessbuilding/compatibility/CompatHelper.java @@ -79,7 +79,7 @@ public class CompatHelper { public static ItemStack getItemBlockByState(ItemStack stack, BlockState state) { if (state == null) return ItemStack.EMPTY; - Item blockItem = Item.getItemFromBlock(state.getBlock()); + Item blockItem = Item.byBlock(state.getBlock()); if (stack.getItem() instanceof BlockItem) return stack; else if (stack.getItem() instanceof ItemRandomizerBag) { diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/RandomizerBagContainer.java b/src/main/java/nl/requios/effortlessbuilding/gui/RandomizerBagContainer.java index 0dc28f3..984d3bd 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/RandomizerBagContainer.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/RandomizerBagContainer.java @@ -59,34 +59,34 @@ public class RandomizerBagContainer extends Container { } @Override - public boolean canInteractWith(PlayerEntity playerIn) { + public boolean stillValid(PlayerEntity playerIn) { return true; } @Override public Slot getSlot(int parSlotIndex) { - if (parSlotIndex >= inventorySlots.size()) - parSlotIndex = inventorySlots.size() - 1; + if (parSlotIndex >= slots.size()) + parSlotIndex = slots.size() - 1; return super.getSlot(parSlotIndex); } @Override - public ItemStack transferStackInSlot(PlayerEntity playerIn, int slotIndex) { + public ItemStack quickMoveStack(PlayerEntity playerIn, int slotIndex) { ItemStack itemstack = ItemStack.EMPTY; - Slot slot = this.inventorySlots.get(slotIndex); + Slot slot = this.slots.get(slotIndex); - if (slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); + if (slot != null && slot.hasItem()) { + ItemStack itemstack1 = slot.getItem(); itemstack = itemstack1.copy(); // If item is in our custom inventory if (slotIndex < INV_START) { // try to place in player inventory / action bar - if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) { + if (!this.moveItemStackTo(itemstack1, INV_START, HOTBAR_END + 1, true)) { return ItemStack.EMPTY; } - slot.onSlotChange(itemstack1, itemstack); + slot.onQuickCraft(itemstack1, itemstack); } // Item is in inventory / hotbar, try to place in custom inventory or armor slots else { @@ -95,7 +95,7 @@ public class RandomizerBagContainer extends Container { */ if (slotIndex >= INV_START) { // place in custom inventory - if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) { + if (!this.moveItemStackTo(itemstack1, 0, INV_START, false)) { return ItemStack.EMPTY; } } @@ -103,9 +103,9 @@ public class RandomizerBagContainer extends Container { } if (itemstack1.getCount() == 0) { - slot.putStack(ItemStack.EMPTY); + slot.set(ItemStack.EMPTY); } else { - slot.onSlotChanged(); + slot.setChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { @@ -124,22 +124,22 @@ public class RandomizerBagContainer extends Container { * be able to save properly */ @Override - public ItemStack slotClick(int slot, int dragType, ClickType clickTypeIn, PlayerEntity player) { + public ItemStack clicked(int slot, int dragType, ClickType clickTypeIn, PlayerEntity player) { // this will prevent the player from interacting with the item that opened the inventory: - if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack().equals(player.getHeldItem(Hand.MAIN_HAND))) { + if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getItem().equals(player.getItemInHand(Hand.MAIN_HAND))) { return ItemStack.EMPTY; } - return super.slotClick(slot, dragType, clickTypeIn, player); + return super.clicked(slot, dragType, clickTypeIn, player); } /** * Callback for when the crafting gui is closed. */ @Override - public void onContainerClosed(PlayerEntity player) { - super.onContainerClosed(player); - if (!player.world.isRemote) { - detectAndSendChanges(); + public void removed(PlayerEntity player) { + super.removed(player); + if (!player.level.isClientSide) { + broadcastChanges(); } } } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/RandomizerBagScreen.java b/src/main/java/nl/requios/effortlessbuilding/gui/RandomizerBagScreen.java index f18b974..31b8cbb 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/RandomizerBagScreen.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/RandomizerBagScreen.java @@ -20,28 +20,28 @@ public class RandomizerBagScreen extends ContainerScreen public RandomizerBagScreen(RandomizerBagContainer randomizerBagContainer, PlayerInventory playerInventory, ITextComponent title) { super(randomizerBagContainer, playerInventory, title);//new TranslationTextComponent("effortlessbuilding.screen.randomizer_bag")); - ySize = 134; + imageHeight = 134; } @Override public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { renderBackground(ms); super.render(ms, mouseX, mouseY, partialTicks); - this.renderHoveredTooltip(ms, mouseX, mouseY); + this.renderTooltip(ms, mouseX, mouseY); } @Override - protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int mouseY) { - font.func_243246_a(ms, this.title, 8, 6, 0x404040); - font.func_243246_a(ms, playerInventory.getDisplayName(), 8, ySize - 96 + 2, 0x404040); + protected void renderLabels(MatrixStack ms, int mouseX, int mouseY) { + font.drawShadow(ms, this.title, 8, 6, 0x404040); + font.drawShadow(ms, inventory.getDisplayName(), 8, imageHeight - 96 + 2, 0x404040); } @Override - protected void drawGuiContainerBackgroundLayer(MatrixStack ms, float partialTicks, int mouseX, int mouseY) { + protected void renderBg(MatrixStack ms, float partialTicks, int mouseX, int mouseY) { RenderSystem.color3f(1.0F, 1.0F, 1.0F); - minecraft.getTextureManager().bindTexture(guiTextures); - int marginHorizontal = (width - xSize) / 2; - int marginVertical = (height - ySize) / 2; - blit(ms, marginHorizontal, marginVertical, 0, 0, xSize, ySize); + minecraft.getTextureManager().bind(guiTextures); + int marginHorizontal = (width - imageWidth) / 2; + int marginVertical = (height - imageHeight) / 2; + blit(ms, marginHorizontal, marginVertical, 0, 0, imageWidth, imageHeight); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/buildmode/PlayerSettingsGui.java b/src/main/java/nl/requios/effortlessbuilding/gui/buildmode/PlayerSettingsGui.java index 8af574a..dc7caf2 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/buildmode/PlayerSettingsGui.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/buildmode/PlayerSettingsGui.java @@ -62,7 +62,7 @@ public class PlayerSettingsGui extends Screen { }); addButton(slider); - closeButton = new ExtendedButton(left + 50, bottom - 20, 180, 20, new StringTextComponent("Done"), (button) -> this.minecraft.player.closeScreen()); + closeButton = new ExtendedButton(left + 50, bottom - 20, 180, 20, new StringTextComponent("Done"), (button) -> this.minecraft.player.closeContainer()); addButton(closeButton); } @@ -76,10 +76,10 @@ public class PlayerSettingsGui extends Screen { this.renderBackground(ms); int yy = top; - font.drawString(ms, "Shader type", left, yy + 5, 0xFFFFFF); + font.draw(ms, "Shader type", left, yy + 5, 0xFFFFFF); yy += 50; - font.drawString(ms, "Shader speed", left, yy + 5, 0xFFFFFF); + font.draw(ms, "Shader speed", left, yy + 5, 0xFFFFFF); super.render(ms, mouseX, mouseY, partialTicks); @@ -98,7 +98,7 @@ public class PlayerSettingsGui extends Screen { } @Override - public void onClose() { + public void removed() { ShaderTypeList.ShaderTypeEntry selectedShader = shaderTypeList.getSelected(); //TODO save and remove } @@ -149,7 +149,7 @@ public class PlayerSettingsGui extends Screen { @Override public void setSelected(PlayerSettingsGui.ShaderTypeList.ShaderTypeEntry selected) { super.setSelected(selected); - Minecraft.getInstance().getSoundHandler().play(SimpleSound.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + Minecraft.getInstance().getSoundManager().play(SimpleSound.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); EffortlessBuilding.log("Selected shader " + selected.shaderType.name); shaderTypeButton.setMessage(selected.shaderType.name); // showShaderList = false; @@ -186,7 +186,7 @@ public class PlayerSettingsGui extends Screen { } protected boolean isFocused() { - return PlayerSettingsGui.this.getListener() == this; + return PlayerSettingsGui.this.getFocused() == this; } @Override @@ -201,18 +201,18 @@ public class PlayerSettingsGui extends Screen { int i = this.getScrollbarPosition(); int j = i + 6; Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); + BufferBuilder bufferbuilder = tessellator.getBuilder(); // this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION); RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); float f = 32.0F; bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR); - bufferbuilder.pos(this.x0, this.y1, 0.0D).color(20, 20, 20, 180).endVertex(); - bufferbuilder.pos(this.x1, this.y1, 0.0D).color(20, 20, 20, 180).endVertex(); - bufferbuilder.pos(this.x1, this.y0, 0.0D).color(20, 20, 20, 180).endVertex(); - bufferbuilder.pos(this.x0, this.y0, 0.0D).color(20, 20, 20, 180).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(this.x0, this.y1, 0.0D).color(20, 20, 20, 180).endVertex(); + bufferbuilder.vertex(this.x1, this.y1, 0.0D).color(20, 20, 20, 180).endVertex(); + bufferbuilder.vertex(this.x1, this.y0, 0.0D).color(20, 20, 20, 180).endVertex(); + bufferbuilder.vertex(this.x0, this.y0, 0.0D).color(20, 20, 20, 180).endVertex(); + tessellator.end(); int k = this.getRowLeft(); int l = this.y0 + 4 - (int) this.getScrollAmount(); if (this.renderHeader) { @@ -253,23 +253,23 @@ public class PlayerSettingsGui extends Screen { } bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - bufferbuilder.pos(i, this.y1, 0.0D).tex(0.0F, 1.0F).color(0, 0, 0, 255).endVertex(); - bufferbuilder.pos(j, this.y1, 0.0D).tex(1.0F, 1.0F).color(0, 0, 0, 255).endVertex(); - bufferbuilder.pos(j, this.y0, 0.0D).tex(1.0F, 0.0F).color(0, 0, 0, 255).endVertex(); - bufferbuilder.pos(i, this.y0, 0.0D).tex(0.0F, 0.0F).color(0, 0, 0, 255).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(i, this.y1, 0.0D).uv(0.0F, 1.0F).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(j, this.y1, 0.0D).uv(1.0F, 1.0F).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(j, this.y0, 0.0D).uv(1.0F, 0.0F).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(i, this.y0, 0.0D).uv(0.0F, 0.0F).color(0, 0, 0, 255).endVertex(); + tessellator.end(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - bufferbuilder.pos(i, l1 + k1, 0.0D).tex(0.0F, 1.0F).color(128, 128, 128, 255).endVertex(); - bufferbuilder.pos(j, l1 + k1, 0.0D).tex(1.0F, 1.0F).color(128, 128, 128, 255).endVertex(); - bufferbuilder.pos(j, l1, 0.0D).tex(1.0F, 0.0F).color(128, 128, 128, 255).endVertex(); - bufferbuilder.pos(i, l1, 0.0D).tex(0.0F, 0.0F).color(128, 128, 128, 255).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(i, l1 + k1, 0.0D).uv(0.0F, 1.0F).color(128, 128, 128, 255).endVertex(); + bufferbuilder.vertex(j, l1 + k1, 0.0D).uv(1.0F, 1.0F).color(128, 128, 128, 255).endVertex(); + bufferbuilder.vertex(j, l1, 0.0D).uv(1.0F, 0.0F).color(128, 128, 128, 255).endVertex(); + bufferbuilder.vertex(i, l1, 0.0D).uv(0.0F, 0.0F).color(128, 128, 128, 255).endVertex(); + tessellator.end(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - bufferbuilder.pos(i, l1 + k1 - 1, 0.0D).tex(0.0F, 1.0F).color(192, 192, 192, 255).endVertex(); - bufferbuilder.pos(j - 1, l1 + k1 - 1, 0.0D).tex(1.0F, 1.0F).color(192, 192, 192, 255).endVertex(); - bufferbuilder.pos(j - 1, l1, 0.0D).tex(1.0F, 0.0F).color(192, 192, 192, 255).endVertex(); - bufferbuilder.pos(i, l1, 0.0D).tex(0.0F, 0.0F).color(192, 192, 192, 255).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(i, l1 + k1 - 1, 0.0D).uv(0.0F, 1.0F).color(192, 192, 192, 255).endVertex(); + bufferbuilder.vertex(j - 1, l1 + k1 - 1, 0.0D).uv(1.0F, 1.0F).color(192, 192, 192, 255).endVertex(); + bufferbuilder.vertex(j - 1, l1, 0.0D).uv(1.0F, 0.0F).color(192, 192, 192, 255).endVertex(); + bufferbuilder.vertex(i, l1, 0.0D).uv(0.0F, 0.0F).color(192, 192, 192, 255).endVertex(); + tessellator.end(); } // this.renderDecorations(p_render_1_, p_render_2_); diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/buildmode/RadialMenu.java b/src/main/java/nl/requios/effortlessbuilding/gui/buildmode/RadialMenu.java index 328d0b2..3af11d2 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/buildmode/RadialMenu.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/buildmode/RadialMenu.java @@ -30,6 +30,10 @@ import java.util.concurrent.TimeUnit; import static nl.requios.effortlessbuilding.buildmode.BuildModes.BuildModeEnum; import static nl.requios.effortlessbuilding.buildmode.ModeOptions.*; +import nl.requios.effortlessbuilding.buildmode.BuildModes.BuildModeEnum; +import nl.requios.effortlessbuilding.buildmode.ModeOptions.ActionEnum; +import nl.requios.effortlessbuilding.buildmode.ModeOptions.OptionEnum; + /** * From Chisels and Bits by AlgorithmX2 * https://github.com/AlgorithmX2/Chisels-and-Bits/blob/1.12/src/main/java/mod/chiselsandbits/client/gui/ChiselsAndBitsMenu.java @@ -75,7 +79,7 @@ public class RadialMenu extends Screen { public void configure(final int scaledWidth, final int scaledHeight) { Minecraft mc = Minecraft.getInstance(); - font = mc.fontRenderer; + font = mc.font; width = scaledWidth; height = scaledHeight; } @@ -100,7 +104,7 @@ public class RadialMenu extends Screen { RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); RenderSystem.shadeModel(GL11.GL_SMOOTH); final Tessellator tessellator = Tessellator.getInstance(); - final BufferBuilder buffer = tessellator.getBuffer(); + final BufferBuilder buffer = tessellator.getBuilder(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); @@ -110,8 +114,8 @@ public class RadialMenu extends Screen { //Fix for high def (retina) displays: use custom mouse coordinates //Borrowed from GameRenderer::updateCameraAndRender Minecraft mc = Minecraft.getInstance(); - int mouseXX = (int) (mc.mouseHelper.getMouseX() * (double) mc.getMainWindow().getScaledWidth() / (double) mc.getMainWindow().getWidth()); - int mouseYY = (int) (mc.mouseHelper.getMouseY() * (double) mc.getMainWindow().getScaledHeight() / (double) mc.getMainWindow().getHeight()); + int mouseXX = (int) (mc.mouseHandler.xpos() * (double) mc.getWindow().getGuiScaledWidth() / (double) mc.getWindow().getScreenWidth()); + int mouseYY = (int) (mc.mouseHandler.ypos() * (double) mc.getWindow().getGuiScaledHeight() / (double) mc.getWindow().getScreenHeight()); final double mouseXCenter = mouseXX - middleX; final double mouseYCenter = mouseYY - middleY; @@ -210,10 +214,10 @@ public class RadialMenu extends Screen { switchTo = menuRegion.mode; } - buffer.pos(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(r, g, b, a).endVertex(); - buffer.pos(middleX + x2m1, middleY + y2m1, getBlitOffset()).color(r, g, b, a).endVertex(); - buffer.pos(middleX + x2m2, middleY + y2m2, getBlitOffset()).color(r, g, b, a).endVertex(); - buffer.pos(middleX + x1m2, middleY + y1m2, getBlitOffset()).color(r, g, b, a).endVertex(); + buffer.vertex(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(r, g, b, a).endVertex(); + buffer.vertex(middleX + x2m1, middleY + y2m1, getBlitOffset()).color(r, g, b, a).endVertex(); + buffer.vertex(middleX + x2m2, middleY + y2m2, getBlitOffset()).color(r, g, b, a).endVertex(); + buffer.vertex(middleX + x1m2, middleY + y1m2, getBlitOffset()).color(r, g, b, a).endVertex(); currentMode++; } @@ -249,13 +253,13 @@ public class RadialMenu extends Screen { doAction = btn.action; } - buffer.pos(middleX + btn.x1, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex(); - buffer.pos(middleX + btn.x1, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex(); - buffer.pos(middleX + btn.x2, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex(); - buffer.pos(middleX + btn.x2, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex(); + buffer.vertex(middleX + btn.x1, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex(); + buffer.vertex(middleX + btn.x1, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex(); + buffer.vertex(middleX + btn.x2, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex(); + buffer.vertex(middleX + btn.x2, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex(); } - tessellator.draw(); + tessellator.end(); RenderSystem.shadeModel(GL11.GL_FLAT); @@ -264,7 +268,7 @@ public class RadialMenu extends Screen { RenderSystem.color3f(1f, 1f, 1f); RenderSystem.disableBlend(); RenderSystem.enableAlphaTest(); - mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); + mc.getTextureManager().bind(AtlasTexture.LOCATION_BLOCKS); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); @@ -289,10 +293,10 @@ public class RadialMenu extends Screen { final double v1 = 0; final double v2 = 16; - buffer.pos(middleX + x1, middleY + y1, getBlitOffset()).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex(); - buffer.pos(middleX + x1, middleY + y2, getBlitOffset()).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex(); - buffer.pos(middleX + x2, middleY + y2, getBlitOffset()).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex(); - buffer.pos(middleX + x2, middleY + y1, getBlitOffset()).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex(); + buffer.vertex(middleX + x1, middleY + y1, getBlitOffset()).uv(sprite.getU(u1), sprite.getV(v1)).color(f, f, f, a).endVertex(); + buffer.vertex(middleX + x1, middleY + y2, getBlitOffset()).uv(sprite.getU(u1), sprite.getV(v2)).color(f, f, f, a).endVertex(); + buffer.vertex(middleX + x2, middleY + y2, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(v2)).color(f, f, f, a).endVertex(); + buffer.vertex(middleX + x2, middleY + y1, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(v1)).color(f, f, f, a).endVertex(); } //Draw action icons @@ -315,13 +319,13 @@ public class RadialMenu extends Screen { final double btny1 = btnmiddleY - 8; final double btny2 = btnmiddleY + 8; - buffer.pos(middleX + btnx1, middleY + btny1, getBlitOffset()).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex(); - buffer.pos(middleX + btnx1, middleY + btny2, getBlitOffset()).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex(); - buffer.pos(middleX + btnx2, middleY + btny2, getBlitOffset()).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex(); - buffer.pos(middleX + btnx2, middleY + btny1, getBlitOffset()).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex(); + buffer.vertex(middleX + btnx1, middleY + btny1, getBlitOffset()).uv(sprite.getU(u1), sprite.getV(v1)).color(f, f, f, a).endVertex(); + buffer.vertex(middleX + btnx1, middleY + btny2, getBlitOffset()).uv(sprite.getU(u1), sprite.getV(v2)).color(f, f, f, a).endVertex(); + buffer.vertex(middleX + btnx2, middleY + btny2, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(v2)).color(f, f, f, a).endVertex(); + buffer.vertex(middleX + btnx2, middleY + btny1, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(v1)).color(f, f, f, a).endVertex(); } - tessellator.draw(); + tessellator.end(); //Draw strings //font.drawStringWithShadow("Actions", (int) (middleX - buttonDistance - 13) - font.getStringWidth("Actions") * 0.5f, (int) middleY - 38, 0xffffffff); @@ -329,11 +333,11 @@ public class RadialMenu extends Screen { //Draw option strings for (int i = 0; i < currentBuildMode.options.length; i++) { OptionEnum option = options[i]; - font.drawStringWithShadow(ms, I18n.format(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, 0xeeeeeeff); + font.drawShadow(ms, I18n.get(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, 0xeeeeeeff); } String credits = "Effortless Building"; - font.drawStringWithShadow(ms, credits, width - font.getStringWidth(credits) - 4, height - 10, 0x88888888); + font.drawShadow(ms, credits, width - font.width(credits) - 4, height - 10, 0x88888888); //Draw buildmode text for (final MenuRegion menuRegion : modes) { @@ -343,16 +347,16 @@ public class RadialMenu extends Screen { final double y = (menuRegion.y1 + menuRegion.y2) * 0.5; int fixed_x = (int) (x * textDistance); - final int fixed_y = (int) (y * textDistance) - font.FONT_HEIGHT / 2; - final String text = I18n.format(menuRegion.mode.name); + final int fixed_y = (int) (y * textDistance) - font.lineHeight / 2; + final String text = I18n.get(menuRegion.mode.name); if (x <= -0.2) { - fixed_x -= font.getStringWidth(text); + fixed_x -= font.width(text); } else if (-0.2 <= x && x <= 0.2) { - fixed_x -= font.getStringWidth(text) / 2; + fixed_x -= font.width(text) / 2; } - font.drawStringWithShadow(ms, text, (int) middleX + fixed_x, (int) middleY + fixed_y, 0xffffffff); + font.drawShadow(ms, text, (int) middleX + fixed_x, (int) middleY + fixed_y, 0xffffffff); } } @@ -366,22 +370,22 @@ public class RadialMenu extends Screen { //Add keybind in brackets if (button.action == ActionEnum.UNDO) { - keybind = I18n.format(ClientProxy.keyBindings[4].getTranslationKey()); + keybind = I18n.get(ClientProxy.keyBindings[4].saveString()); } if (button.action == ActionEnum.REDO) { - keybind = I18n.format(ClientProxy.keyBindings[5].getTranslationKey()); + keybind = I18n.get(ClientProxy.keyBindings[5].saveString()); } if (button.action == ActionEnum.REPLACE) { - keybind = I18n.format(ClientProxy.keyBindings[1].getTranslationKey()); + keybind = I18n.get(ClientProxy.keyBindings[1].saveString()); } if (button.action == ActionEnum.OPEN_MODIFIER_SETTINGS) { - keybind = I18n.format(ClientProxy.keyBindings[0].getTranslationKey()); + keybind = I18n.get(ClientProxy.keyBindings[0].saveString()); } if (currentBuildMode.options.length > 0) { //Add (ctrl) to first two actions of first option if (button.action == currentBuildMode.options[0].actions[0] || button.action == currentBuildMode.options[0].actions[1]) { - keybind = I18n.format(ClientProxy.keyBindings[6].getTranslationKey()); + keybind = I18n.get(ClientProxy.keyBindings[6].saveString()); if (keybind.equals("Left Control")) keybind = "Ctrl"; } } @@ -390,28 +394,28 @@ public class RadialMenu extends Screen { if (button.textSide == Direction.WEST) { - font.drawString(ms, text, (int) (middleX + button.x1 - 8) - font.getStringWidth(text), + font.draw(ms, text, (int) (middleX + button.x1 - 8) - font.width(text), (int) (middleY + button.y1 + 6), 0xffffffff); } else if (button.textSide == Direction.EAST) { - font.drawString(ms, text, (int) (middleX + button.x2 + 8), + font.draw(ms, text, (int) (middleX + button.x2 + 8), (int) (middleY + button.y1 + 6), 0xffffffff); } else if (button.textSide == Direction.UP || button.textSide == Direction.NORTH) { - font.drawString(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.getStringWidth(keybindFormatted) * 0.5), + font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5), (int) (middleY + button.y1 - 26), 0xffffffff); - font.drawString(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.getStringWidth(text) * 0.5), + font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5), (int) (middleY + button.y1 - 14), 0xffffffff); } else if (button.textSide == Direction.DOWN || button.textSide == Direction.SOUTH) { - font.drawString(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.getStringWidth(text) * 0.5), + font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5), (int) (middleY + button.y1 + 26), 0xffffffff); - font.drawString(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.getStringWidth(keybindFormatted) * 0.5), + font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5), (int) (middleY + button.y1 + 38), 0xffffffff); } @@ -441,14 +445,14 @@ public class RadialMenu extends Screen { public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) { EffortlessBuilding.log("mouse clicked"); - KeyBinding.updateKeyBindState(); - KeyBinding.setKeyBindState(ClientProxy.keyBindings[3].getKey(), true); + KeyBinding.setAll(); + KeyBinding.set(ClientProxy.keyBindings[3].getKey(), true); if (mouseButton == 0) { - this.minecraft.displayGuiScreen(null); + this.minecraft.setScreen(null); - if (this.minecraft.currentScreen == null) { - this.minecraft.setGameFocused(true); + if (this.minecraft.screen == null) { + this.minecraft.setWindowActive(true); } } return super.mouseClicked(mouseX, mouseY, mouseButton); @@ -465,7 +469,7 @@ public class RadialMenu extends Screen { public MenuButton(final String name, final ActionEnum action, final double x, final double y, final Direction textSide) { - this.name = I18n.format(name); + this.name = I18n.get(name); this.action = action; x1 = x - 10; x2 = x + 10; diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ArraySettingsGui.java b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ArraySettingsGui.java index 52c848a..24672f1 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ArraySettingsGui.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ArraySettingsGui.java @@ -94,31 +94,31 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry { buttonArrayEnabled.render(ms, mouseX, mouseY, partialTicks); if (buttonArrayEnabled.isChecked()) { buttonArrayEnabled.y = yy; - font.drawString(ms, "Array enabled", left + offset, yy + 2, 0xFFFFFF); + font.draw(ms, "Array enabled", left + offset, yy + 2, 0xFFFFFF); yy = y + 20; - font.drawString(ms, "Offset", left + offset, yy + 5, 0xFFFFFF); - font.drawString(ms, "X", left + 50 + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "Offset", left + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "X", left + 50 + offset, yy + 5, 0xFFFFFF); textArrayOffsetX.y = yy; - font.drawString(ms, "Y", left + 120 + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "Y", left + 120 + offset, yy + 5, 0xFFFFFF); textArrayOffsetY.y = yy; - font.drawString(ms, "Z", left + 190 + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "Z", left + 190 + offset, yy + 5, 0xFFFFFF); textArrayOffsetZ.y = yy; yy = y + 50; - font.drawString(ms, "Count", left + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "Count", left + offset, yy + 5, 0xFFFFFF); textArrayCount.y = yy; int currentReach = Math.max(-1, getArrayReach()); int maxReach = ReachHelper.getMaxReach(mc.player); TextFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? TextFormatting.GRAY : TextFormatting.RED; String reachText = "Reach: " + reachColor + currentReach + TextFormatting.GRAY + "/" + TextFormatting.GRAY + maxReach; - font.drawString(ms, reachText, left + 176 + offset, yy + 5, 0xFFFFFF); + font.draw(ms, reachText, left + 176 + offset, yy + 5, 0xFFFFFF); arrayNumberFieldList.forEach(numberField -> numberField.drawNumberField(ms, mouseX, mouseY, partialTicks)); } else { buttonArrayEnabled.y = yy; - font.drawString(ms, "Array disabled", left + offset, yy + 2, 0x999999); + font.draw(ms, "Array disabled", left + offset, yy + 2, 0x999999); } } @@ -146,7 +146,7 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry { boolean insideArrayEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12; if (insideArrayEnabledLabel) { - buttonArrayEnabled.playDownSound(this.mc.getSoundHandler()); + buttonArrayEnabled.playDownSound(this.mc.getSoundManager()); buttonArrayEnabled.onClick(mouseX, mouseY); } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/MirrorSettingsGui.java b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/MirrorSettingsGui.java index 4102ed7..e7df163 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/MirrorSettingsGui.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/MirrorSettingsGui.java @@ -57,17 +57,17 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry { textMirrorPosX = new GuiNumberField(font, buttonList, left + 58, y, 62, 18); textMirrorPosX.setNumber(0); textMirrorPosX.setTooltip( - Arrays.asList(new StringTextComponent("The position of the mirror."), new StringTextComponent("For odd numbered builds add 0.5.").mergeStyle(TextFormatting.GRAY))); + Arrays.asList(new StringTextComponent("The position of the mirror."), new StringTextComponent("For odd numbered builds add 0.5.").withStyle(TextFormatting.GRAY))); mirrorNumberFieldList.add(textMirrorPosX); textMirrorPosY = new GuiNumberField(font, buttonList, left + 138, y, 62, 18); textMirrorPosY.setNumber(64); - textMirrorPosY.setTooltip(Arrays.asList(new StringTextComponent("The position of the mirror."), new StringTextComponent("For odd numbered builds add 0.5.").mergeStyle(TextFormatting.GRAY))); + textMirrorPosY.setTooltip(Arrays.asList(new StringTextComponent("The position of the mirror."), new StringTextComponent("For odd numbered builds add 0.5.").withStyle(TextFormatting.GRAY))); mirrorNumberFieldList.add(textMirrorPosY); textMirrorPosZ = new GuiNumberField(font, buttonList, left + 218, y, 62, 18); textMirrorPosZ.setNumber(0); - textMirrorPosZ.setTooltip(Arrays.asList(new StringTextComponent("The position of the mirror."), new StringTextComponent("For odd numbered builds add 0.5.").mergeStyle(TextFormatting.GRAY))); + textMirrorPosZ.setTooltip(Arrays.asList(new StringTextComponent("The position of the mirror."), new StringTextComponent("For odd numbered builds add 0.5.").withStyle(TextFormatting.GRAY))); mirrorNumberFieldList.add(textMirrorPosZ); y = top + 50; @@ -85,13 +85,13 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry { textMirrorRadius.setNumber(50); //TODO change to diameter (remove /2) textMirrorRadius.setTooltip(Arrays.asList(new StringTextComponent("How far the mirror reaches in any direction."), - new StringTextComponent("Max: ").mergeStyle(TextFormatting.GRAY).append(new StringTextComponent(String.valueOf(ReachHelper.getMaxReach(mc.player) / 2)).mergeStyle(TextFormatting.GOLD)), - new StringTextComponent("Upgradeable in survival with reach upgrades.").mergeStyle(TextFormatting.GRAY))); + new StringTextComponent("Max: ").withStyle(TextFormatting.GRAY).append(new StringTextComponent(String.valueOf(ReachHelper.getMaxReach(mc.player) / 2)).withStyle(TextFormatting.GOLD)), + new StringTextComponent("Upgradeable in survival with reach upgrades.").withStyle(TextFormatting.GRAY))); mirrorNumberFieldList.add(textMirrorRadius); y = top + 72; buttonCurrentPosition = new GuiIconButton(left + 5, y, 0, 0, BUILDING_ICONS, button -> { - Vector3d pos = new Vector3d(Math.floor(mc.player.getPosX()) + 0.5, Math.floor(mc.player.getPosY()) + 0.5, Math.floor(mc.player.getPosZ()) + 0.5); + Vector3d pos = new Vector3d(Math.floor(mc.player.getX()) + 0.5, Math.floor(mc.player.getY()) + 0.5, Math.floor(mc.player.getZ()) + 0.5); textMirrorPosX.setNumber(pos.x); textMirrorPosY.setNumber(pos.y); textMirrorPosZ.setNumber(pos.z); @@ -182,23 +182,23 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry { buttonMirrorEnabled.render(ms, mouseX, mouseY, partialTicks); if (buttonMirrorEnabled.isChecked()) { buttonMirrorEnabled.y = yy; - font.drawString(ms, "Mirror enabled", left + offset, yy + 2, 0xFFFFFF); + font.draw(ms, "Mirror enabled", left + offset, yy + 2, 0xFFFFFF); yy = y + 18; - font.drawString(ms, "Position", left + offset, yy + 5, 0xFFFFFF); - font.drawString(ms, "X", left + 40 + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "Position", left + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "X", left + 40 + offset, yy + 5, 0xFFFFFF); textMirrorPosX.y = yy; - font.drawString(ms, "Y", left + 120 + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "Y", left + 120 + offset, yy + 5, 0xFFFFFF); textMirrorPosY.y = yy; - font.drawString(ms, "Z", left + 200 + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "Z", left + 200 + offset, yy + 5, 0xFFFFFF); textMirrorPosZ.y = yy; yy = y + 50; - font.drawString(ms, "Direction", left + offset, yy + 2, 0xFFFFFF); + font.draw(ms, "Direction", left + offset, yy + 2, 0xFFFFFF); buttonMirrorX.y = yy; buttonMirrorY.y = yy; buttonMirrorZ.y = yy; - font.drawString(ms, "Radius", left + 176 + offset, yy + 2, 0xFFFFFF); + font.draw(ms, "Radius", left + 176 + offset, yy + 2, 0xFFFFFF); textMirrorRadius.y = yy - 3; yy = y + 72; @@ -212,7 +212,7 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry { mirrorNumberFieldList.forEach(numberField -> numberField.drawNumberField(ms, mouseX, mouseY, partialTicks)); } else { buttonMirrorEnabled.y = yy; - font.drawString(ms, "Mirror disabled", left + offset, yy + 2, 0x999999); + font.draw(ms, "Mirror disabled", left + offset, yy + 2, 0x999999); } } @@ -241,7 +241,7 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry { boolean insideMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12; if (insideMirrorEnabledLabel) { - buttonMirrorEnabled.playDownSound(this.mc.getSoundHandler()); + buttonMirrorEnabled.playDownSound(this.mc.getSoundManager()); buttonMirrorEnabled.onClick(mouseX, mouseY); } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ModifierSettingsGui.java b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ModifierSettingsGui.java index 450e03c..35710d0 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ModifierSettingsGui.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ModifierSettingsGui.java @@ -51,7 +51,7 @@ public class ModifierSettingsGui extends Screen { //Close button int y = height - 26; buttonClose = new Button(width / 2 - 100, y, 200, 20, new StringTextComponent("Close"), (button) -> { - Minecraft.getInstance().player.closeScreen(); + Minecraft.getInstance().player.closeContainer(); }); buttons.add(buttonClose); } @@ -82,8 +82,8 @@ public class ModifierSettingsGui extends Screen { public boolean charTyped(char typedChar, int keyCode) { super.charTyped(typedChar, keyCode); scrollPane.charTyped(typedChar, keyCode); - if (keyCode == ClientProxy.keyBindings[0].getKey().getKeyCode()) { - minecraft.player.closeScreen(); + if (keyCode == ClientProxy.keyBindings[0].getKey().getValue()) { + minecraft.player.closeContainer(); } return false; } @@ -114,7 +114,7 @@ public class ModifierSettingsGui extends Screen { } @Override - public void onClose() { + public void removed() { scrollPane.onGuiClosed(); //save everything @@ -137,7 +137,7 @@ public class ModifierSettingsGui extends Screen { //Send to server PacketHandler.INSTANCE.sendToServer(new ModifierSettingsMessage(modifierSettings)); - Minecraft.getInstance().mouseHelper.grabMouse(); + Minecraft.getInstance().mouseHandler.grabMouse(); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/RadialMirrorSettingsGui.java b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/RadialMirrorSettingsGui.java index bc3a7c9..7392fbc 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/RadialMirrorSettingsGui.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/RadialMirrorSettingsGui.java @@ -57,36 +57,36 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry { textRadialMirrorPosX = new GuiNumberField(font, buttonList, left + 58, y, 62, 18); textRadialMirrorPosX.setNumber(0); textRadialMirrorPosX.setTooltip( - Arrays.asList(new StringTextComponent("The position of the radial mirror."), new StringTextComponent("For odd numbered builds add 0.5.").mergeStyle(TextFormatting.GRAY))); + Arrays.asList(new StringTextComponent("The position of the radial mirror."), new StringTextComponent("For odd numbered builds add 0.5.").withStyle(TextFormatting.GRAY))); radialMirrorNumberFieldList.add(textRadialMirrorPosX); textRadialMirrorPosY = new GuiNumberField(font, buttonList, left + 138, y, 62, 18); textRadialMirrorPosY.setNumber(64); - textRadialMirrorPosY.setTooltip(Arrays.asList(new StringTextComponent("The position of the radial mirror."), new StringTextComponent("For odd numbered builds add 0.5.").mergeStyle(TextFormatting.GRAY))); + textRadialMirrorPosY.setTooltip(Arrays.asList(new StringTextComponent("The position of the radial mirror."), new StringTextComponent("For odd numbered builds add 0.5.").withStyle(TextFormatting.GRAY))); radialMirrorNumberFieldList.add(textRadialMirrorPosY); textRadialMirrorPosZ = new GuiNumberField(font, buttonList, left + 218, y, 62, 18); textRadialMirrorPosZ.setNumber(0); - textRadialMirrorPosZ.setTooltip(Arrays.asList(new StringTextComponent("The position of the radial mirror."), new StringTextComponent("For odd numbered builds add 0.5.").mergeStyle(TextFormatting.GRAY))); + textRadialMirrorPosZ.setTooltip(Arrays.asList(new StringTextComponent("The position of the radial mirror."), new StringTextComponent("For odd numbered builds add 0.5.").withStyle(TextFormatting.GRAY))); radialMirrorNumberFieldList.add(textRadialMirrorPosZ); y = top + 47; textRadialMirrorSlices = new GuiNumberField(font, buttonList, left + 55, y, 50, 18); textRadialMirrorSlices.setNumber(4); - textRadialMirrorSlices.setTooltip(Arrays.asList(new StringTextComponent("The number of repeating slices."), new StringTextComponent("Minimally 2.").mergeStyle(TextFormatting.GRAY))); + textRadialMirrorSlices.setTooltip(Arrays.asList(new StringTextComponent("The number of repeating slices."), new StringTextComponent("Minimally 2.").withStyle(TextFormatting.GRAY))); radialMirrorNumberFieldList.add(textRadialMirrorSlices); textRadialMirrorRadius = new GuiNumberField(font, buttonList, left + 218, y, 62, 18); textRadialMirrorRadius.setNumber(50); //TODO change to diameter (remove /2) textRadialMirrorRadius.setTooltip(Arrays.asList(new StringTextComponent("How far the radial mirror reaches from its center position."), - new StringTextComponent("Max: ").mergeStyle(TextFormatting.GRAY).append(new StringTextComponent(String.valueOf(ReachHelper.getMaxReach(mc.player) / 2)).mergeStyle(TextFormatting.GOLD)), - new StringTextComponent("Upgradeable in survival with reach upgrades.").mergeStyle(TextFormatting.GRAY))); + new StringTextComponent("Max: ").withStyle(TextFormatting.GRAY).append(new StringTextComponent(String.valueOf(ReachHelper.getMaxReach(mc.player) / 2)).withStyle(TextFormatting.GOLD)), + new StringTextComponent("Upgradeable in survival with reach upgrades.").withStyle(TextFormatting.GRAY))); radialMirrorNumberFieldList.add(textRadialMirrorRadius); y = top + 72; buttonCurrentPosition = new GuiIconButton(left + 5, y, 0, 0, BUILDING_ICONS, button -> { - Vector3d pos = new Vector3d(Math.floor(mc.player.getPosX()) + 0.5, Math.floor(mc.player.getPosY()) + 0.5, Math.floor(mc.player.getPosZ()) + 0.5); + Vector3d pos = new Vector3d(Math.floor(mc.player.getX()) + 0.5, Math.floor(mc.player.getY()) + 0.5, Math.floor(mc.player.getZ()) + 0.5); textRadialMirrorPosX.setNumber(pos.x); textRadialMirrorPosY.setNumber(pos.y); textRadialMirrorPosZ.setNumber(pos.z); @@ -179,21 +179,21 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry { buttonRadialMirrorEnabled.render(ms, mouseX, mouseY, partialTicks); if (buttonRadialMirrorEnabled.isChecked()) { buttonRadialMirrorEnabled.y = yy; - font.drawString(ms, "Radial mirror enabled", left + offset, yy + 2, 0xFFFFFF); + font.draw(ms, "Radial mirror enabled", left + offset, yy + 2, 0xFFFFFF); yy = y + 18; - font.drawString(ms, "Position", left + offset, yy + 5, 0xFFFFFF); - font.drawString(ms, "X", left + 40 + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "Position", left + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "X", left + 40 + offset, yy + 5, 0xFFFFFF); textRadialMirrorPosX.y = yy; - font.drawString(ms, "Y", left + 120 + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "Y", left + 120 + offset, yy + 5, 0xFFFFFF); textRadialMirrorPosY.y = yy; - font.drawString(ms, "Z", left + 200 + offset, yy + 5, 0xFFFFFF); + font.draw(ms, "Z", left + 200 + offset, yy + 5, 0xFFFFFF); textRadialMirrorPosZ.y = yy; yy = y + 50; - font.drawString(ms, "Slices", left + offset, yy + 2, 0xFFFFFF); + font.draw(ms, "Slices", left + offset, yy + 2, 0xFFFFFF); textRadialMirrorSlices.y = yy - 3; - font.drawString(ms, "Radius", left + 176 + offset, yy + 2, 0xFFFFFF); + font.draw(ms, "Radius", left + 176 + offset, yy + 2, 0xFFFFFF); textRadialMirrorRadius.y = yy - 3; yy = y + 72; @@ -211,7 +211,7 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry { .forEach(numberField -> numberField.drawNumberField(ms, mouseX, mouseY, partialTicks)); } else { buttonRadialMirrorEnabled.y = yy; - font.drawString(ms, "Radial mirror disabled", left + offset, yy + 2, 0x999999); + font.draw(ms, "Radial mirror disabled", left + offset, yy + 2, 0x999999); } } @@ -240,7 +240,7 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry { boolean insideRadialMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12; if (insideRadialMirrorEnabledLabel) { - buttonRadialMirrorEnabled.playDownSound(this.mc.getSoundHandler()); + buttonRadialMirrorEnabled.playDownSound(this.mc.getSoundManager()); buttonRadialMirrorEnabled.onClick(mouseX, mouseY); } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiCheckBoxFixed.java b/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiCheckBoxFixed.java index 1ceedce..898b011 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiCheckBoxFixed.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiCheckBoxFixed.java @@ -17,12 +17,12 @@ public class GuiCheckBoxFixed extends Button { private boolean isChecked; public GuiCheckBoxFixed(int xPos, int yPos, String displayString, boolean isChecked) { - super(xPos, yPos, Minecraft.getInstance().fontRenderer.getStringWidth(displayString) + 2 + 11, 11, new StringTextComponent(displayString), b -> { + super(xPos, yPos, Minecraft.getInstance().font.width(displayString) + 2 + 11, 11, new StringTextComponent(displayString), b -> { }); this.isChecked = isChecked; this.boxWidth = 11; this.height = 11; - this.width = this.boxWidth + 2 + Minecraft.getInstance().fontRenderer.getStringWidth(displayString); + this.width = this.boxWidth + 2 + Minecraft.getInstance().font.width(displayString); } @Override @@ -41,9 +41,9 @@ public class GuiCheckBoxFixed extends Button { } if (this.isChecked) - drawCenteredString(ms, mc.fontRenderer, "x", this.x + this.boxWidth / 2 + 1, this.y + 1, 14737632); + drawCenteredString(ms, mc.font, "x", this.x + this.boxWidth / 2 + 1, this.y + 1, 14737632); - drawString(ms, mc.fontRenderer, getMessage(), this.x + this.boxWidth + 2, this.y + 2, color); + drawString(ms, mc.font, getMessage(), this.x + this.boxWidth + 2, this.y + 2, color); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiIconButton.java b/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiIconButton.java index a13c5b4..32f36f3 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiIconButton.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiIconButton.java @@ -56,7 +56,7 @@ public class GuiIconButton extends Button { super.render(ms, mouseX, mouseY, partialTicks); if (this.visible) { this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; - Minecraft.getInstance().getTextureManager().bindTexture(this.resourceLocation); + Minecraft.getInstance().getTextureManager().bind(this.resourceLocation); int currentIconX = this.iconX; int currentIconY = this.iconY; @@ -74,7 +74,7 @@ public class GuiIconButton extends Button { boolean flag = mouseX >= x && mouseX < x + width && mouseY >= y && mouseY < y + height; if (flag) { - screen.func_243308_b(ms, tooltip, mouseX - 10, mouseY + 25); + screen.renderComponentTooltip(ms, tooltip, mouseX - 10, mouseY + 25); } } } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiNumberField.java b/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiNumberField.java index d1a4806..f5b47c8 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiNumberField.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiNumberField.java @@ -61,16 +61,16 @@ public class GuiNumberField extends AbstractGui { } public double getNumber() { - if (textField.getText().isEmpty()) return 0; + if (textField.getValue().isEmpty()) return 0; try { - return DecimalFormat.getInstance().parse(textField.getText()).doubleValue(); + return DecimalFormat.getInstance().parse(textField.getValue()).doubleValue(); } catch (ParseException e) { return 0; } } public void setNumber(double number) { - textField.setText(DecimalFormat.getInstance().format(number)); + textField.setValue(DecimalFormat.getInstance().format(number)); } public void setTooltip(ITextComponent tooltip) { @@ -89,8 +89,8 @@ public class GuiNumberField extends AbstractGui { //Rightclicked inside textfield if (flag && mouseButton == 1) { - textField.setText(""); - textField.setFocused2(true); + textField.setValue(""); + textField.setFocus(true); result = true; } @@ -123,20 +123,20 @@ public class GuiNumberField extends AbstractGui { } if (insideMinusButton) { - textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("shift ").mergeStyle(TextFormatting.AQUA)).appendString("for ") - .append(new StringTextComponent("10").mergeStyle(TextFormatting.RED))); - textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("ctrl ").mergeStyle(TextFormatting.AQUA)).appendString("for ") - .append(new StringTextComponent("5").mergeStyle(TextFormatting.RED))); + textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("shift ").withStyle(TextFormatting.AQUA)).append("for ") + .append(new StringTextComponent("10").withStyle(TextFormatting.RED))); + textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("ctrl ").withStyle(TextFormatting.AQUA)).append("for ") + .append(new StringTextComponent("5").withStyle(TextFormatting.RED))); } if (insidePlusButton) { - textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("shift ").mergeStyle(TextFormatting.DARK_GREEN)).appendString("for ") - .append(new StringTextComponent("10").mergeStyle(TextFormatting.RED))); - textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("ctrl ").mergeStyle(TextFormatting.DARK_GREEN)).appendString("for ") - .append(new StringTextComponent("5").mergeStyle(TextFormatting.RED))); + textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("shift ").withStyle(TextFormatting.DARK_GREEN)).append("for ") + .append(new StringTextComponent("10").withStyle(TextFormatting.RED))); + textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("ctrl ").withStyle(TextFormatting.DARK_GREEN)).append("for ") + .append(new StringTextComponent("5").withStyle(TextFormatting.RED))); } - screen.func_243308_b(ms, textLines, mouseX - 10, mouseY + 25); + screen.renderComponentTooltip(ms, textLines, mouseX - 10, mouseY + 25); } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiScrollPane.java b/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiScrollPane.java index 737f0f0..51b843f 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiScrollPane.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/elements/GuiScrollPane.java @@ -84,7 +84,7 @@ public class GuiScrollPane extends SlotGui { this.capYPosition(); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); + BufferBuilder bufferbuilder = tessellator.getBuilder(); int insideLeft = this.x0 + this.width / 2 - this.getRowWidth() / 2 + 2; int insideTop = this.y0 + 4 - (int) this.yo; @@ -133,23 +133,23 @@ public class GuiScrollPane extends SlotGui { } bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - bufferbuilder.pos(scrollbarLeft, this.y1, 0.0F).tex(0.0F, 1.0F).color(0, 0, 0, 255).endVertex(); - bufferbuilder.pos(scrollbarRight, this.y1, 0.0F).tex(1.0F, 1.0F).color(0, 0, 0, 255).endVertex(); - bufferbuilder.pos(scrollbarRight, this.y0, 0.0F).tex(1.0F, 0.0F).color(0, 0, 0, 255).endVertex(); - bufferbuilder.pos(scrollbarLeft, this.y0, 0.0F).tex(0.0F, 0.0F).color(0, 0, 0, 255).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(scrollbarLeft, this.y1, 0.0F).uv(0.0F, 1.0F).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(scrollbarRight, this.y1, 0.0F).uv(1.0F, 1.0F).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(scrollbarRight, this.y0, 0.0F).uv(1.0F, 0.0F).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(scrollbarLeft, this.y0, 0.0F).uv(0.0F, 0.0F).color(0, 0, 0, 255).endVertex(); + tessellator.end(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - bufferbuilder.pos(scrollbarLeft, l1 + k1, 0.0F).tex(0.0F, 1.0F).color(128, 128, 128, 255).endVertex(); - bufferbuilder.pos(scrollbarRight, l1 + k1, 0.0F).tex(1.0F, 1.0F).color(128, 128, 128, 255).endVertex(); - bufferbuilder.pos(scrollbarRight, l1, 0.0F).tex(1.0F, 0.0F).color(128, 128, 128, 255).endVertex(); - bufferbuilder.pos(scrollbarLeft, l1, 0.0F).tex(0.0F, 0.0F).color(128, 128, 128, 255).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(scrollbarLeft, l1 + k1, 0.0F).uv(0.0F, 1.0F).color(128, 128, 128, 255).endVertex(); + bufferbuilder.vertex(scrollbarRight, l1 + k1, 0.0F).uv(1.0F, 1.0F).color(128, 128, 128, 255).endVertex(); + bufferbuilder.vertex(scrollbarRight, l1, 0.0F).uv(1.0F, 0.0F).color(128, 128, 128, 255).endVertex(); + bufferbuilder.vertex(scrollbarLeft, l1, 0.0F).uv(0.0F, 0.0F).color(128, 128, 128, 255).endVertex(); + tessellator.end(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - bufferbuilder.pos(scrollbarLeft, l1 + k1 - 1, 0.0F).tex(0.0F, 1.0F).color(192, 192, 192, 255).endVertex(); - bufferbuilder.pos(scrollbarRight - 1, l1 + k1 - 1, 0.0F).tex(1.0F, 1.0F).color(192, 192, 192, 255).endVertex(); - bufferbuilder.pos(scrollbarRight - 1, l1, 0.0F).tex(1.0F, 0.0F).color(192, 192, 192, 255).endVertex(); - bufferbuilder.pos(scrollbarLeft, l1, 0.0F).tex(0.0F, 0.0F).color(192, 192, 192, 255).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(scrollbarLeft, l1 + k1 - 1, 0.0F).uv(0.0F, 1.0F).color(192, 192, 192, 255).endVertex(); + bufferbuilder.vertex(scrollbarRight - 1, l1 + k1 - 1, 0.0F).uv(1.0F, 1.0F).color(192, 192, 192, 255).endVertex(); + bufferbuilder.vertex(scrollbarRight - 1, l1, 0.0F).uv(1.0F, 0.0F).color(192, 192, 192, 255).endVertex(); + bufferbuilder.vertex(scrollbarLeft, l1, 0.0F).uv(0.0F, 0.0F).color(192, 192, 192, 255).endVertex(); + tessellator.end(); } //this.renderDecorations(mouseXIn, mouseYIn); @@ -210,7 +210,7 @@ public class GuiScrollPane extends SlotGui { } @Override - public List getEventListeners() { + public List children() { return null; } @@ -260,7 +260,7 @@ public class GuiScrollPane extends SlotGui { public void handleMouseInput() { if (this.isMouseInList(this.mouseX, this.mouseY)) { - if (minecraft.mouseHelper.isLeftDown() && this.mouseY >= this.y0 && + if (minecraft.mouseHandler.isLeftPressed() && this.mouseY >= this.y0 && this.mouseY <= this.y1) { int i = this.x0 + (this.width - this.getRowWidth()) / 2; int j = this.x0 + (this.width + this.getRowWidth()) / 2; @@ -274,7 +274,7 @@ public class GuiScrollPane extends SlotGui { } } - if (minecraft.mouseHelper.isLeftDown() && this.isVisible()) { + if (minecraft.mouseHandler.isLeftPressed() && this.isVisible()) { if (this.yDrag == -1) { boolean flag1 = true; @@ -335,7 +335,7 @@ public class GuiScrollPane extends SlotGui { protected void renderList(MatrixStack ms, int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks) { int itemCount = this.getItemCount(); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); + BufferBuilder bufferbuilder = tessellator.getBuilder(); //Find y to start with int y = this.headerHeight + insideTop; @@ -363,18 +363,18 @@ public class GuiScrollPane extends SlotGui { float f = this.isFocused() ? 1.0F : 0.5F; RenderSystem.color4f(f, f, f, 1.0F); bufferbuilder.begin(7, DefaultVertexFormats.POSITION); - bufferbuilder.pos(i1, y + entryHeight2 + 2, 0.0D).endVertex(); - bufferbuilder.pos(j1, y + entryHeight2 + 2, 0.0D).endVertex(); - bufferbuilder.pos(j1, y - 2, 0.0D).endVertex(); - bufferbuilder.pos(i1, y - 2, 0.0D).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(i1, y + entryHeight2 + 2, 0.0D).endVertex(); + bufferbuilder.vertex(j1, y + entryHeight2 + 2, 0.0D).endVertex(); + bufferbuilder.vertex(j1, y - 2, 0.0D).endVertex(); + bufferbuilder.vertex(i1, y - 2, 0.0D).endVertex(); + tessellator.end(); RenderSystem.color4f(0.0F, 0.0F, 0.0F, 1.0F); bufferbuilder.begin(7, DefaultVertexFormats.POSITION); - bufferbuilder.pos(i1 + 1, y + entryHeight2 + 1, 0.0D).endVertex(); - bufferbuilder.pos(j1 - 1, y + entryHeight2 + 1, 0.0D).endVertex(); - bufferbuilder.pos(j1 - 1, y - 1, 0.0D).endVertex(); - bufferbuilder.pos(i1 + 1, y - 1, 0.0D).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(i1 + 1, y + entryHeight2 + 1, 0.0D).endVertex(); + bufferbuilder.vertex(j1 - 1, y + entryHeight2 + 1, 0.0D).endVertex(); + bufferbuilder.vertex(j1 - 1, y - 1, 0.0D).endVertex(); + bufferbuilder.vertex(i1 + 1, y - 1, 0.0D).endVertex(); + tessellator.end(); RenderSystem.enableTexture(); } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/elements/SlotGui.java b/src/main/java/nl/requios/effortlessbuilding/gui/elements/SlotGui.java index 20dda55..e1c5b73 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/elements/SlotGui.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/elements/SlotGui.java @@ -122,7 +122,7 @@ public abstract class SlotGui extends FocusableGui implements IRenderable { return true; } else if (i != -1 && this.selectItem(i, p_mouseClicked_5_, p_mouseClicked_1_, p_mouseClicked_3_)) { if (this.children().size() > i) { - this.setListener(this.children().get(i)); + this.setFocused(this.children().get(i)); } this.setDragging(true); @@ -136,8 +136,8 @@ public abstract class SlotGui extends FocusableGui implements IRenderable { } public boolean mouseReleased(double p_mouseReleased_1_, double p_mouseReleased_3_, int p_mouseReleased_5_) { - if (this.getListener() != null) { - this.getListener().mouseReleased(p_mouseReleased_1_, p_mouseReleased_3_, p_mouseReleased_5_); + if (this.getFocused() != null) { + this.getFocused().mouseReleased(p_mouseReleased_1_, p_mouseReleased_3_, p_mouseReleased_5_); } return false; @@ -217,7 +217,7 @@ public abstract class SlotGui extends FocusableGui implements IRenderable { protected void renderList(MatrixStack ms, int p_renderList_1_, int p_renderList_2_, int p_renderList_3_, int p_renderList_4_, float p_renderList_5_) { int i = this.getItemCount(); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); + BufferBuilder bufferbuilder = tessellator.getBuilder(); for (int j = 0; j < i; ++j) { int k = p_renderList_2_ + j * this.itemHeight + this.headerHeight; @@ -233,18 +233,18 @@ public abstract class SlotGui extends FocusableGui implements IRenderable { float f = this.isFocused() ? 1.0F : 0.5F; RenderSystem.color4f(f, f, f, 1.0F); bufferbuilder.begin(7, DefaultVertexFormats.POSITION); - bufferbuilder.pos(i1, k + l + 2, 0.0D).endVertex(); - bufferbuilder.pos(j1, k + l + 2, 0.0D).endVertex(); - bufferbuilder.pos(j1, k - 2, 0.0D).endVertex(); - bufferbuilder.pos(i1, k - 2, 0.0D).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(i1, k + l + 2, 0.0D).endVertex(); + bufferbuilder.vertex(j1, k + l + 2, 0.0D).endVertex(); + bufferbuilder.vertex(j1, k - 2, 0.0D).endVertex(); + bufferbuilder.vertex(i1, k - 2, 0.0D).endVertex(); + tessellator.end(); RenderSystem.color4f(0.0F, 0.0F, 0.0F, 1.0F); bufferbuilder.begin(7, DefaultVertexFormats.POSITION); - bufferbuilder.pos(i1 + 1, k + l + 1, 0.0D).endVertex(); - bufferbuilder.pos(j1 - 1, k + l + 1, 0.0D).endVertex(); - bufferbuilder.pos(j1 - 1, k - 1, 0.0D).endVertex(); - bufferbuilder.pos(i1 + 1, k - 1, 0.0D).endVertex(); - tessellator.draw(); + bufferbuilder.vertex(i1 + 1, k + l + 1, 0.0D).endVertex(); + bufferbuilder.vertex(j1 - 1, k + l + 1, 0.0D).endVertex(); + bufferbuilder.vertex(j1 - 1, k - 1, 0.0D).endVertex(); + bufferbuilder.vertex(i1 + 1, k - 1, 0.0D).endVertex(); + tessellator.end(); RenderSystem.enableTexture(); } diff --git a/src/main/java/nl/requios/effortlessbuilding/helper/InventoryHelper.java b/src/main/java/nl/requios/effortlessbuilding/helper/InventoryHelper.java index 34989ff..d4fb158 100644 --- a/src/main/java/nl/requios/effortlessbuilding/helper/InventoryHelper.java +++ b/src/main/java/nl/requios/effortlessbuilding/helper/InventoryHelper.java @@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack; public class InventoryHelper { public static ItemStack findItemStackInInventory(PlayerEntity player, Block block) { - for (ItemStack invStack : player.inventory.mainInventory) { + for (ItemStack invStack : player.inventory.items) { if (!invStack.isEmpty() && invStack.getItem() instanceof BlockItem && ((BlockItem) invStack.getItem()).getBlock().equals(block)) { return invStack; @@ -19,7 +19,7 @@ public class InventoryHelper { public static int findTotalBlocksInInventory(PlayerEntity player, Block block) { int total = 0; - for (ItemStack invStack : player.inventory.mainInventory) { + for (ItemStack invStack : player.inventory.items) { if (!invStack.isEmpty() && invStack.getItem() instanceof BlockItem && ((BlockItem) invStack.getItem()).getBlock().equals(block)) { total += invStack.getCount(); diff --git a/src/main/java/nl/requios/effortlessbuilding/helper/SurvivalHelper.java b/src/main/java/nl/requios/effortlessbuilding/helper/SurvivalHelper.java index 12ec89f..d0b72a0 100644 --- a/src/main/java/nl/requios/effortlessbuilding/helper/SurvivalHelper.java +++ b/src/main/java/nl/requios/effortlessbuilding/helper/SurvivalHelper.java @@ -32,7 +32,7 @@ public class SurvivalHelper { public static boolean placeBlock(World world, PlayerEntity player, BlockPos pos, BlockState blockState, ItemStack origstack, Direction facing, Vector3d hitVec, boolean skipPlaceCheck, boolean skipCollisionCheck, boolean playSound) { - if (!world.isBlockPresent(pos)) return false; + if (!world.isLoaded(pos)) return false; ItemStack itemstack = origstack; if (blockState.getBlock().isAir(blockState, world, pos) || itemstack.isEmpty()) { @@ -59,9 +59,9 @@ public class SurvivalHelper { //TryPlace sets block with offset and reduces itemstack count in creative, so we copy only parts of it // BlockItemUseContext blockItemUseContext = new BlockItemUseContext(world, player, itemstack, pos, facing, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z); // EnumActionResult result = ((ItemBlock) itemstack.getItem()).tryPlace(blockItemUseContext); - if (!world.setBlockState(pos, blockState, 3)) return false; - BlockItem.setTileEntityNBT(world, player, pos, itemstack); //Actually BlockItem::onBlockPlaced but that is protected - block.onBlockPlacedBy(world, pos, blockState, player, itemstack); + if (!world.setBlock(pos, blockState, 3)) return false; + BlockItem.updateCustomBlockEntityTag(world, player, pos, itemstack); //Actually BlockItem::onBlockPlaced but that is protected + block.setPlacedBy(world, pos, blockState, player, itemstack); if (player instanceof ServerPlayerEntity) { CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) player, pos, itemstack); } @@ -73,7 +73,7 @@ public class SurvivalHelper { world.playSound(null, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); } - if (!player.isCreative() && Block.getBlockFromItem(itemstack.getItem()) == block) { + if (!player.isCreative() && Block.byItem(itemstack.getItem()) == block) { CompatHelper.shrinkStack(origstack, itemstack, player); } @@ -109,7 +109,7 @@ public class SurvivalHelper { //Used for all breaking of blocks in this mod. //Checks if area is loaded, if appropriate tool is used in survival mode, and drops the block directly into the players inventory public static boolean breakBlock(World world, PlayerEntity player, BlockPos pos, boolean skipChecks) { - if (!world.isBlockPresent(pos) && !world.isAirBlock(pos)) return false; + if (!world.isLoaded(pos) && !world.isEmptyBlock(pos)) return false; //Check if can break if (skipChecks || canBreak(world, player, pos)) { @@ -120,7 +120,7 @@ public class SurvivalHelper { dropBlock(world, player, pos); //Damage tool - player.getHeldItemMainhand().onBlockDestroyed(world, world.getBlockState(pos), pos, player); + player.getMainHandItem().mineBlock(world, world.getBlockState(pos), pos, player); world.removeBlock(pos, false); return true; @@ -135,7 +135,7 @@ public class SurvivalHelper { BlockState blockState = world.getBlockState(pos); Block block = blockState.getBlock(); - block.harvestBlock(world, player, pos, blockState, world.getTileEntity(pos), player.getHeldItemMainhand()); + block.playerDestroy(world, player, pos, blockState, world.getBlockEntity(pos), player.getMainHandItem()); //TODO drop items in inventory instead of world @@ -183,7 +183,7 @@ public class SurvivalHelper { public static boolean canPlace(World world, PlayerEntity player, BlockPos pos, BlockState newBlockState, ItemStack itemStack, boolean skipCollisionCheck, Direction sidePlacedOn) { //Check if itemstack is correct - if (!(itemStack.getItem() instanceof BlockItem) || Block.getBlockFromItem(itemStack.getItem()) != newBlockState.getBlock()) { + if (!(itemStack.getItem() instanceof BlockItem) || Block.byItem(itemStack.getItem()) != newBlockState.getBlock()) { // EffortlessBuilding.log(player, "Cannot (re)place block", true); // EffortlessBuilding.log("SurvivalHelper#canPlace: itemstack " + itemStack.toString() + " does not match blockstate " + newBlockState.toString()); //Happens when breaking blocks, no need to notify in that case @@ -205,7 +205,7 @@ public class SurvivalHelper { switch (BuildConfig.survivalBalancers.quickReplaceMiningLevel.get()) { case -1: - return !state.getRequiresTool(); + return !state.requiresCorrectToolForDrops(); case 0: return state.getBlock().getHarvestLevel(state) <= 0; case 1: @@ -221,15 +221,15 @@ public class SurvivalHelper { //From EntityPlayer#canPlayerEdit private static boolean canPlayerEdit(PlayerEntity player, World world, BlockPos pos, ItemStack stack) { - if (!world.isBlockModifiable(player, pos)) return false; + if (!world.mayInteract(player, pos)) return false; - if (player.abilities.allowEdit) { + if (player.abilities.mayBuild) { //True in creative and survival mode return true; } else { //Adventure mode CachedBlockInfo blockworldstate = new CachedBlockInfo(world, pos, false); - return stack.canPlaceOn(world.getTags(), blockworldstate); + return stack.hasAdventureModePlaceTagForBlock(world.getTagManager(), blockworldstate); } } @@ -237,9 +237,9 @@ public class SurvivalHelper { //From World#mayPlace private static boolean mayPlace(World world, Block blockIn, BlockState newBlockState, BlockPos pos, boolean skipCollisionCheck, Direction sidePlacedOn, @Nullable Entity placer) { BlockState iblockstate1 = world.getBlockState(pos); - VoxelShape voxelShape = skipCollisionCheck ? null : blockIn.getDefaultState().getCollisionShape(world, pos); + VoxelShape voxelShape = skipCollisionCheck ? null : blockIn.defaultBlockState().getCollisionShape(world, pos); - if (voxelShape != null && !world.checkNoEntityCollision(placer, voxelShape)) { + if (voxelShape != null && !world.isUnobstructed(placer, voxelShape)) { return false; } @@ -255,7 +255,7 @@ public class SurvivalHelper { } //TODO 1.14 check what Material.CIRCUITS has become - if (iblockstate1.getMaterial() == Material.REDSTONE_LIGHT && blockIn == Blocks.ANVIL) { + if (iblockstate1.getMaterial() == Material.BUILDABLE_GLASS && blockIn == Blocks.ANVIL) { return true; } @@ -284,34 +284,34 @@ public class SurvivalHelper { BlockState state = world.getBlockState(pos); //Dont break bedrock - if (state.getBlockHardness(world, pos) < 0) { + if (state.getDestroySpeed(world, pos) < 0) { return false; } - if (!state.getRequiresTool()) { + if (!state.requiresCorrectToolForDrops()) { return true; } - ItemStack stack = player.getHeldItemMainhand(); + ItemStack stack = player.getMainHandItem(); ToolType tool = block.getHarvestTool(state); if (stack.isEmpty() || tool == null) { - return player.func_234569_d_(state); + return player.hasCorrectToolForDrops(state); } - if (stack.getDamage() >= stack.getMaxDamage()) return false; + if (stack.getDamageValue() >= stack.getMaxDamage()) return false; int toolLevel = stack.getItem().getHarvestLevel(stack, tool, player, state); if (toolLevel < 0) { - return player.func_234569_d_(state); + return player.hasCorrectToolForDrops(state); } return toolLevel >= block.getHarvestLevel(state); } public static boolean doesBecomeDoubleSlab(PlayerEntity player, BlockPos pos, Direction facing) { - BlockState placedBlockState = player.world.getBlockState(pos); + BlockState placedBlockState = player.level.getBlockState(pos); - ItemStack itemstack = player.getHeldItem(Hand.MAIN_HAND); + ItemStack itemstack = player.getItemInHand(Hand.MAIN_HAND); if (CompatHelper.isItemBlockProxy(itemstack)) itemstack = CompatHelper.getItemBlockFromStack(itemstack); diff --git a/src/main/java/nl/requios/effortlessbuilding/item/ItemRandomizerBag.java b/src/main/java/nl/requios/effortlessbuilding/item/ItemRandomizerBag.java index 6d9b71b..b056e8d 100644 --- a/src/main/java/nl/requios/effortlessbuilding/item/ItemRandomizerBag.java +++ b/src/main/java/nl/requios/effortlessbuilding/item/ItemRandomizerBag.java @@ -52,7 +52,7 @@ public class ItemRandomizerBag extends Item { private static final Random rand = new Random(currentSeed); public ItemRandomizerBag() { - super(new Item.Properties().group(ItemGroup.TOOLS).maxStackSize(1)); + super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1)); this.setRegistryName(EffortlessBuilding.MODID, "randomizer_bag"); } @@ -122,22 +122,22 @@ public class ItemRandomizerBag extends Item { } @Override - public ActionResultType onItemUse(ItemUseContext ctx) { + public ActionResultType useOn(ItemUseContext ctx) { PlayerEntity player = ctx.getPlayer(); - World world = ctx.getWorld(); - BlockPos pos = ctx.getPos(); - Direction facing = ctx.getFace(); - ItemStack item = ctx.getItem(); - Vector3d hitVec = ctx.getHitVec(); + World world = ctx.getLevel(); + BlockPos pos = ctx.getClickedPos(); + Direction facing = ctx.getClickedFace(); + ItemStack item = ctx.getItemInHand(); + Vector3d hitVec = ctx.getClickLocation(); if (player == null) return ActionResultType.FAIL; - if (ctx.getPlayer() != null && ctx.getPlayer().isSneaking()) { //ctx.isPlacerSneaking() - if (world.isRemote) return ActionResultType.SUCCESS; + if (ctx.getPlayer() != null && ctx.getPlayer().isShiftKeyDown()) { //ctx.isPlacerSneaking() + if (world.isClientSide) return ActionResultType.SUCCESS; //Open inventory NetworkHooks.openGui((ServerPlayerEntity) player, new ContainerProvider(item)); } else { - if (world.isRemote) return ActionResultType.SUCCESS; + if (world.isClientSide) return ActionResultType.SUCCESS; //Only place manually if in normal vanilla mode BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode(); @@ -149,7 +149,7 @@ public class ItemRandomizerBag extends Item { //Use item //Get bag inventory //TODO offhand support - ItemStack bag = player.getHeldItem(Hand.MAIN_HAND); + ItemStack bag = player.getItemInHand(Hand.MAIN_HAND); IItemHandler bagInventory = getBagInventory(bag); if (bagInventory == null) return ActionResultType.FAIL; @@ -162,12 +162,12 @@ public class ItemRandomizerBag extends Item { //toPlace.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); //TODO replaceable - if (!world.getBlockState(pos).getBlock().isReplaceable(world.getBlockState(pos), Fluids.EMPTY)) { - pos = pos.offset(facing); + if (!world.getBlockState(pos).getBlock().canBeReplaced(world.getBlockState(pos), Fluids.EMPTY)) { + pos = pos.relative(facing); } BlockItemUseContext blockItemUseContext = new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, new BlockRayTraceResult(hitVec, facing, pos, false))); - BlockState blockState = Block.getBlockFromItem(toPlace.getItem()).getStateForPlacement(blockItemUseContext); + BlockState blockState = Block.byItem(toPlace.getItem()).getStateForPlacement(blockItemUseContext); SurvivalHelper.placeBlock(world, player, pos, blockState, toPlace, facing, hitVec, false, false, true); @@ -182,11 +182,11 @@ public class ItemRandomizerBag extends Item { } @Override - public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { - ItemStack bag = player.getHeldItem(hand); + public ActionResult use(World world, PlayerEntity player, Hand hand) { + ItemStack bag = player.getItemInHand(hand); - if (player.isSneaking()) { - if (world.isRemote) return new ActionResult<>(ActionResultType.SUCCESS, bag); + if (player.isShiftKeyDown()) { + if (world.isClientSide) return new ActionResult<>(ActionResultType.SUCCESS, bag); //Open inventory NetworkHooks.openGui((ServerPlayerEntity) player, new ContainerProvider(bag)); } else { @@ -199,7 +199,7 @@ public class ItemRandomizerBag extends Item { ItemStack toUse = pickRandomStack(bagInventory); if (toUse.isEmpty()) return new ActionResult<>(ActionResultType.FAIL, bag); - return toUse.useItemRightClick(world, player, hand); + return toUse.use(world, player, hand); } return new ActionResult<>(ActionResultType.PASS, bag); } @@ -216,16 +216,16 @@ public class ItemRandomizerBag extends Item { } @Override - public void addInformation(ItemStack stack, @Nullable World world, List tooltip, ITooltipFlag flag) { + public void appendHoverText(ItemStack stack, @Nullable World world, List tooltip, ITooltipFlag flag) { tooltip.add(new StringTextComponent(TextFormatting.BLUE + "Rightclick" + TextFormatting.GRAY + " to place a random block")); tooltip.add(new StringTextComponent(TextFormatting.BLUE + "Sneak + rightclick" + TextFormatting.GRAY + " to open inventory")); - if (world != null && world.getPlayers().size() > 1) { + if (world != null && world.players().size() > 1) { tooltip.add(new StringTextComponent(TextFormatting.YELLOW + "Experimental on servers: may lose inventory")); } } @Override - public String getTranslationKey() { + public String getDescriptionId() { return this.getRegistryName().toString(); } diff --git a/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade1.java b/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade1.java index 2107c69..56c3f63 100644 --- a/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade1.java +++ b/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade1.java @@ -25,16 +25,16 @@ import java.util.List; public class ItemReachUpgrade1 extends Item { public ItemReachUpgrade1() { - super(new Item.Properties().group(ItemGroup.TOOLS).maxStackSize(1)); + super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1)); this.setRegistryName(EffortlessBuilding.MODID, "reach_upgrade1"); } @Override - public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { + public ActionResult use(World world, PlayerEntity player, Hand hand) { if (player.isCreative()) { - if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative."); - if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config."); - return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand)); + if (world.isClientSide) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative."); + if (world.isClientSide) EffortlessBuilding.log(player, "Still want increased reach? Use the config."); + return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand)); } ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); @@ -42,29 +42,29 @@ public class ItemReachUpgrade1 extends Item { if (currentLevel == 0) { modifierSettings.setReachUpgrade(1); - if (world.isRemote) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player)); - player.setHeldItem(hand, ItemStack.EMPTY); + if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player)); + player.setItemInHand(hand, ItemStack.EMPTY); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup")); player.playSound(soundEvent, 1f, 1f); } else if (currentLevel > 0) { - if (world.isRemote) + if (world.isClientSide) EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper .getMaxReach(player) + "."); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather")); player.playSound(soundEvent, 1f, 1f); } - return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand)); + return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand)); } @Override - public void addInformation(ItemStack stack, @Nullable World world, List tooltip, ITooltipFlag flag) { + public void appendHoverText(ItemStack stack, @Nullable World world, List tooltip, ITooltipFlag flag) { tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel1.get())); } @Override - public String getTranslationKey() { + public String getDescriptionId() { return this.getRegistryName().toString(); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade2.java b/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade2.java index 0e994ed..83f0833 100644 --- a/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade2.java +++ b/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade2.java @@ -25,51 +25,51 @@ import java.util.List; public class ItemReachUpgrade2 extends Item { public ItemReachUpgrade2() { - super(new Item.Properties().group(ItemGroup.TOOLS).maxStackSize(1)); + super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1)); this.setRegistryName(EffortlessBuilding.MODID, "reach_upgrade2"); } @Override - public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { + public ActionResult use(World world, PlayerEntity player, Hand hand) { if (player.isCreative()) { - if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative."); - if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config."); - return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand)); + if (world.isClientSide) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative."); + if (world.isClientSide) EffortlessBuilding.log(player, "Still want increased reach? Use the config."); + return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand)); } ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); int currentLevel = modifierSettings.getReachUpgrade(); if (currentLevel == 1) { modifierSettings.setReachUpgrade(2); - if (world.isRemote) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player)); - player.setHeldItem(hand, ItemStack.EMPTY); + if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player)); + player.setItemInHand(hand, ItemStack.EMPTY); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup")); player.playSound(soundEvent, 1f, 1f); } else if (currentLevel < 1) { - if (world.isRemote) EffortlessBuilding.log(player, "Use Reach Upgrade 1 first."); + if (world.isClientSide) EffortlessBuilding.log(player, "Use Reach Upgrade 1 first."); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather")); player.playSound(soundEvent, 1f, 1f); } else if (currentLevel > 1) { - if (world.isRemote) + if (world.isClientSide) EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper .getMaxReach(player) + "."); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather")); player.playSound(soundEvent, 1f, 1f); } - return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand)); + return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand)); } @Override - public void addInformation(ItemStack stack, @Nullable World world, List tooltip, ITooltipFlag flag) { + public void appendHoverText(ItemStack stack, @Nullable World world, List tooltip, ITooltipFlag flag) { tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel2.get())); tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Previous upgrades need to be consumed first")); } @Override - public String getTranslationKey() { + public String getDescriptionId() { return this.getRegistryName().toString(); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade3.java b/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade3.java index c9ce364..281cb9e 100644 --- a/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade3.java +++ b/src/main/java/nl/requios/effortlessbuilding/item/ItemReachUpgrade3.java @@ -25,54 +25,54 @@ import java.util.List; public class ItemReachUpgrade3 extends Item { public ItemReachUpgrade3() { - super(new Item.Properties().group(ItemGroup.TOOLS).maxStackSize(1)); + super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1)); this.setRegistryName(EffortlessBuilding.MODID, "reach_upgrade3"); } @Override - public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { + public ActionResult use(World world, PlayerEntity player, Hand hand) { if (player.isCreative()) { - if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative."); - if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config."); - return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand)); + if (world.isClientSide) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative."); + if (world.isClientSide) EffortlessBuilding.log(player, "Still want increased reach? Use the config."); + return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand)); } ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); int currentLevel = modifierSettings.getReachUpgrade(); if (currentLevel == 2) { modifierSettings.setReachUpgrade(3); - if (world.isRemote) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player)); - player.setHeldItem(hand, ItemStack.EMPTY); + if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player)); + player.setItemInHand(hand, ItemStack.EMPTY); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup")); player.playSound(soundEvent, 1f, 1f); } else if (currentLevel < 2) { if (currentLevel == 0) - if (world.isRemote) EffortlessBuilding.log(player, "Use Reach Upgrade 1 and 2 first."); + if (world.isClientSide) EffortlessBuilding.log(player, "Use Reach Upgrade 1 and 2 first."); if (currentLevel == 1) - if (world.isRemote) EffortlessBuilding.log(player, "Use Reach Upgrade 2 first."); + if (world.isClientSide) EffortlessBuilding.log(player, "Use Reach Upgrade 2 first."); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather")); player.playSound(soundEvent, 1f, 1f); } else if (currentLevel > 2) { - if (world.isRemote) + if (world.isClientSide) EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper .getMaxReach(player) + "."); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather")); player.playSound(soundEvent, 1f, 1f); } - return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand)); + return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand)); } @Override - public void addInformation(ItemStack stack, @Nullable World world, List tooltip, ITooltipFlag flag) { + public void appendHoverText(ItemStack stack, @Nullable World world, List tooltip, ITooltipFlag flag) { tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel3.get())); tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Previous upgrades need to be consumed first")); } @Override - public String getTranslationKey() { + public String getDescriptionId() { return this.getRegistryName().toString(); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/network/AddUndoMessage.java b/src/main/java/nl/requios/effortlessbuilding/network/AddUndoMessage.java index 1d00ba8..f7df013 100644 --- a/src/main/java/nl/requios/effortlessbuilding/network/AddUndoMessage.java +++ b/src/main/java/nl/requios/effortlessbuilding/network/AddUndoMessage.java @@ -39,14 +39,14 @@ public class AddUndoMessage { buf.writeInt(message.coordinate.getX()); buf.writeInt(message.coordinate.getY()); buf.writeInt(message.coordinate.getZ()); - buf.writeInt(Block.getStateId(message.previousBlockState)); - buf.writeInt(Block.getStateId(message.newBlockState)); + buf.writeInt(Block.getId(message.previousBlockState)); + buf.writeInt(Block.getId(message.newBlockState)); } public static AddUndoMessage decode(PacketBuffer buf) { BlockPos coordinate = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()); - BlockState previousBlockState = Block.getStateById(buf.readInt()); - BlockState newBlockState = Block.getStateById(buf.readInt()); + BlockState previousBlockState = Block.stateById(buf.readInt()); + BlockState newBlockState = Block.stateById(buf.readInt()); return new AddUndoMessage(coordinate, previousBlockState, newBlockState); } diff --git a/src/main/java/nl/requios/effortlessbuilding/network/BlockBrokenMessage.java b/src/main/java/nl/requios/effortlessbuilding/network/BlockBrokenMessage.java index 6aebd38..1b22f33 100644 --- a/src/main/java/nl/requios/effortlessbuilding/network/BlockBrokenMessage.java +++ b/src/main/java/nl/requios/effortlessbuilding/network/BlockBrokenMessage.java @@ -31,9 +31,9 @@ public class BlockBrokenMessage { public BlockBrokenMessage(BlockRayTraceResult result) { this.blockHit = result.getType() == RayTraceResult.Type.BLOCK; - this.blockPos = result.getPos(); - this.sideHit = result.getFace(); - this.hitVec = result.getHitVec(); + this.blockPos = result.getBlockPos(); + this.sideHit = result.getDirection(); + this.hitVec = result.getLocation(); } public BlockBrokenMessage(boolean blockHit, BlockPos blockPos, Direction sideHit, Vector3d hitVec) { @@ -48,7 +48,7 @@ public class BlockBrokenMessage { buf.writeInt(message.blockPos.getX()); buf.writeInt(message.blockPos.getY()); buf.writeInt(message.blockPos.getZ()); - buf.writeInt(message.sideHit.getIndex()); + buf.writeInt(message.sideHit.get3DDataValue()); buf.writeDouble(message.hitVec.x); buf.writeDouble(message.hitVec.y); buf.writeDouble(message.hitVec.z); @@ -57,7 +57,7 @@ public class BlockBrokenMessage { public static BlockBrokenMessage decode(PacketBuffer buf) { boolean blockHit = buf.readBoolean(); BlockPos blockPos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()); - Direction sideHit = Direction.byIndex(buf.readInt()); + Direction sideHit = Direction.from3DDataValue(buf.readInt()); Vector3d hitVec = new Vector3d(buf.readDouble(), buf.readDouble(), buf.readDouble()); return new BlockBrokenMessage(blockHit, blockPos, sideHit, hitVec); } diff --git a/src/main/java/nl/requios/effortlessbuilding/network/BlockPlacedMessage.java b/src/main/java/nl/requios/effortlessbuilding/network/BlockPlacedMessage.java index 96934a5..ef384da 100644 --- a/src/main/java/nl/requios/effortlessbuilding/network/BlockPlacedMessage.java +++ b/src/main/java/nl/requios/effortlessbuilding/network/BlockPlacedMessage.java @@ -35,9 +35,9 @@ public class BlockPlacedMessage { public BlockPlacedMessage(BlockRayTraceResult result, boolean placeStartPos) { this.blockHit = result.getType() == RayTraceResult.Type.BLOCK; - this.blockPos = result.getPos(); - this.sideHit = result.getFace(); - this.hitVec = result.getHitVec(); + this.blockPos = result.getBlockPos(); + this.sideHit = result.getDirection(); + this.hitVec = result.getLocation(); this.placeStartPos = placeStartPos; } @@ -54,7 +54,7 @@ public class BlockPlacedMessage { buf.writeInt(message.blockPos.getX()); buf.writeInt(message.blockPos.getY()); buf.writeInt(message.blockPos.getZ()); - buf.writeInt(message.sideHit.getIndex()); + buf.writeInt(message.sideHit.get3DDataValue()); buf.writeDouble(message.hitVec.x); buf.writeDouble(message.hitVec.y); buf.writeDouble(message.hitVec.z); @@ -64,7 +64,7 @@ public class BlockPlacedMessage { public static BlockPlacedMessage decode(PacketBuffer buf) { boolean blockHit = buf.readBoolean(); BlockPos blockPos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()); - Direction sideHit = Direction.byIndex(buf.readInt()); + Direction sideHit = Direction.from3DDataValue(buf.readInt()); Vector3d hitVec = new Vector3d(buf.readDouble(), buf.readDouble(), buf.readDouble()); boolean placeStartPos = buf.readBoolean(); return new BlockPlacedMessage(blockHit, blockPos, sideHit, hitVec, placeStartPos); diff --git a/src/main/java/nl/requios/effortlessbuilding/network/ModifierSettingsMessage.java b/src/main/java/nl/requios/effortlessbuilding/network/ModifierSettingsMessage.java index 053b81a..5260c9d 100644 --- a/src/main/java/nl/requios/effortlessbuilding/network/ModifierSettingsMessage.java +++ b/src/main/java/nl/requios/effortlessbuilding/network/ModifierSettingsMessage.java @@ -15,6 +15,8 @@ import java.util.function.Supplier; import static nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings; +import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings; + /** * Shares modifier settings (see ModifierSettingsManager) between server and client */ diff --git a/src/main/java/nl/requios/effortlessbuilding/network/TranslatedLogMessage.java b/src/main/java/nl/requios/effortlessbuilding/network/TranslatedLogMessage.java index 37f0ec0..ff891b3 100644 --- a/src/main/java/nl/requios/effortlessbuilding/network/TranslatedLogMessage.java +++ b/src/main/java/nl/requios/effortlessbuilding/network/TranslatedLogMessage.java @@ -29,14 +29,14 @@ public class TranslatedLogMessage { } public static void encode(TranslatedLogMessage message, PacketBuffer buf) { - buf.writeString(message.prefix); - buf.writeString(message.translationKey); - buf.writeString(message.suffix); + buf.writeUtf(message.prefix); + buf.writeUtf(message.translationKey); + buf.writeUtf(message.suffix); buf.writeBoolean(message.actionBar); } public static TranslatedLogMessage decode(PacketBuffer buf) { - return new TranslatedLogMessage(buf.readString(), buf.readString(), buf.readString(), buf.readBoolean()); + return new TranslatedLogMessage(buf.readUtf(), buf.readUtf(), buf.readUtf(), buf.readBoolean()); } public String getPrefix() { diff --git a/src/main/java/nl/requios/effortlessbuilding/proxy/ClientProxy.java b/src/main/java/nl/requios/effortlessbuilding/proxy/ClientProxy.java index 6e93270..5b2e437 100644 --- a/src/main/java/nl/requios/effortlessbuilding/proxy/ClientProxy.java +++ b/src/main/java/nl/requios/effortlessbuilding/proxy/ClientProxy.java @@ -73,7 +73,7 @@ public class ClientProxy implements IProxy { onMouseInput(); //Update previousLookAt - RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver; + RayTraceResult objectMouseOver = Minecraft.getInstance().hitResult; //Checking for null is necessary! Even in vanilla when looking down ladders it is occasionally null (instead of Type MISS) if (objectMouseOver == null) return; @@ -88,7 +88,7 @@ public class ClientProxy implements IProxy { currentLookAt = objectMouseOver; previousLookAt = objectMouseOver; } else { - if (((BlockRayTraceResult) currentLookAt).getPos() != ((BlockRayTraceResult) objectMouseOver).getPos()) { + if (((BlockRayTraceResult) currentLookAt).getBlockPos() != ((BlockRayTraceResult) objectMouseOver).getBlockPos()) { previousLookAt = currentLookAt; currentLookAt = objectMouseOver; } @@ -96,7 +96,7 @@ public class ClientProxy implements IProxy { } } else if (event.phase == TickEvent.Phase.END) { - Screen gui = Minecraft.getInstance().currentScreen; + Screen gui = Minecraft.getInstance().screen; if (gui == null || !gui.isPauseScreen()) { ticksInGame++; } @@ -116,22 +116,22 @@ public class ClientProxy implements IProxy { if (player == null) return; BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode(); - if (Minecraft.getInstance().currentScreen != null || + if (Minecraft.getInstance().screen != null || buildMode == BuildModes.BuildModeEnum.NORMAL || RadialMenu.instance.isVisible()) { return; } - if (mc.gameSettings.keyBindUseItem.isKeyDown()) { + if (mc.options.keyUse.isDown()) { //KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); if (placeCooldown <= 0) { placeCooldown = 4; - ItemStack currentItemStack = player.getHeldItem(Hand.MAIN_HAND); + ItemStack currentItemStack = player.getItemInHand(Hand.MAIN_HAND); if (currentItemStack.getItem() instanceof BlockItem || - (CompatHelper.isItemBlockProxy(currentItemStack) && !player.isSneaking())) { + (CompatHelper.isItemBlockProxy(currentItemStack) && !player.isShiftKeyDown())) { ItemStack itemStack = CompatHelper.getItemBlockFromStack(currentItemStack); @@ -144,15 +144,15 @@ public class ClientProxy implements IProxy { PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage(blockLookingAt, true)); //play sound if further than normal - if ((blockLookingAt.getHitVec().subtract(player.getEyePosition(1f))).lengthSquared() > 25f && + if ((blockLookingAt.getLocation().subtract(player.getEyePosition(1f))).lengthSqr() > 25f && itemStack.getItem() instanceof BlockItem) { - BlockState state = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState(); - BlockPos blockPos = blockLookingAt.getPos(); - SoundType soundType = state.getBlock().getSoundType(state, player.world, blockPos, player); - player.world.playSound(player, player.getPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS, + BlockState state = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState(); + BlockPos blockPos = blockLookingAt.getBlockPos(); + SoundType soundType = state.getBlock().getSoundType(state, player.level, blockPos, player); + player.level.playSound(player, player.blockPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS, 0.4f, soundType.getPitch()); - player.swingArm(Hand.MAIN_HAND); + player.swing(Hand.MAIN_HAND); } } else { BuildModes.onBlockPlacedMessage(player, new BlockPlacedMessage()); @@ -167,7 +167,7 @@ public class ClientProxy implements IProxy { placeCooldown = 0; } - if (mc.gameSettings.keyBindAttack.isKeyDown()) { + if (mc.options.keyAttack.isDown()) { //Break block in distance in creative (or survival if enabled in config) if (breakCooldown <= 0) { @@ -187,14 +187,14 @@ public class ClientProxy implements IProxy { PacketHandler.INSTANCE.sendToServer(new BlockBrokenMessage(blockLookingAt)); //play sound if further than normal - if ((blockLookingAt.getHitVec().subtract(player.getEyePosition(1f))).lengthSquared() > 25f) { + if ((blockLookingAt.getLocation().subtract(player.getEyePosition(1f))).lengthSqr() > 25f) { - BlockPos blockPos = blockLookingAt.getPos(); - BlockState state = player.world.getBlockState(blockPos); - SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player); - player.world.playSound(player, player.getPosition(), soundtype.getBreakSound(), SoundCategory.BLOCKS, + BlockPos blockPos = blockLookingAt.getBlockPos(); + BlockState state = player.level.getBlockState(blockPos); + SoundType soundtype = state.getBlock().getSoundType(state, player.level, blockPos, player); + player.level.playSound(player, player.blockPosition(), soundtype.getBreakSound(), SoundCategory.BLOCKS, 0.4f, soundtype.getPitch()); - player.swingArm(Hand.MAIN_HAND); + player.swing(Hand.MAIN_HAND); } } else { BuildModes.onBlockBrokenMessage(player, new BlockBrokenMessage()); @@ -220,12 +220,12 @@ public class ClientProxy implements IProxy { //Remember to send packet to server if necessary //Show Modifier Settings GUI - if (keyBindings[0].isPressed()) { + if (keyBindings[0].consumeClick()) { openModifierSettings(); } //QuickReplace toggle - if (keyBindings[1].isPressed()) { + if (keyBindings[1].consumeClick()) { ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); modifierSettings.setQuickReplace(!modifierSettings.doQuickReplace()); EffortlessBuilding.log(player, "Set " + TextFormatting.GOLD + "Quick Replace " + TextFormatting.RESET + ( @@ -234,30 +234,30 @@ public class ClientProxy implements IProxy { } //Creative/survival mode toggle - if (keyBindings[2].isPressed()) { + if (keyBindings[2].consumeClick()) { if (player.isCreative()) { - player.sendChatMessage("/gamemode survival"); + player.chat("/gamemode survival"); } else { - player.sendChatMessage("/gamemode creative"); + player.chat("/gamemode creative"); } } //Undo (Ctrl+Z) - if (keyBindings[4].isPressed()) { + if (keyBindings[4].consumeClick()) { ModeOptions.ActionEnum action = ModeOptions.ActionEnum.UNDO; ModeOptions.performAction(player, action); PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action)); } //Redo (Ctrl+Y) - if (keyBindings[5].isPressed()) { + if (keyBindings[5].consumeClick()) { ModeOptions.ActionEnum action = ModeOptions.ActionEnum.REDO; ModeOptions.performAction(player, action); PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action)); } //Change placement mode - if (keyBindings[6].isPressed()) { + if (keyBindings[6].consumeClick()) { //Toggle between first two actions of the first option of the current build mode BuildModes.BuildModeEnum currentBuildMode = ModeSettingsManager.getModeSettings(player).getBuildMode(); if (currentBuildMode.options.length > 0) { @@ -275,7 +275,7 @@ public class ClientProxy implements IProxy { } //For shader development - if (keyBindings.length >= 8 && keyBindings[7].isPressed()) { + if (keyBindings.length >= 8 && keyBindings[7].consumeClick()) { ShaderHandler.init(); EffortlessBuilding.log(player, "Reloaded shaders"); } @@ -294,10 +294,10 @@ public class ClientProxy implements IProxy { if (ReachHelper.getMaxReach(player) == 0) { EffortlessBuilding.log(player, "Build modifiers are disabled until your reach has increased. Increase your reach with craftable reach upgrades."); } else { - if (mc.currentScreen == null) { - mc.displayGuiScreen(new ModifierSettingsGui()); + if (mc.screen == null) { + mc.setScreen(new ModifierSettingsGui()); } else { - player.closeScreen(); + player.closeContainer(); } } } @@ -311,10 +311,10 @@ public class ClientProxy implements IProxy { RadialMenu.instance.setVisibility(0f); //Disabled if max reach is 0, might be set in the config that way. - if (mc.currentScreen == null) { - mc.displayGuiScreen(new PlayerSettingsGui()); + if (mc.screen == null) { + mc.setScreen(new PlayerSettingsGui()); } else { - player.closeScreen(); + player.closeContainer(); } } @@ -327,17 +327,17 @@ public class ClientProxy implements IProxy { } public static RayTraceResult getLookingAt(PlayerEntity player) { - World world = player.world; + World world = player.level; //base distance off of player ability (config) float raytraceRange = ReachHelper.getPlacementReach(player); - Vector3d look = player.getLookVec(); - Vector3d start = new Vector3d(player.getPosX(), player.getPosY() + player.getEyeHeight(), player.getPosZ()); - Vector3d end = new Vector3d(player.getPosX() + look.x * raytraceRange, player.getPosY() + player.getEyeHeight() + look.y * raytraceRange, player.getPosZ() + look.z * raytraceRange); + Vector3d look = player.getLookAngle(); + Vector3d start = new Vector3d(player.getX(), player.getY() + player.getEyeHeight(), player.getZ()); + Vector3d end = new Vector3d(player.getX() + look.x * raytraceRange, player.getY() + player.getEyeHeight() + look.y * raytraceRange, player.getZ() + look.z * raytraceRange); // return player.rayTrace(raytraceRange, 1f, RayTraceFluidMode.NEVER); //TODO 1.14 check if correct - return world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player)); + return world.clip(new RayTraceContext(start, end, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player)); } @Override @@ -350,21 +350,21 @@ public class ClientProxy implements IProxy { keyBindings = new KeyBinding[7]; // instantiate the key bindings - keyBindings[0] = new KeyBinding("key.effortlessbuilding.hud.desc", KeyConflictContext.UNIVERSAL, InputMappings.getInputByCode(GLFW.GLFW_KEY_KP_ADD, 0), "key.effortlessbuilding.category"); - keyBindings[1] = new KeyBinding("key.effortlessbuilding.replace.desc", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_KP_SUBTRACT, 0), "key.effortlessbuilding.category"); - keyBindings[2] = new KeyBinding("key.effortlessbuilding.creative.desc", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_F4, 0), "key.effortlessbuilding.category"); - keyBindings[3] = new KeyBinding("key.effortlessbuilding.mode.desc", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_LEFT_ALT, 0), "key.effortlessbuilding.category") { + keyBindings[0] = new KeyBinding("key.effortlessbuilding.hud.desc", KeyConflictContext.UNIVERSAL, InputMappings.getKey(GLFW.GLFW_KEY_KP_ADD, 0), "key.effortlessbuilding.category"); + keyBindings[1] = new KeyBinding("key.effortlessbuilding.replace.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_KP_SUBTRACT, 0), "key.effortlessbuilding.category"); + keyBindings[2] = new KeyBinding("key.effortlessbuilding.creative.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_F4, 0), "key.effortlessbuilding.category"); + keyBindings[3] = new KeyBinding("key.effortlessbuilding.mode.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_LEFT_ALT, 0), "key.effortlessbuilding.category") { @Override - public boolean conflicts(KeyBinding other) { + public boolean same(KeyBinding other) { //Does not conflict with Chisels and Bits radial menu - if (other.getKey().getKeyCode() == getKey().getKeyCode() && other.getKeyDescription().equals("mod.chiselsandbits.other.mode")) + if (other.getKey().getValue() == getKey().getValue() && other.getName().equals("mod.chiselsandbits.other.mode")) return false; - return super.conflicts(other); + return super.same(other); } }; - keyBindings[4] = new KeyBinding("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getInputByCode(GLFW.GLFW_KEY_Z, 0), "key.effortlessbuilding.category"); - keyBindings[5] = new KeyBinding("key.effortlessbuilding.redo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getInputByCode(GLFW.GLFW_KEY_Y, 0), "key.effortlessbuilding.category"); - keyBindings[6] = new KeyBinding("key.effortlessbuilding.altplacement.desc", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_LEFT_CONTROL, 0), "key.effortlessbuilding.category"); + keyBindings[4] = new KeyBinding("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getKey(GLFW.GLFW_KEY_Z, 0), "key.effortlessbuilding.category"); + keyBindings[5] = new KeyBinding("key.effortlessbuilding.redo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getKey(GLFW.GLFW_KEY_Y, 0), "key.effortlessbuilding.category"); + keyBindings[6] = new KeyBinding("key.effortlessbuilding.altplacement.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_LEFT_CONTROL, 0), "key.effortlessbuilding.category"); //keyBindings[7] = new KeyBinding("Reload shaders", KeyConflictContext.UNIVERSAL, InputMappings.getInputByCode(GLFW.GLFW_KEY_TAB, 0), "key.effortlessbuilding.category"); // register all the key bindings @@ -372,7 +372,7 @@ public class ClientProxy implements IProxy { ClientRegistry.registerKeyBinding(keyBinding); } - DeferredWorkQueue.runLater(() -> ScreenManager.registerFactory(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), RandomizerBagScreen::new)); + DeferredWorkQueue.runLater(() -> ScreenManager.register(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), RandomizerBagScreen::new)); } public PlayerEntity getPlayerEntityFromContext(Supplier ctx) { @@ -381,6 +381,6 @@ public class ClientProxy implements IProxy { @Override public void logTranslate(PlayerEntity player, String prefix, String translationKey, String suffix, boolean actionBar) { - EffortlessBuilding.log(Minecraft.getInstance().player, prefix + I18n.format(translationKey) + suffix, actionBar); + EffortlessBuilding.log(Minecraft.getInstance().player, prefix + I18n.get(translationKey) + suffix, actionBar); } } diff --git a/src/main/java/nl/requios/effortlessbuilding/render/BlockPreviewRenderer.java b/src/main/java/nl/requios/effortlessbuilding/render/BlockPreviewRenderer.java index eff7ea6..d3fa858 100644 --- a/src/main/java/nl/requios/effortlessbuilding/render/BlockPreviewRenderer.java +++ b/src/main/java/nl/requios/effortlessbuilding/render/BlockPreviewRenderer.java @@ -58,7 +58,7 @@ public class BlockPreviewRenderer { PlacedData placed = placedDataList.get(i); if (placed.coordinates != null && !placed.coordinates.isEmpty()) { - double totalTime = MathHelper.clampedLerp(30, 60, placed.firstPos.distanceSq(placed.secondPos) / 100.0) * BuildConfig.visuals.dissolveTimeMultiplier.get(); + double totalTime = MathHelper.clampedLerp(30, 60, placed.firstPos.distSqr(placed.secondPos) / 100.0) * BuildConfig.visuals.dissolveTimeMultiplier.get(); float dissolve = (ClientProxy.ticksInGame - placed.time) / (float) totalTime; renderBlockPreviews(matrixStack, renderTypeBuffer, placed.coordinates, placed.blockStates, placed.itemStacks, dissolve, placed.firstPos, placed.secondPos, false, placed.breaking); } @@ -66,16 +66,16 @@ public class BlockPreviewRenderer { } //Expire placedDataList.removeIf(placed -> { - double totalTime = MathHelper.clampedLerp(30, 60, placed.firstPos.distanceSq(placed.secondPos) / 100.0) * BuildConfig.visuals.dissolveTimeMultiplier.get(); + double totalTime = MathHelper.clampedLerp(30, 60, placed.firstPos.distSqr(placed.secondPos) / 100.0) * BuildConfig.visuals.dissolveTimeMultiplier.get(); return placed.time + totalTime < ClientProxy.ticksInGame; }); //Render block previews RayTraceResult lookingAt = ClientProxy.getLookingAt(player); if (modeSettings.getBuildMode() == BuildModes.BuildModeEnum.NORMAL) - lookingAt = Minecraft.getInstance().objectMouseOver; + lookingAt = Minecraft.getInstance().hitResult; - ItemStack mainhand = player.getHeldItemMainhand(); + ItemStack mainhand = player.getMainHandItem(); boolean toolInHand = !(!mainhand.isEmpty() && CompatHelper.isItemBlockProxy(mainhand)); BlockPos startPos = null; @@ -85,23 +85,23 @@ public class BlockPreviewRenderer { //Checking for null is necessary! Even in vanilla when looking down ladders it is occasionally null (instead of Type MISS) if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK) { BlockRayTraceResult blockLookingAt = (BlockRayTraceResult) lookingAt; - startPos = blockLookingAt.getPos(); + startPos = blockLookingAt.getBlockPos(); //Check if tool (or none) in hand //TODO 1.13 replaceable - boolean replaceable = player.world.getBlockState(startPos).getMaterial().isReplaceable(); - boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, blockLookingAt.getFace()); + boolean replaceable = player.level.getBlockState(startPos).getMaterial().isReplaceable(); + boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, blockLookingAt.getDirection()); if (!modifierSettings.doQuickReplace() && !toolInHand && !replaceable && !becomesDoubleSlab) { - startPos = startPos.offset(blockLookingAt.getFace()); + startPos = startPos.relative(blockLookingAt.getDirection()); } //Get under tall grass and other replaceable blocks if (modifierSettings.doQuickReplace() && !toolInHand && replaceable) { - startPos = startPos.down(); + startPos = startPos.below(); } - sideHit = blockLookingAt.getFace(); - hitVec = blockLookingAt.getHitVec(); + sideHit = blockLookingAt.getDirection(); + hitVec = blockLookingAt.getLocation(); } //Dont render if in normal mode and modifiers are disabled @@ -150,7 +150,7 @@ public class BlockPreviewRenderer { if (breaking) { //Find blockstate of world for (BlockPos coordinate : newCoordinates) { - blockStates.add(player.world.getBlockState(coordinate)); + blockStates.add(player.level.getBlockState(coordinate)); } } else { blockStates = BuildModifiers.findBlockStates(player, startCoordinates, hitVec, sideHit, itemStacks); @@ -174,9 +174,9 @@ public class BlockPreviewRenderer { soundTime = ClientProxy.ticksInGame; if (blockStates.get(0) != null) { - SoundType soundType = blockStates.get(0).getBlock().getSoundType(blockStates.get(0), player.world, + SoundType soundType = blockStates.get(0).getBlock().getSoundType(blockStates.get(0), player.level, newCoordinates.get(0), player); - player.world.playSound(player, player.getPosition(), breaking ? soundType.getBreakSound() : soundType.getPlaceSound(), + player.level.playSound(player, player.blockPosition(), breaking ? soundType.getBreakSound() : soundType.getPlaceSound(), SoundCategory.BLOCKS, 0.3f, 0.8f); } } @@ -196,7 +196,7 @@ public class BlockPreviewRenderer { if (breaking) color = new Vector3d(1f, 0f, 0f); for (int i = newCoordinates.size() - 1; i >= 0; i--) { - VoxelShape collisionShape = blockStates.get(i).getCollisionShape(player.world, newCoordinates.get(i)); + VoxelShape collisionShape = blockStates.get(i).getCollisionShape(player.level, newCoordinates.get(i)); RenderHandler.renderBlockOutline(matrixStack, buffer, newCoordinates.get(i), collisionShape, color); } @@ -239,21 +239,21 @@ public class BlockPreviewRenderer { IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer); //Draw outlines if tool in hand //Find proper raytrace: either normal range or increased range depending on canBreakFar - RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver; + RayTraceResult objectMouseOver = Minecraft.getInstance().hitResult; RayTraceResult breakingRaytrace = ReachHelper.canBreakFar(player) ? lookingAt : objectMouseOver; if (toolInHand && breakingRaytrace != null && breakingRaytrace.getType() == RayTraceResult.Type.BLOCK) { BlockRayTraceResult blockBreakingRaytrace = (BlockRayTraceResult) breakingRaytrace; - List breakCoordinates = BuildModifiers.findCoordinates(player, blockBreakingRaytrace.getPos()); + List breakCoordinates = BuildModifiers.findCoordinates(player, blockBreakingRaytrace.getBlockPos()); //Only render first outline if further than normal reach boolean excludeFirst = objectMouseOver != null && objectMouseOver.getType() == RayTraceResult.Type.BLOCK; for (int i = excludeFirst ? 1 : 0; i < breakCoordinates.size(); i++) { BlockPos coordinate = breakCoordinates.get(i); - BlockState blockState = player.world.getBlockState(coordinate); - if (!blockState.getBlock().isAir(blockState, player.world, coordinate)) { - if (SurvivalHelper.canBreak(player.world, player, coordinate) || i == 0) { - VoxelShape collisionShape = blockState.getCollisionShape(player.world, coordinate); + BlockState blockState = player.level.getBlockState(coordinate); + if (!blockState.getBlock().isAir(blockState, player.level, coordinate)) { + if (SurvivalHelper.canBreak(player.level, player, coordinate) || i == 0) { + VoxelShape collisionShape = blockState.getCollisionShape(player.level, coordinate); RenderHandler.renderBlockOutline(matrixStack, buffer, coordinate, collisionShape, new Vector3d(0f, 0f, 0f)); } } @@ -275,7 +275,7 @@ public class BlockPreviewRenderer { BlockPos secondPos, boolean checkCanPlace, boolean red) { PlayerEntity player = Minecraft.getInstance().player; ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); - BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); + BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer(); int blocksValid = 0; if (coordinates.isEmpty()) return blocksValid; @@ -290,7 +290,7 @@ public class BlockPreviewRenderer { //Check if can place //If check is turned off, check if blockstate is the same (for dissolve effect) if ((!checkCanPlace /*&& player.world.getNewBlockState(blockPos) == blockState*/) || //TODO enable (breaks the breaking shader) - SurvivalHelper.canPlace(player.world, player, blockPos, blockState, itemstack, modifierSettings.doQuickReplace(), Direction.UP)) { + SurvivalHelper.canPlace(player.level, player, blockPos, blockState, itemstack, modifierSettings.doQuickReplace(), Direction.UP)) { RenderHandler.renderBlockPreview(matrixStack, renderTypeBuffer, dispatcher, blockPos, blockState, dissolve, firstPos, secondPos, red); blocksValid++; @@ -353,8 +353,8 @@ public class BlockPreviewRenderer { Collections.sort(coordinates, (lhs, rhs) -> { // -1 - less than, 1 - greater than, 0 - equal - double lhsDistanceToPlayer = Vector3d.copy(lhs).subtract(player.getEyePosition(1f)).lengthSquared(); - double rhsDistanceToPlayer = Vector3d.copy(rhs).subtract(player.getEyePosition(1f)).lengthSquared(); + double lhsDistanceToPlayer = Vector3d.atLowerCornerOf(lhs).subtract(player.getEyePosition(1f)).lengthSqr(); + double rhsDistanceToPlayer = Vector3d.atLowerCornerOf(rhs).subtract(player.getEyePosition(1f)).lengthSqr(); return (int) Math.signum(lhsDistanceToPlayer - rhsDistanceToPlayer); }); diff --git a/src/main/java/nl/requios/effortlessbuilding/render/BuildRenderTypes.java b/src/main/java/nl/requios/effortlessbuilding/render/BuildRenderTypes.java index 6dcd9cf..f4021f0 100644 --- a/src/main/java/nl/requios/effortlessbuilding/render/BuildRenderTypes.java +++ b/src/main/java/nl/requios/effortlessbuilding/render/BuildRenderTypes.java @@ -37,13 +37,13 @@ public class BuildRenderTypes { private static final int secondaryTextureUnit = 2; static { - TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228515_g_"); - NO_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228510_b_"); + TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "TRANSLUCENT_TRANSPARENCY"); + NO_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "NO_TRANSPARENCY"); DIFFUSE_LIGHTING_ENABLED = new RenderState.DiffuseLightingState(true); DIFFUSE_LIGHTING_DISABLED = new RenderState.DiffuseLightingState(false); - PROJECTION_LAYERING = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_239235_M_"); + PROJECTION_LAYERING = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "VIEW_OFFSET_Z_LAYERING"); CULL_DISABLED = new RenderState.CullState(false); @@ -68,24 +68,24 @@ public class BuildRenderTypes { // RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // // RenderSystem.lineWidth(2); - renderState = RenderType.State.getBuilder() - .line(new RenderState.LineState(OptionalDouble.of(2))) - .layer(PROJECTION_LAYERING) - .transparency(TRANSLUCENT_TRANSPARENCY) - .writeMask(WRITE_TO_DEPTH_AND_COLOR) - .cull(CULL_DISABLED) - .build(false); - LINES = RenderType.makeType("eb_lines", + renderState = RenderType.State.builder() + .setLineState(new RenderState.LineState(OptionalDouble.of(2))) + .setLayeringState(PROJECTION_LAYERING) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setWriteMaskState(WRITE_TO_DEPTH_AND_COLOR) + .setCullState(CULL_DISABLED) + .createCompositeState(false); + LINES = RenderType.create("eb_lines", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, INITIAL_BUFFER_SIZE, renderState); - renderState = RenderType.State.getBuilder() - .line(new RenderState.LineState(OptionalDouble.of(2))) - .layer(PROJECTION_LAYERING) - .transparency(TRANSLUCENT_TRANSPARENCY) - .writeMask(COLOR_WRITE) - .cull(CULL_DISABLED) - .build(false); - PLANES = RenderType.makeType("eb_planes", + renderState = RenderType.State.builder() + .setLineState(new RenderState.LineState(OptionalDouble.of(2))) + .setLayeringState(PROJECTION_LAYERING) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setWriteMaskState(COLOR_WRITE) + .setCullState(CULL_DISABLED) + .createCompositeState(false); + PLANES = RenderType.create("eb_planes", DefaultVertexFormats.POSITION_COLOR, GL11.GL_TRIANGLE_STRIP, INITIAL_BUFFER_SIZE, renderState); } @@ -111,23 +111,23 @@ public class BuildRenderTypes { // RenderSystem.pushLightingAttributes(); // RenderSystem.pushTextureAttributes(); - ShaderHandler.useShader(ShaderHandler.dissolve, generateShaderCallback(dissolve, Vector3d.copy(blockPos), Vector3d.copy(firstPos), Vector3d.copy(secondPos), blockPos == secondPos, red)); + ShaderHandler.useShader(ShaderHandler.dissolve, generateShaderCallback(dissolve, Vector3d.atLowerCornerOf(blockPos), Vector3d.atLowerCornerOf(firstPos), Vector3d.atLowerCornerOf(secondPos), blockPos == secondPos, red)); RenderSystem.blendColor(1f, 1f, 1f, 0.8f); }, ShaderHandler::releaseShader); - RenderType.State renderState = RenderType.State.getBuilder() - .texture(new RenderState.TextureState(ShaderHandler.shaderMaskTextureLocation, false, false)) - .texturing(MY_TEXTURING) - .transparency(TRANSLUCENT_TRANSPARENCY) - .diffuseLighting(DIFFUSE_LIGHTING_DISABLED) - .alpha(DEFAULT_ALPHA) - .cull(new RenderState.CullState(true)) - .lightmap(new RenderState.LightmapState(false)) - .overlay(new RenderState.OverlayState(false)) - .build(true); + RenderType.State renderState = RenderType.State.builder() + .setTextureState(new RenderState.TextureState(ShaderHandler.shaderMaskTextureLocation, false, false)) + .setTexturingState(MY_TEXTURING) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setDiffuseLightingState(DIFFUSE_LIGHTING_DISABLED) + .setAlphaState(DEFAULT_ALPHA) + .setCullState(new RenderState.CullState(true)) + .setLightmapState(new RenderState.LightmapState(false)) + .setOverlayState(new RenderState.OverlayState(false)) + .createCompositeState(true); //Unique name for every combination, otherwise it will reuse the previous one String name = "eb_block_previews_" + dissolve + "_" + blockPos + "_" + firstPos + "_" + secondPos + "_" + red; - return RenderType.makeType(name, + return RenderType.create(name, DefaultVertexFormats.BLOCK, GL11.GL_QUADS, 256, true, true, renderState); } @@ -151,13 +151,13 @@ public class BuildRenderTypes { //mask ARBShaderObjects.glUniform1iARB(maskUniform, secondaryTextureUnit); glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + secondaryTextureUnit); - mc.getTextureManager().bindTexture(ShaderHandler.shaderMaskTextureLocation);//getTexture(ShaderHandler.shaderMaskTextureLocation).bindTexture(); + mc.getTextureManager().bind(ShaderHandler.shaderMaskTextureLocation);//getTexture(ShaderHandler.shaderMaskTextureLocation).bindTexture(); //GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.getTextureManager().getTexture(ShaderHandler.shaderMaskTextureLocation).getGlTextureId()); //image ARBShaderObjects.glUniform1iARB(imageUniform, primaryTextureUnit); glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + primaryTextureUnit); - mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);//.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).bindTexture(); + mc.getTextureManager().bind(AtlasTexture.LOCATION_BLOCKS);//.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).bindTexture(); //GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.getTextureManager().getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).getGlTextureId()); //blockpos diff --git a/src/main/java/nl/requios/effortlessbuilding/render/ModifierRenderer.java b/src/main/java/nl/requios/effortlessbuilding/render/ModifierRenderer.java index f2cc6b2..877500a 100644 --- a/src/main/java/nl/requios/effortlessbuilding/render/ModifierRenderer.java +++ b/src/main/java/nl/requios/effortlessbuilding/render/ModifierRenderer.java @@ -65,10 +65,10 @@ public class ModifierRenderer { float angle = 2f * ((float) Math.PI) / r.slices; Vector3d relStartVec = new Vector3d(radius, 0, 0); - if (r.slices % 4 == 2) relStartVec = relStartVec.rotateYaw(angle / 2f); + if (r.slices % 4 == 2) relStartVec = relStartVec.yRot(angle / 2f); for (int i = 0; i < r.slices; i++) { - Vector3d relNewVec = relStartVec.rotateYaw(angle * i); + Vector3d relNewVec = relStartVec.yRot(angle * i); Vector3d newVec = pos.add(relNewVec); Vector3d posA = new Vector3d(pos.x, pos.y - radius, pos.z); @@ -84,18 +84,18 @@ public class ModifierRenderer { protected static void drawMirrorPlane(MatrixStack matrixStack, IRenderTypeBuffer.Impl renderTypeBuffer, Vector3d posA, Vector3d posB, Color c, boolean drawLines, boolean drawPlanes, boolean drawVerticalLines) { // GL11.glColor4d(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha); - Matrix4f matrixPos = matrixStack.getLast().getMatrix(); + Matrix4f matrixPos = matrixStack.last().pose(); if (drawPlanes) { IVertexBuilder buffer = RenderHandler.beginPlanes(renderTypeBuffer); - buffer.pos(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); - buffer.pos(matrixPos, (float) posA.x, (float) posB.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); - buffer.pos(matrixPos, (float) posB.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); - buffer.pos(matrixPos, (float) posB.x, (float) posB.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posA.x, (float) posB.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posB.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posB.x, (float) posB.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); //backface (using triangle strip) - buffer.pos(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); - buffer.pos(matrixPos, (float) posA.x, (float) posB.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posA.x, (float) posB.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); RenderHandler.endPlanes(renderTypeBuffer); } @@ -104,11 +104,11 @@ public class ModifierRenderer { IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer); Vector3d middle = posA.add(posB).scale(0.5); - buffer.pos(matrixPos, (float) posA.x, (float) middle.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); - buffer.pos(matrixPos, (float) posB.x, (float) middle.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posA.x, (float) middle.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posB.x, (float) middle.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); if (drawVerticalLines) { - buffer.pos(matrixPos, (float) middle.x, (float) posA.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); - buffer.pos(matrixPos, (float) middle.x, (float) posB.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) middle.x, (float) posA.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) middle.x, (float) posB.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); } RenderHandler.endLines(renderTypeBuffer); @@ -118,18 +118,18 @@ public class ModifierRenderer { protected static void drawMirrorPlaneY(MatrixStack matrixStack, IRenderTypeBuffer.Impl renderTypeBuffer, Vector3d posA, Vector3d posB, Color c, boolean drawLines, boolean drawPlanes) { // GL11.glColor4d(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()); - Matrix4f matrixPos = matrixStack.getLast().getMatrix(); + Matrix4f matrixPos = matrixStack.last().pose(); if (drawPlanes) { IVertexBuilder buffer = RenderHandler.beginPlanes(renderTypeBuffer); - buffer.pos(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); - buffer.pos(matrixPos, (float) posA.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); - buffer.pos(matrixPos, (float) posB.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); - buffer.pos(matrixPos, (float) posB.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posB.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posB.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); //backface (using triangle strip) - buffer.pos(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); - buffer.pos(matrixPos, (float) posA.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex(); RenderHandler.endPlanes(renderTypeBuffer); } @@ -138,10 +138,10 @@ public class ModifierRenderer { IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer); Vector3d middle = posA.add(posB).scale(0.5); - buffer.pos(matrixPos, (float) middle.x, (float) middle.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); - buffer.pos(matrixPos, (float) middle.x, (float) middle.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); - buffer.pos(matrixPos, (float) posA.x, (float) middle.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); - buffer.pos(matrixPos, (float) posB.x, (float) middle.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) middle.x, (float) middle.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) middle.x, (float) middle.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posA.x, (float) middle.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) posB.x, (float) middle.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex(); RenderHandler.endLines(renderTypeBuffer); } @@ -151,16 +151,16 @@ public class ModifierRenderer { // GL11.glColor4d(100, 100, 100, 255); IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer); - Matrix4f matrixPos = matrixStack.getLast().getMatrix(); + Matrix4f matrixPos = matrixStack.last().pose(); Vector3d pos = m.position.add(epsilon); - buffer.pos(matrixPos, (float) pos.x - m.radius, (float) pos.y, (float) pos.z).color(colorX.getRed(), colorX.getGreen(), colorX.getBlue(), lineAlpha).endVertex(); - buffer.pos(matrixPos, (float) pos.x + m.radius, (float) pos.y, (float) pos.z).color(colorX.getRed(), colorX.getGreen(), colorX.getBlue(), lineAlpha).endVertex(); - buffer.pos(matrixPos, (float) pos.x, (float) pos.y - m.radius, (float) pos.z).color(colorY.getRed(), colorY.getGreen(), colorY.getBlue(), lineAlpha).endVertex(); - buffer.pos(matrixPos, (float) pos.x, (float) pos.y + m.radius, (float) pos.z).color(colorY.getRed(), colorY.getGreen(), colorY.getBlue(), lineAlpha).endVertex(); - buffer.pos(matrixPos, (float) pos.x, (float) pos.y, (float) pos.z - m.radius).color(colorZ.getRed(), colorZ.getGreen(), colorZ.getBlue(), lineAlpha).endVertex(); - buffer.pos(matrixPos, (float) pos.x, (float) pos.y, (float) pos.z + m.radius).color(colorZ.getRed(), colorZ.getGreen(), colorZ.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) pos.x - m.radius, (float) pos.y, (float) pos.z).color(colorX.getRed(), colorX.getGreen(), colorX.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) pos.x + m.radius, (float) pos.y, (float) pos.z).color(colorX.getRed(), colorX.getGreen(), colorX.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) pos.x, (float) pos.y - m.radius, (float) pos.z).color(colorY.getRed(), colorY.getGreen(), colorY.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) pos.x, (float) pos.y + m.radius, (float) pos.z).color(colorY.getRed(), colorY.getGreen(), colorY.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) pos.x, (float) pos.y, (float) pos.z - m.radius).color(colorZ.getRed(), colorZ.getGreen(), colorZ.getBlue(), lineAlpha).endVertex(); + buffer.vertex(matrixPos, (float) pos.x, (float) pos.y, (float) pos.z + m.radius).color(colorZ.getRed(), colorZ.getGreen(), colorZ.getBlue(), lineAlpha).endVertex(); RenderHandler.endLines(renderTypeBuffer); } diff --git a/src/main/java/nl/requios/effortlessbuilding/render/RenderHandler.java b/src/main/java/nl/requios/effortlessbuilding/render/RenderHandler.java index 14038b0..d398f87 100644 --- a/src/main/java/nl/requios/effortlessbuilding/render/RenderHandler.java +++ b/src/main/java/nl/requios/effortlessbuilding/render/RenderHandler.java @@ -47,8 +47,8 @@ public class RenderHandler { return; MatrixStack matrixStack = event.getMatrixStack(); - BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer(); - IRenderTypeBuffer.Impl renderTypeBuffer = IRenderTypeBuffer.getImpl(bufferBuilder); + BufferBuilder bufferBuilder = Tessellator.getInstance().getBuilder(); + IRenderTypeBuffer.Impl renderTypeBuffer = IRenderTypeBuffer.immediate(bufferBuilder); if (renderTypeBuffer == null) return; @@ -56,9 +56,9 @@ public class RenderHandler { ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player); ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); - Vector3d projectedView = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView(); + Vector3d projectedView = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(-projectedView.x, -projectedView.y, -projectedView.z); //Mirror and radial mirror lines and areas @@ -67,7 +67,7 @@ public class RenderHandler { //Render block previews BlockPreviewRenderer.render(matrixStack, renderTypeBuffer, player, modifierSettings, modeSettings); - matrixStack.pop(); + matrixStack.popPose(); } @SubscribeEvent @@ -84,11 +84,11 @@ public class RenderHandler { if (type == RenderGameOverlayEvent.ElementType.ALL /*&& !hasChiselInHand*/) { final boolean wasVisible = RadialMenu.instance.isVisible(); - if (ClientProxy.keyBindings[3].isKeyDown()) { + if (ClientProxy.keyBindings[3].isDown()) { if (ReachHelper.getMaxReach(player) > 0) { RadialMenu.instance.actionUsed = false; RadialMenu.instance.raiseVisibility(); - } else if (ClientProxy.keyBindings[3].isPressed()) { + } else if (ClientProxy.keyBindings[3].consumeClick()) { EffortlessBuilding.log(player, "Build modes are disabled until your reach has increased. Increase your reach with craftable reach upgrades."); } } else { @@ -101,7 +101,7 @@ public class RenderHandler { ModeSettingsManager.setModeSettings(player, modeSettings); PacketHandler.INSTANCE.sendToServer(new ModeSettingsMessage(modeSettings)); - EffortlessBuilding.log(player, I18n.format(modeSettings.getBuildMode().name), true); + EffortlessBuilding.log(player, I18n.get(modeSettings.getBuildMode().name), true); } //Perform button action @@ -120,27 +120,27 @@ public class RenderHandler { if (RadialMenu.instance.isVisible()) { - int scaledWidth = mc.getMainWindow().getScaledWidth(); - int scaledHeight = mc.getMainWindow().getScaledHeight(); + int scaledWidth = mc.getWindow().getGuiScaledWidth(); + int scaledHeight = mc.getWindow().getGuiScaledHeight(); RadialMenu.instance.configure(scaledWidth, scaledHeight); if (!wasVisible) { - mc.mouseHelper.ungrabMouse(); + mc.mouseHandler.releaseMouse(); } - if (mc.mouseHelper.isMouseGrabbed()) { - KeyBinding.unPressAllKeys(); + if (mc.mouseHandler.isMouseGrabbed()) { + KeyBinding.releaseAll(); } - final int mouseX = ((int) mc.mouseHelper.getMouseX()) * scaledWidth / mc.getMainWindow().getFramebufferWidth(); - final int mouseY = scaledHeight - ((int) mc.mouseHelper.getMouseY()) * scaledHeight / mc.getMainWindow().getFramebufferHeight() - 1; + final int mouseX = ((int) mc.mouseHandler.xpos()) * scaledWidth / mc.getWindow().getWidth(); + final int mouseY = scaledHeight - ((int) mc.mouseHandler.ypos()) * scaledHeight / mc.getWindow().getHeight() - 1; net.minecraftforge.client.ForgeHooksClient.drawScreen(RadialMenu.instance, event.getMatrixStack(), mouseX, mouseY, event.getPartialTicks()); } else { if (wasVisible && RadialMenu.instance.doAction != ModeOptions.ActionEnum.OPEN_MODIFIER_SETTINGS && RadialMenu.instance.doAction != ModeOptions.ActionEnum.OPEN_PLAYER_SETTINGS) { - mc.mouseHelper.grabMouse(); + mc.mouseHandler.grabMouse(); } } } @@ -149,8 +149,8 @@ public class RenderHandler { public static void playRadialMenuSound() { final float volume = 0.1f; if (volume >= 0.0001f) { - SimpleSound sound = new SimpleSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.MASTER, volume, 1.0f, Minecraft.getInstance().player.getPosition()); - Minecraft.getInstance().getSoundHandler().play(sound); + SimpleSound sound = new SimpleSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.MASTER, volume, 1.0f, Minecraft.getInstance().player.blockPosition()); + Minecraft.getInstance().getSoundManager().play(sound); } } @@ -159,7 +159,7 @@ public class RenderHandler { } protected static void endLines(IRenderTypeBuffer.Impl renderTypeBuffer) { - renderTypeBuffer.finish(); + renderTypeBuffer.endBatch(); } protected static IVertexBuilder beginPlanes(IRenderTypeBuffer.Impl renderTypeBuffer) { @@ -167,14 +167,14 @@ public class RenderHandler { } protected static void endPlanes(IRenderTypeBuffer.Impl renderTypeBuffer) { - renderTypeBuffer.finish(); + renderTypeBuffer.endBatch(); } protected static void renderBlockPreview(MatrixStack matrixStack, IRenderTypeBuffer.Impl renderTypeBuffer, BlockRendererDispatcher dispatcher, BlockPos blockPos, BlockState blockState, float dissolve, BlockPos firstPos, BlockPos secondPos, boolean red) { if (blockState == null) return; - matrixStack.push(); + matrixStack.pushPose(); matrixStack.translate(blockPos.getX(), blockPos.getY(), blockPos.getZ()); // matrixStack.rotate(Vector3f.YP.rotationDegrees(-90f)); matrixStack.translate(-0.01f, -0.01f, -0.01f); @@ -188,8 +188,8 @@ public class RenderHandler { // World world = DimensionManager.getWorld(server, DimensionType.OVERWORLD, false, true); try { - IBakedModel model = dispatcher.getModelForState(blockState); - dispatcher.getBlockModelRenderer().renderModelBrightnessColor(matrixStack.getLast(), buffer, + IBakedModel model = dispatcher.getBlockModel(blockState); + dispatcher.getModelRenderer().renderModel(matrixStack.last(), buffer, blockState, model, 1f, 1f, 1f, 0, OverlayTexture.NO_OVERLAY); // blockRendererDispatcher.getBlockModelRenderer().renderModel(world, blockRendererDispatcher.getModelForState(blockState), // blockState, logicPos, matrixStack, renderTypeBuffer.getBuffer(renderType), true, new Random(), blockState.getPositionRandom(logicPos), i); @@ -197,17 +197,17 @@ public class RenderHandler { EffortlessBuilding.logger.warn("RenderHandler::renderBlockPreview cannot render " + blockState.getBlock().toString()); //Render outline as backup, escape out of the current renderstack - matrixStack.pop(); - renderTypeBuffer.finish(); + matrixStack.popPose(); + renderTypeBuffer.endBatch(); IVertexBuilder lineBuffer = beginLines(renderTypeBuffer); renderBlockOutline(matrixStack, lineBuffer, blockPos, new Vector3d(1f, 1f, 1f)); endLines(renderTypeBuffer); - buffer = renderTypeBuffer.getBuffer(Atlases.getTranslucentCullBlockType()); //any type will do, as long as we have something on the stack - matrixStack.push(); + buffer = renderTypeBuffer.getBuffer(Atlases.translucentCullBlockSheet()); //any type will do, as long as we have something on the stack + matrixStack.pushPose(); } - renderTypeBuffer.finish(); - matrixStack.pop(); + renderTypeBuffer.endBatch(); + matrixStack.popPose(); } protected static void renderBlockOutline(MatrixStack matrixStack, IVertexBuilder buffer, BlockPos pos, Vector3d color) { @@ -216,16 +216,16 @@ public class RenderHandler { //Renders outline. Pos1 has to be minimal x,y,z and pos2 maximal x,y,z protected static void renderBlockOutline(MatrixStack matrixStack, IVertexBuilder buffer, BlockPos pos1, BlockPos pos2, Vector3d color) { - AxisAlignedBB aabb = new AxisAlignedBB(pos1, pos2.add(1, 1, 1)).grow(0.0020000000949949026); + AxisAlignedBB aabb = new AxisAlignedBB(pos1, pos2.offset(1, 1, 1)).inflate(0.0020000000949949026); - WorldRenderer.drawBoundingBox(matrixStack, buffer, aabb, (float) color.x, (float) color.y, (float) color.z, 0.4f); + WorldRenderer.renderLineBox(matrixStack, buffer, aabb, (float) color.x, (float) color.y, (float) color.z, 0.4f); // WorldRenderer.drawSelectionBoundingBox(aabb, (float) color.x, (float) color.y, (float) color.z, 0.4f); } //Renders outline with given bounding box protected static void renderBlockOutline(MatrixStack matrixStack, IVertexBuilder buffer, BlockPos pos, VoxelShape collisionShape, Vector3d color) { // WorldRenderer.drawShape(collisionShape, pos.getX(), pos.getY(), pos.getZ(), (float) color.x, (float) color.y, (float) color.z, 0.4f); - WorldRenderer.drawVoxelShapeParts(matrixStack, buffer, collisionShape, pos.getX(), pos.getY(), pos.getZ(), (float) color.x, (float) color.y, (float) color.z, 0.4f); + WorldRenderer.renderVoxelShape(matrixStack, buffer, collisionShape, pos.getX(), pos.getY(), pos.getZ(), (float) color.x, (float) color.y, (float) color.z, 0.4f); } //TODO 1.14 diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 4d0fa9e..cd021f1 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -9,7 +9,7 @@ modLoader="javafml" #mandatory loaderVersion="[34,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. license="GNU LESSER GENERAL PUBLIC LICENSE" # A URL to refer people to when problems occur with this mod -issueTrackerURL="http://my.issue.tracker/" #optional +issueTrackerURL="https://bitbucket.org/Requios/effortless-building/issues?status=new&status=open" #optional # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] #mandatory # The modid of the mod