From 5977c0f7040b279ef68acd0aafd0e9e15c7710fb Mon Sep 17 00:00:00 2001 From: Lyfts <127234178+Lyfts@users.noreply.github.com> Date: Wed, 3 Jan 2024 10:22:51 +0100 Subject: [PATCH 1/4] fix /tpl and /setwarp "name" "player" using command senders location --- src/main/java/serverutils/command/tp/CmdSetWarp.java | 4 +++- src/main/java/serverutils/command/tp/CmdTplast.java | 2 +- src/main/java/serverutils/lib/math/BlockDimPos.java | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/serverutils/command/tp/CmdSetWarp.java b/src/main/java/serverutils/command/tp/CmdSetWarp.java index 28ec13b10..6892f9b6e 100644 --- a/src/main/java/serverutils/command/tp/CmdSetWarp.java +++ b/src/main/java/serverutils/command/tp/CmdSetWarp.java @@ -4,6 +4,7 @@ import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayerMP; import serverutils.ServerUtilities; import serverutils.data.ServerUtilitiesUniverseData; @@ -35,7 +36,8 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE args[0] = args[0].toLowerCase(); if (args.length == 2) { - pos = new BlockDimPos(sender); + EntityPlayerMP targetPlayer = CommandUtils.getForgePlayer(sender, args[1]).getCommandPlayer(sender); + pos = new BlockDimPos(targetPlayer); } else if (args.length >= 4) { int x = parseInt(sender, args[1]); int y = parseInt(sender, args[2]); diff --git a/src/main/java/serverutils/command/tp/CmdTplast.java b/src/main/java/serverutils/command/tp/CmdTplast.java index a76f0c2cc..4212cfa08 100644 --- a/src/main/java/serverutils/command/tp/CmdTplast.java +++ b/src/main/java/serverutils/command/tp/CmdTplast.java @@ -51,7 +51,7 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE BlockDimPos p; if (to.isOnline()) { - p = new BlockDimPos(sender); + p = new BlockDimPos(to.getCommandPlayer(sender)); } else { NBTTagCompound nbt = to.getPlayerNBT(); NBTTagList posList = nbt.getTagList("Pos", Constants.NBT.TAG_DOUBLE); diff --git a/src/main/java/serverutils/lib/math/BlockDimPos.java b/src/main/java/serverutils/lib/math/BlockDimPos.java index e6f6159d3..04219496a 100644 --- a/src/main/java/serverutils/lib/math/BlockDimPos.java +++ b/src/main/java/serverutils/lib/math/BlockDimPos.java @@ -4,6 +4,7 @@ import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; @@ -40,6 +41,10 @@ public BlockDimPos(ICommandSender sender) { this(sender.getPlayerCoordinates(), sender.getEntityWorld().provider.dimensionId); } + public BlockDimPos(EntityPlayer player) { + this(player.getPlayerCoordinates(), player.getEntityWorld().provider.dimensionId); + } + public int[] toIntArray() { return new int[] { posX, posY, posZ, dim }; } From bf97298ca44a35f0a18a0557f50b71999ea494ea Mon Sep 17 00:00:00 2001 From: Lyfts <127234178+Lyfts@users.noreply.github.com> Date: Wed, 3 Jan 2024 10:24:09 +0100 Subject: [PATCH 2/4] Fix /print_block_state returning an error since player is EntityClientPlayerMP --- .../command/client/CommandPrintState.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/serverutils/command/client/CommandPrintState.java b/src/main/java/serverutils/command/client/CommandPrintState.java index 3f51625c3..1df1c5fa7 100644 --- a/src/main/java/serverutils/command/client/CommandPrintState.java +++ b/src/main/java/serverutils/command/client/CommandPrintState.java @@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.ClickEvent; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; @@ -19,6 +20,9 @@ public CommandPrintState() { @Override public void processCommand(ICommandSender sender, final String[] args) throws CommandException { + if (!(sender instanceof EntityPlayer player)) { + return; + } MovingObjectPosition ray = Minecraft.getMinecraft().objectMouseOver; if (ray.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { return; @@ -27,13 +31,9 @@ public void processCommand(ICommandSender sender, final String[] args) throws Co Block block = sender.getEntityWorld().getBlock(ray.blockX, ray.blockY, ray.blockZ); IChatComponent component = new ChatComponentText( - block.getPickBlock( - ray, - sender.getEntityWorld(), - ray.blockX, - ray.blockY, - ray.blockZ, - getCommandSenderAsPlayer(sender)).getDisplayName() + " :: " + block.getUnlocalizedName()); + block.getPickBlock(ray, sender.getEntityWorld(), ray.blockX, ray.blockY, ray.blockZ, player) + .getDisplayName() + " :: " + + block.getUnlocalizedName()); component.getChatStyle() .setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, block.getUnlocalizedName())); sender.addChatMessage(component); From a05ea97c70838bb8b5c769d9871d499623a7871e Mon Sep 17 00:00:00 2001 From: Lyfts <127234178+Lyfts@users.noreply.github.com> Date: Wed, 3 Jan 2024 10:47:58 +0100 Subject: [PATCH 3/4] Hide buttons from config gui if disabled by NEI --- src/main/java/serverutils/client/gui/GuiSidebarButtonConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/serverutils/client/gui/GuiSidebarButtonConfig.java b/src/main/java/serverutils/client/gui/GuiSidebarButtonConfig.java index 874de9652..9175a058e 100644 --- a/src/main/java/serverutils/client/gui/GuiSidebarButtonConfig.java +++ b/src/main/java/serverutils/client/gui/GuiSidebarButtonConfig.java @@ -70,6 +70,7 @@ public GuiSidebarButtonConfig() { public void addButtons(Panel panel) { for (SidebarButtonGroup group : SidebarButtonManager.INSTANCE.groups) { for (SidebarButton button : group.getButtons()) { + if (!button.isVisible()) continue; panel.add(new ButtonConfigSidebarButton(panel, button)); } } From 22a89a8ca9ad7d4241a13217b6ed489bec3da288 Mon Sep 17 00:00:00 2001 From: Lyfts <127234178+Lyfts@users.noreply.github.com> Date: Wed, 3 Jan 2024 11:24:45 +0100 Subject: [PATCH 4/4] small cleanup --- src/main/java/serverutils/command/tp/CmdSetHome.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/serverutils/command/tp/CmdSetHome.java b/src/main/java/serverutils/command/tp/CmdSetHome.java index f8f384cee..1f2c3506a 100644 --- a/src/main/java/serverutils/command/tp/CmdSetHome.java +++ b/src/main/java/serverutils/command/tp/CmdSetHome.java @@ -35,11 +35,6 @@ public List addTabCompletionOptions(ICommandSender sender, String[] args @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { EntityPlayerMP player = getCommandSenderAsPlayer(sender); - - // if (player.isSpectator()) { - // throw ServerUtilities.error(sender, "serverutilities.lang.homes.spectator"); - // } - ServerUtilitiesPlayerData data = ServerUtilitiesPlayerData.get(CommandUtils.getForgePlayer(player)); if (args.length == 0) {