Skip to content

Commit

Permalink
feat!: Remove Bound Scroll, allow attuning Warp Scroll instead #779
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Dec 21, 2023
1 parent b18e92d commit a92f48d
Show file tree
Hide file tree
Showing 51 changed files with 122 additions and 465 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public ModItemTagProvider(FabricDataOutput output, CompletableFuture<HolderLooku
protected void addTags(HolderLookup.Provider lookup) {
getOrCreateTagBuilder(ModItemTags.WARP_SCROLLS).add(ModItems.warpScroll);
getOrCreateTagBuilder(ModItemTags.RETURN_SCROLLS).add(ModItems.returnScroll);
getOrCreateTagBuilder(ModItemTags.BOUND_SCROLLS).add(ModItems.boundScroll);
getOrCreateTagBuilder(ModItemTags.WARP_STONES).add(ModItems.warpStone);
getOrCreateTagBuilder(ModItemTags.WARP_SHARDS).add(ModItems.attunedShard, ModItems.crumblingAttunedShard);
getOrCreateTagBuilder(ModItemTags.SINGLE_USE_WARP_SHARDS).add(ModItems.crumblingAttunedShard);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void generateItemModels(ItemModelGenerators itemModelGenerator) {
itemModelGenerator.generateFlatItem(ModItems.warpStone, ModelTemplates.FLAT_HANDHELD_ITEM);
itemModelGenerator.generateFlatItem(ModItems.warpScroll, ModelTemplates.FLAT_HANDHELD_ITEM);
itemModelGenerator.generateFlatItem(ModItems.returnScroll, ModelTemplates.FLAT_HANDHELD_ITEM);
itemModelGenerator.generateFlatItem(ModItems.boundScroll, ModelTemplates.FLAT_HANDHELD_ITEM);

final var dyedSharestoneTemplate = new ModelTemplate(Optional.of(new ResourceLocation("waystones", "item/dyed_sharestone")), Optional.empty());
for (Block scopedSharestone : ModBlocks.scopedSharestones) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,6 @@ public void buildRecipes(RecipeOutput exporter) {
.unlockedBy("has_ender_pearl", has(Items.ENDER_PEARL))
.save(exporter);

shaped(RecipeCategory.DECORATIONS, ModItems.boundScroll, 3)
.pattern("DDD")
.pattern("GEG")
.pattern("PPP")
.define('D', BalmItemTags.PURPLE_DYES)
.define('G', BalmItemTags.GOLD_NUGGETS)
.define('E', Items.ENDER_PEARL)
.define('P', Items.PAPER)
.unlockedBy("has_ender_pearl", has(Items.ENDER_PEARL))
.save(exporter);

shaped(RecipeCategory.DECORATIONS, ModItems.returnScroll, 3)
.pattern("GEG")
.pattern("PPP")
Expand Down
2 changes: 1 addition & 1 deletion modpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ It can be used in Survival Mode, for Adventure Maps or on Multiplayer Servers as

- Craftable Waystones for Survival Mode
- Teleporting between Waystones or using a Warp Scroll or rechargeable Warp Stone
- Sharing of activated Waystones through Bound Scrolls
- Sharing of activated Waystones through Bound Warp Scrolls
- Optional Inventory Button for warping without any items
- Global Waystones for Multiplayer Servers and Adventure Maps
- Generation of Random Waystones in the World
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -106,7 +107,7 @@ public ItemStack createAttunedShard(IWaystone warpPlate) {

@Override
public ItemStack createBoundScroll(IWaystone waystone) {
ItemStack itemStack = new ItemStack(ModItems.boundScroll);
ItemStack itemStack = new ItemStack(ModItems.warpScroll);
setBoundWaystone(itemStack, waystone);
return itemStack;
}
Expand Down Expand Up @@ -134,9 +135,9 @@ public Optional<IWaystone> placeWarpPlate(Level level, BlockPos pos) {
}

@Override
public Optional<IWaystone> getBoundWaystone(ItemStack itemStack) {
public Optional<IWaystone> getBoundWaystone(Player player, ItemStack itemStack) {
if (itemStack.getItem() instanceof IAttunementItem attunementItem) {
return Optional.ofNullable(attunementItem.getWaystoneAttunedTo(Balm.getHooks().getServer(), itemStack));
return Optional.ofNullable(attunementItem.getWaystoneAttunedTo(Balm.getHooks().getServer(), player, itemStack));
}
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package net.blay09.mods.waystones.api;

import net.minecraft.server.MinecraftServer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

public interface IAttunementItem {
@Nullable
IWaystone getWaystoneAttunedTo(@Nullable MinecraftServer server, ItemStack itemStack);
IWaystone getWaystoneAttunedTo(@Nullable MinecraftServer server, @Nullable Player player, ItemStack itemStack);

void setWaystoneAttunedTo(ItemStack itemStack, @Nullable IWaystone waystone);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.blay09.mods.waystones.core.WarpMode;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -41,7 +42,7 @@ public interface InternalMethods {

Optional<IWaystone> placeWarpPlate(Level level, BlockPos pos);

Optional<IWaystone> getBoundWaystone(ItemStack itemStack);
Optional<IWaystone> getBoundWaystone(Player player, ItemStack itemStack);

void setBoundWaystone(ItemStack itemStack, @Nullable IWaystone waystone);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -82,8 +83,8 @@ public static Optional<IWaystone> placeWarpPlate(Level level, BlockPos pos) {
return __internalMethods.placeWarpPlate(level, pos);
}

public static Optional<IWaystone> getBoundWaystone(ItemStack itemStack) {
return __internalMethods.getBoundWaystone(itemStack);
public static Optional<IWaystone> getBoundWaystone(Player player, ItemStack itemStack) {
return __internalMethods.getBoundWaystone(player, itemStack);
}

public static void setBoundWaystone(ItemStack itemStack, IWaystone waystone) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {

@Override
protected InteractionResult handleActivation(Level world, BlockPos pos, Player player, WaystoneBlockEntityBase tileEntity, IWaystone waystone) {
if (player.getMainHandItem().is(ModItemTags.BOUND_SCROLLS)) {
return InteractionResult.PASS;
}

boolean isActivated = PlayerWaystoneManager.isWaystoneActivated(player, waystone);
if (isActivated) {
if (!world.isClientSide) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public BlockState playerWillDestroy(Level world, BlockPos pos, BlockState state,

// If not silk touching, don't bother dropping shards attuned to this waystone, since the waystone is gonna die anyways
if (!hasSilkTouch && itemStack.getItem() == ModItems.attunedShard) {
IWaystone waystoneAttunedTo = ((IAttunementItem) ModItems.attunedShard).getWaystoneAttunedTo(world.getServer(), itemStack);
IWaystone waystoneAttunedTo = ((IAttunementItem) ModItems.attunedShard).getWaystoneAttunedTo(world.getServer(), player, itemStack);
if (waystoneAttunedTo != null && waystoneAttunedTo.getWaystoneUid().equals(waystoneBlockEntity.getWaystone().getWaystoneUid())) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void serverTick() {
iterator.remove();
} else if (ticksPassed > useTime) {
ItemStack targetAttunementStack = getTargetAttunementStack();
IWaystone targetWaystone = WaystonesAPI.getBoundWaystone(targetAttunementStack).orElse(null);
IWaystone targetWaystone = WaystonesAPI.getBoundWaystone(null, targetAttunementStack).orElse(null);
if (targetWaystone != null && targetWaystone.isValid()) {
teleportToTarget(entity, targetWaystone, targetAttunementStack);
}
Expand Down Expand Up @@ -295,7 +295,7 @@ public ItemStack getTargetAttunementStack() {
for (int i = 0; i < getContainerSize(); i++) {
ItemStack itemStack = getItem(i);
if (itemStack.is(ModItemTags.WARP_SHARDS)) {
IWaystone waystoneAttunedTo = WaystonesAPI.getBoundWaystone(itemStack).orElse(null);
IWaystone waystoneAttunedTo = WaystonesAPI.getBoundWaystone(null, itemStack).orElse(null);
if (waystoneAttunedTo != null && !waystoneAttunedTo.getWaystoneUid().equals(getWaystone().getWaystoneUid())) {
attunedShards.add(itemStack);
}
Expand All @@ -318,7 +318,7 @@ public ItemStack getTargetAttunementStack() {
}

public Optional<IWaystone> getTargetWaystone() {
return WaystonesAPI.getBoundWaystone(getTargetAttunementStack());
return WaystonesAPI.getBoundWaystone(null, getTargetAttunementStack());
}

public void markEntityForCooldown(Entity entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,15 @@ protected WaystoneRecipe trySelectRecipe() {
if (level == null) {
return null;
}

// Prevent crafting when more than one item is present in center slot
if (getItem(0).getCount() > 1) {
return null; //prevents crafting when more than 1 ingredient is present
return null;
}

// Prevent crafting if center slot is already attuned
if (WaystonesAPI.getBoundWaystone(null, getItem(0)).isPresent()) {
return null;
}

return level.getRecipeManager().getRecipeFor(ModRecipes.waystoneRecipeType, this, level)
Expand Down Expand Up @@ -326,7 +333,7 @@ protected void craft(WaystoneRecipe recipe) {
public Collection<? extends IWaystone> getAuxiliaryTargets() {
final var result = new ArrayList<IWaystone>();
for (final var item : getItems()) {
WaystonesAPI.getBoundWaystone(item).ifPresent(result::add);
WaystonesAPI.getBoundWaystone(null, item).ifPresent(result::add);
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public WaystoneInventoryButton(AbstractContainerScreen<?> parentScreen, OnPress
this.visiblePredicate = visiblePredicate;
this.xPosition = xPosition;
this.yPosition = yPosition;
this.iconItem = new ItemStack(ModItems.boundScroll);
this.iconItem = new ItemStack(ModItems.returnScroll);
this.iconItemHovered = new ItemStack(ModItems.warpScroll);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public static ItemStack findWarpItem(Entity entity, WarpMode warpMode) {
case WARP_SCROLL -> findWarpItem(entity, ModItemTags.WARP_SCROLLS);
case WARP_STONE -> findWarpItem(entity, ModItemTags.WARP_STONES);
case RETURN_SCROLL -> findWarpItem(entity, ModItemTags.RETURN_SCROLLS);
case BOUND_SCROLL -> findWarpItem(entity, ModItemTags.BOUND_SCROLLS);
default -> ItemStack.EMPTY;
};
}
Expand All @@ -180,7 +179,6 @@ public static boolean canUseWarpMode(Entity entity, WarpMode warpMode, ItemStack
return switch (warpMode) {
case INVENTORY_BUTTON -> entity instanceof Player && PlayerWaystoneManager.canUseInventoryButton(((Player) entity));
case WARP_SCROLL -> !heldItem.isEmpty() && heldItem.is(ModItemTags.WARP_SCROLLS);
case BOUND_SCROLL -> !heldItem.isEmpty() && heldItem.is(ModItemTags.BOUND_SCROLLS);
case RETURN_SCROLL -> !heldItem.isEmpty() && heldItem.is(ModItemTags.RETURN_SCROLLS);
case WARP_STONE -> !heldItem.isEmpty() && heldItem.is(ModItemTags.WARP_STONES) && entity instanceof Player
&& PlayerWaystoneManager.canUseWarpStone(((Player) entity), heldItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public enum WarpMode {
INVENTORY_BUTTON(() -> WaystonesConfig.getActive().xpCost.inventoryButtonXpCostMultiplier, WarpMode::always, false),
WARP_SCROLL(() -> 0.0, WarpMode::always, true),
RETURN_SCROLL(() -> 0.0, WarpMode::always, true),
BOUND_SCROLL(() -> 0.0, WarpMode::always, true),
WARP_STONE(() -> WaystonesConfig.getActive().xpCost.warpStoneXpCostMultiplier, WarpMode::always, false),
WAYSTONE_TO_WAYSTONE(() -> WaystonesConfig.getActive().xpCost.waystoneXpCostMultiplier, WarpMode::always, false),
SHARESTONE_TO_SHARESTONE(() -> WaystonesConfig.getActive().xpCost.sharestoneXpCostMultiplier, WarpMode::always, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public AbstractAttunedShardItem(Properties properties) {

@Override
public boolean isFoil(ItemStack itemStack) {
IWaystone waystoneAttunedTo = getWaystoneAttunedTo(null, itemStack);
IWaystone waystoneAttunedTo = getWaystoneAttunedTo(null, null, itemStack);
return waystoneAttunedTo != null && waystoneAttunedTo.isValid();
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> list, TooltipFlag flag) {
super.appendHoverText(stack, world, list, flag);

IWaystone attunedWaystone = getWaystoneAttunedTo(null, stack);
IWaystone attunedWaystone = getWaystoneAttunedTo(null, null, stack);
if (attunedWaystone == null || !attunedWaystone.isValid()) {
var textComponent = Component.translatable("tooltip.waystones.attuned_shard.attunement_lost");
textComponent.withStyle(ChatFormatting.GRAY);
Expand Down Expand Up @@ -68,7 +68,7 @@ public void appendHoverText(ItemStack stack, @Nullable Level world, List<Compone

@Nullable
@Override
public IWaystone getWaystoneAttunedTo(MinecraftServer server, ItemStack itemStack) {
public IWaystone getWaystoneAttunedTo(MinecraftServer server, Player player, ItemStack itemStack) {
CompoundTag compound = itemStack.getTag();
if (compound != null && compound.contains("AttunedToWaystone", Tag.TAG_INT_ARRAY)) {
return new WaystoneProxy(server, NbtUtils.loadUUID(Objects.requireNonNull(compound.get("AttunedToWaystone"))));
Expand Down
Loading

0 comments on commit a92f48d

Please sign in to comment.