mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-20 06:43:49 -07:00
@@ -1,11 +1,12 @@
|
||||
--- a/net/minecraft/server/ContainerEnchantTable.java
|
||||
+++ b/net/minecraft/server/ContainerEnchantTable.java
|
||||
@@ -3,9 +3,21 @@
|
||||
@@ -3,9 +3,22 @@
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.Map;
|
||||
+import org.bukkit.Location;
|
||||
+
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
@@ -23,10 +24,22 @@
|
||||
public int getMaxStackSize() {
|
||||
return 64;
|
||||
}
|
||||
@@ -21,6 +33,10 @@
|
||||
public int f;
|
||||
@@ -14,6 +27,11 @@
|
||||
super.update();
|
||||
ContainerEnchantTable.this.a((IInventory) this);
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ());
|
||||
+ }
|
||||
};
|
||||
private World world;
|
||||
private BlockPosition position;
|
||||
@@ -22,6 +40,10 @@
|
||||
public int[] costs = new int[3];
|
||||
public int[] h = new int[] { -1, -1, -1};
|
||||
public int[] i = new int[] { -1, -1, -1};
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
@@ -34,7 +47,7 @@
|
||||
|
||||
public ContainerEnchantTable(PlayerInventory playerinventory, World world, BlockPosition blockposition) {
|
||||
this.world = world;
|
||||
@@ -53,6 +69,9 @@
|
||||
@@ -54,6 +76,9 @@
|
||||
this.a(new Slot(playerinventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
|
||||
@@ -43,8 +56,8 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void addSlotListener(ICrafting icrafting) {
|
||||
@@ -88,7 +107,7 @@
|
||||
protected void c(ICrafting icrafting) {
|
||||
@@ -90,7 +115,7 @@
|
||||
ItemStack itemstack = iinventory.getItem(0);
|
||||
int i;
|
||||
|
||||
@@ -53,7 +66,7 @@
|
||||
if (!this.world.isClientSide) {
|
||||
i = 0;
|
||||
|
||||
@@ -136,6 +155,20 @@
|
||||
@@ -139,6 +164,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +87,7 @@
|
||||
for (j = 0; j < 3; ++j) {
|
||||
if (this.costs[j] > 0) {
|
||||
List list = this.a(itemstack, j, this.costs[j]);
|
||||
@@ -170,24 +203,55 @@
|
||||
@@ -175,24 +214,55 @@
|
||||
} else if (this.costs[i] > 0 && itemstack != null && (entityhuman.expLevel >= j && entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) {
|
||||
if (!this.world.isClientSide) {
|
||||
List list = this.a(itemstack, i, this.costs[i]);
|
||||
@@ -91,7 +104,7 @@
|
||||
+ Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
|
||||
+ for (Object obj : list) {
|
||||
+ WeightedRandomEnchant instance = (WeightedRandomEnchant) obj;
|
||||
+ enchants.put(org.bukkit.enchantments.Enchantment.getById(instance.enchantment.id), instance.level);
|
||||
+ enchants.put(org.bukkit.enchantments.Enchantment.getById(Enchantment.getId(instance.enchantment)), instance.level);
|
||||
+ }
|
||||
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
@@ -112,7 +125,7 @@
|
||||
+ try {
|
||||
+ if (flag) {
|
||||
+ int enchantId = entry.getKey().getId();
|
||||
+ if (Enchantment.getById(enchantId) == null) {
|
||||
+ if (Enchantment.c(enchantId) == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
|
||||
@@ -120,8 +133,8 @@
|
||||
- Items.ENCHANTED_BOOK.a(itemstack, weightedrandomenchant);
|
||||
- } else {
|
||||
- itemstack.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level);
|
||||
+ WeightedRandomEnchant enchantment = new WeightedRandomEnchant(Enchantment.getById(enchantId), entry.getValue());
|
||||
+ Items.ENCHANTED_BOOK.a(itemstack, enchantment);
|
||||
+ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(Enchantment.c(enchantId), entry.getValue());
|
||||
+ Items.ENCHANTED_BOOK.a(itemstack, weightedrandomenchant);
|
||||
+ } else {
|
||||
+ item.addUnsafeEnchantment(entry.getKey(), entry.getValue());
|
||||
+ }
|
||||
@@ -137,7 +150,7 @@
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack1.count -= j;
|
||||
if (itemstack1.count <= 0) {
|
||||
@@ -221,6 +285,11 @@
|
||||
@@ -226,6 +296,11 @@
|
||||
|
||||
public void b(EntityHuman entityhuman) {
|
||||
super.b(entityhuman);
|
||||
@@ -149,7 +162,7 @@
|
||||
if (!this.world.isClientSide) {
|
||||
for (int i = 0; i < this.enchantSlots.getSize(); ++i) {
|
||||
ItemStack itemstack = this.enchantSlots.splitWithoutUpdate(i);
|
||||
@@ -234,6 +303,7 @@
|
||||
@@ -239,6 +314,7 @@
|
||||
}
|
||||
|
||||
public boolean a(EntityHuman entityhuman) {
|
||||
@@ -157,7 +170,7 @@
|
||||
return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.e((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@@ -286,4 +356,17 @@
|
||||
@@ -291,4 +367,17 @@
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
Reference in New Issue
Block a user