diff --git a/shared/src/main/java/net/blay09/mods/waystones/api/IWaystoneTeleportContext.java b/shared/src/main/java/net/blay09/mods/waystones/api/IWaystoneTeleportContext.java index 7f020654..27d7bea5 100644 --- a/shared/src/main/java/net/blay09/mods/waystones/api/IWaystoneTeleportContext.java +++ b/shared/src/main/java/net/blay09/mods/waystones/api/IWaystoneTeleportContext.java @@ -52,4 +52,11 @@ public interface IWaystoneTeleportContext { boolean playsEffect(); void setPlaysEffect(boolean playsEffect); + + default boolean consumesWarpItem() { + return getWarpMode() != null && getWarpMode().consumesItem(); + }; + + default void setConsumesWarpItem(boolean consumesWarpItem) { } + } diff --git a/shared/src/main/java/net/blay09/mods/waystones/core/PlayerWaystoneManager.java b/shared/src/main/java/net/blay09/mods/waystones/core/PlayerWaystoneManager.java index e20c74c1..6190a2ba 100644 --- a/shared/src/main/java/net/blay09/mods/waystones/core/PlayerWaystoneManager.java +++ b/shared/src/main/java/net/blay09/mods/waystones/core/PlayerWaystoneManager.java @@ -258,7 +258,7 @@ public static Either, WaystoneTeleportError> tryTeleport(IWaystoneT } boolean isCreativeMode = entity instanceof Player && ((Player) entity).getAbilities().instabuild; - if (!context.getWarpItem().isEmpty() && event.getConsumeItemResult().withDefault(() -> warpMode.consumesItem() && !isCreativeMode)) { + if (!context.getWarpItem().isEmpty() && event.getConsumeItemResult().withDefault(() -> !isCreativeMode && context.consumesWarpItem())) { context.getWarpItem().shrink(1); } diff --git a/shared/src/main/java/net/blay09/mods/waystones/core/WaystoneTeleportContext.java b/shared/src/main/java/net/blay09/mods/waystones/core/WaystoneTeleportContext.java index 9a03bc6f..f195c370 100644 --- a/shared/src/main/java/net/blay09/mods/waystones/core/WaystoneTeleportContext.java +++ b/shared/src/main/java/net/blay09/mods/waystones/core/WaystoneTeleportContext.java @@ -3,7 +3,6 @@ import net.blay09.mods.waystones.api.IWaystone; import net.blay09.mods.waystones.api.IWaystoneTeleportContext; import net.blay09.mods.waystones.api.TeleportDestination; -import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; import net.minecraft.world.item.ItemStack; @@ -24,6 +23,8 @@ public class WaystoneTeleportContext implements IWaystoneTeleportContext { private WarpMode warpMode = WarpMode.CUSTOM; private ItemStack warpItem = ItemStack.EMPTY; + @Nullable + private Boolean consumesWarpItem; // nullable for now so we can fallback to legacy warp mode implementation private int xpCost; private int cooldown; private boolean playsSound = true; @@ -145,4 +146,14 @@ public boolean playsEffect() { public void setPlaysEffect(boolean playsEffect) { this.playsEffect = playsEffect; } + + @Override + public boolean consumesWarpItem() { + return this.consumesWarpItem == null ? getWarpMode().consumesItem() : this.consumesWarpItem; + } + + @Override + public void setConsumesWarpItem(boolean consumesWarpItem) { + this.consumesWarpItem = consumesWarpItem; + } }