public override void OnHeldInteractStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, bool firstEvent, ref EnumHandHandling handling) { if (blockSel?.BlockEntity(api) is BlockEntityChisel) { handling = EnumHandHandling.PreventDefault; BlockEntityChisel entityChisel = ((BlockEntityChisel)blockSel.BlockEntity(api)); ITreeAttribute blueprintTree = slot?.Itemstack?.Attributes; ITreeAttribute dummy = blueprintTree.Clone(); entityChisel.ToTreeAttributes(dummy); blueprintTree["materials"] = dummy["materials"]; if (byEntity.Controls.Sneak) { blueprintTree["cuboids"] = new IntArrayAttribute(); entityChisel.ToTreeAttributes(blueprintTree); slot.MarkDirty(); } else if (blueprintTree["cuboids"] != null) { entityChisel.FromTreeAtributes(blueprintTree, api.World); } if (api.Side.IsClient()) { entityChisel.RegenMesh(); } } base.OnHeldInteractStart(slot, byEntity, blockSel, entitySel, firstEvent, ref handling); }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { base.OnBlockInteractStart(world, byPlayer, blockSel); (blockSel.BlockEntity(world) as BlockEntityCraftingStation)?.OnInteract(world, byPlayer, blockSel); return(true); }
private void ExchangeEvent(IServerPlayer byPlayer, BlockSelection blockSel) { (blockSel?.BlockEntity(sapi) as BlockEntityShop)?.Exchange(byPlayer); }