コード例 #1
0
        public static bool WildCardMatch(this AssetLocation asset, AssetLocation match, EnumItemClass itemClass, ICoreAPI Api)
        {
            if (asset == null || match == null)
            {
                return(false);
            }

            if (itemClass == EnumItemClass.Item)
            {
                return(asset.GetItem(Api).WildCardMatch(match));
            }
            else if (itemClass == EnumItemClass.Block)
            {
                return(asset.GetBlock(Api).WildCardMatch(match));
            }
            return(false);
        }
コード例 #2
0
 public static int GetID(this AssetLocation loc, ICoreAPI Api) => loc.GetBlock(Api).BlockId;
コード例 #3
0
 public static BlockEntity BlockEntity(this BlockPos Pos, ICoreAPI Api) => Pos.BlockEntity(Api.World);
コード例 #4
0
        public override void OnLoaded(ICoreAPI api)
        {
            base.OnLoaded(api);

            drop?.Resolve(api.World, "HorizontalOrientable drop for " + block.Code);
        }
コード例 #5
0
 public override void OnLoaded(ICoreAPI api)
 {
     base.OnLoaded(api);
     allowedPrefixes = Attributes["codePrefixes"].AsStringArray();
 }
コード例 #6
0
 public static Block ToBlock(this string block, ICoreAPI Api) => block.WithDomain().ToAsset().GetBlock(Api);
コード例 #7
0
 public InventoryQuern(string inventoryID, ICoreAPI api) : base(inventoryID, api)
 {
     // slot 0 = input
     // slot 1 = output
     slots = GenEmptySlots(2);
 }
コード例 #8
0
 public virtual void OnUnloaded(ICoreAPI api)
 {
 }
コード例 #9
0
        public override void OnLoaded(ICoreAPI api)
        {
            base.OnLoaded(api);

            if (api.Side != EnumAppSide.Client)
            {
                return;
            }

            ICoreClientAPI capi = api as ICoreClientAPI;

            if (capi != null)
            {
                interactions = ObjectCacheUtil.GetOrCreate(api, "ovenInteractions", () =>
                {
                    List <ItemStack> bakeableStacklist = new List <ItemStack>();
                    List <ItemStack> fuelStacklist     = new List <ItemStack>();
                    List <ItemStack> canIgniteStacks   = new List <ItemStack>();

                    foreach (CollectibleObject obj in api.World.Collectibles)
                    {
                        // we test firewood first because LazyWarlock's mod adds a wood baking recipe, which we don't want to be treated as a bakeable item here
                        if (obj.Attributes?.IsTrue("isFirewood") == true)
                        {
                            List <ItemStack> stacks = obj.GetHandBookStacks(capi);
                            if (stacks != null)
                            {
                                fuelStacklist.AddRange(stacks);
                            }
                        }
                        else if (obj.Attributes?["bakingProperties"]?.AsObject <BakingProperties>() != null || obj.CombustibleProps?.SmeltingType == EnumSmeltType.Bake && obj.CombustibleProps.SmeltedStack != null && obj.CombustibleProps.MeltingPoint < BlockEntityOven.maxBakingTemperatureAccepted)
                        {
                            List <ItemStack> stacks = obj.GetHandBookStacks(capi);
                            if (stacks != null)
                            {
                                bakeableStacklist.AddRange(stacks);
                            }
                        }
                        else if (obj is Block)
                        {
                            if ((obj as Block).HasBehavior <BlockBehaviorCanIgnite>() || obj is ItemFirestarter)
                            {
                                List <ItemStack> stacks = obj.GetHandBookStacks(capi);
                                if (stacks != null)
                                {
                                    canIgniteStacks.AddRange(stacks);
                                }
                            }
                        }
                    }

                    return(new WorldInteraction[] {
                        new WorldInteraction()
                        {
                            ActionLangCode = "blockhelp-oven-bakeable",
                            HotKeyCode = null,
                            MouseButton = EnumMouseButton.Right,
                            Itemstacks = bakeableStacklist.ToArray(),
                            GetMatchingStacks = (wi, bs, es) => {
                                if (wi.Itemstacks.Length == 0)
                                {
                                    return null;
                                }
                                BlockEntityOven beo = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityOven;
                                return beo != null ? beo.CanAdd(wi.Itemstacks) : null;
                            }
                        },
                        new WorldInteraction()
                        {
                            ActionLangCode = "blockhelp-oven-fuel",
                            HotKeyCode = null,
                            MouseButton = EnumMouseButton.Right,
                            Itemstacks = fuelStacklist.ToArray(),
                            GetMatchingStacks = (wi, bs, es) => {
                                //if (wi.Itemstacks.Length == 0) return null;
                                BlockEntityOven beo = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityOven;
                                return beo != null ? beo.CanAddAsFuel(fuelStacklist.ToArray()) : null;
                            }
                        },
                        new WorldInteraction()
                        {
                            ActionLangCode = "blockhelp-oven-ignite",
                            MouseButton = EnumMouseButton.Right,
                            HotKeyCode = "sneak",
                            Itemstacks = canIgniteStacks.ToArray(),
                            GetMatchingStacks = (wi, bs, es) => {
                                if (wi.Itemstacks.Length == 0)
                                {
                                    return null;
                                }
                                BlockEntityOven beo = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityOven;
                                return beo != null && beo.CanIgnite() ? wi.Itemstacks : null;
                            }
                        }
                    });
                });
            }

            InitializeParticles();
        }
コード例 #10
0
        public override void OnLoaded(ICoreAPI api)
        {
            base.OnLoaded(api);

            mechPower = api.ModLoader.GetModSystem <MechanicalPowerMod>();
        }
