mirror of
https://github.com/PurpurMC/Purpur.git
synced 2025-02-23 13:09:31 +08:00
Silk spawners now NBT based, lore only for display
This commit is contained in:
parent
0554ce8234
commit
b153699691
@ -1,80 +1,128 @@
|
||||
From 9d9becd499b2fcea1601e0c18f9f090c359a297a Mon Sep 17 00:00:00 2001
|
||||
From 3d81446a71c62cdc61ee17dfee17d1f4fb77132a 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
|
||||
|
||||
---
|
||||
.../net/minecraft/server/BlockMobSpawner.java | 31 +++++++++++++++++--
|
||||
.../net/minecraft/server/ItemSpawner.java | 25 +++++++++++++++
|
||||
src/main/java/net/minecraft/server/Block.java | 1 +
|
||||
.../net/minecraft/server/BlockMobSpawner.java | 35 +++++++++++++++++++
|
||||
.../net/minecraft/server/EntityTypes.java | 13 +++++++
|
||||
.../net/minecraft/server/ItemSpawner.java | 20 +++++++++++
|
||||
src/main/java/net/minecraft/server/Items.java | 2 +-
|
||||
3 files changed, 54 insertions(+), 4 deletions(-)
|
||||
5 files changed, 70 insertions(+), 1 deletion(-)
|
||||
create mode 100644 src/main/java/net/minecraft/server/ItemSpawner.java
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
|
||||
index 5b98c5255..b5c8f2cb3 100644
|
||||
--- a/src/main/java/net/minecraft/server/Block.java
|
||||
+++ b/src/main/java/net/minecraft/server/Block.java
|
||||
@@ -494,6 +494,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("doTileDrops")) {
|
||||
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 bb77d916a..a2812d397 100644
|
||||
index bb77d916a..01b7e10a7 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockMobSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockMobSpawner.java
|
||||
@@ -1,5 +1,12 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// Purpur start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.inventory.meta.ItemMeta;
|
||||
+import javax.annotation.Nullable;
|
||||
+import java.util.Collections;
|
||||
+// Purpur end
|
||||
+
|
||||
public class BlockMobSpawner extends BlockTileEntity {
|
||||
|
||||
protected BlockMobSpawner(Block.Info block_info) {
|
||||
@@ -11,6 +18,26 @@ public class BlockMobSpawner extends BlockTileEntity {
|
||||
@@ -11,6 +11,40 @@ public class BlockMobSpawner extends BlockTileEntity {
|
||||
return new TileEntityMobSpawner();
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ private boolean dropped = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public void a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) {
|
||||
+ if (itemstack != null && itemstack.getItem() == Items.DIAMOND_PICKAXE && tileentity instanceof TileEntityMobSpawner && EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0) {
|
||||
+ public void a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, TileEntity tileentity, ItemStack itemstack) {
|
||||
+ if (isSilkTouch(itemstack)) {
|
||||
+ MinecraftKey type = ((TileEntityMobSpawner) tileentity).getSpawner().getMobName();
|
||||
+ if (type != null) {
|
||||
+ org.bukkit.inventory.ItemStack item = new ItemStack(Blocks.SPAWNER.getItem()).asBukkitMirror();
|
||||
+ ItemMeta meta = item.getItemMeta();
|
||||
+ meta.setLore(Collections.singletonList(type.toString()));
|
||||
+ item.setItemMeta(meta);
|
||||
+ a(world, blockposition, ((CraftItemStack) item).getHandle());
|
||||
+ dropped = true;
|
||||
+ 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(new NBTTagString(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);
|
||||
@@ -23,9 +50,7 @@ public class BlockMobSpawner extends BlockTileEntity {
|
||||
@@ -23,6 +57,7 @@ public class BlockMobSpawner extends BlockTileEntity {
|
||||
|
||||
@Override
|
||||
public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) {
|
||||
- int i = 15 + world.random.nextInt(15) + world.random.nextInt(15);
|
||||
-
|
||||
- return i;
|
||||
+ return dropped ? 0 : 15 + world.random.nextInt(15) + world.random.nextInt(15); // Purpur
|
||||
// CraftBukkit end
|
||||
+ if (isSilkTouch(itemstack)) return 0; // Purpur
|
||||
int i = 15 + world.random.nextInt(15) + world.random.nextInt(15);
|
||||
|
||||
return i;
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
index 77d4bbce1..fb0c6bce0 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
@@ -137,6 +137,12 @@ 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);
|
||||
}
|
||||
@@ -255,6 +261,12 @@ public class EntityTypes<T extends Entity> {
|
||||
return this.ba;
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ public String getTranslatedName() {
|
||||
+ return getNameComponent().getString();
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
public String e() {
|
||||
if (this.be == null) {
|
||||
this.be = SystemUtils.a("entity", IRegistry.ENTITY_TYPE.getKey(this));
|
||||
@@ -263,6 +275,7 @@ public class EntityTypes<T extends Entity> {
|
||||
return this.be;
|
||||
}
|
||||
|
||||
+ public IChatBaseComponent getNameComponent() { return f(); } // Purpur - OBFHELPER
|
||||
public IChatBaseComponent f() {
|
||||
if (this.bf == null) {
|
||||
this.bf = new ChatMessage(this.e(), new Object[0]);
|
||||
diff --git a/src/main/java/net/minecraft/server/ItemSpawner.java b/src/main/java/net/minecraft/server/ItemSpawner.java
|
||||
new file mode 100644
|
||||
index 000000000..1287c071f
|
||||
index 000000000..17da40083
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/ItemSpawner.java
|
||||
@@ -0,0 +1,25 @@
|
||||
@@ -0,0 +1,20 @@
|
||||
+package net.minecraft.server;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class ItemSpawner extends ItemBlock {
|
||||
+ public ItemSpawner(Block block, Info info) {
|
||||
+ super(block, info);
|
||||
@ -83,14 +131,11 @@ index 000000000..1287c071f
|
||||
+ @Override
|
||||
+ protected boolean a(BlockPosition blockposition, World world, EntityHuman entityhuman, ItemStack itemstack, IBlockData iblockdata) {
|
||||
+ boolean handled = super.a(blockposition, world, entityhuman, itemstack, iblockdata);
|
||||
+ TileEntity tileentity = world.getTileEntity(blockposition);
|
||||
+ if (tileentity instanceof TileEntityMobSpawner) {
|
||||
+ org.bukkit.inventory.ItemStack item = itemstack.asBukkitMirror();
|
||||
+ if (item.hasItemMeta()) {
|
||||
+ List<String> lore = item.getItemMeta().getLore();
|
||||
+ if (lore != null && !lore.isEmpty()) {
|
||||
+ EntityTypes.a(lore.get(0)).ifPresent(type -> ((TileEntityMobSpawner) tileentity).getSpawner().setMobName(type));
|
||||
+ }
|
||||
+ TileEntity te = world.getTileEntity(blockposition);
|
||||
+ if (te instanceof TileEntityMobSpawner && itemstack.hasTag()) {
|
||||
+ NBTTagCompound tag = itemstack.getTag();
|
||||
+ if (tag.hasKey("Purpur.mob_type")) {
|
||||
+ EntityTypes.a(tag.getString("Purpur.mob_type")).ifPresent(type -> ((TileEntityMobSpawner) te).getSpawner().setMobName(type));
|
||||
+ }
|
||||
+ }
|
||||
+ return handled;
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 752ca48604bb36245438910284ff165e3ac6ee4e Mon Sep 17 00:00:00 2001
|
||||
From 3ad2b56f69e8fe52b9820dd5366d30389a202651 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Tue, 30 Apr 2019 19:17:21 -0500
|
||||
Subject: [PATCH] Integrate ridables
|
||||
@ -30,13 +30,13 @@ Subject: [PATCH] Integrate ridables
|
||||
.../net/minecraft/server/EntitySnowman.java | 1 +
|
||||
.../net/minecraft/server/EntitySquid.java | 46 +++++++++++
|
||||
.../server/EntityTameableAnimal.java | 6 ++
|
||||
.../net/minecraft/server/EntityTypes.java | 6 ++
|
||||
.../net/minecraft/server/EntityTypes.java | 4 +
|
||||
.../purpur/controller/ControllerLookWASD.java | 74 ++++++++++++++++++
|
||||
.../purpur/controller/ControllerMoveWASD.java | 77 +++++++++++++++++++
|
||||
.../controller/ControllerMoveWASDFlying.java | 58 ++++++++++++++
|
||||
.../controller/ControllerMoveWASDWater.java | 42 ++++++++++
|
||||
.../craftbukkit/entity/CraftLivingEntity.java | 10 +++
|
||||
32 files changed, 562 insertions(+), 72 deletions(-)
|
||||
32 files changed, 560 insertions(+), 72 deletions(-)
|
||||
create mode 100644 src/main/java/net/pl3x/purpur/controller/ControllerLookWASD.java
|
||||
create mode 100644 src/main/java/net/pl3x/purpur/controller/ControllerMoveWASD.java
|
||||
create mode 100644 src/main/java/net/pl3x/purpur/controller/ControllerMoveWASDFlying.java
|
||||
@ -956,22 +956,20 @@ index 70bf06b94..2f41d8ade 100644
|
||||
this.setTamed(true);
|
||||
this.setOwnerUUID(entityhuman.getUniqueID());
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
index 77d4bbce1..73116e48f 100644
|
||||
index fb0c6bce0..4979f77b7 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
@@ -255,6 +255,12 @@ public class EntityTypes<T extends Entity> {
|
||||
return this.ba;
|
||||
@@ -262,6 +262,10 @@ public class EntityTypes<T extends Entity> {
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
// Purpur start
|
||||
+ public String getName() {
|
||||
+ return IRegistry.ENTITY_TYPE.getKey(this).getKey();
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
public String e() {
|
||||
if (this.be == null) {
|
||||
this.be = SystemUtils.a("entity", IRegistry.ENTITY_TYPE.getKey(this));
|
||||
public String getTranslatedName() {
|
||||
return getNameComponent().getString();
|
||||
}
|
||||
diff --git a/src/main/java/net/pl3x/purpur/controller/ControllerLookWASD.java b/src/main/java/net/pl3x/purpur/controller/ControllerLookWASD.java
|
||||
new file mode 100644
|
||||
index 000000000..99e184d36
|
||||
|
@ -1,19 +1,19 @@
|
||||
From 832abc735f332df25b27e9c94013125a9e0b8b82 Mon Sep 17 00:00:00 2001
|
||||
From 132991733ea1452650a9aac46b3f7477659ff4e6 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 11 May 2019 01:31:50 -0500
|
||||
Subject: [PATCH] Villager shops
|
||||
|
||||
---
|
||||
.../net/minecraft/server/EntityTypes.java | 9 +
|
||||
.../net/minecraft/server/EntityTypes.java | 7 +
|
||||
.../server/EntityVillagerAbstract.java | 1 +
|
||||
.../minecraft/server/EntityVillagerShop.java | 227 ++++++++++++++++++
|
||||
.../minecraft/server/NavigationAbstract.java | 2 +
|
||||
.../entity/CraftAbstractVillager.java | 2 +-
|
||||
5 files changed, 240 insertions(+), 1 deletion(-)
|
||||
5 files changed, 238 insertions(+), 1 deletion(-)
|
||||
create mode 100644 src/main/java/net/minecraft/server/EntityVillagerShop.java
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
index 73116e48f..8c67110c8 100644
|
||||
index 4979f77b7..475c3ec63 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
@@ -118,6 +118,7 @@ public class EntityTypes<T extends Entity> {
|
||||
@ -24,20 +24,18 @@ index 73116e48f..8c67110c8 100644
|
||||
private final EntityTypes.b<T> aZ;
|
||||
private final EnumCreatureType ba;
|
||||
private final boolean bb;
|
||||
@@ -137,6 +138,14 @@ public class EntityTypes<T extends Entity> {
|
||||
return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_a.a(s));
|
||||
@@ -138,6 +139,12 @@ public class EntityTypes<T extends Entity> {
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
// Purpur start
|
||||
+ private static <T extends Entity> EntityTypes<T> register(String name, String extendFrom, EntityTypes.a entitytypes_a) {
|
||||
+ Map<Object, Type<?>> dataTypes = (Map<Object, Type<?>>) DataConverterRegistry.a().getSchema(DataFixUtils.makeKey(SharedConstants.a().getWorldVersion())).findChoiceType(DataConverterTypes.o).types(); // entity_tree
|
||||
+ dataTypes.put("minecraft:" + name, dataTypes.get("minecraft:" + extendFrom));
|
||||
+ return a(name, entitytypes_a);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
public static MinecraftKey getName(EntityTypes<?> entitytypes) {
|
||||
return IRegistry.ENTITY_TYPE.getKey(entitytypes);
|
||||
public static EntityTypes getFromKey(MinecraftKey key) {
|
||||
return IRegistry.ENTITY_TYPE.get(key);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityVillagerAbstract.java b/src/main/java/net/minecraft/server/EntityVillagerAbstract.java
|
||||
index d78528696..8c75daee2 100644
|
||||
|
Loading…
Reference in New Issue
Block a user