public override WorldInteraction[] GetPlacedBlockInteractionHelp(IWorldAccessor world, BlockSelection selection, IPlayer forPlayer) { BlockEntityTrough betr = world.BlockAccessor.GetBlockEntity(selection.Position) as BlockEntityTrough; if (betr == null) { return(base.GetPlacedBlockInteractionHelp(world, selection, forPlayer)); } ItemStack[] stacks = betr.GetNonEmptyContentStacks(); if (stacks == null || stacks.Length == 0) { List <ItemStack> allowedstacks = new List <ItemStack>(); foreach (var val in betr.ContentConfig) { allowedstacks.Add(val.Content.ResolvedItemstack); } stacks = allowedstacks.ToArray(); } return(new WorldInteraction[] { new WorldInteraction() { ActionLangCode = "blockhelp-trough-addfeed", MouseButton = EnumMouseButton.Right, Itemstacks = stacks, GetMatchingStacks = (wi, bs, es) => betr.IsFull ? null : wi.Itemstacks } }.Append(base.GetPlacedBlockInteractionHelp(world, selection, forPlayer))); }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { if (blockSel != null) { BlockPos pos = blockSel.Position; if (LastCodePart(1) == "feet") { BlockFacing facing = BlockFacing.FromCode(LastCodePart()).Opposite; pos = pos.AddCopy(facing); } BlockEntityTrough betr = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityTrough; bool ok = betr?.OnInteract(byPlayer, blockSel) == true; if (ok && world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemInteract); return(true); } return(ok); } return(base.OnBlockInteractStart(world, byPlayer, blockSel)); }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { if (blockSel != null) { BlockPos pos = blockSel.Position; BlockEntityTrough betr = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityTrough; if (betr != null) { return(betr.OnInteract(byPlayer, blockSel)); } } return(base.OnBlockInteractStart(world, byPlayer, blockSel)); }
public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer) { if (LastCodePart(1) == "feet") { BlockFacing facing = BlockFacing.FromCode(LastCodePart()).GetOpposite(); pos = pos.AddCopy(facing); } BlockEntityTrough betr = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityTrough; if (betr != null) { return(betr.GetBlockInfo(forPlayer)); } return(base.GetPlacedBlockInfo(world, pos, forPlayer)); }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { if (blockSel != null) { BlockPos pos = blockSel.Position; BlockEntityTrough betr = world.BlockAccessor.GetBlockEntity(pos + RootOffset) as BlockEntityTrough; bool ok = betr?.OnInteract(byPlayer, blockSel) == true; if (ok && world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemInteract); return(true); } return(ok); } return(base.OnBlockInteractStart(world, byPlayer, blockSel)); }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { if (blockSel != null) { BlockPos pos = blockSel.Position; if (LastCodePart(1) == "feet") { BlockFacing facing = BlockFacing.FromCode(LastCodePart()).GetOpposite(); pos = pos.AddCopy(facing); } BlockEntityTrough betr = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityTrough; if (betr != null) { return(betr.OnInteract(byPlayer, blockSel)); } } return(base.OnBlockInteractStart(world, byPlayer, blockSel)); }
public void init() { CanStep = false; contentConfigs = ObjectCacheUtil.GetOrCreate(api, "troughContentConfigs-" + Code, () => { var cfgs = Attributes?["contentConfig"]?.AsObject <ContentConfig[]>(); if (cfgs == null) { return(null); } foreach (var val in cfgs) { if (!val.Content.Code.Path.Contains("*")) { val.Content.Resolve(api.World, "troughcontentconfig"); } } return(cfgs); }); List <ItemStack> allowedstacks = new List <ItemStack>(); foreach (var val in contentConfigs) { if (val.Content.Code.Path.Contains("*")) { if (val.Content.Type == EnumItemClass.Block) { allowedstacks.AddRange(api.World.SearchBlocks(val.Content.Code).Select(block => new ItemStack(block, val.QuantityPerFillLevel))); } else { allowedstacks.AddRange(api.World.SearchItems(val.Content.Code).Select(item => new ItemStack(item, val.QuantityPerFillLevel))); } } else { var stack = val.Content.ResolvedItemstack.Clone(); stack.StackSize = val.QuantityPerFillLevel; allowedstacks.Add(stack); } } placeInteractionHelp = new WorldInteraction[] { new WorldInteraction() { ActionLangCode = "blockhelp-trough-addfeed", MouseButton = EnumMouseButton.Right, Itemstacks = allowedstacks.ToArray(), GetMatchingStacks = (wi, bs, es) => { BlockEntityTrough betr = api.World.BlockAccessor.GetBlockEntity(bs.Position + RootOffset) as BlockEntityTrough; if (betr?.IsFull != false) { return(null); } ItemStack[] stacks = betr.GetNonEmptyContentStacks(); if (stacks != null && stacks.Length != 0) { return(stacks); } return(wi.Itemstacks); } } }; }
public ItemSlotTrough(BlockEntityTrough be, InventoryGeneric inventory) : base(inventory) { this.be = be; }
public DoubleTroughPoiDummy(BlockEntityTrough be) { this.be = be; }