コード例 #11
0
        public override void OnLoaded(ICoreAPI api)
        {
            if (api.Side != EnumAppSide.Client)
            {
                return;
            }
            ICoreClientAPI capi = api as ICoreClientAPI;

            Dictionary <string, MetalPropertyVariant> metalsByCode = new Dictionary <string, MetalPropertyVariant>();

            MetalProperty metals = api.Assets.TryGet("worldproperties/block/metal.json").ToObject <MetalProperty>();

            for (int i = 0; i < metals.Variants.Length; i++)
            {
                // Metals currently don't have a domain
                metalsByCode[metals.Variants[i].Code.Path] = metals.Variants[i];
            }

            string metalType    = LastCodePart();
            int    ownMetalTier = 0;

            if (metalsByCode.ContainsKey(metalType))
            {
                ownMetalTier = metalsByCode[metalType].Tier;
            }

            interactions = ObjectCacheUtil.GetOrCreate(api, "anvilBlockInteractions" + ownMetalTier, () =>
            {
                List <ItemStack> workableStacklist = new List <ItemStack>();
                List <ItemStack> hammerStacklist   = new List <ItemStack>();


                foreach (Item item in api.World.Items)
                {
                    if (item.Code == null)
                    {
                        continue;
                    }

                    bool viableTier = metalsByCode.ContainsKey(metalType) && metalsByCode[metalType].Tier <= ownMetalTier + 1;
                    if (item is ItemIngot && viableTier)
                    {
                        workableStacklist.Add(new ItemStack(item));
                    }

                    if (item is ItemHammer)
                    {
                        hammerStacklist.Add(new ItemStack(item));
                    }
                }

                return(new WorldInteraction[] {
                    new WorldInteraction()
                    {
                        ActionLangCode = "blockhelp-anvil-placeworkable",
                        HotKeyCode = "sneak",
                        MouseButton = EnumMouseButton.Right,
                        Itemstacks = workableStacklist.ToArray(),
                        GetMatchingStacks = (wi, bs, es) => {
                            BlockEntityAnvil bea = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityAnvil;
                            return bea?.WorkItem == null ? wi.Itemstacks : null;
                        }
                    },
                    new WorldInteraction()
                    {
                        ActionLangCode = "blockhelp-anvil-smith",
                        MouseButton = EnumMouseButton.Left,
                        Itemstacks = hammerStacklist.ToArray(),
                        GetMatchingStacks = (wi, bs, es) => {
                            BlockEntityAnvil bea = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityAnvil;
                            return bea?.WorkItem == null ? null : wi.Itemstacks;
                        }
                    },
                    new WorldInteraction()
                    {
                        ActionLangCode = "blockhelp-anvil-addvoxels",
                        HotKeyCode = "sneak",
                        MouseButton = EnumMouseButton.Right,
                        Itemstacks = workableStacklist.ToArray(),
                        GetMatchingStacks = (wi, bs, es) => {
                            BlockEntityAnvil bea = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityAnvil;
                            return bea?.WorkItem == null ? null : new ItemStack[] { bea.BaseMaterial };
                        }
                    },
                    new WorldInteraction()
                    {
                        ActionLangCode = "blockhelp-anvil-takeworkable",
                        HotKeyCode = null,
                        MouseButton = EnumMouseButton.Right,
                        ShouldApply = (wi, bs, es) => {
                            BlockEntityAnvil bea = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityAnvil;
                            return bea?.WorkItem != null;
                        }
                    },
                    new WorldInteraction()
                    {
                        ActionLangCode = "blockhelp-selecttoolmode",
                        HotKeyCode = "toolmodeselect",
                        MouseButton = EnumMouseButton.None,
                        Itemstacks = hammerStacklist.ToArray(),
                        GetMatchingStacks = (wi, bs, es) => {
                            BlockEntityAnvil bea = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityAnvil;
                            return bea?.WorkItem == null ? null : wi.Itemstacks;
                        }
                    }
                });
            });
        }
コード例 #12
0
 public override void OnLoaded(ICoreAPI Api)
 {
     base.OnLoaded(Api);
     props = Attributes["dryingprops"].AsObject <DryingProp[]>();
 }
コード例 #13
0
        public override void Initialize(ICoreAPI api)
        {
            base.Initialize(api);

            inventory.ResolveBlocksOrItems();
        }
コード例 #14
0
 public InventoryQuern(string className, string instanceID, ICoreAPI api) : base(className, instanceID, api)
 {
     slots = GenEmptySlots(2);
 }
コード例 #15
0
 public static Block GetBlock(this int BlockId, ICoreAPI api) => BlockId.GetBlock(api.World);
コード例 #16
0
 public override void OnLoaded(ICoreAPI Api)
 {
     base.OnLoaded(Api);
     allowedPrefixes = Attributes["codePrefixes"].AsArray<string>();
 }
コード例 #17
0
 public static Block GetBlock(this BlockPos Pos, ICoreAPI Api)
 {
     return(Pos.GetBlock(Api.World));
 }
コード例 #18
0
 public override void Initialize(ICoreAPI api)
 {
     base.Initialize(api);
     listenerId = RegisterGameTickListener(Check, 16);
 }
コード例 #19
0
 public static BlockEntity BlockEntity(this BlockSelection sel, ICoreAPI Api) => Api.World.BlockAccessor.GetBlockEntity(sel.Position);
コード例 #20
0
 public override void OnLoaded(ICoreAPI api)
 {
     base.OnLoaded(api);
     around = AreaMethods.AreaAroundOffsetList().ToArray();
 }