Update to Minecraft 1.18-pre5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-11-22 09:00:00 +11:00
parent a852b81a69
commit 43702a9e10
700 changed files with 10286 additions and 10098 deletions

View File

@@ -48,21 +48,21 @@
+
protected Container(@Nullable Containers<?> containers, int i) {
this.carried = ItemStack.EMPTY;
this.remoteSlots = NonNullList.a();
this.remoteSlots = NonNullList.create();
@@ -156,6 +191,15 @@
}
+ // CraftBukkit start
+ public void broadcastCarriedItem() {
+ this.remoteCarried = this.getCarried().cloneItemStack();
+ this.remoteCarried = this.getCarried().copy();
+ if (this.synchronizer != null) {
+ this.synchronizer.sendCarriedChange(this, this.remoteCarried);
+ }
+ }
+ // CraftBukkit end
+
public void b(ICrafting icrafting) {
public void removeSlotListener(ICrafting icrafting) {
this.containerListeners.remove(icrafting);
}
@@ -370,7 +414,7 @@
@@ -72,8 +72,8 @@
- if (this.quickcraftSlots.size() == 1) {
+ if (false && this.quickcraftSlots.size() == 1) { // CraftBukkit - treat everything as a drag since we are unable to easily call InventoryClickEvent instead
k = ((Slot) this.quickcraftSlots.iterator().next()).index;
this.f();
this.b(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman);
this.resetQuickCraft();
this.doClick(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman);
@@ -381,6 +425,7 @@
l = this.getCarried().getCount();
Iterator iterator = this.quickcraftSlots.iterator();
@@ -128,12 +128,12 @@
+ }
+
+ if (needsUpdate && entityhuman instanceof EntityPlayer) {
+ this.updateInventory();
+ this.sendAllDataToRemote();
+ }
+ // CraftBukkit end
}
this.f();
this.resetQuickCraft();
@@ -420,8 +501,11 @@
if (i == -999) {
if (!this.getCarried().isEmpty()) {
@@ -145,18 +145,18 @@
+ entityhuman.drop(carried, true);
+ // CraftBukkit start
} else {
entityhuman.drop(this.getCarried().cloneAndSubtract(1), true);
entityhuman.drop(this.getCarried().split(1), true);
}
@@ -484,6 +568,15 @@
}
slot.d();
slot.setChanged();
+ // CraftBukkit start - Make sure the client has the right slot contents
+ if (entityhuman instanceof EntityPlayer && slot.getMaxStackSize() != 64) {
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), slot.index, slot.getItem()));
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), slot.index, slot.getItem()));
+ // Updating a crafting inventory makes the client reset the result slot, have to send it again
+ if (this.getBukkitView().getType() == InventoryType.WORKBENCH || this.getBukkitView().getType() == InventoryType.CRAFTING) {
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem()));
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem()));
+ }
+ }
+ // CraftBukkit end
@@ -168,8 +168,8 @@
if (!itemstack.isEmpty()) {
+ this.setCarried(ItemStack.EMPTY); // CraftBukkit - SPIGOT-4556 - from below
if (entityhuman.isAlive() && !((EntityPlayer) entityhuman).q()) {
entityhuman.getInventory().f(itemstack);
if (entityhuman.isAlive() && !((EntityPlayer) entityhuman).hasDisconnected()) {
entityhuman.getInventory().placeItemBackInInventory(itemstack);
} else {
entityhuman.drop(itemstack, false);
}

View File

@@ -20,10 +20,10 @@
+
ContainerAccess NULL = new ContainerAccess() {
@Override
public <T> Optional<T> a(BiFunction<World, BlockPosition, T> bifunction) {
public <T> Optional<T> evaluate(BiFunction<World, BlockPosition, T> bifunction) {
@@ -17,6 +31,18 @@
static ContainerAccess at(final World world, final BlockPosition blockposition) {
static ContainerAccess create(final World world, final BlockPosition blockposition) {
return new ContainerAccess() {
+ // CraftBukkit start
+ @Override
@@ -38,5 +38,5 @@
+ // CraftBukkit end
+
@Override
public <T> Optional<T> a(BiFunction<World, BlockPosition, T> bifunction) {
public <T> Optional<T> evaluate(BiFunction<World, BlockPosition, T> bifunction) {
return Optional.of(bifunction.apply(world, blockposition));

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerAnvil.java
+++ b/net/minecraft/world/inventory/ContainerAnvil.java
@@ -19,6 +19,10 @@
@@ -18,6 +18,10 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -11,7 +11,7 @@
public class ContainerAnvil extends ContainerAnvilAbstract {
private static final Logger LOGGER = LogManager.getLogger();
@@ -34,6 +38,10 @@
@@ -33,6 +37,10 @@
private static final int COST_REPAIR_SACRIFICE = 2;
private static final int COST_INCOMPATIBLE_PENALTY = 1;
private static final int COST_RENAME = 1;
@@ -22,7 +22,7 @@
public ContainerAnvil(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -106,7 +114,7 @@
@@ -105,7 +113,7 @@
byte b1 = 0;
if (itemstack.isEmpty()) {
@@ -30,26 +30,26 @@
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
this.cost.set(0);
} else {
ItemStack itemstack1 = itemstack.cloneItemStack();
@@ -124,7 +132,7 @@
if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) {
k = Math.min(itemstack1.getDamage(), itemstack1.i() / 4);
ItemStack itemstack1 = itemstack.copy();
@@ -123,7 +131,7 @@
if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) {
k = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4);
if (k <= 0) {
- this.resultSlots.setItem(0, ItemStack.EMPTY);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
this.cost.set(0);
return;
}
@@ -139,7 +147,7 @@
@@ -138,7 +146,7 @@
this.repairItemCountCost = i1;
} else {
if (!flag && (!itemstack1.a(itemstack2.getItem()) || !itemstack1.f())) {
if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) {
- this.resultSlots.setItem(0, ItemStack.EMPTY);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
this.cost.set(0);
return;
}
@@ -229,7 +237,7 @@
@@ -228,7 +236,7 @@
}
if (flag2 && !flag1) {
@@ -58,7 +58,7 @@
this.cost.set(0);
return;
}
@@ -253,11 +261,11 @@
@@ -252,11 +260,11 @@
itemstack1 = ItemStack.EMPTY;
}
@@ -73,18 +73,18 @@
itemstack1 = ItemStack.EMPTY;
}
@@ -276,7 +284,8 @@
EnchantmentManager.a(map, itemstack1);
@@ -275,7 +283,8 @@
EnchantmentManager.setEnchantments(map, itemstack1);
}
- this.resultSlots.setItem(0, itemstack1);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit
+ updateInventory(); // CraftBukkit - SPIGOT-6686: Always send completed inventory to stay in sync with client
this.d();
+ sendAllDataToRemote(); // CraftBukkit - SPIGOT-6686: Always send completed inventory to stay in sync with client
this.broadcastChanges();
}
}
@@ -303,4 +312,18 @@
public int m() {
@@ -302,4 +311,18 @@
public int getCost() {
return this.cost.get();
}
+

View File

@@ -3,8 +3,8 @@
@@ -92,6 +92,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return (Boolean) this.access.a((world, blockposition) -> {
return !this.a(world.getType(blockposition)) ? false : entityhuman.h((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D;
return (Boolean) this.access.evaluate((world, blockposition) -> {
return !this.isValidBlock(world.getBlockState(blockposition)) ? false : entityhuman.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D;
}, true);

View File

@@ -30,13 +30,13 @@
+ player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this
this.beacon = new InventorySubcontainer(1) {
@Override
public boolean b(int j, ItemStack itemstack) {
public boolean canPlaceItem(int j, ItemStack itemstack) {
@@ -79,6 +89,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.access, entityhuman, Blocks.BEACON);
return stillValid(this.access, entityhuman, Blocks.BEACON);
}
@@ -178,4 +189,17 @@

View File

@@ -28,15 +28,15 @@
public ContainerBrewingStand(int i, PlayerInventory playerinventory, IInventory iinventory, IContainerProperties icontainerproperties) {
super(Containers.BREWING_STAND, i);
+ player = playerinventory; // CraftBukkit
a(iinventory, 5);
a(icontainerproperties, 2);
checkContainerSize(iinventory, 5);
checkContainerDataCount(icontainerproperties, 2);
this.brewingStand = iinventory;
@@ -61,6 +72,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.brewingStand.a(entityhuman);
return this.brewingStand.stillValid(entityhuman);
}
@@ -198,4 +210,17 @@

View File

@@ -32,8 +32,8 @@
public static final int ADDITIONAL_SLOT = 1;
public static final int RESULT_SLOT = 2;
@@ -38,6 +60,13 @@
ContainerCartography.this.a((IInventory) this);
super.update();
ContainerCartography.this.slotsChanged(this);
super.setChanged();
}
+
+ // CraftBukkit start
@@ -46,8 +46,8 @@
this.resultContainer = new InventoryCraftResult() {
@Override
@@ -45,6 +74,13 @@
ContainerCartography.this.a((IInventory) this);
super.update();
ContainerCartography.this.slotsChanged(this);
super.setChanged();
}
+
+ // CraftBukkit start
@@ -58,17 +58,17 @@
+ // CraftBukkit end
};
this.access = containeraccess;
this.a(new Slot(this.container, 0, 15, 15) {
this.addSlot(new Slot(this.container, 0, 15, 15) {
@@ -95,10 +131,12 @@
this.a(new Slot(playerinventory, j, 8 + j * 18, 142));
this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142));
}
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.access, entityhuman, Blocks.CARTOGRAPHY_TABLE);
return stillValid(this.access, entityhuman, Blocks.CARTOGRAPHY_TABLE);
}

View File

@@ -55,8 +55,8 @@
@@ -79,6 +112,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.container.a(entityhuman);
return this.container.stillValid(entityhuman);
}

View File

@@ -31,20 +31,20 @@
+ this.player = playerinventory;
+ // CraftBukkit end
+
a(iinventory, 9);
checkContainerSize(iinventory, 9);
this.dispenser = iinventory;
iinventory.startOpen(playerinventory.player);
@@ -48,6 +61,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.dispenser.a(entityhuman);
return this.dispenser.stillValid(entityhuman);
}
@@ -89,4 +103,17 @@
super.b(entityhuman);
this.dispenser.closeContainer(entityhuman);
super.removed(entityhuman);
this.dispenser.stopOpen(entityhuman);
}
+
+ // CraftBukkit start

View File

@@ -34,8 +34,8 @@
public ContainerEnchantTable(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -42,6 +61,13 @@
super.update();
ContainerEnchantTable.this.a((IInventory) this);
super.setChanged();
ContainerEnchantTable.this.slotsChanged(this);
}
+
+ // CraftBukkit start
@@ -46,11 +46,11 @@
+ // CraftBukkit end
};
this.random = new Random();
this.enchantmentSeed = ContainerProperty.a();
this.enchantmentSeed = ContainerProperty.standalone();
@@ -89,6 +115,9 @@
this.a(ContainerProperty.a(this.levelClue, 0));
this.a(ContainerProperty.a(this.levelClue, 1));
this.a(ContainerProperty.a(this.levelClue, 2));
this.addDataSlot(ContainerProperty.shared(this.levelClue, 0));
this.addDataSlot(ContainerProperty.shared(this.levelClue, 1));
this.addDataSlot(ContainerProperty.shared(this.levelClue, 2));
+ // CraftBukkit start
+ player = (Player) playerinventory.player.getBukkitEntity();
+ // CraftBukkit end
@@ -61,9 +61,9 @@
if (iinventory == this.enchantSlots) {
ItemStack itemstack = iinventory.getItem(0);
- if (!itemstack.isEmpty() && itemstack.canEnchant()) {
- if (!itemstack.isEmpty() && itemstack.isEnchantable()) {
+ if (!itemstack.isEmpty()) { // CraftBukkit - relax condition
this.access.a((world, blockposition) -> {
this.access.execute((world, blockposition) -> {
int i = 0;
@@ -158,6 +187,41 @@
@@ -74,12 +74,12 @@
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
+ org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3];
+ for (j = 0; j < 3; ++j) {
+ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(IRegistry.ENCHANTMENT.fromId(this.enchantClue[j])))) : null;
+ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(IRegistry.ENCHANTMENT.byId(this.enchantClue[j])))) : null;
+ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levelClue[j], this.costs[j]) : null;
+ }
+
+ PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), access.getLocation().getBlock(), item, offers, i);
+ event.setCancelled(!itemstack.canEnchant());
+ event.setCancelled(!itemstack.isEnchantable());
+ world.getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
@@ -105,19 +105,19 @@
+ }
+ // CraftBukkit end
+
this.d();
this.broadcastChanges();
});
} else {
@@ -184,9 +248,24 @@
ItemStack itemstack2 = itemstack;
List<WeightedRandomEnchant> list = this.a(itemstack, i, this.costs[i]);
List<WeightedRandomEnchant> list = this.getEnchantmentList(itemstack, i, this.costs[i]);
- if (!list.isEmpty()) {
- entityhuman.enchantDone(itemstack, j);
- entityhuman.onEnchantmentPerformed(itemstack, j);
+ // CraftBukkit start
+ if (true || !list.isEmpty()) {
+ // entityhuman.enchantDone(itemstack, j); // Moved down
boolean flag = itemstack.a(Items.BOOK);
+ // entityhuman.onEnchantmentPerformed(itemstack, j); // Moved down
boolean flag = itemstack.is(Items.BOOK);
+ Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
+ for (Object obj : list) {
+ WeightedRandomEnchant instance = (WeightedRandomEnchant) obj;
@@ -151,11 +151,11 @@
+ }
- if (flag) {
- ItemEnchantedBook.a(itemstack2, weightedrandomenchant);
- ItemEnchantedBook.addEnchantment(itemstack2, weightedrandomenchant);
- } else {
- itemstack2.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level);
- itemstack2.enchant(weightedrandomenchant.enchantment, weightedrandomenchant.level);
+ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue());
+ ItemEnchantedBook.a(itemstack2, weightedrandomenchant);
+ ItemEnchantedBook.addEnchantment(itemstack2, weightedrandomenchant);
+ } else {
+ item.addUnsafeEnchantment(entry.getKey(), entry.getValue());
+ }
@@ -164,19 +164,19 @@
}
}
+ entityhuman.enchantDone(itemstack, j);
+ entityhuman.onEnchantmentPerformed(itemstack, j);
+ // CraftBukkit end
+
+ // CraftBukkit - TODO: let plugins change this
if (!entityhuman.getAbilities().instabuild) {
itemstack1.subtract(j);
itemstack1.shrink(j);
if (itemstack1.isEmpty()) {
@@ -265,6 +357,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.access, entityhuman, Blocks.ENCHANTING_TABLE);
return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE);
}
@@ -316,4 +409,17 @@

