Update to Minecraft 1.20.2

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-09-22 02:40:00 +10:00
parent 193398c0ff
commit 8a3c8cfcd4
238 changed files with 2448 additions and 2344 deletions

View File

@@ -179,7 +179,7 @@
}
}
@@ -830,6 +924,11 @@
@@ -828,6 +922,11 @@
}
public ItemStack getCarried() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerBeacon.java
+++ b/net/minecraft/world/inventory/ContainerBeacon.java
@@ -11,6 +11,11 @@
@@ -12,6 +12,11 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Blocks;
@@ -12,7 +12,7 @@
public class ContainerBeacon extends Container {
private static final int PAYMENT_SLOT = 0;
@@ -24,6 +29,10 @@
@@ -26,6 +31,10 @@
private final ContainerBeacon.SlotBeacon paymentSlot;
private final ContainerAccess access;
private final IContainerProperties beaconData;
@@ -23,7 +23,7 @@
public ContainerBeacon(int i, IInventory iinventory) {
this(i, iinventory, new ContainerProperties(3), ContainerAccess.NULL);
@@ -31,6 +40,7 @@
@@ -33,6 +42,7 @@
public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) {
super(Containers.BEACON, i);
@@ -31,7 +31,7 @@
this.beacon = new InventorySubcontainer(1) {
@Override
public boolean canPlaceItem(int j, ItemStack itemstack) {
@@ -80,6 +90,7 @@
@@ -82,6 +92,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -39,7 +39,18 @@
return stillValid(this.access, entityhuman, Blocks.BEACON);
}
@@ -180,4 +191,17 @@
@@ -163,8 +174,8 @@
public void updateEffects(Optional<MobEffectList> optional, Optional<MobEffectList> optional1) {
if (this.paymentSlot.hasItem()) {
- this.beaconData.set(1, encodeEffect((MobEffectList) optional.orElse((Object) null)));
- this.beaconData.set(2, encodeEffect((MobEffectList) optional1.orElse((Object) null)));
+ this.beaconData.set(1, encodeEffect((MobEffectList) optional.orElse(null))); // CraftBukkit - decompile error
+ this.beaconData.set(2, encodeEffect((MobEffectList) optional1.orElse(null))); // CraftBukkit - decompile error
this.paymentSlot.remove(1);
this.access.execute(World::blockEntityChanged);
}
@@ -191,4 +202,17 @@
return 1;
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerEnchantTable.java
+++ b/net/minecraft/world/inventory/ContainerEnchantTable.java
@@ -25,6 +25,21 @@
@@ -27,6 +27,21 @@
import net.minecraft.world.level.block.BlockEnchantmentTable;
import net.minecraft.world.level.block.Blocks;
@@ -21,8 +21,8 @@
+
public class ContainerEnchantTable extends Container {
private final IInventory enchantSlots;
@@ -34,6 +49,10 @@
static final MinecraftKey EMPTY_SLOT_LAPIS_LAZULI = new MinecraftKey("item/empty_slot_lapis_lazuli");
@@ -37,6 +52,10 @@
public final int[] costs;
public final int[] enchantClue;
public final int[] levelClue;
@@ -33,7 +33,7 @@
public ContainerEnchantTable(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -47,6 +66,13 @@
@@ -50,6 +69,13 @@
super.setChanged();
ContainerEnchantTable.this.slotsChanged(this);
}
@@ -47,7 +47,7 @@
};
this.random = RandomSource.create();
this.enchantmentSeed = ContainerProperty.standalone();
@@ -94,6 +120,9 @@
@@ -97,6 +123,9 @@
this.addDataSlot(ContainerProperty.shared(this.levelClue, 0));
this.addDataSlot(ContainerProperty.shared(this.levelClue, 1));
this.addDataSlot(ContainerProperty.shared(this.levelClue, 2));
@@ -57,7 +57,7 @@
}
@Override
@@ -101,7 +130,7 @@
@@ -104,7 +133,7 @@
if (iinventory == this.enchantSlots) {
ItemStack itemstack = iinventory.getItem(0);
@@ -66,7 +66,7 @@
this.access.execute((world, blockposition) -> {
int i = 0;
Iterator iterator = BlockEnchantmentTable.BOOKSHELF_OFFSETS.iterator();
@@ -140,6 +169,41 @@
@@ -143,6 +172,41 @@
}
}
@@ -108,7 +108,7 @@
this.broadcastChanges();
});
} else {
@@ -167,9 +231,26 @@
@@ -170,8 +234,25 @@
ItemStack itemstack2 = itemstack;
List<WeightedRandomEnchant> list = this.getEnchantmentList(itemstack, i, this.costs[i]);
@@ -117,10 +117,8 @@
+ // CraftBukkit start
+ if (true || !list.isEmpty()) {
+ // entityhuman.onEnchantmentPerformed(itemstack, j); // Moved down
boolean flag = itemstack.is(Items.BOOK);
+ Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
+ for (Object obj : list) {
+ WeightedRandomEnchant instance = (WeightedRandomEnchant) obj;
+ for (WeightedRandomEnchant instance : list) {
+ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.ENCHANTMENT.getKey(instance.enchantment))), instance.level);
+ }
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2);
@@ -134,20 +132,24 @@
+ if (event.isCancelled() || (level > entityhuman.experienceLevel && !entityhuman.getAbilities().instabuild) || event.getEnchantsToAdd().isEmpty()) {
+ return;
+ }
+ // CraftBukkit end
boolean flag = itemstack.is(Items.BOOK);
if (flag) {
itemstack2 = new ItemStack(Items.ENCHANTED_BOOK);
@@ -182,16 +263,29 @@
@@ -185,18 +266,30 @@
this.enchantSlots.setItem(0, itemstack2);
}
- for (int k = 0; k < list.size(); ++k) {
- WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) list.get(k);
- Iterator iterator = list.iterator();
-
- while (iterator.hasNext()) {
- WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) iterator.next();
-
- if (flag) {
- ItemEnchantedBook.addEnchantment(itemstack2, weightedrandomenchant);
- } else {
- itemstack2.enchant(weightedrandomenchant.enchantment, weightedrandomenchant.level);
+ // CraftBukkit start
+ for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) {
+ try {
+ if (flag) {
@@ -174,7 +176,7 @@
if (!entityhuman.getAbilities().instabuild) {
itemstack1.shrink(j);
if (itemstack1.isEmpty()) {
@@ -254,6 +348,7 @@
@@ -259,6 +352,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -182,7 +184,7 @@
return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE);
}
@@ -304,4 +399,17 @@
@@ -309,4 +403,17 @@
return itemstack;
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerFurnace.java
+++ b/net/minecraft/world/inventory/ContainerFurnace.java
@@ -12,6 +12,11 @@
@@ -14,6 +14,11 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.entity.TileEntityFurnace;
@@ -12,7 +12,7 @@
public abstract class ContainerFurnace extends ContainerRecipeBook<IInventory> {
public static final int INGREDIENT_SLOT = 0;
@@ -29,6 +34,22 @@
@@ -31,6 +36,22 @@
private final Recipes<? extends RecipeCooking> recipeType;
private final RecipeBookType recipeBookType;
@@ -35,7 +35,7 @@
protected ContainerFurnace(Containers<?> containers, Recipes<? extends RecipeCooking> recipes, RecipeBookType recipebooktype, int i, PlayerInventory playerinventory) {
this(containers, recipes, recipebooktype, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4));
}
@@ -45,6 +66,7 @@
@@ -47,6 +68,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));
@@ -43,7 +43,7 @@
int j;
@@ -102,6 +124,7 @@
@@ -104,6 +126,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -51,7 +51,7 @@
return this.container.stillValid(entityhuman);
}
@@ -157,7 +180,7 @@
@@ -159,7 +182,7 @@
}
protected boolean canSmelt(ItemStack itemstack) {

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/inventory/ContainerPlayer.java
+++ b/net/minecraft/world/inventory/ContainerPlayer.java
@@ -13,6 +13,12 @@
import net.minecraft.world.item.crafting.IRecipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.enchantment.EnchantmentManager;
+// CraftBukkit start
@@ -44,7 +44,7 @@
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28));
int i;
@@ -264,4 +283,17 @@
@@ -259,4 +278,17 @@
public boolean shouldMoveToInventory(int i) {
return i != this.getResultSlotIndex();
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerSmithing.java
+++ b/net/minecraft/world/inventory/ContainerSmithing.java
@@ -12,6 +12,8 @@
@@ -13,6 +13,8 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
@@ -9,29 +9,29 @@
public class ContainerSmithing extends ContainerAnvilAbstract {
public static final int TEMPLATE_SLOT = 0;
@@ -27,6 +29,9 @@
@@ -28,6 +30,9 @@
@Nullable
private SmithingRecipe selectedRecipe;
private final List<SmithingRecipe> recipes;
private RecipeHolder<SmithingRecipe> selectedRecipe;
private final List<RecipeHolder<SmithingRecipe>> recipes;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity;
+ // CraftBukkit end
public ContainerSmithing(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -96,7 +101,7 @@
List<SmithingRecipe> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level);
@@ -97,7 +102,7 @@
List<RecipeHolder<SmithingRecipe>> 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 {
SmithingRecipe smithingrecipe = (SmithingRecipe) list.get(0);
ItemStack itemstack = smithingrecipe.assemble(this.inputSlots, this.level.registryAccess());
@@ -104,7 +109,9 @@
RecipeHolder<SmithingRecipe> recipeholder = (RecipeHolder) list.get(0);
ItemStack itemstack = ((SmithingRecipe) recipeholder.value()).assemble(this.inputSlots, this.level.registryAccess());
@@ -105,7 +110,9 @@
if (itemstack.isItemEnabled(this.level.enabledFeatures())) {
this.selectedRecipe = smithingrecipe;
this.resultSlots.setRecipeUsed(smithingrecipe);
this.selectedRecipe = recipeholder;
this.resultSlots.setRecipeUsed(recipeholder);
- this.resultSlots.setItem(0, itemstack);
+ // CraftBukkit start
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
@@ -39,9 +39,9 @@
}
}
@@ -132,4 +139,18 @@
return findSlotMatchingIngredient(smithingrecipe, itemstack);
}).anyMatch(Optional::isPresent);
@@ -137,4 +144,18 @@
return !this.getSlot(i).hasItem();
}).findFirst();
}
+
+ // CraftBukkit start

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerStonecutter.java
+++ b/net/minecraft/world/inventory/ContainerStonecutter.java
@@ -15,6 +15,13 @@
@@ -16,6 +16,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;
@@ -34,6 +41,21 @@
@@ -35,6 +42,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);
@@ -53,6 +75,13 @@
@@ -54,6 +76,13 @@
ContainerStonecutter.this.slotsChanged(this);
ContainerStonecutter.this.slotUpdateListener.run();
}
@@ -50,7 +50,7 @@
};
this.resultContainer = new InventoryCraftResult();
this.access = containeraccess;
@@ -104,6 +133,7 @@
@@ -105,6 +134,7 @@
}
this.addDataSlot(this.selectedRecipeIndex);
@@ -58,7 +58,7 @@
}
public int getSelectedRecipeIndex() {
@@ -124,6 +154,7 @@
@@ -125,6 +155,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerWorkbench.java
+++ b/net/minecraft/world/inventory/ContainerWorkbench.java
@@ -14,6 +14,12 @@
@@ -15,6 +15,12 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Blocks;
@@ -13,7 +13,7 @@
public class ContainerWorkbench extends ContainerRecipeBook<InventoryCrafting> {
public static final int RESULT_SLOT = 0;
@@ -23,10 +29,13 @@
@@ -24,10 +30,13 @@
private static final int INV_SLOT_END = 37;
private static final int USE_ROW_SLOT_START = 37;
private static final int USE_ROW_SLOT_END = 46;
@@ -28,7 +28,7 @@
public ContainerWorkbench(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -34,8 +43,11 @@
@@ -35,8 +44,11 @@
public ContainerWorkbench(int i, PlayerInventory playerinventory, ContainerAccess containeraccess) {
super(Containers.CRAFTING, i);
@@ -41,15 +41,15 @@
this.access = containeraccess;
this.player = playerinventory.player;
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 124, 35));
@@ -78,6 +90,7 @@
@@ -80,6 +92,7 @@
}
}
}
+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), optional.orElse(null) instanceof RecipeRepair); // CraftBukkit
+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), optional.map(RecipeHolder::toBukkitRecipe).orElse(null) instanceof RecipeRepair); // CraftBukkit
inventorycraftresult.setItem(0, itemstack);
container.setRemoteSlot(0, itemstack);
@@ -118,6 +131,7 @@
@@ -120,6 +133,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
@@ -57,7 +57,7 @@
return stillValid(this.access, entityhuman, Blocks.CRAFTING_TABLE);
}
@@ -206,4 +220,17 @@
@@ -208,4 +222,17 @@
public boolean shouldMoveToInventory(int i) {
return i != this.getResultSlotIndex();
}

