Skip to content

Commit 544a2b6

Browse files
committed
copy spawner data exactly when silk touching
1 parent d05e78b commit 544a2b6

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

patches/server/0020-Silk-touch-spawners.patch

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ index f692149d91b525bda6dc79d489d7496ea24037e8..7fbd4bf29bcc0795aa4b0e6d5d4bc374
1818
public static final Item CRAFTING_TABLE = registerBlock(Blocks.CRAFTING_TABLE);
1919
public static final Item FARMLAND = registerBlock(Blocks.FARMLAND);
2020
diff --git a/src/main/java/net/minecraft/world/level/block/SpawnerBlock.java b/src/main/java/net/minecraft/world/level/block/SpawnerBlock.java
21-
index e8b1c44da90f60cde20cda65aba2aa1e30f89d25..c55576424993236da46ed1c2ccd03b72d7ee97f9 100644
21+
index e8b1c44da90f60cde20cda65aba2aa1e30f89d25..1ac38424a44aa2225b9bd3fa0fbbe61b7b24875c 100644
2222
--- a/src/main/java/net/minecraft/world/level/block/SpawnerBlock.java
2323
+++ b/src/main/java/net/minecraft/world/level/block/SpawnerBlock.java
24-
@@ -42,6 +42,58 @@ public class SpawnerBlock extends BaseEntityBlock {
24+
@@ -42,6 +42,60 @@ public class SpawnerBlock extends BaseEntityBlock {
2525
return createTickerHelper(type, BlockEntityType.MOB_SPAWNER, world.isClientSide ? SpawnerBlockEntity::clientTick : SpawnerBlockEntity::serverTick);
2626
}
2727

@@ -35,6 +35,9 @@ index e8b1c44da90f60cde20cda65aba2aa1e30f89d25..c55576424993236da46ed1c2ccd03b72
3535
+ final net.kyori.adventure.text.Component mobName = io.papermc.paper.adventure.PaperAdventure.asAdventure(entityType == null ? Component.empty() : entityType.getDescription());
3636
+ net.minecraft.nbt.CompoundTag display = new net.minecraft.nbt.CompoundTag();
3737
+ net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
38+
+ net.minecraft.nbt.CompoundTag blockEntityTag = blockEntity.getUpdateTag();
39+
+ blockEntityTag.remove("Delay"); // remove this tag to allow stacking duplicate spawners
40+
+ tag.put("BlockEntityTag", blockEntityTag);
3841
+
3942
+ String name = level.purpurConfig.silkTouchSpawnerName;
4043
+ if (name != null && !name.isEmpty() && !name.equals("Monster Spawner")) {
@@ -62,7 +65,6 @@ index e8b1c44da90f60cde20cda65aba2aa1e30f89d25..c55576424993236da46ed1c2ccd03b72
6265
+
6366
+ ItemStack item = new ItemStack(Blocks.SPAWNER.asItem());
6467
+ if (entityType != null) {
65-
+ tag.putString("Purpur.mob_type", entityType.getName());
6668
+ tag.putDouble("HideFlags", ItemStack.TooltipPart.ADDITIONAL.getMask()); // hides the "Interact with Spawn Egg" tooltip
6769
+ item.setTag(tag);
6870
+ }
@@ -80,7 +82,7 @@ index e8b1c44da90f60cde20cda65aba2aa1e30f89d25..c55576424993236da46ed1c2ccd03b72
8082
@Override
8183
public void spawnAfterBreak(BlockState state, ServerLevel world, BlockPos pos, ItemStack tool, boolean dropExperience) {
8284
super.spawnAfterBreak(state, world, pos, tool, dropExperience);
83-
@@ -50,6 +102,7 @@ public class SpawnerBlock extends BaseEntityBlock {
85+
@@ -50,6 +104,7 @@ public class SpawnerBlock extends BaseEntityBlock {
8486

8587
@Override
8688
public int getExpDrop(BlockState iblockdata, ServerLevel worldserver, BlockPos blockposition, ItemStack itemstack, boolean flag) {
@@ -133,10 +135,10 @@ index 70f53ccb22de2c05c9ead68f8bd29d0b69d0993f..d4bca5b5f3d10c3a04befd8c365f4643
133135
public boolean useNightVisionWhenRiding = false;
134136
diff --git a/src/main/java/org/purpurmc/purpur/item/SpawnerItem.java b/src/main/java/org/purpurmc/purpur/item/SpawnerItem.java
135137
new file mode 100644
136-
index 0000000000000000000000000000000000000000..c038fb2bbb0f0e78380bc24bbd6348b869669a90
138+
index 0000000000000000000000000000000000000000..d6cc7e434cb2bacc00e4cad9e1f4be7fcf5d0bee
137139
--- /dev/null
138140
+++ b/src/main/java/org/purpurmc/purpur/item/SpawnerItem.java
139-
@@ -0,0 +1,36 @@
141+
@@ -0,0 +1,38 @@
140142
+package org.purpurmc.purpur.item;
141143
+
142144
+import net.minecraft.core.BlockPos;
@@ -167,6 +169,8 @@ index 0000000000000000000000000000000000000000..c038fb2bbb0f0e78380bc24bbd6348b8
167169
+ if (tag.contains("Purpur.mob_type")) {
168170
+ EntityType.byString(tag.getString("Purpur.mob_type")).ifPresent(type ->
169171
+ ((SpawnerBlockEntity) spawner).getSpawner().setEntityId(type, level, level.random, pos));
172+
+ } else if (tag.contains("BlockEntityTag")) {
173+
+ spawner.load(tag.getCompound("BlockEntityTag"));
170174
+ }
171175
+ }
172176
+ }

0 commit comments

Comments
 (0)