Update to Minecraft 1.21.2

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-10-23 02:15:00 +11:00
parent 2c4beb962b
commit d3a23f42c3
522 changed files with 8501 additions and 6477 deletions

View File

@@ -0,0 +1,41 @@
--- a/net/minecraft/world/inventory/AbstractCraftingMenu.java
+++ b/net/minecraft/world/inventory/AbstractCraftingMenu.java
@@ -13,14 +13,17 @@
private final int width;
private final int height;
- public final InventoryCrafting craftSlots;
+ public final TransientCraftingContainer craftSlots; // CraftBukkit
public final InventoryCraftResult resultSlots = new InventoryCraftResult();
- public AbstractCraftingMenu(Containers<?> containers, int i, int j, int k) {
+ public AbstractCraftingMenu(Containers<?> containers, int i, int j, int k, PlayerInventory playerInventory) { // CraftBukkit
super(containers, i);
this.width = j;
this.height = k;
- this.craftSlots = new TransientCraftingContainer(this, j, k);
+ // CraftBukkit start
+ this.craftSlots = new TransientCraftingContainer(this, j, k, playerInventory.player); // CraftBukkit - pass player
+ this.craftSlots.resultInventory = this.resultSlots; // CraftBukkit - let InventoryCrafting know about its result slot
+ // CraftBukkit end
}
protected Slot addResultSlot(EntityHuman entityhuman, int i, int j) {
@@ -38,7 +41,7 @@
@Override
public ContainerRecipeBook.a handlePlacement(boolean flag, boolean flag1, RecipeHolder<?> recipeholder, WorldServer worldserver, PlayerInventory playerinventory) {
- RecipeHolder<RecipeCrafting> recipeholder1 = recipeholder;
+ RecipeHolder<RecipeCrafting> recipeholder1 = (RecipeHolder<RecipeCrafting>) recipeholder; // CraftBukkit - decompile error
this.beginPlacingRecipe();
@@ -65,7 +68,7 @@
}
}, this.width, this.height, list, list, playerinventory, recipeholder1, flag, flag1);
} finally {
- this.finishPlacingRecipe(worldserver, recipeholder);
+ this.finishPlacingRecipe(worldserver, recipeholder1); // CraftBukkit - decompile error
}
return containerrecipebook_a;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/Container.java
+++ b/net/minecraft/world/inventory/Container.java
@@ -33,6 +33,20 @@
@@ -35,6 +35,20 @@
import net.minecraft.world.level.block.entity.TileEntity;
import org.slf4j.Logger;
@@ -21,7 +21,7 @@
public abstract class Container {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -63,6 +77,27 @@
@@ -67,6 +81,27 @@
private ContainerSynchronizer synchronizer;
private boolean suppressRemoteUpdates;
@@ -49,7 +49,7 @@
protected Container(@Nullable Containers<?> containers, int i) {
this.carried = ItemStack.EMPTY;
this.remoteSlots = NonNullList.create();
@@ -164,6 +199,15 @@
@@ -192,6 +227,15 @@
}
@@ -65,7 +65,7 @@
public void removeSlotListener(ICrafting icrafting) {
this.containerListeners.remove(icrafting);
}
@@ -380,7 +424,7 @@
@@ -417,7 +461,7 @@
}
} else if (this.quickcraftStatus == 2) {
if (!this.quickcraftSlots.isEmpty()) {
@@ -74,7 +74,7 @@
k = ((Slot) this.quickcraftSlots.iterator().next()).index;
this.resetQuickCraft();
this.doClick(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman);
@@ -396,6 +440,7 @@
@@ -433,6 +477,7 @@
l = this.getCarried().getCount();
Iterator iterator = this.quickcraftSlots.iterator();
@@ -82,7 +82,7 @@
while (iterator.hasNext()) {
Slot slot1 = (Slot) iterator.next();
ItemStack itemstack2 = this.getCarried();
@@ -406,12 +451,48 @@
@@ -443,12 +488,48 @@
int l1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1);
l -= l1 - j1;
@@ -134,7 +134,7 @@
}
this.resetQuickCraft();
@@ -429,8 +510,11 @@
@@ -466,8 +547,11 @@
if (i == -999) {
if (!this.getCarried().isEmpty()) {
if (clickaction == ClickAction.PRIMARY) {
@@ -147,7 +147,7 @@
} else {
entityhuman.drop(this.getCarried().split(1), true);
}
@@ -493,6 +577,15 @@
@@ -530,6 +614,15 @@
}
slot.setChanged();
@@ -163,23 +163,18 @@
}
} else {
int j2;
@@ -609,13 +702,14 @@
@@ -662,8 +755,9 @@
ItemStack itemstack = this.getCarried();
if (!itemstack.isEmpty()) {
+ this.setCarried(ItemStack.EMPTY); // CraftBukkit - SPIGOT-4556 - from below
if (entityhuman.isAlive() && !((EntityPlayer) entityhuman).hasDisconnected()) {
entityhuman.getInventory().placeItemBackInInventory(itemstack);
} else {
entityhuman.drop(itemstack, false);
}
dropOrPlaceInInventory(entityhuman, itemstack);
- this.setCarried(ItemStack.EMPTY);
+ // this.setCarried(ItemStack.EMPTY); // CraftBukkit - moved up
}
}
@@ -830,6 +924,11 @@
}
@@ -893,6 +987,11 @@
}
public ItemStack getCarried() {

View File

@@ -11,7 +11,7 @@
public class ContainerAnvil extends ContainerAnvilAbstract {
public static final int INPUT_SLOT = 0;
@@ -44,6 +48,11 @@
@@ -45,6 +49,11 @@
private static final int ADDITIONAL_SLOT_X_PLACEMENT = 76;
private static final int RESULT_SLOT_X_PLACEMENT = 134;
private static final int SLOT_Y_PLACEMENT = 47;
@@ -23,7 +23,7 @@
public ContainerAnvil(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -71,7 +80,7 @@
@@ -72,7 +81,7 @@
@Override
protected boolean mayPickup(EntityHuman entityhuman, boolean flag) {
@@ -38,11 +38,11 @@
- this.cost.set(0);
+ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
this.inputSlots.setItem(0, ItemStack.EMPTY);
this.access.execute((world, blockposition) -> {
IBlockData iblockdata = world.getBlockState(blockposition);
@@ -141,8 +150,8 @@
if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) {
@@ -143,8 +152,8 @@
if (itemstack1.isDamageableItem() && itemstack.isValidRepairItem(itemstack2)) {
k = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4);
if (k <= 0) {
- this.resultSlots.setItem(0, ItemStack.EMPTY);
@@ -52,7 +52,7 @@
return;
}
@@ -156,8 +165,8 @@
@@ -158,8 +167,8 @@
this.repairItemCountCost = i1;
} else {
if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) {
@@ -63,7 +63,7 @@
return;
}
@@ -231,8 +240,8 @@
@@ -233,8 +242,8 @@
}
if (flag2 && !flag1) {
@@ -74,14 +74,17 @@
return;
}
}
@@ -257,11 +266,11 @@
itemstack1 = ItemStack.EMPTY;
@@ -260,14 +269,14 @@
}
- if (b0 == i && b0 > 0 && this.cost.get() >= 40) {
- this.cost.set(39);
+ if (b0 == i && b0 > 0 && this.cost.get() >= maximumRepairCost) { // CraftBukkit
+ this.cost.set(maximumRepairCost - 1); // CraftBukkit
if (b0 == i && b0 > 0) {
- if (this.cost.get() >= 40) {
- this.cost.set(39);
+ if (this.cost.get() >= maximumRepairCost) { // CraftBukkit
+ this.cost.set(maximumRepairCost - 1); // CraftBukkit
}
this.onlyRenaming = true;
}
- if (this.cost.get() >= 40 && !this.player.getAbilities().instabuild) {
@@ -89,7 +92,7 @@
itemstack1 = ItemStack.EMPTY;
}
@@ -279,11 +288,12 @@
@@ -285,11 +294,12 @@
EnchantmentManager.setEnchantments(itemstack1, itemenchantments_a.toImmutable());
}
@@ -105,7 +108,7 @@
}
}
@@ -323,4 +333,19 @@
@@ -329,4 +339,19 @@
public int getCost() {
return this.cost.get();
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java
+++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java
@@ -47,7 +47,7 @@
@@ -50,7 +50,7 @@
while (iterator.hasNext()) {
final ItemCombinerMenuSlotDefinition.b itemcombinermenuslotdefinition_b = (ItemCombinerMenuSlotDefinition.b) iterator.next();
@@ -9,7 +9,7 @@
@Override
public boolean mayPlace(ItemStack itemstack) {
return itemcombinermenuslotdefinition_b.mayPlace().test(itemstack);
@@ -124,6 +124,7 @@
@@ -110,6 +110,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {

View File

@@ -33,7 +33,7 @@
@Override
public boolean canPlaceItem(int j, ItemStack itemstack) {
return itemstack.is(TagsItem.BEACON_PAYMENT_ITEMS);
@@ -83,6 +93,7 @@
@@ -69,6 +79,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -41,7 +41,7 @@
return stillValid(this.access, entityhuman, Blocks.BEACON);
}
@@ -164,8 +175,8 @@
@@ -150,8 +161,8 @@
public void updateEffects(Optional<Holder<MobEffectList>> optional, Optional<Holder<MobEffectList>> optional1) {
if (this.paymentSlot.hasItem()) {
@@ -52,7 +52,7 @@
this.paymentSlot.remove(1);
this.access.execute(World::blockEntityChanged);
}
@@ -192,4 +203,17 @@
@@ -178,4 +189,17 @@
return 1;
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerBrewingStand.java
+++ b/net/minecraft/world/inventory/ContainerBrewingStand.java
@@ -15,6 +15,11 @@
@@ -16,6 +16,11 @@
import net.minecraft.world.item.alchemy.PotionContents;
import net.minecraft.world.item.alchemy.PotionRegistry;
@@ -12,7 +12,7 @@
public class ContainerBrewingStand extends Container {
private static final int BOTTLE_SLOT_START = 0;
@@ -31,12 +36,18 @@
@@ -32,12 +37,18 @@
private final IContainerProperties brewingStandData;
private final Slot ingredientSlot;
@@ -31,7 +31,7 @@
checkContainerSize(iinventory, 5);
checkContainerDataCount(icontainerproperties, 2);
this.brewingStand = iinventory;
@@ -66,6 +77,7 @@
@@ -55,6 +66,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -39,8 +39,8 @@
return this.brewingStand.stillValid(entityhuman);
}
@@ -196,4 +208,17 @@
return itemstack.is(Items.BLAZE_POWDER);
@@ -185,4 +197,17 @@
return itemstack.is(TagsItem.BREWING_FUEL);
}
}
+

View File

@@ -62,7 +62,7 @@
+ this.addSlot(new Slot(this.container, 0, 15, 15) { // CraftBukkit - decompile error
@Override
public boolean mayPlace(ItemStack itemstack) {
return itemstack.is(Items.FILLED_MAP);
return itemstack.has(DataComponents.MAP_ID);
}
});
- this.addSlot(new Slot(this, this.container, 1, 15, 52) {
@@ -70,10 +70,10 @@
@Override
public boolean mayPlace(ItemStack itemstack) {
return itemstack.is(Items.PAPER) || itemstack.is(Items.MAP) || itemstack.is(Items.GLASS_PANE);
@@ -97,10 +133,12 @@
this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142));
}
@@ -85,10 +121,12 @@
}
});
this.addStandardInventorySlots(playerinventory, 8, 84);
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerChest.java
+++ b/net/minecraft/world/inventory/ContainerChest.java
@@ -6,11 +6,40 @@
@@ -6,10 +6,39 @@
import net.minecraft.world.entity.player.PlayerInventory;
import net.minecraft.world.item.ItemStack;
@@ -12,7 +12,6 @@
+
public class ContainerChest extends Container {
private static final int SLOTS_PER_ROW = 9;
private final IInventory container;
private final int containerRows;
+ // CraftBukkit start
@@ -41,18 +40,17 @@
private ContainerChest(Containers<?> containers, int i, PlayerInventory playerinventory, int j) {
this(containers, i, playerinventory, new InventorySubcontainer(9 * j), j);
@@ -56,6 +85,10 @@
@@ -53,6 +82,9 @@
this.container = iinventory;
this.containerRows = j;
iinventory.startOpen(playerinventory.player);
int k = (this.containerRows - 4) * 18;
+ // CraftBukkit start - Save player
+ this.player = playerinventory;
+ // CraftBukkit end
+
int l;
int i1;
boolean flag = true;
@@ -79,6 +112,7 @@
this.addChestGrid(iinventory, 8, 18);
@@ -72,6 +104,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {

View File

@@ -34,7 +34,7 @@
checkContainerSize(iinventory, 9);
this.dispenser = iinventory;
iinventory.startOpen(playerinventory.player);
@@ -48,6 +61,7 @@
@@ -41,6 +54,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -42,7 +42,7 @@
return this.dispenser.stillValid(entityhuman);
}
@@ -89,4 +103,17 @@
@@ -82,4 +96,17 @@
super.removed(entityhuman);
this.dispenser.stopOpen(entityhuman);
}

View File

@@ -61,7 +61,7 @@
@Override
public boolean mayPlace(ItemStack itemstack) {
return itemstack.is(Items.LAPIS_LAZULI);
@@ -101,6 +125,9 @@
@@ -89,6 +113,9 @@
this.addDataSlot(ContainerProperty.shared(this.levelClue, 0));
this.addDataSlot(ContainerProperty.shared(this.levelClue, 1));
this.addDataSlot(ContainerProperty.shared(this.levelClue, 2));
@@ -71,16 +71,16 @@
}
@Override
@@ -108,7 +135,7 @@
@@ -96,7 +123,7 @@
if (iinventory == this.enchantSlots) {
ItemStack itemstack = iinventory.getItem(0);
- if (!itemstack.isEmpty() && itemstack.isEnchantable()) {
+ if (!itemstack.isEmpty()) { // CraftBukkit - relax condition
this.access.execute((world, blockposition) -> {
Registry<Holder<Enchantment>> registry = world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap();
Registry<Holder<Enchantment>> registry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap();
int i = 0;
@@ -148,6 +175,41 @@
@@ -136,6 +163,41 @@
}
}
@@ -122,14 +122,14 @@
this.broadcastChanges();
});
} else {
@@ -175,21 +237,46 @@
@@ -163,21 +225,46 @@
ItemStack itemstack2 = itemstack;
List<WeightedRandomEnchant> list = this.getEnchantmentList(world.registryAccess(), itemstack, i, this.costs[i]);
- if (!list.isEmpty()) {
- entityhuman.onEnchantmentPerformed(itemstack, j);
+ // CraftBukkit start
+ Registry<Holder<Enchantment>> registry = world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap();
+ Registry<Holder<Enchantment>> registry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap();
+ if (true || !list.isEmpty()) {
+ // entityhuman.onEnchantmentPerformed(itemstack, j); // Moved down
+ Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
@@ -175,7 +175,7 @@
itemstack1.consume(j, entityhuman);
if (itemstack1.isEmpty()) {
this.enchantSlots.setItem(1, ItemStack.EMPTY);
@@ -256,6 +343,7 @@
@@ -244,6 +331,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -183,7 +183,7 @@
return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE);
}
@@ -306,4 +394,17 @@
@@ -294,4 +382,17 @@
return itemstack;
}

View File

@@ -1,19 +1,20 @@
--- a/net/minecraft/world/inventory/ContainerFurnace.java
+++ b/net/minecraft/world/inventory/ContainerFurnace.java
@@ -14,6 +14,11 @@
@@ -18,6 +18,12 @@
import net.minecraft.world.item.crafting.SingleRecipeInput;
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.entity.TileEntityFurnace;
+// CraftBukkit start
+import net.minecraft.world.level.block.entity.TileEntityFurnace;
+import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
+import org.bukkit.craftbukkit.inventory.view.CraftFurnaceView;
+// CraftBukkit end
+
public abstract class ContainerFurnace extends ContainerRecipeBook<SingleRecipeInput, RecipeCooking> {
public abstract class ContainerFurnace extends ContainerRecipeBook {
public static final int INGREDIENT_SLOT = 0;
@@ -31,6 +36,22 @@
private final Recipes<? extends RecipeCooking> recipeType;
@@ -36,6 +42,22 @@
private final RecipePropertySet acceptedInputs;
private final RecipeBookType recipeBookType;
+ // CraftBukkit start
@@ -32,18 +33,18 @@
+ }
+ // CraftBukkit end
+
protected ContainerFurnace(Containers<?> containers, Recipes<? extends RecipeCooking> recipes, RecipeBookType recipebooktype, int i, PlayerInventory playerinventory) {
this(containers, recipes, recipebooktype, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4));
protected ContainerFurnace(Containers<?> containers, Recipes<? extends RecipeCooking> recipes, ResourceKey<RecipePropertySet> resourcekey, RecipeBookType recipebooktype, int i, PlayerInventory playerinventory) {
this(containers, recipes, resourcekey, recipebooktype, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4));
}
@@ -47,6 +68,7 @@
@@ -53,6 +75,7 @@
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;
@@ -104,6 +126,7 @@
this.addStandardInventorySlots(playerinventory, 8, 84);
this.addDataSlots(icontainerproperties);
}
@@ -71,6 +94,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -51,3 +52,11 @@
return this.container.stillValid(entityhuman);
}
@@ -180,6 +204,6 @@
public boolean recipeMatches(RecipeHolder<RecipeCooking> recipeholder1) {
return ((RecipeCooking) recipeholder1.value()).matches(new SingleRecipeInput(ContainerFurnace.this.container.getItem(0)), worldserver);
}
- }, 1, 1, List.of(this.getSlot(0)), list, playerinventory, recipeholder, flag, flag1);
+ }, 1, 1, List.of(this.getSlot(0)), list, playerinventory, (RecipeHolder<RecipeCooking>) recipeholder, flag, flag1); // CraftBukkit - decompile error
}
}

