Fixes MC-75630 - Exploit with signs and command blocks

This commit is contained in:
Lex Manos 2015-05-25 15:28:14 -07:00
parent 19d7e16fa6
commit c608e7c04e
7 changed files with 101 additions and 3 deletions

View file

@ -0,0 +1,26 @@
--- ../src-base/minecraft/net/minecraft/init/Bootstrap.java
+++ ../src-work/minecraft/net/minecraft/init/Bootstrap.java
@@ -67,6 +67,7 @@
return field_151355_a;
}
+ @SuppressWarnings("unused")
static void func_151353_a()
{
BlockDispenser.field_149943_a.func_82595_a(Items.field_151032_g, new BehaviorProjectileDispense()
@@ -509,6 +510,7 @@
}
}
});
+ if (false){ //Forge: Removed, Fixes MC-75630 - Exploit with signs and command blocks
BlockDispenser.field_149943_a.func_82595_a(Item.func_150898_a(Blocks.field_150483_bI), new BehaviorDefaultDispenseItem()
{
private static final String __OBFID = "CL_00002276";
@@ -535,6 +537,7 @@
protected void func_82485_a(IBlockSource p_82485_1_) {}
protected void func_82489_a(IBlockSource p_82489_1_, EnumFacing p_82489_2_) {}
});
+ }
}
public static void func_151354_b()

View file

@ -18,7 +18,32 @@
p_180614_3_.func_72908_a((double)((float)p_180614_4_.func_177958_n() + 0.5F), (double)((float)p_180614_4_.func_177956_o() + 0.5F), (double)((float)p_180614_4_.func_177952_p() + 0.5F), this.field_150939_a.field_149762_H.func_150496_b(), (this.field_150939_a.field_149762_H.func_150497_c() + 1.0F) / 2.0F, this.field_150939_a.field_149762_H.func_150494_d() * 0.8F);
--p_180614_1_.field_77994_a;
}
@@ -157,4 +149,26 @@
@@ -85,14 +77,24 @@
}
}
+ @Deprecated //Use player sensitive version
public static boolean func_179224_a(World p_179224_0_, BlockPos p_179224_1_, ItemStack p_179224_2_)
{
+ return setTileEntityNBT(p_179224_0_, p_179224_1_, p_179224_2_, null);
+ }
+ public static boolean setTileEntityNBT(World p_179224_0_, BlockPos p_179224_1_, ItemStack p_179224_2_, EntityPlayer player)
+ {
if (p_179224_2_.func_77942_o() && p_179224_2_.func_77978_p().func_150297_b("BlockEntityTag", 10))
{
TileEntity tileentity = p_179224_0_.func_175625_s(p_179224_1_);
if (tileentity != null)
{
+ //Forge: Fixes MC-75630 - Exploit with signs and command blocks
+ final net.minecraft.server.MinecraftServer server = net.minecraft.server.MinecraftServer.func_71276_C();
+ if (!p_179224_0_.field_72995_K && tileentity.restrictNBTCopy() &&
+ (server == null || server.func_71203_ab().func_152596_g(player.func_146103_bH())))
+ return false;
NBTTagCompound nbttagcompound = new NBTTagCompound();
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttagcompound.func_74737_b();
tileentity.func_145841_b(nbttagcompound);
@@ -157,4 +159,26 @@
{
return this.field_150939_a;
}
@ -38,7 +63,7 @@
+ IBlockState state = world.func_180495_p(pos);
+ if (state.func_177230_c() == this.field_150939_a)
+ {
+ func_179224_a(world, pos, stack);
+ setTileEntityNBT(world, pos, stack, player);
+ this.field_150939_a.func_180633_a(world, pos, state, player, stack);
+ }
+

View file

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/item/ItemReed.java
+++ ../src-work/minecraft/net/minecraft/item/ItemReed.java
@@ -54,7 +54,7 @@
if (iblockstate1.func_177230_c() == this.field_150935_a)
{
- ItemBlock.func_179224_a(p_180614_3_, p_180614_4_, p_180614_1_);
+ ItemBlock.setTileEntityNBT(p_180614_3_, p_180614_4_, p_180614_1_, p_180614_2_);
iblockstate1.func_177230_c().func_180633_a(p_180614_3_, p_180614_4_, iblockstate1, p_180614_2_, p_180614_1_);
}

View file

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/item/ItemSign.java
+++ ../src-work/minecraft/net/minecraft/item/ItemSign.java
@@ -63,7 +63,7 @@
--p_180614_1_.field_77994_a;
TileEntity tileentity = p_180614_3_.func_175625_s(p_180614_4_);
- if (tileentity instanceof TileEntitySign && !ItemBlock.func_179224_a(p_180614_3_, p_180614_4_, p_180614_1_))
+ if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(p_180614_3_, p_180614_4_, p_180614_1_, p_180614_2_))
{
p_180614_2_.func_175141_a((TileEntitySign)tileentity);
}

View file

@ -16,7 +16,7 @@
}
}
@@ -294,4 +296,123 @@
@@ -294,4 +296,135 @@
func_145826_a(TileEntityFlowerPot.class, "FlowerPot");
func_145826_a(TileEntityBanner.class, "Banner");
}
@ -138,5 +138,17 @@
+ this.customTileData = new NBTTagCompound();
+ }
+ return this.customTileData;
+ }
+
+ /**
+ * Determines if the player can overwrite the NBT data of this tile entity while they place it using a ItemStack.
+ * Added as a fix for MC-75630 - Exploit with signs and command blocks
+ * @return True to prevent NBT copy, false to allow.
+ */
+ public boolean restrictNBTCopy()
+ {
+ return this instanceof TileEntityCommandBlock ||
+ this instanceof TileEntityMobSpawner ||
+ this instanceof TileEntitySign;
+ }
}

