-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add CrumblingAttunedShard and recipe (#756)
* Add CrumblingAttunedShard and recipe This variant of an Attuned Shard is less costly to create in a warp-plate, but can only be used once. For the same target warp-plate it stacks up to 4 (and one can create the full stack at once when attuning). Each separate teleport event will consume 1 Crumbling Attuned Shard when teleporting to the associated destination. If multiple shards are in a Plate inventory Crumbling Attuned Shards are considered like any other shard in terms of random picking. This can be changed by putting a spider eye in one of the slots, in which case the picking process will only consider crumbling attuned shards. * Rename shards/shards_consumable -> single_use_warp_shards and warp_shards Create AbstractAttunedShardItem to avoid badly aging constructor overloads Remove unnecessary stack size limiting that should be deferred to the item stack instead Rename useShardsPrioritization to shouldPrioritizeSingleUseShards --------- Co-authored-by: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com>
- Loading branch information
1 parent
c6e10a6
commit aba9b45
Showing
15 changed files
with
234 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
shared/src/main/generated/data/waystones/tags/items/single_use_warp_shards.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
"waystones:crumbling_attuned_shard" | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
shared/src/main/generated/data/waystones/tags/items/warp_shards.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
"waystones:attuned_shard", | ||
"waystones:crumbling_attuned_shard" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
shared/src/main/java/net/blay09/mods/waystones/item/AbstractAttunedShardItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package net.blay09.mods.waystones.item; | ||
|
||
import net.blay09.mods.balm.api.Balm; | ||
import net.blay09.mods.waystones.api.IAttunementItem; | ||
import net.blay09.mods.waystones.api.IWaystone; | ||
import net.blay09.mods.waystones.block.WarpPlateBlock; | ||
import net.blay09.mods.waystones.core.WaystoneProxy; | ||
import net.blay09.mods.waystones.menu.WarpPlateContainer; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.nbt.NbtUtils; | ||
import net.minecraft.nbt.Tag; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.minecraft.world.level.Level; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public abstract class AbstractAttunedShardItem extends Item implements IAttunementItem { | ||
|
||
public AbstractAttunedShardItem(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
public boolean isFoil(ItemStack itemStack) { | ||
IWaystone waystoneAttunedTo = getWaystoneAttunedTo(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 attunedWarpPlate = getWaystoneAttunedTo(null, stack); | ||
if (attunedWarpPlate == null || !attunedWarpPlate.isValid()) { | ||
var textComponent = Component.translatable("tooltip.waystones.attuned_shard.attunement_lost"); | ||
textComponent.withStyle(ChatFormatting.GRAY); | ||
list.add(textComponent); | ||
return; | ||
} | ||
|
||
list.add(WarpPlateBlock.getGalacticName(attunedWarpPlate)); | ||
|
||
Player player = Balm.getProxy().getClientPlayer(); | ||
if (player != null && player.containerMenu instanceof WarpPlateContainer) { | ||
IWaystone currentWarpPlate = ((WarpPlateContainer) player.containerMenu).getWaystone(); | ||
if (attunedWarpPlate.getWaystoneUid().equals(currentWarpPlate.getWaystoneUid())) { | ||
list.add(Component.translatable("tooltip.waystones.attuned_shard.move_to_other_warp_plate")); | ||
} else { | ||
list.add(Component.translatable("tooltip.waystones.attuned_shard.plug_into_warp_plate")); | ||
} | ||
} else { | ||
list.add(Component.translatable("tooltip.waystones.attuned_shard.plug_into_warp_plate")); | ||
} | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public IWaystone getWaystoneAttunedTo(MinecraftServer server, 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")))); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void setWaystoneAttunedTo(ItemStack itemStack, @Nullable IWaystone waystone) { | ||
CompoundTag tagCompound = itemStack.getTag(); | ||
if (tagCompound == null) { | ||
tagCompound = new CompoundTag(); | ||
itemStack.setTag(tagCompound); | ||
} | ||
|
||
if (waystone != null) { | ||
tagCompound.put("AttunedToWaystone", NbtUtils.createUUID(waystone.getWaystoneUid())); | ||
} else { | ||
tagCompound.remove("AttunedToWaystone"); | ||
} | ||
} | ||
} |
82 changes: 1 addition & 81 deletions
82
shared/src/main/java/net/blay09/mods/waystones/item/AttunedShardItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,9 @@ | ||
package net.blay09.mods.waystones.item; | ||
|
||
import net.blay09.mods.balm.api.Balm; | ||
import net.blay09.mods.waystones.api.IAttunementItem; | ||
import net.blay09.mods.waystones.api.IWaystone; | ||
import net.blay09.mods.waystones.block.WarpPlateBlock; | ||
import net.blay09.mods.waystones.menu.WarpPlateContainer; | ||
import net.blay09.mods.waystones.core.WaystoneProxy; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.nbt.NbtUtils; | ||
import net.minecraft.nbt.Tag; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.minecraft.world.level.Level; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class AttunedShardItem extends Item implements IAttunementItem { | ||
public class AttunedShardItem extends AbstractAttunedShardItem { | ||
|
||
public AttunedShardItem(Properties properties) { | ||
super(properties.stacksTo(1)); | ||
} | ||
|
||
@Override | ||
public boolean isFoil(ItemStack itemStack) { | ||
IWaystone waystoneAttunedTo = getWaystoneAttunedTo(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 attunedWarpPlate = getWaystoneAttunedTo(null, stack); | ||
if (attunedWarpPlate == null || !attunedWarpPlate.isValid()) { | ||
var textComponent = Component.translatable("tooltip.waystones.attuned_shard.attunement_lost"); | ||
textComponent.withStyle(ChatFormatting.GRAY); | ||
list.add(textComponent); | ||
return; | ||
} | ||
|
||
list.add(WarpPlateBlock.getGalacticName(attunedWarpPlate)); | ||
|
||
Player player = Balm.getProxy().getClientPlayer(); | ||
if (player != null && player.containerMenu instanceof WarpPlateContainer) { | ||
IWaystone currentWarpPlate = ((WarpPlateContainer) player.containerMenu).getWaystone(); | ||
if (attunedWarpPlate.getWaystoneUid().equals(currentWarpPlate.getWaystoneUid())) { | ||
list.add(Component.translatable("tooltip.waystones.attuned_shard.move_to_other_warp_plate")); | ||
} else { | ||
list.add(Component.translatable("tooltip.waystones.attuned_shard.plug_into_warp_plate")); | ||
} | ||
} else { | ||
list.add(Component.translatable("tooltip.waystones.attuned_shard.plug_into_warp_plate")); | ||
} | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public IWaystone getWaystoneAttunedTo(MinecraftServer server, 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")))); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void setWaystoneAttunedTo(ItemStack itemStack, @Nullable IWaystone waystone) { | ||
CompoundTag tagCompound = itemStack.getTag(); | ||
if (tagCompound == null) { | ||
tagCompound = new CompoundTag(); | ||
itemStack.setTag(tagCompound); | ||
} | ||
|
||
if (waystone != null) { | ||
tagCompound.put("AttunedToWaystone", NbtUtils.createUUID(waystone.getWaystoneUid())); | ||
} else { | ||
tagCompound.remove("AttunedToWaystone"); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
shared/src/main/java/net/blay09/mods/waystones/item/CrumblingAttunedShardItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package net.blay09.mods.waystones.item; | ||
|
||
import net.blay09.mods.balm.api.Balm; | ||
import net.blay09.mods.waystones.api.IWaystone; | ||
import net.blay09.mods.waystones.menu.WarpPlateContainer; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.minecraft.world.level.Level; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
|
||
public class CrumblingAttunedShardItem extends AbstractAttunedShardItem { | ||
|
||
public CrumblingAttunedShardItem(Properties properties) { | ||
super(properties.stacksTo(4)); | ||
} | ||
|
||
@Override | ||
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> list, TooltipFlag flag) { | ||
super.appendHoverText(stack, world, list, flag); | ||
|
||
IWaystone attunedWarpPlate = getWaystoneAttunedTo(null, stack); | ||
if (attunedWarpPlate != null && attunedWarpPlate.isValid()) { | ||
var textComponent = Component.translatable("tooltip.waystones.attuned_shard.attunement_crumbling"); | ||
textComponent.withStyle(ChatFormatting.WHITE).withStyle(ChatFormatting.ITALIC); | ||
|
||
Player player = Balm.getProxy().getClientPlayer(); | ||
if (player != null && player.containerMenu instanceof WarpPlateContainer wpc) { | ||
if (!attunedWarpPlate.getWaystoneUid().equals(wpc.getWaystone().getWaystoneUid())) { | ||
list.add(textComponent); | ||
} | ||
} else { | ||
list.add(textComponent); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.