Skip to content

Commit 0e5c80f

Browse files
Merge pull request #240 from Agarmal/1.20.1/force-wand-reload
Force Wanderwand to reload when equipped
2 parents 854ae67 + 0b38bd2 commit 0e5c80f

File tree

1 file changed

+7
-4
lines changed
  • common/src/main/kotlin/org/valkyrienskies/clockwork/content/curiosities/tools/wanderwand

1 file changed

+7
-4
lines changed

common/src/main/kotlin/org/valkyrienskies/clockwork/content/curiosities/tools/wanderwand/WanderwandItem.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ class WanderwandItem(properties: Properties) : CWItem(properties) {
4343

4444
override fun inventoryTick(stack: ItemStack, level: Level, entity: Entity, slotId: Int, isSelected: Boolean) {
4545
if (!level.isClientSide && entity is ServerPlayer) {
46-
if (!stack.orCreateTag.getBoolean("hasLoaded")) {
47-
stack.tag!!.putBoolean("hasLoaded", true)
48-
if (stack.tag!!.contains("selectedBlocks")) {
49-
sendTo(WanderwandRenderUpdatePacket(BlockPos.ZERO, ToolType.SELECT, blocks = stack.tag!!.get("selectedBlocks") as CompoundTag), entity as ServerPlayer)
46+
val tag = stack.orCreateTag
47+
if (!isSelected) {
48+
tag.putBoolean("hasLoaded", false)
49+
} else if (!tag.getBoolean("hasLoaded")) {
50+
tag.putBoolean("hasLoaded", true)
51+
if (tag.contains("selectedBlocks")) {
52+
sendTo(WanderwandRenderUpdatePacket(BlockPos.ZERO, ToolType.SELECT, blocks = tag.get("selectedBlocks") as CompoundTag), entity)
5053
}
5154
}
5255
}

0 commit comments

Comments
 (0)