Move CraftBukkit per-file patches
By: Initial <noreply+automated@papermc.io>
This commit is contained in:
@@ -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;
|
||||
@@ -0,0 +1,188 @@
|
||||
--- a/net/minecraft/world/inventory/Container.java
|
||||
+++ b/net/minecraft/world/inventory/Container.java
|
||||
@@ -35,6 +35,20 @@
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.google.common.base.Preconditions;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import net.minecraft.network.chat.IChatBaseComponent;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutSetSlot;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.Event.Result;
|
||||
+import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
+import org.bukkit.event.inventory.InventoryType;
|
||||
+import org.bukkit.inventory.InventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class Container {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -67,6 +81,27 @@
|
||||
private ContainerSynchronizer synchronizer;
|
||||
private boolean suppressRemoteUpdates;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean checkReachable = true;
|
||||
+ public abstract InventoryView getBukkitView();
|
||||
+ public void transferTo(Container other, org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
|
||||
+ InventoryView source = this.getBukkitView(), destination = other.getBukkitView();
|
||||
+ ((CraftInventory) source.getTopInventory()).getInventory().onClose(player);
|
||||
+ ((CraftInventory) source.getBottomInventory()).getInventory().onClose(player);
|
||||
+ ((CraftInventory) destination.getTopInventory()).getInventory().onOpen(player);
|
||||
+ ((CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player);
|
||||
+ }
|
||||
+ private IChatBaseComponent title;
|
||||
+ public final IChatBaseComponent getTitle() {
|
||||
+ Preconditions.checkState(this.title != null, "Title not set");
|
||||
+ return this.title;
|
||||
+ }
|
||||
+ public final void setTitle(IChatBaseComponent title) {
|
||||
+ Preconditions.checkState(this.title == null, "Title already set");
|
||||
+ this.title = title;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected Container(@Nullable Containers<?> containers, int i) {
|
||||
this.carried = ItemStack.EMPTY;
|
||||
this.remoteSlots = NonNullList.create();
|
||||
@@ -192,6 +227,15 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void broadcastCarriedItem() {
|
||||
+ this.remoteCarried = this.getCarried().copy();
|
||||
+ if (this.synchronizer != null) {
|
||||
+ this.synchronizer.sendCarriedChange(this, this.remoteCarried);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void removeSlotListener(ICrafting icrafting) {
|
||||
this.containerListeners.remove(icrafting);
|
||||
}
|
||||
@@ -417,7 +461,7 @@
|
||||
}
|
||||
} else if (this.quickcraftStatus == 2) {
|
||||
if (!this.quickcraftSlots.isEmpty()) {
|
||||
- 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.resetQuickCraft();
|
||||
this.doClick(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman);
|
||||
@@ -433,6 +477,7 @@
|
||||
l = this.getCarried().getCount();
|
||||
Iterator iterator = this.quickcraftSlots.iterator();
|
||||
|
||||
+ Map<Integer, ItemStack> draggedSlots = new HashMap<Integer, ItemStack>(); // CraftBukkit - Store slots from drag in map (raw slot id -> new stack)
|
||||
while (iterator.hasNext()) {
|
||||
Slot slot1 = (Slot) iterator.next();
|
||||
ItemStack itemstack2 = this.getCarried();
|
||||
@@ -443,12 +488,48 @@
|
||||
int l1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1);
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
- itemstack1.setCount(l);
|
||||
- this.setCarried(itemstack1);
|
||||
+ // CraftBukkit start - InventoryDragEvent
|
||||
+ InventoryView view = getBukkitView();
|
||||
+ org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+ newcursor.setAmount(l);
|
||||
+ Map<Integer, org.bukkit.inventory.ItemStack> eventmap = new HashMap<Integer, org.bukkit.inventory.ItemStack>();
|
||||
+ for (Map.Entry<Integer, ItemStack> ditem : draggedSlots.entrySet()) {
|
||||
+ eventmap.put(ditem.getKey(), CraftItemStack.asBukkitCopy(ditem.getValue()));
|
||||
+ }
|
||||
+
|
||||
+ // It's essential that we set the cursor to the new value here to prevent item duplication if a plugin closes the inventory.
|
||||
+ ItemStack oldCursor = this.getCarried();
|
||||
+ 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);
|
||||
+
|
||||
+ // Whether or not a change was made to the inventory that requires an update.
|
||||
+ boolean needsUpdate = event.getResult() != Result.DEFAULT;
|
||||
+
|
||||
+ if (event.getResult() != Result.DENY) {
|
||||
+ for (Map.Entry<Integer, ItemStack> dslot : draggedSlots.entrySet()) {
|
||||
+ view.setItem(dslot.getKey(), CraftItemStack.asBukkitCopy(dslot.getValue()));
|
||||
+ }
|
||||
+ // The only time the carried item will be set to null is if the inventory is closed by the server.
|
||||
+ // If the inventory is closed by the server, then the cursor items are dropped. This is why we change the cursor early.
|
||||
+ if (this.getCarried() != null) {
|
||||
+ this.setCarried(CraftItemStack.asNMSCopy(event.getCursor()));
|
||||
+ needsUpdate = true;
|
||||
+ }
|
||||
+ } else {
|
||||
+ this.setCarried(oldCursor);
|
||||
+ }
|
||||
+
|
||||
+ if (needsUpdate && entityhuman instanceof EntityPlayer) {
|
||||
+ this.sendAllDataToRemote();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
this.resetQuickCraft();
|
||||
@@ -466,8 +547,11 @@
|
||||
if (i == -999) {
|
||||
if (!this.getCarried().isEmpty()) {
|
||||
if (clickaction == ClickAction.PRIMARY) {
|
||||
- entityhuman.drop(this.getCarried(), true);
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack carried = this.getCarried();
|
||||
this.setCarried(ItemStack.EMPTY);
|
||||
+ entityhuman.drop(carried, true);
|
||||
+ // CraftBukkit start
|
||||
} else {
|
||||
entityhuman.drop(this.getCarried().split(1), true);
|
||||
}
|
||||
@@ -530,6 +614,15 @@
|
||||
}
|
||||
|
||||
slot.setChanged();
|
||||
+ // CraftBukkit start - Make sure the client has the right slot contents
|
||||
+ if (entityhuman instanceof EntityPlayer && slot.getMaxStackSize() != 64) {
|
||||
+ ((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.send(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem()));
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
} else {
|
||||
int j2;
|
||||
@@ -662,8 +755,9 @@
|
||||
ItemStack itemstack = this.getCarried();
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
+ this.setCarried(ItemStack.EMPTY); // CraftBukkit - SPIGOT-4556 - from below
|
||||
dropOrPlaceInInventory(entityhuman, itemstack);
|
||||
- this.setCarried(ItemStack.EMPTY);
|
||||
+ // this.setCarried(ItemStack.EMPTY); // CraftBukkit - moved up
|
||||
}
|
||||
|
||||
}
|
||||
@@ -893,6 +987,11 @@
|
||||
}
|
||||
|
||||
public ItemStack getCarried() {
|
||||
+ // CraftBukkit start
|
||||
+ if (this.carried.isEmpty()) {
|
||||
+ this.setCarried(ItemStack.EMPTY);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return this.carried;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerAccess.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerAccess.java
|
||||
@@ -8,6 +8,20 @@
|
||||
|
||||
public interface ContainerAccess {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ default World getWorld() {
|
||||
+ throw new UnsupportedOperationException("Not supported yet.");
|
||||
+ }
|
||||
+
|
||||
+ default BlockPosition getPosition() {
|
||||
+ throw new UnsupportedOperationException("Not supported yet.");
|
||||
+ }
|
||||
+
|
||||
+ default org.bukkit.Location getLocation() {
|
||||
+ return new org.bukkit.Location(getWorld().getWorld(), getPosition().getX(), getPosition().getY(), getPosition().getZ());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
ContainerAccess NULL = new ContainerAccess() {
|
||||
@Override
|
||||
public <T> Optional<T> evaluate(BiFunction<World, BlockPosition, T> bifunction) {
|
||||
@@ -17,6 +31,18 @@
|
||||
|
||||
static ContainerAccess create(final World world, final BlockPosition blockposition) {
|
||||
return new ContainerAccess() {
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public World getWorld() {
|
||||
+ return world;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BlockPosition getPosition() {
|
||||
+ return blockposition;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public <T> Optional<T> evaluate(BiFunction<World, BlockPosition, T> bifunction) {
|
||||
return Optional.of(bifunction.apply(world, blockposition));
|
||||
@@ -0,0 +1,131 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerAnvil.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerAnvil.java
|
||||
@@ -21,6 +21,10 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftAnvilView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerAnvil extends ContainerAnvilAbstract {
|
||||
|
||||
public static final int INPUT_SLOT = 0;
|
||||
@@ -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;
|
||||
+ // CraftBukkit start
|
||||
+ public static final int DEFAULT_DENIED_COST = -1;
|
||||
+ public int maximumRepairCost = 40;
|
||||
+ private CraftAnvilView bukkitEntity;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerAnvil(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -72,7 +81,7 @@
|
||||
|
||||
@Override
|
||||
protected boolean mayPickup(EntityHuman entityhuman, boolean flag) {
|
||||
- return (entityhuman.hasInfiniteMaterials() || entityhuman.experienceLevel >= this.cost.get()) && this.cost.get() > 0;
|
||||
+ return (entityhuman.hasInfiniteMaterials() || entityhuman.experienceLevel >= this.cost.get()) && this.cost.get() > ContainerAnvil.DEFAULT_DENIED_COST && flag; // CraftBukkit - allow cost 0 like a free item
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,7 +103,7 @@
|
||||
this.inputSlots.setItem(1, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
- 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);
|
||||
@@ -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);
|
||||
- this.cost.set(0);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
+ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,8 +167,8 @@
|
||||
this.repairItemCountCost = i1;
|
||||
} else {
|
||||
if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) {
|
||||
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
||||
- this.cost.set(0);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
+ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -233,8 +242,8 @@
|
||||
}
|
||||
|
||||
if (flag2 && !flag1) {
|
||||
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
||||
- this.cost.set(0);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
+ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -260,14 +269,14 @@
|
||||
}
|
||||
|
||||
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) {
|
||||
+ if (this.cost.get() >= maximumRepairCost && !this.player.getAbilities().instabuild) { // CraftBukkit
|
||||
itemstack1 = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@@ -285,12 +294,13 @@
|
||||
EnchantmentManager.setEnchantments(itemstack1, itemenchantments_a.toImmutable());
|
||||
}
|
||||
|
||||
- this.resultSlots.setItem(0, itemstack1);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit
|
||||
this.broadcastChanges();
|
||||
} else {
|
||||
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
||||
- this.cost.set(0);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
+ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
|
||||
}
|
||||
+ sendAllDataToRemote(); // CraftBukkit - SPIGOT-6686, SPIGOT-7931: Always send completed inventory to stay in sync with client
|
||||
}
|
||||
|
||||
public static int calculateIncreasedRepairCost(int i) {
|
||||
@@ -329,4 +339,19 @@
|
||||
public int getCost() {
|
||||
return this.cost.get();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftAnvilView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftInventoryAnvil inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil(
|
||||
+ access.getLocation(), this.inputSlots, this.resultSlots);
|
||||
+ bukkitEntity = new CraftAnvilView(this.player.getBukkitEntity(), inventory, this);
|
||||
+ bukkitEntity.updateFromLegacy(inventory);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java
|
||||
@@ -50,7 +50,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
final ItemCombinerMenuSlotDefinition.b itemcombinermenuslotdefinition_b = (ItemCombinerMenuSlotDefinition.b) iterator.next();
|
||||
|
||||
- this.addSlot(new Slot(this, this.inputSlots, itemcombinermenuslotdefinition_b.slotIndex(), itemcombinermenuslotdefinition_b.x(), itemcombinermenuslotdefinition_b.y()) {
|
||||
+ this.addSlot(new Slot(this.inputSlots, itemcombinermenuslotdefinition_b.slotIndex(), itemcombinermenuslotdefinition_b.x(), itemcombinermenuslotdefinition_b.y()) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemcombinermenuslotdefinition_b.mayPlace().test(itemstack);
|
||||
@@ -110,6 +110,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return (Boolean) this.access.evaluate((world, blockposition) -> {
|
||||
return !this.isValidBlock(world.getBlockState(blockposition)) ? false : entityhuman.canInteractWithBlock(blockposition, 4.0D);
|
||||
}, true);
|
||||
@@ -0,0 +1,72 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerBeacon.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerBeacon.java
|
||||
@@ -13,6 +13,11 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.entity.player.PlayerInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftBeaconView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerBeacon extends Container {
|
||||
|
||||
private static final int PAYMENT_SLOT = 0;
|
||||
@@ -27,6 +32,10 @@
|
||||
private final ContainerBeacon.SlotBeacon paymentSlot;
|
||||
private final ContainerAccess access;
|
||||
private final IContainerProperties beaconData;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftBeaconView bukkitEntity = null;
|
||||
+ private PlayerInventory player;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerBeacon(int i, IInventory iinventory) {
|
||||
this(i, iinventory, new ContainerProperties(3), ContainerAccess.NULL);
|
||||
@@ -34,7 +43,8 @@
|
||||
|
||||
public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) {
|
||||
super(Containers.BEACON, i);
|
||||
- this.beacon = new InventorySubcontainer(this, 1) {
|
||||
+ player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this
|
||||
+ this.beacon = new InventorySubcontainer(1) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean canPlaceItem(int j, ItemStack itemstack) {
|
||||
return itemstack.is(TagsItem.BEACON_PAYMENT_ITEMS);
|
||||
@@ -69,6 +79,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, entityhuman, Blocks.BEACON);
|
||||
}
|
||||
|
||||
@@ -150,8 +161,8 @@
|
||||
|
||||
public void updateEffects(Optional<Holder<MobEffectList>> optional, Optional<Holder<MobEffectList>> optional1) {
|
||||
if (this.paymentSlot.hasItem()) {
|
||||
- this.beaconData.set(1, encodeEffect((Holder) optional.orElse((Object) null)));
|
||||
- this.beaconData.set(2, encodeEffect((Holder) optional1.orElse((Object) null)));
|
||||
+ this.beaconData.set(1, encodeEffect((Holder) optional.orElse(null)));// CraftBukkit - decompile error
|
||||
+ this.beaconData.set(2, encodeEffect((Holder) optional1.orElse(null)));// CraftBukkit - decompile error
|
||||
this.paymentSlot.remove(1);
|
||||
this.access.execute(World::blockEntityChanged);
|
||||
}
|
||||
@@ -178,4 +189,17 @@
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftBeaconView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftInventoryBeacon inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.beacon);
|
||||
+ bukkitEntity = new CraftBeaconView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerBrewingStand.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerBrewingStand.java
|
||||
@@ -17,6 +17,11 @@
|
||||
import net.minecraft.world.item.alchemy.PotionContents;
|
||||
import net.minecraft.world.item.alchemy.PotionRegistry;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftBrewingStandView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerBrewingStand extends Container {
|
||||
|
||||
static final MinecraftKey EMPTY_SLOT_FUEL = MinecraftKey.withDefaultNamespace("container/slot/brewing_fuel");
|
||||
@@ -35,12 +40,18 @@
|
||||
private final IContainerProperties brewingStandData;
|
||||
private final Slot ingredientSlot;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftBrewingStandView bukkitEntity = null;
|
||||
+ private PlayerInventory player;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public ContainerBrewingStand(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, new InventorySubcontainer(5), new ContainerProperties(2));
|
||||
}
|
||||
|
||||
public ContainerBrewingStand(int i, PlayerInventory playerinventory, IInventory iinventory, IContainerProperties icontainerproperties) {
|
||||
super(Containers.BREWING_STAND, i);
|
||||
+ player = playerinventory; // CraftBukkit
|
||||
checkContainerSize(iinventory, 5);
|
||||
checkContainerDataCount(icontainerproperties, 2);
|
||||
this.brewingStand = iinventory;
|
||||
@@ -58,6 +69,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.brewingStand.stillValid(entityhuman);
|
||||
}
|
||||
|
||||
@@ -198,4 +210,17 @@
|
||||
return ContainerBrewingStand.EMPTY_SLOT_FUEL;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftBrewingStandView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryBrewer inventory = new CraftInventoryBrewer(this.brewingStand);
|
||||
+ bukkitEntity = new CraftBrewingStandView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerCartography.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerCartography.java
|
||||
@@ -14,8 +14,30 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.saveddata.maps.WorldMap;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryCartography;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+import org.bukkit.entity.Player;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerCartography extends Container {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryCartography inventory = new CraftInventoryCartography(this.container, this.resultContainer);
|
||||
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
public static final int MAP_SLOT = 0;
|
||||
public static final int ADDITIONAL_SLOT = 1;
|
||||
public static final int RESULT_SLOT = 2;
|
||||
@@ -40,6 +62,13 @@
|
||||
ContainerCartography.this.slotsChanged(this);
|
||||
super.setChanged();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return containeraccess.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.resultContainer = new InventoryCraftResult() {
|
||||
@Override
|
||||
@@ -47,15 +76,22 @@
|
||||
ContainerCartography.this.slotsChanged(this);
|
||||
super.setChanged();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return containeraccess.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.access = containeraccess;
|
||||
- this.addSlot(new Slot(this, this.container, 0, 15, 15) {
|
||||
+ this.addSlot(new Slot(this.container, 0, 15, 15) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.has(DataComponents.MAP_ID);
|
||||
}
|
||||
});
|
||||
- this.addSlot(new Slot(this, this.container, 1, 15, 52) {
|
||||
+ this.addSlot(new Slot(this.container, 1, 15, 52) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.is(Items.PAPER) || itemstack.is(Items.MAP) || itemstack.is(Items.GLASS_PANE);
|
||||
@@ -85,10 +121,12 @@
|
||||
}
|
||||
});
|
||||
this.addStandardInventorySlots(playerinventory, 8, 84);
|
||||
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, entityhuman, Blocks.CARTOGRAPHY_TABLE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerChest.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerChest.java
|
||||
@@ -6,10 +6,39 @@
|
||||
import net.minecraft.world.entity.player.PlayerInventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.InventoryLargeChest;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerChest extends Container {
|
||||
|
||||
private final IInventory container;
|
||||
private final int containerRows;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private PlayerInventory player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventory inventory;
|
||||
+ if (this.container instanceof PlayerInventory) {
|
||||
+ inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryPlayer((PlayerInventory) this.container);
|
||||
+ } else if (this.container instanceof InventoryLargeChest) {
|
||||
+ inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) this.container);
|
||||
+ } else {
|
||||
+ inventory = new CraftInventory(this.container);
|
||||
+ }
|
||||
+
|
||||
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
private ContainerChest(Containers<?> containers, int i, PlayerInventory playerinventory, int j) {
|
||||
this(containers, i, playerinventory, new InventorySubcontainer(9 * j), j);
|
||||
@@ -53,6 +82,9 @@
|
||||
this.container = iinventory;
|
||||
this.containerRows = j;
|
||||
iinventory.startOpen(playerinventory.player);
|
||||
+ // CraftBukkit start - Save player
|
||||
+ this.player = playerinventory;
|
||||
+ // CraftBukkit end
|
||||
boolean flag = true;
|
||||
|
||||
this.addChestGrid(iinventory, 8, 18);
|
||||
@@ -72,6 +104,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.container.stillValid(entityhuman);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerDispenser.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerDispenser.java
|
||||
@@ -6,6 +6,11 @@
|
||||
import net.minecraft.world.entity.player.PlayerInventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerDispenser extends Container {
|
||||
|
||||
private static final int SLOT_COUNT = 9;
|
||||
@@ -14,6 +19,10 @@
|
||||
private static final int USE_ROW_SLOT_START = 36;
|
||||
private static final int USE_ROW_SLOT_END = 45;
|
||||
public final IInventory dispenser;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private PlayerInventory player;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerDispenser(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, new InventorySubcontainer(9));
|
||||
@@ -21,6 +30,10 @@
|
||||
|
||||
public ContainerDispenser(int i, PlayerInventory playerinventory, IInventory iinventory) {
|
||||
super(Containers.GENERIC_3x3, i);
|
||||
+ // CraftBukkit start - Save player
|
||||
+ this.player = playerinventory;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
checkContainerSize(iinventory, 9);
|
||||
this.dispenser = iinventory;
|
||||
iinventory.startOpen(playerinventory.player);
|
||||
@@ -41,6 +54,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.dispenser.stillValid(entityhuman);
|
||||
}
|
||||
|
||||
@@ -82,4 +96,17 @@
|
||||
super.removed(entityhuman);
|
||||
this.dispenser.stopOpen(entityhuman);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventory inventory = new CraftInventory(this.dispenser);
|
||||
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerEnchantTable.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerEnchantTable.java
|
||||
@@ -30,6 +30,19 @@
|
||||
import net.minecraft.world.level.block.BlockEnchantmentTable;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.Map;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftEnchantmentView;
|
||||
+import org.bukkit.enchantments.EnchantmentOffer;
|
||||
+import org.bukkit.event.enchantment.EnchantItemEvent;
|
||||
+import org.bukkit.event.enchantment.PrepareItemEnchantEvent;
|
||||
+import org.bukkit.entity.Player;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerEnchantTable extends Container {
|
||||
|
||||
static final MinecraftKey EMPTY_SLOT_LAPIS_LAZULI = MinecraftKey.withDefaultNamespace("container/slot/lapis_lazuli");
|
||||
@@ -40,6 +53,10 @@
|
||||
public final int[] costs;
|
||||
public final int[] enchantClue;
|
||||
public final int[] levelClue;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftEnchantmentView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerEnchantTable(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -53,6 +70,13 @@
|
||||
super.setChanged();
|
||||
ContainerEnchantTable.this.slotsChanged(this);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return containeraccess.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.random = RandomSource.create();
|
||||
this.enchantmentSeed = ContainerProperty.standalone();
|
||||
@@ -60,13 +84,13 @@
|
||||
this.enchantClue = new int[]{-1, -1, -1};
|
||||
this.levelClue = new int[]{-1, -1, -1};
|
||||
this.access = containeraccess;
|
||||
- this.addSlot(new Slot(this, this.enchantSlots, 0, 15, 47) {
|
||||
+ this.addSlot(new Slot(this.enchantSlots, 0, 15, 47) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
- this.addSlot(new Slot(this, this.enchantSlots, 1, 35, 47) {
|
||||
+ this.addSlot(new Slot(this.enchantSlots, 1, 35, 47) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.is(Items.LAPIS_LAZULI);
|
||||
@@ -88,6 +112,9 @@
|
||||
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
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,7 +122,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().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap();
|
||||
int i = 0;
|
||||
@@ -135,6 +162,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ 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) ? CraftEnchantment.minecraftHolderToBukkit(registry.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.isEnchantable());
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ for (j = 0; j < 3; ++j) {
|
||||
+ this.costs[j] = 0;
|
||||
+ this.enchantClue[j] = -1;
|
||||
+ this.levelClue[j] = -1;
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (j = 0; j < 3; j++) {
|
||||
+ EnchantmentOffer offer = event.getOffers()[j];
|
||||
+ if (offer != null) {
|
||||
+ this.costs[j] = offer.getCost();
|
||||
+ this.enchantClue[j] = registry.getId(CraftEnchantment.bukkitToMinecraftHolder(offer.getEnchantment()));
|
||||
+ this.levelClue[j] = offer.getEnchantmentLevel();
|
||||
+ } else {
|
||||
+ this.costs[j] = 0;
|
||||
+ this.enchantClue[j] = -1;
|
||||
+ this.levelClue[j] = -1;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.broadcastChanges();
|
||||
});
|
||||
} else {
|
||||
@@ -162,21 +224,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().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>();
|
||||
+ for (WeightedRandomEnchant instance : list) {
|
||||
+ enchants.put(CraftEnchantment.minecraftHolderToBukkit(instance.enchantment), instance.level);
|
||||
+ }
|
||||
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2);
|
||||
+
|
||||
+ org.bukkit.enchantments.Enchantment hintedEnchantment = CraftEnchantment.minecraftHolderToBukkit(registry.byId(enchantClue[i]));
|
||||
+ int hintedEnchantmentLevel = levelClue[i];
|
||||
+ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[i], enchants, hintedEnchantment, hintedEnchantmentLevel, i);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ int level = event.getExpLevelCost();
|
||||
+ if (event.isCancelled() || (level > entityhuman.experienceLevel && !entityhuman.getAbilities().instabuild) || event.getEnchantsToAdd().isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (itemstack.is(Items.BOOK)) {
|
||||
itemstack2 = itemstack.transmuteCopy(Items.ENCHANTED_BOOK);
|
||||
this.enchantSlots.setItem(0, itemstack2);
|
||||
}
|
||||
|
||||
- Iterator iterator = list.iterator();
|
||||
-
|
||||
- while (iterator.hasNext()) {
|
||||
- WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) iterator.next();
|
||||
+ // CraftBukkit start
|
||||
+ for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) {
|
||||
+ Holder<Enchantment> nms = CraftEnchantment.bukkitToMinecraftHolder(entry.getKey());
|
||||
+ if (nms == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
|
||||
+ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue());
|
||||
itemstack2.enchant(weightedrandomenchant.enchantment, weightedrandomenchant.level);
|
||||
}
|
||||
|
||||
+ entityhuman.onEnchantmentPerformed(itemstack, j);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ // CraftBukkit - TODO: let plugins change this
|
||||
itemstack1.consume(j, entityhuman);
|
||||
if (itemstack1.isEmpty()) {
|
||||
this.enchantSlots.setItem(1, ItemStack.EMPTY);
|
||||
@@ -243,6 +330,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE);
|
||||
}
|
||||
|
||||
@@ -293,4 +381,17 @@
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftEnchantmentView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryEnchanting inventory = new CraftInventoryEnchanting(this.enchantSlots);
|
||||
+ bukkitEntity = new CraftEnchantmentView(this.player, inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerFurnace.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerFurnace.java
|
||||
@@ -18,6 +18,12 @@
|
||||
import net.minecraft.world.item.crafting.SingleRecipeInput;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// 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 {
|
||||
|
||||
public static final int INGREDIENT_SLOT = 0;
|
||||
@@ -36,6 +42,22 @@
|
||||
private final RecipePropertySet acceptedInputs;
|
||||
private final RecipeBookType recipeBookType;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftFurnaceView bukkitEntity = null;
|
||||
+ private PlayerInventory player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftFurnaceView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryFurnace inventory = new CraftInventoryFurnace((TileEntityFurnace) this.container);
|
||||
+ bukkitEntity = new CraftFurnaceView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
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));
|
||||
}
|
||||
@@ -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
|
||||
this.addStandardInventorySlots(playerinventory, 8, 84);
|
||||
this.addDataSlots(icontainerproperties);
|
||||
}
|
||||
@@ -71,6 +94,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerGrindstone.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerGrindstone.java
|
||||
@@ -20,8 +20,30 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryGrindstone;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+import org.bukkit.entity.Player;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerGrindstone extends Container {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryGrindstone inventory = new CraftInventoryGrindstone(this.repairSlots, this.resultSlots);
|
||||
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
public static final int MAX_NAME_LENGTH = 35;
|
||||
public static final int INPUT_SLOT = 0;
|
||||
public static final int ADDITIONAL_SLOT = 1;
|
||||
@@ -47,15 +69,22 @@
|
||||
super.setChanged();
|
||||
ContainerGrindstone.this.slotsChanged(this);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return containeraccess.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.access = containeraccess;
|
||||
- this.addSlot(new Slot(this, this.repairSlots, 0, 49, 19) {
|
||||
+ this.addSlot(new Slot(this.repairSlots, 0, 49, 19) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.isDamageableItem() || EnchantmentManager.hasAnyEnchantments(itemstack);
|
||||
}
|
||||
});
|
||||
- this.addSlot(new Slot(this, this.repairSlots, 1, 49, 40) {
|
||||
+ this.addSlot(new Slot(this.repairSlots, 1, 49, 40) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.isDamageableItem() || EnchantmentManager.hasAnyEnchantments(itemstack);
|
||||
@@ -113,6 +142,7 @@
|
||||
}
|
||||
});
|
||||
this.addStandardInventorySlots(playerinventory, 8, 84);
|
||||
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,7 +155,8 @@
|
||||
}
|
||||
|
||||
private void createResult() {
|
||||
- this.resultSlots.setItem(0, this.computeResult(this.repairSlots.getItem(0), this.repairSlots.getItem(1)));
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareGrindstoneEvent(getBukkitView(), this.computeResult(this.repairSlots.getItem(0), this.repairSlots.getItem(1))); // CraftBukkit
|
||||
+ sendAllDataToRemote(); // CraftBukkit - SPIGOT-6686: Always send completed inventory to stay in sync with client
|
||||
this.broadcastChanges();
|
||||
}
|
||||
|
||||
@@ -227,6 +258,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, entityhuman, Blocks.GRINDSTONE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerHopper.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerHopper.java
|
||||
@@ -6,11 +6,32 @@
|
||||
import net.minecraft.world.entity.player.PlayerInventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerHopper extends Container {
|
||||
|
||||
public static final int CONTAINER_SIZE = 5;
|
||||
private final IInventory hopper;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private PlayerInventory player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventory inventory = new CraftInventory(this.hopper);
|
||||
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public ContainerHopper(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, new InventorySubcontainer(5));
|
||||
}
|
||||
@@ -18,6 +39,7 @@
|
||||
public ContainerHopper(int i, PlayerInventory playerinventory, IInventory iinventory) {
|
||||
super(Containers.HOPPER, i);
|
||||
this.hopper = iinventory;
|
||||
+ this.player = playerinventory; // CraftBukkit - save player
|
||||
checkContainerSize(iinventory, 5);
|
||||
iinventory.startOpen(playerinventory.player);
|
||||
|
||||
@@ -30,6 +52,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.hopper.stillValid(entityhuman);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerHorse.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerHorse.java
|
||||
@@ -11,6 +11,11 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+import org.bukkit.inventory.InventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerHorse extends Container {
|
||||
|
||||
static final MinecraftKey SADDLE_SLOT_SPRITE = MinecraftKey.withDefaultNamespace("container/slot/saddle");
|
||||
@@ -22,13 +27,28 @@
|
||||
private static final int SLOT_BODY_ARMOR = 1;
|
||||
private static final int SLOT_HORSE_INVENTORY_START = 2;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity;
|
||||
+ PlayerInventory player;
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), horseContainer.getOwner().getInventory(), this);
|
||||
+ }
|
||||
+
|
||||
public ContainerHorse(int i, PlayerInventory playerinventory, IInventory iinventory, final EntityHorseAbstract entityhorseabstract, int j) {
|
||||
super((Containers) null, i);
|
||||
+ player = playerinventory;
|
||||
+ // CraftBukkit end
|
||||
this.horseContainer = iinventory;
|
||||
this.armorContainer = entityhorseabstract.getBodyArmorAccess();
|
||||
this.horse = entityhorseabstract;
|
||||
iinventory.startOpen(playerinventory.player);
|
||||
- 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();
|
||||
@@ -46,7 +66,7 @@
|
||||
});
|
||||
MinecraftKey minecraftkey = entityhorseabstract instanceof EntityLlama ? ContainerHorse.LLAMA_ARMOR_SLOT_SPRITE : ContainerHorse.ARMOR_SLOT_SPRITE;
|
||||
|
||||
- this.addSlot(new ArmorSlot(this, this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, minecraftkey) {
|
||||
+ this.addSlot(new ArmorSlot(this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, minecraftkey) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return entityhorseabstract.isEquippableInSlot(itemstack, EnumItemSlot.BODY);
|
||||
@@ -0,0 +1,84 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerLectern.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerLectern.java
|
||||
@@ -5,8 +5,33 @@
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.level.block.entity.TileEntityLectern.LecternInventory;
|
||||
+import net.minecraft.world.entity.player.PlayerInventory;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryLectern;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftLecternView;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.player.PlayerTakeLecternBookEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerLectern extends Container {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftLecternView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftLecternView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryLectern inventory = new CraftInventoryLectern(this.lectern);
|
||||
+ bukkitEntity = new CraftLecternView(this.player, inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
private static final int DATA_COUNT = 1;
|
||||
private static final int SLOT_COUNT = 1;
|
||||
public static final int BUTTON_PREV_PAGE = 1;
|
||||
@@ -16,11 +41,13 @@
|
||||
private final IInventory lectern;
|
||||
private final IContainerProperties lecternData;
|
||||
|
||||
- public ContainerLectern(int i) {
|
||||
- this(i, new InventorySubcontainer(1), new ContainerProperties(1));
|
||||
+ // CraftBukkit start - add player
|
||||
+ public ContainerLectern(int i, PlayerInventory playerinventory) {
|
||||
+ this(i, new InventorySubcontainer(1), new ContainerProperties(1), playerinventory);
|
||||
}
|
||||
|
||||
- public ContainerLectern(int i, IInventory iinventory, IContainerProperties icontainerproperties) {
|
||||
+ public ContainerLectern(int i, IInventory iinventory, IContainerProperties icontainerproperties, PlayerInventory playerinventory) {
|
||||
+ // CraftBukkit end
|
||||
super(Containers.LECTERN, i);
|
||||
checkContainerSize(iinventory, 1);
|
||||
checkContainerDataCount(icontainerproperties, 1);
|
||||
@@ -34,6 +61,7 @@
|
||||
}
|
||||
});
|
||||
this.addDataSlots(icontainerproperties);
|
||||
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,6 +87,13 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Event for taking the book
|
||||
+ PlayerTakeLecternBookEvent event = new PlayerTakeLecternBookEvent(player, ((CraftInventoryLectern) getBukkitView().getTopInventory()).getHolder());
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack = this.lectern.removeItemNoUpdate(0);
|
||||
|
||||
this.lectern.setChanged();
|
||||
@@ -86,6 +121,8 @@
|
||||
|
||||
@Override
|
||||
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.stillValid(entityhuman);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerLoom.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerLoom.java
|
||||
@@ -23,8 +23,30 @@
|
||||
import net.minecraft.world.level.block.entity.BannerPatternLayers;
|
||||
import net.minecraft.world.level.block.entity.EnumBannerPatternType;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryLoom;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftLoomView;
|
||||
+import org.bukkit.entity.Player;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerLoom extends Container {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftLoomView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftLoomView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryLoom inventory = new CraftInventoryLoom(this.inputContainer, this.outputContainer);
|
||||
+ bukkitEntity = new CraftLoomView(this.player, inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
private static final int PATTERN_NOT_SET = -1;
|
||||
private static final int INV_SLOT_START = 4;
|
||||
private static final int INV_SLOT_END = 31;
|
||||
@@ -60,6 +82,13 @@
|
||||
ContainerLoom.this.slotsChanged(this);
|
||||
ContainerLoom.this.slotUpdateListener.run();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return containeraccess.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.outputContainer = new InventorySubcontainer(1) {
|
||||
@Override
|
||||
@@ -67,21 +96,28 @@
|
||||
super.setChanged();
|
||||
ContainerLoom.this.slotUpdateListener.run();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return containeraccess.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.access = containeraccess;
|
||||
- this.bannerSlot = this.addSlot(new Slot(this, this.inputContainer, 0, 13, 26) {
|
||||
+ this.bannerSlot = this.addSlot(new Slot(this.inputContainer, 0, 13, 26) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.getItem() instanceof ItemBanner;
|
||||
}
|
||||
});
|
||||
- this.dyeSlot = this.addSlot(new Slot(this, this.inputContainer, 1, 33, 26) {
|
||||
+ this.dyeSlot = this.addSlot(new Slot(this.inputContainer, 1, 33, 26) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.getItem() instanceof ItemDye;
|
||||
}
|
||||
});
|
||||
- this.patternSlot = this.addSlot(new Slot(this, this.inputContainer, 2, 23, 45) {
|
||||
+ this.patternSlot = this.addSlot(new Slot(this.inputContainer, 2, 23, 45) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.getItem() instanceof ItemBannerPattern;
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, entityhuman, Blocks.LOOM);
|
||||
}
|
||||
|
||||
@@ -294,6 +332,11 @@
|
||||
EnumColor enumcolor = ((ItemDye) itemstack1.getItem()).getDyeColor();
|
||||
|
||||
itemstack2.update(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY, (bannerpatternlayers) -> {
|
||||
+ // CraftBukkit start
|
||||
+ if (bannerpatternlayers.layers().size() > 20) {
|
||||
+ bannerpatternlayers = new BannerPatternLayers(List.copyOf(bannerpatternlayers.layers().subList(0, 20)));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return (new BannerPatternLayers.a()).addAll(bannerpatternlayers).add(holder, enumcolor).build();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerMerchant.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerMerchant.java
|
||||
@@ -13,6 +13,8 @@
|
||||
import net.minecraft.world.item.trading.MerchantRecipe;
|
||||
import net.minecraft.world.item.trading.MerchantRecipeList;
|
||||
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftMerchantView; // CraftBukkit
|
||||
+
|
||||
public class ContainerMerchant extends Container {
|
||||
|
||||
protected static final int PAYMENT1_SLOT = 0;
|
||||
@@ -32,6 +34,19 @@
|
||||
private boolean showProgressBar;
|
||||
private boolean canRestock;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftMerchantView bukkitEntity = null;
|
||||
+ private PlayerInventory player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftMerchantView getBukkitView() {
|
||||
+ if (bukkitEntity == null) {
|
||||
+ bukkitEntity = new CraftMerchantView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(trader, tradeContainer), this, trader);
|
||||
+ }
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public ContainerMerchant(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, new MerchantWrapper(playerinventory.player));
|
||||
}
|
||||
@@ -43,6 +58,7 @@
|
||||
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
|
||||
this.addStandardInventorySlots(playerinventory, 108, 84);
|
||||
}
|
||||
|
||||
@@ -143,7 +159,7 @@
|
||||
}
|
||||
|
||||
private void playTradeSound() {
|
||||
- if (!this.trader.isClientSide()) {
|
||||
+ if (!this.trader.isClientSide() && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035
|
||||
Entity entity = (Entity) this.trader;
|
||||
|
||||
entity.level().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), this.trader.getNotifyTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false);
|
||||
@@ -0,0 +1,59 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerPlayer.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerPlayer.java
|
||||
@@ -12,6 +12,12 @@
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.network.chat.IChatBaseComponent;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerPlayer extends AbstractCraftingMenu {
|
||||
|
||||
public static final int CONTAINER_ID = 0;
|
||||
@@ -38,9 +44,15 @@
|
||||
private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
|
||||
public final boolean active;
|
||||
private final EntityHuman owner;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerPlayer(PlayerInventory playerinventory, boolean flag, final EntityHuman entityhuman) {
|
||||
- super((Containers) null, 0, 2, 2);
|
||||
+ // CraftBukkit start
|
||||
+ 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.active = flag;
|
||||
this.owner = entityhuman;
|
||||
this.addResultSlot(entityhuman, 154, 28);
|
||||
@@ -54,7 +66,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);
|
||||
@@ -190,4 +202,17 @@
|
||||
protected EntityHuman owner() {
|
||||
return this.owner;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots);
|
||||
+ bukkitEntity = new CraftInventoryView(this.owner.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerShulkerBox.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerShulkerBox.java
|
||||
@@ -6,10 +6,29 @@
|
||||
import net.minecraft.world.entity.player.PlayerInventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerShulkerBox extends Container {
|
||||
|
||||
private static final int CONTAINER_SIZE = 27;
|
||||
private final IInventory container;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity;
|
||||
+ private PlayerInventory player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new CraftInventory(this.container), this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerShulkerBox(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, new InventorySubcontainer(27));
|
||||
@@ -19,6 +38,7 @@
|
||||
super(Containers.SHULKER_BOX, i);
|
||||
checkContainerSize(iinventory, 27);
|
||||
this.container = iinventory;
|
||||
+ this.player = playerinventory; // CraftBukkit - save player
|
||||
iinventory.startOpen(playerinventory.player);
|
||||
boolean flag = true;
|
||||
boolean flag1 = true;
|
||||
@@ -34,6 +54,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.container.stillValid(entityhuman);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerSmithing.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerSmithing.java
|
||||
@@ -18,6 +18,8 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
|
||||
+
|
||||
public class ContainerSmithing extends ContainerAnvilAbstract {
|
||||
|
||||
public static final int TEMPLATE_SLOT = 0;
|
||||
@@ -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);
|
||||
@@ -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 (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());
|
||||
|
||||
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
|
||||
+ @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
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerStonecutter.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerStonecutter.java
|
||||
@@ -17,6 +17,13 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryStonecutter;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftStonecutterView;
|
||||
+import org.bukkit.entity.Player;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerStonecutter extends Container {
|
||||
|
||||
public static final int INPUT_SLOT = 0;
|
||||
@@ -36,6 +43,21 @@
|
||||
Runnable slotUpdateListener;
|
||||
public final IInventory container;
|
||||
final InventoryCraftResult resultContainer;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftStonecutterView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftStonecutterView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.container, this.resultContainer);
|
||||
+ bukkitEntity = new CraftStonecutterView(this.player, inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerStonecutter(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -55,6 +77,13 @@
|
||||
ContainerStonecutter.this.slotsChanged(this);
|
||||
ContainerStonecutter.this.slotUpdateListener.run();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return containeraccess.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.resultContainer = new InventoryCraftResult();
|
||||
this.access = containeraccess;
|
||||
@@ -94,6 +123,7 @@
|
||||
});
|
||||
this.addStandardInventorySlots(playerinventory, 8, 84);
|
||||
this.addDataSlot(this.selectedRecipeIndex);
|
||||
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
|
||||
}
|
||||
|
||||
public int getSelectedRecipeIndex() {
|
||||
@@ -114,6 +144,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, entityhuman, Blocks.STONECUTTER);
|
||||
}
|
||||
|
||||
@@ -158,7 +189,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);
|
||||
@@ -0,0 +1,75 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerWorkbench.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerWorkbench.java
|
||||
@@ -16,6 +16,12 @@
|
||||
import net.minecraft.world.item.crafting.Recipes;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.item.crafting.RecipeRepair;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerWorkbench extends AbstractCraftingMenu {
|
||||
|
||||
private static final int CRAFTING_GRID_WIDTH = 3;
|
||||
@@ -31,13 +37,16 @@
|
||||
public final ContainerAccess access;
|
||||
private final EntityHuman player;
|
||||
private boolean placingRecipe;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerWorkbench(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
}
|
||||
|
||||
public ContainerWorkbench(int i, PlayerInventory playerinventory, ContainerAccess containeraccess) {
|
||||
- super(Containers.CRAFTING, i, 3, 3);
|
||||
+ super(Containers.CRAFTING, i, 3, 3, playerinventory); // CraftBukkit - pass player
|
||||
this.access = containeraccess;
|
||||
this.player = playerinventory.player;
|
||||
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();
|
||||
@@ -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
|
||||
|
||||
inventorycraftresult.setItem(0, itemstack);
|
||||
container.setRemoteSlot(0, itemstack);
|
||||
@@ -103,6 +114,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE);
|
||||
}
|
||||
|
||||
@@ -181,4 +193,17 @@
|
||||
protected EntityHuman owner() {
|
||||
return this.player;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots);
|
||||
+ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/world/inventory/Containers.java
|
||||
+++ b/net/minecraft/world/inventory/Containers.java
|
||||
@@ -8,6 +8,10 @@
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.entity.player.PlayerInventory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class Containers<T extends Container> implements FeatureElement {
|
||||
|
||||
public static final Containers<ContainerChest> GENERIC_9x1 = register("generic_9x1", ContainerChest::oneRow);
|
||||
@@ -28,7 +32,7 @@
|
||||
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 = register("loom", ContainerLoom::new);
|
||||
public static final Containers<ContainerMerchant> MERCHANT = register("merchant", ContainerMerchant::new);
|
||||
@@ -0,0 +1,38 @@
|
||||
--- a/net/minecraft/world/inventory/CrafterMenu.java
|
||||
+++ b/net/minecraft/world/inventory/CrafterMenu.java
|
||||
@@ -10,8 +10,27 @@
|
||||
import net.minecraft.world.item.crafting.RecipeCrafting;
|
||||
import net.minecraft.world.level.block.CrafterBlock;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafter;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftCrafterView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class CrafterMenu extends Container implements ICrafting {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftCrafterView bukkitEntity = null;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftCrafterView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryCrafter inventory = new CraftInventoryCrafter(this.container, this.resultContainer);
|
||||
+ bukkitEntity = new CraftCrafterView(this.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
protected static final int SLOT_COUNT = 9;
|
||||
private static final int INV_SLOT_START = 9;
|
||||
private static final int INV_SLOT_END = 36;
|
||||
@@ -106,6 +125,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.container.stillValid(entityhuman);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
--- a/net/minecraft/world/inventory/InventoryCraftResult.java
|
||||
+++ b/net/minecraft/world/inventory/InventoryCraftResult.java
|
||||
@@ -9,12 +9,51 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class InventoryCraftResult implements IInventory, RecipeCraftingHolder {
|
||||
|
||||
private final NonNullList<ItemStack> itemStacks;
|
||||
@Nullable
|
||||
private RecipeHolder<?> recipeUsed;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+
|
||||
+ public java.util.List<ItemStack> getContents() {
|
||||
+ return this.itemStacks;
|
||||
+ }
|
||||
+
|
||||
+ public org.bukkit.inventory.InventoryHolder getOwner() {
|
||||
+ return null; // Result slots don't get an owner
|
||||
+ }
|
||||
+
|
||||
+ // Don't need a transaction; the InventoryCrafting keeps track of it for us
|
||||
+ public void onOpen(CraftHumanEntity who) {}
|
||||
+ public void onClose(CraftHumanEntity who) {}
|
||||
+ public java.util.List<HumanEntity> getViewers() {
|
||||
+ return new java.util.ArrayList<HumanEntity>();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public InventoryCraftResult() {
|
||||
this.itemStacks = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/world/inventory/InventoryCrafting.java
|
||||
+++ b/net/minecraft/world/inventory/InventoryCrafting.java
|
||||
@@ -5,6 +5,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingInput;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public interface InventoryCrafting extends IInventory, AutoRecipeOutput {
|
||||
|
||||
int getWidth();
|
||||
@@ -13,6 +17,15 @@
|
||||
|
||||
List<ItemStack> getItems();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ default RecipeHolder<?> getCurrentRecipe() {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ default void setCurrentRecipe(RecipeHolder<?> recipe) {
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
default CraftingInput asCraftInput() {
|
||||
return this.asPositionedCraftInput().input();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
--- a/net/minecraft/world/inventory/InventoryEnderChest.java
|
||||
+++ b/net/minecraft/world/inventory/InventoryEnderChest.java
|
||||
@@ -9,13 +9,32 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.TileEntityEnderChest;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.inventory.InventoryHolder;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class InventoryEnderChest extends InventorySubcontainer {
|
||||
|
||||
@Nullable
|
||||
private TileEntityEnderChest activeChest;
|
||||
+ // CraftBukkit start
|
||||
+ private final EntityHuman owner;
|
||||
|
||||
- public InventoryEnderChest() {
|
||||
+ public InventoryHolder getBukkitOwner() {
|
||||
+ return owner.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return this.activeChest != null ? CraftLocation.toBukkit(this.activeChest.getBlockPos(), this.activeChest.getLevel().getWorld()) : null;
|
||||
+ }
|
||||
+
|
||||
+ public InventoryEnderChest(EntityHuman owner) {
|
||||
super(27);
|
||||
+ this.owner = owner;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void setActiveChest(TileEntityEnderChest tileentityenderchest) {
|
||||
@@ -0,0 +1,66 @@
|
||||
--- a/net/minecraft/world/inventory/InventoryMerchant.java
|
||||
+++ b/net/minecraft/world/inventory/InventoryMerchant.java
|
||||
@@ -11,6 +11,16 @@
|
||||
import net.minecraft.world.item.trading.MerchantRecipe;
|
||||
import net.minecraft.world.item.trading.MerchantRecipeList;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.List;
|
||||
+import net.minecraft.world.entity.npc.EntityVillager;
|
||||
+import net.minecraft.world.entity.npc.EntityVillagerAbstract;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.entity.CraftAbstractVillager;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class InventoryMerchant implements IInventory {
|
||||
|
||||
private final IMerchant merchant;
|
||||
@@ -20,6 +30,46 @@
|
||||
public int selectionHint;
|
||||
private int futureXp;
|
||||
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return this.itemStacks;
|
||||
+ }
|
||||
+
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ merchant.setTradingPlayer((EntityHuman) null); // SPIGOT-4860
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int i) {
|
||||
+ maxStack = i;
|
||||
+ }
|
||||
+
|
||||
+ public org.bukkit.inventory.InventoryHolder getOwner() {
|
||||
+ return (merchant instanceof EntityVillagerAbstract) ? (CraftAbstractVillager) ((EntityVillagerAbstract) this.merchant).getBukkitEntity() : null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return (merchant instanceof EntityVillager) ? ((EntityVillager) this.merchant).getBukkitEntity().getLocation() : null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public InventoryMerchant(IMerchant imerchant) {
|
||||
this.itemStacks = NonNullList.withSize(3, ItemStack.EMPTY);
|
||||
this.merchant = imerchant;
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/inventory/SlotFurnaceResult.java
|
||||
+++ b/net/minecraft/world/inventory/SlotFurnaceResult.java
|
||||
@@ -51,7 +51,7 @@
|
||||
IInventory iinventory = this.container;
|
||||
|
||||
if (iinventory instanceof TileEntityFurnace tileentityfurnace) {
|
||||
- tileentityfurnace.awardUsedRecipesAndPopExperience(entityplayer);
|
||||
+ tileentityfurnace.awardUsedRecipesAndPopExperience(entityplayer, itemstack, this.removeCount); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
--- a/net/minecraft/world/inventory/TransientCraftingContainer.java
|
||||
+++ b/net/minecraft/world/inventory/TransientCraftingContainer.java
|
||||
@@ -8,6 +8,16 @@
|
||||
import net.minecraft.world.entity.player.StackedItemContents;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.List;
|
||||
+import net.minecraft.world.IInventory;
|
||||
+import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.event.inventory.InventoryType;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TransientCraftingContainer implements InventoryCrafting {
|
||||
|
||||
private final NonNullList<ItemStack> items;
|
||||
@@ -15,6 +25,68 @@
|
||||
private final int height;
|
||||
private final Container menu;
|
||||
|
||||
+ // CraftBukkit start - add fields
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private RecipeHolder<?> currentRecipe;
|
||||
+ public IInventory resultInventory;
|
||||
+ private EntityHuman owner;
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return this.items;
|
||||
+ }
|
||||
+
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public InventoryType getInvType() {
|
||||
+ return items.size() == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH;
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ public org.bukkit.inventory.InventoryHolder getOwner() {
|
||||
+ return (owner == null) ? null : owner.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ resultInventory.setMaxStackSize(size);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return menu instanceof ContainerWorkbench ? ((ContainerWorkbench) menu).access.getLocation() : owner.getBukkitEntity().getLocation();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public RecipeHolder<?> getCurrentRecipe() {
|
||||
+ return currentRecipe;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCurrentRecipe(RecipeHolder<?> currentRecipe) {
|
||||
+ this.currentRecipe = currentRecipe;
|
||||
+ }
|
||||
+
|
||||
+ public TransientCraftingContainer(Container container, int i, int j, EntityHuman player) {
|
||||
+ this(container, i, j);
|
||||
+ this.owner = player;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
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