@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerEnchantTable.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerEnchantTable.java
|
||||
@@ -25,6 +25,22 @@
|
||||
@@ -31,6 +31,22 @@
|
||||
import net.minecraft.world.level.block.BlockEnchantmentTable;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
+
|
||||
public class ContainerEnchantTable extends Container {
|
||||
|
||||
static final MinecraftKey EMPTY_SLOT_LAPIS_LAZULI = new MinecraftKey("item/empty_slot_lapis_lazuli");
|
||||
@@ -35,6 +51,10 @@
|
||||
static final MinecraftKey EMPTY_SLOT_LAPIS_LAZULI = MinecraftKey.withDefaultNamespace("item/empty_slot_lapis_lazuli");
|
||||
@@ -41,6 +57,10 @@
|
||||
public final int[] costs;
|
||||
public final int[] enchantClue;
|
||||
public final int[] levelClue;
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
public ContainerEnchantTable(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -48,6 +68,13 @@
|
||||
@@ -54,6 +74,13 @@
|
||||
super.setChanged();
|
||||
ContainerEnchantTable.this.slotsChanged(this);
|
||||
}
|
||||
@@ -48,7 +48,7 @@
|
||||
};
|
||||
this.random = RandomSource.create();
|
||||
this.enchantmentSeed = ContainerProperty.standalone();
|
||||
@@ -55,13 +82,13 @@
|
||||
@@ -61,13 +88,13 @@
|
||||
this.enchantClue = new int[]{-1, -1, -1};
|
||||
this.levelClue = new int[]{-1, -1, -1};
|
||||
this.access = containeraccess;
|
||||
@@ -64,7 +64,7 @@
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.is(Items.LAPIS_LAZULI);
|
||||
@@ -95,6 +122,9 @@
|
||||
@@ -101,6 +128,9 @@
|
||||
this.addDataSlot(ContainerProperty.shared(this.levelClue, 0));
|
||||
this.addDataSlot(ContainerProperty.shared(this.levelClue, 1));
|
||||
this.addDataSlot(ContainerProperty.shared(this.levelClue, 2));
|
||||
@@ -74,16 +74,16 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,7 +132,7 @@
|
||||
@@ -108,7 +138,7 @@
|
||||
if (iinventory == this.enchantSlots) {
|
||||
ItemStack itemstack = iinventory.getItem(0);
|
||||
|
||||
- if (!itemstack.isEmpty() && itemstack.isEnchantable()) {
|
||||
+ if (!itemstack.isEmpty()) { // CraftBukkit - relax condition
|
||||
this.access.execute((world, blockposition) -> {
|
||||
Registry<Holder<Enchantment>> registry = world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap();
|
||||
int i = 0;
|
||||
Iterator iterator = BlockEnchantmentTable.BOOKSHELF_OFFSETS.iterator();
|
||||
@@ -141,6 +171,41 @@
|
||||
@@ -148,6 +178,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,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) ? CraftEnchantment.minecraftToBukkit(Enchantment.byId(this.enchantClue[j])) : null;
|
||||
+ org.bukkit.enchantments.Enchantment enchantment = (this.enchantClue[j] >= 0) ? CraftEnchantment.minecraftHolderToBukkit(registry.byId(this.enchantClue[j])) : null;
|
||||
+ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levelClue[j], this.costs[j]) : null;
|
||||
+ }
|
||||
+
|
||||
@@ -112,7 +112,7 @@
|
||||
+ EnchantmentOffer offer = event.getOffers()[j];
|
||||
+ if (offer != null) {
|
||||
+ this.costs[j] = offer.getCost();
|
||||
+ this.enchantClue[j] = BuiltInRegistries.ENCHANTMENT.getId(CraftEnchantment.bukkitToMinecraft(offer.getEnchantment()));
|
||||
+ this.enchantClue[j] = registry.getId(CraftEnchantment.bukkitToMinecraftHolder(offer.getEnchantment()));
|
||||
+ this.levelClue[j] = offer.getEnchantmentLevel();
|
||||
+ } else {
|
||||
+ this.costs[j] = 0;
|
||||
@@ -125,22 +125,23 @@
|
||||
this.broadcastChanges();
|
||||
});
|
||||
} else {
|
||||
@@ -168,21 +233,46 @@
|
||||
@@ -175,21 +240,46 @@
|
||||
ItemStack itemstack2 = itemstack;
|
||||
List<WeightedRandomEnchant> list = this.getEnchantmentList(world.enabledFeatures(), itemstack, i, this.costs[i]);
|
||||
List<WeightedRandomEnchant> list = this.getEnchantmentList(world.registryAccess(), itemstack, i, this.costs[i]);
|
||||
|
||||
- if (!list.isEmpty()) {
|
||||
- entityhuman.onEnchantmentPerformed(itemstack, j);
|
||||
+ // CraftBukkit start
|
||||
+ Registry<Holder<Enchantment>> registry = world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).asHolderIdMap();
|
||||
+ if (true || !list.isEmpty()) {
|
||||
+ // entityhuman.onEnchantmentPerformed(itemstack, j); // Moved down
|
||||
+ Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
|
||||
+ for (WeightedRandomEnchant instance : list) {
|
||||
+ enchants.put(CraftEnchantment.minecraftToBukkit(instance.enchantment), instance.level);
|
||||
+ enchants.put(CraftEnchantment.minecraftHolderToBukkit(instance.enchantment), instance.level);
|
||||
+ }
|
||||
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2);
|
||||
+
|
||||
+ org.bukkit.enchantments.Enchantment hintedEnchantment = CraftEnchantment.minecraftToBukkit(Enchantment.byId(enchantClue[i]));
|
||||
+ org.bukkit.enchantments.Enchantment hintedEnchantment = CraftEnchantment.minecraftHolderToBukkit(registry.byId(enchantClue[i]));
|
||||
+ int hintedEnchantmentLevel = levelClue[i];
|
||||
+ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[i], enchants, hintedEnchantment, hintedEnchantmentLevel, i);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
@@ -151,7 +152,7 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (itemstack.is(Items.BOOK)) {
|
||||
itemstack2 = itemstack.transmuteCopy(Items.ENCHANTED_BOOK, 1);
|
||||
itemstack2 = itemstack.transmuteCopy(Items.ENCHANTED_BOOK);
|
||||
this.enchantSlots.setItem(0, itemstack2);
|
||||
}
|
||||
|
||||
@@ -161,8 +162,7 @@
|
||||
- WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) iterator.next();
|
||||
+ // CraftBukkit start
|
||||
+ for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) {
|
||||
+ NamespacedKey enchantId = entry.getKey().getKey();
|
||||
+ Enchantment nms = BuiltInRegistries.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(enchantId));
|
||||
+ Holder<Enchantment> nms = CraftEnchantment.bukkitToMinecraftHolder(entry.getKey());
|
||||
+ if (nms == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
@@ -175,10 +175,10 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ // CraftBukkit - TODO: let plugins change this
|
||||
if (!entityhuman.hasInfiniteMaterials()) {
|
||||
itemstack1.shrink(j);
|
||||
if (itemstack1.isEmpty()) {
|
||||
@@ -245,6 +335,7 @@
|
||||
itemstack1.consume(j, entityhuman);
|
||||
if (itemstack1.isEmpty()) {
|
||||
this.enchantSlots.setItem(1, ItemStack.EMPTY);
|
||||
@@ -256,6 +346,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
@@ -186,7 +186,7 @@
|
||||
return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE);
|
||||
}
|
||||
|
||||
@@ -295,4 +386,17 @@
|
||||
@@ -306,4 +397,17 @@
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class ContainerFurnace extends ContainerRecipeBook<IInventory> {
|
||||
public abstract class ContainerFurnace extends ContainerRecipeBook<SingleRecipeInput, RecipeCooking> {
|
||||
|
||||
public static final int INGREDIENT_SLOT = 0;
|
||||
@@ -31,6 +36,22 @@
|
||||
@@ -51,12 +51,3 @@
|
||||
return this.container.stillValid(entityhuman);
|
||||
}
|
||||
|
||||
@@ -159,7 +182,7 @@
|
||||
}
|
||||
|
||||
protected boolean canSmelt(ItemStack itemstack) {
|
||||
- return this.level.getRecipeManager().getRecipeFor(this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent();
|
||||
+ return this.level.getRecipeManager().getRecipeFor((Recipes<RecipeCooking>) this.recipeType, new InventorySubcontainer(new ItemStack[]{itemstack}), this.level).isPresent(); // Eclipse fail
|
||||
}
|
||||
|
||||
protected boolean isFuel(ItemStack itemstack) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerGrindstone.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerGrindstone.java
|
||||
@@ -19,8 +19,30 @@
|
||||
@@ -20,8 +20,30 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
public static final int MAX_NAME_LENGTH = 35;
|
||||
public static final int INPUT_SLOT = 0;
|
||||
public static final int ADDITIONAL_SLOT = 1;
|
||||
@@ -46,15 +68,22 @@
|
||||
@@ -47,15 +69,22 @@
|
||||
super.setChanged();
|
||||
ContainerGrindstone.this.slotsChanged(this);
|
||||
}
|
||||
@@ -56,7 +56,7 @@
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.isDamageableItem() || EnchantmentManager.hasAnyEnchantments(itemstack);
|
||||
@@ -124,6 +153,7 @@
|
||||
@@ -125,6 +154,7 @@
|
||||
this.addSlot(new Slot(playerinventory, j, 8 + j * 18, 142));
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,7 +166,8 @@
|
||||
@@ -137,7 +167,8 @@
|
||||
}
|
||||
|
||||
private void createResult() {
|
||||
@@ -74,7 +74,7 @@
|
||||
this.broadcastChanges();
|
||||
}
|
||||
|
||||
@@ -238,6 +269,7 @@
|
||||
@@ -239,6 +270,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerHorse.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerHorse.java
|
||||
@@ -9,6 +9,11 @@
|
||||
@@ -10,6 +10,11 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
public class ContainerHorse extends Container {
|
||||
|
||||
private final IInventory horseContainer;
|
||||
@@ -17,8 +22,23 @@
|
||||
@@ -18,8 +23,23 @@
|
||||
private static final int SLOT_BODY_ARMOR = 1;
|
||||
private static final int SLOT_HORSE_INVENTORY_START = 2;
|
||||
|
||||
@@ -29,14 +29,14 @@
|
||||
+ return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), horseContainer.getOwner().getInventory(), this);
|
||||
+ }
|
||||
+
|
||||
public ContainerHorse(int i, PlayerInventory playerinventory, IInventory iinventory, final EntityHorseAbstract entityhorseabstract) {
|
||||
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;
|
||||
@@ -27,7 +47,7 @@
|
||||
@@ -28,7 +48,7 @@
|
||||
iinventory.startOpen(playerinventory.player);
|
||||
boolean flag1 = true;
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return itemstack.is(Items.SADDLE) && !this.hasItem() && entityhorseabstract.isSaddleable();
|
||||
@@ -38,7 +58,7 @@
|
||||
@@ -39,7 +59,7 @@
|
||||
return entityhorseabstract.isSaddleable();
|
||||
}
|
||||
});
|
||||
- this.addSlot(new Slot(this, this.armorContainer, 0, 8, 36) {
|
||||
+ this.addSlot(new Slot(this.armorContainer, 0, 8, 36) { // CraftBukkit - decompile error
|
||||
- this.addSlot(new ArmorSlot(this, this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, (MinecraftKey) null) {
|
||||
+ this.addSlot(new ArmorSlot(this.armorContainer, entityhorseabstract, EnumItemSlot.BODY, 0, 8, 36, (MinecraftKey) null) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack itemstack) {
|
||||
return entityhorseabstract.isBodyArmorItem(itemstack);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerPlayer.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerPlayer.java
|
||||
@@ -13,6 +13,12 @@
|
||||
import net.minecraft.world.item.crafting.RecipeCrafting;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentManager;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.network.chat.IChatBaseComponent;
|
||||
@@ -10,12 +10,12 @@
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerPlayer extends ContainerRecipeBook<InventoryCrafting> {
|
||||
public class ContainerPlayer extends ContainerRecipeBook<CraftingInput, RecipeCrafting> {
|
||||
|
||||
public static final int CONTAINER_ID = 0;
|
||||
@@ -36,15 +42,28 @@
|
||||
public static final MinecraftKey EMPTY_ARMOR_SLOT_SHIELD = new MinecraftKey("item/empty_armor_slot_shield");
|
||||
static final MinecraftKey[] TEXTURE_EMPTY_SLOTS = new MinecraftKey[]{ContainerPlayer.EMPTY_ARMOR_SLOT_BOOTS, ContainerPlayer.EMPTY_ARMOR_SLOT_LEGGINGS, ContainerPlayer.EMPTY_ARMOR_SLOT_CHESTPLATE, ContainerPlayer.EMPTY_ARMOR_SLOT_HELMET};
|
||||
public static final MinecraftKey EMPTY_ARMOR_SLOT_SHIELD = MinecraftKey.withDefaultNamespace("item/empty_armor_slot_shield");
|
||||
private static final Map<EnumItemSlot, MinecraftKey> TEXTURE_EMPTY_SLOTS = Map.of(EnumItemSlot.FEET, ContainerPlayer.EMPTY_ARMOR_SLOT_BOOTS, EnumItemSlot.LEGS, ContainerPlayer.EMPTY_ARMOR_SLOT_LEGGINGS, EnumItemSlot.CHEST, ContainerPlayer.EMPTY_ARMOR_SLOT_CHESTPLATE, EnumItemSlot.HEAD, ContainerPlayer.EMPTY_ARMOR_SLOT_HELMET);
|
||||
private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
|
||||
- private final InventoryCrafting craftSlots = new TransientCraftingContainer(this, 2, 2);
|
||||
- private final InventoryCraftResult resultSlots = new InventoryCraftResult();
|
||||
@@ -44,16 +44,7 @@
|
||||
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28));
|
||||
|
||||
int i;
|
||||
@@ -59,7 +78,7 @@
|
||||
for (i = 0; i < 4; ++i) {
|
||||
final EnumItemSlot enumitemslot = ContainerPlayer.SLOT_IDS[i];
|
||||
|
||||
- this.addSlot(new Slot(this, playerinventory, 39 - i, 8, 8 + i * 18) {
|
||||
+ this.addSlot(new Slot(playerinventory, 39 - i, 8, 8 + i * 18) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public void setByPlayer(ItemStack itemstack, ItemStack itemstack1) {
|
||||
ContainerPlayer.onEquipItem(entityhuman, enumitemslot, itemstack, itemstack1);
|
||||
@@ -100,7 +119,7 @@
|
||||
@@ -73,7 +92,7 @@
|
||||
this.addSlot(new Slot(playerinventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
|
||||
@@ -61,8 +52,8 @@
|
||||
+ this.addSlot(new Slot(playerinventory, 40, 77, 62) { // CraftBukkit - decompile error
|
||||
@Override
|
||||
public void setByPlayer(ItemStack itemstack, ItemStack itemstack1) {
|
||||
ContainerPlayer.onEquipItem(entityhuman, EnumItemSlot.OFFHAND, itemstack, itemstack1);
|
||||
@@ -261,4 +280,17 @@
|
||||
entityhuman.onEquipItem(EnumItemSlot.OFFHAND, itemstack1, itemstack);
|
||||
@@ -230,4 +249,17 @@
|
||||
public boolean shouldMoveToInventory(int i) {
|
||||
return i != this.getResultSlotIndex();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerSmithing.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerSmithing.java
|
||||
@@ -13,6 +13,8 @@
|
||||
@@ -14,6 +14,8 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
public class ContainerSmithing extends ContainerAnvilAbstract {
|
||||
|
||||
public static final int TEMPLATE_SLOT = 0;
|
||||
@@ -28,6 +30,9 @@
|
||||
@@ -29,6 +31,9 @@
|
||||
@Nullable
|
||||
private RecipeHolder<SmithingRecipe> selectedRecipe;
|
||||
private final List<RecipeHolder<SmithingRecipe>> recipes;
|
||||
@@ -19,16 +19,16 @@
|
||||
|
||||
public ContainerSmithing(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -97,7 +102,7 @@
|
||||
List<RecipeHolder<SmithingRecipe>> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level);
|
||||
@@ -103,7 +108,7 @@
|
||||
List<RecipeHolder<SmithingRecipe>> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, smithingrecipeinput, this.level);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
- this.resultSlots.setItem(0, ItemStack.EMPTY);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
|
||||
} else {
|
||||
RecipeHolder<SmithingRecipe> recipeholder = (RecipeHolder) list.get(0);
|
||||
ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(this.inputSlots, this.level.registryAccess());
|
||||
@@ -105,7 +110,9 @@
|
||||
ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(smithingrecipeinput, this.level.registryAccess());
|
||||
@@ -111,7 +116,9 @@
|
||||
if (itemstack.isItemEnabled(this.level.enabledFeatures())) {
|
||||
this.selectedRecipe = recipeholder;
|
||||
this.resultSlots.setRecipeUsed(recipeholder);
|
||||
@@ -39,7 +39,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,4 +144,18 @@
|
||||
@@ -143,4 +150,18 @@
|
||||
return !this.getSlot(i).hasItem();
|
||||
}).findFirst();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerStonecutter.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerStonecutter.java
|
||||
@@ -16,6 +16,13 @@
|
||||
@@ -17,6 +17,13 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
public class ContainerStonecutter extends Container {
|
||||
|
||||
public static final int INPUT_SLOT = 0;
|
||||
@@ -35,6 +42,21 @@
|
||||
@@ -36,6 +43,21 @@
|
||||
Runnable slotUpdateListener;
|
||||
public final IInventory container;
|
||||
final InventoryCraftResult resultContainer;
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
public ContainerStonecutter(int i, PlayerInventory playerinventory) {
|
||||
this(i, playerinventory, ContainerAccess.NULL);
|
||||
@@ -54,6 +76,13 @@
|
||||
@@ -55,6 +77,13 @@
|
||||
ContainerStonecutter.this.slotsChanged(this);
|
||||
ContainerStonecutter.this.slotUpdateListener.run();
|
||||
}
|
||||
@@ -50,7 +50,7 @@
|
||||
};
|
||||
this.resultContainer = new InventoryCraftResult();
|
||||
this.access = containeraccess;
|
||||
@@ -105,6 +134,7 @@
|
||||
@@ -106,6 +135,7 @@
|
||||
}
|
||||
|
||||
this.addDataSlot(this.selectedRecipeIndex);
|
||||
@@ -58,7 +58,7 @@
|
||||
}
|
||||
|
||||
public int getSelectedRecipeIndex() {
|
||||
@@ -125,6 +155,7 @@
|
||||
@@ -126,6 +156,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/inventory/ContainerWorkbench.java
|
||||
+++ b/net/minecraft/world/inventory/ContainerWorkbench.java
|
||||
@@ -15,6 +15,12 @@
|
||||
@@ -16,6 +16,12 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ContainerWorkbench extends ContainerRecipeBook<InventoryCrafting> {
|
||||
public class ContainerWorkbench extends ContainerRecipeBook<CraftingInput, RecipeCrafting> {
|
||||
|
||||
public static final int RESULT_SLOT = 0;
|
||||
@@ -24,10 +30,13 @@
|
||||
@@ -25,11 +31,14 @@
|
||||
private static final int INV_SLOT_END = 37;
|
||||
private static final int USE_ROW_SLOT_START = 37;
|
||||
private static final int USE_ROW_SLOT_END = 46;
|
||||
@@ -22,13 +22,14 @@
|
||||
public final InventoryCraftResult resultSlots;
|
||||
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);
|
||||
@@ -35,8 +44,11 @@
|
||||
@@ -37,8 +46,11 @@
|
||||
|
||||
public ContainerWorkbench(int i, PlayerInventory playerinventory, ContainerAccess containeraccess) {
|
||||
super(Containers.CRAFTING, i);
|
||||
@@ -41,7 +42,15 @@
|
||||
this.access = containeraccess;
|
||||
this.player = playerinventory.player;
|
||||
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35));
|
||||
@@ -80,6 +92,7 @@
|
||||
@@ -70,6 +82,7 @@
|
||||
EntityPlayer entityplayer = (EntityPlayer) entityhuman;
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Optional<RecipeHolder<RecipeCrafting>> optional = world.getServer().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, world, recipeholder);
|
||||
+ inventorycrafting.setCurrentRecipe(optional.orElse(null)); // CraftBukkit
|
||||
|
||||
if (optional.isPresent()) {
|
||||
RecipeHolder<RecipeCrafting> recipeholder1 = (RecipeHolder) optional.get();
|
||||
@@ -83,6 +96,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +58,7 @@
|
||||
|
||||
inventorycraftresult.setItem(0, itemstack);
|
||||
container.setRemoteSlot(0, itemstack);
|
||||
@@ -120,6 +133,7 @@
|
||||
@@ -139,6 +153,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
@@ -57,7 +66,7 @@
|
||||
return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE);
|
||||
}
|
||||
|
||||
@@ -208,4 +222,17 @@
|
||||
@@ -227,4 +242,17 @@
|
||||
public boolean shouldMoveToInventory(int i) {
|
||||
return i != this.getResultSlotIndex();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/inventory/CrafterMenu.java
|
||||
+++ b/net/minecraft/world/inventory/CrafterMenu.java
|
||||
@@ -9,8 +9,27 @@
|
||||
@@ -10,8 +10,27 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.CrafterBlock;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
protected static final int SLOT_COUNT = 9;
|
||||
private static final int INV_SLOT_START = 9;
|
||||
private static final int INV_SLOT_END = 36;
|
||||
@@ -117,6 +136,7 @@
|
||||
@@ -118,6 +137,7 @@
|
||||
|
||||
@Override
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/world/inventory/InventoryCrafting.java
|
||||
+++ b/net/minecraft/world/inventory/InventoryCrafting.java
|
||||
@@ -5,6 +5,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingInput;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public interface InventoryCrafting extends IInventory, AutoRecipeOutput {
|
||||
|
||||
int getWidth();
|
||||
@@ -13,6 +17,15 @@
|
||||
|
||||
List<ItemStack> getItems();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ default RecipeHolder<?> getCurrentRecipe() {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ default void setCurrentRecipe(RecipeHolder<?> recipe) {
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
default CraftingInput asCraftInput() {
|
||||
return this.asPositionedCraftInput().input();
|
||||
}
|
||||
Reference in New Issue
Block a user