Skip to content

Commit

Permalink
feat: Allow deletion of sharestones while in creative mode #644
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Dec 27, 2023
1 parent fa4e80c commit dc8b560
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ protected boolean allowSorting() {

@Override
protected boolean allowDeletion() {
return false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion shared/src/main/resources/assets/waystones/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"gui.waystones.waystone_selection.unnamed_waystone": "<unnamed>",
"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",
Expand Down

0 comments on commit dc8b560

Please sign in to comment.