View File

@@ -2,7 +2,7 @@
+++ b/net/minecraft/world/inventory/InventoryCraftResult.java
@@ -9,12 +9,51 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.IRecipe;
import net.minecraft.world.item.crafting.RecipeHolder;
+// CraftBukkit start
+import org.bukkit.Location;
@@ -10,11 +10,11 @@
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class InventoryCraftResult implements IInventory, RecipeHolder {
public class InventoryCraftResult implements IInventory, RecipeCraftingHolder {
private final NonNullList<ItemStack> itemStacks;
@Nullable
private IRecipe<?> recipeUsed;
private RecipeHolder<?> recipeUsed;
+ // CraftBukkit start
+ private int maxStack = MAX_STACK;

View File

@@ -7,7 +7,7 @@
+// CraftBukkit start
+import java.util.List;
+import net.minecraft.world.IInventory;
+import net.minecraft.world.item.crafting.IRecipe;
+import net.minecraft.world.item.crafting.RecipeHolder;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
@@ -23,7 +23,7 @@
+ // CraftBukkit start - add fields
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private IRecipe currentRecipe;
+ private RecipeHolder<?> currentRecipe;
+ public IInventory resultInventory;
+ private EntityHuman owner;
+ private int maxStack = MAX_STACK;
@@ -68,12 +68,12 @@
+ }
+
+ @Override
+ public IRecipe getCurrentRecipe() {
+ public RecipeHolder<?> getCurrentRecipe() {
+ return currentRecipe;
+ }
+
+ @Override
+ public void setCurrentRecipe(IRecipe currentRecipe) {
+ public void setCurrentRecipe(RecipeHolder<?> currentRecipe) {
+ this.currentRecipe = currentRecipe;
+ }
+