Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/MiNET/MiNET/Blocks/Deadbush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

#endregion

using System;
using MiNET.Items;
using MiNET.Utils;
using MiNET.Worlds;

namespace MiNET.Blocks
{
public partial class Deadbush : Block
Expand All @@ -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];
}
}
}
16 changes: 16 additions & 0 deletions src/MiNET/MiNET/Blocks/TallGrass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/MiNET/MiNET/Items/ItemBow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/MiNET/MiNET/Items/ItemShears.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down