@@ -74,7 +74,7 @@
|
||||
k = ((Slot) this.quickcraftSlots.iterator().next()).index;
|
||||
this.resetQuickCraft();
|
||||
this.doClick(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman);
|
||||
@@ -391,6 +435,7 @@
|
||||
@@ -396,6 +440,7 @@
|
||||
l = this.getCarried().getCount();
|
||||
Iterator iterator = this.quickcraftSlots.iterator();
|
||||
|
||||
@@ -82,13 +82,13 @@
|
||||
while (iterator.hasNext()) {
|
||||
Slot slot1 = (Slot) iterator.next();
|
||||
ItemStack itemstack2 = this.getCarried();
|
||||
@@ -407,12 +452,48 @@
|
||||
}
|
||||
@@ -406,12 +451,48 @@
|
||||
int l1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1);
|
||||
|
||||
l -= itemstack3.getCount() - j1;
|
||||
- slot1.setByPlayer(itemstack3);
|
||||
+ // slot1.setByPlayer(itemstack3);
|
||||
+ draggedSlots.put(slot1.index, itemstack3); // CraftBukkit - Put in map instead of setting
|
||||
l -= l1 - j1;
|
||||
- slot1.setByPlayer(itemstack1.copyWithCount(l1));
|
||||
+ // slot1.setByPlayer(itemstack1.copyWithCount(l1));
|
||||
+ draggedSlots.put(slot1.index, itemstack1.copyWithCount(l1)); // CraftBukkit - Put in map instead of setting
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
+ this.setCarried(CraftItemStack.asNMSCopy(newcursor));
|
||||
+
|
||||
+ InventoryDragEvent event = new InventoryDragEvent(view, (newcursor.getType() != org.bukkit.Material.AIR ? newcursor : null), CraftItemStack.asBukkitCopy(oldCursor), this.quickcraftType == 1, eventmap);
|
||||
+ entityhuman.level.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ entityhuman.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ // Whether or not a change was made to the inventory that requires an update.
|
||||
+ boolean needsUpdate = event.getResult() != Result.DEFAULT;
|
||||
@@ -134,7 +134,7 @@
|
||||
}
|
||||
|
||||
this.resetQuickCraft();
|
||||
@@ -430,8 +511,11 @@
|
||||
@@ -429,8 +510,11 @@
|
||||
if (i == -999) {
|
||||
if (!this.getCarried().isEmpty()) {
|
||||
if (clickaction == ClickAction.PRIMARY) {
|
||||
@@ -147,7 +147,7 @@
|
||||
} else {
|
||||
entityhuman.drop(this.getCarried().split(1), true);
|
||||
}
|
||||
@@ -494,6 +578,15 @@
|
||||
@@ -493,6 +577,15 @@
|
||||
}
|
||||
|
||||
slot.setChanged();
|
||||
@@ -163,7 +163,7 @@
|
||||
}
|
||||
} else {
|
||||
Slot slot2;
|
||||
@@ -607,13 +700,14 @@
|
||||
@@ -605,13 +698,14 @@
|
||||
ItemStack itemstack = this.getCarried();
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
@@ -179,7 +179,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -827,6 +921,11 @@
|
||||
@@ -830,6 +924,11 @@
|
||||
}
|
||||
|
||||
public ItemStack getCarried() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerAnvil.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerAnvil.java
|
||||
@@ -17,6 +17,10 @@
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -19,6 +19,10 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -11,7 +11,7 @@
|
||||
public class ContainerAnvil extends ContainerAnvilAbstract {
|
||||
|
||||
public static final int INPUT_SLOT = 0;
|
||||
@@ -39,6 +43,11 @@
|
||||
@@ -42,6 +46,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);
|
||||
@@ -66,7 +75,7 @@
|
||||
@@ -69,7 +78,7 @@
|
||||
|
||||
@Override
|
||||
protected boolean mayPickup(EntityHuman entityhuman, boolean flag) {
|
||||
@@ -32,7 +32,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +98,7 @@
|
||||
@@ -92,7 +101,7 @@
|
||||
this.inputSlots.setItem(1, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
this.access.execute((world, blockposition) -> {
|
||||
IBlockData iblockdata = world.getBlockState(blockposition);
|
||||
|
||||
@@ -120,8 +129,8 @@
|
||||
@@ -123,8 +132,8 @@
|
||||
byte b1 = 0;
|
||||
|
||||
if (itemstack.isEmpty()) {
|
||||
@@ -52,7 +52,7 @@
|
||||
} else {
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
ItemStack itemstack2 = this.inputSlots.getItem(1);
|
||||
@@ -138,8 +147,8 @@
|
||||
@@ -141,8 +150,8 @@
|
||||
if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) {
|
||||
k = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4);
|
||||
if (k <= 0) {
|
||||
@@ -63,7 +63,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -153,8 +162,8 @@
|
||||
@@ -156,8 +165,8 @@
|
||||
this.repairItemCountCost = i1;
|
||||
} else {
|
||||
if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) {
|
||||
@@ -74,7 +74,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -243,8 +252,8 @@
|
||||
@@ -246,8 +255,8 @@
|
||||
}
|
||||
|
||||
if (flag2 && !flag1) {
|
||||
@@ -85,7 +85,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -267,11 +276,11 @@
|
||||
@@ -270,11 +279,11 @@
|
||||
itemstack1 = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
itemstack1 = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@@ -290,7 +299,8 @@
|
||||
@@ -293,7 +302,8 @@
|
||||
EnchantmentManager.setEnchantments(map, itemstack1);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
this.broadcastChanges();
|
||||
}
|
||||
}
|
||||
@@ -317,4 +327,18 @@
|
||||
@@ -334,4 +344,18 @@
|
||||
public int getCost() {
|
||||
return this.cost.get();
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE);
|
||||
}
|
||||
|
||||
@@ -305,4 +398,17 @@
|
||||
@@ -304,4 +397,17 @@
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
this.broadcastChanges();
|
||||
}
|
||||
|
||||
@@ -251,6 +281,7 @@
|
||||
@@ -250,6 +280,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
return stillValid(this.access, entityhuman, Blocks.LOOM);
|
||||
}
|
||||
|
||||
@@ -309,6 +347,11 @@
|
||||
@@ -308,6 +346,11 @@
|
||||
|
||||
if (nbttagcompound != null && nbttagcompound.contains("Patterns", 9)) {
|
||||
nbttaglist = nbttagcompound.getList("Patterns", 10);
|
||||
|
||||
@@ -45,4 +45,4 @@
|
||||
+ if (!this.trader.isClientSide() && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035
|
||||
Entity entity = (Entity) this.trader;
|
||||
|
||||
entity.getLevel().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), this.trader.getNotifyTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false);
|
||||
entity.level().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), this.trader.getNotifyTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false);
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
public static final MinecraftKey EMPTY_ARMOR_SLOT_SHIELD = new MinecraftKey("item/empty_armor_slot_shield");
|
||||
static final MinecraftKey[] TEXTURE_EMPTY_SLOTS = new MinecraftKey[]{ContainerPlayer.EMPTY_ARMOR_SLOT_BOOTS, ContainerPlayer.EMPTY_ARMOR_SLOT_LEGGINGS, ContainerPlayer.EMPTY_ARMOR_SLOT_CHESTPLATE, ContainerPlayer.EMPTY_ARMOR_SLOT_HELMET};
|
||||
private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
|
||||
- private final InventoryCrafting craftSlots = new InventoryCrafting(this, 2, 2);
|
||||
- private final InventoryCrafting craftSlots = new TransientCraftingContainer(this, 2, 2);
|
||||
- private final InventoryCraftResult resultSlots = new InventoryCraftResult();
|
||||
+ // CraftBukkit start
|
||||
+ private final InventoryCrafting craftSlots;
|
||||
+ private final TransientCraftingContainer craftSlots;
|
||||
+ private final InventoryCraftResult resultSlots;
|
||||
+ // CraftBukkit end
|
||||
public final boolean active;
|
||||
@@ -36,7 +36,7 @@
|
||||
this.owner = entityhuman;
|
||||
+ // CraftBukkit start
|
||||
+ this.resultSlots = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction
|
||||
+ this.craftSlots = new InventoryCrafting(this, 2, 2, playerinventory.player); // CraftBukkit - pass player
|
||||
+ 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
|
||||
+ setTitle(IChatBaseComponent.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
public ContainerSmithing(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -89,7 +94,7 @@
|
||||
@@ -96,7 +101,7 @@
|
||||
List<SmithingRecipe> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
@@ -28,7 +28,7 @@
|
||||
} else {
|
||||
SmithingRecipe smithingrecipe = (SmithingRecipe) list.get(0);
|
||||
ItemStack itemstack = smithingrecipe.assemble(this.inputSlots, this.level.registryAccess());
|
||||
@@ -97,7 +102,9 @@
|
||||
@@ -104,7 +109,9 @@
|
||||
if (itemstack.isItemEnabled(this.level.enabledFeatures())) {
|
||||
this.selectedRecipe = smithingrecipe;
|
||||
this.resultSlots.setRecipeUsed(smithingrecipe);
|
||||
@@ -39,7 +39,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,4 +132,18 @@
|
||||
@@ -132,4 +139,18 @@
|
||||
return findSlotMatchingIngredient(smithingrecipe, itemstack);
|
||||
}).anyMatch(Optional::isPresent);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
};
|
||||
this.resultContainer = new InventoryCraftResult();
|
||||
this.access = containeraccess;
|
||||
@@ -100,6 +129,7 @@
|
||||
@@ -104,6 +133,7 @@
|
||||
}
|
||||
|
||||
this.addDataSlot(this.selectedRecipeIndex);
|
||||
@@ -58,7 +58,7 @@
|
||||
}
|
||||
|
||||
public int getSelectedRecipeIndex() {
|
||||
@@ -120,6 +150,7 @@
|
||||
@@ -124,6 +154,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
|
||||
@@ -13,7 +13,12 @@
|
||||
public class ContainerWorkbench extends ContainerRecipeBook<InventoryCrafting> {
|
||||
|
||||
public static final int RESULT_SLOT = 0;
|
||||
@@ -27,6 +33,9 @@
|
||||
@@ -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;
|
||||
- public final InventoryCrafting craftSlots;
|
||||
+ public final TransientCraftingContainer craftSlots; // CraftBukkit
|
||||
public final InventoryCraftResult resultSlots;
|
||||
public final ContainerAccess access;
|
||||
private final EntityHuman player;
|
||||
@@ -27,10 +32,10 @@
|
||||
|
||||
public ContainerWorkbench(int i, PlayerInventory playerinventory, ContainerAccess containeraccess) {
|
||||
super(Containers.CRAFTING, i);
|
||||
- this.craftSlots = new InventoryCrafting(this, 3, 3);
|
||||
- this.craftSlots = new TransientCraftingContainer(this, 3, 3);
|
||||
+ // CraftBukkit start - Switched order of IInventory construction and stored player
|
||||
this.resultSlots = new InventoryCraftResult();
|
||||
+ this.craftSlots = new InventoryCrafting(this, 3, 3, playerinventory.player); // CraftBukkit - pass player
|
||||
+ this.craftSlots = new TransientCraftingContainer(this, 3, 3, playerinventory.player); // CraftBukkit - pass player
|
||||
+ this.craftSlots.resultInventory = this.resultSlots;
|
||||
+ // CraftBukkit end
|
||||
this.access = containeraccess;
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
--- a/net/minecraft/world/inventory/LegacySmithingMenu.java
|
||||
+++ b/net/minecraft/world/inventory/LegacySmithingMenu.java
|
||||
@@ -11,6 +11,8 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
|
||||
+
|
||||
/** @deprecated */
|
||||
@Deprecated(forRemoval = true)
|
||||
public class LegacySmithingMenu extends ContainerAnvilAbstract {
|
||||
@@ -26,6 +28,9 @@
|
||||
@Nullable
|
||||
private LegacyUpgradeRecipe selectedRecipe;
|
||||
private final List<LegacyUpgradeRecipe> recipes;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public LegacySmithingMenu(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -87,7 +92,7 @@
|
||||
}).toList();
|
||||
|
||||
if (list.isEmpty()) {
|
||||
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
} else {
|
||||
LegacyUpgradeRecipe legacyupgraderecipe = (LegacyUpgradeRecipe) list.get(0);
|
||||
ItemStack itemstack = legacyupgraderecipe.assemble(this.inputSlots, this.level.registryAccess());
|
||||
@@ -95,7 +100,9 @@
|
||||
if (itemstack.isItemEnabled(this.level.enabledFeatures())) {
|
||||
this.selectedRecipe = legacyupgraderecipe;
|
||||
this.resultSlots.setRecipeUsed(legacyupgraderecipe);
|
||||
- this.resultSlots.setItem(0, itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,4 +123,18 @@
|
||||
public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) {
|
||||
return slot.container != this.resultSlots && super.canTakeItemForPickAll(itemstack, slot);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithing(
|
||||
+ access.getLocation(), this.inputSlots, this.resultSlots);
|
||||
+ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/world/inventory/SlotFurnaceResult.java
|
||||
+++ b/net/minecraft/world/inventory/SlotFurnaceResult.java
|
||||
@@ -46,7 +46,7 @@
|
||||
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).awardUsedRecipesAndPopExperience((EntityPlayer) this.player);
|
||||
+ ((TileEntityFurnace) this.container).awardUsedRecipesAndPopExperience((EntityPlayer) this.player, itemstack, this.removeCount); // CraftBukkit
|
||||
@@ -54,7 +54,7 @@
|
||||
if (iinventory instanceof TileEntityFurnace) {
|
||||
TileEntityFurnace tileentityfurnace = (TileEntityFurnace) iinventory;
|
||||
|
||||
- tileentityfurnace.awardUsedRecipesAndPopExperience(entityplayer);
|
||||
+ tileentityfurnace.awardUsedRecipesAndPopExperience(entityplayer, itemstack, this.removeCount); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
this.removeCount = 0;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
--- a/net/minecraft/world/inventory/InventoryCrafting.java
|
||||
+++ b/net/minecraft/world/inventory/InventoryCrafting.java
|
||||
@@ -8,6 +8,15 @@
|
||||
--- 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.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.List;
|
||||
+import net.minecraft.world.IInventory;
|
||||
+import net.minecraft.world.item.crafting.IRecipe;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
@@ -13,12 +14,12 @@
|
||||
+import org.bukkit.event.inventory.InventoryType;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class InventoryCrafting implements IInventory, AutoRecipeOutput {
|
||||
public class TransientCraftingContainer implements InventoryCrafting {
|
||||
|
||||
private final NonNullList<ItemStack> items;
|
||||
@@ -15,6 +24,68 @@
|
||||
@@ -15,6 +25,68 @@
|
||||
private final int height;
|
||||
public final Container menu;
|
||||
private final Container menu;
|
||||
|
||||
+ // CraftBukkit start - add fields
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
@@ -76,12 +77,12 @@
|
||||
+ this.currentRecipe = currentRecipe;
|
||||
+ }
|
||||
+
|
||||
+ public InventoryCrafting(Container container, int i, int j, EntityHuman player) {
|
||||
+ public TransientCraftingContainer(Container container, int i, int j, EntityHuman player) {
|
||||
+ this(container, i, j);
|
||||
+ this.owner = player;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public InventoryCrafting(Container container, int i, int j) {
|
||||
this.items = NonNullList.withSize(i * j, ItemStack.EMPTY);
|
||||
this.menu = container;
|
||||
public TransientCraftingContainer(Container container, int i, int j) {
|
||||
this(container, i, j, NonNullList.withSize(i * j, ItemStack.EMPTY));
|
||||
}
|
||||
Reference in New Issue
Block a user