コード例 #1
0
            public BlockState(Vector3Int pos, Players.Player owner, string blocktype)
            {
                Position  = pos;
                Owner     = owner;
                BlockType = ItemTypes.IndexLookup.GetIndex(blocktype);

                BlockSetting = ActiveBlockManager.GetCallbacks(blocktype);
            }
コード例 #2
0
        public static void OnTryChangeBlockUser(ModLoader.OnTryChangeBlockData d)
        {
            if (d.CallbackState == ModLoader.OnTryChangeBlockData.ECallbackState.Cancelled)
            {
                return;
            }

            if (d.TypeNew == Item.ItemIndex && d.TypeOld == BuiltinBlocks.Air)
            {
                if (World.TryGetTypeAt(d.Position.Add(0, -1, 0), out ushort itemBelow))
                {
                    ActiveBlockManager.RegisterBlockState(d.RequestedByPlayer, new ActiveBlockManager.BlockState(d.Position, d.RequestedByPlayer, nameof(ChickenCoop)));
                    return;
                }

                Chat.Send(d.RequestedByPlayer, "The mining machine must be placed on stone or ore.", ChatColor.orange);
                d.CallbackState = ModLoader.OnTryChangeBlockData.ECallbackState.Cancelled;
                return;
            }
        }
コード例 #3
0
 public static void RegisterMachines(Dictionary <string, ItemTypesServer.ItemTypeRaw> items)
 {
     ActiveBlockManager.RegisterBlockType(nameof(ChickenCoop), new ActiveBlockManager.BlockSetting(Item.ItemIndex, DoWork));
 }