Fix various keybinding bugs

This commit is contained in:
Marcel Konrad
2021-05-20 23:59:04 +02:00
parent be4f7ed818
commit 70b48b8041
3 changed files with 13 additions and 4 deletions

View File

@@ -95,6 +95,7 @@ public class Config
if(configValue != null && value != null && (!value.equals(configValue.get()) || configValue.get() instanceof List<?>)) if(configValue != null && value != null && (!value.equals(configValue.get()) || configValue.get() instanceof List<?>))
{ {
Config.CONFIG_DATA.set(configValue.getPath(), value); Config.CONFIG_DATA.set(configValue.getPath(), value);
configValue.clearCache();
} }
} }

View File

@@ -1,6 +1,7 @@
package exopandora.worldhandler.config; package exopandora.worldhandler.config;
import exopandora.worldhandler.builder.impl.BuilderSetBlock.EnumMode; import exopandora.worldhandler.builder.impl.BuilderSetBlock.EnumMode;
import exopandora.worldhandler.event.KeyHandler;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
@@ -124,7 +125,14 @@ public class ConfigCategorySettings
public void setShortcutKeys(boolean enabled) public void setShortcutKeys(boolean enabled)
{ {
boolean previous = this.shortcutKeys();
Config.set(this.shortcutKeys, enabled); Config.set(this.shortcutKeys, enabled);
if(previous != enabled)
{
KeyHandler.updatePosKeys();
}
} }
public boolean tooltips() public boolean tooltips()

View File

@@ -19,22 +19,22 @@ public class KeyHandler
{ {
public static final KeyBinding KEY_WORLD_HANDLER = new KeyBinding("key.worldhandler", GLFW.GLFW_KEY_V, "key.categories.worldhandler"); public static final KeyBinding KEY_WORLD_HANDLER = new KeyBinding("key.worldhandler", GLFW.GLFW_KEY_V, "key.categories.worldhandler");
public static final KeyBinding KEY_WORLD_HANDLER_POS1 = new KeyBinding("key.worldhandler.pos1", GLFW.GLFW_KEY_O, "key.categories.worldhandler"); public static final KeyBinding KEY_WORLD_HANDLER_POS1 = new KeyBinding("key.worldhandler.pos1", GLFW.GLFW_KEY_O, "key.categories.worldhandler");
public static final KeyBinding KEY_WORLD_HANDLER_POS2 = new KeyBinding("key.worldhandler.pos1", GLFW.GLFW_KEY_P, "key.categories.worldhandler"); public static final KeyBinding KEY_WORLD_HANDLER_POS2 = new KeyBinding("key.worldhandler.pos2", GLFW.GLFW_KEY_P, "key.categories.worldhandler");
@SubscribeEvent @SubscribeEvent
public static void keyInputEvent(KeyInputEvent event) public static void keyInputEvent(KeyInputEvent event)
{ {
if(Minecraft.getInstance() != null && Minecraft.getInstance().screen == null) if(Minecraft.getInstance() != null && Minecraft.getInstance().screen == null)
{ {
if(KEY_WORLD_HANDLER.isDown()) if(KEY_WORLD_HANDLER.consumeClick())
{ {
ActionHelper.displayGui(); ActionHelper.displayGui();
} }
else if(KEY_WORLD_HANDLER_POS1.isDown() && Config.getSettings().shortcutKeys()) else if(Config.getSettings().shortcutKeys() && KEY_WORLD_HANDLER_POS1.consumeClick())
{ {
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos()); BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
} }
else if(KEY_WORLD_HANDLER_POS2.isDown() && Config.getSettings().shortcutKeys()) else if(Config.getSettings().shortcutKeys() && KEY_WORLD_HANDLER_POS2.consumeClick())
{ {
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos()); BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
} }