예제 #1
0
        public bool ConnectToServer(string ip, int port)
        {
            var b = ServerHandler.Connect(ip, port);

            if (b)
            {
                ParticleRenderer = new ParticleRenderer();
                SkyboxRenderer   = new SkyboxRenderer();

                BlockPos playerPos = new BlockPos(0, 100, 0);//MathUtil.NextFloat(-100, 100));

                World = new WorldClientServer();

                Player = new EntityPlayerSp(World, playerPos.ToVec());

                World.AddEntity(Player);

                Player.SetItemStackInInventory(0, new ItemStack(ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockCraftingTable>())));
                ResetMouse();

                MouseState state = Mouse.GetState();
                _mouseLast = new Point(state.X, state.Y);
            }

            return(b);
        }
예제 #2
0
        public void CommandGive(string itemName, int amount)
        {
            Item item = ItemRegistry.GetItem(itemName);

            if (item == null)
            {
                return;
            }

            // does it work for max stack??
            ItemStack itemStack = new ItemStack(item, amount);

            Player.OnPickup(itemStack);
        }
예제 #3
0
        private bool TryParseStack(ItemStackNode node, out ItemStack stack)
        {
            if (node == null)
            {
                stack = null;
                return(false);
            }

            Item item = ItemRegistry.GetItem(node.id);

            stack = new ItemStack(item, node.count, node.meta);

            return(true);
        }
예제 #4
0
        public override void ReadData(ByteBufferReader bbr)
        {
            ClearGrid();

            var count = bbr.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var x = bbr.ReadInt32();
                var y = bbr.ReadInt32();

                var meta = bbr.ReadInt32();
                var name = bbr.ReadString();

                _grid[x, y] = new ItemStack(ItemRegistry.GetItem(name), 1, (short)meta);
            }
        }
예제 #5
0
        public void LoadWorld(string saveName)
        {
            if (World != null)
            {
                return;
            }

            ParticleRenderer = new ParticleRenderer();
            SkyboxRenderer   = new SkyboxRenderer();

            World loadedWorld = WorldLoader.LoadWorld(saveName);

            if (loadedWorld == null)
            {
                Console.WriteLine("DEBUG: generating World");

                BlockPos playerPos = new BlockPos(0, 10, 0);//MathUtil.NextFloat(-100, 100));

                World = new WorldClient("MyWorld", "Tomlow's Fuckaround", SettingsManager.GetString("worldseed"));

                Player = new EntityPlayerSp(World, playerPos.ToVec());

                World.AddEntity(Player);

                Player.SetItemStackInInventory(0, new ItemStack(ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockCraftingTable>())));
            }
            else
            {
                World = loadedWorld;
            }

            ResetMouse();

            MouseState state = Mouse.GetState();

            _mouseLast = new Point(state.X, state.Y);
        }
예제 #6
0
 public static void Init(ItemRegistry r)
 {
     food = r.GetItem("food");
 }
