mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 02:17:42 +01:00
Customizable spawner name and lore
This commit is contained in:
@@ -17,10 +17,25 @@ index a45ceff9f..d08b58473 100644
|
||||
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 81e145ff0..5929220b0 100644
|
||||
index 81e145ff0..91b92d95a 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 {
|
||||
@@ -1,5 +1,14 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// Purpur start
|
||||
+import net.md_5.bungee.api.ChatColor;
|
||||
+import net.md_5.bungee.api.chat.BaseComponent;
|
||||
+import net.md_5.bungee.api.chat.TextComponent;
|
||||
+import net.md_5.bungee.chat.ComponentSerializer;
|
||||
+
|
||||
+import java.util.List;
|
||||
+// Purpur end
|
||||
+
|
||||
public class BlockMobSpawner extends BlockTileEntity {
|
||||
|
||||
protected BlockMobSpawner(BlockBase.Info blockbase_info) {
|
||||
@@ -11,6 +20,59 @@ public class BlockMobSpawner extends BlockTileEntity {
|
||||
return new TileEntityMobSpawner();
|
||||
}
|
||||
|
||||
@@ -30,21 +45,40 @@ index 81e145ff0..5929220b0 100644
|
||||
+ if (world.purpurConfig.silkTouchEnabled && entityhuman.getBukkitEntity().hasPermission("purpur.drop.spawners") && isSilkTouch(world, 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);
|
||||
+ boolean customDisplay = false;
|
||||
+
|
||||
+ String name = world.purpurConfig.silkTouchSpawnerName;
|
||||
+ if (name != null && !name.isEmpty() && !name.equals("Spawner")) {
|
||||
+ name = ChatColor.translateAlternateColorCodes('&', name
|
||||
+ .replace("{mob}", mobName));
|
||||
+ BaseComponent[] comp = TextComponent.fromLegacyText(name);
|
||||
+ display.set("Name", NBTTagString.create(ComponentSerializer.toString(comp)));
|
||||
+ customDisplay = true;
|
||||
+ }
|
||||
+
|
||||
+ List<String> lore = world.purpurConfig.silkTouchSpawnerLore;
|
||||
+ if (lore != null && !lore.isEmpty()) {
|
||||
+ NBTTagList list = new NBTTagList();
|
||||
+ for (String line : lore) {
|
||||
+ line = ChatColor.translateAlternateColorCodes('&', line
|
||||
+ .replace("{mob}", mobName));
|
||||
+ BaseComponent[] comp = TextComponent.fromLegacyText(line);
|
||||
+ list.add(NBTTagString.create(ComponentSerializer.toString(comp)));
|
||||
+ }
|
||||
+ display.set("Lore", list);
|
||||
+ customDisplay = true;
|
||||
+ }
|
||||
+
|
||||
+ NBTTagCompound tag = new NBTTagCompound();
|
||||
+ tag.set("display", display);
|
||||
+ if (customDisplay) {
|
||||
+ tag.set("display", display);
|
||||
+ }
|
||||
+ tag.setString("Purpur.mob_type", type.toString());
|
||||
+
|
||||
+ ItemStack item = new ItemStack(Blocks.SPAWNER.getItem());
|
||||
+ item.setTag(tag);
|
||||
+
|
||||
+ dropItem(world, blockposition, item);
|
||||
@@ -61,7 +95,7 @@ index 81e145ff0..5929220b0 100644
|
||||
@Override
|
||||
public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
|
||||
super.dropNaturally(iblockdata, worldserver, blockposition, itemstack);
|
||||
@@ -23,6 +57,7 @@ public class BlockMobSpawner extends BlockTileEntity {
|
||||
@@ -23,6 +85,7 @@ public class BlockMobSpawner extends BlockTileEntity {
|
||||
|
||||
@Override
|
||||
public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
|
||||
@@ -112,7 +146,7 @@ index 1c861bccc..67ebcbe4d 100644
|
||||
public static final Item cy = a(Blocks.CHEST, CreativeModeTab.c);
|
||||
public static final Item cz = a(Blocks.DIAMOND_ORE, CreativeModeTab.b);
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index c7fb5a737..818c4da17 100644
|
||||
index c7fb5a737..ba89efb31 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -1,6 +1,12 @@
|
||||
@@ -128,14 +162,21 @@ index c7fb5a737..818c4da17 100644
|
||||
import java.util.List;
|
||||
import static net.pl3x.purpur.PurpurConfig.log;
|
||||
|
||||
@@ -75,6 +81,22 @@ public class PurpurWorldConfig {
|
||||
@@ -75,6 +81,29 @@ public class PurpurWorldConfig {
|
||||
playerInvulnerableWhileAcceptingResourcePack = getBoolean("gameplay-mechanics.player.invulnerable-while-accepting-resource-pack", playerInvulnerableWhileAcceptingResourcePack);
|
||||
}
|
||||
|
||||
+ public boolean silkTouchEnabled = false;
|
||||
+ public String silkTouchSpawnerName = "Spawner";
|
||||
+ public List<String> silkTouchSpawnerLore = new ArrayList<>();
|
||||
+ public List<Item> silkTouchTools = new ArrayList<>();
|
||||
+ private void silkTouchSettings() {
|
||||
+ silkTouchEnabled = getBoolean("gameplay-mechanics.silk-touch.enabled", silkTouchEnabled);
|
||||
+ silkTouchSpawnerName = getString("gameplay-mechanics.silk-touch.spawner-name", silkTouchSpawnerName);
|
||||
+ silkTouchSpawnerLore.clear();
|
||||
+ getList("gameplay-mechanics.silk-touch.spawner-lore", new ArrayList<String>(){{
|
||||
+ add("Spawns a {mob}");
|
||||
+ }}).forEach(line -> silkTouchSpawnerLore.add(line.toString()));
|
||||
+ silkTouchTools.clear();
|
||||
+ getList("gameplay-mechanics.silk-touch.tools", new ArrayList<String>(){{
|
||||
+ add("minecraft:iron_pickaxe");
|
||||
|
||||
Reference in New Issue
Block a user