diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2012-01-15 09:45:16 +0000 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2012-01-15 10:01:49 +0000 |
commit | 25050e38eb02c93b32fc9b1eaf2de82992a7ff3a (patch) | |
tree | 1fe352e8233e004eb5a51191c55c4b05f8a4211d /src | |
parent | 390a79e098903371a271f9bc68fe711915caf9e7 (diff) | |
download | craftbukkit-25050e38eb02c93b32fc9b1eaf2de82992a7ff3a.tar craftbukkit-25050e38eb02c93b32fc9b1eaf2de82992a7ff3a.tar.gz craftbukkit-25050e38eb02c93b32fc9b1eaf2de82992a7ff3a.tar.lz craftbukkit-25050e38eb02c93b32fc9b1eaf2de82992a7ff3a.tar.xz craftbukkit-25050e38eb02c93b32fc9b1eaf2de82992a7ff3a.zip |
Disallow people spawning invalid entities using monster eggs. Thanks to md-5 for the PR.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/ItemMonsterEgg.java | 6 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/NetServerHandler.java | 7 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/net/minecraft/server/ItemMonsterEgg.java b/src/main/java/net/minecraft/server/ItemMonsterEgg.java index c4bd8644..58bf9b7b 100644 --- a/src/main/java/net/minecraft/server/ItemMonsterEgg.java +++ b/src/main/java/net/minecraft/server/ItemMonsterEgg.java @@ -9,7 +9,7 @@ public class ItemMonsterEgg extends Item { } public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { - if (world.isStatic) { + if (world.isStatic || itemstack.getData() == 48 || itemstack.getData() == 49 || itemstack.getData() == 63) { // CraftBukkit return true; } else { i += Facing.b[l]; @@ -17,7 +17,7 @@ public class ItemMonsterEgg extends Item { k += Facing.d[l]; Entity entity = EntityTypes.a(itemstack.getData(), world); - if (entity != null) { + if (entity != null && entity instanceof EntityLiving) { // CraftBukkit if (!entityhuman.abilities.canInstantlyBuild) { --itemstack.count; } @@ -29,4 +29,4 @@ public class ItemMonsterEgg extends Item { return true; } } -} +}
\ No newline at end of file diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 24a39212..a03b9677 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -7,6 +7,8 @@ import java.util.logging.Level; import java.util.logging.Logger; // CraftBukkit start +import java.util.Arrays; +import java.util.HashSet; import org.bukkit.ChatColor; import org.bukkit.craftbukkit.ChunkCompressionThread; import org.bukkit.Location; @@ -89,6 +91,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { public CraftPlayer getPlayer() { return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity(); } + private final static HashSet<Integer> invalidItems = new HashSet<Integer>(Arrays.asList(8, 9, 10, 11, 26, 34, 36, 51, 52, 55, 59, 60, 63, 64, 68, 71, 75, 78, 83, 90, 92, 93, 94, 95)); // CraftBukkit end public void a() { @@ -1012,7 +1015,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { boolean flag = packet107setcreativeslot.a < 0; ItemStack itemstack = packet107setcreativeslot.b; boolean flag1 = packet107setcreativeslot.a >= 36 && packet107setcreativeslot.a < 36 + PlayerInventory.getHotbarSize(); - boolean flag2 = itemstack == null || itemstack.id < Item.byId.length && itemstack.id >= 0 && Item.byId[itemstack.id] != null; + boolean flag2 = itemstack == null || itemstack.id < Item.byId.length && itemstack.id >= 0 && Item.byId[itemstack.id] != null && !invalidItems.contains(itemstack.id); // CraftBukkit boolean flag3 = itemstack == null || itemstack.getData() >= 0 && itemstack.getData() >= 0 && itemstack.count <= 64 && itemstack.count > 0; if (flag1 && flag2 && flag3) { @@ -1142,4 +1145,4 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } } // CraftBukkit end -} +}
\ No newline at end of file |