예제 #7
0
        public static void Postfix(GameScript __instance, ref RaycastHit ___hit, ref int ___craftType, ref int ___slotID, ref bool ___shifting, ref Item[] ___inventory, ref Item[] ___craft, ref Item[] ___modSlot, ref int ___curBlockSlot, ref ChunkWorld ___chunkWorld, ref ChunkWorld ___chunkWorldWall, ref Item __state)
        {
            if (!GameScript.pausing && !GameScript.inventoryOpen && GameScript.buildMode && Input.GetMouseButtonDown(0) && ___inventory[___curBlockSlot].q > 0 && ItemRegistry.Singleton.HasEntry(___inventory[___curBlockSlot].id))
            {
                int num4 = (int)__instance.hoverBuild.transform.position.x;
                int num5 = (int)__instance.hoverBuild.transform.position.y;
                int num6 = (num4 + 62) / 4;
                int num7 = (num5 + 62) / 4;
                if (num6 < 64 && num6 >= 0 && num7 < 64 && num7 >= 0)
                {
                    ItemInfo item = ItemRegistry.Singleton.GetEntry(___inventory[___curBlockSlot].id);
                    if (item.Tile != null && item.Tile.TryPlaceTile())
                    {
                        if (item.Tile.Type == TileType.WALL)
                        {
                            if (___chunkWorldWall.grid[num6, num7] == 0)
                            {
                                int[] value = new int[]
                                {
                                    num4,
                                    num5,
                                    GameScript.curBlockID
                                };
                                __instance.WallManager.SendMessage("PlaceTile", value);
                                __instance.hoverBuild.SendMessage("Refresh");
                                __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/emblem"), Menuu.soundLevel / 10f);
                                ___inventory[___curBlockSlot].q--;
                                RefreshSlot.Invoke(__instance, new object[] { ___curBlockSlot });
                                if (___inventory[___curBlockSlot].q <= 0 && GameScript.buildMode)
                                {
                                    __instance.ExitBuildMode();
                                    __instance.hoverSprite.GetComponent <Renderer>().material = (Material)Resources.Load("mat/trans");
                                    GameScript.curBlockID = 0;
                                }
                            }
                        }
                        else if (item.Tile.Type == TileType.SOLID)
                        {
                            if (___chunkWorld.gridSpecial[num6, num7] == 0 && ___chunkWorld.grid[num6, num7] == 0)
                            {
                                int[] value3 = new int[]
                                {
                                    num4,
                                    num5,
                                    GameScript.curBlockID
                                };
                                __instance.TileManager.SendMessage("PlaceTile", value3);
                                __instance.hoverBuild.SendMessage("Refresh");
                                __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/emblem"), Menuu.soundLevel / 10f);
                                ___inventory[___curBlockSlot].q--;
                                RefreshSlot.Invoke(__instance, new object[] { ___curBlockSlot });
                                if (___inventory[___curBlockSlot].q <= 0 && GameScript.buildMode)
                                {
                                    __instance.ExitBuildMode();
                                    __instance.hoverSprite.GetComponent <Renderer>().material = (Material)Resources.Load("mat/trans");
                                    GameScript.curBlockID = 0;
                                }
                            }
                        }
                        else
                        {
                            if (___chunkWorld.gridSpecial[num6, num7] == 0 && ___chunkWorld.grid[num6, num7] == 0)
                            {
                                if (GameScript.curBlockID == 2107 && __instance.gatherer)
                                {
                                    __instance.Error(11);
                                }
                                else
                                {
                                    int[] value2 = new int[]
                                    {
                                        num4,
                                        num5,
                                        GameScript.curBlockID
                                    };
                                    __instance.TileManager.SendMessage("PlaceTileSpecial", value2);
                                    __instance.hoverBuild.SendMessage("Refresh");
                                    __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/emblem"), Menuu.soundLevel / 10f);
                                    ___inventory[___curBlockSlot].q--;
                                    RefreshSlot.Invoke(__instance, new object[] { ___curBlockSlot });
                                    if (___inventory[___curBlockSlot].q <= 0 && GameScript.buildMode)
                                    {
                                        __instance.ExitBuildMode();
                                        __instance.hoverSprite.GetComponent <Renderer>().material = (Material)Resources.Load("mat/trans");
                                        GameScript.curBlockID = 0;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (MenuScript.player && !GameScript.pausing)
            {
                if (Input.GetMouseButtonDown(0) && GameScript.inventoryOpen && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out ___hit, 7f))
                {
                    if (___hit.transform.gameObject.layer == 16)
                    {
                        if (___hit.transform.gameObject.tag == "craft")
                        {
                            if (MenuRegistry.Singleton[___craftType] is CraftMenuInfo craftMenu)
                            {
                                ___slotID = int.Parse(___hit.transform.gameObject.name);
                                if (__state.id != 0)
                                {
                                    Item   holdingItem = __state;
                                    Item[] craftItems  = ___craft;
                                    int    slotID      = ___slotID;
                                    if (craftMenu.SlotValidators.Any(x => x(holdingItem, craftItems, slotID)))
                                    {
                                        if (___craft[___slotID].id == __state.id)
                                        {
                                            __instance.InvokeMethod("CombineItemCraft", ___slotID);
                                        }
                                        else if (___craft[___slotID].id == 0)
                                        {
                                            __instance.InvokeMethod("PlaceItemCraft", ___slotID);
                                        }
                                    }
                                }
                                else if (___craft[___slotID].id != 0)
                                {
                                    if (!___shifting)
                                    {
                                        __instance.InvokeMethod("SelectItemCraft", ___slotID);
                                    }
                                    else if (___shifting && __instance.menuCraft.activeSelf)
                                    {
                                        __instance.StartCoroutine(__instance.InvokeMethod <IEnumerator>("ShiftClickCraft", ___slotID));
                                    }
                                }
                            }
                            else if (___craftType == 0)
                            {
                                ___slotID = int.Parse(___hit.transform.gameObject.name);
                                if (__state.id != 0 && ___craft[___slotID].id != __state.id)
                                {
                                    if ((__state.id <= 100 || __state.id >= 200) && __instance.InvokeMethod <bool>("CanPlaceCraft", __state.id))
                                    {
                                        ItemType?itemType = ItemRegistry.GetItem(__state.id)?.Type;
                                        if (itemType.HasValue && (itemType.Value & (ItemType.EMBLEM | ItemType.EQUIPABLE)) == ItemType.EMBLEM)
                                        {
                                            if (___craft[___slotID].id == 0)
                                            {
                                                __instance.InvokeMethod("PlaceItemCraft", ___slotID);
                                            }
                                            else
                                            {
                                                __instance.InvokeMethod("SwapItemCraft", ___slotID);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (___craftType == 1)
                            {
                                ___slotID = int.Parse(___hit.transform.gameObject.name);
                                if (__state.id != 0 && ___craft[___slotID].id != __state.id)
                                {
                                    if ((__state.id <= 10 || __state.id >= 40) && __instance.InvokeMethod <bool>("CanPlaceCraft", __state.id))
                                    {
                                        ItemType?itemType = ItemRegistry.GetItem(__state.id)?.Type;
                                        if (itemType.HasValue && (itemType.Value & (ItemType.EMBLEM | ItemType.EQUIPABLE)) == ItemType.LOOT && (itemType.Value & ItemType.ORGANIC) == ItemType.ORGANIC)
                                        {
                                            if (___craft[___slotID].id == 0)
                                            {
                                                __instance.InvokeMethod("PlaceItemCraft", ___slotID);
                                            }
                                            else
                                            {
                                                __instance.InvokeMethod("SwapItemCraft", ___slotID);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (___craftType == 2)
                            {
                                ___slotID = int.Parse(___hit.transform.gameObject.name);
                                if (__state.id != 0)
                                {
                                    if (___slotID == 0 && ___craft[___slotID].id != __state.id)
                                    {
                                        if (___craft[0].id == 0 &&
                                            (__state.id < 1000 || __state.id >= 1006) && (__state.id < 450 || __state.id >= 456) &&
                                            (__state.id < 500 || __state.id >= 506) && (__state.id < 600 || __state.id >= 612) &&
                                            (__state.id < 550 || __state.id >= 562) && (__state.id < 350 || __state.id >= 362) &&
                                            (__state.id < 400 || __state.id >= 412) && (__state.id < 300 || __state.id >= 312) &&
                                            (__state.id < 700 || __state.id >= 712) && (__state.id < 800 || __state.id >= 812))
                                        {
                                            Item holdingItem = __state;
                                            if (GadgetCoreAPI.ultimateForgeRecipes.Any(x => x.Key.Item1 == holdingItem.id))
                                            {
                                                if (__instance.InvokeMethod <int>("GetItemLevel", holdingItem.exp) >= 10)
                                                {
                                                    __instance.InvokeMethod("PlaceItemCraft", ___slotID);
                                                }
                                                else
                                                {
                                                    __instance.InvokeMethod("Error", 12);
                                                }
                                            }
                                        }
                                    }
                                    else if (___slotID == 2)
                                    {
                                        if (___craft[2].id == 0 && (__state.id < 89 || __state.id >= 92))
                                        {
                                            Item holdingItem = __state;
                                            if (GadgetCoreAPI.ultimateForgeRecipes.Any(x => x.Key.Item2 == holdingItem.id))
                                            {
                                                __instance.InvokeMethod("PlaceItemCraft", ___slotID);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (___craftType == 3)
                            {
                                ___slotID = int.Parse(___hit.transform.gameObject.name);
                                if (__state.id != 0 && ___craft[___slotID].id != __state.id)
                                {
                                    if ((__state.id <= 103 || __state.id >= 107) && (__state.id <= 113 || __state.id >= 117) &&
                                        (__state.id <= 123 || __state.id >= 127) && (__state.id <= 133 || __state.id >= 137) &&
                                        __instance.InvokeMethod <bool>("CanPlaceCraft2", __state.id))
                                    {
                                        Item holdingItem = __state;
                                        if (GadgetCoreAPI.creationMachineRecipes.Any(x => x.Key == holdingItem.id))
                                        {
                                            if (___craft[___slotID].id == 0)
                                            {
                                                __instance.InvokeMethod("PlaceItemCraft", ___slotID);
                                            }
                                            else
                                            {
                                                __instance.InvokeMethod("SwapItemCraft", ___slotID);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else if (___hit.transform.gameObject.tag == "planet")
                        {
                            ___slotID = int.Parse(___hit.transform.gameObject.name);
                            if (___slotID >= 14)
                            {
                                while (___slotID >= 14)
                                {
                                    ___slotID -= 14;
                                    PlanetRegistry.PlanetSelectorPage++;
                                }
                                PlanetRegistry.UpdatePlanetSelector();
                            }
                            int planetIndex = (PlanetRegistry.PlanetSelectorPage - 2) * 14 + ___slotID;
                            if (planetIndex >= 0 && planetIndex < PlanetRegistry.selectorPlanets.Length && PlanetRegistry.selectorPlanets[planetIndex] is PlanetInfo planet)
                            {
                                if (planet.PortalUses > 0 || planet.PortalUses == -1)
                                {
                                    InstanceTracker.GameScript.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/confirm"), Menuu.soundLevel / 10f);
                                    InstanceTracker.GameScript.planetSelector.transform.position = new Vector3(InstanceTracker.GameScript.planetGuard[___slotID].transform.position.x, InstanceTracker.GameScript.planetGuard[___slotID].transform.position.y, InstanceTracker.GameScript.planetSelector.transform.position.z);
                                    GameScript.curPlanet = ___slotID;
                                    InstanceTracker.GameScript.planetObj.GetComponent <Renderer>().material = (Material)Resources.Load("mat/planet" + planet.ID);
                                    InstanceTracker.GameScript.planetObj.GetComponent <Animation>().Play();
                                    InstanceTracker.GameScript.txtPlanetName[0].text = planet.Name;
                                    InstanceTracker.GameScript.txtPlanetName[1].text = InstanceTracker.GameScript.txtPlanetName[0].text;
                                    InstanceTracker.GameScript.txtHostile[0].text    = "Hostile Lv." + InstanceTracker.GameScript.InvokeMethod("GetPlanetHostile", planet.ID);
                                    InstanceTracker.GameScript.txtHostile[1].text    = InstanceTracker.GameScript.txtHostile[0].text;
                                    if (planet.PortalUses > 0)
                                    {
                                        InstanceTracker.GameScript.txtPortalUses[0].text = "Portal Uses: " + planet.PortalUses;
                                        InstanceTracker.GameScript.txtPortalUses[1].text = InstanceTracker.GameScript.txtPortalUses[0].text;
                                    }
                                    else if (planet.PortalUses == -1)
                                    {
                                        InstanceTracker.GameScript.txtPortalUses[0].text = "Portal Uses: Infinite";
                                        InstanceTracker.GameScript.txtPortalUses[1].text = InstanceTracker.GameScript.txtPortalUses[0].text;
                                    }
                                }
                            }
                        }
                        else if (___hit.transform.gameObject.tag == "mod")
                        {
                            ___slotID = int.Parse(___hit.transform.gameObject.name);
                            Item holdingItem = __state;
                            if (holdingItem.id != 0)
                            {
                                if ((holdingItem.id < 300 || holdingItem.id >= 1000) && (ItemRegistry.GetItem(holdingItem.id).Type & ItemType.MODABLE) == ItemType.MODABLE)
                                {
                                    if (___modSlot[___slotID].id == 0)
                                    {
                                        __instance.PlaceItemMod(___slotID);
                                    }
                                    else
                                    {
                                        __instance.SwapItemMod(___slotID);
                                    }
                                }
                            }
                            else if ((___modSlot[___slotID].id < 300 || ___modSlot[___slotID].id >= 1000) && (ItemRegistry.GetItem(___modSlot[___slotID].id).Type & ItemType.MODABLE) == ItemType.MODABLE)
                            {
                                __instance.SelectItemMod(___slotID);
                            }
                        }
                    }
                    else if (___hit.transform.gameObject.layer != 17)
                    {
                        switch (___hit.transform.gameObject.name)
                        {
                        case "bPlanetPageBack":
                            __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/confirm"), Menuu.soundLevel / 10f);
                            if (PlanetRegistry.PlanetSelectorPage <= 1)
                            {
                                PlanetRegistry.PlanetSelectorPage = PlanetRegistry.PlanetSelectorPages;
                            }
                            else
                            {
                                PlanetRegistry.PlanetSelectorPage--;
                            }
                            PlanetRegistry.UpdatePlanetSelector();
                            break;

                        case "bPlanetPageForward":
                            __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/confirm"), Menuu.soundLevel / 10f);
                            if (PlanetRegistry.PlanetSelectorPage >= PlanetRegistry.PlanetSelectorPages)
                            {
                                PlanetRegistry.PlanetSelectorPage = 1;
                            }
                            else
                            {
                                PlanetRegistry.PlanetSelectorPage++;
                            }
                            PlanetRegistry.UpdatePlanetSelector();
                            break;
                        }
                    }
                }
                else if (Input.GetMouseButtonDown(1) && GameScript.inventoryOpen && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out ___hit, 7f))
                {
                    if (___hit.transform.gameObject.layer == 16)
                    {
                        if (___hit.transform.gameObject.tag == "craft")
                        {
                            if (MenuRegistry.Singleton.GetEntry(___craftType) is CraftMenuInfo craftMenu)
                            {
                                ___slotID = int.Parse(___hit.transform.gameObject.name);
                                if (__state.id != 0)
                                {
                                    Item   holdingItem = __state;
                                    Item[] craftItems  = ___craft;
                                    int    slotID      = ___slotID;
                                    if (craftMenu.SlotValidators.Any(x => x(holdingItem, craftItems, slotID)))
                                    {
                                        if (___craft[___slotID].id == 0 || (GadgetCoreAPI.CanItemsStack(___craft[___slotID], __state) && ___craft[___slotID].q < 9999))
                                        {
                                            __instance.InvokeMethod("PlaceOneItemCraft", ___slotID);
                                        }
                                        else
                                        {
                                            __instance.InvokeMethod("SwapItemCraft", ___slotID);
                                        }
                                    }
                                }
                            }
                        }
                        else if (___hit.transform.gameObject.tag == "mod")
                        {
                            ___slotID = int.Parse(___hit.transform.gameObject.name);
                            Item holdingItem = __state;
                            if (holdingItem.id != 0)
                            {
                                if ((holdingItem.id < 300 || holdingItem.id >= 1000) && (ItemRegistry.GetItem(holdingItem.id).Type & ItemType.MODABLE) == ItemType.MODABLE)
                                {
                                    if (___modSlot[___slotID].id == 0)
                                    {
                                        __instance.PlaceItemMod(___slotID);
                                    }
                                    else
                                    {
                                        __instance.SwapItemMod(___slotID);
                                    }
                                }
                            }
                            else if ((___modSlot[___slotID].id < 300 || ___modSlot[___slotID].id >= 1000) && (ItemRegistry.GetItem(holdingItem.id).Type & ItemType.MODABLE) == ItemType.MODABLE)
                            {
                                __instance.SelectItemMod(___slotID);
                            }
                        }
                    }
                }
            }
        }
예제 #8
0
 public static bool Prefix(GameScript __instance, ref bool ___shiftclicking, Item[] ___inventory, ref Item[] ___craft, ref int ___craftType, int slot, ref IEnumerator __result)
 {
     itemInSlot = ___inventory[slot];
     if (!___shiftclicking)
     {
         ItemInfo slotInfo = ItemRegistry.GetItem(itemInSlot.id);
         ItemType slotItemTypeUnfiltered = slotInfo.Type;
         ItemType slotItemType           = slotItemTypeUnfiltered & (ItemType.EQUIP_MASK | ItemType.TYPE_MASK);
         bool     flag = false;
         int      num  = 0;
         if ((___craftType == 0 && (slotItemType & (ItemType.EMBLEM | ItemType.EQUIPABLE)) == ItemType.EMBLEM) ||
             (___craftType == 1 && (slotItemType & (ItemType.EMBLEM | ItemType.EQUIPABLE)) == ItemType.LOOT && (slotItemTypeUnfiltered & ItemType.ORGANIC) == ItemType.ORGANIC))
         {
             for (int i = 0; i < 3; i++)
             {
                 if (GadgetCoreAPI.CanItemsStack(___craft[i], itemInSlot) && ___craft[i].q + ___inventory[slot].q <= 9999)
                 {
                     flag = true;
                     num  = i;
                     break;
                 }
             }
             if (flag)
             {
                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                 ___craft[num].q   += ___inventory[slot].q;
                 ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                 __instance.RefreshSlot(slot);
                 __instance.RefreshSlotCraft(num);
             }
             else
             {
                 for (int i = 0; i < 3; i++)
                 {
                     if (___craft[i].id == 0)
                     {
                         __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         ___craft[i]        = ___inventory[slot];
                         ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                         __instance.RefreshSlot(slot);
                         __instance.RefreshSlotCraft(i);
                         break;
                     }
                 }
             }
         }
         else if (MenuRegistry.Singleton.GetEntry(___craftType) is CraftMenuInfo craftMenu)
         {
             Item[]        craftItems      = ___craft;
             HashSet <int> acceptableSlots = new HashSet <int>(Enumerable.Range(0, ___craft.Length).Where(x => craftMenu.SlotValidators.Any(v => v(___inventory[slot], craftItems, x))));
             foreach (int i in acceptableSlots)
             {
                 if (GadgetCoreAPI.CanItemsStack(___craft[i], itemInSlot) && ___craft[i].q < 9999)
                 {
                     flag = true;
                     num  = i;
                     break;
                 }
             }
             if (flag)
             {
                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                 ___craft[num].q += ___inventory[slot].q;
                 if (___craft[num].q > 9999)
                 {
                     ___inventory[slot].q = ___craft[num].q - 9999;
                     ___craft[num].q      = 9999;
                 }
                 else
                 {
                     ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                 }
                 __instance.RefreshSlot(slot);
                 __instance.RefreshSlotCraft(num);
             }
             else
             {
                 foreach (int i in acceptableSlots)
                 {
                     if (___craft[i].id == 0)
                     {
                         __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         ___craft[i]        = ___inventory[slot];
                         ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                         __instance.RefreshSlot(slot);
                         __instance.RefreshSlotCraft(i);
                         break;
                     }
                 }
             }
         }
         ___shiftclicking = false;
         __instance.InvokeMethod("CraftCheck");
         __result = FakeRoutine();
         return(false);
     }
     return(true);
 }
예제 #9
0
        private void GameRegistry()
        {
            _blockRegistry  = new BlockRegistry();
            _itemRegistry   = new ItemRegistry();
            _recipeRegistry = new RecipeRegistry();

            for (int i = 1; i < 6; i++)
            {
                //SoundEngine.RegisterSound($"block/grass/walk{i}");
            }

            //register materails
            Material.RegisterMaterial(new Material("air", true));
            Material.RegisterMaterial(new Material("tallgrass", true));
            Material.RegisterMaterial(new Material("grass", false));
            Material.RegisterMaterial(new Material("dirt", false));
            Material.RegisterMaterial(new Material("stone", false));
            Material.RegisterMaterial(new Material("wood", false));

            _blockRegistry.Put(new BlockAir());
            _blockRegistry.Put(new BlockStone());
            _blockRegistry.Put(new BlockGrass());
            _blockRegistry.Put(new BlockDirt());
            _blockRegistry.Put(new BlockCobbleStone());
            _blockRegistry.Put(new BlockPlanks());
            _blockRegistry.Put(new BlockBedrock());
            _blockRegistry.Put(new BlockLog());
            _blockRegistry.Put(new BlockLeaves());
            _blockRegistry.Put(new BlockGlass());
            _blockRegistry.Put(new BlockCraftingTable());
            _blockRegistry.Put(new BlockFurnace());
            //_blockRegistry.Put(new BlockSlab());
            _blockRegistry.Put(new BlockRare());
            _blockRegistry.Put(new BlockLadder());
            _blockRegistry.Put(new BlockTallGrass());
            _blockRegistry.Put(new BlockTulipRed());
            _blockRegistry.Put(new BlockTulipOrange());
            _blockRegistry.Put(new BlockTNT());

            //POST - MOD Blocks and Items
            //foreach (ModMain mod in _installedMods)
            //{
            //mod.OnItemsAndBlocksRegistry(new RegistryEventArgs(_blockRegistry, _itemRegistry, _recipeRegistry));
            //}

            foreach (var block in BlockRegistry.AllBlocks())
            {
                _itemRegistry.Put(new ItemBlock(block));
            }

            Item stick = new ItemStick();

            _itemRegistry.Put(new ItemPickaxe("wood"));
            _itemRegistry.Put(new ItemPickaxe("stone"));
            _itemRegistry.Put(new ItemPickaxe("rare"));
            _itemRegistry.Put(stick);

            var log    = ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockLog>());
            var wood   = ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockPlanks>());
            var cobble = ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockCobbleStone>());
            var rare   = ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockRare>());

            Item[] recipe =
            {
                cobble, cobble, cobble,
                null,   stick,  null,
                null,   stick,  null
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem("sharpcraft", "pick_stone"));

            recipe = new[]
            {
                rare, rare, rare,
                null, stick, null,
                null, stick, null
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem("sharpcraft", "pick_rare"));

            recipe = new[]
            {
                wood, wood, wood,
                null, stick, null,
                null, stick, null
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem("sharpcraft", "pick_wood"));

            recipe = new[]
            {
                cobble, cobble, cobble,
                cobble, null, cobble,
                cobble, cobble, cobble
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockFurnace>()));

            recipe = new[]
            {
                wood, wood, null,
                wood, wood, null,
                null, null, null
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockCraftingTable>()));

            recipe = new[]
            {
                log, null, null,
                null, null, null,
                null, null, null
            };
            _recipeRegistry.RegisterRecipe(recipe, new ItemStack(wood, 4), true);

            recipe = new[]
            {
                wood, null, null,
                wood, null, null,
                null, null, null
            };
            _recipeRegistry.RegisterRecipe(recipe, new ItemStack(stick, 4));

            recipe = new[]
            {
                wood, wood, wood,
                null, wood, null,
                wood, wood, wood
            };
            _recipeRegistry.RegisterRecipe(recipe, ItemRegistry.GetItem("sharpcraft", "ladder"));

            //foreach (ModMain mod in _installedMods)
            //{
            //mod.OnRecipeRegistry(new RecipeRegistryEventArgs(_recipeRegistry));
            //}

            //LangUtil.LoadLang(SettingsManager.GetString("lang"));//TODO - find a proper placement for this line
        }
예제 #10
0
 public void AddItem(string itemId)
 {
     AddItem(ItemRegistry.GetItem(itemId));
 }
예제 #11
0
        public void SendMessage()
        {
            string msg = _currentInputText.Trim();

            if (msg.Length > 0)
            {
                bool isCommand = msg[0] == '/';

                if (!HistoryQueue.Contains(msg))
                {
                    HistoryQueue.Add(msg);
                }

                if (!isCommand)
                {
                    return;
                }

                try
                {
                    msg = msg.Substring(1, msg.Length - 1);

                    string[] split = msg.Split(' ');

                    var cmd = split[0];

                    switch (cmd)
                    {
                    case "tp":
                        Vector3 position  = Vector3.Zero;
                        Vector3 playerPos = SharpCraft.Instance.Player.Pos;

                        for (int i = 0; i < 3; i++)
                        {
                            string arg = split[1 + i];

                            float value;

                            if (arg[0] == '~')
                            {
                                value = int.Parse("0" + arg.Substring(1, arg.Length - 1)) + playerPos[i];
                            }
                            else
                            {
                                value = int.Parse(arg);
                            }

                            position[i] = value;
                        }

                        SharpCraft.Instance.Player.TeleportTo(position);
                        break;

                    case "give":
                        string itemName = split[1];
                        int    ammount  = 1;

                        if (split.Length > 2)
                        {
                            ammount = int.Parse(split[2]);
                        }

                        if (ItemRegistry.GetItem(itemName) is Item item)
                        {
                            SharpCraft.Instance.Player.OnPickup(new ItemStack(item, ammount));
                        }

                        break;
                    }
                }
                catch
                {
                }
            }
        }