public bool Construct(ItemSlot slot, IWorldAccessor world, BlockPos pos, IPlayer player) { Block block = world.BlockAccessor.GetBlock(pos); if (!block.IsReplacableBy(this)) { return(false); } Block belowBlock = world.BlockAccessor.GetBlock(pos.DownCopy()); if (!belowBlock.CanAttachBlockAt(world.BlockAccessor, this, pos.DownCopy(), BlockFacing.UP) && (belowBlock != this || FillLevel(world.BlockAccessor, pos.DownCopy()) != 4)) { return(false); } world.BlockAccessor.SetBlock(BlockId, pos); BlockEntity be = world.BlockAccessor.GetBlockEntity(pos); if (be is BlockEntityFirewoodPile) { BlockEntityFirewoodPile pile = (BlockEntityFirewoodPile)be; if (player == null || player.WorldData.CurrentGameMode != EnumGameMode.Creative) { pile.inventory[0].Itemstack = (ItemStack)slot.TakeOut(player.Entity.Controls.Sprint ? pile.BulkTakeQuantity : pile.DefaultTakeQuantity); slot.MarkDirty(); } else { pile.inventory[0].Itemstack = (ItemStack)slot.Itemstack.Clone(); pile.inventory[0].Itemstack.StackSize = Math.Min(pile.inventory[0].Itemstack.StackSize, pile.MaxStackSize); } pile.MarkDirty(); world.BlockAccessor.MarkBlockDirty(pos); world.PlaySoundAt(pile.soundLocation, pos.X, pos.Y, pos.Z, player, true); } return(true); }
internal bool Construct(IItemSlot slot, IWorldAccessor world, BlockPos pos, IPlayer player) { Block block = world.BlockAccessor.GetBlock(pos); if (!block.IsReplacableBy(this)) { return(false); } Block belowBlock = world.BlockAccessor.GetBlock(pos.DownCopy()); if (!belowBlock.SideSolid[BlockFacing.UP.Index] && (belowBlock != this || FillLevel(world.BlockAccessor, pos.DownCopy()) != 4)) { return(false); } world.BlockAccessor.SetBlock(BlockId, pos); BlockEntity be = world.BlockAccessor.GetBlockEntity(pos); if (be is BlockEntityFirewoodPile) { BlockEntityFirewoodPile pile = (BlockEntityFirewoodPile)be; if (player == null || player.WorldData.CurrentGameMode != EnumGameMode.Creative) { pile.inventory.GetSlot(0).Itemstack = (ItemStack)slot.TakeOut(2); slot.MarkDirty(); } else { pile.inventory.GetSlot(0).Itemstack = (ItemStack)slot.Itemstack.Clone(); } pile.MarkDirty(); world.BlockAccessor.MarkBlockDirty(pos); world.PlaySoundAt(new AssetLocation("sounds/block/planks"), pos.X, pos.Y, pos.Z, player, false); } return(true); }