View file

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/tileentity/TileEntitySign.java
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntitySign.java
@@ -161,7 +161,7 @@
public void func_145747_a(IChatComponent p_145747_1_) {}
public boolean func_70003_b(int p_70003_1_, String p_70003_2_)
{
- return true;
+ return p_70003_1_ <= 2; //Forge: Fixes MC-75630 - Exploit with signs and command blocks
}
public BlockPos func_180425_c()
{

View file

@ -35,3 +35,5 @@ net/minecraft/client/renderer/block/model/FaceBakery.makeBakedQuad(Ljavax/vecmat
net/minecraft/client/renderer/block/model/FaceBakery.makeQuadVertexData(Lnet/minecraft/client/renderer/block/model/BlockPartFace;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/util/EnumFacing;[FLnet/minecraftforge/client/model/ITransformation;Lnet/minecraft/client/renderer/block/model/BlockPartRotation;ZZ)[I=|p_178405_1_,p_178405_2_,p_178405_3_,p_178405_4_,p_178405_5_,p_178405_6_,p_178405_7_,p_178405_8_
net/minecraft/client/renderer/block/model/FaceBakery.fillVertexData([IILnet/minecraft/util/EnumFacing;Lnet/minecraft/client/renderer/block/model/BlockPartFace;[FLnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraftforge/client/model/ITransformation;Lnet/minecraft/client/renderer/block/model/BlockPartRotation;ZZ)V=|p_178402_1_,p_178402_2_,p_178402_3_,p_178402_4_,p_178402_5_,p_178402_6_,p_178402_7_,p_178402_8_,p_178402_9_,p_178402_10_
net/minecraft/client/renderer/block/model/FaceBakery.rotateVertex(Ljavax/vecmath/Vector3d;Lnet/minecraft/util/EnumFacing;ILnet/minecraftforge/client/model/ITransformation;Z)I=|p_178415_1_,p_178415_2_,p_178415_3_,p_178415_4_,p_178415_5_
net/minecraft/item/ItemBlock.setTileEntityNBT(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/EntityPlayer;)Z=|p_179224_0_,p_179224_1_,p_179224_2_,player