mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
fix not being able to pick up empty spawners with silk touch option
This commit is contained in:
@@ -18,10 +18,10 @@ index 21b74b3473553162c0113b2d365605782080cdfc..fd10ecc79b503b3a650bec1db656b86d
|
||||
public static final Item CRAFTING_TABLE = registerBlock(Blocks.CRAFTING_TABLE);
|
||||
public static final Item FARMLAND = registerBlock(Blocks.FARMLAND);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/SpawnerBlock.java b/src/main/java/net/minecraft/world/level/block/SpawnerBlock.java
|
||||
index 5af520104f25d597917e99ac09aa9d68c4864e44..5ab00db14e697085eb96c3c6db9b67ea85918506 100644
|
||||
index 5af520104f25d597917e99ac09aa9d68c4864e44..c4e5ff55a629ec57889175a0082abf95b8183069 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/SpawnerBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/SpawnerBlock.java
|
||||
@@ -40,6 +40,55 @@ public class SpawnerBlock extends BaseEntityBlock {
|
||||
@@ -40,6 +40,58 @@ public class SpawnerBlock extends BaseEntityBlock {
|
||||
return createTickerHelper(type, BlockEntityType.MOB_SPAWNER, world.isClientSide ? SpawnerBlockEntity::clientTick : SpawnerBlockEntity::serverTick);
|
||||
}
|
||||
|
||||
@@ -30,41 +30,44 @@ index 5af520104f25d597917e99ac09aa9d68c4864e44..5ab00db14e697085eb96c3c6db9b67ea
|
||||
+ public void playerDestroy(Level level, net.minecraft.world.entity.player.Player player, BlockPos pos, BlockState state, BlockEntity blockEntity, ItemStack stack) {
|
||||
+ if (level.purpurConfig.silkTouchEnabled && player.getBukkitEntity().hasPermission("purpur.drop.spawners") && isSilkTouch(level, stack)) {
|
||||
+ Optional<net.minecraft.world.entity.EntityType<?>> type = net.minecraft.world.entity.EntityType.by(((SpawnerBlockEntity) blockEntity).getSpawner().nextSpawnData.getEntityToSpawn());
|
||||
+ if (type.isPresent()) {
|
||||
+ final net.kyori.adventure.text.Component mobName = io.papermc.paper.adventure.PaperAdventure.asAdventure(type.get().getDescription());
|
||||
+ CompoundTag display = new CompoundTag();
|
||||
+ CompoundTag tag = new CompoundTag();
|
||||
+
|
||||
+ String name = level.purpurConfig.silkTouchSpawnerName;
|
||||
+ if (name != null && !name.isEmpty() && !name.equals("Spawner")) {
|
||||
+ net.kyori.adventure.text.Component displayName = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(name, net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.component("mob", mobName));
|
||||
+ if (name.startsWith("<reset>")) {
|
||||
+ displayName = displayName.decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, false);
|
||||
+ }
|
||||
+ display.put("Name", net.minecraft.nbt.StringTag.valueOf(io.papermc.paper.adventure.PaperAdventure.asJsonString(displayName, java.util.Locale.ROOT)));
|
||||
+ tag.put("display", display);
|
||||
+ net.minecraft.world.entity.EntityType<?> entityType = type.orElse(null);
|
||||
+ final net.kyori.adventure.text.Component mobName = io.papermc.paper.adventure.PaperAdventure.asAdventure(entityType == null ? Component.empty() : entityType.getDescription());
|
||||
+ CompoundTag display = new CompoundTag();
|
||||
+ CompoundTag tag = new CompoundTag();
|
||||
+
|
||||
+ String name = level.purpurConfig.silkTouchSpawnerName;
|
||||
+ if (name != null && !name.isEmpty() && !name.equals("Monster Spawner")) {
|
||||
+ net.kyori.adventure.text.Component displayName = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(name, net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.component("mob", mobName));
|
||||
+ if (name.startsWith("<reset>")) {
|
||||
+ displayName = displayName.decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, false);
|
||||
+ }
|
||||
+
|
||||
+ List<String> lore = level.purpurConfig.silkTouchSpawnerLore;
|
||||
+ if (lore != null && !lore.isEmpty()) {
|
||||
+ net.minecraft.nbt.ListTag list = new net.minecraft.nbt.ListTag();
|
||||
+ for (String line : lore) {
|
||||
+ net.kyori.adventure.text.Component lineComponent = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(line, net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.component("mob", mobName));
|
||||
+ if (line.startsWith("<reset>")) {
|
||||
+ lineComponent = lineComponent.decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, false);
|
||||
+ }
|
||||
+ list.add(net.minecraft.nbt.StringTag.valueOf(io.papermc.paper.adventure.PaperAdventure.asJsonString(lineComponent, java.util.Locale.ROOT)));
|
||||
+ }
|
||||
+ display.put("Lore", list);
|
||||
+ tag.put("display", display);
|
||||
+ }
|
||||
+
|
||||
+ ItemStack item = new ItemStack(Blocks.SPAWNER.asItem());
|
||||
+ tag.putString("Purpur.mob_type", type.get().getName());
|
||||
+ item.setTag(tag);
|
||||
+
|
||||
+ popResource(level, pos, item);
|
||||
+ display.put("Name", net.minecraft.nbt.StringTag.valueOf(io.papermc.paper.adventure.PaperAdventure.asJsonString(displayName, java.util.Locale.ROOT)));
|
||||
+ tag.put("display", display);
|
||||
+ }
|
||||
+
|
||||
+ List<String> lore = level.purpurConfig.silkTouchSpawnerLore;
|
||||
+ if (lore != null && !lore.isEmpty()) {
|
||||
+ net.minecraft.nbt.ListTag list = new net.minecraft.nbt.ListTag();
|
||||
+ for (String line : lore) {
|
||||
+ net.kyori.adventure.text.Component lineComponent = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(line, net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.component("mob", mobName));
|
||||
+ if (line.startsWith("<reset>")) {
|
||||
+ lineComponent = lineComponent.decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, false);
|
||||
+ }
|
||||
+ list.add(net.minecraft.nbt.StringTag.valueOf(io.papermc.paper.adventure.PaperAdventure.asJsonString(lineComponent, java.util.Locale.ROOT)));
|
||||
+ }
|
||||
+ display.put("Lore", list);
|
||||
+ tag.put("display", display);
|
||||
+ }
|
||||
+
|
||||
+ ItemStack item = new ItemStack(Blocks.SPAWNER.asItem());
|
||||
+ if (entityType != null) {
|
||||
+ tag.putString("Purpur.mob_type", entityType.getName());
|
||||
+ tag.putDouble("HideFlags", 32); // hides the "Interact with Spawn Egg" tooltip
|
||||
+ item.setTag(tag);
|
||||
+ }
|
||||
+
|
||||
+ popResource(level, pos, item);
|
||||
+ }
|
||||
+ super.playerDestroy(level, player, pos, state, blockEntity, stack);
|
||||
+ }
|
||||
@@ -77,7 +80,7 @@ index 5af520104f25d597917e99ac09aa9d68c4864e44..5ab00db14e697085eb96c3c6db9b67ea
|
||||
@Override
|
||||
public void spawnAfterBreak(BlockState state, ServerLevel world, BlockPos pos, ItemStack stack, boolean dropExperience) {
|
||||
super.spawnAfterBreak(state, world, pos, stack, dropExperience);
|
||||
@@ -48,6 +97,7 @@ public class SpawnerBlock extends BaseEntityBlock {
|
||||
@@ -48,6 +100,7 @@ public class SpawnerBlock extends BaseEntityBlock {
|
||||
|
||||
@Override
|
||||
public int getExpDrop(BlockState iblockdata, ServerLevel worldserver, BlockPos blockposition, ItemStack itemstack, boolean flag) {
|
||||
@@ -86,7 +89,7 @@ index 5af520104f25d597917e99ac09aa9d68c4864e44..5ab00db14e697085eb96c3c6db9b67ea
|
||||
int i = 15 + worldserver.random.nextInt(15) + worldserver.random.nextInt(15);
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index fcf58a69e8f3d0e3aa2566ddcdf05554aec979de..c46dc432e0a004c1912dc2eeb5da41cc76dfd7e8 100644
|
||||
index fcf58a69e8f3d0e3aa2566ddcdf05554aec979de..49675007c24b51a3f08e0da7d6e119b7541670ca 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -115,6 +115,38 @@ public class PurpurWorldConfig {
|
||||
@@ -94,7 +97,7 @@ index fcf58a69e8f3d0e3aa2566ddcdf05554aec979de..c46dc432e0a004c1912dc2eeb5da41cc
|
||||
}
|
||||
|
||||
+ public boolean silkTouchEnabled = false;
|
||||
+ public String silkTouchSpawnerName = "<reset><white>Spawner";
|
||||
+ public String silkTouchSpawnerName = "<reset><white>Monster Spawner";
|
||||
+ public List<String> silkTouchSpawnerLore = new ArrayList<>();
|
||||
+ public List<Item> silkTouchTools = new ArrayList<>();
|
||||
+ public int minimumSilkTouchSpawnerRequire = 1;
|
||||
|
||||
@@ -7,7 +7,7 @@ This patch's implementation has been removed in favor of Pufferfish's entity-tim
|
||||
The config remains for migration purposes.
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index ebad70a5fdfb4fb705d4542073cf068690294972..34b1fa9b540bc42e13bf4a1949c266fc8a973398 100644
|
||||
index dec121a4f817bdb1c3bf8ce784ad9028932a4357..a63428e576d4fd4cccd0d1bc9a7e831239500574 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -293,6 +293,39 @@ public class PurpurWorldConfig {
|
||||
@@ -48,5 +48,5 @@ index ebad70a5fdfb4fb705d4542073cf068690294972..34b1fa9b540bc42e13bf4a1949c266fc
|
||||
+ }
|
||||
+
|
||||
public boolean silkTouchEnabled = false;
|
||||
public String silkTouchSpawnerName = "<reset><white>Spawner";
|
||||
public String silkTouchSpawnerName = "<reset><white>Monster Spawner";
|
||||
public List<String> silkTouchSpawnerLore = new ArrayList<>();
|
||||
|
||||
@@ -18,7 +18,7 @@ index a725851060f13e734dbd2fbf8c83c9e1af57a8b7..74f798baafc53cd7dd1d4f58bc9a3581
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index 6c1f8b9aa052f78a59bb3dcbe0c3f480b73e9f34..ceaab7d62d6397a1bb8f89630f47ff2c8eb20946 100644
|
||||
index c7503beac939f5f636763c0cea0d997c6c4d335d..3fa62a02116798366bc30b48fcdd422d5e15e366 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -357,6 +357,11 @@ public class PurpurWorldConfig {
|
||||
@@ -31,5 +31,5 @@ index 6c1f8b9aa052f78a59bb3dcbe0c3f480b73e9f34..ceaab7d62d6397a1bb8f89630f47ff2c
|
||||
+ }
|
||||
+
|
||||
public boolean silkTouchEnabled = false;
|
||||
public String silkTouchSpawnerName = "<reset><white>Spawner";
|
||||
public String silkTouchSpawnerName = "<reset><white>Monster Spawner";
|
||||
public List<String> silkTouchSpawnerLore = new ArrayList<>();
|
||||
|
||||
@@ -18,7 +18,7 @@ index c7195f2e12bbd6545f7bffcc2b4ba5cc3d48df20..5e730bc9c8ff94b16ac2bf8567dda8ae
|
||||
Runnable afterAction = null; // Paper
|
||||
if (blockState2 != null && level.getBlockState(blockPos.above()).isAir()) {
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index 5c02af6ff74909bfa41323857080d3c0d1443f17..275a3fff5a87c774cbd91a88ed0da50d78e8e886 100644
|
||||
index 8593a03080ab1799eef4696a29090014ac303f9d..ac440d02ad7a041392d7086c83c9c12e15009747 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -447,6 +447,21 @@ public class PurpurWorldConfig {
|
||||
@@ -41,5 +41,5 @@ index 5c02af6ff74909bfa41323857080d3c0d1443f17..275a3fff5a87c774cbd91a88ed0da50d
|
||||
+ }
|
||||
+
|
||||
public boolean silkTouchEnabled = false;
|
||||
public String silkTouchSpawnerName = "<reset><white>Spawner";
|
||||
public String silkTouchSpawnerName = "<reset><white>Monster Spawner";
|
||||
public List<String> silkTouchSpawnerLore = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user