From 49645cbeaeae2c07330768ce8c505a78ccf3d615 Mon Sep 17 00:00:00 2001 From: nnnnt21 Date: Sat, 27 Feb 2021 04:33:59 -0600 Subject: [PATCH 1/4] Fix drops from deadbush and tell grass and fix what blocks they can be placed on --- src/MiNET/MiNET/Blocks/Deadbush.cs | 21 +++++++++++++++++++++ src/MiNET/MiNET/Blocks/TallGrass.cs | 16 ++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/MiNET/MiNET/Blocks/Deadbush.cs b/src/MiNET/MiNET/Blocks/Deadbush.cs index 3a0c4bd6a..bffdf1c58 100644 --- a/src/MiNET/MiNET/Blocks/Deadbush.cs +++ b/src/MiNET/MiNET/Blocks/Deadbush.cs @@ -23,6 +23,9 @@ #endregion +using System; +using MiNET.Items; + namespace MiNET.Blocks { public partial class Deadbush : Block @@ -33,5 +36,23 @@ public Deadbush() : base(32) IsTransparent = true; IsFlammable = true; } + + 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) From 3926acf9fdc24463c90c5e2cac0105b77c497098 Mon Sep 17 00:00:00 2001 From: nnnnt21 Date: Sat, 27 Feb 2021 04:34:31 -0600 Subject: [PATCH 2/4] Fix arrow not being removed --- src/MiNET/MiNET/Items/ItemBow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } } From 0fc4278815e8af02f5586d1896c70d9bee7414e3 Mon Sep 17 00:00:00 2001 From: nnnnt21 Date: Sat, 27 Feb 2021 04:34:53 -0600 Subject: [PATCH 3/4] Add tall grass and deadbush as possible block types to damage the shears --- src/MiNET/MiNET/Items/ItemShears.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 0b1b0b8df704fcc6e6645baaef6daf25b63c6ef5 Mon Sep 17 00:00:00 2001 From: nnnnt21 Date: Sat, 27 Feb 2021 04:38:18 -0600 Subject: [PATCH 4/4] Add blocks deadbush can be placed onto --- src/MiNET/MiNET/Blocks/Deadbush.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/MiNET/MiNET/Blocks/Deadbush.cs b/src/MiNET/MiNET/Blocks/Deadbush.cs index bffdf1c58..edb4cfa64 100644 --- a/src/MiNET/MiNET/Blocks/Deadbush.cs +++ b/src/MiNET/MiNET/Blocks/Deadbush.cs @@ -25,6 +25,8 @@ using System; using MiNET.Items; +using MiNET.Utils; +using MiNET.Worlds; namespace MiNET.Blocks { @@ -37,6 +39,17 @@ public Deadbush() : base(32) 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