Update CraftBukkit to Minecraft 1.3.1
This commit is contained in:
committed by
Travis Watkins
parent
08e2923bd4
commit
a43d621c01
@@ -1,6 +1,6 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// import java.util.Iterator; // CraftBukkit
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ContainerEnchantTable extends Container {
|
||||
private int y;
|
||||
private int z;
|
||||
private Random l = new Random();
|
||||
public long b;
|
||||
public long f;
|
||||
public int[] costs = new int[3];
|
||||
// CraftBukkit start
|
||||
private CraftInventoryView bukkitEntity = null;
|
||||
@@ -49,8 +49,9 @@ public class ContainerEnchantTable extends Container {
|
||||
for (l = 0; l < 9; ++l) {
|
||||
this.a(new Slot(playerinventory, l, 8 + l * 18, 142));
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
player = (Player) playerinventory.player.bukkitEntity;
|
||||
player = (Player) playerinventory.player.getBukkitEntity();
|
||||
enchantSlots.player = player;
|
||||
// CraftBukkit end
|
||||
}
|
||||
@@ -62,11 +63,12 @@ public class ContainerEnchantTable extends Container {
|
||||
icrafting.setContainerData(this, 2, this.costs[2]);
|
||||
}
|
||||
|
||||
public void a() {
|
||||
super.a();
|
||||
public void b() {
|
||||
super.b();
|
||||
Iterator iterator = this.listeners.iterator();
|
||||
|
||||
for (int i = 0; i < this.listeners.size(); ++i) {
|
||||
ICrafting icrafting = (ICrafting) this.listeners.get(i);
|
||||
while (iterator.hasNext()) {
|
||||
ICrafting icrafting = (ICrafting) iterator.next();
|
||||
|
||||
icrafting.setContainerData(this, 0, this.costs[0]);
|
||||
icrafting.setContainerData(this, 1, this.costs[1]);
|
||||
@@ -79,8 +81,8 @@ public class ContainerEnchantTable extends Container {
|
||||
ItemStack itemstack = iinventory.getItem(0);
|
||||
int i;
|
||||
|
||||
if (itemstack != null && itemstack.q()) {
|
||||
this.b = this.l.nextLong();
|
||||
if (itemstack != null && itemstack.u()) {
|
||||
this.f = this.l.nextLong();
|
||||
if (!this.world.isStatic) {
|
||||
i = 0;
|
||||
|
||||
@@ -134,7 +136,8 @@ public class ContainerEnchantTable extends Container {
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
||||
this.a();
|
||||
|
||||
this.b();
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < 3; ++i) {
|
||||
@@ -160,13 +163,14 @@ public class ContainerEnchantTable extends Container {
|
||||
}
|
||||
CraftItemStack item = new CraftItemStack(itemstack);
|
||||
|
||||
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);
|
||||
EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), 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 && !entityhuman.abilities.canInstantlyBuild) || enchants.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
entityhuman.levelDown(level);
|
||||
for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) {
|
||||
try {
|
||||
@@ -198,38 +202,48 @@ public class ContainerEnchantTable extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean b(EntityHuman entityhuman) {
|
||||
public boolean c(EntityHuman entityhuman) {
|
||||
if (!this.checkReachable) return true; // CraftBukkit
|
||||
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) {
|
||||
public ItemStack b(int i) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot) this.e.get(i);
|
||||
Slot slot = (Slot) this.b.get(i);
|
||||
|
||||
if (slot != null && slot.c()) {
|
||||
if (slot != null && slot.d()) {
|
||||
ItemStack itemstack1 = slot.getItem();
|
||||
|
||||
itemstack = itemstack1.cloneItemStack();
|
||||
if (i != 0) {
|
||||
return null;
|
||||
}
|
||||
if (i == 0) {
|
||||
if (!this.a(itemstack1, 1, 37, true)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (((Slot) this.b.get(0)).d() || !((Slot) this.b.get(0)).isAllowed(itemstack1)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!this.a(itemstack1, 1, 37, true)) {
|
||||
return null;
|
||||
if (itemstack1.hasTag() && itemstack1.count == 1) {
|
||||
((Slot) this.b.get(0)).set(itemstack1.cloneItemStack());
|
||||
itemstack1.count = 0;
|
||||
} else if (itemstack1.count >= 1) {
|
||||
((Slot) this.b.get(0)).set(new ItemStack(itemstack1.id, 1, itemstack1.getData()));
|
||||
--itemstack1.count;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemstack1.count == 0) {
|
||||
slot.set((ItemStack) null);
|
||||
} else {
|
||||
slot.d();
|
||||
slot.e();
|
||||
}
|
||||
|
||||
if (itemstack1.count == itemstack.count) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.c(itemstack1);
|
||||
slot.b(itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
@@ -240,6 +254,7 @@ public class ContainerEnchantTable extends Container {
|
||||
if (bukkitEntity != null) {
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
CraftInventoryEnchanting inventory = new CraftInventoryEnchanting(this.enchantSlots);
|
||||
bukkitEntity = new CraftInventoryView(this.player, inventory, this);
|
||||
return bukkitEntity;
|
||||
|
||||
Reference in New Issue
Block a user