Update to Minecraft 1.17.1

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-07-07 00:00:00 +10:00
parent 0392f45e9c
commit e8c9836ec9
59 changed files with 428 additions and 492 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/Container.java
+++ b/net/minecraft/world/inventory/Container.java
@@ -29,6 +29,20 @@
@@ -30,6 +30,20 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.TileEntity;
@@ -21,16 +21,7 @@
public abstract class Container {
public static final int SLOT_CLICKED_OUTSIDE = -999;
@@ -43,7 +57,7 @@
public NonNullList<Slot> slots = NonNullList.a();
private final List<ContainerProperty> dataSlots = Lists.newArrayList();
private ItemStack carried;
- private final NonNullList<ItemStack> remoteSlots;
+ public NonNullList<ItemStack> remoteSlots;
private final IntList remoteDataSlots;
private ItemStack remoteCarried;
@Nullable
@@ -57,6 +71,27 @@
@@ -59,6 +73,27 @@
private ContainerSynchronizer synchronizer;
private boolean suppressRemoteUpdates;
@@ -58,7 +49,7 @@
protected Container(@Nullable Containers<?> containers, int i) {
this.carried = ItemStack.EMPTY;
this.remoteSlots = NonNullList.a();
@@ -154,6 +189,15 @@
@@ -156,6 +191,15 @@
}
@@ -74,16 +65,16 @@
public void b(ICrafting icrafting) {
this.containerListeners.remove(icrafting);
}
@@ -338,7 +382,7 @@
@@ -370,7 +414,7 @@
}
} else if (this.quickcraftStatus == 2) {
if (!this.quickcraftSlots.isEmpty()) {
- if (this.quickcraftSlots.size() == 1) {
+ 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.e();
this.f();
this.b(k, this.quickcraftType, InventoryClickType.PICKUP, entityhuman);
@@ -349,6 +393,7 @@
@@ -381,6 +425,7 @@
l = this.getCarried().getCount();
Iterator iterator = this.quickcraftSlots.iterator();
@@ -91,16 +82,18 @@
while (iterator.hasNext()) {
Slot slot1 = (Slot) iterator.next();
ItemStack itemstack2 = this.getCarried();
@@ -365,12 +410,48 @@
@@ -397,12 +442,48 @@
}
l -= itemstack3.getCount() - j1;
- slot1.set(itemstack3);
+ // slot1.set(itemstack3);
+ draggedSlots.put(slot1.index, itemstack3); // CraftBukkit - Put in map instead of setting
+ }
+ }
+
}
}
- itemstack1.setCount(l);
- this.setCarried(itemstack1);
+ // CraftBukkit start - InventoryDragEvent
+ InventoryView view = getBukkitView();
+ org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack1);
@@ -129,21 +122,19 @@
+ if (this.getCarried() != null) {
+ this.setCarried(CraftItemStack.asNMSCopy(event.getCursor()));
+ needsUpdate = true;
}
+ }
+ } else {
+ this.setCarried(oldCursor);
}
- itemstack1.setCount(l);
- this.setCarried(itemstack1);
+ }
+
+ if (needsUpdate && entityhuman instanceof EntityPlayer) {
+ this.updateInventory();
+ }
+ // CraftBukkit end
}
this.e();
@@ -388,8 +469,11 @@
this.f();
@@ -420,8 +501,11 @@
if (i == -999) {
if (!this.getCarried().isEmpty()) {
if (clickaction == ClickAction.PRIMARY) {
@@ -156,36 +147,39 @@
} else {
entityhuman.drop(this.getCarried().cloneAndSubtract(1), true);
}
@@ -452,6 +536,15 @@
@@ -484,6 +568,15 @@
}
slot.d();
+ // CraftBukkit start - Make sure the client has the right slot contents
+ if (entityhuman instanceof EntityPlayer && slot.getMaxStackSize() != 64) {
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutSetSlot(this.containerId, slot.index, slot.getItem()));
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutSetSlot(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.sendPacket(new PacketPlayOutSetSlot(this.containerId, 0, this.getSlot(0).getItem()));
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutSetSlot(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem()));
+ }
+ }
+ // CraftBukkit end
}
} else {
Slot slot2;
@@ -556,8 +649,11 @@
@@ -591,13 +684,14 @@
ItemStack itemstack = this.getCarried();
public void b(EntityHuman entityhuman) {
if (!this.getCarried().isEmpty()) {
- entityhuman.drop(this.getCarried(), false);
+ // CraftBukkit start - SPIGOT-4556
+ ItemStack carried = this.getCarried();
this.setCarried(ItemStack.EMPTY);
+ entityhuman.drop(carried, false);
+ // CraftBukkit end
if (!itemstack.isEmpty()) {
+ this.setCarried(ItemStack.EMPTY); // CraftBukkit - SPIGOT-4556 - from below
if (entityhuman.isAlive() && !((EntityPlayer) entityhuman).q()) {
entityhuman.getInventory().f(itemstack);
} else {
entityhuman.drop(itemstack, false);
}
- this.setCarried(ItemStack.EMPTY);
+ // this.setCarried(ItemStack.EMPTY); // CraftBukkit - moved up
}
}
}
@@ -767,6 +863,11 @@
@@ -811,6 +905,11 @@
}
public ItemStack getCarried() {

View File

@@ -22,15 +22,7 @@
public ContainerAnvil(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.NULL);
@@ -85,7 +93,6 @@
if (iblockdata1 == null) {
world.a(blockposition, false);
world.triggerEffect(1029, blockposition, 0);
- entityhuman.getInventory().f(itemstack);
} else {
world.setTypeAndData(blockposition, iblockdata1, 2);
world.triggerEffect(1030, blockposition, 0);
@@ -107,7 +114,7 @@
@@ -106,7 +114,7 @@
byte b1 = 0;
if (itemstack.isEmpty()) {
@@ -39,7 +31,7 @@
this.cost.set(0);
} else {
ItemStack itemstack1 = itemstack.cloneItemStack();
@@ -125,7 +132,7 @@
@@ -124,7 +132,7 @@
if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) {
k = Math.min(itemstack1.getDamage(), itemstack1.i() / 4);
if (k <= 0) {
@@ -48,7 +40,7 @@
this.cost.set(0);
return;
}
@@ -140,7 +147,7 @@
@@ -139,7 +147,7 @@
this.repairItemCountCost = i1;
} else {
if (!flag && (!itemstack1.a(itemstack2.getItem()) || !itemstack1.f())) {
@@ -57,7 +49,7 @@
this.cost.set(0);
return;
}
@@ -230,7 +237,7 @@
@@ -229,7 +237,7 @@
}
if (flag2 && !flag1) {
@@ -66,7 +58,7 @@
this.cost.set(0);
return;
}
@@ -254,11 +261,11 @@
@@ -253,11 +261,11 @@
itemstack1 = ItemStack.EMPTY;
}
@@ -81,7 +73,7 @@
itemstack1 = ItemStack.EMPTY;
}
@@ -277,7 +284,7 @@
@@ -276,7 +284,7 @@
EnchantmentManager.a(map, itemstack1);
}
@@ -90,8 +82,8 @@
this.d();
}
}
@@ -304,4 +311,18 @@
public int j() {
@@ -303,4 +311,18 @@
public int m() {
return this.cost.get();
}
+

View File

@@ -66,7 +66,7 @@
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
public int i() {
public int l() {
@@ -124,6 +161,7 @@
@Override

View File

@@ -40,7 +40,7 @@
@@ -154,7 +170,7 @@
}
private void o() {
private void r() {
- if (!this.trader.getWorld().isClientSide) {
+ if (!this.trader.getWorld().isClientSide && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035
Entity entity = (Entity) this.trader;

View File

@@ -46,7 +46,7 @@
int i;
@@ -242,4 +261,17 @@
public boolean d(int i) {
return i != this.j();
return i != this.m();
}
+
+ // CraftBukkit start

View File

@@ -57,7 +57,7 @@
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
public int i() {
public int l() {
@@ -120,6 +150,7 @@
@Override

View File

@@ -58,7 +58,7 @@
@@ -202,4 +216,17 @@
public boolean d(int i) {
return i != this.j();
return i != this.m();
}
+
+ // CraftBukkit start