diff options
author | Erik Broes <erikbroes@grum.nl> | 2012-02-29 22:31:04 +0100 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2012-03-01 01:12:41 +0000 |
commit | 33ba9f0a2f56bdba89574d25b44905af95480dbe (patch) | |
tree | dd446975bfd0406c3deac50c0bc1e156ca737698 /src/main/java/net/minecraft/server/ContainerEnchantTable.java | |
parent | 8524ff8ef7be2d386e98f65fdca14c0157e8309f (diff) | |
download | craftbukkit-33ba9f0a2f56bdba89574d25b44905af95480dbe.tar craftbukkit-33ba9f0a2f56bdba89574d25b44905af95480dbe.tar.gz craftbukkit-33ba9f0a2f56bdba89574d25b44905af95480dbe.tar.lz craftbukkit-33ba9f0a2f56bdba89574d25b44905af95480dbe.tar.xz craftbukkit-33ba9f0a2f56bdba89574d25b44905af95480dbe.zip |
Updated to rename revision 02
Diffstat (limited to 'src/main/java/net/minecraft/server/ContainerEnchantTable.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ContainerEnchantTable.java | 110 |
1 files changed, 56 insertions, 54 deletions
diff --git a/src/main/java/net/minecraft/server/ContainerEnchantTable.java b/src/main/java/net/minecraft/server/ContainerEnchantTable.java index 3acf5065..83c3fc1a 100644 --- a/src/main/java/net/minecraft/server/ContainerEnchantTable.java +++ b/src/main/java/net/minecraft/server/ContainerEnchantTable.java @@ -19,26 +19,26 @@ import org.bukkit.entity.Player; public class ContainerEnchantTable extends Container { // CraftBukkit start - make type specific (changed from IInventory) - public ContainerEnchantTableInventory a = new ContainerEnchantTableInventory(this, "Enchant", 1); + public ContainerEnchantTableInventory enchantSlots = new ContainerEnchantTableInventory(this, "Enchant", 1); // CraftBukkit end - private World h; - private int i; - private int j; - private int k; + private World world; + private int x; + private int y; + private int z; private Random l = new Random(); public long b; - public int[] c = new int[3]; + public int[] costs = new int[3]; // CraftBukkit start private CraftInventoryView bukkitEntity = null; private Player player; // CraftBukkit end public ContainerEnchantTable(PlayerInventory playerinventory, World world, int i, int j, int k) { - this.h = world; - this.i = i; - this.j = j; - this.k = k; - this.a((Slot) (new SlotEnchant(this, this.a, 0, 25, 47))); + this.world = world; + this.x = i; + this.y = j; + this.z = k; + this.a((Slot) (new SlotEnchant(this, this.enchantSlots, 0, 25, 47))); int l; @@ -51,14 +51,14 @@ public class ContainerEnchantTable extends Container { for (l = 0; l < 9; ++l) { this.a(new Slot(playerinventory, l, 8 + l * 18, 142)); } - player = (Player) playerinventory.d.getBukkitEntity(); // CraftBukkit + player = (Player) playerinventory.player.bukkitEntity; // CraftBukkit } - public void a(ICrafting icrafting) { - super.a(icrafting); - icrafting.a(this, 0, this.c[0]); - icrafting.a(this, 1, this.c[1]); - icrafting.a(this, 2, this.c[2]); + public void addSlotListener(ICrafting icrafting) { + super.addSlotListener(icrafting); + icrafting.setContainerData(this, 0, this.costs[0]); + icrafting.setContainerData(this, 1, this.costs[1]); + icrafting.setContainerData(this, 2, this.costs[2]); } public void a() { @@ -67,49 +67,49 @@ public class ContainerEnchantTable extends Container { for (int i = 0; i < this.listeners.size(); ++i) { ICrafting icrafting = (ICrafting) this.listeners.get(i); - icrafting.a(this, 0, this.c[0]); - icrafting.a(this, 1, this.c[1]); - icrafting.a(this, 2, this.c[2]); + icrafting.setContainerData(this, 0, this.costs[0]); + icrafting.setContainerData(this, 1, this.costs[1]); + icrafting.setContainerData(this, 2, this.costs[2]); } } public void a(IInventory iinventory) { - if (iinventory == this.a) { + if (iinventory == this.enchantSlots) { ItemStack itemstack = iinventory.getItem(0); int i; if (itemstack != null && itemstack.q()) { this.b = this.l.nextLong(); - if (!this.h.isStatic) { + if (!this.world.isStatic) { i = 0; int j; for (j = -1; j <= 1; ++j) { for (int k = -1; k <= 1; ++k) { - if ((j != 0 || k != 0) && this.h.isEmpty(this.i + k, this.j, this.k + j) && this.h.isEmpty(this.i + k, this.j + 1, this.k + j)) { - if (this.h.getTypeId(this.i + k * 2, this.j, this.k + j * 2) == Block.BOOKSHELF.id) { + if ((j != 0 || k != 0) && this.world.isEmpty(this.x + k, this.y, this.z + j) && this.world.isEmpty(this.x + k, this.y + 1, this.z + j)) { + if (this.world.getTypeId(this.x + k * 2, this.y, this.z + j * 2) == Block.BOOKSHELF.id) { ++i; } - if (this.h.getTypeId(this.i + k * 2, this.j + 1, this.k + j * 2) == Block.BOOKSHELF.id) { + if (this.world.getTypeId(this.x + k * 2, this.y + 1, this.z + j * 2) == Block.BOOKSHELF.id) { ++i; } if (k != 0 && j != 0) { - if (this.h.getTypeId(this.i + k * 2, this.j, this.k + j) == Block.BOOKSHELF.id) { + if (this.world.getTypeId(this.x + k * 2, this.y, this.z + j) == Block.BOOKSHELF.id) { ++i; } - if (this.h.getTypeId(this.i + k * 2, this.j + 1, this.k + j) == Block.BOOKSHELF.id) { + if (this.world.getTypeId(this.x + k * 2, this.y + 1, this.z + j) == Block.BOOKSHELF.id) { ++i; } - if (this.h.getTypeId(this.i + k, this.j, this.k + j * 2) == Block.BOOKSHELF.id) { + if (this.world.getTypeId(this.x + k, this.y, this.z + j * 2) == Block.BOOKSHELF.id) { ++i; } - if (this.h.getTypeId(this.i + k, this.j + 1, this.k + j * 2) == Block.BOOKSHELF.id) { + if (this.world.getTypeId(this.x + k, this.y + 1, this.z + j * 2) == Block.BOOKSHELF.id) { ++i; } } @@ -118,16 +118,17 @@ public class ContainerEnchantTable extends Container { } for (j = 0; j < 3; ++j) { - this.c[j] = EnchantmentManager.a(this.l, j, i, itemstack); + this.costs[j] = EnchantmentManager.a(this.l, j, i, itemstack); } // CraftBukkit start CraftItemStack item = new CraftItemStack(itemstack); - PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), h.getWorld().getBlockAt(this.i, this.j, this.k), item, this.c, i); - h.getServer().getPluginManager().callEvent(event); + PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), this.world.getWorld().getBlockAt(this.x, this.y, this.z), item, this.costs, i); + this.world.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { for (i = 0; i < 3; ++i) { - this.c[i] = 0; + this.costs[i] = 0; } return; } @@ -136,28 +137,29 @@ public class ContainerEnchantTable extends Container { } } else { for (i = 0; i < 3; ++i) { - this.c[i] = 0; + this.costs[i] = 0; } } } } public boolean a(EntityHuman entityhuman, int i) { - ItemStack itemstack = this.a.getItem(0); + ItemStack itemstack = this.enchantSlots.getItem(0); - if (this.c[i] > 0 && itemstack != null && entityhuman.expLevel >= this.c[i]) { - if (!this.h.isStatic) { - List list = EnchantmentManager.a(this.l, itemstack, this.c[i]); + if (this.costs[i] > 0 && itemstack != null && entityhuman.expLevel >= this.costs[i]) { + if (!this.world.isStatic) { + List list = EnchantmentManager.a(this.l, itemstack, this.costs[i]); // CraftBukkit start Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new HashMap<org.bukkit.enchantments.Enchantment, Integer>(); - for (Object o : list) { - EnchantmentInstance e = (EnchantmentInstance) o; - enchants.put(org.bukkit.enchantments.Enchantment.getById(e.a.id), e.b); + for (Object obj : list) { + EnchantmentInstance instance = (EnchantmentInstance) obj; + enchants.put(org.bukkit.enchantments.Enchantment.getById(instance.enchantment.id), instance.level); } CraftItemStack item = new CraftItemStack(itemstack); - EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.bukkitEntity, this.getBukkitView(), h.getWorld().getBlockAt(this.i, this.j, this.k), item, this.c[i], enchants, i); - h.getServer().getPluginManager().callEvent(event); + + EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.bukkitEntity, this.getBukkitView(), this.world.getWorld().getBlockAt(this.x, this.y, this.z), item, this.costs[i], enchants, i); + this.world.getServer().getPluginManager().callEvent(event); int level = event.getExpLevelCost(); if (event.isCancelled() || (level > entityhuman.expLevel)) { @@ -165,16 +167,16 @@ public class ContainerEnchantTable extends Container { } if (enchants.isEmpty() == false) { entityhuman.levelDown(level); - for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> ent : event.getEnchantsToAdd().entrySet()) { + for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) { try { - item.addEnchantment(ent.getKey(), ent.getValue()); - } catch (IllegalArgumentException iax) { + item.addEnchantment(entry.getKey(), entry.getValue()); + } catch (IllegalArgumentException e) { /* Just swallow invalid enchantments */ } + // CraftBukkit end } - // CraftBukkit end - this.a(this.a); + this.a(this.enchantSlots); } } @@ -186,18 +188,18 @@ public class ContainerEnchantTable extends Container { public void a(EntityHuman entityhuman) { super.a(entityhuman); - if (!this.h.isStatic) { - ItemStack itemstack = this.a.getItem(0); + if (!this.world.isStatic) { + ItemStack itemstack = this.enchantSlots.getItem(0); if (itemstack != null) { - entityhuman.b(itemstack); + entityhuman.drop(itemstack); } } } public boolean b(EntityHuman entityhuman) { if (!this.checkReachable) return true; // CraftBukkit - return this.h.getTypeId(this.i, this.j, this.k) != Block.ENCHANTMENT_TABLE.id ? false : entityhuman.e((double) this.i + 0.5D, (double) this.j + 0.5D, (double) this.k + 0.5D) <= 64.0D; + return this.world.getTypeId(this.x, this.y, this.z) != Block.ENCHANTMENT_TABLE.id ? false : entityhuman.e((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D) <= 64.0D; } public ItemStack a(int i) { @@ -217,7 +219,7 @@ public class ContainerEnchantTable extends Container { } if (itemstack1.count == 0) { - slot.c((ItemStack) null); + slot.set((ItemStack) null); } else { slot.d(); } @@ -237,7 +239,7 @@ public class ContainerEnchantTable extends Container { if (bukkitEntity != null) { return bukkitEntity; } - CraftInventoryEnchanting inventory = new CraftInventoryEnchanting(this.a); + CraftInventoryEnchanting inventory = new CraftInventoryEnchanting(this.enchantSlots); bukkitEntity = new CraftInventoryView(this.player, inventory, this); return bukkitEntity; } |