Remap CraftBukkit to Mojang+Yarn Mappings
By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
@@ -1,15 +1,22 @@
|
||||
--- 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;
|
||||
--- a/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||
+++ b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||
@@ -21,6 +21,8 @@
|
||||
import net.minecraft.ReportedException;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.network.chat.Component;
|
||||
+import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.Container;
|
||||
@@ -35,6 +37,18 @@
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
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;
|
||||
@@ -18,37 +25,37 @@
|
||||
+import org.bukkit.inventory.InventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class Container {
|
||||
public abstract class AbstractContainerMenu {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -67,6 +81,27 @@
|
||||
@@ -66,6 +80,27 @@
|
||||
@Nullable
|
||||
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) {
|
||||
+ public void transferTo(AbstractContainerMenu 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() {
|
||||
+ private Component title;
|
||||
+ public final Component getTitle() {
|
||||
+ Preconditions.checkState(this.title != null, "Title not set");
|
||||
+ return this.title;
|
||||
+ }
|
||||
+ public final void setTitle(IChatBaseComponent title) {
|
||||
+ public final void setTitle(Component title) {
|
||||
+ Preconditions.checkState(this.title == null, "Title already set");
|
||||
+ this.title = title;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected Container(@Nullable Containers<?> containers, int i) {
|
||||
|
||||
protected AbstractContainerMenu(@Nullable MenuType<?> type, int syncId) {
|
||||
this.carried = ItemStack.EMPTY;
|
||||
this.remoteSlots = NonNullList.create();
|
||||
@@ -192,6 +227,15 @@
|
||||
|
||||
}
|
||||
@@ -62,8 +69,8 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void removeSlotListener(ICrafting icrafting) {
|
||||
this.containerListeners.remove(icrafting);
|
||||
public void removeSlotListener(ContainerListener listener) {
|
||||
this.containerListeners.remove(listener);
|
||||
}
|
||||
@@ -417,7 +461,7 @@
|
||||
}
|
||||
@@ -73,7 +80,7 @@
|
||||
+ 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);
|
||||
this.doClick(k, this.quickcraftType, ClickType.PICKUP, player);
|
||||
@@ -433,6 +477,7 @@
|
||||
l = this.getCarried().getCount();
|
||||
Iterator iterator = this.quickcraftSlots.iterator();
|
||||
@@ -83,7 +90,7 @@
|
||||
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);
|
||||
int l1 = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1);
|
||||
|
||||
l -= l1 - j1;
|
||||
- slot1.setByPlayer(itemstack1.copyWithCount(l1));
|
||||
@@ -95,7 +102,7 @@
|
||||
- itemstack1.setCount(l);
|
||||
- this.setCarried(itemstack1);
|
||||
+ // CraftBukkit start - InventoryDragEvent
|
||||
+ InventoryView view = getBukkitView();
|
||||
+ InventoryView view = this.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>();
|
||||
@@ -108,7 +115,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);
|
||||
+ player.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;
|
||||
@@ -127,7 +134,7 @@
|
||||
+ this.setCarried(oldCursor);
|
||||
+ }
|
||||
+
|
||||
+ if (needsUpdate && entityhuman instanceof EntityPlayer) {
|
||||
+ if (needsUpdate && player instanceof ServerPlayer) {
|
||||
+ this.sendAllDataToRemote();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@@ -135,28 +142,28 @@
|
||||
|
||||
this.resetQuickCraft();
|
||||
@@ -466,8 +547,11 @@
|
||||
if (i == -999) {
|
||||
if (slotIndex == -999) {
|
||||
if (!this.getCarried().isEmpty()) {
|
||||
if (clickaction == ClickAction.PRIMARY) {
|
||||
- entityhuman.drop(this.getCarried(), true);
|
||||
- player.drop(this.getCarried(), true);
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack carried = this.getCarried();
|
||||
this.setCarried(ItemStack.EMPTY);
|
||||
+ entityhuman.drop(carried, true);
|
||||
+ player.drop(carried, true);
|
||||
+ // CraftBukkit start
|
||||
} else {
|
||||
entityhuman.drop(this.getCarried().split(1), true);
|
||||
player.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()));
|
||||
+ if (player instanceof ServerPlayer && slot.getMaxStackSize() != 64) {
|
||||
+ ((ServerPlayer) player).connection.send(new ClientboundContainerSetSlotPacket(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()));
|
||||
+ ((ServerPlayer) player).connection.send(new ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem()));
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@@ -168,7 +175,7 @@
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
+ this.setCarried(ItemStack.EMPTY); // CraftBukkit - SPIGOT-4556 - from below
|
||||
dropOrPlaceInInventory(entityhuman, itemstack);
|
||||
AbstractContainerMenu.dropOrPlaceInInventory(player, itemstack);
|
||||
- this.setCarried(ItemStack.EMPTY);
|
||||
+ // this.setCarried(ItemStack.EMPTY); // CraftBukkit - moved up
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
--- 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 CraftingContainer craftSlots;
|
||||
+ public final TransientCraftingContainer craftSlots; // CraftBukkit
|
||||
public final ResultContainer resultSlots = new ResultContainer();
|
||||
|
||||
- public AbstractCraftingMenu(MenuType<?> type, int syncId, int width, int height) {
|
||||
- super(type, syncId);
|
||||
- this.width = width;
|
||||
- this.height = height;
|
||||
- this.craftSlots = new TransientCraftingContainer(this, width, height);
|
||||
+ public AbstractCraftingMenu(MenuType<?> containers, int i, int j, int k, Inventory playerInventory) { // CraftBukkit
|
||||
+ super(containers, i);
|
||||
+ this.width = j;
|
||||
+ this.height = 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(Player player, int x, int y) {
|
||||
@@ -38,7 +41,7 @@
|
||||
|
||||
@Override
|
||||
public RecipeBookMenu.PostPlaceAction handlePlacement(boolean craftAll, boolean creative, RecipeHolder<?> recipe, ServerLevel world, Inventory inventory) {
|
||||
- RecipeHolder<CraftingRecipe> recipeholder1 = recipe;
|
||||
+ RecipeHolder<CraftingRecipe> recipeholder1 = (RecipeHolder<CraftingRecipe>) recipe; // CraftBukkit - decompile error
|
||||
|
||||
this.beginPlacingRecipe();
|
||||
|
||||
@@ -65,7 +68,7 @@
|
||||
}
|
||||
}, this.width, this.height, list, list, inventory, recipeholder1, craftAll, creative);
|
||||
} finally {
|
||||
- this.finishPlacingRecipe(world, recipe);
|
||||
+ this.finishPlacingRecipe(world, recipeholder1); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
return containerrecipebook_a;
|
||||
@@ -1,41 +0,0 @@
|
||||
--- 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,60 @@
|
||||
--- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java
|
||||
+++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java
|
||||
@@ -17,6 +17,10 @@
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.item.crafting.SingleRecipeInput;
|
||||
import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftFurnaceView;
|
||||
+// CraftBukkit end
|
||||
|
||||
public abstract class AbstractFurnaceMenu extends RecipeBookMenu {
|
||||
|
||||
@@ -36,6 +40,22 @@
|
||||
private final RecipePropertySet acceptedInputs;
|
||||
private final RecipeBookType recipeBookType;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftFurnaceView bukkitEntity = null;
|
||||
+ private Inventory player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftFurnaceView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryFurnace inventory = new CraftInventoryFurnace((AbstractFurnaceBlockEntity) this.container);
|
||||
+ this.bukkitEntity = new CraftFurnaceView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected AbstractFurnaceMenu(MenuType<?> type, RecipeType<? extends AbstractCookingRecipe> recipeType, ResourceKey<RecipePropertySet> recipePropertySetKey, RecipeBookType category, int syncId, Inventory platerInventory) {
|
||||
this(type, recipeType, recipePropertySetKey, category, syncId, platerInventory, new SimpleContainer(3), new SimpleContainerData(4));
|
||||
}
|
||||
@@ -53,6 +73,7 @@
|
||||
this.addSlot(new Slot(inventory, 0, 56, 17));
|
||||
this.addSlot(new FurnaceFuelSlot(this, inventory, 1, 56, 53));
|
||||
this.addSlot(new FurnaceResultSlot(platerInventory.player, inventory, 2, 116, 35));
|
||||
+ this.player = platerInventory; // CraftBukkit - save player
|
||||
this.addStandardInventorySlots(platerInventory, 8, 84);
|
||||
this.addDataSlots(propertyDelegate);
|
||||
}
|
||||
@@ -71,6 +92,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.container.stillValid(player);
|
||||
}
|
||||
|
||||
@@ -180,6 +202,6 @@
|
||||
public boolean recipeMatches(RecipeHolder<AbstractCookingRecipe> entry) {
|
||||
return ((AbstractCookingRecipe) entry.value()).matches(new SingleRecipeInput(AbstractFurnaceMenu.this.container.getItem(0)), world);
|
||||
}
|
||||
- }, 1, 1, List.of(this.getSlot(0)), list, inventory, recipe, craftAll, creative);
|
||||
+ }, 1, 1, List.of(this.getSlot(0)), list, inventory, (RecipeHolder<AbstractCookingRecipe>) recipe, craftAll, creative); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerAnvil.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerAnvil.java
|
||||
--- a/net/minecraft/world/inventory/AnvilMenu.java
|
||||
+++ b/net/minecraft/world/inventory/AnvilMenu.java
|
||||
@@ -21,6 +21,10 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftAnvilView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerAnvil extends ContainerAnvilAbstract {
|
||||
public class AnvilMenu extends ItemCombinerMenu {
|
||||
|
||||
public static final int INPUT_SLOT = 0;
|
||||
@@ -45,6 +49,11 @@
|
||||
@@ -21,14 +21,14 @@
|
||||
+ private CraftAnvilView bukkitEntity;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerAnvil(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
public AnvilMenu(int syncId, Inventory inventory) {
|
||||
this(syncId, inventory, ContainerLevelAccess.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
|
||||
protected boolean mayPickup(Player player, boolean present) {
|
||||
- return (player.hasInfiniteMaterials() || player.experienceLevel >= this.cost.get()) && this.cost.get() > 0;
|
||||
+ return (player.hasInfiniteMaterials() || player.experienceLevel >= this.cost.get()) && this.cost.get() > AnvilMenu.DEFAULT_DENIED_COST && present; // CraftBukkit - allow cost 0 like a free item
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,18 +37,18 @@
|
||||
}
|
||||
|
||||
- this.cost.set(0);
|
||||
+ this.cost.set(DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
|
||||
+ this.cost.set(AnvilMenu.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);
|
||||
BlockState 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
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(this.getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
+ this.cost.set(AnvilMenu.DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@
|
||||
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
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(this.getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
+ this.cost.set(AnvilMenu.DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,8 +69,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
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(this.getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
+ this.cost.set(AnvilMenu.DEFAULT_DENIED_COST); // CraftBukkit - use a variable for set a cost for denied item
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -80,35 +80,35 @@
|
||||
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
|
||||
+ if (this.cost.get() >= this.maximumRepairCost) { // CraftBukkit
|
||||
+ this.cost.set(this.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
|
||||
+ if (this.cost.get() >= this.maximumRepairCost && !this.player.getAbilities().instabuild) { // CraftBukkit
|
||||
itemstack1 = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@@ -285,12 +294,13 @@
|
||||
EnchantmentManager.setEnchantments(itemstack1, itemenchantments_a.toImmutable());
|
||||
EnchantmentHelper.setEnchantments(itemstack1, itemenchantments_a.toImmutable());
|
||||
}
|
||||
|
||||
- this.resultSlots.setItem(0, itemstack1);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(this.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
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(this.getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
+ this.cost.set(AnvilMenu.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
|
||||
+ this.sendAllDataToRemote(); // CraftBukkit - SPIGOT-6686, SPIGOT-7931: Always send completed inventory to stay in sync with client
|
||||
}
|
||||
|
||||
public static int calculateIncreasedRepairCost(int i) {
|
||||
public static int calculateIncreasedRepairCost(int cost) {
|
||||
@@ -329,4 +339,19 @@
|
||||
public int getCost() {
|
||||
return this.cost.get();
|
||||
@@ -117,15 +117,15 @@
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftAnvilView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.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;
|
||||
+ this.access.getLocation(), this.inputSlots, this.resultSlots);
|
||||
+ this.bukkitEntity = new CraftAnvilView(this.player.getBukkitEntity(), inventory, this);
|
||||
+ this.bukkitEntity.updateFromLegacy(inventory);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
--- a/net/minecraft/world/inventory/BeaconMenu.java
|
||||
+++ b/net/minecraft/world/inventory/BeaconMenu.java
|
||||
@@ -8,10 +8,13 @@
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
+import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftBeaconView;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class BeaconMenu extends AbstractContainerMenu {
|
||||
|
||||
@@ -27,6 +30,10 @@
|
||||
private final BeaconMenu.PaymentSlot paymentSlot;
|
||||
private final ContainerLevelAccess access;
|
||||
private final ContainerData beaconData;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftBeaconView bukkitEntity = null;
|
||||
+ private Inventory player;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public BeaconMenu(int syncId, Container inventory) {
|
||||
this(syncId, inventory, new SimpleContainerData(3), ContainerLevelAccess.NULL);
|
||||
@@ -34,7 +41,8 @@
|
||||
|
||||
public BeaconMenu(int syncId, Container inventory, ContainerData propertyDelegate, ContainerLevelAccess context) {
|
||||
super(MenuType.BEACON, syncId);
|
||||
- this.beacon = new SimpleContainer(this, 1) {
|
||||
+ this.player = (Inventory) inventory; // CraftBukkit - TODO: check this
|
||||
+ this.beacon = new SimpleContainer(1) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean canPlaceItem(int slot, ItemStack stack) {
|
||||
return stack.is(ItemTags.BEACON_PAYMENT_ITEMS);
|
||||
@@ -69,6 +77,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, player, Blocks.BEACON);
|
||||
}
|
||||
|
||||
@@ -150,8 +159,8 @@
|
||||
|
||||
public void updateEffects(Optional<Holder<MobEffect>> primary, Optional<Holder<MobEffect>> secondary) {
|
||||
if (this.paymentSlot.hasItem()) {
|
||||
- this.beaconData.set(1, BeaconMenu.encodeEffect((Holder) primary.orElse((Object) null)));
|
||||
- this.beaconData.set(2, BeaconMenu.encodeEffect((Holder) secondary.orElse((Object) null)));
|
||||
+ this.beaconData.set(1, BeaconMenu.encodeEffect((Holder) primary.orElse(null)));// CraftBukkit - decompile error
|
||||
+ this.beaconData.set(2, BeaconMenu.encodeEffect((Holder) secondary.orElse(null)));// CraftBukkit - decompile error
|
||||
this.paymentSlot.remove(1);
|
||||
this.access.execute(Level::blockEntityChanged);
|
||||
}
|
||||
@@ -178,4 +187,17 @@
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftBeaconView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftInventoryBeacon inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.beacon);
|
||||
+ this.bukkitEntity = new CraftBeaconView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
--- a/net/minecraft/world/inventory/BrewingStandMenu.java
|
||||
+++ b/net/minecraft/world/inventory/BrewingStandMenu.java
|
||||
@@ -16,6 +16,10 @@
|
||||
import net.minecraft.world.item.alchemy.Potion;
|
||||
import net.minecraft.world.item.alchemy.PotionBrewing;
|
||||
import net.minecraft.world.item.alchemy.PotionContents;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftBrewingStandView;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class BrewingStandMenu extends AbstractContainerMenu {
|
||||
|
||||
@@ -35,12 +39,18 @@
|
||||
public final ContainerData brewingStandData;
|
||||
private final Slot ingredientSlot;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftBrewingStandView bukkitEntity = null;
|
||||
+ private Inventory player;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public BrewingStandMenu(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, new SimpleContainer(5), new SimpleContainerData(2));
|
||||
}
|
||||
|
||||
public BrewingStandMenu(int syncId, Inventory playerInventory, Container inventory, ContainerData propertyDelegate) {
|
||||
super(MenuType.BREWING_STAND, syncId);
|
||||
+ this.player = playerInventory; // CraftBukkit
|
||||
checkContainerSize(inventory, 5);
|
||||
checkContainerDataCount(propertyDelegate, 2);
|
||||
this.brewingStand = inventory;
|
||||
@@ -58,6 +68,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.brewingStand.stillValid(player);
|
||||
}
|
||||
|
||||
@@ -198,4 +209,17 @@
|
||||
return BrewingStandMenu.EMPTY_SLOT_FUEL;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftBrewingStandView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryBrewer inventory = new CraftInventoryBrewer(this.brewingStand);
|
||||
+ this.bukkitEntity = new CraftBrewingStandView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
--- a/net/minecraft/world/inventory/CartographyTableMenu.java
|
||||
+++ b/net/minecraft/world/inventory/CartographyTableMenu.java
|
||||
@@ -6,16 +6,36 @@
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
-import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.MapItem;
|
||||
import net.minecraft.world.item.component.MapPostProcessing;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
|
||||
+// 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 CartographyTableMenu extends AbstractContainerMenu {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryCartography inventory = new CraftInventoryCartography(this.container, this.resultContainer);
|
||||
+ this.bukkitEntity = new CraftInventoryView(this.player, inventory, this);
|
||||
+ return this.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 +60,13 @@
|
||||
CartographyTableMenu.this.slotsChanged(this);
|
||||
super.setChanged();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return context.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.resultContainer = new ResultContainer() {
|
||||
@Override
|
||||
@@ -47,15 +74,22 @@
|
||||
CartographyTableMenu.this.slotsChanged(this);
|
||||
super.setChanged();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return context.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.access = context;
|
||||
- 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 stack) {
|
||||
return stack.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 stack) {
|
||||
return stack.is(Items.PAPER) || stack.is(Items.MAP) || stack.is(Items.GLASS_PANE);
|
||||
@@ -68,7 +102,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void onTake(Player player, ItemStack stack) {
|
||||
+ public void onTake(net.minecraft.world.entity.player.Player player, ItemStack stack) {
|
||||
((Slot) CartographyTableMenu.this.slots.get(0)).remove(1);
|
||||
((Slot) CartographyTableMenu.this.slots.get(1)).remove(1);
|
||||
stack.getItem().onCraftedBy(stack, player.level(), player);
|
||||
@@ -76,7 +110,7 @@
|
||||
long j = world.getGameTime();
|
||||
|
||||
if (CartographyTableMenu.this.lastSoundTime != j) {
|
||||
- world.playSound((Player) null, blockposition, SoundEvents.UI_CARTOGRAPHY_TABLE_TAKE_RESULT, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
+ world.playSound((net.minecraft.world.entity.player.Player) null, blockposition, SoundEvents.UI_CARTOGRAPHY_TABLE_TAKE_RESULT, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
CartographyTableMenu.this.lastSoundTime = j;
|
||||
}
|
||||
|
||||
@@ -85,10 +119,12 @@
|
||||
}
|
||||
});
|
||||
this.addStandardInventorySlots(inventory, 8, 84);
|
||||
+ this.player = (Player) inventory.player.getBukkitEntity(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean stillValid(Player player) {
|
||||
+ public boolean stillValid(net.minecraft.world.entity.player.Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, player, Blocks.CARTOGRAPHY_TABLE);
|
||||
}
|
||||
|
||||
@@ -147,7 +183,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public ItemStack quickMoveStack(Player player, int slot) {
|
||||
+ public ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int slot) {
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot1 = (Slot) this.slots.get(slot);
|
||||
|
||||
@@ -199,7 +235,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void removed(Player player) {
|
||||
+ public void removed(net.minecraft.world.entity.player.Player player) {
|
||||
super.removed(player);
|
||||
this.resultContainer.removeItemNoUpdate(2);
|
||||
this.access.execute((world, blockposition) -> {
|
||||
@@ -0,0 +1,64 @@
|
||||
--- a/net/minecraft/world/inventory/ChestMenu.java
|
||||
+++ b/net/minecraft/world/inventory/ChestMenu.java
|
||||
@@ -1,16 +1,43 @@
|
||||
package net.minecraft.world.inventory;
|
||||
|
||||
+import net.minecraft.world.CompoundContainer;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class ChestMenu extends AbstractContainerMenu {
|
||||
|
||||
private final Container container;
|
||||
private final int containerRows;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private Inventory player;
|
||||
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventory inventory;
|
||||
+ if (this.container instanceof Inventory) {
|
||||
+ inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryPlayer((Inventory) this.container);
|
||||
+ } else if (this.container instanceof CompoundContainer) {
|
||||
+ inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) this.container);
|
||||
+ } else {
|
||||
+ inventory = new CraftInventory(this.container);
|
||||
+ }
|
||||
+
|
||||
+ this.bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
private ChestMenu(MenuType<?> type, int syncId, Inventory playerInventory, int rows) {
|
||||
this(type, syncId, playerInventory, new SimpleContainer(9 * rows), rows);
|
||||
}
|
||||
@@ -53,6 +80,9 @@
|
||||
this.container = inventory;
|
||||
this.containerRows = rows;
|
||||
inventory.startOpen(playerInventory.player);
|
||||
+ // CraftBukkit start - Save player
|
||||
+ this.player = playerInventory;
|
||||
+ // CraftBukkit end
|
||||
boolean flag = true;
|
||||
|
||||
this.addChestGrid(inventory, 8, 18);
|
||||
@@ -72,6 +102,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.container.stillValid(player);
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
--- 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));
|
||||
@@ -1,72 +0,0 @@
|
||||
--- 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
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
--- 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
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
--- 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);
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
--- 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);
|
||||
}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
--- 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
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
--- 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
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
--- 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);
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
--- 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);
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
--- 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);
|
||||
@@ -1,84 +0,0 @@
|
||||
--- 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,43 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerLevelAccess.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerLevelAccess.java
|
||||
@@ -8,6 +8,20 @@
|
||||
|
||||
public interface ContainerLevelAccess {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ default Level getWorld() {
|
||||
+ throw new UnsupportedOperationException("Not supported yet.");
|
||||
+ }
|
||||
+
|
||||
+ default BlockPos getPosition() {
|
||||
+ throw new UnsupportedOperationException("Not supported yet.");
|
||||
+ }
|
||||
+
|
||||
+ default org.bukkit.Location getLocation() {
|
||||
+ return new org.bukkit.Location(this.getWorld().getWorld(), this.getPosition().getX(), this.getPosition().getY(), this.getPosition().getZ());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
ContainerLevelAccess NULL = new ContainerLevelAccess() {
|
||||
@Override
|
||||
public <T> Optional<T> evaluate(BiFunction<Level, BlockPos, T> getter) {
|
||||
@@ -17,7 +31,19 @@
|
||||
|
||||
static ContainerLevelAccess create(final Level world, final BlockPos pos) {
|
||||
return new ContainerLevelAccess() {
|
||||
+ // CraftBukkit start
|
||||
@Override
|
||||
+ public Level getWorld() {
|
||||
+ return world;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BlockPos getPosition() {
|
||||
+ return pos;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ @Override
|
||||
public <T> Optional<T> evaluate(BiFunction<Level, BlockPos, T> getter) {
|
||||
return Optional.of(getter.apply(world, pos));
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
--- 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();
|
||||
});
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
--- 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);
|
||||
@@ -1,59 +0,0 @@
|
||||
--- 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
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
--- 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);
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
--- 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);
|
||||
@@ -1,75 +0,0 @@
|
||||
--- 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
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
--- 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);
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/inventory/CrafterMenu.java
|
||||
+++ b/net/minecraft/world/inventory/CrafterMenu.java
|
||||
@@ -10,8 +10,27 @@
|
||||
import net.minecraft.world.item.crafting.RecipeCrafting;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import net.minecraft.world.level.block.CrafterBlock;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -9,20 +9,20 @@
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftCrafterView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class CrafterMenu extends Container implements ICrafting {
|
||||
public class CrafterMenu extends AbstractContainerMenu implements ContainerListener {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftCrafterView bukkitEntity = null;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftCrafterView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryCrafter inventory = new CraftInventoryCrafter(this.container, this.resultContainer);
|
||||
+ bukkitEntity = new CraftCrafterView(this.player.getBukkitEntity(), inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ this.bukkitEntity = new CraftCrafterView(this.player.getBukkitEntity(), inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
protected static final int SLOT_COUNT = 9;
|
||||
@@ -31,8 +31,8 @@
|
||||
@@ -106,6 +125,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
public boolean stillValid(Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.container.stillValid(entityhuman);
|
||||
return this.container.stillValid(player);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--- a/net/minecraft/world/inventory/InventoryCrafting.java
|
||||
+++ b/net/minecraft/world/inventory/InventoryCrafting.java
|
||||
--- a/net/minecraft/world/inventory/CraftingContainer.java
|
||||
+++ b/net/minecraft/world/inventory/CraftingContainer.java
|
||||
@@ -5,6 +5,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingInput;
|
||||
@@ -8,7 +8,7 @@
|
||||
+import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public interface InventoryCrafting extends IInventory, AutoRecipeOutput {
|
||||
public interface CraftingContainer extends Container, StackedContentsCompatible {
|
||||
|
||||
int getWidth();
|
||||
@@ -13,6 +17,15 @@
|
||||
@@ -0,0 +1,74 @@
|
||||
--- a/net/minecraft/world/inventory/CraftingMenu.java
|
||||
+++ b/net/minecraft/world/inventory/CraftingMenu.java
|
||||
@@ -14,7 +14,11 @@
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
+import net.minecraft.world.item.crafting.RepairItemRecipe;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class CraftingMenu extends AbstractCraftingMenu {
|
||||
|
||||
@@ -31,13 +35,16 @@
|
||||
public final ContainerLevelAccess access;
|
||||
private final Player player;
|
||||
private boolean placingRecipe;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public CraftingMenu(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, ContainerLevelAccess.NULL);
|
||||
}
|
||||
|
||||
public CraftingMenu(int syncId, Inventory playerInventory, ContainerLevelAccess context) {
|
||||
- super(MenuType.CRAFTING, syncId, 3, 3);
|
||||
+ super(MenuType.CRAFTING, syncId, 3, 3, playerInventory); // CraftBukkit - pass player
|
||||
this.access = context;
|
||||
this.player = playerInventory.player;
|
||||
this.addResultSlot(this.player, 124, 35);
|
||||
@@ -50,6 +57,7 @@
|
||||
ServerPlayer entityplayer = (ServerPlayer) player;
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Optional<RecipeHolder<CraftingRecipe>> optional = world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftinginput, world, recipe);
|
||||
+ craftingInventory.setCurrentRecipe(optional.orElse(null)); // CraftBukkit
|
||||
|
||||
if (optional.isPresent()) {
|
||||
RecipeHolder<CraftingRecipe> recipeholder1 = (RecipeHolder) optional.get();
|
||||
@@ -63,6 +71,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(craftingInventory, resultInventory, itemstack, handler.getBukkitView(), optional.map(RecipeHolder::value).orElse(null) instanceof RepairItemRecipe); // CraftBukkit
|
||||
|
||||
resultInventory.setItem(0, itemstack);
|
||||
handler.setRemoteSlot(0, itemstack);
|
||||
@@ -103,6 +112,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, player, Blocks.CRAFTING_TABLE);
|
||||
}
|
||||
|
||||
@@ -181,4 +191,17 @@
|
||||
protected Player owner() {
|
||||
return this.player;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots);
|
||||
+ this.bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
--- a/net/minecraft/world/inventory/DispenserMenu.java
|
||||
+++ b/net/minecraft/world/inventory/DispenserMenu.java
|
||||
@@ -6,6 +6,11 @@
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class DispenserMenu extends AbstractContainerMenu {
|
||||
|
||||
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 Container dispenser;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private Inventory player;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public DispenserMenu(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, new SimpleContainer(9));
|
||||
@@ -21,6 +30,10 @@
|
||||
|
||||
public DispenserMenu(int syncId, Inventory playerInventory, Container inventory) {
|
||||
super(MenuType.GENERIC_3x3, syncId);
|
||||
+ // CraftBukkit start - Save player
|
||||
+ this.player = playerInventory;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
checkContainerSize(inventory, 9);
|
||||
this.dispenser = inventory;
|
||||
inventory.startOpen(playerInventory.player);
|
||||
@@ -41,6 +54,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.dispenser.stillValid(player);
|
||||
}
|
||||
|
||||
@@ -82,4 +96,17 @@
|
||||
super.removed(player);
|
||||
this.dispenser.stopOpen(player);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventory inventory = new CraftInventory(this.dispenser);
|
||||
+ this.bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -1,9 +1,17 @@
|
||||
--- 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;
|
||||
--- a/net/minecraft/world/inventory/EnchantmentMenu.java
|
||||
+++ b/net/minecraft/world/inventory/EnchantmentMenu.java
|
||||
@@ -21,7 +21,6 @@
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
-import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
@@ -29,6 +28,18 @@
|
||||
import net.minecraft.world.item.enchantment.EnchantmentInstance;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
import net.minecraft.world.level.block.EnchantingTableBlock;
|
||||
+// CraftBukkit start
|
||||
+import java.util.Map;
|
||||
+import org.bukkit.Location;
|
||||
@@ -16,11 +24,10 @@
|
||||
+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 class EnchantmentMenu extends AbstractContainerMenu {
|
||||
|
||||
@@ -40,6 +51,10 @@
|
||||
public final int[] costs;
|
||||
public final int[] enchantClue;
|
||||
public final int[] levelClue;
|
||||
@@ -29,26 +36,26 @@
|
||||
+ private Player player;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerEnchantTable(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -53,6 +70,13 @@
|
||||
public EnchantmentMenu(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, ContainerLevelAccess.NULL);
|
||||
@@ -53,6 +68,13 @@
|
||||
super.setChanged();
|
||||
ContainerEnchantTable.this.slotsChanged(this);
|
||||
EnchantmentMenu.this.slotsChanged(this);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return containeraccess.getLocation();
|
||||
+ return context.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.random = RandomSource.create();
|
||||
this.enchantmentSeed = ContainerProperty.standalone();
|
||||
@@ -60,13 +84,13 @@
|
||||
this.enchantmentSeed = DataSlot.standalone();
|
||||
@@ -60,13 +82,13 @@
|
||||
this.enchantClue = new int[]{-1, -1, -1};
|
||||
this.levelClue = new int[]{-1, -1, -1};
|
||||
this.access = containeraccess;
|
||||
this.access = context;
|
||||
- this.addSlot(new Slot(this, this.enchantSlots, 0, 15, 47) {
|
||||
+ this.addSlot(new Slot(this.enchantSlots, 0, 15, 47) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
@@ -59,28 +66,28 @@
|
||||
- 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));
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return stack.is(Items.LAPIS_LAZULI);
|
||||
@@ -88,6 +110,9 @@
|
||||
this.addDataSlot(DataSlot.shared(this.levelClue, 0));
|
||||
this.addDataSlot(DataSlot.shared(this.levelClue, 1));
|
||||
this.addDataSlot(DataSlot.shared(this.levelClue, 2));
|
||||
+ // CraftBukkit start
|
||||
+ player = (Player) playerinventory.player.getBukkitEntity();
|
||||
+ this.player = (Player) playerInventory.player.getBukkitEntity();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,7 +122,7 @@
|
||||
if (iinventory == this.enchantSlots) {
|
||||
ItemStack itemstack = iinventory.getItem(0);
|
||||
@@ -95,7 +120,7 @@
|
||||
if (inventory == this.enchantSlots) {
|
||||
ItemStack itemstack = inventory.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();
|
||||
IdMap<Holder<Enchantment>> registry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap();
|
||||
int i = 0;
|
||||
@@ -135,6 +162,41 @@
|
||||
@@ -135,6 +160,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +99,7 @@
|
||||
+ 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);
|
||||
+ PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(this.player, this.getBukkitView(), this.access.getLocation().getBlock(), item, offers, i);
|
||||
+ event.setCancelled(!itemstack.isEnchantable());
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
@@ -122,29 +129,38 @@
|
||||
this.broadcastChanges();
|
||||
});
|
||||
} else {
|
||||
@@ -162,21 +224,46 @@
|
||||
@@ -149,7 +209,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean clickMenuButton(Player player, int id) {
|
||||
+ public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) {
|
||||
if (id >= 0 && id < this.costs.length) {
|
||||
ItemStack itemstack = this.enchantSlots.getItem(0);
|
||||
ItemStack itemstack1 = this.enchantSlots.getItem(1);
|
||||
@@ -162,21 +222,46 @@
|
||||
ItemStack itemstack2 = itemstack;
|
||||
List<WeightedRandomEnchant> list = this.getEnchantmentList(world.registryAccess(), itemstack, i, this.costs[i]);
|
||||
List<EnchantmentInstance> list = this.getEnchantmentList(world.registryAccess(), itemstack, id, this.costs[id]);
|
||||
|
||||
- if (!list.isEmpty()) {
|
||||
- entityhuman.onEnchantmentPerformed(itemstack, j);
|
||||
- player.onEnchantmentPerformed(itemstack, j);
|
||||
+ // CraftBukkit start
|
||||
+ Registry<Holder<Enchantment>> registry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).asHolderIdMap();
|
||||
+ IdMap<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) {
|
||||
+ for (EnchantmentInstance 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);
|
||||
+ org.bukkit.enchantments.Enchantment hintedEnchantment = CraftEnchantment.minecraftHolderToBukkit(registry.byId(this.enchantClue[id]));
|
||||
+ int hintedEnchantmentLevel = this.levelClue[id];
|
||||
+ EnchantItemEvent event = new EnchantItemEvent((Player) player.getBukkitEntity(), this.getBukkitView(), this.access.getLocation().getBlock(), item, this.costs[id], enchants, hintedEnchantment, hintedEnchantmentLevel, id);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ int level = event.getExpLevelCost();
|
||||
+ if (event.isCancelled() || (level > entityhuman.experienceLevel && !entityhuman.getAbilities().instabuild) || event.getEnchantsToAdd().isEmpty()) {
|
||||
+ if (event.isCancelled() || (level > player.experienceLevel && !player.getAbilities().instabuild) || event.getEnchantsToAdd().isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@@ -154,9 +170,6 @@
|
||||
}
|
||||
|
||||
- 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());
|
||||
@@ -164,26 +177,55 @@
|
||||
+ continue;
|
||||
+ }
|
||||
|
||||
+ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue());
|
||||
- while (iterator.hasNext()) {
|
||||
- EnchantmentInstance weightedrandomenchant = (EnchantmentInstance) iterator.next();
|
||||
-
|
||||
+ EnchantmentInstance weightedrandomenchant = new EnchantmentInstance(nms, entry.getValue());
|
||||
itemstack2.enchant(weightedrandomenchant.enchantment, weightedrandomenchant.level);
|
||||
}
|
||||
|
||||
+ entityhuman.onEnchantmentPerformed(itemstack, j);
|
||||
+ player.onEnchantmentPerformed(itemstack, j);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ // CraftBukkit - TODO: let plugins change this
|
||||
itemstack1.consume(j, entityhuman);
|
||||
itemstack1.consume(j, player);
|
||||
if (itemstack1.isEmpty()) {
|
||||
this.enchantSlots.setItem(1, ItemStack.EMPTY);
|
||||
@@ -243,6 +330,7 @@
|
||||
@@ -190,7 +275,7 @@
|
||||
this.enchantSlots.setChanged();
|
||||
this.enchantmentSeed.set(player.getEnchantmentSeed());
|
||||
this.slotsChanged(this.enchantSlots);
|
||||
- world.playSound((Player) null, blockposition, SoundEvents.ENCHANTMENT_TABLE_USE, SoundSource.BLOCKS, 1.0F, world.random.nextFloat() * 0.1F + 0.9F);
|
||||
+ world.playSound((net.minecraft.world.entity.player.Player) null, blockposition, SoundEvents.ENCHANTMENT_TABLE_USE, SoundSource.BLOCKS, 1.0F, world.random.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE);
|
||||
});
|
||||
@@ -234,7 +319,7 @@
|
||||
}
|
||||
|
||||
@@ -293,4 +381,17 @@
|
||||
@Override
|
||||
- public void removed(Player player) {
|
||||
+ public void removed(net.minecraft.world.entity.player.Player player) {
|
||||
super.removed(player);
|
||||
this.access.execute((world, blockposition) -> {
|
||||
this.clearContainer(player, this.enchantSlots);
|
||||
@@ -242,12 +327,13 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean stillValid(Player player) {
|
||||
+ public boolean stillValid(net.minecraft.world.entity.player.Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, player, Blocks.ENCHANTING_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
- public ItemStack quickMoveStack(Player player, int slot) {
|
||||
+ public ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int slot) {
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot1 = (Slot) this.slots.get(slot);
|
||||
|
||||
@@ -293,4 +379,17 @@
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
@@ -191,13 +233,13 @@
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftEnchantmentView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryEnchanting inventory = new CraftInventoryEnchanting(this.enchantSlots);
|
||||
+ bukkitEntity = new CraftEnchantmentView(this.player, inventory, this);
|
||||
+ return bukkitEntity;
|
||||
+ this.bukkitEntity = new CraftEnchantmentView(this.player, inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/inventory/FurnaceResultSlot.java
|
||||
+++ b/net/minecraft/world/inventory/FurnaceResultSlot.java
|
||||
@@ -51,7 +51,7 @@
|
||||
Container iinventory = this.container;
|
||||
|
||||
if (iinventory instanceof AbstractFurnaceBlockEntity tileentityfurnace) {
|
||||
- tileentityfurnace.awardUsedRecipesAndPopExperience(entityplayer);
|
||||
+ tileentityfurnace.awardUsedRecipesAndPopExperience(entityplayer, stack, this.removeCount); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
--- a/net/minecraft/world/inventory/GrindstoneMenu.java
|
||||
+++ b/net/minecraft/world/inventory/GrindstoneMenu.java
|
||||
@@ -10,7 +10,6 @@
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
-import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
@@ -19,9 +18,30 @@
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// 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 GrindstoneMenu extends AbstractContainerMenu {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryGrindstone inventory = new CraftInventoryGrindstone(this.repairSlots, this.resultSlots);
|
||||
+ this.bukkitEntity = new CraftInventoryView(this.player, inventory, this);
|
||||
+ return this.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;
|
||||
@@ -46,16 +66,23 @@
|
||||
public void setChanged() {
|
||||
super.setChanged();
|
||||
GrindstoneMenu.this.slotsChanged(this);
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return context.getLocation();
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.access = context;
|
||||
- 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 stack) {
|
||||
return stack.isDamageableItem() || EnchantmentHelper.hasAnyEnchantments(stack);
|
||||
}
|
||||
});
|
||||
- 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 stack) {
|
||||
return stack.isDamageableItem() || EnchantmentHelper.hasAnyEnchantments(stack);
|
||||
@@ -68,7 +95,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void onTake(Player player, ItemStack stack) {
|
||||
+ public void onTake(net.minecraft.world.entity.player.Player player, ItemStack stack) {
|
||||
context.execute((world, blockposition) -> {
|
||||
if (world instanceof ServerLevel) {
|
||||
ExperienceOrb.award((ServerLevel) world, Vec3.atCenterOf(blockposition), this.getExperienceAmount(world));
|
||||
@@ -113,6 +140,7 @@
|
||||
}
|
||||
});
|
||||
this.addStandardInventorySlots(playerInventory, 8, 84);
|
||||
+ this.player = (Player) playerInventory.player.getBukkitEntity(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,7 +153,8 @@
|
||||
}
|
||||
|
||||
private void createResult() {
|
||||
- this.resultSlots.setItem(0, this.computeResult(this.repairSlots.getItem(0), this.repairSlots.getItem(1)));
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareGrindstoneEvent(this.getBukkitView(), this.computeResult(this.repairSlots.getItem(0), this.repairSlots.getItem(1))); // CraftBukkit
|
||||
+ this.sendAllDataToRemote(); // CraftBukkit - SPIGOT-6686: Always send completed inventory to stay in sync with client
|
||||
this.broadcastChanges();
|
||||
}
|
||||
|
||||
@@ -218,7 +247,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void removed(Player player) {
|
||||
+ public void removed(net.minecraft.world.entity.player.Player player) {
|
||||
super.removed(player);
|
||||
this.access.execute((world, blockposition) -> {
|
||||
this.clearContainer(player, this.repairSlots);
|
||||
@@ -226,12 +255,13 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean stillValid(Player player) {
|
||||
+ public boolean stillValid(net.minecraft.world.entity.player.Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, player, Blocks.GRINDSTONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
- public ItemStack quickMoveStack(Player player, int slot) {
|
||||
+ public ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int slot) {
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot1 = (Slot) this.slots.get(slot);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/world/inventory/HopperMenu.java
|
||||
+++ b/net/minecraft/world/inventory/HopperMenu.java
|
||||
@@ -6,11 +6,32 @@
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class HopperMenu extends AbstractContainerMenu {
|
||||
|
||||
public static final int CONTAINER_SIZE = 5;
|
||||
private final Container hopper;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ private Inventory player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventory inventory = new CraftInventory(this.hopper);
|
||||
+ this.bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public HopperMenu(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, new SimpleContainer(5));
|
||||
}
|
||||
@@ -18,6 +39,7 @@
|
||||
public HopperMenu(int syncId, Inventory playerInventory, Container inventory) {
|
||||
super(MenuType.HOPPER, syncId);
|
||||
this.hopper = inventory;
|
||||
+ this.player = playerInventory; // CraftBukkit - save player
|
||||
checkContainerSize(inventory, 5);
|
||||
inventory.startOpen(playerInventory.player);
|
||||
|
||||
@@ -30,6 +52,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.hopper.stillValid(player);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
--- a/net/minecraft/world/inventory/HorseInventoryMenu.java
|
||||
+++ b/net/minecraft/world/inventory/HorseInventoryMenu.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 HorseInventoryMenu extends AbstractContainerMenu {
|
||||
|
||||
static final ResourceLocation SADDLE_SLOT_SPRITE = ResourceLocation.withDefaultNamespace("container/slot/saddle");
|
||||
@@ -22,13 +27,28 @@
|
||||
public static final int SLOT_BODY_ARMOR = 1;
|
||||
private static final int SLOT_HORSE_INVENTORY_START = 2;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity;
|
||||
+ Inventory player;
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ return this.bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), this.horseContainer.getOwner().getInventory(), this);
|
||||
+ }
|
||||
+
|
||||
public HorseInventoryMenu(int syncId, Inventory playerInventory, Container inventory, final AbstractHorse entity, int slotColumnCount) {
|
||||
super((MenuType) null, syncId);
|
||||
+ this.player = playerInventory;
|
||||
+ // CraftBukkit end
|
||||
this.horseContainer = inventory;
|
||||
this.armorContainer = entity.getBodyArmorAccess();
|
||||
this.horse = entity;
|
||||
inventory.startOpen(playerInventory.player);
|
||||
- this.addSlot(new Slot(this, inventory, 0, 8, 18) {
|
||||
+ this.addSlot(new Slot(inventory, 0, 8, 18) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return stack.is(Items.SADDLE) && !this.hasItem() && entity.isSaddleable();
|
||||
@@ -46,7 +66,7 @@
|
||||
});
|
||||
ResourceLocation minecraftkey = entity instanceof Llama ? HorseInventoryMenu.LLAMA_ARMOR_SLOT_SPRITE : HorseInventoryMenu.ARMOR_SLOT_SPRITE;
|
||||
|
||||
- this.addSlot(new ArmorSlot(this, this.armorContainer, entity, EquipmentSlot.BODY, 0, 8, 36, minecraftkey) {
|
||||
+ this.addSlot(new ArmorSlot(this.armorContainer, entity, EquipmentSlot.BODY, 0, 8, 36, minecraftkey) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return entity.isEquippableInSlot(stack, EquipmentSlot.BODY);
|
||||
@@ -1,36 +0,0 @@
|
||||
--- 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,64 @@
|
||||
--- a/net/minecraft/world/inventory/InventoryMenu.java
|
||||
+++ b/net/minecraft/world/inventory/InventoryMenu.java
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
+import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.Container;
|
||||
@@ -11,6 +12,9 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.level.Level;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class InventoryMenu extends AbstractCraftingMenu {
|
||||
|
||||
@@ -38,9 +42,15 @@
|
||||
private static final EquipmentSlot[] SLOT_IDS = new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET};
|
||||
public final boolean active;
|
||||
private final Player owner;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity = null;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public InventoryMenu(Inventory inventory, boolean onServer, final Player owner) {
|
||||
- super((MenuType) null, 0, 2, 2);
|
||||
+ // CraftBukkit start
|
||||
+ super((MenuType) null, 0, 2, 2, inventory); // CraftBukkit - save player
|
||||
+ this.setTitle(Component.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory
|
||||
+ // CraftBukkit end
|
||||
this.active = onServer;
|
||||
this.owner = owner;
|
||||
this.addResultSlot(owner, 154, 28);
|
||||
@@ -54,7 +64,7 @@
|
||||
}
|
||||
|
||||
this.addStandardInventorySlots(inventory, 8, 84);
|
||||
- this.addSlot(new Slot(this, inventory, 40, 77, 62) {
|
||||
+ this.addSlot(new Slot(inventory, 40, 77, 62) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public void setByPlayer(ItemStack stack, ItemStack previousStack) {
|
||||
owner.onEquipItem(EquipmentSlot.OFFHAND, previousStack, stack);
|
||||
@@ -190,4 +200,17 @@
|
||||
protected Player owner() {
|
||||
return this.owner;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftSlots, this.resultSlots);
|
||||
+ this.bukkitEntity = new CraftInventoryView(this.owner.getBukkitEntity(), inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
--- 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;
|
||||
@@ -1,19 +1,19 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java
|
||||
--- a/net/minecraft/world/inventory/ItemCombinerMenu.java
|
||||
+++ b/net/minecraft/world/inventory/ItemCombinerMenu.java
|
||||
@@ -50,7 +50,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
final ItemCombinerMenuSlotDefinition.b itemcombinermenuslotdefinition_b = (ItemCombinerMenuSlotDefinition.b) iterator.next();
|
||||
final ItemCombinerMenuSlotDefinition.SlotDefinition itemcombinermenuslotdefinition_b = (ItemCombinerMenuSlotDefinition.SlotDefinition) 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);
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return itemcombinermenuslotdefinition_b.mayPlace().test(stack);
|
||||
@@ -110,6 +110,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
public boolean stillValid(Player player) {
|
||||
+ 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);
|
||||
return !this.isValidBlock(world.getBlockState(blockposition)) ? false : player.canInteractWithBlock(blockposition, 4.0D);
|
||||
}, true);
|
||||
@@ -0,0 +1,114 @@
|
||||
--- a/net/minecraft/world/inventory/LecternMenu.java
|
||||
+++ b/net/minecraft/world/inventory/LecternMenu.java
|
||||
@@ -2,11 +2,33 @@
|
||||
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
-import net.minecraft.world.entity.player.Player;
|
||||
+import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
+import net.minecraft.world.level.block.entity.LecternBlockEntity.LecternInventory;
|
||||
+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 LecternMenu extends AbstractContainerMenu {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftLecternView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftLecternView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryLectern inventory = new CraftInventoryLectern(this.lectern);
|
||||
+ this.bukkitEntity = new CraftLecternView(this.player, inventory, this);
|
||||
+ return this.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,28 +38,31 @@
|
||||
private final Container lectern;
|
||||
private final ContainerData lecternData;
|
||||
|
||||
- public LecternMenu(int syncId) {
|
||||
- this(syncId, new SimpleContainer(1), new SimpleContainerData(1));
|
||||
+ // CraftBukkit start - add player
|
||||
+ public LecternMenu(int i, Inventory playerinventory) {
|
||||
+ this(i, new SimpleContainer(1), new SimpleContainerData(1), playerinventory);
|
||||
}
|
||||
|
||||
- public LecternMenu(int syncId, Container inventory, ContainerData propertyDelegate) {
|
||||
- super(MenuType.LECTERN, syncId);
|
||||
- checkContainerSize(inventory, 1);
|
||||
- checkContainerDataCount(propertyDelegate, 1);
|
||||
- this.lectern = inventory;
|
||||
- this.lecternData = propertyDelegate;
|
||||
- this.addSlot(new Slot(inventory, 0, 0, 0) {
|
||||
+ public LecternMenu(int i, Container iinventory, ContainerData icontainerproperties, Inventory playerinventory) {
|
||||
+ // CraftBukkit end
|
||||
+ super(MenuType.LECTERN, i);
|
||||
+ checkContainerSize(iinventory, 1);
|
||||
+ checkContainerDataCount(icontainerproperties, 1);
|
||||
+ this.lectern = iinventory;
|
||||
+ this.lecternData = icontainerproperties;
|
||||
+ this.addSlot(new Slot(iinventory, 0, 0, 0) {
|
||||
@Override
|
||||
public void setChanged() {
|
||||
super.setChanged();
|
||||
LecternMenu.this.slotsChanged(this.container);
|
||||
}
|
||||
});
|
||||
- this.addDataSlots(propertyDelegate);
|
||||
+ this.addDataSlots(icontainerproperties);
|
||||
+ this.player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean clickMenuButton(Player player, int id) {
|
||||
+ public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) {
|
||||
int j;
|
||||
|
||||
if (id >= 100) {
|
||||
@@ -59,6 +84,13 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Event for taking the book
|
||||
+ PlayerTakeLecternBookEvent event = new PlayerTakeLecternBookEvent(this.player, ((CraftInventoryLectern) this.getBukkitView().getTopInventory()).getHolder());
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack = this.lectern.removeItemNoUpdate(0);
|
||||
|
||||
this.lectern.setChanged();
|
||||
@@ -74,7 +106,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public ItemStack quickMoveStack(Player player, int slot) {
|
||||
+ public ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int slot) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@@ -85,7 +117,9 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean stillValid(Player player) {
|
||||
+ public boolean stillValid(net.minecraft.world.entity.player.Player player) {
|
||||
+ if (this.lectern instanceof LecternInventory && !((LecternInventory) this.lectern).getLectern().hasBook()) return false; // CraftBukkit
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.lectern.stillValid(player);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
--- a/net/minecraft/world/inventory/LoomMenu.java
|
||||
+++ b/net/minecraft/world/inventory/LoomMenu.java
|
||||
@@ -12,7 +12,6 @@
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
-import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BannerItem;
|
||||
import net.minecraft.world.item.BannerPatternItem;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
@@ -22,9 +21,30 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BannerPattern;
|
||||
import net.minecraft.world.level.block.entity.BannerPatternLayers;
|
||||
+// 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 LoomMenu extends AbstractContainerMenu {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftLoomView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftLoomView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryLoom inventory = new CraftInventoryLoom(this.inputContainer, this.outputContainer);
|
||||
+ this.bukkitEntity = new CraftLoomView(this.player, inventory, this);
|
||||
+ return this.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 +80,13 @@
|
||||
LoomMenu.this.slotsChanged(this);
|
||||
LoomMenu.this.slotUpdateListener.run();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return context.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.outputContainer = new SimpleContainer(1) {
|
||||
@Override
|
||||
@@ -67,21 +94,28 @@
|
||||
super.setChanged();
|
||||
LoomMenu.this.slotUpdateListener.run();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return context.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.access = context;
|
||||
- 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 stack) {
|
||||
return stack.getItem() instanceof BannerItem;
|
||||
}
|
||||
});
|
||||
- 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 stack) {
|
||||
return stack.getItem() instanceof DyeItem;
|
||||
}
|
||||
});
|
||||
- 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 stack) {
|
||||
return stack.getItem() instanceof BannerPatternItem;
|
||||
@@ -94,7 +128,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void onTake(Player player, ItemStack stack) {
|
||||
+ public void onTake(net.minecraft.world.entity.player.Player player, ItemStack stack) {
|
||||
LoomMenu.this.bannerSlot.remove(1);
|
||||
LoomMenu.this.dyeSlot.remove(1);
|
||||
if (!LoomMenu.this.bannerSlot.hasItem() || !LoomMenu.this.dyeSlot.hasItem()) {
|
||||
@@ -105,7 +139,7 @@
|
||||
long j = world.getGameTime();
|
||||
|
||||
if (LoomMenu.this.lastSoundTime != j) {
|
||||
- world.playSound((Player) null, blockposition, SoundEvents.UI_LOOM_TAKE_RESULT, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
+ world.playSound((net.minecraft.world.entity.player.Player) null, blockposition, SoundEvents.UI_LOOM_TAKE_RESULT, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
LoomMenu.this.lastSoundTime = j;
|
||||
}
|
||||
|
||||
@@ -116,15 +150,17 @@
|
||||
this.addStandardInventorySlots(playerInventory, 8, 84);
|
||||
this.addDataSlot(this.selectedBannerPatternIndex);
|
||||
this.patternGetter = playerInventory.player.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN);
|
||||
+ this.player = (Player) playerInventory.player.getBukkitEntity(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean stillValid(Player player) {
|
||||
+ public boolean stillValid(net.minecraft.world.entity.player.Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, player, Blocks.LOOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean clickMenuButton(Player player, int id) {
|
||||
+ public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) {
|
||||
if (id >= 0 && id < this.selectablePatterns.size()) {
|
||||
this.selectedBannerPatternIndex.set(id);
|
||||
this.setupResultSlot((Holder) this.selectablePatterns.get(id));
|
||||
@@ -222,7 +258,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public ItemStack quickMoveStack(Player player, int slot) {
|
||||
+ public ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int slot) {
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot1 = (Slot) this.slots.get(slot);
|
||||
|
||||
@@ -277,7 +313,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void removed(Player player) {
|
||||
+ public void removed(net.minecraft.world.entity.player.Player player) {
|
||||
super.removed(player);
|
||||
this.access.execute((world, blockposition) -> {
|
||||
this.clearContainer(player, this.inputContainer);
|
||||
@@ -294,6 +330,11 @@
|
||||
DyeColor enumcolor = ((DyeItem) 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.Builder()).addAll(bannerpatternlayers).add(pattern, enumcolor).build();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/inventory/MenuType.java
|
||||
+++ b/net/minecraft/world/inventory/MenuType.java
|
||||
@@ -28,7 +28,7 @@
|
||||
public static final MenuType<GrindstoneMenu> GRINDSTONE = MenuType.register("grindstone", GrindstoneMenu::new);
|
||||
public static final MenuType<HopperMenu> HOPPER = MenuType.register("hopper", HopperMenu::new);
|
||||
public static final MenuType<LecternMenu> LECTERN = MenuType.register("lectern", (i, playerinventory) -> {
|
||||
- return new LecternMenu(i);
|
||||
+ return new LecternMenu(i, playerinventory); // CraftBukkit
|
||||
});
|
||||
public static final MenuType<LoomMenu> LOOM = MenuType.register("loom", LoomMenu::new);
|
||||
public static final MenuType<MerchantMenu> MERCHANT = MenuType.register("merchant", MerchantMenu::new);
|
||||
@@ -0,0 +1,70 @@
|
||||
--- a/net/minecraft/world/inventory/MerchantContainer.java
|
||||
+++ b/net/minecraft/world/inventory/MerchantContainer.java
|
||||
@@ -5,11 +5,20 @@
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.ContainerHelper;
|
||||
+import net.minecraft.world.entity.npc.AbstractVillager;
|
||||
+import net.minecraft.world.entity.npc.Villager;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.trading.Merchant;
|
||||
import net.minecraft.world.item.trading.MerchantOffer;
|
||||
import net.minecraft.world.item.trading.MerchantOffers;
|
||||
+// CraftBukkit start
|
||||
+import java.util.List;
|
||||
+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 MerchantContainer implements Container {
|
||||
|
||||
@@ -20,6 +29,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) {
|
||||
+ this.transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ this.transaction.remove(who);
|
||||
+ this.merchant.setTradingPlayer((Player) null); // SPIGOT-4860
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return this.transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return this.maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int i) {
|
||||
+ this.maxStack = i;
|
||||
+ }
|
||||
+
|
||||
+ public org.bukkit.inventory.InventoryHolder getOwner() {
|
||||
+ return (this.merchant instanceof AbstractVillager) ? (CraftAbstractVillager) ((AbstractVillager) this.merchant).getBukkitEntity() : null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return (this.merchant instanceof Villager) ? ((Villager) this.merchant).getBukkitEntity().getLocation() : null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public MerchantContainer(Merchant merchant) {
|
||||
this.itemStacks = NonNullList.withSize(3, ItemStack.EMPTY);
|
||||
this.merchant = merchant;
|
||||
@@ -0,0 +1,47 @@
|
||||
--- a/net/minecraft/world/inventory/MerchantMenu.java
|
||||
+++ b/net/minecraft/world/inventory/MerchantMenu.java
|
||||
@@ -12,6 +12,7 @@
|
||||
import net.minecraft.world.item.trading.Merchant;
|
||||
import net.minecraft.world.item.trading.MerchantOffer;
|
||||
import net.minecraft.world.item.trading.MerchantOffers;
|
||||
+import org.bukkit.craftbukkit.inventory.view.CraftMerchantView; // CraftBukkit
|
||||
|
||||
public class MerchantMenu extends AbstractContainerMenu {
|
||||
|
||||
@@ -32,6 +33,19 @@
|
||||
private boolean showProgressBar;
|
||||
private boolean canRestock;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftMerchantView bukkitEntity = null;
|
||||
+ private Inventory player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftMerchantView getBukkitView() {
|
||||
+ if (this.bukkitEntity == null) {
|
||||
+ this.bukkitEntity = new CraftMerchantView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(this.trader, this.tradeContainer), this, this.trader);
|
||||
+ }
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public MerchantMenu(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, new ClientSideMerchant(playerInventory.player));
|
||||
}
|
||||
@@ -43,6 +57,7 @@
|
||||
this.addSlot(new Slot(this.tradeContainer, 0, 136, 37));
|
||||
this.addSlot(new Slot(this.tradeContainer, 1, 162, 37));
|
||||
this.addSlot(new MerchantResultSlot(playerInventory.player, merchant, this.tradeContainer, 2, 220, 37));
|
||||
+ this.player = playerInventory; // CraftBukkit - save player
|
||||
this.addStandardInventorySlots(playerInventory, 108, 84);
|
||||
}
|
||||
|
||||
@@ -143,7 +158,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(), SoundSource.NEUTRAL, 1.0F, 1.0F, false);
|
||||
@@ -0,0 +1,36 @@
|
||||
--- a/net/minecraft/world/inventory/PlayerEnderChestContainer.java
|
||||
+++ b/net/minecraft/world/inventory/PlayerEnderChestContainer.java
|
||||
@@ -8,14 +8,32 @@
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.inventory.InventoryHolder;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class PlayerEnderChestContainer extends SimpleContainer {
|
||||
|
||||
@Nullable
|
||||
private EnderChestBlockEntity activeChest;
|
||||
+ // CraftBukkit start
|
||||
+ private final Player owner;
|
||||
|
||||
- public PlayerEnderChestContainer() {
|
||||
+ public InventoryHolder getBukkitOwner() {
|
||||
+ return this.owner.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return this.activeChest != null ? CraftLocation.toBukkit(this.activeChest.getBlockPos(), this.activeChest.getLevel().getWorld()) : null;
|
||||
+ }
|
||||
+
|
||||
+ public PlayerEnderChestContainer(Player owner) {
|
||||
super(27);
|
||||
+ this.owner = owner;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void setActiveChest(EnderChestBlockEntity blockEntity) {
|
||||
@@ -1,5 +1,5 @@
|
||||
--- a/net/minecraft/world/inventory/InventoryCraftResult.java
|
||||
+++ b/net/minecraft/world/inventory/InventoryCraftResult.java
|
||||
--- a/net/minecraft/world/inventory/ResultContainer.java
|
||||
+++ b/net/minecraft/world/inventory/ResultContainer.java
|
||||
@@ -9,12 +9,51 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
@@ -10,7 +10,7 @@
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class InventoryCraftResult implements IInventory, RecipeCraftingHolder {
|
||||
public class ResultContainer implements Container, RecipeCraftingHolder {
|
||||
|
||||
private final NonNullList<ItemStack> itemStacks;
|
||||
@Nullable
|
||||
@@ -36,11 +36,11 @@
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ return this.maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ this.maxStack = size;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@@ -49,6 +49,6 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public InventoryCraftResult() {
|
||||
public ResultContainer() {
|
||||
this.itemStacks = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
--- a/net/minecraft/world/inventory/ShulkerBoxMenu.java
|
||||
+++ b/net/minecraft/world/inventory/ShulkerBoxMenu.java
|
||||
@@ -6,11 +6,30 @@
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ShulkerBoxMenu extends AbstractContainerMenu {
|
||||
|
||||
private static final int CONTAINER_SIZE = 27;
|
||||
private final Container container;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity;
|
||||
+ private Inventory player;
|
||||
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ this.bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new CraftInventory(this.container), this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public ShulkerBoxMenu(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, new SimpleContainer(27));
|
||||
}
|
||||
@@ -19,6 +38,7 @@
|
||||
super(MenuType.SHULKER_BOX, syncId);
|
||||
checkContainerSize(inventory, 27);
|
||||
this.container = inventory;
|
||||
+ this.player = playerInventory; // CraftBukkit - save player
|
||||
inventory.startOpen(playerInventory.player);
|
||||
boolean flag = true;
|
||||
boolean flag1 = true;
|
||||
@@ -34,6 +54,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return this.container.stillValid(player);
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
--- 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,44 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerSmithing.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerSmithing.java
|
||||
@@ -18,6 +18,8 @@
|
||||
--- a/net/minecraft/world/inventory/SmithingMenu.java
|
||||
+++ b/net/minecraft/world/inventory/SmithingMenu.java
|
||||
@@ -17,6 +17,7 @@
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
|
||||
+
|
||||
public class ContainerSmithing extends ContainerAnvilAbstract {
|
||||
|
||||
public static final int TEMPLATE_SLOT = 0;
|
||||
@@ -34,6 +36,9 @@
|
||||
public class SmithingMenu extends ItemCombinerMenu {
|
||||
|
||||
@@ -34,6 +35,9 @@
|
||||
private final RecipePropertySet templateItemTest;
|
||||
private final RecipePropertySet additionItemTest;
|
||||
private final ContainerProperty hasRecipeError;
|
||||
private final DataSlot hasRecipeError;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftInventoryView bukkitEntity;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public ContainerSmithing(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -117,7 +122,7 @@
|
||||
public SmithingMenu(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, ContainerLevelAccess.NULL);
|
||||
@@ -117,7 +121,7 @@
|
||||
public void createResult() {
|
||||
SmithingRecipeInput smithingrecipeinput = this.createRecipeInput();
|
||||
World world = this.level;
|
||||
Level 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 @@
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
optional = worldserver.recipeAccess().getRecipeFor(RecipeType.SMITHING, smithingrecipeinput, worldserver);
|
||||
@@ -129,7 +133,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);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(this.getBukkitView(), itemstack);
|
||||
+ // CraftBukkit end
|
||||
}, () -> {
|
||||
this.resultSlots.setRecipeUsed((RecipeHolder) null);
|
||||
this.resultSlots.setItem(0, ItemStack.EMPTY);
|
||||
@@ -149,4 +156,18 @@
|
||||
@@ -149,4 +155,18 @@
|
||||
public boolean hasRecipeError() {
|
||||
return this.hasRecipeError.get() > 0;
|
||||
}
|
||||
@@ -47,14 +46,14 @@
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CraftInventoryView getBukkitView() {
|
||||
+ if (bukkitEntity != null) {
|
||||
+ return bukkitEntity;
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.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;
|
||||
+ this.access.getLocation(), this.inputSlots, this.resultSlots);
|
||||
+ this.bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
--- a/net/minecraft/world/inventory/StonecutterMenu.java
|
||||
+++ b/net/minecraft/world/inventory/StonecutterMenu.java
|
||||
@@ -7,7 +7,6 @@
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
-import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
@@ -17,6 +16,13 @@
|
||||
import net.minecraft.world.level.Level;
|
||||
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 StonecutterMenu extends AbstractContainerMenu {
|
||||
|
||||
public static final int INPUT_SLOT = 0;
|
||||
@@ -36,6 +42,21 @@
|
||||
Runnable slotUpdateListener;
|
||||
public final Container container;
|
||||
final ResultContainer resultContainer;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftStonecutterView bukkitEntity = null;
|
||||
+ private Player player;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftStonecutterView getBukkitView() {
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.container, this.resultContainer);
|
||||
+ this.bukkitEntity = new CraftStonecutterView(this.player, inventory, this);
|
||||
+ return this.bukkitEntity;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public StonecutterMenu(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, ContainerLevelAccess.NULL);
|
||||
@@ -55,6 +76,13 @@
|
||||
StonecutterMenu.this.slotsChanged(this);
|
||||
StonecutterMenu.this.slotUpdateListener.run();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return context.getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.resultContainer = new ResultContainer();
|
||||
this.access = context;
|
||||
@@ -67,7 +95,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void onTake(Player player, ItemStack stack) {
|
||||
+ public void onTake(net.minecraft.world.entity.player.Player player, ItemStack stack) {
|
||||
stack.onCraftedBy(player.level(), player, stack.getCount());
|
||||
StonecutterMenu.this.resultContainer.awardUsedRecipes(player, this.getRelevantItems());
|
||||
ItemStack itemstack1 = StonecutterMenu.this.inputSlot.remove(1);
|
||||
@@ -80,7 +108,7 @@
|
||||
long j = world.getGameTime();
|
||||
|
||||
if (StonecutterMenu.this.lastSoundTime != j) {
|
||||
- world.playSound((Player) null, blockposition, SoundEvents.UI_STONECUTTER_TAKE_RESULT, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
+ world.playSound((net.minecraft.world.entity.player.Player) null, blockposition, SoundEvents.UI_STONECUTTER_TAKE_RESULT, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
StonecutterMenu.this.lastSoundTime = j;
|
||||
}
|
||||
|
||||
@@ -94,6 +122,7 @@
|
||||
});
|
||||
this.addStandardInventorySlots(playerInventory, 8, 84);
|
||||
this.addDataSlot(this.selectedRecipeIndex);
|
||||
+ this.player = (Player) playerInventory.player.getBukkitEntity(); // CraftBukkit
|
||||
}
|
||||
|
||||
public int getSelectedRecipeIndex() {
|
||||
@@ -113,12 +142,13 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean stillValid(Player player) {
|
||||
+ public boolean stillValid(net.minecraft.world.entity.player.Player player) {
|
||||
+ if (!this.checkReachable) return true; // CraftBukkit
|
||||
return stillValid(this.access, player, Blocks.STONECUTTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean clickMenuButton(Player player, int id) {
|
||||
+ public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) {
|
||||
if (this.selectedRecipeIndex.get() == id) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -158,7 +188,7 @@
|
||||
}
|
||||
|
||||
void setupResultSlot(int selectedId) {
|
||||
- Optional optional;
|
||||
+ Optional<RecipeHolder<StonecutterRecipe>> optional; // CraftBukkit - decompile error
|
||||
|
||||
if (!this.recipesForInput.isEmpty() && this.isValidRecipeIndex(selectedId)) {
|
||||
SelectableRecipe.SingleInputEntry<StonecutterRecipe> selectablerecipe_a = (SelectableRecipe.SingleInputEntry) this.recipesForInput.entries().get(selectedId);
|
||||
@@ -193,7 +223,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public ItemStack quickMoveStack(Player player, int slot) {
|
||||
+ public ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int slot) {
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot1 = (Slot) this.slots.get(slot);
|
||||
|
||||
@@ -246,7 +276,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void removed(Player player) {
|
||||
+ public void removed(net.minecraft.world.entity.player.Player player) {
|
||||
super.removed(player);
|
||||
this.resultContainer.removeItemNoUpdate(1);
|
||||
this.access.execute((world, blockposition) -> {
|
||||
@@ -1,12 +1,17 @@
|
||||
--- a/net/minecraft/world/inventory/TransientCraftingContainer.java
|
||||
+++ b/net/minecraft/world/inventory/TransientCraftingContainer.java
|
||||
@@ -8,6 +8,16 @@
|
||||
@@ -3,11 +3,21 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import net.minecraft.core.NonNullList;
|
||||
+import net.minecraft.world.Container;
|
||||
import net.minecraft.world.ContainerHelper;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
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;
|
||||
@@ -14,18 +19,18 @@
|
||||
+import org.bukkit.event.inventory.InventoryType;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TransientCraftingContainer implements InventoryCrafting {
|
||||
public class TransientCraftingContainer implements CraftingContainer {
|
||||
|
||||
private final NonNullList<ItemStack> items;
|
||||
@@ -15,6 +25,68 @@
|
||||
private final int height;
|
||||
private final Container menu;
|
||||
private final AbstractContainerMenu menu;
|
||||
|
||||
+ // CraftBukkit start - add fields
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private RecipeHolder<?> currentRecipe;
|
||||
+ public IInventory resultInventory;
|
||||
+ private EntityHuman owner;
|
||||
+ public Container resultInventory;
|
||||
+ private Player owner;
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+
|
||||
+ public List<ItemStack> getContents() {
|
||||
@@ -33,43 +38,43 @@
|
||||
+ }
|
||||
+
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ this.transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public InventoryType getInvType() {
|
||||
+ return items.size() == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH;
|
||||
+ return this.items.size() == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH;
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ this.transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ return this.transaction;
|
||||
+ }
|
||||
+
|
||||
+ public org.bukkit.inventory.InventoryHolder getOwner() {
|
||||
+ return (owner == null) ? null : owner.getBukkitEntity();
|
||||
+ return (this.owner == null) ? null : this.owner.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ return this.maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ resultInventory.setMaxStackSize(size);
|
||||
+ this.maxStack = size;
|
||||
+ this.resultInventory.setMaxStackSize(size);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return menu instanceof ContainerWorkbench ? ((ContainerWorkbench) menu).access.getLocation() : owner.getBukkitEntity().getLocation();
|
||||
+ return this.menu instanceof CraftingMenu ? ((CraftingMenu) this.menu).access.getLocation() : this.owner.getBukkitEntity().getLocation();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public RecipeHolder<?> getCurrentRecipe() {
|
||||
+ return currentRecipe;
|
||||
+ return this.currentRecipe;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@@ -77,12 +82,12 @@
|
||||
+ this.currentRecipe = currentRecipe;
|
||||
+ }
|
||||
+
|
||||
+ public TransientCraftingContainer(Container container, int i, int j, EntityHuman player) {
|
||||
+ public TransientCraftingContainer(AbstractContainerMenu container, int i, int j, Player 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));
|
||||
public TransientCraftingContainer(AbstractContainerMenu handler, int width, int height) {
|
||||
this(handler, width, height, NonNullList.withSize(width * height, ItemStack.EMPTY));
|
||||
}
|
||||
Reference in New Issue
Block a user