@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/inventory/Container.java
|
||||
+++ b/net/minecraft/world/inventory/Container.java
|
||||
@@ -32,6 +32,20 @@
|
||||
@@ -33,6 +33,20 @@
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
public abstract class Container {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -62,6 +76,27 @@
|
||||
@@ -63,6 +77,27 @@
|
||||
private ContainerSynchronizer synchronizer;
|
||||
private boolean suppressRemoteUpdates;
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
protected Container(@Nullable Containers<?> containers, int i) {
|
||||
this.carried = ItemStack.EMPTY;
|
||||
this.remoteSlots = NonNullList.create();
|
||||
@@ -163,6 +198,15 @@
|
||||
@@ -164,6 +199,15 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
public void removeSlotListener(ICrafting icrafting) {
|
||||
this.containerListeners.remove(icrafting);
|
||||
}
|
||||
@@ -379,7 +423,7 @@
|
||||
@@ -380,7 +424,7 @@
|
||||
}
|
||||
} else if (this.quickcraftStatus == 2) {
|
||||
if (!this.quickcraftSlots.isEmpty()) {
|
||||
@@ -74,7 +74,7 @@
|
||||
k = ((Slot) this.quickcraftSlots.iterator().next()).index;
|
||||
this.resetQuickCraft();
|
||||
this.doClick(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman);
|
||||
@@ -390,6 +434,7 @@
|
||||
@@ -391,6 +435,7 @@
|
||||
l = this.getCarried().getCount();
|
||||
Iterator iterator = this.quickcraftSlots.iterator();
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Slot slot1 = (Slot) iterator.next();
|
||||
ItemStack itemstack2 = this.getCarried();
|
||||
@@ -406,12 +451,48 @@
|
||||
@@ -407,12 +452,48 @@
|
||||
}
|
||||
|
||||
l -= itemstack3.getCount() - j1;
|
||||
@@ -134,7 +134,7 @@
|
||||
}
|
||||
|
||||
this.resetQuickCraft();
|
||||
@@ -429,8 +510,11 @@
|
||||
@@ -430,8 +511,11 @@
|
||||
if (i == -999) {
|
||||
if (!this.getCarried().isEmpty()) {
|
||||
if (clickaction == ClickAction.PRIMARY) {
|
||||
@@ -147,7 +147,7 @@
|
||||
} else {
|
||||
entityhuman.drop(this.getCarried().split(1), true);
|
||||
}
|
||||
@@ -493,6 +577,15 @@
|
||||
@@ -494,6 +578,15 @@
|
||||
}
|
||||
|
||||
slot.setChanged();
|
||||
@@ -163,7 +163,7 @@
|
||||
}
|
||||
} else {
|
||||
Slot slot2;
|
||||
@@ -600,13 +693,14 @@
|
||||
@@ -607,13 +700,14 @@
|
||||
ItemStack itemstack = this.getCarried();
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
@@ -179,7 +179,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -820,6 +914,11 @@
|
||||
@@ -827,6 +921,11 @@
|
||||
}
|
||||
|
||||
public ItemStack getCarried() {
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
|
||||
+ org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3];
|
||||
+ for (j = 0; j < 3; ++j) {
|
||||
+ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(IRegistry.ENCHANTMENT.byId(this.enchantClue[j])))) : null;
|
||||
+ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.ENCHANTMENT.getKey(BuiltInRegistries.ENCHANTMENT.byId(this.enchantClue[j])))) : null;
|
||||
+ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levelClue[j], this.costs[j]) : null;
|
||||
+ }
|
||||
+
|
||||
@@ -95,7 +95,7 @@
|
||||
+ EnchantmentOffer offer = event.getOffers()[j];
|
||||
+ if (offer != null) {
|
||||
+ this.costs[j] = offer.getCost();
|
||||
+ this.enchantClue[j] = IRegistry.ENCHANTMENT.getId(IRegistry.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey())));
|
||||
+ this.enchantClue[j] = BuiltInRegistries.ENCHANTMENT.getId(BuiltInRegistries.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey())));
|
||||
+ this.levelClue[j] = offer.getEnchantmentLevel();
|
||||
+ } else {
|
||||
+ this.costs[j] = 0;
|
||||
@@ -121,7 +121,7 @@
|
||||
+ Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
|
||||
+ for (Object obj : list) {
|
||||
+ WeightedRandomEnchant instance = (WeightedRandomEnchant) obj;
|
||||
+ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(instance.enchantment))), instance.level);
|
||||
+ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.ENCHANTMENT.getKey(instance.enchantment))), instance.level);
|
||||
+ }
|
||||
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2);
|
||||
+
|
||||
@@ -150,7 +150,7 @@
|
||||
+ try {
|
||||
+ if (flag) {
|
||||
+ NamespacedKey enchantId = entry.getKey().getKey();
|
||||
+ Enchantment nms = IRegistry.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(enchantId));
|
||||
+ Enchantment nms = BuiltInRegistries.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(enchantId));
|
||||
+ if (nms == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
|
||||
@@ -18,25 +18,27 @@
|
||||
|
||||
public ContainerSmithing(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -61,13 +66,15 @@
|
||||
@@ -61,7 +66,7 @@
|
||||
List<RecipeSmithing> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
} else {
|
||||
this.selectedRecipe = (RecipeSmithing) list.get(0);
|
||||
ItemStack itemstack = this.selectedRecipe.assemble(this.inputSlots);
|
||||
|
||||
this.resultSlots.setRecipeUsed(this.selectedRecipe);
|
||||
- this.resultSlots.setItem(0, itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
|
||||
+ // CraftBukkit end
|
||||
RecipeSmithing recipesmithing = (RecipeSmithing) list.get(0);
|
||||
ItemStack itemstack = recipesmithing.assemble(this.inputSlots);
|
||||
@@ -69,7 +74,9 @@
|
||||
if (itemstack.isItemEnabled(this.level.enabledFeatures())) {
|
||||
this.selectedRecipe = recipesmithing;
|
||||
this.resultSlots.setRecipeUsed(recipesmithing);
|
||||
- this.resultSlots.setItem(0, itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,4 +90,18 @@
|
||||
@@ -86,4 +93,18 @@
|
||||
public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) {
|
||||
return slot.container != this.resultSlots && super.canTakeItemForPickAll(itemstack, slot);
|
||||
}
|
||||
|
||||
@@ -36,15 +36,15 @@
|
||||
this.access = containeraccess;
|
||||
this.player = playerinventory.player;
|
||||
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35));
|
||||
@@ -74,6 +86,7 @@
|
||||
itemstack = recipecrafting.assemble(inventorycrafting);
|
||||
@@ -78,6 +90,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), optional.orElse(null) instanceof RecipeRepair); // CraftBukkit
|
||||
|
||||
inventorycraftresult.setItem(0, itemstack);
|
||||
container.setRemoteSlot(0, itemstack);
|
||||
@@ -114,6 +127,7 @@
|
||||
@@ -118,6 +131,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
@@ -52,7 +52,7 @@
|
||||
return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE);
|
||||
}
|
||||
|
||||
@@ -202,4 +216,17 @@
|
||||
@@ -206,4 +220,17 @@
|
||||
public boolean shouldMoveToInventory(int i) {
|
||||
return i != this.getResultSlotIndex();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/inventory/Containers.java
|
||||
+++ b/net/minecraft/world/inventory/Containers.java
|
||||
@@ -3,6 +3,10 @@
|
||||
import net.minecraft.core.IRegistry;
|
||||
@@ -4,6 +4,10 @@
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.entity.player.PlayerInventory;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -11,7 +11,7 @@
|
||||
public class Containers<T extends Container> {
|
||||
|
||||
public static final Containers<ContainerChest> GENERIC_9x1 = register("generic_9x1", ContainerChest::oneRow);
|
||||
@@ -22,7 +26,7 @@
|
||||
@@ -23,7 +27,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) -> {
|
||||
|
||||
Reference in New Issue
Block a user