mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 04:02:50 +01:00
Filter data for items that shouldn't have it and filter wool.
We used to fall Item.filterData() for this but that method is meant for converting item data to block data during placement and does the wrong thing for this case. Instead we just see if the item should have data and if not set it to zero. We also have to filter wool data explicitly because clients crash when given invalid wool data.
This commit is contained in:
parent
a76a5bd36f
commit
6d88d545e9
2 changed files with 14 additions and 1 deletions
|
@ -149,6 +149,19 @@ public final class ItemStack {
|
|||
}
|
||||
|
||||
public void setData(int i) {
|
||||
// CraftBukkit start - filter out data for items that shouldn't have it
|
||||
if (!this.usesData()) {
|
||||
this.damage = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter wool to avoid confusing the client
|
||||
if (this.id == Block.WOOL.id) {
|
||||
this.damage = Math.min(15, i);
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
this.damage = i;
|
||||
if (this.damage < 0) {
|
||||
this.damage = 0;
|
||||
|
|
|
@ -1228,7 +1228,7 @@ public class PlayerConnection extends Connection {
|
|||
this.player.a(this.player.activeContainer, arraylist);
|
||||
|
||||
// CraftBukkit start - send a Set Slot to update the crafting result slot
|
||||
if(type == SlotType.RESULT && itemstack != null) {
|
||||
if (type == SlotType.RESULT && itemstack != null) {
|
||||
this.player.playerConnection.sendPacket((Packet) (new Packet103SetSlot(this.player.activeContainer.windowId, 0, itemstack)));
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
|
Loading…
Reference in a new issue