Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom drops for basket trap #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 13 additions & 1 deletion Block/BlockBasketTrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@ public override ItemStack[] GetDrops(IWorldAccessor world, BlockPos pos, IPlayer
var be = GetBlockEntity<BlockEntityBasketTrap>(pos);
if (be != null && be.TrapState == EnumTrapState.Destroyed)
{
return new ItemStack[] { new ItemStack(world.GetItem(new AssetLocation("cattailtops")), 6 + world.Rand.Next(8)) };
ItemStack dropStack = null;
if (Attributes != null && Attributes.KeyExists("drop"))
{
JsonItemStack jsonDropStack = Attributes["drop"].AsObject<JsonItemStack>();
if (jsonDropStack != null && jsonDropStack.Resolve(world, ""))
{
ItemStack newStack = jsonDropStack.ResolvedItemstack;
newStack.StackSize = 6 + world.Rand.Next(8);
return new ItemStack[] { newStack };
}
}

return new ItemStack[] { new ItemStack(world.GetItem(AssetLocation.Create("cattailtops")), 6 + world.Rand.Next(8)) };
}

return base.GetDrops(world, pos, byPlayer, dropQuantityMultiplier);
Expand Down