From bf6385529267b3f08df25239f02c7a3983f76d7f Mon Sep 17 00:00:00 2001 From: RainWarrior Date: Thu, 12 Nov 2015 20:27:54 +0300 Subject: [PATCH] ItemBlock, ItemBow, ItemMonsterPlacer, ItemReed, ItemSign rejects fixed. --- .../net/minecraft/item/ItemBlock.java.patch | 22 ++++++++- .../net/minecraft/item/ItemBow.java.patch | 12 ++++- .../item/ItemMonsterPlacer.java.patch | 42 ++++++++++++++++- .../minecraft/item/ItemBlock.java.patch.rej | 45 ------------------- .../net/minecraft/item/ItemBow.java.patch.rej | 18 -------- .../item/ItemMonsterPlacer.java.patch.rej | 42 ----------------- .../minecraft/item/ItemReed.java.patch.rej | 10 ----- .../minecraft/item/ItemSign.java.patch.rej | 10 ----- 8 files changed, 72 insertions(+), 129 deletions(-) delete mode 100644 rejects/minecraft/net/minecraft/item/ItemBlock.java.patch.rej delete mode 100644 rejects/minecraft/net/minecraft/item/ItemBow.java.patch.rej delete mode 100644 rejects/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch.rej delete mode 100644 rejects/minecraft/net/minecraft/item/ItemReed.java.patch.rej delete mode 100644 rejects/minecraft/net/minecraft/item/ItemSign.java.patch.rej diff --git a/patches/minecraft/net/minecraft/item/ItemBlock.java.patch b/patches/minecraft/net/minecraft/item/ItemBlock.java.patch index 1da8fecd8..f92205dec 100644 --- a/patches/minecraft/net/minecraft/item/ItemBlock.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemBlock.java.patch @@ -1,6 +1,24 @@ --- ../src-base/minecraft/net/minecraft/item/ItemBlock.java +++ ../src-work/minecraft/net/minecraft/item/ItemBlock.java -@@ -163,4 +163,26 @@ +@@ -55,16 +55,8 @@ + int i = this.getMetadata(stack.getMetadata()); + IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn); + +- if (worldIn.setBlockState(pos, iblockstate1, 3)) ++ if (placeBlockAt(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ, iblockstate1)) + { +- iblockstate1 = worldIn.getBlockState(pos); +- +- if (iblockstate1.getBlock() == this.block) +- { +- setTileEntityNBT(worldIn, playerIn, pos, stack); +- this.block.onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack); +- } +- + worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F); + --stack.stackSize; + } +@@ -163,4 +155,26 @@ { return this.block; } @@ -20,7 +38,7 @@ + IBlockState state = world.getBlockState(pos); + if (state.getBlock() == this.block) + { -+ setTileEntityNBT(world, pos, stack, player); ++ setTileEntityNBT(world, player, pos, stack); + this.block.onBlockPlacedBy(world, pos, state, player, stack); + } + diff --git a/patches/minecraft/net/minecraft/item/ItemBow.java.patch b/patches/minecraft/net/minecraft/item/ItemBow.java.patch index 9c80583a4..8d346a3b3 100644 --- a/patches/minecraft/net/minecraft/item/ItemBow.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemBow.java.patch @@ -1,6 +1,16 @@ --- ../src-base/minecraft/net/minecraft/item/ItemBow.java +++ ../src-work/minecraft/net/minecraft/item/ItemBow.java -@@ -105,6 +105,9 @@ +@@ -28,6 +28,9 @@ + if (flag || playerIn.inventory.hasItem(Items.arrow)) + { + int i = this.getMaxItemUseDuration(stack) - timeLeft; ++ net.minecraftforge.event.entity.player.ArrowLooseEvent event = new net.minecraftforge.event.entity.player.ArrowLooseEvent(playerIn, stack, i); ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; ++ i = event.charge; + float f = (float)i / 20.0F; + f = (f * f + f * 2.0F) / 3.0F; + +@@ -105,6 +108,9 @@ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { diff --git a/patches/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch b/patches/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch index 9d23fda26..5372c4ec0 100644 --- a/patches/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch @@ -9,6 +9,15 @@ if (s1 != null) { +@@ -51,7 +51,7 @@ + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int renderPass) + { +- EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.entityEggs.get(Integer.valueOf(stack.getMetadata())); ++ EntityList.EntityEggInfo entitylist$entityegginfo = ItemMonsterPlacer.getEggInfo(stack); + return entitylist$entityegginfo != null ? (renderPass == 0 ? entitylist$entityegginfo.primaryColor : entitylist$entityegginfo.secondaryColor) : 16777215; + } + @@ -76,7 +76,7 @@ if (tileentity instanceof TileEntityMobSpawner) { @@ -36,7 +45,38 @@ if (entity != null) { -@@ -209,5 +209,28 @@ +@@ -172,19 +172,29 @@ + } + } + ++ @Deprecated // Use string version below. + public static Entity spawnCreature(World worldIn, int entityID, double x, double y, double z) + { + if (!EntityList.entityEggs.containsKey(Integer.valueOf(entityID))) + { + return null; + } ++ return spawnCreature(worldIn, EntityList.getStringFromID(entityID), x, y, z); ++ } ++ ++ public static Entity spawnCreature(World worldIn, String name, double x, double y, double z) ++ { ++ if (!EntityList.stringToClassMapping.containsKey(name)) ++ { ++ return null; ++ } + else + { + Entity entity = null; + + for (int i = 0; i < 1; ++i) + { +- entity = EntityList.createEntityByID(entityID, worldIn); ++ entity = EntityList.createEntityByName(name, worldIn); + + if (entity instanceof EntityLivingBase) + { +@@ -209,5 +219,28 @@ { subItems.add(new ItemStack(itemIn, 1, entitylist$entityegginfo.spawnedID)); } diff --git a/rejects/minecraft/net/minecraft/item/ItemBlock.java.patch.rej b/rejects/minecraft/net/minecraft/item/ItemBlock.java.patch.rej deleted file mode 100644 index a25b08932..000000000 --- a/rejects/minecraft/net/minecraft/item/ItemBlock.java.patch.rej +++ /dev/null @@ -1,45 +0,0 @@ -++++ REJECTED PATCH 1 - int i = this.getMetadata(stack.getMetadata()); - IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn); - -- if (worldIn.setBlockState(pos, iblockstate1, 3)) -+ if (placeBlockAt(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ, iblockstate1)) - { -- iblockstate1 = worldIn.getBlockState(pos); -- -- if (iblockstate1.getBlock() == this.block) -- { -- setTileEntityNBT(worldIn, pos, stack); -- this.block.onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack); -- } -- - worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F); - --stack.stackSize; - } -++++ END PATCH -++++ REJECTED PATCH 2 - } - } - -+ @Deprecated //Use player sensitive version - public static boolean setTileEntityNBT(World worldIn, BlockPos pos, ItemStack stack) - { -+ return setTileEntityNBT(worldIn, pos, stack, null); -+ } -+ public static boolean setTileEntityNBT(World worldIn, BlockPos pos, ItemStack stack, EntityPlayer player) -+ { - if (stack.hasTagCompound() && stack.getTagCompound().hasKey("BlockEntityTag", 10)) - { - TileEntity tileentity = worldIn.getTileEntity(pos); - - if (tileentity != null) - { -+ //Forge: Fixes MC-75630 - Exploit with signs and command blocks -+ final net.minecraft.server.MinecraftServer server = net.minecraft.server.MinecraftServer.getServer(); -+ if (!worldIn.isRemote && tileentity.restrictNBTCopy() && -+ (server == null || !server.getConfigurationManager().canSendCommands(player.getGameProfile()))) -+ return false; - NBTTagCompound nbttagcompound = new NBTTagCompound(); - NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttagcompound.copy(); - tileentity.writeToNBT(nbttagcompound); -++++ END PATCH diff --git a/rejects/minecraft/net/minecraft/item/ItemBow.java.patch.rej b/rejects/minecraft/net/minecraft/item/ItemBow.java.patch.rej deleted file mode 100644 index 4da43f942..000000000 --- a/rejects/minecraft/net/minecraft/item/ItemBow.java.patch.rej +++ /dev/null @@ -1,18 +0,0 @@ -++++ REJECTED PATCH 1 - - public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) - { -+ int j = this.getMaxItemUseDuration(stack) - timeLeft; -+ net.minecraftforge.event.entity.player.ArrowLooseEvent event = new net.minecraftforge.event.entity.player.ArrowLooseEvent(playerIn, stack, j); -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; -+ j = event.charge; -+ - boolean flag = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0; - - if (flag || playerIn.inventory.hasItem(Items.arrow)) - { -- int j = this.getMaxItemUseDuration(stack) - timeLeft; - float f = (float)j / 20.0F; - f = (f * f + f * 2.0F) / 3.0F; - -++++ END PATCH diff --git a/rejects/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch.rej b/rejects/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch.rej deleted file mode 100644 index b28b8be6a..000000000 --- a/rejects/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch.rej +++ /dev/null @@ -1,42 +0,0 @@ -++++ REJECTED PATCH 2 - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int renderPass) - { -- EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)EntityList.entityEggs.get(Integer.valueOf(stack.getMetadata())); -+ EntityList.EntityEggInfo entityegginfo = ItemMonsterPlacer.getEggInfo(stack); - return entityegginfo != null ? (renderPass == 0 ? entityegginfo.primaryColor : entityegginfo.secondaryColor) : 16777215; - } - -++++ END PATCH -++++ REJECTED PATCH 6 - } - } - -+ @Deprecated // Use string version below. - public static Entity spawnCreature(World worldIn, int entityID, double x, double y, double z) - { - if (!EntityList.entityEggs.containsKey(Integer.valueOf(entityID))) - { - return null; - } -+ return spawnCreature(worldIn, EntityList.getStringFromID(entityID), x, y, z); -+ } -+ -+ public static Entity spawnCreature(World worldIn, String name, double x, double y, double z) -+ { -+ if (!EntityList.stringToClassMapping.containsKey(name)) -+ { -+ return null; -+ } - else - { - Entity entity = null; - - for (int j = 0; j < 1; ++j) - { -- entity = EntityList.createEntityByID(entityID, worldIn); -+ entity = EntityList.createEntityByName(name, worldIn); - - if (entity instanceof EntityLivingBase) - { -++++ END PATCH diff --git a/rejects/minecraft/net/minecraft/item/ItemReed.java.patch.rej b/rejects/minecraft/net/minecraft/item/ItemReed.java.patch.rej deleted file mode 100644 index 8281b9838..000000000 --- a/rejects/minecraft/net/minecraft/item/ItemReed.java.patch.rej +++ /dev/null @@ -1,10 +0,0 @@ -++++ REJECTED PATCH 1 - - if (iblockstate1.getBlock() == this.block) - { -- ItemBlock.setTileEntityNBT(worldIn, pos, stack); -+ ItemBlock.setTileEntityNBT(worldIn, pos, stack, playerIn); - iblockstate1.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack); - } - -++++ END PATCH diff --git a/rejects/minecraft/net/minecraft/item/ItemSign.java.patch.rej b/rejects/minecraft/net/minecraft/item/ItemSign.java.patch.rej deleted file mode 100644 index 790c3449e..000000000 --- a/rejects/minecraft/net/minecraft/item/ItemSign.java.patch.rej +++ /dev/null @@ -1,10 +0,0 @@ -++++ REJECTED PATCH 1 - --stack.stackSize; - TileEntity tileentity = worldIn.getTileEntity(pos); - -- if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, pos, stack)) -+ if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, pos, stack, playerIn)) - { - playerIn.openEditSign((TileEntitySign)tileentity); - } -++++ END PATCH