View File

@@ -36,9 +36,9 @@
this(containers, recipes, recipebooktype, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4));
}
@@ -45,6 +66,7 @@
this.a(new Slot(iinventory, 0, 56, 17));
this.a((Slot) (new SlotFurnaceFuel(this, iinventory, 1, 56, 53)));
this.a((Slot) (new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35)));
this.addSlot(new Slot(iinventory, 0, 56, 17));
this.addSlot(new SlotFurnaceFuel(this, iinventory, 1, 56, 53));
this.addSlot(new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35));
+ this.player = playerinventory; // CraftBukkit - save player
int j;
@@ -46,17 +46,17 @@
@@ -102,6 +124,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.container.a(entityhuman);
return this.container.stillValid(entityhuman);
}
@@ -157,7 +180,7 @@
}
protected boolean c(ItemStack itemstack) {
- return this.level.getCraftingManager().craft(this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent();
+ return this.level.getCraftingManager().craft((Recipes<RecipeCooking>) this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent(); // Eclipse fail
protected boolean canSmelt(ItemStack itemstack) {
- return this.level.getRecipeManager().getRecipeFor(this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent();
+ return this.level.getRecipeManager().getRecipeFor((Recipes<RecipeCooking>) this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent(); // Eclipse fail
}
protected boolean d(ItemStack itemstack) {
protected boolean isFuel(ItemStack itemstack) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerGrindstone.java
+++ b/net/minecraft/world/inventory/ContainerGrindstone.java
@@ -20,8 +20,30 @@
@@ -19,8 +19,30 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.Vec3D;
@@ -31,9 +31,9 @@
public static final int MAX_NAME_LENGTH = 35;
public static final int INPUT_SLOT = 0;
public static final int ADDITIONAL_SLOT = 1;
@@ -47,6 +69,13 @@
super.update();
ContainerGrindstone.this.a((IInventory) this);
@@ -46,6 +68,13 @@
super.setChanged();
ContainerGrindstone.this.slotsChanged(this);
}
+
+ // CraftBukkit start
@@ -44,20 +44,20 @@
+ // CraftBukkit end
};
this.access = containeraccess;
this.a(new Slot(this.repairSlots, 0, 49, 19) {
@@ -125,6 +154,7 @@
this.a(new Slot(playerinventory, j, 8 + j * 18, 142));
this.addSlot(new Slot(this.repairSlots, 0, 49, 19) {
@@ -124,6 +153,7 @@
this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142));
}
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
@Override
@@ -252,6 +282,7 @@
@@ -251,6 +281,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.access, entityhuman, Blocks.GRINDSTONE);
return stillValid(this.access, entityhuman, Blocks.GRINDSTONE);
}

View File

@@ -38,14 +38,14 @@
super(Containers.HOPPER, i);
this.hopper = iinventory;
+ this.player = playerinventory; // CraftBukkit - save player
a(iinventory, 5);
checkContainerSize(iinventory, 5);
iinventory.startOpen(playerinventory.player);
boolean flag = true;
@@ -42,6 +64,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.hopper.a(entityhuman);
return this.hopper.stillValid(entityhuman);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerHorse.java
+++ b/net/minecraft/world/inventory/ContainerHorse.java
@@ -9,13 +9,33 @@
@@ -8,13 +8,33 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;

View File

@@ -49,12 +49,12 @@
+ public ContainerLectern(int i, IInventory iinventory, IContainerProperties icontainerproperties, PlayerInventory playerinventory) {
+ // CraftBukkit end
super(Containers.LECTERN, i);
a(iinventory, 1);
a(icontainerproperties, 1);
checkContainerSize(iinventory, 1);
checkContainerDataCount(icontainerproperties, 1);
@@ -34,6 +61,7 @@
}
});
this.a(icontainerproperties);
this.addDataSlots(icontainerproperties);
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
@@ -70,15 +70,15 @@
+ return false;
+ }
+ // CraftBukkit end
ItemStack itemstack = this.lectern.splitWithoutUpdate(0);
ItemStack itemstack = this.lectern.removeItemNoUpdate(0);
this.lectern.update();
this.lectern.setChanged();
@@ -81,6 +116,8 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (lectern instanceof LecternInventory && !((LecternInventory) lectern).getLectern().hasBook()) return false; // CraftBukkit
+ if (!this.checkReachable) return true; // CraftBukkit
return this.lectern.a(entityhuman);
return this.lectern.stillValid(entityhuman);
}

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/inventory/ContainerLoom.java
+++ b/net/minecraft/world/inventory/ContainerLoom.java
@@ -16,8 +16,30 @@
import net.minecraft.world.level.block.Blocks;
@@ -18,8 +18,30 @@
import net.minecraft.world.level.block.entity.EnumBannerPatternType;
import net.minecraft.world.level.block.entity.TileEntityTypes;
+// CraftBukkit start
+import org.bukkit.Location;
@@ -31,8 +31,8 @@
private static final int INV_SLOT_START = 4;
private static final int INV_SLOT_END = 31;
private static final int USE_ROW_SLOT_START = 31;
@@ -49,6 +71,13 @@
ContainerLoom.this.a((IInventory) this);
@@ -51,6 +73,13 @@
ContainerLoom.this.slotsChanged(this);
ContainerLoom.this.slotUpdateListener.run();
}
+
@@ -45,8 +45,8 @@
};
this.outputContainer = new InventorySubcontainer(1) {
@Override
@@ -56,6 +85,13 @@
super.update();
@@ -58,6 +87,13 @@
super.setChanged();
ContainerLoom.this.slotUpdateListener.run();
}
+
@@ -58,26 +58,26 @@
+ // CraftBukkit end
};
this.access = containeraccess;
this.bannerSlot = this.a(new Slot(this.inputContainer, 0, 13, 26) {
@@ -116,6 +152,7 @@
this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) {
@@ -118,6 +154,7 @@
}
this.a(this.selectedBannerPatternIndex);
this.addDataSlot(this.selectedBannerPatternIndex);
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
public int l() {
@@ -124,6 +161,7 @@
public int getSelectedBannerPatternIndex() {
@@ -126,6 +163,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.access, entityhuman, Blocks.LOOM);
return stillValid(this.access, entityhuman, Blocks.LOOM);
}
@@ -246,6 +284,11 @@
@@ -248,6 +286,11 @@
if (nbttagcompound.hasKeyOfType("Patterns", 9)) {
if (nbttagcompound != null && nbttagcompound.contains("Patterns", 9)) {
nbttaglist = nbttagcompound.getList("Patterns", 10);
+ // CraftBukkit start
+ while (nbttaglist.size() > 20) {
@@ -86,4 +86,4 @@
+ // CraftBukkit end
} else {
nbttaglist = new NBTTagList();
nbttagcompound.set("Patterns", nbttaglist);
if (nbttagcompound == null) {

View File

@@ -30,9 +30,9 @@
this(i, playerinventory, new MerchantWrapper(playerinventory.player));
}
@@ -42,6 +57,7 @@
this.a(new Slot(this.tradeContainer, 0, 136, 37));
this.a(new Slot(this.tradeContainer, 1, 162, 37));
this.a((Slot) (new SlotMerchantResult(playerinventory.player, imerchant, this.tradeContainer, 2, 220, 37)));
this.addSlot(new Slot(this.tradeContainer, 0, 136, 37));
this.addSlot(new Slot(this.tradeContainer, 1, 162, 37));
this.addSlot(new SlotMerchantResult(playerinventory.player, imerchant, this.tradeContainer, 2, 220, 37));
+ this.player = playerinventory; // CraftBukkit - save player
int j;
@@ -40,9 +40,9 @@
@@ -154,7 +170,7 @@
}
private void r() {
- if (!this.trader.getWorld().isClientSide) {
+ if (!this.trader.getWorld().isClientSide && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035
private void playTradeSound() {
- if (!this.trader.isClientSide()) {
+ if (!this.trader.isClientSide() && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035
Entity entity = (Entity) this.trader;
this.trader.getWorld().a(entity.locX(), entity.locY(), entity.locZ(), this.trader.getTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false);
entity.getLevel().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), this.trader.getNotifyTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false);

View File

@@ -41,12 +41,12 @@
+ this.player = playerinventory; // CraftBukkit - save player
+ setTitle(new ChatMessage("container.crafting")); // SPIGOT-4722: Allocate title for player inventory
+ // CraftBukkit end
this.a((Slot) (new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28)));
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28));
int i;
@@ -242,4 +261,17 @@
public boolean d(int i) {
return i != this.m();
public boolean shouldMoveToInventory(int i) {
return i != this.getResultSlotIndex();
}
+
+ // CraftBukkit start

View File

@@ -32,7 +32,7 @@
this(i, playerinventory, new InventorySubcontainer(27));
@@ -19,6 +38,7 @@
super(Containers.SHULKER_BOX, i);
a(iinventory, 27);
checkContainerSize(iinventory, 27);
this.container = iinventory;
+ this.player = playerinventory; // CraftBukkit - save player
iinventory.startOpen(playerinventory.player);

View File

@@ -19,14 +19,14 @@
public ContainerSmithing(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -61,13 +66,15 @@
List<RecipeSmithing> list = this.level.getCraftingManager().b(Recipes.SMITHING, this.inputSlots, this.level);
List<RecipeSmithing> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level);
if (list.isEmpty()) {
- this.resultSlots.setItem(0, ItemStack.EMPTY);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
} else {
this.selectedRecipe = (RecipeSmithing) list.get(0);
ItemStack itemstack = this.selectedRecipe.a(this.inputSlots);
ItemStack itemstack = this.selectedRecipe.assemble(this.inputSlots);
this.resultSlots.setRecipeUsed(this.selectedRecipe);
- this.resultSlots.setItem(0, itemstack);
@@ -37,8 +37,8 @@
}
@@ -83,4 +90,18 @@
public boolean a(ItemStack itemstack, Slot slot) {
return slot.container != this.resultSlots && super.a(itemstack, slot);
public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) {
return slot.container != this.resultSlots && super.canTakeItemForPickAll(itemstack, slot);
}
+
+ // CraftBukkit start

View File

@@ -37,7 +37,7 @@
public ContainerStonecutter(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -53,6 +75,13 @@
ContainerStonecutter.this.a((IInventory) this);
ContainerStonecutter.this.slotsChanged(this);
ContainerStonecutter.this.slotUpdateListener.run();
}
+
@@ -53,16 +53,16 @@
@@ -100,6 +129,7 @@
}
this.a(this.selectedRecipeIndex);
this.addDataSlot(this.selectedRecipeIndex);
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
public int l() {
public int getSelectedRecipeIndex() {
@@ -120,6 +150,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.access, entityhuman, Blocks.STONECUTTER);
return stillValid(this.access, entityhuman, Blocks.STONECUTTER);
}

View File

@@ -13,14 +13,8 @@
public class ContainerWorkbench extends ContainerRecipeBook<InventoryCrafting> {
public static final int RESULT_SLOT = 0;
@@ -23,10 +29,13 @@
private static final int INV_SLOT_END = 37;
private static final int USE_ROW_SLOT_START = 37;
private static final int USE_ROW_SLOT_END = 46;
- private final InventoryCrafting craftSlots;
- private final InventoryCraftResult resultSlots;
+ public final InventoryCrafting craftSlots; // PAIL private -> public
+ public final InventoryCraftResult resultSlots; // PAIL private -> public
@@ -27,6 +33,9 @@
public final InventoryCraftResult resultSlots;
public final ContainerAccess access;
private final EntityHuman player;
+ // CraftBukkit start
@@ -41,30 +35,26 @@
+ // CraftBukkit end
this.access = containeraccess;
this.player = playerinventory.player;
this.a((Slot) (new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35)));
@@ -71,9 +83,10 @@
RecipeCrafting recipecrafting = (RecipeCrafting) optional.get();
if (inventorycraftresult.setRecipeUsed(world, entityplayer, recipecrafting)) {
- itemstack = recipecrafting.a((IInventory) inventorycrafting);
+ itemstack = recipecrafting.a(inventorycrafting); // CraftBukkit - decompile error
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35));
@@ -74,6 +86,7 @@
itemstack = recipecrafting.assemble(inventorycrafting);
}
}
+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), optional.orElse(null) instanceof RecipeRepair); // CraftBukkit
inventorycraftresult.setItem(0, itemstack);
container.a(0, itemstack);
container.setRemoteSlot(0, itemstack);
@@ -114,6 +127,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.access, entityhuman, Blocks.CRAFTING_TABLE);
return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE);
}
@@ -202,4 +216,17 @@
public boolean d(int i) {
return i != this.m();
public boolean shouldMoveToInventory(int i) {
return i != this.getResultSlotIndex();
}
+
+ // CraftBukkit start

View File

@@ -10,22 +10,13 @@
+
public class Containers<T extends Container> {
public static final Containers<ContainerChest> GENERIC_9x1 = a("generic_9x1", ContainerChest::a);
public static final Containers<ContainerChest> GENERIC_9x1 = register("generic_9x1", ContainerChest::oneRow);
@@ -22,7 +26,7 @@
public static final Containers<ContainerGrindstone> GRINDSTONE = a("grindstone", ContainerGrindstone::new);
public static final Containers<ContainerHopper> HOPPER = a("hopper", ContainerHopper::new);
public static final Containers<ContainerLectern> LECTERN = a("lectern", (i, playerinventory) -> {
public static final Containers<ContainerGrindstone> GRINDSTONE = register("grindstone", ContainerGrindstone::new);
public static final Containers<ContainerHopper> HOPPER = register("hopper", ContainerHopper::new);
public static final Containers<ContainerLectern> LECTERN = register("lectern", (i, playerinventory) -> {
- return new ContainerLectern(i);
+ return new ContainerLectern(i, playerinventory); // CraftBukkit
});
public static final Containers<ContainerLoom> LOOM = a("loom", ContainerLoom::new);
public static final Containers<ContainerMerchant> MERCHANT = a("merchant", ContainerMerchant::new);
@@ -34,7 +38,7 @@
private final Containers.Supplier<T> constructor;
private static <T extends Container> Containers<T> a(String s, Containers.Supplier<T> containers_supplier) {
- return (Containers) IRegistry.a(IRegistry.MENU, s, (Object) (new Containers<>(containers_supplier)));
+ return (Containers) IRegistry.a(IRegistry.MENU, s, (new Containers<>(containers_supplier))); // CraftBukkit - decompile error
}
private Containers(Containers.Supplier<T> containers_supplier) {
public static final Containers<ContainerLoom> LOOM = register("loom", ContainerLoom::new);
public static final Containers<ContainerMerchant> MERCHANT = register("merchant", ContainerMerchant::new);

View File

@@ -50,5 +50,5 @@
+ // CraftBukkit end
+
public InventoryCraftResult() {
this.itemStacks = NonNullList.a(1, ItemStack.EMPTY);
this.itemStacks = NonNullList.withSize(1, ItemStack.EMPTY);
}

View File

@@ -83,5 +83,5 @@
+ // CraftBukkit end
+
public InventoryCrafting(Container container, int i, int j) {
this.items = NonNullList.a(i * j, ItemStack.EMPTY);
this.items = NonNullList.withSize(i * j, ItemStack.EMPTY);
this.menu = container;

View File

@@ -22,7 +22,7 @@
+
+ @Override
+ public Location getLocation() {
+ return this.activeChest != null ? new Location(this.activeChest.getWorld().getWorld(), this.activeChest.getPosition().getX(), this.activeChest.getPosition().getY(), this.activeChest.getPosition().getZ()) : null;
+ return this.activeChest != null ? new Location(this.activeChest.getLevel().getWorld(), this.activeChest.getBlockPos().getX(), this.activeChest.getBlockPos().getY(), this.activeChest.getBlockPos().getZ()) : null;
+ }
- public InventoryEnderChest() {
@@ -32,4 +32,4 @@
+ // CraftBukkit end
}
public void a(TileEntityEnderChest tileentityenderchest) {
public void setActiveChest(TileEntityEnderChest tileentityenderchest) {

View File

@@ -62,5 +62,5 @@
+ // CraftBukkit end
+
public InventoryMerchant(IMerchant imerchant) {
this.itemStacks = NonNullList.a(3, ItemStack.EMPTY);
this.itemStacks = NonNullList.withSize(3, ItemStack.EMPTY);
this.merchant = imerchant;

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/inventory/SlotFurnaceResult.java
+++ b/net/minecraft/world/inventory/SlotFurnaceResult.java
@@ -46,7 +46,7 @@
protected void b_(ItemStack itemstack) {
itemstack.a(this.player.level, this.player, this.removeCount);
protected void checkTakeAchievements(ItemStack itemstack) {
itemstack.onCraftedBy(this.player.level, this.player, this.removeCount);
if (this.player instanceof EntityPlayer && this.container instanceof TileEntityFurnace) {
- ((TileEntityFurnace) this.container).a((EntityPlayer) this.player);
+ ((TileEntityFurnace) this.container).a((EntityPlayer) this.player, itemstack, this.removeCount); // CraftBukkit
- ((TileEntityFurnace) this.container).awardUsedRecipesAndPopExperience((EntityPlayer) this.player);
+ ((TileEntityFurnace) this.container).awardUsedRecipesAndPopExperience((EntityPlayer) this.player, itemstack, this.removeCount); // CraftBukkit
}
this.removeCount = 0;