View File

@@ -56,15 +56,15 @@
@Override
public boolean mayPlace(ItemStack itemstack) {
return itemstack.isDamageableItem() || EnchantmentManager.hasAnyEnchantments(itemstack);
@@ -125,6 +154,7 @@
this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142));
}
@@ -113,6 +142,7 @@
}
});
this.addStandardInventorySlots(playerinventory, 8, 84);
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
@Override
@@ -137,7 +167,8 @@
@@ -125,7 +155,8 @@
}
private void createResult() {
@@ -74,7 +74,7 @@
this.broadcastChanges();
}
@@ -239,6 +270,7 @@
@@ -227,6 +258,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {

View File

@@ -40,8 +40,8 @@
+ this.player = playerinventory; // CraftBukkit - save player
checkContainerSize(iinventory, 5);
iinventory.startOpen(playerinventory.player);
boolean flag = true;
@@ -42,6 +64,7 @@
@@ -30,6 +52,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {

View File

@@ -12,7 +12,7 @@
public class ContainerHorse extends Container {
private final IInventory horseContainer;
@@ -18,8 +23,23 @@
@@ -18,13 +23,28 @@
private static final int SLOT_BODY_ARMOR = 1;
private static final int SLOT_HORSE_INVENTORY_START = 2;
@@ -36,16 +36,13 @@
this.horseContainer = iinventory;
this.armorContainer = entityhorseabstract.getBodyArmorAccess();
this.horse = entityhorseabstract;
@@ -28,7 +48,7 @@
iinventory.startOpen(playerinventory.player);
boolean flag1 = true;
- this.addSlot(new Slot(this, iinventory, 0, 8, 18) {
+ this.addSlot(new Slot(iinventory, 0, 8, 18) { // CraftBukkit - decompile error
@Override
public boolean mayPlace(ItemStack itemstack) {
return itemstack.is(Items.SADDLE) && !this.hasItem() && entityhorseabstract.isSaddleable();
@@ -39,7 +59,7 @@
@@ -35,7 +55,7 @@
return entityhorseabstract.isSaddleable();
}
});
@@ -53,4 +50,4 @@
+ this.addSlot(new ArmorSlot(this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, (MinecraftKey) null) { // CraftBukkit - decompile error
@Override
public boolean mayPlace(ItemStack itemstack) {
return entityhorseabstract.isBodyArmorItem(itemstack);
return entityhorseabstract.isEquippableInSlot(itemstack, EnumItemSlot.BODY);

View File

@@ -77,8 +77,8 @@
@Override
public boolean mayPlace(ItemStack itemstack) {
return itemstack.getItem() instanceof ItemBannerPattern;
@@ -128,10 +164,12 @@
@@ -116,10 +152,12 @@
this.addStandardInventorySlots(playerinventory, 8, 84);
this.addDataSlot(this.selectedBannerPatternIndex);
this.patternGetter = playerinventory.player.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN);
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
@@ -90,7 +90,7 @@
return stillValid(this.access, entityhuman, Blocks.LOOM);
}
@@ -306,6 +344,11 @@
@@ -294,6 +332,11 @@
EnumColor enumcolor = ((ItemDye) itemstack1.getItem()).getDyeColor();
itemstack2.update(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY, (bannerpatternlayers) -> {

View File

@@ -34,10 +34,10 @@
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
this.addStandardInventorySlots(playerinventory, 108, 84);
}
int j;
@@ -155,7 +171,7 @@
@@ -143,7 +159,7 @@
}
private void playTradeSound() {

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/inventory/ContainerPlayer.java
+++ b/net/minecraft/world/inventory/ContainerPlayer.java
@@ -13,6 +13,12 @@
import net.minecraft.world.item.crafting.RecipeCrafting;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.level.World;
+// CraftBukkit start
+import net.minecraft.network.chat.IChatBaseComponent;
@@ -10,52 +10,38 @@
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerPlayer extends ContainerRecipeBook<CraftingInput, RecipeCrafting> {
public class ContainerPlayer extends AbstractCraftingMenu {
public static final int CONTAINER_ID = 0;
@@ -36,15 +42,28 @@
public static final MinecraftKey EMPTY_ARMOR_SLOT_SHIELD = MinecraftKey.withDefaultNamespace("item/empty_armor_slot_shield");
private static final Map<EnumItemSlot, MinecraftKey> TEXTURE_EMPTY_SLOTS = Map.of(EnumItemSlot.FEET, ContainerPlayer.EMPTY_ARMOR_SLOT_BOOTS, EnumItemSlot.LEGS, ContainerPlayer.EMPTY_ARMOR_SLOT_LEGGINGS, EnumItemSlot.CHEST, ContainerPlayer.EMPTY_ARMOR_SLOT_CHESTPLATE, EnumItemSlot.HEAD, ContainerPlayer.EMPTY_ARMOR_SLOT_HELMET);
@@ -40,9 +46,15 @@
private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
- private final InventoryCrafting craftSlots = new TransientCraftingContainer(this, 2, 2);
- private final InventoryCraftResult resultSlots = new InventoryCraftResult();
+ // CraftBukkit start
+ private final TransientCraftingContainer craftSlots;
+ private final InventoryCraftResult resultSlots;
+ // CraftBukkit end
public final boolean active;
private final EntityHuman owner;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerPlayer(PlayerInventory playerinventory, boolean flag, final EntityHuman entityhuman) {
super((Containers) null, 0);
this.active = flag;
this.owner = entityhuman;
- super((Containers) null, 0, 2, 2);
+ // CraftBukkit start
+ this.resultSlots = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction
+ this.craftSlots = new TransientCraftingContainer(this, 2, 2, playerinventory.player); // CraftBukkit - pass player
+ this.craftSlots.resultInventory = this.resultSlots; // CraftBukkit - let InventoryCrafting know about its result slot
+ this.player = playerinventory; // CraftBukkit - save player
+ super((Containers) null, 0, 2, 2, playerinventory); // CraftBukkit - save player
+ setTitle(IChatBaseComponent.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory
+ // CraftBukkit end
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28));
int i;
@@ -73,7 +92,7 @@
this.addSlot(new Slot(playerinventory, i, 8 + i * 18, 142));
this.active = flag;
this.owner = entityhuman;
this.addResultSlot(entityhuman, 154, 28);
@@ -56,7 +68,7 @@
}
this.addStandardInventorySlots(playerinventory, 8, 84);
- this.addSlot(new Slot(this, playerinventory, 40, 77, 62) {
+ this.addSlot(new Slot(playerinventory, 40, 77, 62) { // CraftBukkit - decompile error
@Override
public void setByPlayer(ItemStack itemstack, ItemStack itemstack1) {
entityhuman.onEquipItem(EnumItemSlot.OFFHAND, itemstack1, itemstack);
@@ -230,4 +249,17 @@
public boolean shouldMoveToInventory(int i) {
return i != this.getResultSlotIndex();
@@ -192,4 +204,17 @@
protected EntityHuman owner() {
return this.owner;
}
+
+ // CraftBukkit start
@@ -66,7 +52,7 @@
+ }
+
+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ bukkitEntity = new CraftInventoryView(this.owner.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end

View File

@@ -38,7 +38,7 @@
iinventory.startOpen(playerinventory.player);
boolean flag = true;
boolean flag1 = true;
@@ -46,6 +66,7 @@
@@ -34,6 +54,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerSmithing.java
+++ b/net/minecraft/world/inventory/ContainerSmithing.java
@@ -14,6 +14,8 @@
@@ -18,6 +18,8 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
@@ -9,39 +9,39 @@
public class ContainerSmithing extends ContainerAnvilAbstract {
public static final int TEMPLATE_SLOT = 0;
@@ -29,6 +31,9 @@
@Nullable
private RecipeHolder<SmithingRecipe> selectedRecipe;
private final List<RecipeHolder<SmithingRecipe>> recipes;
@@ -34,6 +36,9 @@
private final RecipePropertySet templateItemTest;
private final RecipePropertySet additionItemTest;
private final ContainerProperty hasRecipeError;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity;
+ // CraftBukkit end
public ContainerSmithing(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -103,7 +108,7 @@
List<RecipeHolder<SmithingRecipe>> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, smithingrecipeinput, this.level);
@@ -117,7 +122,7 @@
public void createResult() {
SmithingRecipeInput smithingrecipeinput = this.createRecipeInput();
World world = this.level;
- Optional optional;
+ Optional<RecipeHolder<SmithingRecipe>> optional; // CraftBukkit - decompile error
if (list.isEmpty()) {
- this.resultSlots.setItem(0, ItemStack.EMPTY);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
} else {
RecipeHolder<SmithingRecipe> recipeholder = (RecipeHolder) list.get(0);
if (world instanceof WorldServer worldserver) {
optional = worldserver.recipeAccess().getRecipeFor(Recipes.SMITHING, smithingrecipeinput, worldserver);
@@ -129,7 +134,9 @@
ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(smithingrecipeinput, this.level.registryAccess());
@@ -111,7 +116,9 @@
if (itemstack.isItemEnabled(this.level.enabledFeatures())) {
this.selectedRecipe = recipeholder;
this.resultSlots.setRecipeUsed(recipeholder);
- this.resultSlots.setItem(0, itemstack);
+ // CraftBukkit start
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
+ // CraftBukkit end
}
}
@@ -143,4 +150,18 @@
return !this.getSlot(i).hasItem();
}).findFirst();
this.resultSlots.setRecipeUsed(recipeholder);
- this.resultSlots.setItem(0, itemstack);
+ // CraftBukkit start
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
+ // CraftBukkit end
}, () -> {
this.resultSlots.setRecipeUsed((RecipeHolder) null);
this.resultSlots.setItem(0, ItemStack.EMPTY);
@@ -149,4 +156,18 @@
public boolean hasRecipeError() {
return this.hasRecipeError.get() > 0;
}
+
+ // CraftBukkit start

View File

@@ -50,15 +50,15 @@
};
this.resultContainer = new InventoryCraftResult();
this.access = containeraccess;
@@ -106,6 +135,7 @@
}
@@ -94,6 +123,7 @@
});
this.addStandardInventorySlots(playerinventory, 8, 84);
this.addDataSlot(this.selectedRecipeIndex);
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
public int getSelectedRecipeIndex() {
@@ -126,6 +156,7 @@
@@ -114,6 +144,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -66,3 +66,12 @@
return stillValid(this.access, entityhuman, Blocks.STONECUTTER);
}
@@ -154,7 +185,7 @@
}
void setupResultSlot(int i) {
- Optional optional;
+ Optional<RecipeHolder<RecipeStonecutting>> optional; // CraftBukkit - decompile error
if (!this.recipesForInput.isEmpty() && this.isValidRecipeIndex(i)) {
SelectableRecipe.a<RecipeStonecutting> selectablerecipe_a = (SelectableRecipe.a) this.recipesForInput.entries().get(i);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/inventory/ContainerWorkbench.java
+++ b/net/minecraft/world/inventory/ContainerWorkbench.java
@@ -16,6 +16,12 @@
import net.minecraft.world.level.World;
import net.minecraft.world.item.crafting.Recipes;
import net.minecraft.world.level.block.Blocks;
+// CraftBukkit start
@@ -10,16 +10,10 @@
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerWorkbench extends ContainerRecipeBook<CraftingInput, RecipeCrafting> {
public class ContainerWorkbench extends AbstractCraftingMenu {
public static final int RESULT_SLOT = 0;
@@ -25,11 +31,14 @@
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;
- public final InventoryCrafting craftSlots;
+ public final TransientCraftingContainer craftSlots; // CraftBukkit
public final InventoryCraftResult resultSlots;
private static final int CRAFTING_GRID_WIDTH = 3;
@@ -31,13 +37,16 @@
public final ContainerAccess access;
private final EntityHuman player;
private boolean placingRecipe;
@@ -29,36 +23,31 @@
public ContainerWorkbench(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -37,8 +46,11 @@
}
public ContainerWorkbench(int i, PlayerInventory playerinventory, ContainerAccess containeraccess) {
super(Containers.CRAFTING, i);
- this.craftSlots = new TransientCraftingContainer(this, 3, 3);
+ // CraftBukkit start - Switched order of IInventory construction and stored player
this.resultSlots = new InventoryCraftResult();
+ this.craftSlots = new TransientCraftingContainer(this, 3, 3, playerinventory.player); // CraftBukkit - pass player
+ this.craftSlots.resultInventory = this.resultSlots;
+ // CraftBukkit end
- super(Containers.CRAFTING, i, 3, 3);
+ super(Containers.CRAFTING, i, 3, 3, playerinventory); // CraftBukkit - pass player
this.access = containeraccess;
this.player = playerinventory.player;
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35));
@@ -70,6 +82,7 @@
EntityPlayer entityplayer = (EntityPlayer) entityhuman;
ItemStack itemstack = ItemStack.EMPTY;
Optional<RecipeHolder<RecipeCrafting>> optional = world.getServer().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, world, recipeholder);
+ inventorycrafting.setCurrentRecipe(optional.orElse(null)); // CraftBukkit
this.addResultSlot(this.player, 124, 35);
@@ -50,6 +59,7 @@
EntityPlayer entityplayer = (EntityPlayer) entityhuman;
ItemStack itemstack = ItemStack.EMPTY;
Optional<RecipeHolder<RecipeCrafting>> optional = worldserver.getServer().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver, recipeholder);
+ inventorycrafting.setCurrentRecipe(optional.orElse(null)); // CraftBukkit
if (optional.isPresent()) {
RecipeHolder<RecipeCrafting> recipeholder1 = (RecipeHolder) optional.get();
@@ -83,6 +96,7 @@
}
if (optional.isPresent()) {
RecipeHolder<RecipeCrafting> recipeholder1 = (RecipeHolder) optional.get();
@@ -63,6 +73,7 @@
}
}
+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), optional.map(RecipeHolder::value).orElse(null) instanceof RecipeRepair); // CraftBukkit
}
+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), optional.map(RecipeHolder::value).orElse(null) instanceof RecipeRepair); // CraftBukkit
inventorycraftresult.setItem(0, itemstack);
container.setRemoteSlot(0, itemstack);
@@ -139,6 +153,7 @@
inventorycraftresult.setItem(0, itemstack);
container.setRemoteSlot(0, itemstack);
@@ -103,6 +114,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -66,9 +55,9 @@
return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE);
}
@@ -227,4 +242,17 @@
public boolean shouldMoveToInventory(int i) {
return i != this.getResultSlotIndex();
@@ -181,4 +193,17 @@
protected EntityHuman owner() {
return this.player;
}
+
+ // CraftBukkit start

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/inventory/CrafterMenu.java
+++ b/net/minecraft/world/inventory/CrafterMenu.java
@@ -10,8 +10,27 @@
import net.minecraft.world.level.World;
import net.minecraft.world.item.crafting.RecipeCrafting;
import net.minecraft.world.level.block.CrafterBlock;
+// CraftBukkit start
@@ -28,7 +28,7 @@
protected static final int SLOT_COUNT = 9;
private static final int INV_SLOT_START = 9;
private static final int INV_SLOT_END = 36;
@@ -118,6 +137,7 @@
@@ -106,6 +125,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/inventory/TransientCraftingContainer.java
+++ b/net/minecraft/world/inventory/TransientCraftingContainer.java
@@ -8,6 +8,16 @@
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.entity.player.StackedItemContents;
import net.minecraft.world.item.ItemStack;
+// CraftBukkit start