Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for minor command problems #26

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/serverutils/command/client/CommandPrintState.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/serverutils/command/tp/CmdSetHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public List<String> 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) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/serverutils/command/tp/CmdSetWarp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/serverutils/command/tp/CmdTplast.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/serverutils/lib/math/BlockDimPos.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
}
Expand Down