Updated mapping to 1.16.5 official names.
This commit is contained in:
@@ -5,7 +5,7 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
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'
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
@@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
|||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'maven-publish'
|
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
|
group = 'nl.requios.effortlessbuilding' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = 'effortlessbuilding'
|
archivesBaseName = 'effortlessbuilding'
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ minecraft {
|
|||||||
// stable_# Stables are built at the discretion of the MCP team.
|
// stable_# Stables are built at the discretion of the MCP team.
|
||||||
// Use non-default mappings at your own risk. they may not always work.
|
// 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.
|
// 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')
|
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||||
|
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
|
|
||||||
|
|||||||
71
gradlew
vendored
71
gradlew
vendored
@@ -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"`
|
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.
|
# 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.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
@@ -56,7 +72,7 @@ case "`uname`" in
|
|||||||
Darwin* )
|
Darwin* )
|
||||||
darwin=true
|
darwin=true
|
||||||
;;
|
;;
|
||||||
MINGW* )
|
MSYS* | MINGW* )
|
||||||
msys=true
|
msys=true
|
||||||
;;
|
;;
|
||||||
NONSTOP* )
|
NONSTOP* )
|
||||||
@@ -66,6 +82,7 @@ esac
|
|||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; 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\""
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if $cygwin ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
@@ -138,35 +156,28 @@ if $cygwin ; then
|
|||||||
else
|
else
|
||||||
eval `echo args$i`="\"$arg\""
|
eval `echo args$i`="\"$arg\""
|
||||||
fi
|
fi
|
||||||
i=$((i+1))
|
i=`expr $i + 1`
|
||||||
done
|
done
|
||||||
case $i in
|
case $i in
|
||||||
(0) set -- ;;
|
0) set -- ;;
|
||||||
(1) set -- "$args0" ;;
|
1) set -- "$args0" ;;
|
||||||
(2) set -- "$args0" "$args1" ;;
|
2) set -- "$args0" "$args1" ;;
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
ARGV=("$@")
|
||||||
save () {
|
eval set -- $DEFAULT_JVM_OPTS
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
|
||||||
echo " "
|
|
||||||
}
|
|
||||||
APP_ARGS=$(save "$@")
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
IFS=$'
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
' 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
|
exec "$JAVACMD" "$@" "${JAVA_OPTS_ARR[@]}" "${GRADLE_OPTS_ARR[@]}" "-Dorg.gradle.appname=$APP_BASE_NAME" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "${ARGV[@]}"
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
||||||
|
|||||||
43
gradlew.bat
vendored
43
gradlew.bat
vendored
@@ -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
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
|||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
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.
|
@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
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
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_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
@@ -45,28 +64,14 @@ echo location of your Java installation.
|
|||||||
|
|
||||||
goto fail
|
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
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@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
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class EffortlessBuilding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void log(PlayerEntity player, String msg, boolean actionBar) {
|
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)
|
//Log with translation supported, call either on client or server (which then sends a message)
|
||||||
@@ -147,6 +147,6 @@ public class EffortlessBuilding {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onServerStarting(FMLServerStartingEvent event) {
|
public void onServerStarting(FMLServerStartingEvent event) {
|
||||||
CommandReach.register(event.getServer().getCommandManager().getDispatcher());
|
CommandReach.register(event.getServer().getCommands().getDispatcher());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class EventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
//Only called serverside (except with lilypads...)
|
//Only called serverside (except with lilypads...)
|
||||||
public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) {
|
public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) {
|
||||||
if (event.getWorld().isRemote()) return;
|
if (event.getWorld().isClientSide()) return;
|
||||||
|
|
||||||
if (!(event.getEntity() instanceof PlayerEntity)) return;
|
if (!(event.getEntity() instanceof PlayerEntity)) return;
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ public class EventHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onBlockBroken(BlockEvent.BreakEvent event) {
|
public static void onBlockBroken(BlockEvent.BreakEvent event) {
|
||||||
if (event.getWorld().isRemote()) return;
|
if (event.getWorld().isClientSide()) return;
|
||||||
|
|
||||||
if (event.getPlayer() instanceof FakePlayer) 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) {
|
if (event.getPlayer() instanceof ServerPlayerEntity && event.getState() != null && event.getPos() != null) {
|
||||||
PacketDistributor.PacketTarget packetTarget = PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) event.getPlayer());
|
PacketDistributor.PacketTarget packetTarget = PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) event.getPlayer());
|
||||||
if (packetTarget != null)
|
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;
|
if (event.getPlayer() instanceof FakePlayer) return;
|
||||||
|
|
||||||
PlayerEntity player = event.getPlayer();
|
PlayerEntity player = event.getPlayer();
|
||||||
World world = player.world;
|
World world = player.level;
|
||||||
BlockPos pos = event.getPos();
|
BlockPos pos = event.getPos();
|
||||||
|
|
||||||
//EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed()));
|
//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
|
if (originalBlockHardness < 0) return; //Dont break bedrock
|
||||||
float totalBlockHardness = 0;
|
float totalBlockHardness = 0;
|
||||||
//get coordinates
|
//get coordinates
|
||||||
@@ -144,7 +144,7 @@ public class EventHandler {
|
|||||||
BlockState blockState = world.getBlockState(coordinate);
|
BlockState blockState = world.getBlockState(coordinate);
|
||||||
//add hardness for each blockstate, if can break
|
//add hardness for each blockstate, if can break
|
||||||
if (SurvivalHelper.canBreak(world, player, coordinate))
|
if (SurvivalHelper.canBreak(world, player, coordinate))
|
||||||
totalBlockHardness += blockState.getBlockHardness(world, coordinate);
|
totalBlockHardness += blockState.getDestroySpeed(world, coordinate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Grabbing percentage from config
|
//Grabbing percentage from config
|
||||||
@@ -171,7 +171,7 @@ public class EventHandler {
|
|||||||
public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||||
if (event.getPlayer() instanceof FakePlayer) return;
|
if (event.getPlayer() instanceof FakePlayer) return;
|
||||||
PlayerEntity player = event.getPlayer();
|
PlayerEntity player = event.getPlayer();
|
||||||
if (player.getEntityWorld().isRemote) return;
|
if (player.getCommandSenderWorld().isClientSide) return;
|
||||||
|
|
||||||
UndoRedo.clear(player);
|
UndoRedo.clear(player);
|
||||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new ClearUndoMessage());
|
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new ClearUndoMessage());
|
||||||
@@ -189,7 +189,7 @@ public class EventHandler {
|
|||||||
public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||||
if (event.getPlayer() instanceof FakePlayer) return;
|
if (event.getPlayer() instanceof FakePlayer) return;
|
||||||
PlayerEntity player = event.getPlayer();
|
PlayerEntity player = event.getPlayer();
|
||||||
if (player.getEntityWorld().isRemote) return;
|
if (player.getCommandSenderWorld().isClientSide) return;
|
||||||
|
|
||||||
//Set build mode to normal
|
//Set build mode to normal
|
||||||
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ public class ModClientEventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static TextureAtlasSprite getBuildModeIcon(BuildModes.BuildModeEnum mode) {
|
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) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,20 +20,20 @@ public abstract class BaseBuildMode implements IBuildMode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(PlayerEntity player) {
|
public void initialize(PlayerEntity player) {
|
||||||
rightClickClientTable.put(player.getUniqueID(), 0);
|
rightClickClientTable.put(player.getUUID(), 0);
|
||||||
rightClickServerTable.put(player.getUniqueID(), 0);
|
rightClickServerTable.put(player.getUUID(), 0);
|
||||||
firstPosTable.put(player.getUniqueID(), BlockPos.ZERO);
|
firstPosTable.put(player.getUUID(), BlockPos.ZERO);
|
||||||
sideHitTable.put(player.getUniqueID(), Direction.UP);
|
sideHitTable.put(player.getUUID(), Direction.UP);
|
||||||
hitVecTable.put(player.getUniqueID(), Vector3d.ZERO);
|
hitVecTable.put(player.getUUID(), Vector3d.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Direction getSideHit(PlayerEntity player) {
|
public Direction getSideHit(PlayerEntity player) {
|
||||||
return sideHitTable.get(player.getUniqueID());
|
return sideHitTable.get(player.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector3d getHitVec(PlayerEntity player) {
|
public Vector3d getHitVec(PlayerEntity player) {
|
||||||
return hitVecTable.get(player.getUniqueID());
|
return hitVecTable.get(player.getUUID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class BuildModes {
|
|||||||
public static void onBlockPlacedMessage(PlayerEntity player, BlockPlacedMessage message) {
|
public static void onBlockPlacedMessage(PlayerEntity player, BlockPlacedMessage message) {
|
||||||
|
|
||||||
//Check if not in the middle of breaking
|
//Check if not in the middle of breaking
|
||||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer;
|
||||||
if (currentlyBreaking.get(player) != null && currentlyBreaking.get(player)) {
|
if (currentlyBreaking.get(player) != null && currentlyBreaking.get(player)) {
|
||||||
//Cancel breaking
|
//Cancel breaking
|
||||||
initializeMode(player);
|
initializeMode(player);
|
||||||
@@ -53,20 +53,20 @@ public class BuildModes {
|
|||||||
|
|
||||||
//Offset in direction of sidehit if not quickreplace and not replaceable
|
//Offset in direction of sidehit if not quickreplace and not replaceable
|
||||||
//TODO 1.13 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());
|
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, message.getSideHit());
|
||||||
if (!modifierSettings.doQuickReplace() && !replaceable && !becomesDoubleSlab) {
|
if (!modifierSettings.doQuickReplace() && !replaceable && !becomesDoubleSlab) {
|
||||||
startPos = startPos.offset(message.getSideHit());
|
startPos = startPos.relative(message.getSideHit());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get under tall grass and other replaceable blocks
|
//Get under tall grass and other replaceable blocks
|
||||||
if (modifierSettings.doQuickReplace() && replaceable) {
|
if (modifierSettings.doQuickReplace() && replaceable) {
|
||||||
startPos = startPos.down();
|
startPos = startPos.below();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if player reach does not exceed startpos
|
//Check if player reach does not exceed startpos
|
||||||
int maxReach = ReachHelper.getMaxReach(player);
|
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.");
|
EffortlessBuilding.log(player, "Placement exceeds your reach.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public class BuildModes {
|
|||||||
public static void onBlockBroken(PlayerEntity player, BlockPos startPos, boolean breakStartPos) {
|
public static void onBlockBroken(PlayerEntity player, BlockPos startPos, boolean breakStartPos) {
|
||||||
|
|
||||||
//Check if not in the middle of placing
|
//Check if not in the middle of placing
|
||||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer;
|
||||||
if (currentlyBreaking.get(player) != null && !currentlyBreaking.get(player)) {
|
if (currentlyBreaking.get(player) != null && !currentlyBreaking.get(player)) {
|
||||||
//Cancel placing
|
//Cancel placing
|
||||||
initializeMode(player);
|
initializeMode(player);
|
||||||
@@ -154,25 +154,25 @@ public class BuildModes {
|
|||||||
|
|
||||||
public static void initializeMode(PlayerEntity player) {
|
public static void initializeMode(PlayerEntity player) {
|
||||||
//Resetting mode, so not placing or breaking
|
//Resetting mode, so not placing or breaking
|
||||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer;
|
||||||
currentlyBreaking.remove(player);
|
currentlyBreaking.remove(player);
|
||||||
|
|
||||||
ModeSettingsManager.getModeSettings(player).getBuildMode().instance.initialize(player);
|
ModeSettingsManager.getModeSettings(player).getBuildMode().instance.initialize(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCurrentlyPlacing(PlayerEntity player) {
|
public static boolean isCurrentlyPlacing(PlayerEntity player) {
|
||||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer;
|
||||||
return currentlyBreaking.get(player) != null && !currentlyBreaking.get(player);
|
return currentlyBreaking.get(player) != null && !currentlyBreaking.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCurrentlyBreaking(PlayerEntity player) {
|
public static boolean isCurrentlyBreaking(PlayerEntity player) {
|
||||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer;
|
||||||
return currentlyBreaking.get(player) != null && currentlyBreaking.get(player);
|
return currentlyBreaking.get(player) != null && currentlyBreaking.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Either placing or breaking
|
//Either placing or breaking
|
||||||
public static boolean isActive(PlayerEntity player) {
|
public static boolean isActive(PlayerEntity player) {
|
||||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.level.isClientSide ? currentlyBreakingClient : currentlyBreakingServer;
|
||||||
return currentlyBreaking.get(player) != null;
|
return currentlyBreaking.get(player) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ public class BuildModes {
|
|||||||
|
|
||||||
//Use this instead of player.getLookVec() in any buildmodes code
|
//Use this instead of player.getLookVec() in any buildmodes code
|
||||||
public static Vector3d getPlayerLookVec(PlayerEntity player) {
|
public static Vector3d getPlayerLookVec(PlayerEntity player) {
|
||||||
Vector3d lookVec = player.getLookVec();
|
Vector3d lookVec = player.getLookAngle();
|
||||||
double x = lookVec.x;
|
double x = lookVec.x;
|
||||||
double y = lookVec.y;
|
double y = lookVec.y;
|
||||||
double z = lookVec.z;
|
double z = lookVec.z;
|
||||||
@@ -234,12 +234,12 @@ public class BuildModes {
|
|||||||
if (!skipRaytrace) {
|
if (!skipRaytrace) {
|
||||||
//collision within a 1 block radius to selected is fine
|
//collision within a 1 block radius to selected is fine
|
||||||
RayTraceContext rayTraceContext = new RayTraceContext(start, lineBound, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player);
|
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 &&
|
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 &&
|
distToPlayerSq > 2 && distToPlayerSq < reach * reach &&
|
||||||
!intersects;
|
!intersects;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ public class ModeOptions {
|
|||||||
modifierSettings.doQuickReplace() ? "on" : "off"), true);
|
modifierSettings.doQuickReplace() ? "on" : "off"), true);
|
||||||
break;
|
break;
|
||||||
case OPEN_MODIFIER_SETTINGS:
|
case OPEN_MODIFIER_SETTINGS:
|
||||||
if (player.world.isRemote)
|
if (player.level.isClientSide)
|
||||||
ClientProxy.openModifierSettings();
|
ClientProxy.openModifierSettings();
|
||||||
break;
|
break;
|
||||||
case OPEN_PLAYER_SETTINGS:
|
case OPEN_PLAYER_SETTINGS:
|
||||||
if (player.world.isRemote)
|
if (player.level.isClientSide)
|
||||||
ClientProxy.openPlayerSettings();
|
ClientProxy.openPlayerSettings();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ public class ModeOptions {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.world.isRemote &&
|
if (player.level.isClientSide &&
|
||||||
action != ActionEnum.REPLACE &&
|
action != ActionEnum.REPLACE &&
|
||||||
action != ActionEnum.OPEN_MODIFIER_SETTINGS &&
|
action != ActionEnum.OPEN_MODIFIER_SETTINGS &&
|
||||||
action != ActionEnum.OPEN_PLAYER_SETTINGS) {
|
action != ActionEnum.OPEN_PLAYER_SETTINGS) {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class ModeSettingsManager {
|
|||||||
getModeSettings(player);
|
getModeSettings(player);
|
||||||
|
|
||||||
//Only on server
|
//Only on server
|
||||||
if (!player.world.isRemote) {
|
if (!player.level.isClientSide) {
|
||||||
//Send to client
|
//Send to client
|
||||||
ModeSettingsMessage msg = new ModeSettingsMessage(getModeSettings(player));
|
ModeSettingsMessage msg = new ModeSettingsMessage(getModeSettings(player));
|
||||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), msg);
|
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), msg);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
|||||||
//Finds height after floor has been chosen in buildmodes with 3 clicks
|
//Finds height after floor has been chosen in buildmodes with 3 clicks
|
||||||
public static BlockPos findHeight(PlayerEntity player, BlockPos secondPos, boolean skipRaytrace) {
|
public static BlockPos findHeight(PlayerEntity player, BlockPos secondPos, boolean skipRaytrace) {
|
||||||
Vector3d look = BuildModes.getPlayerLookVec(player);
|
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<HeightCriteria> criteriaList = new ArrayList<>(3);
|
List<HeightCriteria> criteriaList = new ArrayList<>(3);
|
||||||
|
|
||||||
@@ -58,46 +58,46 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize(PlayerEntity player) {
|
public void initialize(PlayerEntity player) {
|
||||||
super.initialize(player);
|
super.initialize(player);
|
||||||
secondPosTable.put(player.getUniqueID(), BlockPos.ZERO);
|
secondPosTable.put(player.getUUID(), BlockPos.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BlockPos> onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vector3d hitVec, boolean skipRaytrace) {
|
public List<BlockPos> onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vector3d hitVec, boolean skipRaytrace) {
|
||||||
List<BlockPos> list = new ArrayList<>();
|
List<BlockPos> list = new ArrayList<>();
|
||||||
|
|
||||||
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
|
Dictionary<UUID, Integer> rightClickTable = player.level.isClientSide ? rightClickClientTable : rightClickServerTable;
|
||||||
int rightClickNr = rightClickTable.get(player.getUniqueID());
|
int rightClickNr = rightClickTable.get(player.getUUID());
|
||||||
rightClickNr++;
|
rightClickNr++;
|
||||||
rightClickTable.put(player.getUniqueID(), rightClickNr);
|
rightClickTable.put(player.getUUID(), rightClickNr);
|
||||||
|
|
||||||
if (rightClickNr == 1) {
|
if (rightClickNr == 1) {
|
||||||
//If clicking in air, reset and try again
|
//If clicking in air, reset and try again
|
||||||
if (blockPos == null) {
|
if (blockPos == null) {
|
||||||
rightClickTable.put(player.getUniqueID(), 0);
|
rightClickTable.put(player.getUUID(), 0);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
//First click, remember starting position
|
//First click, remember starting position
|
||||||
firstPosTable.put(player.getUniqueID(), blockPos);
|
firstPosTable.put(player.getUUID(), blockPos);
|
||||||
sideHitTable.put(player.getUniqueID(), sideHit);
|
sideHitTable.put(player.getUUID(), sideHit);
|
||||||
hitVecTable.put(player.getUniqueID(), hitVec);
|
hitVecTable.put(player.getUUID(), hitVec);
|
||||||
//Keep list empty, dont place any blocks yet
|
//Keep list empty, dont place any blocks yet
|
||||||
} else if (rightClickNr == 2) {
|
} else if (rightClickNr == 2) {
|
||||||
//Second click, find other floor point
|
//Second click, find other floor point
|
||||||
BlockPos firstPos = firstPosTable.get(player.getUniqueID());
|
BlockPos firstPos = firstPosTable.get(player.getUUID());
|
||||||
BlockPos secondPos = findSecondPos(player, firstPos, true);
|
BlockPos secondPos = findSecondPos(player, firstPos, true);
|
||||||
|
|
||||||
if (secondPos == null) {
|
if (secondPos == null) {
|
||||||
rightClickTable.put(player.getUniqueID(), 1);
|
rightClickTable.put(player.getUUID(), 1);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
secondPosTable.put(player.getUniqueID(), secondPos);
|
secondPosTable.put(player.getUUID(), secondPos);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//Third click, place diagonal wall with height
|
//Third click, place diagonal wall with height
|
||||||
list = findCoordinates(player, blockPos, skipRaytrace);
|
list = findCoordinates(player, blockPos, skipRaytrace);
|
||||||
rightClickTable.put(player.getUniqueID(), 0);
|
rightClickTable.put(player.getUUID(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@@ -106,14 +106,14 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
|||||||
@Override
|
@Override
|
||||||
public List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace) {
|
public List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace) {
|
||||||
List<BlockPos> list = new ArrayList<>();
|
List<BlockPos> list = new ArrayList<>();
|
||||||
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
|
Dictionary<UUID, Integer> rightClickTable = player.level.isClientSide ? rightClickClientTable : rightClickServerTable;
|
||||||
int rightClickNr = rightClickTable.get(player.getUniqueID());
|
int rightClickNr = rightClickTable.get(player.getUUID());
|
||||||
|
|
||||||
if (rightClickNr == 0) {
|
if (rightClickNr == 0) {
|
||||||
if (blockPos != null)
|
if (blockPos != null)
|
||||||
list.add(blockPos);
|
list.add(blockPos);
|
||||||
} else if (rightClickNr == 1) {
|
} else if (rightClickNr == 1) {
|
||||||
BlockPos firstPos = firstPosTable.get(player.getUniqueID());
|
BlockPos firstPos = firstPosTable.get(player.getUUID());
|
||||||
|
|
||||||
BlockPos secondPos = findSecondPos(player, firstPos, true);
|
BlockPos secondPos = findSecondPos(player, firstPos, true);
|
||||||
if (secondPos == null) return list;
|
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));
|
list.addAll(getIntermediateBlocks(player, x1, y1, z1, x2, y2, z2));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
BlockPos firstPos = firstPosTable.get(player.getUniqueID());
|
BlockPos firstPos = firstPosTable.get(player.getUUID());
|
||||||
BlockPos secondPos = secondPosTable.get(player.getUniqueID());
|
BlockPos secondPos = secondPosTable.get(player.getUUID());
|
||||||
|
|
||||||
BlockPos thirdPos = findThirdPos(player, firstPos, secondPos, skipRaytrace);
|
BlockPos thirdPos = findThirdPos(player, firstPos, secondPos, skipRaytrace);
|
||||||
if (thirdPos == null) return list;
|
if (thirdPos == null) return list;
|
||||||
@@ -193,8 +193,8 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
|||||||
HeightCriteria(Vector3d planeBound, BlockPos secondPos, Vector3d start) {
|
HeightCriteria(Vector3d planeBound, BlockPos secondPos, Vector3d start) {
|
||||||
this.planeBound = planeBound;
|
this.planeBound = planeBound;
|
||||||
this.lineBound = toLongestLine(this.planeBound, secondPos);
|
this.lineBound = toLongestLine(this.planeBound, secondPos);
|
||||||
this.distToLineSq = this.lineBound.subtract(this.planeBound).lengthSquared();
|
this.distToLineSq = this.lineBound.subtract(this.planeBound).lengthSqr();
|
||||||
this.distToPlayerSq = this.planeBound.subtract(start).lengthSquared();
|
this.distToPlayerSq = this.planeBound.subtract(start).lengthSqr();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Make it from a plane into a line, on y axis only
|
//Make it from a plane into a line, on y axis only
|
||||||
|
|||||||
@@ -17,27 +17,27 @@ public abstract class TwoClicksBuildMode extends BaseBuildMode {
|
|||||||
public List<BlockPos> onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vector3d hitVec, boolean skipRaytrace) {
|
public List<BlockPos> onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vector3d hitVec, boolean skipRaytrace) {
|
||||||
List<BlockPos> list = new ArrayList<>();
|
List<BlockPos> list = new ArrayList<>();
|
||||||
|
|
||||||
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
|
Dictionary<UUID, Integer> rightClickTable = player.level.isClientSide ? rightClickClientTable : rightClickServerTable;
|
||||||
int rightClickNr = rightClickTable.get(player.getUniqueID());
|
int rightClickNr = rightClickTable.get(player.getUUID());
|
||||||
rightClickNr++;
|
rightClickNr++;
|
||||||
rightClickTable.put(player.getUniqueID(), rightClickNr);
|
rightClickTable.put(player.getUUID(), rightClickNr);
|
||||||
|
|
||||||
if (rightClickNr == 1) {
|
if (rightClickNr == 1) {
|
||||||
//If clicking in air, reset and try again
|
//If clicking in air, reset and try again
|
||||||
if (blockPos == null) {
|
if (blockPos == null) {
|
||||||
rightClickTable.put(player.getUniqueID(), 0);
|
rightClickTable.put(player.getUUID(), 0);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
//First click, remember starting position
|
//First click, remember starting position
|
||||||
firstPosTable.put(player.getUniqueID(), blockPos);
|
firstPosTable.put(player.getUUID(), blockPos);
|
||||||
sideHitTable.put(player.getUniqueID(), sideHit);
|
sideHitTable.put(player.getUUID(), sideHit);
|
||||||
hitVecTable.put(player.getUniqueID(), hitVec);
|
hitVecTable.put(player.getUUID(), hitVec);
|
||||||
//Keep list empty, dont place any blocks yet
|
//Keep list empty, dont place any blocks yet
|
||||||
} else {
|
} else {
|
||||||
//Second click, place blocks
|
//Second click, place blocks
|
||||||
list = findCoordinates(player, blockPos, skipRaytrace);
|
list = findCoordinates(player, blockPos, skipRaytrace);
|
||||||
rightClickTable.put(player.getUniqueID(), 0);
|
rightClickTable.put(player.getUUID(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@@ -46,9 +46,9 @@ public abstract class TwoClicksBuildMode extends BaseBuildMode {
|
|||||||
@Override
|
@Override
|
||||||
public List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace) {
|
public List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace) {
|
||||||
List<BlockPos> list = new ArrayList<>();
|
List<BlockPos> list = new ArrayList<>();
|
||||||
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
|
Dictionary<UUID, Integer> rightClickTable = player.level.isClientSide ? rightClickClientTable : rightClickServerTable;
|
||||||
int rightClickNr = rightClickTable.get(player.getUniqueID());
|
int rightClickNr = rightClickTable.get(player.getUUID());
|
||||||
BlockPos firstPos = firstPosTable.get(player.getUniqueID());
|
BlockPos firstPos = firstPosTable.get(player.getUUID());
|
||||||
|
|
||||||
if (rightClickNr == 0) {
|
if (rightClickNr == 0) {
|
||||||
if (blockPos != null)
|
if (blockPos != null)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class Floor extends TwoClicksBuildMode {
|
|||||||
|
|
||||||
public static BlockPos findFloor(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
public static BlockPos findFloor(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||||
Vector3d look = BuildModes.getPlayerLookVec(player);
|
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<Criteria> criteriaList = new ArrayList<>(3);
|
List<Criteria> criteriaList = new ArrayList<>(3);
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ public class Floor extends TwoClicksBuildMode {
|
|||||||
|
|
||||||
Criteria(Vector3d planeBound, Vector3d start) {
|
Criteria(Vector3d planeBound, Vector3d start) {
|
||||||
this.planeBound = planeBound;
|
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
|
//check if its not behind the player and its not too close and not too far
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class Line extends TwoClicksBuildMode {
|
|||||||
|
|
||||||
public static BlockPos findLine(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
public static BlockPos findLine(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||||
Vector3d look = BuildModes.getPlayerLookVec(player);
|
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<Criteria> criteriaList = new ArrayList<>(3);
|
List<Criteria> criteriaList = new ArrayList<>(3);
|
||||||
|
|
||||||
@@ -112,8 +112,8 @@ public class Line extends TwoClicksBuildMode {
|
|||||||
Criteria(Vector3d planeBound, BlockPos firstPos, Vector3d start) {
|
Criteria(Vector3d planeBound, BlockPos firstPos, Vector3d start) {
|
||||||
this.planeBound = planeBound;
|
this.planeBound = planeBound;
|
||||||
this.lineBound = toLongestLine(this.planeBound, firstPos);
|
this.lineBound = toLongestLine(this.planeBound, firstPos);
|
||||||
this.distToLineSq = this.lineBound.subtract(this.planeBound).lengthSquared();
|
this.distToLineSq = this.lineBound.subtract(this.planeBound).lengthSqr();
|
||||||
this.distToPlayerSq = this.planeBound.subtract(start).lengthSquared();
|
this.distToPlayerSq = this.planeBound.subtract(start).lengthSqr();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Make it from a plane into a line
|
//Make it from a plane into a line
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class Wall extends TwoClicksBuildMode {
|
|||||||
|
|
||||||
public static BlockPos findWall(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
public static BlockPos findWall(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||||
Vector3d look = BuildModes.getPlayerLookVec(player);
|
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<Criteria> criteriaList = new ArrayList<>(3);
|
List<Criteria> criteriaList = new ArrayList<>(3);
|
||||||
|
|
||||||
@@ -120,8 +120,8 @@ public class Wall extends TwoClicksBuildMode {
|
|||||||
|
|
||||||
Criteria(Vector3d planeBound, BlockPos firstPos, Vector3d start, Vector3d look) {
|
Criteria(Vector3d planeBound, BlockPos firstPos, Vector3d start, Vector3d look) {
|
||||||
this.planeBound = planeBound;
|
this.planeBound = planeBound;
|
||||||
this.distToPlayerSq = this.planeBound.subtract(start).lengthSquared();
|
this.distToPlayerSq = this.planeBound.subtract(start).lengthSqr();
|
||||||
Vector3d wall = this.planeBound.subtract(Vector3d.copy(firstPos));
|
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)
|
this.angle = wall.x * look.x + wall.z * look.z; //dot product ignoring y (looking up/down should not affect this angle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class Array {
|
|||||||
Vector3i offset = new Vector3i(a.offset.getX(), a.offset.getY(), a.offset.getZ());
|
Vector3i offset = new Vector3i(a.offset.getX(), a.offset.getY(), a.offset.getZ());
|
||||||
|
|
||||||
for (int i = 0; i < a.count; i++) {
|
for (int i = 0; i < a.count; i++) {
|
||||||
pos = pos.add(offset);
|
pos = pos.offset(offset);
|
||||||
coordinates.add(pos);
|
coordinates.add(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ public class Array {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < a.count; i++) {
|
for (int i = 0; i < a.count; i++) {
|
||||||
pos = pos.add(offset);
|
pos = pos.offset(offset);
|
||||||
|
|
||||||
//Randomizer bag synergy
|
//Randomizer bag synergy
|
||||||
if (bagInventory != null) {
|
if (bagInventory != null) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class BuildModifiers {
|
|||||||
|
|
||||||
//Called from BuildModes
|
//Called from BuildModes
|
||||||
public static void onBlockPlaced(PlayerEntity player, List<BlockPos> startCoordinates, Direction sideHit, Vector3d hitVec, boolean placeStartPos) {
|
public static void onBlockPlaced(PlayerEntity player, List<BlockPos> startCoordinates, Direction sideHit, Vector3d hitVec, boolean placeStartPos) {
|
||||||
World world = player.world;
|
World world = player.level;
|
||||||
ItemRandomizerBag.renewRandomness();
|
ItemRandomizerBag.renewRandomness();
|
||||||
|
|
||||||
//Format hitvec to 0.x
|
//Format hitvec to 0.x
|
||||||
@@ -50,7 +50,7 @@ public class BuildModifiers {
|
|||||||
previousBlockStates.add(world.getBlockState(coordinate));
|
previousBlockStates.add(world.getBlockState(coordinate));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.isRemote) {
|
if (world.isClientSide) {
|
||||||
|
|
||||||
BlockPreviewRenderer.onBlocksPlaced();
|
BlockPreviewRenderer.onBlocksPlaced();
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ public class BuildModifiers {
|
|||||||
BlockState blockState = blockStates.get(i);
|
BlockState blockState = blockStates.get(i);
|
||||||
ItemStack itemStack = itemStacks.get(i);
|
ItemStack itemStack = itemStacks.get(i);
|
||||||
|
|
||||||
if (world.isBlockPresent(blockPos)) {
|
if (world.isLoaded(blockPos)) {
|
||||||
//check itemstack empty
|
//check itemstack empty
|
||||||
if (itemStack.isEmpty()) {
|
if (itemStack.isEmpty()) {
|
||||||
//try to find new stack, otherwise continue
|
//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
|
//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)
|
//(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
|
//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
|
//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
|
//add to undo stack
|
||||||
BlockPos firstPos = startCoordinates.get(0);
|
BlockPos firstPos = startCoordinates.get(0);
|
||||||
BlockPos secondPos = startCoordinates.get(startCoordinates.size() - 1);
|
BlockPos secondPos = startCoordinates.get(startCoordinates.size() - 1);
|
||||||
@@ -96,7 +96,7 @@ public class BuildModifiers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void onBlockBroken(PlayerEntity player, List<BlockPos> startCoordinates, boolean breakStartPos) {
|
public static void onBlockBroken(PlayerEntity player, List<BlockPos> startCoordinates, boolean breakStartPos) {
|
||||||
World world = player.world;
|
World world = player.level;
|
||||||
|
|
||||||
List<BlockPos> coordinates = findCoordinates(player, startCoordinates);
|
List<BlockPos> coordinates = findCoordinates(player, startCoordinates);
|
||||||
|
|
||||||
@@ -109,25 +109,25 @@ public class BuildModifiers {
|
|||||||
previousBlockStates.add(world.getBlockState(coordinate));
|
previousBlockStates.add(world.getBlockState(coordinate));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.isRemote) {
|
if (world.isClientSide) {
|
||||||
BlockPreviewRenderer.onBlocksBroken();
|
BlockPreviewRenderer.onBlocksBroken();
|
||||||
|
|
||||||
//list of air blockstates
|
//list of air blockstates
|
||||||
for (int i = 0; i < coordinates.size(); i++) {
|
for (int i = 0; i < coordinates.size(); i++) {
|
||||||
newBlockStates.add(Blocks.AIR.getDefaultState());
|
newBlockStates.add(Blocks.AIR.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//If the player is going to instabreak grass or a plant, only break other instabreaking things
|
//If the player is going to instabreak grass or a plant, only break other instabreaking things
|
||||||
boolean onlyInstaBreaking = !player.isCreative() &&
|
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
|
//break all those blocks
|
||||||
for (int i = breakStartPos ? 0 : 1; i < coordinates.size(); i++) {
|
for (int i = breakStartPos ? 0 : 1; i < coordinates.size(); i++) {
|
||||||
BlockPos coordinate = coordinates.get(i);
|
BlockPos coordinate = coordinates.get(i);
|
||||||
if (world.isBlockPresent(coordinate) && !world.isAirBlock(coordinate)) {
|
if (world.isLoaded(coordinate) && !world.isEmptyBlock(coordinate)) {
|
||||||
if (!onlyInstaBreaking || world.getBlockState(coordinate).getBlockHardness(world, coordinate) == 0f) {
|
if (!onlyInstaBreaking || world.getBlockState(coordinate).getDestroySpeed(world, coordinate) == 0f) {
|
||||||
SurvivalHelper.breakBlock(world, player, coordinate, false);
|
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
|
//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)
|
//(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
|
//add to undo stack
|
||||||
BlockPos firstPos = startCoordinates.get(0);
|
BlockPos firstPos = startCoordinates.get(0);
|
||||||
@@ -181,9 +181,9 @@ public class BuildModifiers {
|
|||||||
itemStacks.clear();
|
itemStacks.clear();
|
||||||
|
|
||||||
//Get itemstack
|
//Get itemstack
|
||||||
ItemStack itemStack = player.getHeldItem(Hand.MAIN_HAND);
|
ItemStack itemStack = player.getItemInHand(Hand.MAIN_HAND);
|
||||||
if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) {
|
if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) {
|
||||||
itemStack = player.getHeldItem(Hand.OFF_HAND);
|
itemStack = player.getItemInHand(Hand.OFF_HAND);
|
||||||
}
|
}
|
||||||
if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) {
|
if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) {
|
||||||
return blockStates;
|
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) {
|
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)
|
//Returns true if equal (or both null)
|
||||||
|
|||||||
@@ -160,39 +160,39 @@ public class Mirror {
|
|||||||
private static BlockState getVerticalMirror(BlockState blockState) {
|
private static BlockState getVerticalMirror(BlockState blockState) {
|
||||||
//Stairs
|
//Stairs
|
||||||
if (blockState.getBlock() instanceof StairsBlock) {
|
if (blockState.getBlock() instanceof StairsBlock) {
|
||||||
if (blockState.get(StairsBlock.HALF) == Half.BOTTOM) {
|
if (blockState.getValue(StairsBlock.HALF) == Half.BOTTOM) {
|
||||||
return blockState.with(StairsBlock.HALF, Half.TOP);
|
return blockState.setValue(StairsBlock.HALF, Half.TOP);
|
||||||
} else {
|
} else {
|
||||||
return blockState.with(StairsBlock.HALF, Half.BOTTOM);
|
return blockState.setValue(StairsBlock.HALF, Half.BOTTOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Slabs
|
//Slabs
|
||||||
if (blockState.getBlock() instanceof SlabBlock) {
|
if (blockState.getBlock() instanceof SlabBlock) {
|
||||||
if (blockState.get(SlabBlock.TYPE) == SlabType.DOUBLE) {
|
if (blockState.getValue(SlabBlock.TYPE) == SlabType.DOUBLE) {
|
||||||
return blockState;
|
return blockState;
|
||||||
} else if (blockState.get(SlabBlock.TYPE) == SlabType.BOTTOM) {
|
} else if (blockState.getValue(SlabBlock.TYPE) == SlabType.BOTTOM) {
|
||||||
return blockState.with(SlabBlock.TYPE, SlabType.TOP);
|
return blockState.setValue(SlabBlock.TYPE, SlabType.TOP);
|
||||||
} else {
|
} else {
|
||||||
return blockState.with(SlabBlock.TYPE, SlabType.BOTTOM);
|
return blockState.setValue(SlabBlock.TYPE, SlabType.BOTTOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Buttons, endrod, observer, piston
|
//Buttons, endrod, observer, piston
|
||||||
if (blockState.getBlock() instanceof DirectionalBlock) {
|
if (blockState.getBlock() instanceof DirectionalBlock) {
|
||||||
if (blockState.get(DirectionalBlock.FACING) == Direction.DOWN) {
|
if (blockState.getValue(DirectionalBlock.FACING) == Direction.DOWN) {
|
||||||
return blockState.with(DirectionalBlock.FACING, Direction.UP);
|
return blockState.setValue(DirectionalBlock.FACING, Direction.UP);
|
||||||
} else if (blockState.get(DirectionalBlock.FACING) == Direction.UP) {
|
} else if (blockState.getValue(DirectionalBlock.FACING) == Direction.UP) {
|
||||||
return blockState.with(DirectionalBlock.FACING, Direction.DOWN);
|
return blockState.setValue(DirectionalBlock.FACING, Direction.DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dispenser, dropper
|
//Dispenser, dropper
|
||||||
if (blockState.getBlock() instanceof DispenserBlock) {
|
if (blockState.getBlock() instanceof DispenserBlock) {
|
||||||
if (blockState.get(DispenserBlock.FACING) == Direction.DOWN) {
|
if (blockState.getValue(DispenserBlock.FACING) == Direction.DOWN) {
|
||||||
return blockState.with(DispenserBlock.FACING, Direction.UP);
|
return blockState.setValue(DispenserBlock.FACING, Direction.UP);
|
||||||
} else if (blockState.get(DispenserBlock.FACING) == Direction.UP) {
|
} else if (blockState.getValue(DispenserBlock.FACING) == Direction.UP) {
|
||||||
return blockState.with(DispenserBlock.FACING, Direction.DOWN);
|
return blockState.setValue(DispenserBlock.FACING, Direction.DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class ModifierSettingsManager {
|
|||||||
getModifierSettings(player);
|
getModifierSettings(player);
|
||||||
|
|
||||||
//Only on server
|
//Only on server
|
||||||
if (!player.world.isRemote) {
|
if (!player.level.isClientSide) {
|
||||||
//Send to client
|
//Send to client
|
||||||
ModifierSettingsMessage msg = new ModifierSettingsMessage(getModifierSettings(player));
|
ModifierSettingsMessage msg = new ModifierSettingsMessage(getModifierSettings(player));
|
||||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), msg);
|
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), msg);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class RadialMirror {
|
|||||||
curAngle = curAngle - startAngleInSlice + (sliceAngle - startAngleInSlice);
|
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));
|
BlockPos newBlockPos = new BlockPos(r.position.add(relNewVec));
|
||||||
if (!coordinates.contains(newBlockPos) && !newBlockPos.equals(startPos)) coordinates.add(newBlockPos);
|
if (!coordinates.contains(newBlockPos) && !newBlockPos.equals(startPos)) coordinates.add(newBlockPos);
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ public class RadialMirror {
|
|||||||
curAngle = curAngle - startAngleInSlice + (sliceAngle - startAngleInSlice);
|
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));
|
BlockPos newBlockPos = new BlockPos(r.position.add(relNewVec));
|
||||||
if (coordinates.contains(newBlockPos) || newBlockPos.equals(startPos)) continue; //filter out duplicates
|
if (coordinates.contains(newBlockPos) || newBlockPos.equals(startPos)) continue; //filter out duplicates
|
||||||
coordinates.add(newBlockPos);
|
coordinates.add(newBlockPos);
|
||||||
@@ -159,7 +159,7 @@ public class RadialMirror {
|
|||||||
public static boolean isEnabled(RadialMirrorSettings r, BlockPos startPos) {
|
public static boolean isEnabled(RadialMirrorSettings r, BlockPos startPos) {
|
||||||
if (r == null || !r.enabled) return false;
|
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);
|
r.radius * r.radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class UndoRedo {
|
|||||||
|
|
||||||
//add to undo stack
|
//add to undo stack
|
||||||
public static void addUndo(PlayerEntity player, BlockSet blockSet) {
|
public static void addUndo(PlayerEntity player, BlockSet blockSet) {
|
||||||
Map<UUID, FixedStack<BlockSet>> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer;
|
Map<UUID, FixedStack<BlockSet>> undoStacks = player.level.isClientSide ? undoStacksClient : undoStacksServer;
|
||||||
|
|
||||||
//Assert coordinates is as long as previous and new blockstate lists
|
//Assert coordinates is as long as previous and new blockstate lists
|
||||||
if (blockSet.getCoordinates().size() != blockSet.getPreviousBlockStates().size() ||
|
if (blockSet.getCoordinates().size() != blockSet.getPreviousBlockStates().size() ||
|
||||||
@@ -49,32 +49,32 @@ public class UndoRedo {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
//If no stack exists, make one
|
//If no stack exists, make one
|
||||||
if (!undoStacks.containsKey(player.getUniqueID())) {
|
if (!undoStacks.containsKey(player.getUUID())) {
|
||||||
undoStacks.put(player.getUniqueID(), new FixedStack<>(new BlockSet[BuildConfig.survivalBalancers.undoStackSize.get()]));
|
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) {
|
private static void addRedo(PlayerEntity player, BlockSet blockSet) {
|
||||||
Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer;
|
Map<UUID, FixedStack<BlockSet>> redoStacks = player.level.isClientSide ? redoStacksClient : redoStacksServer;
|
||||||
|
|
||||||
//(No asserts necessary, it's private)
|
//(No asserts necessary, it's private)
|
||||||
|
|
||||||
//If no stack exists, make one
|
//If no stack exists, make one
|
||||||
if (!redoStacks.containsKey(player.getUniqueID())) {
|
if (!redoStacks.containsKey(player.getUUID())) {
|
||||||
redoStacks.put(player.getUniqueID(), new FixedStack<>(new BlockSet[BuildConfig.survivalBalancers.undoStackSize.get()]));
|
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) {
|
public static boolean undo(PlayerEntity player) {
|
||||||
Map<UUID, FixedStack<BlockSet>> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer;
|
Map<UUID, FixedStack<BlockSet>> undoStacks = player.level.isClientSide ? undoStacksClient : undoStacksServer;
|
||||||
|
|
||||||
if (!undoStacks.containsKey(player.getUniqueID())) return false;
|
if (!undoStacks.containsKey(player.getUUID())) return false;
|
||||||
|
|
||||||
FixedStack<BlockSet> undoStack = undoStacks.get(player.getUniqueID());
|
FixedStack<BlockSet> undoStack = undoStacks.get(player.getUUID());
|
||||||
|
|
||||||
if (undoStack.isEmpty()) return false;
|
if (undoStack.isEmpty()) return false;
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class UndoRedo {
|
|||||||
//Find up to date itemstacks in player inventory
|
//Find up to date itemstacks in player inventory
|
||||||
List<ItemStack> itemStacks = findItemStacksInInventory(player, previousBlockStates);
|
List<ItemStack> itemStacks = findItemStacksInInventory(player, previousBlockStates);
|
||||||
|
|
||||||
if (player.world.isRemote) {
|
if (player.level.isClientSide) {
|
||||||
BlockPreviewRenderer.onBlocksBroken(coordinates, itemStacks, newBlockStates, blockSet.getSecondPos(), blockSet.getFirstPos());
|
BlockPreviewRenderer.onBlocksBroken(coordinates, itemStacks, newBlockStates, blockSet.getSecondPos(), blockSet.getFirstPos());
|
||||||
} else {
|
} else {
|
||||||
//break all those blocks, reset to what they were
|
//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;
|
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
||||||
|
|
||||||
//get blockstate from itemstack
|
//get blockstate from itemstack
|
||||||
BlockState previousBlockState = Blocks.AIR.getDefaultState();
|
BlockState previousBlockState = Blocks.AIR.defaultBlockState();
|
||||||
if (itemStack.getItem() instanceof BlockItem) {
|
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
|
//check itemstack empty
|
||||||
if (itemStack.isEmpty()) {
|
if (itemStack.isEmpty()) {
|
||||||
itemStack = findItemStackInInventory(player, previousBlockStates.get(i));
|
itemStack = findItemStackInInventory(player, previousBlockStates.get(i));
|
||||||
//get blockstate from new itemstack
|
//get blockstate from new itemstack
|
||||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
|
if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
|
||||||
previousBlockState = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
|
previousBlockState = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState();
|
||||||
} else {
|
} else {
|
||||||
if (previousBlockStates.get(i).getBlock() != Blocks.AIR)
|
if (previousBlockStates.get(i).getBlock() != Blocks.AIR)
|
||||||
EffortlessBuilding.logTranslate(player, "", previousBlockStates.get(i).getBlock().getTranslationKey(), " not found in inventory", true);
|
EffortlessBuilding.logTranslate(player, "", previousBlockStates.get(i).getBlock().getDescriptionId(), " not found in inventory", true);
|
||||||
previousBlockState = Blocks.AIR.getDefaultState();
|
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
|
//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) {
|
public static boolean redo(PlayerEntity player) {
|
||||||
Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer;
|
Map<UUID, FixedStack<BlockSet>> redoStacks = player.level.isClientSide ? redoStacksClient : redoStacksServer;
|
||||||
|
|
||||||
if (!redoStacks.containsKey(player.getUniqueID())) return false;
|
if (!redoStacks.containsKey(player.getUUID())) return false;
|
||||||
|
|
||||||
FixedStack<BlockSet> redoStack = redoStacks.get(player.getUniqueID());
|
FixedStack<BlockSet> redoStack = redoStacks.get(player.getUUID());
|
||||||
|
|
||||||
if (redoStack.isEmpty()) return false;
|
if (redoStack.isEmpty()) return false;
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ public class UndoRedo {
|
|||||||
//Find up to date itemstacks in player inventory
|
//Find up to date itemstacks in player inventory
|
||||||
List<ItemStack> itemStacks = findItemStacksInInventory(player, newBlockStates);
|
List<ItemStack> itemStacks = findItemStacksInInventory(player, newBlockStates);
|
||||||
|
|
||||||
if (player.world.isRemote) {
|
if (player.level.isClientSide) {
|
||||||
BlockPreviewRenderer.onBlocksPlaced(coordinates, itemStacks, newBlockStates, blockSet.getFirstPos(), blockSet.getSecondPos());
|
BlockPreviewRenderer.onBlocksPlaced(coordinates, itemStacks, newBlockStates, blockSet.getFirstPos(), blockSet.getSecondPos());
|
||||||
} else {
|
} else {
|
||||||
//place blocks
|
//place blocks
|
||||||
@@ -158,26 +158,26 @@ public class UndoRedo {
|
|||||||
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
||||||
|
|
||||||
//get blockstate from itemstack
|
//get blockstate from itemstack
|
||||||
BlockState newBlockState = Blocks.AIR.getDefaultState();
|
BlockState newBlockState = Blocks.AIR.defaultBlockState();
|
||||||
if (itemStack.getItem() instanceof BlockItem) {
|
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
|
//check itemstack empty
|
||||||
if (itemStack.isEmpty()) {
|
if (itemStack.isEmpty()) {
|
||||||
itemStack = findItemStackInInventory(player, newBlockStates.get(i));
|
itemStack = findItemStackInInventory(player, newBlockStates.get(i));
|
||||||
//get blockstate from new itemstack
|
//get blockstate from new itemstack
|
||||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
|
if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
|
||||||
newBlockState = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
|
newBlockState = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState();
|
||||||
} else {
|
} else {
|
||||||
if (newBlockStates.get(i).getBlock() != Blocks.AIR)
|
if (newBlockStates.get(i).getBlock() != Blocks.AIR)
|
||||||
EffortlessBuilding.logTranslate(player, "", newBlockStates.get(i).getBlock().getTranslationKey(), " not found in inventory", true);
|
EffortlessBuilding.logTranslate(player, "", newBlockStates.get(i).getBlock().getDescriptionId(), " not found in inventory", true);
|
||||||
newBlockState = Blocks.AIR.getDefaultState();
|
newBlockState = Blocks.AIR.defaultBlockState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.world, player, coordinate, true);
|
if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.level, player, coordinate, true);
|
||||||
SurvivalHelper.placeBlock(player.world, player, coordinate, newBlockState, itemStack, Direction.UP, hitVec, true, false, false);
|
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) {
|
public static void clear(PlayerEntity player) {
|
||||||
Map<UUID, FixedStack<BlockSet>> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer;
|
Map<UUID, FixedStack<BlockSet>> undoStacks = player.level.isClientSide ? undoStacksClient : undoStacksServer;
|
||||||
Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer;
|
Map<UUID, FixedStack<BlockSet>> redoStacks = player.level.isClientSide ? redoStacksClient : redoStacksServer;
|
||||||
if (undoStacks.containsKey(player.getUniqueID())) {
|
if (undoStacks.containsKey(player.getUUID())) {
|
||||||
undoStacks.get(player.getUniqueID()).clear();
|
undoStacks.get(player.getUUID()).clear();
|
||||||
}
|
}
|
||||||
if (redoStacks.containsKey(player.getUniqueID())) {
|
if (redoStacks.containsKey(player.getUUID())) {
|
||||||
redoStacks.get(player.getUniqueID()).clear();
|
redoStacks.get(player.getUUID()).clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,8 +220,8 @@ public class UndoRedo {
|
|||||||
//then anything it drops
|
//then anything it drops
|
||||||
if (itemStack.isEmpty()) {
|
if (itemStack.isEmpty()) {
|
||||||
//Cannot check drops on clientside because loot tables are server only
|
//Cannot check drops on clientside because loot tables are server only
|
||||||
if (!player.world.isRemote) {
|
if (!player.level.isClientSide) {
|
||||||
List<ItemStack> itemsDropped = Block.getDrops(blockState, (ServerWorld) player.world, BlockPos.ZERO, null);
|
List<ItemStack> itemsDropped = Block.getDrops(blockState, (ServerWorld) player.level, BlockPos.ZERO, null);
|
||||||
for (ItemStack itemStackDropped : itemsDropped) {
|
for (ItemStack itemStackDropped : itemsDropped) {
|
||||||
if (itemStackDropped.getItem() instanceof BlockItem) {
|
if (itemStackDropped.getItem() instanceof BlockItem) {
|
||||||
Block block = ((BlockItem) itemStackDropped.getItem()).getBlock();
|
Block block = ((BlockItem) itemStackDropped.getItem()).getBlock();
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
import static nl.requios.effortlessbuilding.buildmode.ModeSettingsManager.ModeSettings;
|
import static nl.requios.effortlessbuilding.buildmode.ModeSettingsManager.ModeSettings;
|
||||||
|
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager.ModeSettings;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class ModeCapabilityManager {
|
public class ModeCapabilityManager {
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
import static nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
import static nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
||||||
|
|
||||||
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class ModifierCapabilityManager {
|
public class ModifierCapabilityManager {
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ public class CommandReach {
|
|||||||
|
|
||||||
public static void register(CommandDispatcher<CommandSource> dispatcher) {
|
public static void register(CommandDispatcher<CommandSource> dispatcher) {
|
||||||
dispatcher.register(Commands.literal("reach").then(Commands.literal("set").then(Commands.argument("level", IntegerArgumentType.integer(0, 3)).executes((context) -> {
|
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 -> {
|
}))).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
|
//Send to client
|
||||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new ModifierSettingsMessage(modifierSettings));
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class CompatHelper {
|
|||||||
public static ItemStack getItemBlockByState(ItemStack stack, BlockState state) {
|
public static ItemStack getItemBlockByState(ItemStack stack, BlockState state) {
|
||||||
if (state == null) return ItemStack.EMPTY;
|
if (state == null) return ItemStack.EMPTY;
|
||||||
|
|
||||||
Item blockItem = Item.getItemFromBlock(state.getBlock());
|
Item blockItem = Item.byBlock(state.getBlock());
|
||||||
if (stack.getItem() instanceof BlockItem)
|
if (stack.getItem() instanceof BlockItem)
|
||||||
return stack;
|
return stack;
|
||||||
else if (stack.getItem() instanceof ItemRandomizerBag) {
|
else if (stack.getItem() instanceof ItemRandomizerBag) {
|
||||||
|
|||||||
@@ -59,34 +59,34 @@ public class RandomizerBagContainer extends Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(PlayerEntity playerIn) {
|
public boolean stillValid(PlayerEntity playerIn) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slot getSlot(int parSlotIndex) {
|
public Slot getSlot(int parSlotIndex) {
|
||||||
if (parSlotIndex >= inventorySlots.size())
|
if (parSlotIndex >= slots.size())
|
||||||
parSlotIndex = inventorySlots.size() - 1;
|
parSlotIndex = slots.size() - 1;
|
||||||
return super.getSlot(parSlotIndex);
|
return super.getSlot(parSlotIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int slotIndex) {
|
public ItemStack quickMoveStack(PlayerEntity playerIn, int slotIndex) {
|
||||||
ItemStack itemstack = ItemStack.EMPTY;
|
ItemStack itemstack = ItemStack.EMPTY;
|
||||||
Slot slot = this.inventorySlots.get(slotIndex);
|
Slot slot = this.slots.get(slotIndex);
|
||||||
|
|
||||||
if (slot != null && slot.getHasStack()) {
|
if (slot != null && slot.hasItem()) {
|
||||||
ItemStack itemstack1 = slot.getStack();
|
ItemStack itemstack1 = slot.getItem();
|
||||||
itemstack = itemstack1.copy();
|
itemstack = itemstack1.copy();
|
||||||
|
|
||||||
// If item is in our custom inventory
|
// If item is in our custom inventory
|
||||||
if (slotIndex < INV_START) {
|
if (slotIndex < INV_START) {
|
||||||
// try to place in player inventory / action bar
|
// 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;
|
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
|
// Item is in inventory / hotbar, try to place in custom inventory or armor slots
|
||||||
else {
|
else {
|
||||||
@@ -95,7 +95,7 @@ public class RandomizerBagContainer extends Container {
|
|||||||
*/
|
*/
|
||||||
if (slotIndex >= INV_START) {
|
if (slotIndex >= INV_START) {
|
||||||
// place in custom inventory
|
// place in custom inventory
|
||||||
if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) {
|
if (!this.moveItemStackTo(itemstack1, 0, INV_START, false)) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,9 +103,9 @@ public class RandomizerBagContainer extends Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (itemstack1.getCount() == 0) {
|
if (itemstack1.getCount() == 0) {
|
||||||
slot.putStack(ItemStack.EMPTY);
|
slot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
slot.onSlotChanged();
|
slot.setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemstack1.getCount() == itemstack.getCount()) {
|
if (itemstack1.getCount() == itemstack.getCount()) {
|
||||||
@@ -124,22 +124,22 @@ public class RandomizerBagContainer extends Container {
|
|||||||
* be able to save properly
|
* be able to save properly
|
||||||
*/
|
*/
|
||||||
@Override
|
@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:
|
// 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 ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
return super.slotClick(slot, dragType, clickTypeIn, player);
|
return super.clicked(slot, dragType, clickTypeIn, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for when the crafting gui is closed.
|
* Callback for when the crafting gui is closed.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onContainerClosed(PlayerEntity player) {
|
public void removed(PlayerEntity player) {
|
||||||
super.onContainerClosed(player);
|
super.removed(player);
|
||||||
if (!player.world.isRemote) {
|
if (!player.level.isClientSide) {
|
||||||
detectAndSendChanges();
|
broadcastChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,28 +20,28 @@ public class RandomizerBagScreen extends ContainerScreen<RandomizerBagContainer>
|
|||||||
|
|
||||||
public RandomizerBagScreen(RandomizerBagContainer randomizerBagContainer, PlayerInventory playerInventory, ITextComponent title) {
|
public RandomizerBagScreen(RandomizerBagContainer randomizerBagContainer, PlayerInventory playerInventory, ITextComponent title) {
|
||||||
super(randomizerBagContainer, playerInventory, title);//new TranslationTextComponent("effortlessbuilding.screen.randomizer_bag"));
|
super(randomizerBagContainer, playerInventory, title);//new TranslationTextComponent("effortlessbuilding.screen.randomizer_bag"));
|
||||||
ySize = 134;
|
imageHeight = 134;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
|
public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
renderBackground(ms);
|
renderBackground(ms);
|
||||||
super.render(ms, mouseX, mouseY, partialTicks);
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
this.renderHoveredTooltip(ms, mouseX, mouseY);
|
this.renderTooltip(ms, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int mouseY) {
|
protected void renderLabels(MatrixStack ms, int mouseX, int mouseY) {
|
||||||
font.func_243246_a(ms, this.title, 8, 6, 0x404040);
|
font.drawShadow(ms, this.title, 8, 6, 0x404040);
|
||||||
font.func_243246_a(ms, playerInventory.getDisplayName(), 8, ySize - 96 + 2, 0x404040);
|
font.drawShadow(ms, inventory.getDisplayName(), 8, imageHeight - 96 + 2, 0x404040);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
RenderSystem.color3f(1.0F, 1.0F, 1.0F);
|
||||||
minecraft.getTextureManager().bindTexture(guiTextures);
|
minecraft.getTextureManager().bind(guiTextures);
|
||||||
int marginHorizontal = (width - xSize) / 2;
|
int marginHorizontal = (width - imageWidth) / 2;
|
||||||
int marginVertical = (height - ySize) / 2;
|
int marginVertical = (height - imageHeight) / 2;
|
||||||
blit(ms, marginHorizontal, marginVertical, 0, 0, xSize, ySize);
|
blit(ms, marginHorizontal, marginVertical, 0, 0, imageWidth, imageHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
});
|
});
|
||||||
addButton(slider);
|
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);
|
addButton(closeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,10 +76,10 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
this.renderBackground(ms);
|
this.renderBackground(ms);
|
||||||
|
|
||||||
int yy = top;
|
int yy = top;
|
||||||
font.drawString(ms, "Shader type", left, yy + 5, 0xFFFFFF);
|
font.draw(ms, "Shader type", left, yy + 5, 0xFFFFFF);
|
||||||
|
|
||||||
yy += 50;
|
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);
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose() {
|
public void removed() {
|
||||||
ShaderTypeList.ShaderTypeEntry selectedShader = shaderTypeList.getSelected();
|
ShaderTypeList.ShaderTypeEntry selectedShader = shaderTypeList.getSelected();
|
||||||
//TODO save and remove
|
//TODO save and remove
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
@Override
|
@Override
|
||||||
public void setSelected(PlayerSettingsGui.ShaderTypeList.ShaderTypeEntry selected) {
|
public void setSelected(PlayerSettingsGui.ShaderTypeList.ShaderTypeEntry selected) {
|
||||||
super.setSelected(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);
|
EffortlessBuilding.log("Selected shader " + selected.shaderType.name);
|
||||||
shaderTypeButton.setMessage(selected.shaderType.name);
|
shaderTypeButton.setMessage(selected.shaderType.name);
|
||||||
// showShaderList = false;
|
// showShaderList = false;
|
||||||
@@ -186,7 +186,7 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isFocused() {
|
protected boolean isFocused() {
|
||||||
return PlayerSettingsGui.this.getListener() == this;
|
return PlayerSettingsGui.this.getFocused() == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -201,18 +201,18 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
int i = this.getScrollbarPosition();
|
int i = this.getScrollbarPosition();
|
||||||
int j = i + 6;
|
int j = i + 6;
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
||||||
// this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
|
// this.minecraft.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
|
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);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
float f = 32.0F;
|
float f = 32.0F;
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||||
bufferbuilder.pos(this.x0, this.y1, 0.0D).color(20, 20, 20, 180).endVertex();
|
bufferbuilder.vertex(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.vertex(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.vertex(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();
|
bufferbuilder.vertex(this.x0, this.y0, 0.0D).color(20, 20, 20, 180).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
int k = this.getRowLeft();
|
int k = this.getRowLeft();
|
||||||
int l = this.y0 + 4 - (int) this.getScrollAmount();
|
int l = this.y0 + 4 - (int) this.getScrollAmount();
|
||||||
if (this.renderHeader) {
|
if (this.renderHeader) {
|
||||||
@@ -253,23 +253,23 @@ public class PlayerSettingsGui extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
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.vertex(i, this.y1, 0.0D).uv(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.vertex(j, this.y1, 0.0D).uv(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.vertex(j, this.y0, 0.0D).uv(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();
|
bufferbuilder.vertex(i, this.y0, 0.0D).uv(0.0F, 0.0F).color(0, 0, 0, 255).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
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.vertex(i, l1 + k1, 0.0D).uv(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.vertex(j, l1 + k1, 0.0D).uv(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.vertex(j, l1, 0.0D).uv(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();
|
bufferbuilder.vertex(i, l1, 0.0D).uv(0.0F, 0.0F).color(128, 128, 128, 255).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
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.vertex(i, l1 + k1 - 1, 0.0D).uv(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.vertex(j - 1, l1 + k1 - 1, 0.0D).uv(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.vertex(j - 1, l1, 0.0D).uv(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();
|
bufferbuilder.vertex(i, l1, 0.0D).uv(0.0F, 0.0F).color(192, 192, 192, 255).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.renderDecorations(p_render_1_, p_render_2_);
|
// this.renderDecorations(p_render_1_, p_render_2_);
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import static nl.requios.effortlessbuilding.buildmode.BuildModes.BuildModeEnum;
|
import static nl.requios.effortlessbuilding.buildmode.BuildModes.BuildModeEnum;
|
||||||
import static nl.requios.effortlessbuilding.buildmode.ModeOptions.*;
|
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
|
* 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
|
* 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) {
|
public void configure(final int scaledWidth, final int scaledHeight) {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
font = mc.fontRenderer;
|
font = mc.font;
|
||||||
width = scaledWidth;
|
width = scaledWidth;
|
||||||
height = scaledHeight;
|
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.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||||
RenderSystem.shadeModel(GL11.GL_SMOOTH);
|
RenderSystem.shadeModel(GL11.GL_SMOOTH);
|
||||||
final Tessellator tessellator = Tessellator.getInstance();
|
final Tessellator tessellator = Tessellator.getInstance();
|
||||||
final BufferBuilder buffer = tessellator.getBuffer();
|
final BufferBuilder buffer = tessellator.getBuilder();
|
||||||
|
|
||||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
|
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
|
//Fix for high def (retina) displays: use custom mouse coordinates
|
||||||
//Borrowed from GameRenderer::updateCameraAndRender
|
//Borrowed from GameRenderer::updateCameraAndRender
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
int mouseXX = (int) (mc.mouseHelper.getMouseX() * (double) mc.getMainWindow().getScaledWidth() / (double) mc.getMainWindow().getWidth());
|
int mouseXX = (int) (mc.mouseHandler.xpos() * (double) mc.getWindow().getGuiScaledWidth() / (double) mc.getWindow().getScreenWidth());
|
||||||
int mouseYY = (int) (mc.mouseHelper.getMouseY() * (double) mc.getMainWindow().getScaledHeight() / (double) mc.getMainWindow().getHeight());
|
int mouseYY = (int) (mc.mouseHandler.ypos() * (double) mc.getWindow().getGuiScaledHeight() / (double) mc.getWindow().getScreenHeight());
|
||||||
|
|
||||||
final double mouseXCenter = mouseXX - middleX;
|
final double mouseXCenter = mouseXX - middleX;
|
||||||
final double mouseYCenter = mouseYY - middleY;
|
final double mouseYCenter = mouseYY - middleY;
|
||||||
@@ -210,10 +214,10 @@ public class RadialMenu extends Screen {
|
|||||||
switchTo = menuRegion.mode;
|
switchTo = menuRegion.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.pos(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(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.vertex(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.vertex(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 + x1m2, middleY + y1m2, getBlitOffset()).color(r, g, b, a).endVertex();
|
||||||
|
|
||||||
currentMode++;
|
currentMode++;
|
||||||
}
|
}
|
||||||
@@ -249,13 +253,13 @@ public class RadialMenu extends Screen {
|
|||||||
doAction = btn.action;
|
doAction = btn.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.pos(middleX + btn.x1, 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.pos(middleX + btn.x1, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(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.vertex(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.x2, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
|
|
||||||
RenderSystem.shadeModel(GL11.GL_FLAT);
|
RenderSystem.shadeModel(GL11.GL_FLAT);
|
||||||
|
|
||||||
@@ -264,7 +268,7 @@ public class RadialMenu extends Screen {
|
|||||||
RenderSystem.color3f(1f, 1f, 1f);
|
RenderSystem.color3f(1f, 1f, 1f);
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
RenderSystem.enableAlphaTest();
|
RenderSystem.enableAlphaTest();
|
||||||
mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
mc.getTextureManager().bind(AtlasTexture.LOCATION_BLOCKS);
|
||||||
|
|
||||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||||
|
|
||||||
@@ -289,10 +293,10 @@ public class RadialMenu extends Screen {
|
|||||||
final double v1 = 0;
|
final double v1 = 0;
|
||||||
final double v2 = 16;
|
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.vertex(middleX + x1, middleY + y1, getBlitOffset()).uv(sprite.getU(u1), sprite.getV(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.vertex(middleX + x1, middleY + y2, getBlitOffset()).uv(sprite.getU(u1), sprite.getV(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.vertex(middleX + x2, middleY + y2, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(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 + x2, middleY + y1, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(v1)).color(f, f, f, a).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw action icons
|
//Draw action icons
|
||||||
@@ -315,13 +319,13 @@ public class RadialMenu extends Screen {
|
|||||||
final double btny1 = btnmiddleY - 8;
|
final double btny1 = btnmiddleY - 8;
|
||||||
final double btny2 = 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.vertex(middleX + btnx1, middleY + btny1, getBlitOffset()).uv(sprite.getU(u1), sprite.getV(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.vertex(middleX + btnx1, middleY + btny2, getBlitOffset()).uv(sprite.getU(u1), sprite.getV(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.vertex(middleX + btnx2, middleY + btny2, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(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 + btnx2, middleY + btny1, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(v1)).color(f, f, f, a).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
|
|
||||||
//Draw strings
|
//Draw strings
|
||||||
//font.drawStringWithShadow("Actions", (int) (middleX - buttonDistance - 13) - font.getStringWidth("Actions") * 0.5f, (int) middleY - 38, 0xffffffff);
|
//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
|
//Draw option strings
|
||||||
for (int i = 0; i < currentBuildMode.options.length; i++) {
|
for (int i = 0; i < currentBuildMode.options.length; i++) {
|
||||||
OptionEnum option = options[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";
|
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
|
//Draw buildmode text
|
||||||
for (final MenuRegion menuRegion : modes) {
|
for (final MenuRegion menuRegion : modes) {
|
||||||
@@ -343,16 +347,16 @@ public class RadialMenu extends Screen {
|
|||||||
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5;
|
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5;
|
||||||
|
|
||||||
int fixed_x = (int) (x * textDistance);
|
int fixed_x = (int) (x * textDistance);
|
||||||
final int fixed_y = (int) (y * textDistance) - font.FONT_HEIGHT / 2;
|
final int fixed_y = (int) (y * textDistance) - font.lineHeight / 2;
|
||||||
final String text = I18n.format(menuRegion.mode.name);
|
final String text = I18n.get(menuRegion.mode.name);
|
||||||
|
|
||||||
if (x <= -0.2) {
|
if (x <= -0.2) {
|
||||||
fixed_x -= font.getStringWidth(text);
|
fixed_x -= font.width(text);
|
||||||
} else if (-0.2 <= x && x <= 0.2) {
|
} 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
|
//Add keybind in brackets
|
||||||
if (button.action == ActionEnum.UNDO) {
|
if (button.action == ActionEnum.UNDO) {
|
||||||
keybind = I18n.format(ClientProxy.keyBindings[4].getTranslationKey());
|
keybind = I18n.get(ClientProxy.keyBindings[4].saveString());
|
||||||
}
|
}
|
||||||
if (button.action == ActionEnum.REDO) {
|
if (button.action == ActionEnum.REDO) {
|
||||||
keybind = I18n.format(ClientProxy.keyBindings[5].getTranslationKey());
|
keybind = I18n.get(ClientProxy.keyBindings[5].saveString());
|
||||||
}
|
}
|
||||||
if (button.action == ActionEnum.REPLACE) {
|
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) {
|
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) {
|
if (currentBuildMode.options.length > 0) {
|
||||||
//Add (ctrl) to first two actions of first option
|
//Add (ctrl) to first two actions of first option
|
||||||
if (button.action == currentBuildMode.options[0].actions[0]
|
if (button.action == currentBuildMode.options[0].actions[0]
|
||||||
|| button.action == currentBuildMode.options[0].actions[1]) {
|
|| 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";
|
if (keybind.equals("Left Control")) keybind = "Ctrl";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -390,28 +394,28 @@ public class RadialMenu extends Screen {
|
|||||||
|
|
||||||
if (button.textSide == Direction.WEST) {
|
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);
|
(int) (middleY + button.y1 + 6), 0xffffffff);
|
||||||
|
|
||||||
} else if (button.textSide == Direction.EAST) {
|
} 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);
|
(int) (middleY + button.y1 + 6), 0xffffffff);
|
||||||
|
|
||||||
} else if (button.textSide == Direction.UP || button.textSide == Direction.NORTH) {
|
} 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);
|
(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);
|
(int) (middleY + button.y1 - 14), 0xffffffff);
|
||||||
|
|
||||||
} else if (button.textSide == Direction.DOWN || button.textSide == Direction.SOUTH) {
|
} 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);
|
(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);
|
(int) (middleY + button.y1 + 38), 0xffffffff);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -441,14 +445,14 @@ public class RadialMenu extends Screen {
|
|||||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||||
EffortlessBuilding.log("mouse clicked");
|
EffortlessBuilding.log("mouse clicked");
|
||||||
|
|
||||||
KeyBinding.updateKeyBindState();
|
KeyBinding.setAll();
|
||||||
KeyBinding.setKeyBindState(ClientProxy.keyBindings[3].getKey(), true);
|
KeyBinding.set(ClientProxy.keyBindings[3].getKey(), true);
|
||||||
|
|
||||||
if (mouseButton == 0) {
|
if (mouseButton == 0) {
|
||||||
this.minecraft.displayGuiScreen(null);
|
this.minecraft.setScreen(null);
|
||||||
|
|
||||||
if (this.minecraft.currentScreen == null) {
|
if (this.minecraft.screen == null) {
|
||||||
this.minecraft.setGameFocused(true);
|
this.minecraft.setWindowActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mouseClicked(mouseX, mouseY, mouseButton);
|
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,
|
public MenuButton(final String name, final ActionEnum action, final double x, final double y,
|
||||||
final Direction textSide) {
|
final Direction textSide) {
|
||||||
this.name = I18n.format(name);
|
this.name = I18n.get(name);
|
||||||
this.action = action;
|
this.action = action;
|
||||||
x1 = x - 10;
|
x1 = x - 10;
|
||||||
x2 = x + 10;
|
x2 = x + 10;
|
||||||
|
|||||||
@@ -94,31 +94,31 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
buttonArrayEnabled.render(ms, mouseX, mouseY, partialTicks);
|
buttonArrayEnabled.render(ms, mouseX, mouseY, partialTicks);
|
||||||
if (buttonArrayEnabled.isChecked()) {
|
if (buttonArrayEnabled.isChecked()) {
|
||||||
buttonArrayEnabled.y = yy;
|
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;
|
yy = y + 20;
|
||||||
font.drawString(ms, "Offset", left + offset, yy + 5, 0xFFFFFF);
|
font.draw(ms, "Offset", left + offset, yy + 5, 0xFFFFFF);
|
||||||
font.drawString(ms, "X", left + 50 + offset, yy + 5, 0xFFFFFF);
|
font.draw(ms, "X", left + 50 + offset, yy + 5, 0xFFFFFF);
|
||||||
textArrayOffsetX.y = yy;
|
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;
|
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;
|
textArrayOffsetZ.y = yy;
|
||||||
|
|
||||||
yy = y + 50;
|
yy = y + 50;
|
||||||
font.drawString(ms, "Count", left + offset, yy + 5, 0xFFFFFF);
|
font.draw(ms, "Count", left + offset, yy + 5, 0xFFFFFF);
|
||||||
textArrayCount.y = yy;
|
textArrayCount.y = yy;
|
||||||
|
|
||||||
int currentReach = Math.max(-1, getArrayReach());
|
int currentReach = Math.max(-1, getArrayReach());
|
||||||
int maxReach = ReachHelper.getMaxReach(mc.player);
|
int maxReach = ReachHelper.getMaxReach(mc.player);
|
||||||
TextFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? TextFormatting.GRAY : TextFormatting.RED;
|
TextFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? TextFormatting.GRAY : TextFormatting.RED;
|
||||||
String reachText = "Reach: " + reachColor + currentReach + TextFormatting.GRAY + "/" + TextFormatting.GRAY + maxReach;
|
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));
|
arrayNumberFieldList.forEach(numberField -> numberField.drawNumberField(ms, mouseX, mouseY, partialTicks));
|
||||||
} else {
|
} else {
|
||||||
buttonArrayEnabled.y = yy;
|
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;
|
boolean insideArrayEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
|
||||||
|
|
||||||
if (insideArrayEnabledLabel) {
|
if (insideArrayEnabledLabel) {
|
||||||
buttonArrayEnabled.playDownSound(this.mc.getSoundHandler());
|
buttonArrayEnabled.playDownSound(this.mc.getSoundManager());
|
||||||
buttonArrayEnabled.onClick(mouseX, mouseY);
|
buttonArrayEnabled.onClick(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,17 +57,17 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
textMirrorPosX = new GuiNumberField(font, buttonList, left + 58, y, 62, 18);
|
textMirrorPosX = new GuiNumberField(font, buttonList, left + 58, y, 62, 18);
|
||||||
textMirrorPosX.setNumber(0);
|
textMirrorPosX.setNumber(0);
|
||||||
textMirrorPosX.setTooltip(
|
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);
|
mirrorNumberFieldList.add(textMirrorPosX);
|
||||||
|
|
||||||
textMirrorPosY = new GuiNumberField(font, buttonList, left + 138, y, 62, 18);
|
textMirrorPosY = new GuiNumberField(font, buttonList, left + 138, y, 62, 18);
|
||||||
textMirrorPosY.setNumber(64);
|
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);
|
mirrorNumberFieldList.add(textMirrorPosY);
|
||||||
|
|
||||||
textMirrorPosZ = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
textMirrorPosZ = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||||
textMirrorPosZ.setNumber(0);
|
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);
|
mirrorNumberFieldList.add(textMirrorPosZ);
|
||||||
|
|
||||||
y = top + 50;
|
y = top + 50;
|
||||||
@@ -85,13 +85,13 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
textMirrorRadius.setNumber(50);
|
textMirrorRadius.setNumber(50);
|
||||||
//TODO change to diameter (remove /2)
|
//TODO change to diameter (remove /2)
|
||||||
textMirrorRadius.setTooltip(Arrays.asList(new StringTextComponent("How far the mirror reaches in any direction."),
|
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("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.").mergeStyle(TextFormatting.GRAY)));
|
new StringTextComponent("Upgradeable in survival with reach upgrades.").withStyle(TextFormatting.GRAY)));
|
||||||
mirrorNumberFieldList.add(textMirrorRadius);
|
mirrorNumberFieldList.add(textMirrorRadius);
|
||||||
|
|
||||||
y = top + 72;
|
y = top + 72;
|
||||||
buttonCurrentPosition = new GuiIconButton(left + 5, y, 0, 0, BUILDING_ICONS, button -> {
|
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);
|
textMirrorPosX.setNumber(pos.x);
|
||||||
textMirrorPosY.setNumber(pos.y);
|
textMirrorPosY.setNumber(pos.y);
|
||||||
textMirrorPosZ.setNumber(pos.z);
|
textMirrorPosZ.setNumber(pos.z);
|
||||||
@@ -182,23 +182,23 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
buttonMirrorEnabled.render(ms, mouseX, mouseY, partialTicks);
|
buttonMirrorEnabled.render(ms, mouseX, mouseY, partialTicks);
|
||||||
if (buttonMirrorEnabled.isChecked()) {
|
if (buttonMirrorEnabled.isChecked()) {
|
||||||
buttonMirrorEnabled.y = yy;
|
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;
|
yy = y + 18;
|
||||||
font.drawString(ms, "Position", left + offset, yy + 5, 0xFFFFFF);
|
font.draw(ms, "Position", left + offset, yy + 5, 0xFFFFFF);
|
||||||
font.drawString(ms, "X", left + 40 + offset, yy + 5, 0xFFFFFF);
|
font.draw(ms, "X", left + 40 + offset, yy + 5, 0xFFFFFF);
|
||||||
textMirrorPosX.y = yy;
|
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;
|
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;
|
textMirrorPosZ.y = yy;
|
||||||
|
|
||||||
yy = y + 50;
|
yy = y + 50;
|
||||||
font.drawString(ms, "Direction", left + offset, yy + 2, 0xFFFFFF);
|
font.draw(ms, "Direction", left + offset, yy + 2, 0xFFFFFF);
|
||||||
buttonMirrorX.y = yy;
|
buttonMirrorX.y = yy;
|
||||||
buttonMirrorY.y = yy;
|
buttonMirrorY.y = yy;
|
||||||
buttonMirrorZ.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;
|
textMirrorRadius.y = yy - 3;
|
||||||
|
|
||||||
yy = y + 72;
|
yy = y + 72;
|
||||||
@@ -212,7 +212,7 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
mirrorNumberFieldList.forEach(numberField -> numberField.drawNumberField(ms, mouseX, mouseY, partialTicks));
|
mirrorNumberFieldList.forEach(numberField -> numberField.drawNumberField(ms, mouseX, mouseY, partialTicks));
|
||||||
} else {
|
} else {
|
||||||
buttonMirrorEnabled.y = yy;
|
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;
|
boolean insideMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
|
||||||
|
|
||||||
if (insideMirrorEnabledLabel) {
|
if (insideMirrorEnabledLabel) {
|
||||||
buttonMirrorEnabled.playDownSound(this.mc.getSoundHandler());
|
buttonMirrorEnabled.playDownSound(this.mc.getSoundManager());
|
||||||
buttonMirrorEnabled.onClick(mouseX, mouseY);
|
buttonMirrorEnabled.onClick(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
//Close button
|
//Close button
|
||||||
int y = height - 26;
|
int y = height - 26;
|
||||||
buttonClose = new Button(width / 2 - 100, y, 200, 20, new StringTextComponent("Close"), (button) -> {
|
buttonClose = new Button(width / 2 - 100, y, 200, 20, new StringTextComponent("Close"), (button) -> {
|
||||||
Minecraft.getInstance().player.closeScreen();
|
Minecraft.getInstance().player.closeContainer();
|
||||||
});
|
});
|
||||||
buttons.add(buttonClose);
|
buttons.add(buttonClose);
|
||||||
}
|
}
|
||||||
@@ -82,8 +82,8 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
public boolean charTyped(char typedChar, int keyCode) {
|
public boolean charTyped(char typedChar, int keyCode) {
|
||||||
super.charTyped(typedChar, keyCode);
|
super.charTyped(typedChar, keyCode);
|
||||||
scrollPane.charTyped(typedChar, keyCode);
|
scrollPane.charTyped(typedChar, keyCode);
|
||||||
if (keyCode == ClientProxy.keyBindings[0].getKey().getKeyCode()) {
|
if (keyCode == ClientProxy.keyBindings[0].getKey().getValue()) {
|
||||||
minecraft.player.closeScreen();
|
minecraft.player.closeContainer();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose() {
|
public void removed() {
|
||||||
scrollPane.onGuiClosed();
|
scrollPane.onGuiClosed();
|
||||||
|
|
||||||
//save everything
|
//save everything
|
||||||
@@ -137,7 +137,7 @@ public class ModifierSettingsGui extends Screen {
|
|||||||
//Send to server
|
//Send to server
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModifierSettingsMessage(modifierSettings));
|
PacketHandler.INSTANCE.sendToServer(new ModifierSettingsMessage(modifierSettings));
|
||||||
|
|
||||||
Minecraft.getInstance().mouseHelper.grabMouse();
|
Minecraft.getInstance().mouseHandler.grabMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,36 +57,36 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
textRadialMirrorPosX = new GuiNumberField(font, buttonList, left + 58, y, 62, 18);
|
textRadialMirrorPosX = new GuiNumberField(font, buttonList, left + 58, y, 62, 18);
|
||||||
textRadialMirrorPosX.setNumber(0);
|
textRadialMirrorPosX.setNumber(0);
|
||||||
textRadialMirrorPosX.setTooltip(
|
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);
|
radialMirrorNumberFieldList.add(textRadialMirrorPosX);
|
||||||
|
|
||||||
textRadialMirrorPosY = new GuiNumberField(font, buttonList, left + 138, y, 62, 18);
|
textRadialMirrorPosY = new GuiNumberField(font, buttonList, left + 138, y, 62, 18);
|
||||||
textRadialMirrorPosY.setNumber(64);
|
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);
|
radialMirrorNumberFieldList.add(textRadialMirrorPosY);
|
||||||
|
|
||||||
textRadialMirrorPosZ = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
textRadialMirrorPosZ = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||||
textRadialMirrorPosZ.setNumber(0);
|
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);
|
radialMirrorNumberFieldList.add(textRadialMirrorPosZ);
|
||||||
|
|
||||||
y = top + 47;
|
y = top + 47;
|
||||||
textRadialMirrorSlices = new GuiNumberField(font, buttonList, left + 55, y, 50, 18);
|
textRadialMirrorSlices = new GuiNumberField(font, buttonList, left + 55, y, 50, 18);
|
||||||
textRadialMirrorSlices.setNumber(4);
|
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);
|
radialMirrorNumberFieldList.add(textRadialMirrorSlices);
|
||||||
|
|
||||||
textRadialMirrorRadius = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
textRadialMirrorRadius = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||||
textRadialMirrorRadius.setNumber(50);
|
textRadialMirrorRadius.setNumber(50);
|
||||||
//TODO change to diameter (remove /2)
|
//TODO change to diameter (remove /2)
|
||||||
textRadialMirrorRadius.setTooltip(Arrays.asList(new StringTextComponent("How far the radial mirror reaches from its center position."),
|
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("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.").mergeStyle(TextFormatting.GRAY)));
|
new StringTextComponent("Upgradeable in survival with reach upgrades.").withStyle(TextFormatting.GRAY)));
|
||||||
radialMirrorNumberFieldList.add(textRadialMirrorRadius);
|
radialMirrorNumberFieldList.add(textRadialMirrorRadius);
|
||||||
|
|
||||||
y = top + 72;
|
y = top + 72;
|
||||||
buttonCurrentPosition = new GuiIconButton(left + 5, y, 0, 0, BUILDING_ICONS, button -> {
|
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);
|
textRadialMirrorPosX.setNumber(pos.x);
|
||||||
textRadialMirrorPosY.setNumber(pos.y);
|
textRadialMirrorPosY.setNumber(pos.y);
|
||||||
textRadialMirrorPosZ.setNumber(pos.z);
|
textRadialMirrorPosZ.setNumber(pos.z);
|
||||||
@@ -179,21 +179,21 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
buttonRadialMirrorEnabled.render(ms, mouseX, mouseY, partialTicks);
|
buttonRadialMirrorEnabled.render(ms, mouseX, mouseY, partialTicks);
|
||||||
if (buttonRadialMirrorEnabled.isChecked()) {
|
if (buttonRadialMirrorEnabled.isChecked()) {
|
||||||
buttonRadialMirrorEnabled.y = yy;
|
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;
|
yy = y + 18;
|
||||||
font.drawString(ms, "Position", left + offset, yy + 5, 0xFFFFFF);
|
font.draw(ms, "Position", left + offset, yy + 5, 0xFFFFFF);
|
||||||
font.drawString(ms, "X", left + 40 + offset, yy + 5, 0xFFFFFF);
|
font.draw(ms, "X", left + 40 + offset, yy + 5, 0xFFFFFF);
|
||||||
textRadialMirrorPosX.y = yy;
|
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;
|
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;
|
textRadialMirrorPosZ.y = yy;
|
||||||
|
|
||||||
yy = y + 50;
|
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;
|
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;
|
textRadialMirrorRadius.y = yy - 3;
|
||||||
|
|
||||||
yy = y + 72;
|
yy = y + 72;
|
||||||
@@ -211,7 +211,7 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
|||||||
.forEach(numberField -> numberField.drawNumberField(ms, mouseX, mouseY, partialTicks));
|
.forEach(numberField -> numberField.drawNumberField(ms, mouseX, mouseY, partialTicks));
|
||||||
} else {
|
} else {
|
||||||
buttonRadialMirrorEnabled.y = yy;
|
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;
|
boolean insideRadialMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
|
||||||
|
|
||||||
if (insideRadialMirrorEnabledLabel) {
|
if (insideRadialMirrorEnabledLabel) {
|
||||||
buttonRadialMirrorEnabled.playDownSound(this.mc.getSoundHandler());
|
buttonRadialMirrorEnabled.playDownSound(this.mc.getSoundManager());
|
||||||
buttonRadialMirrorEnabled.onClick(mouseX, mouseY);
|
buttonRadialMirrorEnabled.onClick(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ public class GuiCheckBoxFixed extends Button {
|
|||||||
private boolean isChecked;
|
private boolean isChecked;
|
||||||
|
|
||||||
public GuiCheckBoxFixed(int xPos, int yPos, String displayString, 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.isChecked = isChecked;
|
||||||
this.boxWidth = 11;
|
this.boxWidth = 11;
|
||||||
this.height = 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
|
@Override
|
||||||
@@ -41,9 +41,9 @@ public class GuiCheckBoxFixed extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.isChecked)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class GuiIconButton extends Button {
|
|||||||
super.render(ms, mouseX, mouseY, partialTicks);
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
if (this.visible) {
|
if (this.visible) {
|
||||||
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
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 currentIconX = this.iconX;
|
||||||
int currentIconY = this.iconY;
|
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;
|
boolean flag = mouseX >= x && mouseX < x + width && mouseY >= y && mouseY < y + height;
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
screen.func_243308_b(ms, tooltip, mouseX - 10, mouseY + 25);
|
screen.renderComponentTooltip(ms, tooltip, mouseX - 10, mouseY + 25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,16 +61,16 @@ public class GuiNumberField extends AbstractGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double getNumber() {
|
public double getNumber() {
|
||||||
if (textField.getText().isEmpty()) return 0;
|
if (textField.getValue().isEmpty()) return 0;
|
||||||
try {
|
try {
|
||||||
return DecimalFormat.getInstance().parse(textField.getText()).doubleValue();
|
return DecimalFormat.getInstance().parse(textField.getValue()).doubleValue();
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumber(double number) {
|
public void setNumber(double number) {
|
||||||
textField.setText(DecimalFormat.getInstance().format(number));
|
textField.setValue(DecimalFormat.getInstance().format(number));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTooltip(ITextComponent tooltip) {
|
public void setTooltip(ITextComponent tooltip) {
|
||||||
@@ -89,8 +89,8 @@ public class GuiNumberField extends AbstractGui {
|
|||||||
|
|
||||||
//Rightclicked inside textfield
|
//Rightclicked inside textfield
|
||||||
if (flag && mouseButton == 1) {
|
if (flag && mouseButton == 1) {
|
||||||
textField.setText("");
|
textField.setValue("");
|
||||||
textField.setFocused2(true);
|
textField.setFocus(true);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,20 +123,20 @@ public class GuiNumberField extends AbstractGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (insideMinusButton) {
|
if (insideMinusButton) {
|
||||||
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("shift ").mergeStyle(TextFormatting.AQUA)).appendString("for ")
|
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("shift ").withStyle(TextFormatting.AQUA)).append("for ")
|
||||||
.append(new StringTextComponent("10").mergeStyle(TextFormatting.RED)));
|
.append(new StringTextComponent("10").withStyle(TextFormatting.RED)));
|
||||||
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("ctrl ").mergeStyle(TextFormatting.AQUA)).appendString("for ")
|
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("ctrl ").withStyle(TextFormatting.AQUA)).append("for ")
|
||||||
.append(new StringTextComponent("5").mergeStyle(TextFormatting.RED)));
|
.append(new StringTextComponent("5").withStyle(TextFormatting.RED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insidePlusButton) {
|
if (insidePlusButton) {
|
||||||
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("shift ").mergeStyle(TextFormatting.DARK_GREEN)).appendString("for ")
|
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("shift ").withStyle(TextFormatting.DARK_GREEN)).append("for ")
|
||||||
.append(new StringTextComponent("10").mergeStyle(TextFormatting.RED)));
|
.append(new StringTextComponent("10").withStyle(TextFormatting.RED)));
|
||||||
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("ctrl ").mergeStyle(TextFormatting.DARK_GREEN)).appendString("for ")
|
textLines.add(new StringTextComponent("Hold ").append(new StringTextComponent("ctrl ").withStyle(TextFormatting.DARK_GREEN)).append("for ")
|
||||||
.append(new StringTextComponent("5").mergeStyle(TextFormatting.RED)));
|
.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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
this.capYPosition();
|
this.capYPosition();
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
||||||
|
|
||||||
int insideLeft = this.x0 + this.width / 2 - this.getRowWidth() / 2 + 2;
|
int insideLeft = this.x0 + this.width / 2 - this.getRowWidth() / 2 + 2;
|
||||||
int insideTop = this.y0 + 4 - (int) this.yo;
|
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.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.vertex(scrollbarLeft, this.y1, 0.0F).uv(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.vertex(scrollbarRight, this.y1, 0.0F).uv(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.vertex(scrollbarRight, this.y0, 0.0F).uv(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();
|
bufferbuilder.vertex(scrollbarLeft, this.y0, 0.0F).uv(0.0F, 0.0F).color(0, 0, 0, 255).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
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.vertex(scrollbarLeft, l1 + k1, 0.0F).uv(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.vertex(scrollbarRight, l1 + k1, 0.0F).uv(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.vertex(scrollbarRight, l1, 0.0F).uv(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();
|
bufferbuilder.vertex(scrollbarLeft, l1, 0.0F).uv(0.0F, 0.0F).color(128, 128, 128, 255).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
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.vertex(scrollbarLeft, l1 + k1 - 1, 0.0F).uv(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.vertex(scrollbarRight - 1, l1 + k1 - 1, 0.0F).uv(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.vertex(scrollbarRight - 1, l1, 0.0F).uv(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();
|
bufferbuilder.vertex(scrollbarLeft, l1, 0.0F).uv(0.0F, 0.0F).color(192, 192, 192, 255).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.renderDecorations(mouseXIn, mouseYIn);
|
//this.renderDecorations(mouseXIn, mouseYIn);
|
||||||
@@ -210,7 +210,7 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends IGuiEventListener> getEventListeners() {
|
public List<? extends IGuiEventListener> children() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
|
|
||||||
public void handleMouseInput() {
|
public void handleMouseInput() {
|
||||||
if (this.isMouseInList(this.mouseX, this.mouseY)) {
|
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) {
|
this.mouseY <= this.y1) {
|
||||||
int i = this.x0 + (this.width - this.getRowWidth()) / 2;
|
int i = this.x0 + (this.width - this.getRowWidth()) / 2;
|
||||||
int j = 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) {
|
if (this.yDrag == -1) {
|
||||||
boolean flag1 = true;
|
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) {
|
protected void renderList(MatrixStack ms, int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks) {
|
||||||
int itemCount = this.getItemCount();
|
int itemCount = this.getItemCount();
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
||||||
|
|
||||||
//Find y to start with
|
//Find y to start with
|
||||||
int y = this.headerHeight + insideTop;
|
int y = this.headerHeight + insideTop;
|
||||||
@@ -363,18 +363,18 @@ public class GuiScrollPane extends SlotGui {
|
|||||||
float f = this.isFocused() ? 1.0F : 0.5F;
|
float f = this.isFocused() ? 1.0F : 0.5F;
|
||||||
RenderSystem.color4f(f, f, f, 1.0F);
|
RenderSystem.color4f(f, f, f, 1.0F);
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||||
bufferbuilder.pos(i1, y + entryHeight2 + 2, 0.0D).endVertex();
|
bufferbuilder.vertex(i1, y + entryHeight2 + 2, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(j1, y + entryHeight2 + 2, 0.0D).endVertex();
|
bufferbuilder.vertex(j1, y + entryHeight2 + 2, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(j1, y - 2, 0.0D).endVertex();
|
bufferbuilder.vertex(j1, y - 2, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(i1, y - 2, 0.0D).endVertex();
|
bufferbuilder.vertex(i1, y - 2, 0.0D).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
RenderSystem.color4f(0.0F, 0.0F, 0.0F, 1.0F);
|
RenderSystem.color4f(0.0F, 0.0F, 0.0F, 1.0F);
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||||
bufferbuilder.pos(i1 + 1, y + entryHeight2 + 1, 0.0D).endVertex();
|
bufferbuilder.vertex(i1 + 1, y + entryHeight2 + 1, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(j1 - 1, y + entryHeight2 + 1, 0.0D).endVertex();
|
bufferbuilder.vertex(j1 - 1, y + entryHeight2 + 1, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(j1 - 1, y - 1, 0.0D).endVertex();
|
bufferbuilder.vertex(j1 - 1, y - 1, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(i1 + 1, y - 1, 0.0D).endVertex();
|
bufferbuilder.vertex(i1 + 1, y - 1, 0.0D).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
RenderSystem.enableTexture();
|
RenderSystem.enableTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public abstract class SlotGui extends FocusableGui implements IRenderable {
|
|||||||
return true;
|
return true;
|
||||||
} else if (i != -1 && this.selectItem(i, p_mouseClicked_5_, p_mouseClicked_1_, p_mouseClicked_3_)) {
|
} else if (i != -1 && this.selectItem(i, p_mouseClicked_5_, p_mouseClicked_1_, p_mouseClicked_3_)) {
|
||||||
if (this.children().size() > i) {
|
if (this.children().size() > i) {
|
||||||
this.setListener(this.children().get(i));
|
this.setFocused(this.children().get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setDragging(true);
|
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_) {
|
public boolean mouseReleased(double p_mouseReleased_1_, double p_mouseReleased_3_, int p_mouseReleased_5_) {
|
||||||
if (this.getListener() != null) {
|
if (this.getFocused() != null) {
|
||||||
this.getListener().mouseReleased(p_mouseReleased_1_, p_mouseReleased_3_, p_mouseReleased_5_);
|
this.getFocused().mouseReleased(p_mouseReleased_1_, p_mouseReleased_3_, p_mouseReleased_5_);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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_) {
|
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();
|
int i = this.getItemCount();
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
||||||
|
|
||||||
for (int j = 0; j < i; ++j) {
|
for (int j = 0; j < i; ++j) {
|
||||||
int k = p_renderList_2_ + j * this.itemHeight + this.headerHeight;
|
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;
|
float f = this.isFocused() ? 1.0F : 0.5F;
|
||||||
RenderSystem.color4f(f, f, f, 1.0F);
|
RenderSystem.color4f(f, f, f, 1.0F);
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||||
bufferbuilder.pos(i1, k + l + 2, 0.0D).endVertex();
|
bufferbuilder.vertex(i1, k + l + 2, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(j1, k + l + 2, 0.0D).endVertex();
|
bufferbuilder.vertex(j1, k + l + 2, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(j1, k - 2, 0.0D).endVertex();
|
bufferbuilder.vertex(j1, k - 2, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(i1, k - 2, 0.0D).endVertex();
|
bufferbuilder.vertex(i1, k - 2, 0.0D).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
RenderSystem.color4f(0.0F, 0.0F, 0.0F, 1.0F);
|
RenderSystem.color4f(0.0F, 0.0F, 0.0F, 1.0F);
|
||||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||||
bufferbuilder.pos(i1 + 1, k + l + 1, 0.0D).endVertex();
|
bufferbuilder.vertex(i1 + 1, k + l + 1, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(j1 - 1, k + l + 1, 0.0D).endVertex();
|
bufferbuilder.vertex(j1 - 1, k + l + 1, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(j1 - 1, k - 1, 0.0D).endVertex();
|
bufferbuilder.vertex(j1 - 1, k - 1, 0.0D).endVertex();
|
||||||
bufferbuilder.pos(i1 + 1, k - 1, 0.0D).endVertex();
|
bufferbuilder.vertex(i1 + 1, k - 1, 0.0D).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
RenderSystem.enableTexture();
|
RenderSystem.enableTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
public class InventoryHelper {
|
public class InventoryHelper {
|
||||||
|
|
||||||
public static ItemStack findItemStackInInventory(PlayerEntity player, Block block) {
|
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 &&
|
if (!invStack.isEmpty() && invStack.getItem() instanceof BlockItem &&
|
||||||
((BlockItem) invStack.getItem()).getBlock().equals(block)) {
|
((BlockItem) invStack.getItem()).getBlock().equals(block)) {
|
||||||
return invStack;
|
return invStack;
|
||||||
@@ -19,7 +19,7 @@ public class InventoryHelper {
|
|||||||
|
|
||||||
public static int findTotalBlocksInInventory(PlayerEntity player, Block block) {
|
public static int findTotalBlocksInInventory(PlayerEntity player, Block block) {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (ItemStack invStack : player.inventory.mainInventory) {
|
for (ItemStack invStack : player.inventory.items) {
|
||||||
if (!invStack.isEmpty() && invStack.getItem() instanceof BlockItem &&
|
if (!invStack.isEmpty() && invStack.getItem() instanceof BlockItem &&
|
||||||
((BlockItem) invStack.getItem()).getBlock().equals(block)) {
|
((BlockItem) invStack.getItem()).getBlock().equals(block)) {
|
||||||
total += invStack.getCount();
|
total += invStack.getCount();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class SurvivalHelper {
|
|||||||
public static boolean placeBlock(World world, PlayerEntity player, BlockPos pos, BlockState blockState,
|
public static boolean placeBlock(World world, PlayerEntity player, BlockPos pos, BlockState blockState,
|
||||||
ItemStack origstack, Direction facing, Vector3d hitVec, boolean skipPlaceCheck,
|
ItemStack origstack, Direction facing, Vector3d hitVec, boolean skipPlaceCheck,
|
||||||
boolean skipCollisionCheck, boolean playSound) {
|
boolean skipCollisionCheck, boolean playSound) {
|
||||||
if (!world.isBlockPresent(pos)) return false;
|
if (!world.isLoaded(pos)) return false;
|
||||||
ItemStack itemstack = origstack;
|
ItemStack itemstack = origstack;
|
||||||
|
|
||||||
if (blockState.getBlock().isAir(blockState, world, pos) || itemstack.isEmpty()) {
|
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
|
//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);
|
// 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);
|
// EnumActionResult result = ((ItemBlock) itemstack.getItem()).tryPlace(blockItemUseContext);
|
||||||
if (!world.setBlockState(pos, blockState, 3)) return false;
|
if (!world.setBlock(pos, blockState, 3)) return false;
|
||||||
BlockItem.setTileEntityNBT(world, player, pos, itemstack); //Actually BlockItem::onBlockPlaced but that is protected
|
BlockItem.updateCustomBlockEntityTag(world, player, pos, itemstack); //Actually BlockItem::onBlockPlaced but that is protected
|
||||||
block.onBlockPlacedBy(world, pos, blockState, player, itemstack);
|
block.setPlacedBy(world, pos, blockState, player, itemstack);
|
||||||
if (player instanceof ServerPlayerEntity) {
|
if (player instanceof ServerPlayerEntity) {
|
||||||
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) player, pos, itemstack);
|
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);
|
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);
|
CompatHelper.shrinkStack(origstack, itemstack, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ public class SurvivalHelper {
|
|||||||
//Used for all breaking of blocks in this mod.
|
//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
|
//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) {
|
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
|
//Check if can break
|
||||||
if (skipChecks || canBreak(world, player, pos)) {
|
if (skipChecks || canBreak(world, player, pos)) {
|
||||||
@@ -120,7 +120,7 @@ public class SurvivalHelper {
|
|||||||
dropBlock(world, player, pos);
|
dropBlock(world, player, pos);
|
||||||
|
|
||||||
//Damage tool
|
//Damage tool
|
||||||
player.getHeldItemMainhand().onBlockDestroyed(world, world.getBlockState(pos), pos, player);
|
player.getMainHandItem().mineBlock(world, world.getBlockState(pos), pos, player);
|
||||||
|
|
||||||
world.removeBlock(pos, false);
|
world.removeBlock(pos, false);
|
||||||
return true;
|
return true;
|
||||||
@@ -135,7 +135,7 @@ public class SurvivalHelper {
|
|||||||
BlockState blockState = world.getBlockState(pos);
|
BlockState blockState = world.getBlockState(pos);
|
||||||
Block block = blockState.getBlock();
|
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
|
//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) {
|
public static boolean canPlace(World world, PlayerEntity player, BlockPos pos, BlockState newBlockState, ItemStack itemStack, boolean skipCollisionCheck, Direction sidePlacedOn) {
|
||||||
|
|
||||||
//Check if itemstack is correct
|
//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(player, "Cannot (re)place block", true);
|
||||||
// EffortlessBuilding.log("SurvivalHelper#canPlace: itemstack " + itemStack.toString() + " does not match blockstate " + newBlockState.toString());
|
// EffortlessBuilding.log("SurvivalHelper#canPlace: itemstack " + itemStack.toString() + " does not match blockstate " + newBlockState.toString());
|
||||||
//Happens when breaking blocks, no need to notify in that case
|
//Happens when breaking blocks, no need to notify in that case
|
||||||
@@ -205,7 +205,7 @@ public class SurvivalHelper {
|
|||||||
|
|
||||||
switch (BuildConfig.survivalBalancers.quickReplaceMiningLevel.get()) {
|
switch (BuildConfig.survivalBalancers.quickReplaceMiningLevel.get()) {
|
||||||
case -1:
|
case -1:
|
||||||
return !state.getRequiresTool();
|
return !state.requiresCorrectToolForDrops();
|
||||||
case 0:
|
case 0:
|
||||||
return state.getBlock().getHarvestLevel(state) <= 0;
|
return state.getBlock().getHarvestLevel(state) <= 0;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -221,15 +221,15 @@ public class SurvivalHelper {
|
|||||||
|
|
||||||
//From EntityPlayer#canPlayerEdit
|
//From EntityPlayer#canPlayerEdit
|
||||||
private static boolean canPlayerEdit(PlayerEntity player, World world, BlockPos pos, ItemStack stack) {
|
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
|
//True in creative and survival mode
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
//Adventure mode
|
//Adventure mode
|
||||||
CachedBlockInfo blockworldstate = new CachedBlockInfo(world, pos, false);
|
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
|
//From World#mayPlace
|
||||||
private static boolean mayPlace(World world, Block blockIn, BlockState newBlockState, BlockPos pos, boolean skipCollisionCheck, Direction sidePlacedOn, @Nullable Entity placer) {
|
private static boolean mayPlace(World world, Block blockIn, BlockState newBlockState, BlockPos pos, boolean skipCollisionCheck, Direction sidePlacedOn, @Nullable Entity placer) {
|
||||||
BlockState iblockstate1 = world.getBlockState(pos);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ public class SurvivalHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO 1.14 check what Material.CIRCUITS has become
|
//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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,34 +284,34 @@ public class SurvivalHelper {
|
|||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
|
|
||||||
//Dont break bedrock
|
//Dont break bedrock
|
||||||
if (state.getBlockHardness(world, pos) < 0) {
|
if (state.getDestroySpeed(world, pos) < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.getRequiresTool()) {
|
if (!state.requiresCorrectToolForDrops()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
ItemStack stack = player.getMainHandItem();
|
||||||
ToolType tool = block.getHarvestTool(state);
|
ToolType tool = block.getHarvestTool(state);
|
||||||
if (stack.isEmpty() || tool == null) {
|
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);
|
int toolLevel = stack.getItem().getHarvestLevel(stack, tool, player, state);
|
||||||
if (toolLevel < 0) {
|
if (toolLevel < 0) {
|
||||||
return player.func_234569_d_(state);
|
return player.hasCorrectToolForDrops(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
return toolLevel >= block.getHarvestLevel(state);
|
return toolLevel >= block.getHarvestLevel(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean doesBecomeDoubleSlab(PlayerEntity player, BlockPos pos, Direction facing) {
|
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))
|
if (CompatHelper.isItemBlockProxy(itemstack))
|
||||||
itemstack = CompatHelper.getItemBlockFromStack(itemstack);
|
itemstack = CompatHelper.getItemBlockFromStack(itemstack);
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class ItemRandomizerBag extends Item {
|
|||||||
private static final Random rand = new Random(currentSeed);
|
private static final Random rand = new Random(currentSeed);
|
||||||
|
|
||||||
public ItemRandomizerBag() {
|
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");
|
this.setRegistryName(EffortlessBuilding.MODID, "randomizer_bag");
|
||||||
}
|
}
|
||||||
@@ -122,22 +122,22 @@ public class ItemRandomizerBag extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onItemUse(ItemUseContext ctx) {
|
public ActionResultType useOn(ItemUseContext ctx) {
|
||||||
PlayerEntity player = ctx.getPlayer();
|
PlayerEntity player = ctx.getPlayer();
|
||||||
World world = ctx.getWorld();
|
World world = ctx.getLevel();
|
||||||
BlockPos pos = ctx.getPos();
|
BlockPos pos = ctx.getClickedPos();
|
||||||
Direction facing = ctx.getFace();
|
Direction facing = ctx.getClickedFace();
|
||||||
ItemStack item = ctx.getItem();
|
ItemStack item = ctx.getItemInHand();
|
||||||
Vector3d hitVec = ctx.getHitVec();
|
Vector3d hitVec = ctx.getClickLocation();
|
||||||
|
|
||||||
if (player == null) return ActionResultType.FAIL;
|
if (player == null) return ActionResultType.FAIL;
|
||||||
|
|
||||||
if (ctx.getPlayer() != null && ctx.getPlayer().isSneaking()) { //ctx.isPlacerSneaking()
|
if (ctx.getPlayer() != null && ctx.getPlayer().isShiftKeyDown()) { //ctx.isPlacerSneaking()
|
||||||
if (world.isRemote) return ActionResultType.SUCCESS;
|
if (world.isClientSide) return ActionResultType.SUCCESS;
|
||||||
//Open inventory
|
//Open inventory
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, new ContainerProvider(item));
|
NetworkHooks.openGui((ServerPlayerEntity) player, new ContainerProvider(item));
|
||||||
} else {
|
} else {
|
||||||
if (world.isRemote) return ActionResultType.SUCCESS;
|
if (world.isClientSide) return ActionResultType.SUCCESS;
|
||||||
|
|
||||||
//Only place manually if in normal vanilla mode
|
//Only place manually if in normal vanilla mode
|
||||||
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||||
@@ -149,7 +149,7 @@ public class ItemRandomizerBag extends Item {
|
|||||||
//Use item
|
//Use item
|
||||||
//Get bag inventory
|
//Get bag inventory
|
||||||
//TODO offhand support
|
//TODO offhand support
|
||||||
ItemStack bag = player.getHeldItem(Hand.MAIN_HAND);
|
ItemStack bag = player.getItemInHand(Hand.MAIN_HAND);
|
||||||
IItemHandler bagInventory = getBagInventory(bag);
|
IItemHandler bagInventory = getBagInventory(bag);
|
||||||
if (bagInventory == null)
|
if (bagInventory == null)
|
||||||
return ActionResultType.FAIL;
|
return ActionResultType.FAIL;
|
||||||
@@ -162,12 +162,12 @@ public class ItemRandomizerBag extends Item {
|
|||||||
//toPlace.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
//toPlace.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||||
|
|
||||||
//TODO replaceable
|
//TODO replaceable
|
||||||
if (!world.getBlockState(pos).getBlock().isReplaceable(world.getBlockState(pos), Fluids.EMPTY)) {
|
if (!world.getBlockState(pos).getBlock().canBeReplaced(world.getBlockState(pos), Fluids.EMPTY)) {
|
||||||
pos = pos.offset(facing);
|
pos = pos.relative(facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockItemUseContext blockItemUseContext = new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, new BlockRayTraceResult(hitVec, facing, pos, false)));
|
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);
|
SurvivalHelper.placeBlock(world, player, pos, blockState, toPlace, facing, hitVec, false, false, true);
|
||||||
|
|
||||||
@@ -182,11 +182,11 @@ public class ItemRandomizerBag extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||||
ItemStack bag = player.getHeldItem(hand);
|
ItemStack bag = player.getItemInHand(hand);
|
||||||
|
|
||||||
if (player.isSneaking()) {
|
if (player.isShiftKeyDown()) {
|
||||||
if (world.isRemote) return new ActionResult<>(ActionResultType.SUCCESS, bag);
|
if (world.isClientSide) return new ActionResult<>(ActionResultType.SUCCESS, bag);
|
||||||
//Open inventory
|
//Open inventory
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, new ContainerProvider(bag));
|
NetworkHooks.openGui((ServerPlayerEntity) player, new ContainerProvider(bag));
|
||||||
} else {
|
} else {
|
||||||
@@ -199,7 +199,7 @@ public class ItemRandomizerBag extends Item {
|
|||||||
ItemStack toUse = pickRandomStack(bagInventory);
|
ItemStack toUse = pickRandomStack(bagInventory);
|
||||||
if (toUse.isEmpty()) return new ActionResult<>(ActionResultType.FAIL, bag);
|
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);
|
return new ActionResult<>(ActionResultType.PASS, bag);
|
||||||
}
|
}
|
||||||
@@ -216,16 +216,16 @@ public class ItemRandomizerBag extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
public void appendHoverText(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
||||||
tooltip.add(new StringTextComponent(TextFormatting.BLUE + "Rightclick" + TextFormatting.GRAY + " to place a random block"));
|
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"));
|
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"));
|
tooltip.add(new StringTextComponent(TextFormatting.YELLOW + "Experimental on servers: may lose inventory"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTranslationKey() {
|
public String getDescriptionId() {
|
||||||
return this.getRegistryName().toString();
|
return this.getRegistryName().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,16 +25,16 @@ import java.util.List;
|
|||||||
public class ItemReachUpgrade1 extends Item {
|
public class ItemReachUpgrade1 extends Item {
|
||||||
|
|
||||||
public ItemReachUpgrade1() {
|
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");
|
this.setRegistryName(EffortlessBuilding.MODID, "reach_upgrade1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||||
if (player.isCreative()) {
|
if (player.isCreative()) {
|
||||||
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
if (world.isClientSide) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
||||||
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
if (world.isClientSide) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
||||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||||
@@ -42,29 +42,29 @@ public class ItemReachUpgrade1 extends Item {
|
|||||||
if (currentLevel == 0) {
|
if (currentLevel == 0) {
|
||||||
modifierSettings.setReachUpgrade(1);
|
modifierSettings.setReachUpgrade(1);
|
||||||
|
|
||||||
if (world.isRemote) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player));
|
if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player));
|
||||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||||
|
|
||||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup"));
|
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup"));
|
||||||
player.playSound(soundEvent, 1f, 1f);
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
} else if (currentLevel > 0) {
|
} else if (currentLevel > 0) {
|
||||||
if (world.isRemote)
|
if (world.isClientSide)
|
||||||
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper
|
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper
|
||||||
.getMaxReach(player) + ".");
|
.getMaxReach(player) + ".");
|
||||||
|
|
||||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
player.playSound(soundEvent, 1f, 1f);
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
}
|
}
|
||||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
public void appendHoverText(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
||||||
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel1.get()));
|
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel1.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTranslationKey() {
|
public String getDescriptionId() {
|
||||||
return this.getRegistryName().toString();
|
return this.getRegistryName().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,51 +25,51 @@ import java.util.List;
|
|||||||
public class ItemReachUpgrade2 extends Item {
|
public class ItemReachUpgrade2 extends Item {
|
||||||
|
|
||||||
public ItemReachUpgrade2() {
|
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");
|
this.setRegistryName(EffortlessBuilding.MODID, "reach_upgrade2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||||
if (player.isCreative()) {
|
if (player.isCreative()) {
|
||||||
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
if (world.isClientSide) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
||||||
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
if (world.isClientSide) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
||||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||||
int currentLevel = modifierSettings.getReachUpgrade();
|
int currentLevel = modifierSettings.getReachUpgrade();
|
||||||
if (currentLevel == 1) {
|
if (currentLevel == 1) {
|
||||||
modifierSettings.setReachUpgrade(2);
|
modifierSettings.setReachUpgrade(2);
|
||||||
if (world.isRemote) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player));
|
if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player));
|
||||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||||
|
|
||||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup"));
|
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup"));
|
||||||
player.playSound(soundEvent, 1f, 1f);
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
} else if (currentLevel < 1) {
|
} 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"));
|
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
player.playSound(soundEvent, 1f, 1f);
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
} else if (currentLevel > 1) {
|
} else if (currentLevel > 1) {
|
||||||
if (world.isRemote)
|
if (world.isClientSide)
|
||||||
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper
|
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper
|
||||||
.getMaxReach(player) + ".");
|
.getMaxReach(player) + ".");
|
||||||
|
|
||||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
player.playSound(soundEvent, 1f, 1f);
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
}
|
}
|
||||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
public void appendHoverText(ItemStack stack, @Nullable World world, List<ITextComponent> 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 + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel2.get()));
|
||||||
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTranslationKey() {
|
public String getDescriptionId() {
|
||||||
return this.getRegistryName().toString();
|
return this.getRegistryName().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,54 +25,54 @@ import java.util.List;
|
|||||||
public class ItemReachUpgrade3 extends Item {
|
public class ItemReachUpgrade3 extends Item {
|
||||||
|
|
||||||
public ItemReachUpgrade3() {
|
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");
|
this.setRegistryName(EffortlessBuilding.MODID, "reach_upgrade3");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||||
if (player.isCreative()) {
|
if (player.isCreative()) {
|
||||||
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
if (world.isClientSide) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
||||||
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
if (world.isClientSide) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
||||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||||
int currentLevel = modifierSettings.getReachUpgrade();
|
int currentLevel = modifierSettings.getReachUpgrade();
|
||||||
if (currentLevel == 2) {
|
if (currentLevel == 2) {
|
||||||
modifierSettings.setReachUpgrade(3);
|
modifierSettings.setReachUpgrade(3);
|
||||||
if (world.isRemote) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player));
|
if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player));
|
||||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||||
|
|
||||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup"));
|
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup"));
|
||||||
player.playSound(soundEvent, 1f, 1f);
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
} else if (currentLevel < 2) {
|
} else if (currentLevel < 2) {
|
||||||
if (currentLevel == 0)
|
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 (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"));
|
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
player.playSound(soundEvent, 1f, 1f);
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
} else if (currentLevel > 2) {
|
} else if (currentLevel > 2) {
|
||||||
if (world.isRemote)
|
if (world.isClientSide)
|
||||||
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper
|
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper
|
||||||
.getMaxReach(player) + ".");
|
.getMaxReach(player) + ".");
|
||||||
|
|
||||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||||
player.playSound(soundEvent, 1f, 1f);
|
player.playSound(soundEvent, 1f, 1f);
|
||||||
}
|
}
|
||||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
public void appendHoverText(ItemStack stack, @Nullable World world, List<ITextComponent> 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 + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel3.get()));
|
||||||
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTranslationKey() {
|
public String getDescriptionId() {
|
||||||
return this.getRegistryName().toString();
|
return this.getRegistryName().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ public class AddUndoMessage {
|
|||||||
buf.writeInt(message.coordinate.getX());
|
buf.writeInt(message.coordinate.getX());
|
||||||
buf.writeInt(message.coordinate.getY());
|
buf.writeInt(message.coordinate.getY());
|
||||||
buf.writeInt(message.coordinate.getZ());
|
buf.writeInt(message.coordinate.getZ());
|
||||||
buf.writeInt(Block.getStateId(message.previousBlockState));
|
buf.writeInt(Block.getId(message.previousBlockState));
|
||||||
buf.writeInt(Block.getStateId(message.newBlockState));
|
buf.writeInt(Block.getId(message.newBlockState));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AddUndoMessage decode(PacketBuffer buf) {
|
public static AddUndoMessage decode(PacketBuffer buf) {
|
||||||
BlockPos coordinate = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
BlockPos coordinate = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||||
BlockState previousBlockState = Block.getStateById(buf.readInt());
|
BlockState previousBlockState = Block.stateById(buf.readInt());
|
||||||
BlockState newBlockState = Block.getStateById(buf.readInt());
|
BlockState newBlockState = Block.stateById(buf.readInt());
|
||||||
return new AddUndoMessage(coordinate, previousBlockState, newBlockState);
|
return new AddUndoMessage(coordinate, previousBlockState, newBlockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ public class BlockBrokenMessage {
|
|||||||
|
|
||||||
public BlockBrokenMessage(BlockRayTraceResult result) {
|
public BlockBrokenMessage(BlockRayTraceResult result) {
|
||||||
this.blockHit = result.getType() == RayTraceResult.Type.BLOCK;
|
this.blockHit = result.getType() == RayTraceResult.Type.BLOCK;
|
||||||
this.blockPos = result.getPos();
|
this.blockPos = result.getBlockPos();
|
||||||
this.sideHit = result.getFace();
|
this.sideHit = result.getDirection();
|
||||||
this.hitVec = result.getHitVec();
|
this.hitVec = result.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockBrokenMessage(boolean blockHit, BlockPos blockPos, Direction sideHit, Vector3d hitVec) {
|
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.getX());
|
||||||
buf.writeInt(message.blockPos.getY());
|
buf.writeInt(message.blockPos.getY());
|
||||||
buf.writeInt(message.blockPos.getZ());
|
buf.writeInt(message.blockPos.getZ());
|
||||||
buf.writeInt(message.sideHit.getIndex());
|
buf.writeInt(message.sideHit.get3DDataValue());
|
||||||
buf.writeDouble(message.hitVec.x);
|
buf.writeDouble(message.hitVec.x);
|
||||||
buf.writeDouble(message.hitVec.y);
|
buf.writeDouble(message.hitVec.y);
|
||||||
buf.writeDouble(message.hitVec.z);
|
buf.writeDouble(message.hitVec.z);
|
||||||
@@ -57,7 +57,7 @@ public class BlockBrokenMessage {
|
|||||||
public static BlockBrokenMessage decode(PacketBuffer buf) {
|
public static BlockBrokenMessage decode(PacketBuffer buf) {
|
||||||
boolean blockHit = buf.readBoolean();
|
boolean blockHit = buf.readBoolean();
|
||||||
BlockPos blockPos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
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());
|
Vector3d hitVec = new Vector3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
|
||||||
return new BlockBrokenMessage(blockHit, blockPos, sideHit, hitVec);
|
return new BlockBrokenMessage(blockHit, blockPos, sideHit, hitVec);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ public class BlockPlacedMessage {
|
|||||||
|
|
||||||
public BlockPlacedMessage(BlockRayTraceResult result, boolean placeStartPos) {
|
public BlockPlacedMessage(BlockRayTraceResult result, boolean placeStartPos) {
|
||||||
this.blockHit = result.getType() == RayTraceResult.Type.BLOCK;
|
this.blockHit = result.getType() == RayTraceResult.Type.BLOCK;
|
||||||
this.blockPos = result.getPos();
|
this.blockPos = result.getBlockPos();
|
||||||
this.sideHit = result.getFace();
|
this.sideHit = result.getDirection();
|
||||||
this.hitVec = result.getHitVec();
|
this.hitVec = result.getLocation();
|
||||||
this.placeStartPos = placeStartPos;
|
this.placeStartPos = placeStartPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ public class BlockPlacedMessage {
|
|||||||
buf.writeInt(message.blockPos.getX());
|
buf.writeInt(message.blockPos.getX());
|
||||||
buf.writeInt(message.blockPos.getY());
|
buf.writeInt(message.blockPos.getY());
|
||||||
buf.writeInt(message.blockPos.getZ());
|
buf.writeInt(message.blockPos.getZ());
|
||||||
buf.writeInt(message.sideHit.getIndex());
|
buf.writeInt(message.sideHit.get3DDataValue());
|
||||||
buf.writeDouble(message.hitVec.x);
|
buf.writeDouble(message.hitVec.x);
|
||||||
buf.writeDouble(message.hitVec.y);
|
buf.writeDouble(message.hitVec.y);
|
||||||
buf.writeDouble(message.hitVec.z);
|
buf.writeDouble(message.hitVec.z);
|
||||||
@@ -64,7 +64,7 @@ public class BlockPlacedMessage {
|
|||||||
public static BlockPlacedMessage decode(PacketBuffer buf) {
|
public static BlockPlacedMessage decode(PacketBuffer buf) {
|
||||||
boolean blockHit = buf.readBoolean();
|
boolean blockHit = buf.readBoolean();
|
||||||
BlockPos blockPos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
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());
|
Vector3d hitVec = new Vector3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
|
||||||
boolean placeStartPos = buf.readBoolean();
|
boolean placeStartPos = buf.readBoolean();
|
||||||
return new BlockPlacedMessage(blockHit, blockPos, sideHit, hitVec, placeStartPos);
|
return new BlockPlacedMessage(blockHit, blockPos, sideHit, hitVec, placeStartPos);
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import static nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
import static nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
||||||
|
|
||||||
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.ModifierSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shares modifier settings (see ModifierSettingsManager) between server and client
|
* Shares modifier settings (see ModifierSettingsManager) between server and client
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ public class TranslatedLogMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void encode(TranslatedLogMessage message, PacketBuffer buf) {
|
public static void encode(TranslatedLogMessage message, PacketBuffer buf) {
|
||||||
buf.writeString(message.prefix);
|
buf.writeUtf(message.prefix);
|
||||||
buf.writeString(message.translationKey);
|
buf.writeUtf(message.translationKey);
|
||||||
buf.writeString(message.suffix);
|
buf.writeUtf(message.suffix);
|
||||||
buf.writeBoolean(message.actionBar);
|
buf.writeBoolean(message.actionBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TranslatedLogMessage decode(PacketBuffer buf) {
|
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() {
|
public String getPrefix() {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class ClientProxy implements IProxy {
|
|||||||
onMouseInput();
|
onMouseInput();
|
||||||
|
|
||||||
//Update previousLookAt
|
//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)
|
//Checking for null is necessary! Even in vanilla when looking down ladders it is occasionally null (instead of Type MISS)
|
||||||
if (objectMouseOver == null) return;
|
if (objectMouseOver == null) return;
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ public class ClientProxy implements IProxy {
|
|||||||
currentLookAt = objectMouseOver;
|
currentLookAt = objectMouseOver;
|
||||||
previousLookAt = objectMouseOver;
|
previousLookAt = objectMouseOver;
|
||||||
} else {
|
} else {
|
||||||
if (((BlockRayTraceResult) currentLookAt).getPos() != ((BlockRayTraceResult) objectMouseOver).getPos()) {
|
if (((BlockRayTraceResult) currentLookAt).getBlockPos() != ((BlockRayTraceResult) objectMouseOver).getBlockPos()) {
|
||||||
previousLookAt = currentLookAt;
|
previousLookAt = currentLookAt;
|
||||||
currentLookAt = objectMouseOver;
|
currentLookAt = objectMouseOver;
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ public class ClientProxy implements IProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (event.phase == TickEvent.Phase.END) {
|
} else if (event.phase == TickEvent.Phase.END) {
|
||||||
Screen gui = Minecraft.getInstance().currentScreen;
|
Screen gui = Minecraft.getInstance().screen;
|
||||||
if (gui == null || !gui.isPauseScreen()) {
|
if (gui == null || !gui.isPauseScreen()) {
|
||||||
ticksInGame++;
|
ticksInGame++;
|
||||||
}
|
}
|
||||||
@@ -116,22 +116,22 @@ public class ClientProxy implements IProxy {
|
|||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||||
|
|
||||||
if (Minecraft.getInstance().currentScreen != null ||
|
if (Minecraft.getInstance().screen != null ||
|
||||||
buildMode == BuildModes.BuildModeEnum.NORMAL ||
|
buildMode == BuildModes.BuildModeEnum.NORMAL ||
|
||||||
RadialMenu.instance.isVisible()) {
|
RadialMenu.instance.isVisible()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc.gameSettings.keyBindUseItem.isKeyDown()) {
|
if (mc.options.keyUse.isDown()) {
|
||||||
|
|
||||||
//KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false);
|
//KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false);
|
||||||
|
|
||||||
if (placeCooldown <= 0) {
|
if (placeCooldown <= 0) {
|
||||||
placeCooldown = 4;
|
placeCooldown = 4;
|
||||||
|
|
||||||
ItemStack currentItemStack = player.getHeldItem(Hand.MAIN_HAND);
|
ItemStack currentItemStack = player.getItemInHand(Hand.MAIN_HAND);
|
||||||
if (currentItemStack.getItem() instanceof BlockItem ||
|
if (currentItemStack.getItem() instanceof BlockItem ||
|
||||||
(CompatHelper.isItemBlockProxy(currentItemStack) && !player.isSneaking())) {
|
(CompatHelper.isItemBlockProxy(currentItemStack) && !player.isShiftKeyDown())) {
|
||||||
|
|
||||||
ItemStack itemStack = CompatHelper.getItemBlockFromStack(currentItemStack);
|
ItemStack itemStack = CompatHelper.getItemBlockFromStack(currentItemStack);
|
||||||
|
|
||||||
@@ -144,15 +144,15 @@ public class ClientProxy implements IProxy {
|
|||||||
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage(blockLookingAt, true));
|
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage(blockLookingAt, true));
|
||||||
|
|
||||||
//play sound if further than normal
|
//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) {
|
itemStack.getItem() instanceof BlockItem) {
|
||||||
|
|
||||||
BlockState state = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
|
BlockState state = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState();
|
||||||
BlockPos blockPos = blockLookingAt.getPos();
|
BlockPos blockPos = blockLookingAt.getBlockPos();
|
||||||
SoundType soundType = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
SoundType soundType = state.getBlock().getSoundType(state, player.level, blockPos, player);
|
||||||
player.world.playSound(player, player.getPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS,
|
player.level.playSound(player, player.blockPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS,
|
||||||
0.4f, soundType.getPitch());
|
0.4f, soundType.getPitch());
|
||||||
player.swingArm(Hand.MAIN_HAND);
|
player.swing(Hand.MAIN_HAND);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BuildModes.onBlockPlacedMessage(player, new BlockPlacedMessage());
|
BuildModes.onBlockPlacedMessage(player, new BlockPlacedMessage());
|
||||||
@@ -167,7 +167,7 @@ public class ClientProxy implements IProxy {
|
|||||||
placeCooldown = 0;
|
placeCooldown = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc.gameSettings.keyBindAttack.isKeyDown()) {
|
if (mc.options.keyAttack.isDown()) {
|
||||||
|
|
||||||
//Break block in distance in creative (or survival if enabled in config)
|
//Break block in distance in creative (or survival if enabled in config)
|
||||||
if (breakCooldown <= 0) {
|
if (breakCooldown <= 0) {
|
||||||
@@ -187,14 +187,14 @@ public class ClientProxy implements IProxy {
|
|||||||
PacketHandler.INSTANCE.sendToServer(new BlockBrokenMessage(blockLookingAt));
|
PacketHandler.INSTANCE.sendToServer(new BlockBrokenMessage(blockLookingAt));
|
||||||
|
|
||||||
//play sound if further than normal
|
//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();
|
BlockPos blockPos = blockLookingAt.getBlockPos();
|
||||||
BlockState state = player.world.getBlockState(blockPos);
|
BlockState state = player.level.getBlockState(blockPos);
|
||||||
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
SoundType soundtype = state.getBlock().getSoundType(state, player.level, blockPos, player);
|
||||||
player.world.playSound(player, player.getPosition(), soundtype.getBreakSound(), SoundCategory.BLOCKS,
|
player.level.playSound(player, player.blockPosition(), soundtype.getBreakSound(), SoundCategory.BLOCKS,
|
||||||
0.4f, soundtype.getPitch());
|
0.4f, soundtype.getPitch());
|
||||||
player.swingArm(Hand.MAIN_HAND);
|
player.swing(Hand.MAIN_HAND);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BuildModes.onBlockBrokenMessage(player, new BlockBrokenMessage());
|
BuildModes.onBlockBrokenMessage(player, new BlockBrokenMessage());
|
||||||
@@ -220,12 +220,12 @@ public class ClientProxy implements IProxy {
|
|||||||
|
|
||||||
//Remember to send packet to server if necessary
|
//Remember to send packet to server if necessary
|
||||||
//Show Modifier Settings GUI
|
//Show Modifier Settings GUI
|
||||||
if (keyBindings[0].isPressed()) {
|
if (keyBindings[0].consumeClick()) {
|
||||||
openModifierSettings();
|
openModifierSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
//QuickReplace toggle
|
//QuickReplace toggle
|
||||||
if (keyBindings[1].isPressed()) {
|
if (keyBindings[1].consumeClick()) {
|
||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||||
modifierSettings.setQuickReplace(!modifierSettings.doQuickReplace());
|
modifierSettings.setQuickReplace(!modifierSettings.doQuickReplace());
|
||||||
EffortlessBuilding.log(player, "Set " + TextFormatting.GOLD + "Quick Replace " + TextFormatting.RESET + (
|
EffortlessBuilding.log(player, "Set " + TextFormatting.GOLD + "Quick Replace " + TextFormatting.RESET + (
|
||||||
@@ -234,30 +234,30 @@ public class ClientProxy implements IProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Creative/survival mode toggle
|
//Creative/survival mode toggle
|
||||||
if (keyBindings[2].isPressed()) {
|
if (keyBindings[2].consumeClick()) {
|
||||||
if (player.isCreative()) {
|
if (player.isCreative()) {
|
||||||
player.sendChatMessage("/gamemode survival");
|
player.chat("/gamemode survival");
|
||||||
} else {
|
} else {
|
||||||
player.sendChatMessage("/gamemode creative");
|
player.chat("/gamemode creative");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Undo (Ctrl+Z)
|
//Undo (Ctrl+Z)
|
||||||
if (keyBindings[4].isPressed()) {
|
if (keyBindings[4].consumeClick()) {
|
||||||
ModeOptions.ActionEnum action = ModeOptions.ActionEnum.UNDO;
|
ModeOptions.ActionEnum action = ModeOptions.ActionEnum.UNDO;
|
||||||
ModeOptions.performAction(player, action);
|
ModeOptions.performAction(player, action);
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action));
|
PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Redo (Ctrl+Y)
|
//Redo (Ctrl+Y)
|
||||||
if (keyBindings[5].isPressed()) {
|
if (keyBindings[5].consumeClick()) {
|
||||||
ModeOptions.ActionEnum action = ModeOptions.ActionEnum.REDO;
|
ModeOptions.ActionEnum action = ModeOptions.ActionEnum.REDO;
|
||||||
ModeOptions.performAction(player, action);
|
ModeOptions.performAction(player, action);
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action));
|
PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Change placement mode
|
//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
|
//Toggle between first two actions of the first option of the current build mode
|
||||||
BuildModes.BuildModeEnum currentBuildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
BuildModes.BuildModeEnum currentBuildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||||
if (currentBuildMode.options.length > 0) {
|
if (currentBuildMode.options.length > 0) {
|
||||||
@@ -275,7 +275,7 @@ public class ClientProxy implements IProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//For shader development
|
//For shader development
|
||||||
if (keyBindings.length >= 8 && keyBindings[7].isPressed()) {
|
if (keyBindings.length >= 8 && keyBindings[7].consumeClick()) {
|
||||||
ShaderHandler.init();
|
ShaderHandler.init();
|
||||||
EffortlessBuilding.log(player, "Reloaded shaders");
|
EffortlessBuilding.log(player, "Reloaded shaders");
|
||||||
}
|
}
|
||||||
@@ -294,10 +294,10 @@ public class ClientProxy implements IProxy {
|
|||||||
if (ReachHelper.getMaxReach(player) == 0) {
|
if (ReachHelper.getMaxReach(player) == 0) {
|
||||||
EffortlessBuilding.log(player, "Build modifiers are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
EffortlessBuilding.log(player, "Build modifiers are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
||||||
} else {
|
} else {
|
||||||
if (mc.currentScreen == null) {
|
if (mc.screen == null) {
|
||||||
mc.displayGuiScreen(new ModifierSettingsGui());
|
mc.setScreen(new ModifierSettingsGui());
|
||||||
} else {
|
} else {
|
||||||
player.closeScreen();
|
player.closeContainer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,10 +311,10 @@ public class ClientProxy implements IProxy {
|
|||||||
RadialMenu.instance.setVisibility(0f);
|
RadialMenu.instance.setVisibility(0f);
|
||||||
|
|
||||||
//Disabled if max reach is 0, might be set in the config that way.
|
//Disabled if max reach is 0, might be set in the config that way.
|
||||||
if (mc.currentScreen == null) {
|
if (mc.screen == null) {
|
||||||
mc.displayGuiScreen(new PlayerSettingsGui());
|
mc.setScreen(new PlayerSettingsGui());
|
||||||
} else {
|
} else {
|
||||||
player.closeScreen();
|
player.closeContainer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,17 +327,17 @@ public class ClientProxy implements IProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static RayTraceResult getLookingAt(PlayerEntity player) {
|
public static RayTraceResult getLookingAt(PlayerEntity player) {
|
||||||
World world = player.world;
|
World world = player.level;
|
||||||
|
|
||||||
//base distance off of player ability (config)
|
//base distance off of player ability (config)
|
||||||
float raytraceRange = ReachHelper.getPlacementReach(player);
|
float raytraceRange = ReachHelper.getPlacementReach(player);
|
||||||
|
|
||||||
Vector3d look = player.getLookVec();
|
Vector3d look = player.getLookAngle();
|
||||||
Vector3d start = new Vector3d(player.getPosX(), player.getPosY() + player.getEyeHeight(), player.getPosZ());
|
Vector3d start = new Vector3d(player.getX(), player.getY() + player.getEyeHeight(), player.getZ());
|
||||||
Vector3d end = new Vector3d(player.getPosX() + look.x * raytraceRange, player.getPosY() + player.getEyeHeight() + look.y * raytraceRange, player.getPosZ() + look.z * raytraceRange);
|
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);
|
// return player.rayTrace(raytraceRange, 1f, RayTraceFluidMode.NEVER);
|
||||||
//TODO 1.14 check if correct
|
//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
|
@Override
|
||||||
@@ -350,21 +350,21 @@ public class ClientProxy implements IProxy {
|
|||||||
keyBindings = new KeyBinding[7];
|
keyBindings = new KeyBinding[7];
|
||||||
|
|
||||||
// instantiate the key bindings
|
// 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[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.getInputByCode(GLFW.GLFW_KEY_KP_SUBTRACT, 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.getInputByCode(GLFW.GLFW_KEY_F4, 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.getInputByCode(GLFW.GLFW_KEY_LEFT_ALT, 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
|
@Override
|
||||||
public boolean conflicts(KeyBinding other) {
|
public boolean same(KeyBinding other) {
|
||||||
//Does not conflict with Chisels and Bits radial menu
|
//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 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[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.getInputByCode(GLFW.GLFW_KEY_Y, 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.getInputByCode(GLFW.GLFW_KEY_LEFT_CONTROL, 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");
|
//keyBindings[7] = new KeyBinding("Reload shaders", KeyConflictContext.UNIVERSAL, InputMappings.getInputByCode(GLFW.GLFW_KEY_TAB, 0), "key.effortlessbuilding.category");
|
||||||
|
|
||||||
// register all the key bindings
|
// register all the key bindings
|
||||||
@@ -372,7 +372,7 @@ public class ClientProxy implements IProxy {
|
|||||||
ClientRegistry.registerKeyBinding(keyBinding);
|
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<NetworkEvent.Context> ctx) {
|
public PlayerEntity getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx) {
|
||||||
@@ -381,6 +381,6 @@ public class ClientProxy implements IProxy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logTranslate(PlayerEntity player, String prefix, String translationKey, String suffix, boolean actionBar) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class BlockPreviewRenderer {
|
|||||||
PlacedData placed = placedDataList.get(i);
|
PlacedData placed = placedDataList.get(i);
|
||||||
if (placed.coordinates != null && !placed.coordinates.isEmpty()) {
|
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;
|
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);
|
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
|
//Expire
|
||||||
placedDataList.removeIf(placed -> {
|
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;
|
return placed.time + totalTime < ClientProxy.ticksInGame;
|
||||||
});
|
});
|
||||||
|
|
||||||
//Render block previews
|
//Render block previews
|
||||||
RayTraceResult lookingAt = ClientProxy.getLookingAt(player);
|
RayTraceResult lookingAt = ClientProxy.getLookingAt(player);
|
||||||
if (modeSettings.getBuildMode() == BuildModes.BuildModeEnum.NORMAL)
|
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));
|
boolean toolInHand = !(!mainhand.isEmpty() && CompatHelper.isItemBlockProxy(mainhand));
|
||||||
|
|
||||||
BlockPos startPos = null;
|
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)
|
//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) {
|
if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK) {
|
||||||
BlockRayTraceResult blockLookingAt = (BlockRayTraceResult) lookingAt;
|
BlockRayTraceResult blockLookingAt = (BlockRayTraceResult) lookingAt;
|
||||||
startPos = blockLookingAt.getPos();
|
startPos = blockLookingAt.getBlockPos();
|
||||||
|
|
||||||
//Check if tool (or none) in hand
|
//Check if tool (or none) in hand
|
||||||
//TODO 1.13 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, blockLookingAt.getFace());
|
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, blockLookingAt.getDirection());
|
||||||
if (!modifierSettings.doQuickReplace() && !toolInHand && !replaceable && !becomesDoubleSlab) {
|
if (!modifierSettings.doQuickReplace() && !toolInHand && !replaceable && !becomesDoubleSlab) {
|
||||||
startPos = startPos.offset(blockLookingAt.getFace());
|
startPos = startPos.relative(blockLookingAt.getDirection());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get under tall grass and other replaceable blocks
|
//Get under tall grass and other replaceable blocks
|
||||||
if (modifierSettings.doQuickReplace() && !toolInHand && replaceable) {
|
if (modifierSettings.doQuickReplace() && !toolInHand && replaceable) {
|
||||||
startPos = startPos.down();
|
startPos = startPos.below();
|
||||||
}
|
}
|
||||||
|
|
||||||
sideHit = blockLookingAt.getFace();
|
sideHit = blockLookingAt.getDirection();
|
||||||
hitVec = blockLookingAt.getHitVec();
|
hitVec = blockLookingAt.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dont render if in normal mode and modifiers are disabled
|
//Dont render if in normal mode and modifiers are disabled
|
||||||
@@ -150,7 +150,7 @@ public class BlockPreviewRenderer {
|
|||||||
if (breaking) {
|
if (breaking) {
|
||||||
//Find blockstate of world
|
//Find blockstate of world
|
||||||
for (BlockPos coordinate : newCoordinates) {
|
for (BlockPos coordinate : newCoordinates) {
|
||||||
blockStates.add(player.world.getBlockState(coordinate));
|
blockStates.add(player.level.getBlockState(coordinate));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
blockStates = BuildModifiers.findBlockStates(player, startCoordinates, hitVec, sideHit, itemStacks);
|
blockStates = BuildModifiers.findBlockStates(player, startCoordinates, hitVec, sideHit, itemStacks);
|
||||||
@@ -174,9 +174,9 @@ public class BlockPreviewRenderer {
|
|||||||
soundTime = ClientProxy.ticksInGame;
|
soundTime = ClientProxy.ticksInGame;
|
||||||
|
|
||||||
if (blockStates.get(0) != null) {
|
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);
|
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);
|
SoundCategory.BLOCKS, 0.3f, 0.8f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ public class BlockPreviewRenderer {
|
|||||||
if (breaking) color = new Vector3d(1f, 0f, 0f);
|
if (breaking) color = new Vector3d(1f, 0f, 0f);
|
||||||
|
|
||||||
for (int i = newCoordinates.size() - 1; i >= 0; i--) {
|
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);
|
RenderHandler.renderBlockOutline(matrixStack, buffer, newCoordinates.get(i), collisionShape, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,21 +239,21 @@ public class BlockPreviewRenderer {
|
|||||||
IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer);
|
IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||||
//Draw outlines if tool in hand
|
//Draw outlines if tool in hand
|
||||||
//Find proper raytrace: either normal range or increased range depending on canBreakFar
|
//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;
|
RayTraceResult breakingRaytrace = ReachHelper.canBreakFar(player) ? lookingAt : objectMouseOver;
|
||||||
if (toolInHand && breakingRaytrace != null && breakingRaytrace.getType() == RayTraceResult.Type.BLOCK) {
|
if (toolInHand && breakingRaytrace != null && breakingRaytrace.getType() == RayTraceResult.Type.BLOCK) {
|
||||||
BlockRayTraceResult blockBreakingRaytrace = (BlockRayTraceResult) breakingRaytrace;
|
BlockRayTraceResult blockBreakingRaytrace = (BlockRayTraceResult) breakingRaytrace;
|
||||||
List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, blockBreakingRaytrace.getPos());
|
List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, blockBreakingRaytrace.getBlockPos());
|
||||||
|
|
||||||
//Only render first outline if further than normal reach
|
//Only render first outline if further than normal reach
|
||||||
boolean excludeFirst = objectMouseOver != null && objectMouseOver.getType() == RayTraceResult.Type.BLOCK;
|
boolean excludeFirst = objectMouseOver != null && objectMouseOver.getType() == RayTraceResult.Type.BLOCK;
|
||||||
for (int i = excludeFirst ? 1 : 0; i < breakCoordinates.size(); i++) {
|
for (int i = excludeFirst ? 1 : 0; i < breakCoordinates.size(); i++) {
|
||||||
BlockPos coordinate = breakCoordinates.get(i);
|
BlockPos coordinate = breakCoordinates.get(i);
|
||||||
|
|
||||||
BlockState blockState = player.world.getBlockState(coordinate);
|
BlockState blockState = player.level.getBlockState(coordinate);
|
||||||
if (!blockState.getBlock().isAir(blockState, player.world, coordinate)) {
|
if (!blockState.getBlock().isAir(blockState, player.level, coordinate)) {
|
||||||
if (SurvivalHelper.canBreak(player.world, player, coordinate) || i == 0) {
|
if (SurvivalHelper.canBreak(player.level, player, coordinate) || i == 0) {
|
||||||
VoxelShape collisionShape = blockState.getCollisionShape(player.world, coordinate);
|
VoxelShape collisionShape = blockState.getCollisionShape(player.level, coordinate);
|
||||||
RenderHandler.renderBlockOutline(matrixStack, buffer, coordinate, collisionShape, new Vector3d(0f, 0f, 0f));
|
RenderHandler.renderBlockOutline(matrixStack, buffer, coordinate, collisionShape, new Vector3d(0f, 0f, 0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ public class BlockPreviewRenderer {
|
|||||||
BlockPos secondPos, boolean checkCanPlace, boolean red) {
|
BlockPos secondPos, boolean checkCanPlace, boolean red) {
|
||||||
PlayerEntity player = Minecraft.getInstance().player;
|
PlayerEntity player = Minecraft.getInstance().player;
|
||||||
ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||||
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer();
|
||||||
int blocksValid = 0;
|
int blocksValid = 0;
|
||||||
|
|
||||||
if (coordinates.isEmpty()) return blocksValid;
|
if (coordinates.isEmpty()) return blocksValid;
|
||||||
@@ -290,7 +290,7 @@ public class BlockPreviewRenderer {
|
|||||||
//Check if can place
|
//Check if can place
|
||||||
//If check is turned off, check if blockstate is the same (for dissolve effect)
|
//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)
|
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);
|
RenderHandler.renderBlockPreview(matrixStack, renderTypeBuffer, dispatcher, blockPos, blockState, dissolve, firstPos, secondPos, red);
|
||||||
blocksValid++;
|
blocksValid++;
|
||||||
@@ -353,8 +353,8 @@ public class BlockPreviewRenderer {
|
|||||||
|
|
||||||
Collections.sort(coordinates, (lhs, rhs) -> {
|
Collections.sort(coordinates, (lhs, rhs) -> {
|
||||||
// -1 - less than, 1 - greater than, 0 - equal
|
// -1 - less than, 1 - greater than, 0 - equal
|
||||||
double lhsDistanceToPlayer = Vector3d.copy(lhs).subtract(player.getEyePosition(1f)).lengthSquared();
|
double lhsDistanceToPlayer = Vector3d.atLowerCornerOf(lhs).subtract(player.getEyePosition(1f)).lengthSqr();
|
||||||
double rhsDistanceToPlayer = Vector3d.copy(rhs).subtract(player.getEyePosition(1f)).lengthSquared();
|
double rhsDistanceToPlayer = Vector3d.atLowerCornerOf(rhs).subtract(player.getEyePosition(1f)).lengthSqr();
|
||||||
return (int) Math.signum(lhsDistanceToPlayer - rhsDistanceToPlayer);
|
return (int) Math.signum(lhsDistanceToPlayer - rhsDistanceToPlayer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ public class BuildRenderTypes {
|
|||||||
private static final int secondaryTextureUnit = 2;
|
private static final int secondaryTextureUnit = 2;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228515_g_");
|
TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "TRANSLUCENT_TRANSPARENCY");
|
||||||
NO_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228510_b_");
|
NO_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "NO_TRANSPARENCY");
|
||||||
|
|
||||||
DIFFUSE_LIGHTING_ENABLED = new RenderState.DiffuseLightingState(true);
|
DIFFUSE_LIGHTING_ENABLED = new RenderState.DiffuseLightingState(true);
|
||||||
DIFFUSE_LIGHTING_DISABLED = new RenderState.DiffuseLightingState(false);
|
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);
|
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.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
//
|
//
|
||||||
// RenderSystem.lineWidth(2);
|
// RenderSystem.lineWidth(2);
|
||||||
renderState = RenderType.State.getBuilder()
|
renderState = RenderType.State.builder()
|
||||||
.line(new RenderState.LineState(OptionalDouble.of(2)))
|
.setLineState(new RenderState.LineState(OptionalDouble.of(2)))
|
||||||
.layer(PROJECTION_LAYERING)
|
.setLayeringState(PROJECTION_LAYERING)
|
||||||
.transparency(TRANSLUCENT_TRANSPARENCY)
|
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||||
.writeMask(WRITE_TO_DEPTH_AND_COLOR)
|
.setWriteMaskState(WRITE_TO_DEPTH_AND_COLOR)
|
||||||
.cull(CULL_DISABLED)
|
.setCullState(CULL_DISABLED)
|
||||||
.build(false);
|
.createCompositeState(false);
|
||||||
LINES = RenderType.makeType("eb_lines",
|
LINES = RenderType.create("eb_lines",
|
||||||
DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, INITIAL_BUFFER_SIZE, renderState);
|
DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, INITIAL_BUFFER_SIZE, renderState);
|
||||||
|
|
||||||
renderState = RenderType.State.getBuilder()
|
renderState = RenderType.State.builder()
|
||||||
.line(new RenderState.LineState(OptionalDouble.of(2)))
|
.setLineState(new RenderState.LineState(OptionalDouble.of(2)))
|
||||||
.layer(PROJECTION_LAYERING)
|
.setLayeringState(PROJECTION_LAYERING)
|
||||||
.transparency(TRANSLUCENT_TRANSPARENCY)
|
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||||
.writeMask(COLOR_WRITE)
|
.setWriteMaskState(COLOR_WRITE)
|
||||||
.cull(CULL_DISABLED)
|
.setCullState(CULL_DISABLED)
|
||||||
.build(false);
|
.createCompositeState(false);
|
||||||
PLANES = RenderType.makeType("eb_planes",
|
PLANES = RenderType.create("eb_planes",
|
||||||
DefaultVertexFormats.POSITION_COLOR, GL11.GL_TRIANGLE_STRIP, INITIAL_BUFFER_SIZE, renderState);
|
DefaultVertexFormats.POSITION_COLOR, GL11.GL_TRIANGLE_STRIP, INITIAL_BUFFER_SIZE, renderState);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -111,23 +111,23 @@ public class BuildRenderTypes {
|
|||||||
// RenderSystem.pushLightingAttributes();
|
// RenderSystem.pushLightingAttributes();
|
||||||
// RenderSystem.pushTextureAttributes();
|
// 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);
|
RenderSystem.blendColor(1f, 1f, 1f, 0.8f);
|
||||||
}, ShaderHandler::releaseShader);
|
}, ShaderHandler::releaseShader);
|
||||||
|
|
||||||
RenderType.State renderState = RenderType.State.getBuilder()
|
RenderType.State renderState = RenderType.State.builder()
|
||||||
.texture(new RenderState.TextureState(ShaderHandler.shaderMaskTextureLocation, false, false))
|
.setTextureState(new RenderState.TextureState(ShaderHandler.shaderMaskTextureLocation, false, false))
|
||||||
.texturing(MY_TEXTURING)
|
.setTexturingState(MY_TEXTURING)
|
||||||
.transparency(TRANSLUCENT_TRANSPARENCY)
|
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||||
.diffuseLighting(DIFFUSE_LIGHTING_DISABLED)
|
.setDiffuseLightingState(DIFFUSE_LIGHTING_DISABLED)
|
||||||
.alpha(DEFAULT_ALPHA)
|
.setAlphaState(DEFAULT_ALPHA)
|
||||||
.cull(new RenderState.CullState(true))
|
.setCullState(new RenderState.CullState(true))
|
||||||
.lightmap(new RenderState.LightmapState(false))
|
.setLightmapState(new RenderState.LightmapState(false))
|
||||||
.overlay(new RenderState.OverlayState(false))
|
.setOverlayState(new RenderState.OverlayState(false))
|
||||||
.build(true);
|
.createCompositeState(true);
|
||||||
//Unique name for every combination, otherwise it will reuse the previous one
|
//Unique name for every combination, otherwise it will reuse the previous one
|
||||||
String name = "eb_block_previews_" + dissolve + "_" + blockPos + "_" + firstPos + "_" + secondPos + "_" + red;
|
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);
|
DefaultVertexFormats.BLOCK, GL11.GL_QUADS, 256, true, true, renderState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,13 +151,13 @@ public class BuildRenderTypes {
|
|||||||
//mask
|
//mask
|
||||||
ARBShaderObjects.glUniform1iARB(maskUniform, secondaryTextureUnit);
|
ARBShaderObjects.glUniform1iARB(maskUniform, secondaryTextureUnit);
|
||||||
glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + 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());
|
//GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.getTextureManager().getTexture(ShaderHandler.shaderMaskTextureLocation).getGlTextureId());
|
||||||
|
|
||||||
//image
|
//image
|
||||||
ARBShaderObjects.glUniform1iARB(imageUniform, primaryTextureUnit);
|
ARBShaderObjects.glUniform1iARB(imageUniform, primaryTextureUnit);
|
||||||
glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + 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());
|
//GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.getTextureManager().getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).getGlTextureId());
|
||||||
|
|
||||||
//blockpos
|
//blockpos
|
||||||
|
|||||||
@@ -65,10 +65,10 @@ public class ModifierRenderer {
|
|||||||
|
|
||||||
float angle = 2f * ((float) Math.PI) / r.slices;
|
float angle = 2f * ((float) Math.PI) / r.slices;
|
||||||
Vector3d relStartVec = new Vector3d(radius, 0, 0);
|
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++) {
|
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 newVec = pos.add(relNewVec);
|
||||||
|
|
||||||
Vector3d posA = new Vector3d(pos.x, pos.y - radius, pos.z);
|
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) {
|
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);
|
// GL11.glColor4d(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha);
|
||||||
Matrix4f matrixPos = matrixStack.getLast().getMatrix();
|
Matrix4f matrixPos = matrixStack.last().pose();
|
||||||
|
|
||||||
if (drawPlanes) {
|
if (drawPlanes) {
|
||||||
IVertexBuilder buffer = RenderHandler.beginPlanes(renderTypeBuffer);
|
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.vertex(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) 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.vertex(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) posB.x, (float) posB.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||||
//backface (using triangle strip)
|
//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.vertex(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) posB.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||||
|
|
||||||
RenderHandler.endPlanes(renderTypeBuffer);
|
RenderHandler.endPlanes(renderTypeBuffer);
|
||||||
}
|
}
|
||||||
@@ -104,11 +104,11 @@ public class ModifierRenderer {
|
|||||||
IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer);
|
IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||||
|
|
||||||
Vector3d middle = posA.add(posB).scale(0.5);
|
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.vertex(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) posB.x, (float) middle.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||||
if (drawVerticalLines) {
|
if (drawVerticalLines) {
|
||||||
buffer.pos(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) 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) posB.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderHandler.endLines(renderTypeBuffer);
|
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) {
|
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());
|
// GL11.glColor4d(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
|
||||||
Matrix4f matrixPos = matrixStack.getLast().getMatrix();
|
Matrix4f matrixPos = matrixStack.last().pose();
|
||||||
|
|
||||||
if (drawPlanes) {
|
if (drawPlanes) {
|
||||||
IVertexBuilder buffer = RenderHandler.beginPlanes(renderTypeBuffer);
|
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.vertex(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) 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.vertex(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) posB.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||||
//backface (using triangle strip)
|
//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.vertex(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) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||||
|
|
||||||
RenderHandler.endPlanes(renderTypeBuffer);
|
RenderHandler.endPlanes(renderTypeBuffer);
|
||||||
}
|
}
|
||||||
@@ -138,10 +138,10 @@ public class ModifierRenderer {
|
|||||||
IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer);
|
IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||||
|
|
||||||
Vector3d middle = posA.add(posB).scale(0.5);
|
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.vertex(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.vertex(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.vertex(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) posB.x, (float) middle.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||||
|
|
||||||
RenderHandler.endLines(renderTypeBuffer);
|
RenderHandler.endLines(renderTypeBuffer);
|
||||||
}
|
}
|
||||||
@@ -151,16 +151,16 @@ public class ModifierRenderer {
|
|||||||
|
|
||||||
// GL11.glColor4d(100, 100, 100, 255);
|
// GL11.glColor4d(100, 100, 100, 255);
|
||||||
IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer);
|
IVertexBuilder buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||||
Matrix4f matrixPos = matrixStack.getLast().getMatrix();
|
Matrix4f matrixPos = matrixStack.last().pose();
|
||||||
|
|
||||||
Vector3d pos = m.position.add(epsilon);
|
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.vertex(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.vertex(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.vertex(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.vertex(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.vertex(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, (float) pos.y, (float) pos.z + m.radius).color(colorZ.getRed(), colorZ.getGreen(), colorZ.getBlue(), lineAlpha).endVertex();
|
||||||
|
|
||||||
RenderHandler.endLines(renderTypeBuffer);
|
RenderHandler.endLines(renderTypeBuffer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ public class RenderHandler {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
MatrixStack matrixStack = event.getMatrixStack();
|
MatrixStack matrixStack = event.getMatrixStack();
|
||||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
|
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuilder();
|
||||||
IRenderTypeBuffer.Impl renderTypeBuffer = IRenderTypeBuffer.getImpl(bufferBuilder);
|
IRenderTypeBuffer.Impl renderTypeBuffer = IRenderTypeBuffer.immediate(bufferBuilder);
|
||||||
if (renderTypeBuffer == null)
|
if (renderTypeBuffer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -56,9 +56,9 @@ public class RenderHandler {
|
|||||||
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(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);
|
matrixStack.translate(-projectedView.x, -projectedView.y, -projectedView.z);
|
||||||
|
|
||||||
//Mirror and radial mirror lines and areas
|
//Mirror and radial mirror lines and areas
|
||||||
@@ -67,7 +67,7 @@ public class RenderHandler {
|
|||||||
//Render block previews
|
//Render block previews
|
||||||
BlockPreviewRenderer.render(matrixStack, renderTypeBuffer, player, modifierSettings, modeSettings);
|
BlockPreviewRenderer.render(matrixStack, renderTypeBuffer, player, modifierSettings, modeSettings);
|
||||||
|
|
||||||
matrixStack.pop();
|
matrixStack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@@ -84,11 +84,11 @@ public class RenderHandler {
|
|||||||
if (type == RenderGameOverlayEvent.ElementType.ALL /*&& !hasChiselInHand*/) {
|
if (type == RenderGameOverlayEvent.ElementType.ALL /*&& !hasChiselInHand*/) {
|
||||||
final boolean wasVisible = RadialMenu.instance.isVisible();
|
final boolean wasVisible = RadialMenu.instance.isVisible();
|
||||||
|
|
||||||
if (ClientProxy.keyBindings[3].isKeyDown()) {
|
if (ClientProxy.keyBindings[3].isDown()) {
|
||||||
if (ReachHelper.getMaxReach(player) > 0) {
|
if (ReachHelper.getMaxReach(player) > 0) {
|
||||||
RadialMenu.instance.actionUsed = false;
|
RadialMenu.instance.actionUsed = false;
|
||||||
RadialMenu.instance.raiseVisibility();
|
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.");
|
EffortlessBuilding.log(player, "Build modes are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -101,7 +101,7 @@ public class RenderHandler {
|
|||||||
ModeSettingsManager.setModeSettings(player, modeSettings);
|
ModeSettingsManager.setModeSettings(player, modeSettings);
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModeSettingsMessage(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
|
//Perform button action
|
||||||
@@ -120,27 +120,27 @@ public class RenderHandler {
|
|||||||
|
|
||||||
if (RadialMenu.instance.isVisible()) {
|
if (RadialMenu.instance.isVisible()) {
|
||||||
|
|
||||||
int scaledWidth = mc.getMainWindow().getScaledWidth();
|
int scaledWidth = mc.getWindow().getGuiScaledWidth();
|
||||||
int scaledHeight = mc.getMainWindow().getScaledHeight();
|
int scaledHeight = mc.getWindow().getGuiScaledHeight();
|
||||||
RadialMenu.instance.configure(scaledWidth, scaledHeight);
|
RadialMenu.instance.configure(scaledWidth, scaledHeight);
|
||||||
|
|
||||||
if (!wasVisible) {
|
if (!wasVisible) {
|
||||||
mc.mouseHelper.ungrabMouse();
|
mc.mouseHandler.releaseMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc.mouseHelper.isMouseGrabbed()) {
|
if (mc.mouseHandler.isMouseGrabbed()) {
|
||||||
KeyBinding.unPressAllKeys();
|
KeyBinding.releaseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
final int mouseX = ((int) mc.mouseHelper.getMouseX()) * scaledWidth / mc.getMainWindow().getFramebufferWidth();
|
final int mouseX = ((int) mc.mouseHandler.xpos()) * scaledWidth / mc.getWindow().getWidth();
|
||||||
final int mouseY = scaledHeight - ((int) mc.mouseHelper.getMouseY()) * scaledHeight / mc.getMainWindow().getFramebufferHeight() - 1;
|
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());
|
net.minecraftforge.client.ForgeHooksClient.drawScreen(RadialMenu.instance, event.getMatrixStack(), mouseX, mouseY, event.getPartialTicks());
|
||||||
} else {
|
} else {
|
||||||
if (wasVisible &&
|
if (wasVisible &&
|
||||||
RadialMenu.instance.doAction != ModeOptions.ActionEnum.OPEN_MODIFIER_SETTINGS &&
|
RadialMenu.instance.doAction != ModeOptions.ActionEnum.OPEN_MODIFIER_SETTINGS &&
|
||||||
RadialMenu.instance.doAction != ModeOptions.ActionEnum.OPEN_PLAYER_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() {
|
public static void playRadialMenuSound() {
|
||||||
final float volume = 0.1f;
|
final float volume = 0.1f;
|
||||||
if (volume >= 0.0001f) {
|
if (volume >= 0.0001f) {
|
||||||
SimpleSound sound = new SimpleSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.MASTER, volume, 1.0f, Minecraft.getInstance().player.getPosition());
|
SimpleSound sound = new SimpleSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.MASTER, volume, 1.0f, Minecraft.getInstance().player.blockPosition());
|
||||||
Minecraft.getInstance().getSoundHandler().play(sound);
|
Minecraft.getInstance().getSoundManager().play(sound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ public class RenderHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void endLines(IRenderTypeBuffer.Impl renderTypeBuffer) {
|
protected static void endLines(IRenderTypeBuffer.Impl renderTypeBuffer) {
|
||||||
renderTypeBuffer.finish();
|
renderTypeBuffer.endBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static IVertexBuilder beginPlanes(IRenderTypeBuffer.Impl renderTypeBuffer) {
|
protected static IVertexBuilder beginPlanes(IRenderTypeBuffer.Impl renderTypeBuffer) {
|
||||||
@@ -167,14 +167,14 @@ public class RenderHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void endPlanes(IRenderTypeBuffer.Impl renderTypeBuffer) {
|
protected static void endPlanes(IRenderTypeBuffer.Impl renderTypeBuffer) {
|
||||||
renderTypeBuffer.finish();
|
renderTypeBuffer.endBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void renderBlockPreview(MatrixStack matrixStack, IRenderTypeBuffer.Impl renderTypeBuffer, BlockRendererDispatcher dispatcher,
|
protected static void renderBlockPreview(MatrixStack matrixStack, IRenderTypeBuffer.Impl renderTypeBuffer, BlockRendererDispatcher dispatcher,
|
||||||
BlockPos blockPos, BlockState blockState, float dissolve, BlockPos firstPos, BlockPos secondPos, boolean red) {
|
BlockPos blockPos, BlockState blockState, float dissolve, BlockPos firstPos, BlockPos secondPos, boolean red) {
|
||||||
if (blockState == null) return;
|
if (blockState == null) return;
|
||||||
|
|
||||||
matrixStack.push();
|
matrixStack.pushPose();
|
||||||
matrixStack.translate(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
matrixStack.translate(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||||
// matrixStack.rotate(Vector3f.YP.rotationDegrees(-90f));
|
// matrixStack.rotate(Vector3f.YP.rotationDegrees(-90f));
|
||||||
matrixStack.translate(-0.01f, -0.01f, -0.01f);
|
matrixStack.translate(-0.01f, -0.01f, -0.01f);
|
||||||
@@ -188,8 +188,8 @@ public class RenderHandler {
|
|||||||
// World world = DimensionManager.getWorld(server, DimensionType.OVERWORLD, false, true);
|
// World world = DimensionManager.getWorld(server, DimensionType.OVERWORLD, false, true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IBakedModel model = dispatcher.getModelForState(blockState);
|
IBakedModel model = dispatcher.getBlockModel(blockState);
|
||||||
dispatcher.getBlockModelRenderer().renderModelBrightnessColor(matrixStack.getLast(), buffer,
|
dispatcher.getModelRenderer().renderModel(matrixStack.last(), buffer,
|
||||||
blockState, model, 1f, 1f, 1f, 0, OverlayTexture.NO_OVERLAY);
|
blockState, model, 1f, 1f, 1f, 0, OverlayTexture.NO_OVERLAY);
|
||||||
// blockRendererDispatcher.getBlockModelRenderer().renderModel(world, blockRendererDispatcher.getModelForState(blockState),
|
// blockRendererDispatcher.getBlockModelRenderer().renderModel(world, blockRendererDispatcher.getModelForState(blockState),
|
||||||
// blockState, logicPos, matrixStack, renderTypeBuffer.getBuffer(renderType), true, new Random(), blockState.getPositionRandom(logicPos), i);
|
// 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());
|
EffortlessBuilding.logger.warn("RenderHandler::renderBlockPreview cannot render " + blockState.getBlock().toString());
|
||||||
|
|
||||||
//Render outline as backup, escape out of the current renderstack
|
//Render outline as backup, escape out of the current renderstack
|
||||||
matrixStack.pop();
|
matrixStack.popPose();
|
||||||
renderTypeBuffer.finish();
|
renderTypeBuffer.endBatch();
|
||||||
IVertexBuilder lineBuffer = beginLines(renderTypeBuffer);
|
IVertexBuilder lineBuffer = beginLines(renderTypeBuffer);
|
||||||
renderBlockOutline(matrixStack, lineBuffer, blockPos, new Vector3d(1f, 1f, 1f));
|
renderBlockOutline(matrixStack, lineBuffer, blockPos, new Vector3d(1f, 1f, 1f));
|
||||||
endLines(renderTypeBuffer);
|
endLines(renderTypeBuffer);
|
||||||
buffer = renderTypeBuffer.getBuffer(Atlases.getTranslucentCullBlockType()); //any type will do, as long as we have something on the stack
|
buffer = renderTypeBuffer.getBuffer(Atlases.translucentCullBlockSheet()); //any type will do, as long as we have something on the stack
|
||||||
matrixStack.push();
|
matrixStack.pushPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
renderTypeBuffer.finish();
|
renderTypeBuffer.endBatch();
|
||||||
matrixStack.pop();
|
matrixStack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void renderBlockOutline(MatrixStack matrixStack, IVertexBuilder buffer, BlockPos pos, Vector3d color) {
|
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
|
//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) {
|
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);
|
// WorldRenderer.drawSelectionBoundingBox(aabb, (float) color.x, (float) color.y, (float) color.z, 0.4f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Renders outline with given bounding box
|
//Renders outline with given bounding box
|
||||||
protected static void renderBlockOutline(MatrixStack matrixStack, IVertexBuilder buffer, BlockPos pos, VoxelShape collisionShape, Vector3d color) {
|
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.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
|
//TODO 1.14
|
||||||
|
|||||||
@@ -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.
|
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"
|
license="GNU LESSER GENERAL PUBLIC LICENSE"
|
||||||
# A URL to refer people to when problems occur with this mod
|
# 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
|
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||||
[[mods]] #mandatory
|
[[mods]] #mandatory
|
||||||
# The modid of the mod
|
# The modid of the mod
|
||||||
|
|||||||
Reference in New Issue
Block a user