diff --git a/common/net/minecraftforge/common/ForgeHooks.java b/common/net/minecraftforge/common/ForgeHooks.java index 7768d858aa..5c276daec3 100644 --- a/common/net/minecraftforge/common/ForgeHooks.java +++ b/common/net/minecraftforge/common/ForgeHooks.java @@ -39,6 +39,16 @@ public class ForgeHooks } world.setBlockAndMetadataWithNotify(x, y, z, grass.block.blockID, grass.metadata); } + + public static ItemStack getGrassSeed(World world) + { + SeedEntry entry = (SeedEntry)WeightedRandom.getRandomItem(world.rand, seedList); + if (entry == null || entry.seed == null) + { + return null; + } + return entry.seed.copy(); + } static { diff --git a/forge_common/net/minecraft/src/forge/IShearable.java b/common/net/minecraftforge/common/IShearable.java similarity index 98% rename from forge_common/net/minecraft/src/forge/IShearable.java rename to common/net/minecraftforge/common/IShearable.java index e858316fc7..0b0407610c 100644 --- a/forge_common/net/minecraft/src/forge/IShearable.java +++ b/common/net/minecraftforge/common/IShearable.java @@ -1,4 +1,4 @@ -package net.minecraft.src.forge; +package net.minecraftforge.common; import java.util.ArrayList; diff --git a/forge_common/net/minecraft/src/forge/IBonemealHandler.java b/forge_common/net/minecraft/src/forge/IBonemealHandler.java deleted file mode 100644 index 30b2d8a697..0000000000 --- a/forge_common/net/minecraft/src/forge/IBonemealHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This software is provided under the terms of the Minecraft Forge Public - * License v1.0. - */ - -package net.minecraft.src.forge; - -import net.minecraft.src.World; - -public interface IBonemealHandler -{ - /** Called when bonemeal is used on a block. This is also called for - * multiplayer servers, which must still return true if appropriate but - * shouldn't actually perform world manipulation. - * @return true to use up the bonemeal and stop processing. - */ - public boolean onUseBonemeal(World world, int blockID, int X, int Y, int Z); -} - diff --git a/patches/common/net/minecraft/src/ItemShears.java.patch b/patches/common/net/minecraft/src/ItemShears.java.patch new file mode 100644 index 0000000000..bcb120bb0e --- /dev/null +++ b/patches/common/net/minecraft/src/ItemShears.java.patch @@ -0,0 +1,90 @@ +--- ../src_base/common/net/minecraft/src/ItemShears.java ++++ ../src_work/common/net/minecraft/src/ItemShears.java +@@ -1,4 +1,8 @@ + package net.minecraft.src; ++ ++import java.util.ArrayList; ++ ++import net.minecraftforge.common.IShearable; + + public class ItemShears extends Item + { +@@ -16,9 +20,12 @@ + { + return super.func_77660_a(par1ItemStack, par2World, par3, par4, par5, par6, par7EntityLiving); + } ++ else if (!(Block.blocksList[par3] instanceof IShearable)) ++ { ++ return super.func_77660_a(par1ItemStack, par2World, par3, par4, par5, par6, par7EntityLiving); ++ } + else + { +- par1ItemStack.damageItem(1, par7EntityLiving); + return true; + } + } +@@ -39,4 +46,64 @@ + { + return par2Block.blockID != Block.web.blockID && par2Block.blockID != Block.leaves.blockID ? (par2Block.blockID == Block.cloth.blockID ? 5.0F : super.getStrVsBlock(par1ItemStack, par2Block)) : 15.0F; + } ++ ++ @Override ++ public boolean itemInteractionForEntity(ItemStack itemstack, EntityLiving entity) ++ { ++ if (entity.worldObj.isRemote) ++ { ++ return false; ++ } ++ if (entity instanceof IShearable) ++ { ++ IShearable target = (IShearable)entity; ++ if (target.isShearable(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ)) ++ { ++ ArrayList drops = target.onSheared(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ, ++ EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); ++ for(ItemStack stack : drops) ++ { ++ EntityItem ent = entity.entityDropItem(stack, 1.0F); ++ ent.motionY += entity.rand.nextFloat() * 0.05F; ++ ent.motionX += (entity.rand.nextFloat() - entity.rand.nextFloat()) * 0.1F; ++ ent.motionZ += (entity.rand.nextFloat() - entity.rand.nextFloat()) * 0.1F; ++ } ++ itemstack.damageItem(1, entity); ++ } ++ return true; ++ } ++ return false; ++ } ++ ++ @Override ++ public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) ++ { ++ if (player.worldObj.isRemote) ++ { ++ return false; ++ } ++ int id = player.worldObj.getBlockId(x, y, z); ++ if (Block.blocksList[id] instanceof IShearable) ++ { ++ IShearable target = (IShearable)Block.blocksList[id]; ++ if (target.isShearable(itemstack, player.worldObj, x, y, z)) ++ { ++ ArrayList drops = target.onSheared(itemstack, player.worldObj, x, y, z, ++ EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); ++ for(ItemStack stack : drops) ++ { ++ float f = 0.7F; ++ double d = (double)(player.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; ++ double d1 = (double)(player.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; ++ double d2 = (double)(player.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; ++ EntityItem entityitem = new EntityItem(player.worldObj, (double)x + d, (double)y + d1, (double)z + d2, stack); ++ entityitem.delayBeforeCanPickup = 10; ++ player.worldObj.spawnEntityInWorld(entityitem); ++ } ++ itemstack.damageItem(1, player); ++ player.addStat(StatList.mineBlockStatArray[id], 1); ++ } ++ } ++ return false; ++ } + } diff --git a/patches/minecraft/net/minecraft/src/BlockTallGrass.java.patch b/patches/minecraft/net/minecraft/src/BlockTallGrass.java.patch new file mode 100644 index 0000000000..1d0f39cb37 --- /dev/null +++ b/patches/minecraft/net/minecraft/src/BlockTallGrass.java.patch @@ -0,0 +1,79 @@ +--- ../src_base/minecraft/net/minecraft/src/BlockTallGrass.java ++++ ../src_work/minecraft/net/minecraft/src/BlockTallGrass.java +@@ -1,9 +1,13 @@ + package net.minecraft.src; + ++import java.util.ArrayList; + import java.util.List; + import java.util.Random; + +-public class BlockTallGrass extends BlockFlower ++import net.minecraftforge.common.ForgeHooks; ++import net.minecraftforge.common.IShearable; ++ ++public class BlockTallGrass extends BlockFlower implements IShearable + { + protected BlockTallGrass(int par1, int par2) + { +@@ -50,7 +54,7 @@ + */ + public int idDropped(int par1, Random par2Random, int par3) + { +- return par2Random.nextInt(8) == 0 ? Item.seeds.shiftedIndex : -1; ++ return -1; + } + + /** +@@ -67,15 +71,7 @@ + */ + public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) + { +- if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.shiftedIndex) +- { +- par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); +- this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(Block.tallGrass, 1, par6)); +- } +- else +- { +- super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); +- } ++ super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); + } + + /** +@@ -96,4 +92,35 @@ + par3List.add(new ItemStack(par1, 1, var4)); + } + } ++ ++ @Override ++ public ArrayList getBlockDropped(World world, int x, int y, int z, int meta, int fortune) ++ { ++ ArrayList ret = new ArrayList(); ++ if (world.rand.nextInt(8) != 0) ++ { ++ return ret; ++ } ++ ++ ItemStack item = ForgeHooks.getGrassSeed(world); ++ if (item != null) ++ { ++ ret.add(item); ++ } ++ return ret; ++ } ++ ++ @Override ++ public boolean isShearable(ItemStack item, World world, int x, int y, int z) ++ { ++ return true; ++ } ++ ++ @Override ++ public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) ++ { ++ ArrayList ret = new ArrayList(); ++ ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z))); ++ return ret; ++ } + } diff --git a/patches/minecraft_server/net/minecraft/src/BlockTallGrass.java.patch b/patches/minecraft_server/net/minecraft/src/BlockTallGrass.java.patch new file mode 100644 index 0000000000..ce9b6f1d17 --- /dev/null +++ b/patches/minecraft_server/net/minecraft/src/BlockTallGrass.java.patch @@ -0,0 +1,68 @@ +--- ../src_base/minecraft_server/net/minecraft/src/BlockTallGrass.java ++++ ../src_work/minecraft_server/net/minecraft/src/BlockTallGrass.java +@@ -1,8 +1,12 @@ + package net.minecraft.src; + ++import java.util.ArrayList; + import java.util.Random; + +-public class BlockTallGrass extends BlockFlower ++import net.minecraftforge.common.ForgeHooks; ++import net.minecraftforge.common.IShearable; ++ ++public class BlockTallGrass extends BlockFlower implements IShearable + { + protected BlockTallGrass(int par1, int par2) + { +@@ -24,7 +28,7 @@ + */ + public int idDropped(int par1, Random par2Random, int par3) + { +- return par2Random.nextInt(8) == 0 ? Item.seeds.shiftedIndex : -1; ++ return -1; + } + + /** +@@ -41,14 +45,37 @@ + */ + public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) + { +- if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.shiftedIndex) ++ super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); ++ } ++ ++ @Override ++ public ArrayList getBlockDropped(World world, int x, int y, int z, int meta, int fortune) ++ { ++ ArrayList ret = new ArrayList(); ++ if (world.rand.nextInt(8) != 0) + { +- par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); +- this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(Block.tallGrass, 1, par6)); ++ return ret; + } +- else ++ ++ ItemStack item = ForgeHooks.getGrassSeed(world); ++ if (item != null) + { +- super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); ++ ret.add(item); + } ++ return ret; ++ } ++ ++ @Override ++ public boolean isShearable(ItemStack item, World world, int x, int y, int z) ++ { ++ return true; ++ } ++ ++ @Override ++ public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) ++ { ++ ArrayList ret = new ArrayList(); ++ ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z))); ++ return ret; + } + }