From dc8b560cde6e32198dd7f5410cdc986b975ae241 Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:50:49 +0100 Subject: [PATCH] feat: Allow deletion of sharestones while in creative mode #644 --- .../client/gui/screen/SharestoneSelectionScreen.java | 2 +- .../client/gui/screen/WaystoneSelectionScreenBase.java | 9 +++++++-- .../client/gui/widget/RemoveWaystoneButton.java | 3 ++- .../src/main/resources/assets/waystones/lang/en_us.json | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/shared/src/main/java/net/blay09/mods/waystones/client/gui/screen/SharestoneSelectionScreen.java b/shared/src/main/java/net/blay09/mods/waystones/client/gui/screen/SharestoneSelectionScreen.java index d4e2c513..a97d9aa0 100644 --- a/shared/src/main/java/net/blay09/mods/waystones/client/gui/screen/SharestoneSelectionScreen.java +++ b/shared/src/main/java/net/blay09/mods/waystones/client/gui/screen/SharestoneSelectionScreen.java @@ -17,6 +17,6 @@ protected boolean allowSorting() { @Override protected boolean allowDeletion() { - return false; + return true; } } diff --git a/shared/src/main/java/net/blay09/mods/waystones/client/gui/screen/WaystoneSelectionScreenBase.java b/shared/src/main/java/net/blay09/mods/waystones/client/gui/screen/WaystoneSelectionScreenBase.java index 16bd6fe8..93fab00d 100644 --- a/shared/src/main/java/net/blay09/mods/waystones/client/gui/screen/WaystoneSelectionScreenBase.java +++ b/shared/src/main/java/net/blay09/mods/waystones/client/gui/screen/WaystoneSelectionScreenBase.java @@ -184,11 +184,16 @@ private void updateList() { } private boolean allowDeletion(Waystone waystone) { - if (waystone.getVisibility() == WaystoneVisibility.GLOBAL && !Minecraft.getInstance().player.getAbilities().instabuild) { + final var isCreative = Minecraft.getInstance().player.getAbilities().instabuild; + if (waystone.getVisibility() == WaystoneVisibility.GLOBAL && !isCreative) { return false; } - if (!waystone.getWaystoneType().equals(WaystoneTypes.WAYSTONE)) { + if (WaystoneTypes.isSharestone(waystone.getWaystoneType())) { + if (!isCreative) { + return false; + } + } else if (!waystone.getWaystoneType().equals(WaystoneTypes.WAYSTONE)) { return false; } diff --git a/shared/src/main/java/net/blay09/mods/waystones/client/gui/widget/RemoveWaystoneButton.java b/shared/src/main/java/net/blay09/mods/waystones/client/gui/widget/RemoveWaystoneButton.java index a92e0421..8eb2bdcb 100644 --- a/shared/src/main/java/net/blay09/mods/waystones/client/gui/widget/RemoveWaystoneButton.java +++ b/shared/src/main/java/net/blay09/mods/waystones/client/gui/widget/RemoveWaystoneButton.java @@ -2,6 +2,7 @@ import com.google.common.collect.Lists; import net.blay09.mods.waystones.api.Waystone; +import net.blay09.mods.waystones.api.WaystoneTypes; import net.blay09.mods.waystones.api.WaystoneVisibility; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.GuiGraphics; @@ -28,7 +29,7 @@ public RemoveWaystoneButton(int x, int y, int visibleRegionStart, int visibleReg this.visibleRegionHeight = visibleRegionHeight; tooltip = Lists.newArrayList(Component.translatable("gui.waystones.waystone_selection.hold_shift_to_delete")); activeTooltip = Lists.newArrayList(Component.translatable("gui.waystones.waystone_selection.click_to_delete")); - if (waystone.getVisibility() == WaystoneVisibility.GLOBAL) { + if (waystone.getVisibility() == WaystoneVisibility.GLOBAL || WaystoneTypes.isSharestone(waystone.getWaystoneType())) { var component = Component.translatable("gui.waystones.waystone_selection.deleting_global_for_all"); component.withStyle(ChatFormatting.DARK_RED); tooltip.add(component); diff --git a/shared/src/main/resources/assets/waystones/lang/en_us.json b/shared/src/main/resources/assets/waystones/lang/en_us.json index bc0c6efb..5644fa91 100644 --- a/shared/src/main/resources/assets/waystones/lang/en_us.json +++ b/shared/src/main/resources/assets/waystones/lang/en_us.json @@ -46,7 +46,7 @@ "gui.waystones.waystone_selection.unnamed_waystone": "", "gui.waystones.waystone_selection.hold_shift_to_delete": "Hold shift and click to delete", "gui.waystones.waystone_selection.click_to_delete": "Click to delete", - "gui.waystones.waystone_selection.deleting_global_for_all": "This will remove the global waystone for everyone.", + "gui.waystones.waystone_selection.deleting_global_for_all": "This will remove the waystone for everyone.", "gui.waystones.waystone_selection.no_waystones_activated": "You have not activated any waystones yet.", "gui.waystones.waystone_selection.level_requirement": "Level Cost: %d", "gui.waystones.waystone_selection.xp_requirement": "Experience Cost: %d",