testserver/CraftBukkit-Patches/0084-Block-data-values-that...

101 lines
3.8 KiB
Diff
Raw Normal View History

From 2a693183d7eef1e420940b89477c31b4589e6dea Mon Sep 17 00:00:00 2001
2014-04-12 04:18:37 +00:00
From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Wed, 15 Jan 2014 21:52:47 +0000
Subject: [PATCH] Block data values that crash the client
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 874a089..088ee42 100644
2014-04-12 04:18:37 +00:00
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -115,7 +115,7 @@ public class Chunk {
}
this.sections[l1].setTypeId(l, j1 & 15, i1, block);
- this.sections[l1].setData(l, j1 & 15, i1, abyte[k1]);
+ this.sections[l1].setData(l, j1 & 15, i1, checkData( block, abyte[k1] ) );
}
}
}
@@ -398,6 +398,17 @@ public class Chunk {
}
}
+ // Spigot start - prevent invalid data values
+ public static int checkData( Block block, int data )
2014-04-12 04:18:37 +00:00
+ {
+ if (block == Blocks.DOUBLE_PLANT )
2014-04-12 04:18:37 +00:00
+ {
+ return data < 6 || data >= 8 ? data : 0;
2014-04-12 04:18:37 +00:00
+ }
+ return data;
2014-04-12 04:18:37 +00:00
+ }
+ // Spigot end
+
public boolean a(int i, int j, int k, Block block, int l) {
int i1 = k << 4 | i;
@@ -452,7 +463,7 @@ public class Chunk {
if (chunksection.getTypeId(i, j & 15, k) != block) {
return false;
} else {
- chunksection.setData(i, j & 15, k, l);
+ chunksection.setData(i, j & 15, k, checkData( block, l ) );
if (flag) {
this.initLighting();
} else {
2014-04-24 06:27:12 +00:00
@@ -517,8 +528,9 @@ public class Chunk {
2014-04-12 04:18:37 +00:00
return false;
} else {
this.n = true;
- chunksection.setData(i, j & 15, k, l);
- if (chunksection.getTypeId(i, j & 15, k) instanceof IContainer) {
+ Block block = chunksection.getTypeId( i, j & 15, k );
+ chunksection.setData(i, j & 15, k, checkData( block, l ) );
+ if (block instanceof IContainer) {
TileEntity tileentity = this.e(i, j, k);
if (tileentity != null) {
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index 3a18002..2ab3b9b 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -204,10 +204,7 @@ public final class ItemStack {
public void c(NBTTagCompound nbttagcompound) {
this.item = Item.d(nbttagcompound.getShort("id"));
this.count = nbttagcompound.getByte("Count");
- this.damage = nbttagcompound.getShort("Damage");
- if (this.damage < 0) {
- this.damage = 0;
- }
+ setData( nbttagcompound.getShort("Damage") ); // Spigot
if (nbttagcompound.hasKeyOfType("tag", 10)) {
// CraftBukkit - make defensive copy as this data may be coming from the save thread
@@ -258,11 +255,21 @@ public final class ItemStack {
}
// Is this a block?
- if (CraftMagicNumbers.getBlock(CraftMagicNumbers.getId(this.getItem())) != Blocks.AIR) {
+ // Spigot start - filter
+ Block block = CraftMagicNumbers.getBlock(CraftMagicNumbers.getId(this.getItem()));
+ if (block != Blocks.AIR) {
// If vanilla doesn't use data on it don't allow any
if (!(this.usesData() || this.getItem().usesDurability())) {
i = 0;
}
+ if ( block == Blocks.DOUBLE_PLANT )
+ {
+ if ( i >= 6 && i != 8 )
+ {
+ i = 0;
+ }
+ }
+ // Spigot end
}
// CraftBukkit end
2014-04-12 04:18:37 +00:00
--
2014-04-18 23:15:23 +00:00
1.9.1
2014-04-12 04:18:37 +00:00