mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 00:47:42 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: b75eeca0 Boost light task priority to ensure it doesnt hold up chunk loads 3d2bc848 Ensure VillagerTrades doesn't load async - fixes #3495 e470f1ef Add more information to Timing Reports f4a47db6 Improve Thread Pool usage to allow single threads for single cpu servers a4fe910f Fix sounds when using worldedit regen command 70ad51a8 Updated Upstream (Bukkit/CraftBukkit) d7cfa4fa Improve legacy format serialization more
113 lines
4.9 KiB
Diff
113 lines
4.9 KiB
Diff
From c458e4eb00beea0dc60c35e6c343e6b013c80a97 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Thu, 9 May 2019 14:27:37 -0500
|
|
Subject: [PATCH] Silk touch spawners
|
|
|
|
---
|
|
src/main/java/net/minecraft/server/Block.java | 1 +
|
|
.../net/minecraft/server/BlockMobSpawner.java | 34 +++++++++++++++++++
|
|
.../net/minecraft/server/EntityTypes.java | 12 +++++++
|
|
3 files changed, 47 insertions(+)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
|
|
index d051a54aa0..8c8dc9d6b8 100644
|
|
--- a/src/main/java/net/minecraft/server/Block.java
|
|
+++ b/src/main/java/net/minecraft/server/Block.java
|
|
@@ -501,6 +501,7 @@ public class Block implements IMaterial {
|
|
iblockdata.dropNaturally(world, blockposition, itemstack);
|
|
}
|
|
|
|
+ public static void dropItem(World world, BlockPosition blockposition, ItemStack itemstack) { a(world, blockposition, itemstack); } // Purpur - OBFHELPER
|
|
public static void a(World world, BlockPosition blockposition, ItemStack itemstack) {
|
|
if (!world.isClientSide && !itemstack.isEmpty() && world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) {
|
|
float f = 0.5F;
|
|
diff --git a/src/main/java/net/minecraft/server/BlockMobSpawner.java b/src/main/java/net/minecraft/server/BlockMobSpawner.java
|
|
index 5296fdf168..69d04f6cbf 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockMobSpawner.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockMobSpawner.java
|
|
@@ -11,6 +11,40 @@ public class BlockMobSpawner extends BlockTileEntity {
|
|
return new TileEntityMobSpawner();
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ public void a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, TileEntity tileentity, ItemStack itemstack) {
|
|
+ if (entityhuman.getBukkitEntity().hasPermission("purpur.drop.spawners") && isSilkTouch(itemstack)) {
|
|
+ MinecraftKey type = ((TileEntityMobSpawner) tileentity).getSpawner().getMobName();
|
|
+ if (type != null) {
|
|
+ ItemStack item = new ItemStack(Blocks.SPAWNER.getItem());
|
|
+
|
|
+ String mobName = EntityTypes.getFromKey(type).getTranslatedName();
|
|
+ ChatComponentText text = new ChatComponentText("Spawns a " + mobName);
|
|
+
|
|
+ NBTTagList lore = new NBTTagList();
|
|
+ lore.add(NBTTagString.a(IChatBaseComponent.ChatSerializer.a(text)));
|
|
+
|
|
+ NBTTagCompound display = new NBTTagCompound();
|
|
+ display.set("Lore", lore);
|
|
+
|
|
+ NBTTagCompound tag = new NBTTagCompound();
|
|
+ tag.set("display", display);
|
|
+ tag.setString("Purpur.mob_type", type.toString());
|
|
+
|
|
+ item.setTag(tag);
|
|
+
|
|
+ dropItem(world, blockposition, item);
|
|
+ }
|
|
+ }
|
|
+ super.a(world, entityhuman, blockposition, iblockdata, tileentity, itemstack);
|
|
+ }
|
|
+
|
|
+ private boolean isSilkTouch(ItemStack itemstack) {
|
|
+ return itemstack != null && itemstack.getItem() == Items.DIAMOND_PICKAXE && EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) {
|
|
super.dropNaturally(iblockdata, world, blockposition, itemstack);
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
|
index 5a7494947c..8e8d392a15 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
|
@@ -136,10 +136,17 @@ public class EntityTypes<T extends Entity> {
|
|
return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_a.a(s));
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public static EntityTypes getFromKey(MinecraftKey key) {
|
|
+ return IRegistry.ENTITY_TYPE.get(key);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
public static MinecraftKey getName(EntityTypes<?> entitytypes) {
|
|
return IRegistry.ENTITY_TYPE.getKey(entitytypes);
|
|
}
|
|
|
|
+ public static Optional<EntityTypes<?>> getType(String name) { return a(name); } // Purpur - OBFHELPER
|
|
public static Optional<EntityTypes<?>> a(String s) {
|
|
return IRegistry.ENTITY_TYPE.getOptional(MinecraftKey.a(s));
|
|
}
|
|
@@ -263,6 +270,10 @@ public class EntityTypes<T extends Entity> {
|
|
public String getName() {
|
|
return IRegistry.ENTITY_TYPE.getKey(this).getKey();
|
|
}
|
|
+
|
|
+ public String getTranslatedName() {
|
|
+ return getNameComponent().getString();
|
|
+ }
|
|
// Purpur end
|
|
|
|
public String f() {
|
|
@@ -273,6 +284,7 @@ public class EntityTypes<T extends Entity> {
|
|
return this.bg;
|
|
}
|
|
|
|
+ public IChatBaseComponent getNameComponent() { return g(); } // Purpur - OBFHELPER
|
|
public IChatBaseComponent g() {
|
|
if (this.bh == null) {
|
|
this.bh = new ChatMessage(this.f(), new Object[0]);
|
|
--
|
|
2.24.0
|
|
|