Update to Minecraft 1.19.4

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-03-15 03:30:00 +11:00
parent 90a887a912
commit 40076782ed
227 changed files with 2788 additions and 1621 deletions

View File

@@ -86,8 +86,8 @@
}
l -= itemstack3.getCount() - j1;
- slot1.set(itemstack3);
+ // slot1.set(itemstack3);
- slot1.setByPlayer(itemstack3);
+ // slot1.setByPlayer(itemstack3);
+ draggedSlots.put(slot1.index, itemstack3); // CraftBukkit - Put in map instead of setting
}
}

View File

@@ -10,11 +10,11 @@
+
public class ContainerAnvil extends ContainerAnvilAbstract {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -32,6 +36,11 @@
private static final int COST_REPAIR_SACRIFICE = 2;
private static final int COST_INCOMPATIBLE_PENALTY = 1;
private static final int COST_RENAME = 1;
public static final int INPUT_SLOT = 0;
@@ -39,6 +43,11 @@
private static final int ADDITIONAL_SLOT_X_PLACEMENT = 76;
private static final int RESULT_SLOT_X_PLACEMENT = 134;
private static final int SLOT_Y_PLACEMENT = 47;
+ // CraftBukkit start
+ public static final int DEFAULT_DENIED_COST = -1;
+ public int maximumRepairCost = 40;
@@ -23,7 +23,7 @@
public ContainerAnvil(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -50,7 +59,7 @@
@@ -66,7 +75,7 @@
@Override
protected boolean mayPickup(EntityHuman entityhuman, boolean flag) {
@@ -32,7 +32,7 @@
}
@Override
@@ -73,7 +82,7 @@
@@ -89,7 +98,7 @@
this.inputSlots.setItem(1, ItemStack.EMPTY);
}
@@ -41,7 +41,7 @@
this.access.execute((world, blockposition) -> {
IBlockData iblockdata = world.getBlockState(blockposition);
@@ -104,8 +113,8 @@
@@ -120,8 +129,8 @@
byte b1 = 0;
if (itemstack.isEmpty()) {
@@ -52,7 +52,7 @@
} else {
ItemStack itemstack1 = itemstack.copy();
ItemStack itemstack2 = this.inputSlots.getItem(1);
@@ -122,8 +131,8 @@
@@ -138,8 +147,8 @@
if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) {
k = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4);
if (k <= 0) {
@@ -63,7 +63,7 @@
return;
}
@@ -137,8 +146,8 @@
@@ -153,8 +162,8 @@
this.repairItemCountCost = i1;
} else {
if (!flag && (!itemstack1.is(itemstack2.getItem()) || !itemstack1.isDamageableItem())) {
@@ -74,7 +74,7 @@
return;
}
@@ -227,8 +236,8 @@
@@ -243,8 +252,8 @@
}
if (flag2 && !flag1) {
@@ -85,7 +85,7 @@
return;
}
}
@@ -251,11 +260,11 @@
@@ -267,11 +276,11 @@
itemstack1 = ItemStack.EMPTY;
}
@@ -100,7 +100,7 @@
itemstack1 = ItemStack.EMPTY;
}
@@ -274,7 +283,8 @@
@@ -290,7 +299,8 @@
EnchantmentManager.setEnchantments(map, itemstack1);
}
@@ -110,7 +110,7 @@
this.broadcastChanges();
}
}
@@ -301,4 +311,18 @@
@@ -317,4 +327,18 @@
public int getCost() {
return this.cost.get();
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerAnvilAbstract.java
+++ b/net/minecraft/world/inventory/ContainerAnvilAbstract.java
@@ -92,6 +92,7 @@
@@ -124,6 +124,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/ContainerPlayer.java
+++ b/net/minecraft/world/inventory/ContainerPlayer.java
@@ -12,6 +12,12 @@
@@ -13,6 +13,12 @@
import net.minecraft.world.item.crafting.IRecipe;
import net.minecraft.world.item.enchantment.EnchantmentManager;
@@ -13,7 +13,7 @@
public class ContainerPlayer extends ContainerRecipeBook<InventoryCrafting> {
public static final int CONTAINER_ID = 0;
@@ -33,15 +39,28 @@
@@ -34,15 +40,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};
private static final EnumItemSlot[] SLOT_IDS = new EnumItemSlot[]{EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
@@ -44,7 +44,7 @@
this.addSlot(new SlotResult(playerinventory.player, this.craftSlots, this.resultSlots, 0, 154, 28));
int i;
@@ -250,4 +269,17 @@
@@ -264,4 +283,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
@@ -11,12 +11,17 @@
@@ -12,6 +12,8 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
@@ -8,29 +8,30 @@
+
public class ContainerSmithing extends ContainerAnvilAbstract {
private final World level;
public static final int TEMPLATE_SLOT = 0;
@@ -27,6 +29,9 @@
@Nullable
private RecipeSmithing selectedRecipe;
private final List<RecipeSmithing> recipes;
private SmithingRecipe selectedRecipe;
private final List<SmithingRecipe> recipes;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity;
+ // CraftBukkit end
public ContainerSmithing(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -61,7 +66,7 @@
List<RecipeSmithing> list = this.level.getRecipeManager().getRecipesFor(Recipes.SMITHING, this.inputSlots, this.level);
@@ -89,7 +94,7 @@
List<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 {
RecipeSmithing recipesmithing = (RecipeSmithing) list.get(0);
ItemStack itemstack = recipesmithing.assemble(this.inputSlots);
@@ -69,7 +74,9 @@
SmithingRecipe smithingrecipe = (SmithingRecipe) list.get(0);
ItemStack itemstack = smithingrecipe.assemble(this.inputSlots, this.level.registryAccess());
@@ -97,7 +102,9 @@
if (itemstack.isItemEnabled(this.level.enabledFeatures())) {
this.selectedRecipe = recipesmithing;
this.resultSlots.setRecipeUsed(recipesmithing);
this.selectedRecipe = smithingrecipe;
this.resultSlots.setRecipeUsed(smithingrecipe);
- this.resultSlots.setItem(0, itemstack);
+ // CraftBukkit start
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
@@ -38,9 +39,9 @@
}
}
@@ -86,4 +93,18 @@
public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) {
return slot.container != this.resultSlots && super.canTakeItemForPickAll(itemstack, slot);
@@ -125,4 +132,18 @@
return findSlotMatchingIngredient(smithingrecipe, itemstack);
}).anyMatch(Optional::isPresent);
}
+
+ // CraftBukkit start
@@ -50,7 +51,7 @@
+ return bukkitEntity;
+ }
+
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithing(
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithingNew(
+ access.getLocation(), this.inputSlots, this.resultSlots);
+ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;

View File

@@ -1,17 +1,17 @@
--- a/net/minecraft/world/inventory/Containers.java
+++ b/net/minecraft/world/inventory/Containers.java
@@ -4,6 +4,10 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.player.PlayerInventory;
@@ -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> {
public class Containers<T extends Container> implements FeatureElement {
public static final Containers<ContainerChest> GENERIC_9x1 = register("generic_9x1", ContainerChest::oneRow);
@@ -23,7 +27,7 @@
@@ -27,7 +31,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) -> {

View File

@@ -0,0 +1,60 @@
--- a/net/minecraft/world/inventory/LegacySmithingMenu.java
+++ b/net/minecraft/world/inventory/LegacySmithingMenu.java
@@ -11,6 +11,8 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
/** @deprecated */
@Deprecated(forRemoval = true)
public class LegacySmithingMenu extends ContainerAnvilAbstract {
@@ -26,6 +28,9 @@
@Nullable
private LegacyUpgradeRecipe selectedRecipe;
private final List<LegacyUpgradeRecipe> recipes;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity;
+ // CraftBukkit end
public LegacySmithingMenu(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -87,7 +92,7 @@
}).toList();
if (list.isEmpty()) {
- this.resultSlots.setItem(0, ItemStack.EMPTY);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), ItemStack.EMPTY); // CraftBukkit
} else {
LegacyUpgradeRecipe legacyupgraderecipe = (LegacyUpgradeRecipe) list.get(0);
ItemStack itemstack = legacyupgraderecipe.assemble(this.inputSlots, this.level.registryAccess());
@@ -95,7 +100,9 @@
if (itemstack.isItemEnabled(this.level.enabledFeatures())) {
this.selectedRecipe = legacyupgraderecipe;
this.resultSlots.setRecipeUsed(legacyupgraderecipe);
- this.resultSlots.setItem(0, itemstack);
+ // CraftBukkit start
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack);
+ // CraftBukkit end
}
}
@@ -116,4 +123,18 @@
public boolean canTakeItemForPickAll(ItemStack itemstack, Slot slot) {
return slot.container != this.resultSlots && super.canTakeItemForPickAll(itemstack, slot);
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithing(
+ access.getLocation(), this.inputSlots, this.resultSlots);
+ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}