diff --git a/src/MiNET/MiNET/Blocks/Deadbush.cs b/src/MiNET/MiNET/Blocks/Deadbush.cs index 3a0c4bd6a..edb4cfa64 100644 --- a/src/MiNET/MiNET/Blocks/Deadbush.cs +++ b/src/MiNET/MiNET/Blocks/Deadbush.cs @@ -23,6 +23,11 @@ #endregion +using System; +using MiNET.Items; +using MiNET.Utils; +using MiNET.Worlds; + namespace MiNET.Blocks { public partial class Deadbush : Block @@ -33,5 +38,34 @@ public Deadbush() : base(32) IsTransparent = true; IsFlammable = true; } + + protected override bool CanPlace(Level world, Player player, BlockCoordinates blockCoordinates, BlockCoordinates targetCoordinates, BlockFace face) + { + if (base.CanPlace(world, player, blockCoordinates, targetCoordinates, face)) + { + var under = world.GetBlock(Coordinates.BlockDown()); + return under is Sand || under is Dirt || under is Podzol || under is HardenedClay || under is StainedHardenedClay; + } + + return false; + } + + public override Item[] GetDrops(Item tool) + { + // if shear drop deadbush + if (tool is ItemShears) + { + return new[] {ItemFactory.GetItem(32)}; + } + + //random between 0 and 3 sticks + var rnd = new Random(); + byte count = (byte) rnd.Next(3); + if (count > 0) + { + return new[] {ItemFactory.GetItem(280, 0, count)}; + } + return new Item[0]; + } } } \ No newline at end of file diff --git a/src/MiNET/MiNET/Blocks/TallGrass.cs b/src/MiNET/MiNET/Blocks/TallGrass.cs index ed9b522ce..d19864328 100644 --- a/src/MiNET/MiNET/Blocks/TallGrass.cs +++ b/src/MiNET/MiNET/Blocks/TallGrass.cs @@ -58,6 +58,17 @@ public override void OnTick(Level level, bool isRandom) } } + protected override bool CanPlace(Level world, Player player, BlockCoordinates blockCoordinates, BlockCoordinates targetCoordinates, BlockFace face) + { + if (base.CanPlace(world, player, blockCoordinates, targetCoordinates, face)) + { + var under = world.GetBlock(Coordinates.BlockDown()); + return under is Grass || under is Dirt || under is Podzol || under is Farmland; + } + + return false; + } + public override void BlockUpdate(Level level, BlockCoordinates blockCoordinates) { if (Coordinates.BlockDown() == blockCoordinates) @@ -69,6 +80,11 @@ public override void BlockUpdate(Level level, BlockCoordinates blockCoordinates) public override Item[] GetDrops(Item tool) { + //if shear drop grass + if (tool is ItemShears) + { + return new[] {ItemFactory.GetItem(31)}; + } // 50% chance to drop seeds. var rnd = new Random(); if (rnd.NextDouble() > 0.5) diff --git a/src/MiNET/MiNET/Items/ItemBow.cs b/src/MiNET/MiNET/Items/ItemBow.cs index 0ec212b4b..76e51f954 100644 --- a/src/MiNET/MiNET/Items/ItemBow.cs +++ b/src/MiNET/MiNET/Items/ItemBow.cs @@ -111,7 +111,7 @@ public override void Release(Level world, Player player, BlockCoordinates blockC if (itemStack.Id == 262) { haveArrow = true; - if (isInfinity) inventory.RemoveItems(262, 1); + if (!isInfinity) inventory.RemoveItems(262, 1); break; } } diff --git a/src/MiNET/MiNET/Items/ItemShears.cs b/src/MiNET/MiNET/Items/ItemShears.cs index ac1b3dc44..1408e188a 100644 --- a/src/MiNET/MiNET/Items/ItemShears.cs +++ b/src/MiNET/MiNET/Items/ItemShears.cs @@ -43,7 +43,7 @@ public override bool DamageItem(Player player, ItemDamageReason reason, Entity t { case ItemDamageReason.BlockBreak: { - if (block is Web || block is Leaves || block is Leaves2 || block is Wool || block is Vine) + if (block is Web || block is Leaves || block is Leaves2 || block is Wool || block is Vine || block is Tallgrass || block is Deadbush) { Metadata++; return Metadata >= GetMaxUses() - 1;