mirror of https://github.com/YatopiaMC/Yatopia.git
87 lines
4.0 KiB
Diff
87 lines
4.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Fri, 5 Jul 2019 18:21:00 -0500
|
|
Subject: [PATCH] PlayerSetSpawnerTypeWithEggEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityTypes.java b/src/main/java/net/minecraft/world/entity/EntityTypes.java
|
|
index 80c229c1852199fda85c03453d64cae33e413e89..6335e9046a6288f7bcf945ad8c381e080744653d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityTypes.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityTypes.java
|
|
@@ -274,6 +274,16 @@ public class EntityTypes<T extends Entity> {
|
|
return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s));
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public static EntityTypes getFromBukkitType(org.bukkit.entity.EntityType bukkitType) {
|
|
+ return getFromKey(new MinecraftKey(bukkitType.getKey().toString()));
|
|
+ }
|
|
+
|
|
+ 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);
|
|
}
|
|
@@ -439,6 +449,16 @@ public class EntityTypes<T extends Entity> {
|
|
return this.bg;
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public String getName() {
|
|
+ return IRegistry.ENTITY_TYPE.getKey(this).getKey();
|
|
+ }
|
|
+
|
|
+ public String getTranslatedName() {
|
|
+ return getNameComponent().getString();
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
public String getDescriptionId() { return f(); } // Paper - OBFHELPER
|
|
public String f() {
|
|
if (this.bo == null) {
|
|
@@ -448,6 +468,7 @@ public class EntityTypes<T extends Entity> {
|
|
return this.bo;
|
|
}
|
|
|
|
+ public IChatBaseComponent getNameComponent() { return g(); } // Purpur - OBFHELPER
|
|
public IChatBaseComponent g() {
|
|
if (this.bp == null) {
|
|
this.bp = new ChatMessage(this.f());
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemMonsterEgg.java b/src/main/java/net/minecraft/world/item/ItemMonsterEgg.java
|
|
index addddb64956c63563fc072b35cc511d31c9afd45..5e2d0246146af8bf1de1038f6a1953451b99f0f5 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemMonsterEgg.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemMonsterEgg.java
|
|
@@ -33,6 +33,13 @@ import net.minecraft.world.phys.MovingObjectPosition;
|
|
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
|
import net.minecraft.world.phys.Vec3D;
|
|
|
|
+// Purpur start
|
|
+import net.pl3x.purpur.event.PlayerSetSpawnerTypeWithEggEvent;
|
|
+import org.bukkit.block.CreatureSpawner;
|
|
+import org.bukkit.entity.EntityType;
|
|
+import org.bukkit.entity.Player;
|
|
+// Purpur end
|
|
+
|
|
public class ItemMonsterEgg extends Item {
|
|
|
|
public static final Map<EntityTypes<?>, ItemMonsterEgg> a = Maps.newIdentityHashMap(); // Purpur - private -> public
|
|
@@ -67,6 +74,15 @@ public class ItemMonsterEgg extends Item {
|
|
MobSpawnerAbstract mobspawnerabstract = ((TileEntityMobSpawner) tileentity).getSpawner();
|
|
EntityTypes<?> entitytypes = this.a(itemstack.getTag());
|
|
|
|
+ // Purpur start
|
|
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
+ PlayerSetSpawnerTypeWithEggEvent event = new PlayerSetSpawnerTypeWithEggEvent((Player) itemactioncontext.getEntity().getBukkitEntity(), bukkitBlock, (CreatureSpawner) bukkitBlock.getState(), EntityType.fromName(entitytypes.getName()));
|
|
+ if (!event.callEvent()) {
|
|
+ return EnumInteractionResult.FAIL;
|
|
+ }
|
|
+ entitytypes = EntityTypes.getFromBukkitType(event.getEntityType());
|
|
+ // Purpur end
|
|
+
|
|
mobspawnerabstract.setMobName(entitytypes);
|
|
tileentity.update();
|
|
world.notify(blockposition, iblockdata, iblockdata, 3);
|