Fix crash when installed on a dedicated server. Closes #4
This commit is contained in:
@@ -2,7 +2,6 @@ package exopandora.worldhandler;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.event.ClientEventHandler;
|
||||
@@ -10,12 +9,12 @@ import exopandora.worldhandler.event.KeyHandler;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.util.UtilKeyBinding;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -28,11 +27,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
public class WorldHandler
|
||||
{
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static final KeyBinding KEY_WORLD_HANDLER = new KeyBinding(Main.NAME, GLFW.GLFW_KEY_V, Main.NAME);
|
||||
public static final KeyBinding KEY_WORLD_HANDLER_POS1 = new KeyBinding(Main.NAME + " Pos1", GLFW.GLFW_KEY_O, Main.NAME);
|
||||
public static final KeyBinding KEY_WORLD_HANDLER_POS2 = new KeyBinding(Main.NAME + " Pos2", GLFW.GLFW_KEY_P, Main.NAME);
|
||||
|
||||
public static String USERNAME = null;
|
||||
|
||||
public WorldHandler()
|
||||
@@ -40,12 +34,15 @@ public class WorldHandler
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
modEventBus.addListener(this::clientSetup);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStarting);
|
||||
ModLoadingContext.get().registerConfig(Type.CLIENT, Config.CLIENT_SPEC, Main.MODID + ".toml");
|
||||
modEventBus.register(Config.class);
|
||||
modEventBus.addListener(Content::createRegistry);
|
||||
modEventBus.addListener(Category::createRegistry);
|
||||
modEventBus.addGenericListener(Content.class, Content::register);
|
||||
modEventBus.addGenericListener(Category.class, Category::register);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
ModLoadingContext.get().registerConfig(Type.CLIENT, Config.CLIENT_SPEC, Main.MODID + ".toml");
|
||||
modEventBus.register(Config.class);
|
||||
modEventBus.addListener(Content::createRegistry);
|
||||
modEventBus.addListener(Category::createRegistry);
|
||||
modEventBus.addGenericListener(Content.class, Content::register);
|
||||
modEventBus.addGenericListener(Category.class, Category::register);
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -56,8 +53,8 @@ public class WorldHandler
|
||||
MinecraftForge.EVENT_BUS.addListener(ClientEventHandler::clientChatEvent);
|
||||
|
||||
USERNAME = Minecraft.getInstance().getSession().getUsername();
|
||||
ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER);
|
||||
UtilKeyBinding.updatePosKeys();
|
||||
ClientRegistry.registerKeyBinding(KeyHandler.KEY_WORLD_HANDLER);
|
||||
KeyHandler.updatePosKeys();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface ICommandBuilder
|
||||
{
|
||||
static final int MAX_COMMAND_LENGTH = 256;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface ICommandBuilderSyntax extends ICommandBuilder
|
||||
{
|
||||
String getCommandName();
|
||||
|
||||
@@ -16,6 +16,7 @@ import exopandora.worldhandler.builder.impl.BuilderFill;
|
||||
import exopandora.worldhandler.builder.types.BlockResourceLocation;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.helper.CommandHelper;
|
||||
import exopandora.worldhandler.helper.EnumHelper;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.command.arguments.BlockPredicateArgument;
|
||||
@@ -24,6 +25,8 @@ import net.minecraft.command.arguments.BlockStateInput;
|
||||
import net.minecraft.command.arguments.BlockStateParser;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class CommandWH
|
||||
@@ -36,80 +39,105 @@ public class CommandWH
|
||||
.then(Commands.literal("pos2")
|
||||
.executes(context -> pos2(context.getSource())))
|
||||
.then(Commands.literal("fill")
|
||||
.requires(context -> context.hasPermissionLevel(2))
|
||||
.requires(source -> source.hasPermissionLevel(2))
|
||||
.then(Commands.argument("block", BlockStateArgument.blockState())
|
||||
.executes(context -> fill(context.getSource(), BlockStateArgument.getBlockState(context, "block")))))
|
||||
.then(Commands.literal("replace")
|
||||
.requires(context -> context.hasPermissionLevel(2))
|
||||
.requires(source -> source.hasPermissionLevel(2))
|
||||
.then(Commands.argument("block", BlockStateArgument.blockState())
|
||||
.then(Commands.argument("replace", BlockStateArgument.blockState())
|
||||
.executes(context -> replace(context.getSource(), BlockStateArgument.getBlockState(context, "block"), BlockStateArgument.getBlockState(context, "replace"))))))
|
||||
.then(Commands.literal("clone")
|
||||
.requires(context -> context.hasPermissionLevel(2))
|
||||
.executes(context -> clone(context.getSource(), EnumMask.MASKED))
|
||||
.requires(source -> source.hasPermissionLevel(2))
|
||||
.executes(context -> clone(context.getSource(), "masked"))
|
||||
.then(Commands.literal("filtered")
|
||||
.then(Commands.argument("filter", StringBlockPredicateArgument.blockPredicate())
|
||||
.executes(context -> clone(context.getSource(), StringBlockPredicateArgument.getBlockPredicate(context, "filter")))))
|
||||
.executes(context -> clone(context.getSource(), "filter", StringBlockPredicateArgument.getBlockPredicate(context, "filter")))))
|
||||
.then(Commands.literal("masked")
|
||||
.executes(context -> clone(context.getSource(), EnumMask.MASKED)))
|
||||
.executes(context -> clone(context.getSource(), "masked")))
|
||||
.then(Commands.literal("replace")
|
||||
.executes(context -> clone(context.getSource(), EnumMask.REPLACE)))));
|
||||
.executes(context -> clone(context.getSource(), "replace")))));
|
||||
}
|
||||
|
||||
private static int pos1(CommandSource source) throws CommandSyntaxException
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
|
||||
BlockPos pos = BlockHelper.getPos1();
|
||||
ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
|
||||
CommandHelper.sendFeedback(source, "Set first position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
|
||||
BlockPos pos = BlockHelper.getPos1();
|
||||
ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
|
||||
CommandHelper.sendFeedback(source, "Set first position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
|
||||
});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int pos2(CommandSource source) throws CommandSyntaxException
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
|
||||
BlockPos pos = BlockHelper.getPos2();
|
||||
ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
|
||||
CommandHelper.sendFeedback(source, "Set second position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
|
||||
BlockPos pos = BlockHelper.getPos2();
|
||||
ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
|
||||
CommandHelper.sendFeedback(source, "Set second position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
|
||||
});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int fill(CommandSource source, BlockStateInput block)
|
||||
{
|
||||
BuilderFill builder = new BuilderFill();
|
||||
builder.setBlock1(new BlockResourceLocation(block.getState().getBlock().getRegistryName(), block.getState(), block.tag));
|
||||
CommandHelper.sendCommand(builder);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
BuilderFill builder = new BuilderFill();
|
||||
builder.setBlock1(new BlockResourceLocation(block.getState().getBlock().getRegistryName(), block.getState(), block.tag));
|
||||
CommandHelper.sendCommand(builder);
|
||||
});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int replace(CommandSource source, BlockStateInput block, BlockStateInput replace)
|
||||
{
|
||||
BuilderFill builder = new BuilderFill();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setBlock1(new BlockResourceLocation(block.getState().getBlock().getRegistryName(), block.getState(), block.tag));
|
||||
builder.setBlock2(new BlockResourceLocation(replace.getState().getBlock().getRegistryName(), replace.getState(), replace.tag));
|
||||
CommandHelper.sendCommand(builder);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
BuilderFill builder = new BuilderFill();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setBlock1(new BlockResourceLocation(block.getState().getBlock().getRegistryName(), block.getState(), block.tag));
|
||||
builder.setBlock2(new BlockResourceLocation(replace.getState().getBlock().getRegistryName(), replace.getState(), replace.tag));
|
||||
CommandHelper.sendCommand(builder);
|
||||
});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int clone(CommandSource source, String filter)
|
||||
private static int clone(CommandSource source, String mask, String filter)
|
||||
{
|
||||
BuilderClone builder = new BuilderClone();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setFilter(filter);
|
||||
CommandHelper.sendCommand(builder);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
BuilderClone builder = new BuilderClone();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setMask(EnumHelper.valueOf(mask, EnumMask.class));
|
||||
builder.setFilter(filter);
|
||||
CommandHelper.sendCommand(builder);
|
||||
});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int clone(CommandSource source, EnumMask mask)
|
||||
private static int clone(CommandSource source, String mask)
|
||||
{
|
||||
BuilderClone builder = new BuilderClone();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setMask(mask);
|
||||
CommandHelper.sendCommand(builder);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
{
|
||||
BuilderClone builder = new BuilderClone();
|
||||
builder.setPosition1(BlockHelper.getPos1());
|
||||
builder.setPosition2(BlockHelper.getPos2());
|
||||
builder.setMask(EnumHelper.valueOf(mask, EnumMask.class));
|
||||
CommandHelper.sendCommand(builder);
|
||||
});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ import exopandora.worldhandler.helper.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
|
||||
@@ -22,7 +24,7 @@ public class CommandWorldHandler
|
||||
.then(Commands.literal("help")
|
||||
.executes(context -> help(context.getSource())))
|
||||
.then(Commands.literal("display")
|
||||
.executes(context -> display()))
|
||||
.executes(context -> display(context.getSource())))
|
||||
.then(Commands.literal("version")
|
||||
.executes(context -> version(context.getSource()))));
|
||||
}
|
||||
@@ -35,9 +37,9 @@ public class CommandWorldHandler
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int display() throws CommandSyntaxException
|
||||
private static int display(CommandSource source) throws CommandSyntaxException
|
||||
{
|
||||
Minecraft.getInstance().execute(ActionHelper::displayGui);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().execute(ActionHelper::displayGui));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
|
||||
import exopandora.worldhandler.util.UtilKeyBinding;
|
||||
import exopandora.worldhandler.event.KeyHandler;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
@@ -121,7 +121,7 @@ public class Config
|
||||
Config.CONFIG_DATA.load();
|
||||
Config.CLIENT.read();
|
||||
|
||||
UtilKeyBinding.updatePosKeys();
|
||||
KeyHandler.updatePosKeys();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,69 @@
|
||||
package exopandora.worldhandler.event;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.helper.ActionHelper;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.InputEvent.KeyInputEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class KeyHandler
|
||||
{
|
||||
public static final KeyBinding KEY_WORLD_HANDLER = new KeyBinding(Main.NAME, GLFW.GLFW_KEY_V, Main.NAME);
|
||||
public static final KeyBinding KEY_WORLD_HANDLER_POS1 = new KeyBinding(Main.NAME + " Pos1", GLFW.GLFW_KEY_O, Main.NAME);
|
||||
public static final KeyBinding KEY_WORLD_HANDLER_POS2 = new KeyBinding(Main.NAME + " Pos2", GLFW.GLFW_KEY_P, Main.NAME);
|
||||
|
||||
@SubscribeEvent
|
||||
public static void keyInputEvent(KeyInputEvent event)
|
||||
{
|
||||
if(Minecraft.getInstance() != null && Minecraft.getInstance().currentScreen == null)
|
||||
{
|
||||
if(WorldHandler.KEY_WORLD_HANDLER.isPressed())
|
||||
if(KeyHandler.KEY_WORLD_HANDLER.isPressed())
|
||||
{
|
||||
ActionHelper.displayGui();
|
||||
}
|
||||
else if(WorldHandler.KEY_WORLD_HANDLER_POS1.isPressed() && Config.getSettings().shortcutKeys())
|
||||
else if(KeyHandler.KEY_WORLD_HANDLER_POS1.isPressed() && Config.getSettings().shortcutKeys())
|
||||
{
|
||||
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
|
||||
}
|
||||
else if(WorldHandler.KEY_WORLD_HANDLER_POS2.isPressed() && Config.getSettings().shortcutKeys())
|
||||
else if(KeyHandler.KEY_WORLD_HANDLER_POS2.isPressed() && Config.getSettings().shortcutKeys())
|
||||
{
|
||||
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updatePosKeys()
|
||||
{
|
||||
boolean isRegistered = KeyHandler.arePosKeysRegistered();
|
||||
|
||||
if(Config.getSettings().shortcutKeys() && !isRegistered)
|
||||
{
|
||||
ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER_POS1);
|
||||
ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER_POS2);
|
||||
}
|
||||
else if(!Config.getSettings().shortcutKeys() && isRegistered)
|
||||
{
|
||||
KeyHandler.removePosKeys();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean arePosKeysRegistered()
|
||||
{
|
||||
return ArrayUtils.contains(Minecraft.getInstance().gameSettings.keyBindings, KEY_WORLD_HANDLER_POS1) || ArrayUtils.contains(Minecraft.getInstance().gameSettings.keyBindings, KEY_WORLD_HANDLER_POS2);
|
||||
}
|
||||
|
||||
public static void removePosKeys()
|
||||
{
|
||||
Minecraft.getInstance().gameSettings.keyBindings = ArrayUtils.removeElements(Minecraft.getInstance().gameSettings.keyBindings, KEY_WORLD_HANDLER_POS1, KEY_WORLD_HANDLER_POS2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderNoteEditor;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.event.KeyHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonPiano;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonPiano.Type;
|
||||
@@ -205,7 +205,7 @@ public class ContentNoteEditor extends Content
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
String displayString = I18n.format("gui.worldhandler.blocks.note_block_editor.look_at_note_block", WorldHandler.KEY_WORLD_HANDLER.getLocalizedName());
|
||||
String displayString = I18n.format("gui.worldhandler.blocks.note_block_editor.look_at_note_block", KeyHandler.KEY_WORLD_HANDLER.getLocalizedName());
|
||||
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
|
||||
fontRenderer.drawString(displayString, x + 116 - fontRenderer.getStringWidth(displayString) / 2, y + 70, Config.getSkin().getLabelColor());
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSignEditor;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.event.KeyHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
@@ -190,7 +190,7 @@ public class ContentSignEditor extends Content
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
String displayString = I18n.format("gui.worldhandler.blocks.sign_editor.look_at_sign", WorldHandler.KEY_WORLD_HANDLER.getLocalizedName());
|
||||
String displayString = I18n.format("gui.worldhandler.blocks.sign_editor.look_at_sign", KeyHandler.KEY_WORLD_HANDLER.getLocalizedName());
|
||||
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
|
||||
fontRenderer.drawString(displayString, x + 116 - fontRenderer.getStringWidth(displayString) / 2, y + 70, Config.getSkin().getLabelColor());
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class CommandHelper
|
||||
{
|
||||
public static void sendFeedback(CommandSource source, String message)
|
||||
@@ -32,11 +31,13 @@ public class CommandHelper
|
||||
CommandWH.register(dispatcher);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void sendCommand(ICommandBuilder builder)
|
||||
{
|
||||
CommandHelper.sendCommand(builder, false);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void sendCommand(ICommandBuilder builder, boolean special)
|
||||
{
|
||||
if(builder != null)
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class UtilKeyBinding
|
||||
{
|
||||
public static void updatePosKeys()
|
||||
{
|
||||
boolean isRegistered = arePosKeysRegistered();
|
||||
|
||||
if(Config.getSettings().shortcutKeys() && !isRegistered)
|
||||
{
|
||||
ClientRegistry.registerKeyBinding(WorldHandler.KEY_WORLD_HANDLER_POS1);
|
||||
ClientRegistry.registerKeyBinding(WorldHandler.KEY_WORLD_HANDLER_POS2);
|
||||
}
|
||||
else if(!Config.getSettings().shortcutKeys() && isRegistered)
|
||||
{
|
||||
removePosKeys();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean arePosKeysRegistered()
|
||||
{
|
||||
return ArrayUtils.contains(Minecraft.getInstance().gameSettings.keyBindings, WorldHandler.KEY_WORLD_HANDLER_POS1) || ArrayUtils.contains(Minecraft.getInstance().gameSettings.keyBindings, WorldHandler.KEY_WORLD_HANDLER_POS2);
|
||||
}
|
||||
|
||||
public static void removePosKeys()
|
||||
{
|
||||
Minecraft.getInstance().gameSettings.keyBindings = ArrayUtils.removeElements(Minecraft.getInstance().gameSettings.keyBindings, WorldHandler.KEY_WORLD_HANDLER_POS1, WorldHandler.KEY_WORLD_HANDLER_POS2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user