当前位置: 首页>>代码示例>>C#>>正文


C# Item.netDefaults方法代码示例

本文整理汇总了C#中Terraria.Item.netDefaults方法的典型用法代码示例。如果您正苦于以下问题:C# Item.netDefaults方法的具体用法?C# Item.netDefaults怎么用?C# Item.netDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Terraria.Item的用法示例。


在下文中一共展示了Item.netDefaults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FillVanilla

        /// <summary>
        /// Adds all the original vanilla items.
        /// </summary>
        internal static void FillVanilla()
        {
            for (int i = -24 /* some phasesabre */; i < ItemID.Count; i++)
            {
                //if (i > -19 /* phasesabres stop at -19 because Redigit */ && i <= 0)
                // copper etc items, using <=1.2-style netids instead of the new types (backwards compatibility needed for terraria code that still uses those netids)
                if (i == 0)
                    continue;

                Item it = new Item();
                it.netDefaults(i);

                ItemDef def = new ItemDef(Lang.itemName(it.type, true));

                def.InternalName = it.name;
                def.Type = it.type;
                def.NetID = i;

                CopyItemToDef(def, it);

                DefFromType.Add(i, def);
                // TODO Fix overlapping names
                //VanillaDefFromName.Add(it.name, def);
            }

            Recipes.AddVanillaRecipeReferences();
        }
开发者ID:chatrat12,项目名称:Prism,代码行数:30,代码来源:ItemDefHandler.cs

示例2: ReadExtraData

 public override void ReadExtraData(BinaryReader reader)
 {
     item = new Item();
     item.netDefaults((int)reader.ReadInt16());
     item.Prefix((int)reader.ReadByte());
     item.stack = (int)reader.ReadInt16();
 }
开发者ID:EmuDevs,项目名称:EDTerraria,代码行数:7,代码来源:TEItemFrame.cs

示例3: Process

        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            int num48 = (int)ReadInt16(readBuffer);
            var position = ReadVector2(readBuffer);
            var velocity = ReadVector2(readBuffer);
            int stack2 = (int)ReadInt16(readBuffer);
            int pre = (int)ReadByte(readBuffer);
            int num49 = (int)ReadByte(readBuffer);
            int num50 = (int)ReadInt16(readBuffer);

            {
                if (num50 == 0)
                {
                    if (num48 < 400)
                    {
                        Main.item[num48].active = false;
                        NewNetMessage.SendData(21, -1, -1, String.Empty, num48, 0f, 0f, 0f, 0);
                        return;
                    }
                    return;
                }
                else
                {
                    bool flag7 = false;
                    if (num48 == 400)
                    {
                        flag7 = true;
                    }
                    if (flag7)
                    {
                        Item item2 = new Item();
                        item2.netDefaults(num50);
                        num48 = Item.NewItem((int)position.X, (int)position.Y, item2.width, item2.height, item2.type, stack2, true, 0, false);
                    }
                    Item item3 = Main.item[num48];
                    item3.netDefaults(num50);
                    item3.Prefix(pre);
                    item3.stack = stack2;
                    item3.position = position;
                    item3.velocity = velocity;
                    item3.active = true;
                    item3.owner = Main.myPlayer;
                    if (flag7)
                    {
                        NewNetMessage.SendData(21, -1, -1, String.Empty, num48, 0f, 0f, 0f, 0);
                        if (num49 == 0)
                        {
                            Main.item[num48].ownIgnore = whoAmI;
                            Main.item[num48].ownTime = 100;
                        }
                        Main.item[num48].FindOwner(num48);
                        return;
                    }
                    NewNetMessage.SendData(21, -1, whoAmI, String.Empty, num48, 0f, 0f, 0f, 0);
                    return;
                }
            }
        }
开发者ID:VanixxGraphix,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:58,代码来源:21_ItemInfoMessage.cs

示例4: ReadModItem

 internal static void ReadModItem(Item item, BinaryReader reader)
 {
     string modName = reader.ReadString();
     string itemName = reader.ReadString();
     Mod mod = ModLoader.GetMod(modName);
     int type = mod == null ? 0 : mod.ItemType(itemName);
     if (type != 0)
     {
         item.netDefaults(type);
         int dataLength = reader.ReadUInt16();
         if (dataLength > 0)
         {
             byte[] data = reader.ReadBytes(dataLength);
             using (MemoryStream memoryStream = new MemoryStream(data))
             {
                 using (BinaryReader customReader = new BinaryReader(memoryStream))
                 {
                     item.modItem.LoadCustomData(customReader);
                 }
             }
         }
         if (type == ModLoader.GetMod("ModLoader").ItemType("MysteryItem"))
         {
             MysteryItem mystery = item.modItem as MysteryItem;
             modName = mystery.GetModName();
             itemName = mystery.GetItemName();
             mod = ModLoader.GetMod(modName);
             type = mod == null ? 0 : mod.ItemType(itemName);
             if (type != 0)
             {
                 item.netDefaults(type);
             }
         }
     }
     else
     {
         item.netDefaults(ModLoader.GetMod("ModLoader").ItemType("MysteryItem"));
         MysteryItem mystery = item.modItem as MysteryItem;
         mystery.SetModName(modName);
         mystery.SetItemName(itemName);
         reader.ReadBytes(reader.ReadUInt16());
     }
     item.Prefix(reader.ReadByte());
 }
开发者ID:Evarenis,项目名称:tModLoader,代码行数:44,代码来源:ItemIO.cs

示例5: Item

        TextSnippet ITagHandler.Parse(string text, Color baseColor, string options)
        {
            Item obj = new Item();
            int result1;
            if (int.TryParse(text, out result1))
                obj.netDefaults(result1);
            else
                obj.SetDefaults(text);

            if (obj.itemId <= 0)
                return new TextSnippet(text);

            obj.stack = 1;
            if (options != null)
            {
                string[] strArray = options.Split(',');
                for (int index = 0; index < strArray.Length; ++index)
                {
                    if (strArray[index].Length != 0)
                    {
                        switch (strArray[index][0])
                        {
                            case 'p':
                                int result2;
                                if (int.TryParse(strArray[index].Substring(1), out result2))
                                {
                                    obj.Prefix(Utils.Clamp<int>(result2, 0, 84));
                                    continue;
                                }
                                continue;
                            case 's':
                            case 'x':
                                int result3;
                                if (int.TryParse(strArray[index].Substring(1), out result3))
                                {
                                    obj.stack = Utils.Clamp<int>(result3, 1, obj.maxStack);
                                    continue;
                                }
                                continue;
                            default:
                                continue;
                        }
                    }
                }
            }

            string str = "";
            if (obj.stack > 1)
                str = " (" + obj.stack + ")";

            ItemSnippet itemSnippet = new ItemSnippet(obj);
            itemSnippet.Text = "[" + obj.AffixName() + str + "]";
            itemSnippet.CheckForHover = true;
            itemSnippet.DeleteWhole = true;
            return itemSnippet;
        }
开发者ID:EmuDevs,项目名称:EDTerraria,代码行数:56,代码来源:ItemTagHandler.cs

示例6: Draw

		public override void Draw(SpriteBatch sb, bool mouseOver)
		{
			//base.Draw(sb, mouseOver);

			StarterSet set = StarterSet.Sets[StarterSet.SelectedSet];

			Item drawItem = new Item();

			for (int i = 0; i < set.Items.Length; i++)
			{
				drawItem.netDefaults(set.Items[i]);

				DrawItem(drawItem, sb, position + new Vector2(0f, i * (drawItem.GetTexture().Height + 5f)));
				//sb.Draw(drawItem.GetTexture(), position + new Vector2(0f, i * (drawItem.GetTexture().Height + 5f)), ComposeColour(drawItem));
			}

			if (set.ArmourHead != 0)
			{
				drawItem.netDefaults(set.ArmourHead);

				DrawItem(drawItem, sb, position + new Vector2(ARMOUR_OFFSET, 0f));
				//sb.Draw(drawItem.GetTexture(), position + new Vector2(ARMOUR_OFFSET, 0f                                     ), ComposeColour(drawItem));
			}
			if (set.ArmourBody != 0)
			{
				drawItem.netDefaults(set.ArmourBody);

				DrawItem(drawItem, sb, position + new Vector2(ARMOUR_OFFSET, 2f * drawItem.GetTexture().Height + 5f));
				//sb.Draw(drawItem.GetTexture(), position + new Vector2(ARMOUR_OFFSET, 2f * drawItem.GetTexture().Height +  5f), ComposeColour(drawItem));
			}
			if (set.ArmourLegs != 0)
			{
				drawItem.netDefaults(set.ArmourLegs);

				DrawItem(drawItem, sb, position + new Vector2(ARMOUR_OFFSET, 4f * drawItem.GetTexture().Height + 10f));
				//sb.Draw(drawItem.GetTexture(), position + new Vector2(ARMOUR_OFFSET, 4f * drawItem.GetTexture().Height + 10f), ComposeColour(drawItem));
			}
		}
开发者ID:RainbowDashGaming,项目名称:Terraria-Avalon-MODIFIED,代码行数:38,代码来源:StarterSetDisplayer.cs

示例7: TerrariaWrapper

        public TerrariaWrapper()
        {
            base.Initialize();

            Terraria.Item curItem = new Item();
            for (int i = -1; i > -255; i--)
            {
                curItem = new Item();
                curItem.netDefaults(i);
                if (string.IsNullOrWhiteSpace(curItem.name))
                    break;

                HardCodedItems.Add(new ItemId(curItem.type, curItem.name, GetItemType(curItem)));
            }
        }
开发者ID:prototype464,项目名称:Terraria-Map-Editor,代码行数:15,代码来源:TerrariaWrapper.cs

示例8: TerrariaWrapper

        public TerrariaWrapper()
        {

            Main.dedServ = true;
            Main.showSplash = false;
            this.Initialize();

            Terraria.Item curItem = new Item();
            for (int i = -1; i > -255; i--)
            {
                curItem = new Item();
                curItem.netDefaults(i);
                if (string.IsNullOrWhiteSpace(curItem.name))
                    break;

                HardCodedItems.Add(new ItemId(curItem.type, curItem.name, GetItemType(curItem)));
            }

        }
开发者ID:KeviinSkyline,项目名称:Terraria-Map-Editor,代码行数:19,代码来源:TerrariaWrapper.cs

示例9: HandleItemDrop

        private static bool HandleItemDrop(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt16();
            var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            var stacks = args.Data.ReadInt16();
            var prefix = args.Data.ReadInt8();
            var noDelay = args.Data.ReadInt8() == 1;
            var type = args.Data.ReadInt16();

            if (OnItemDrop(id, pos, vel, stacks, prefix, noDelay, type))
                return true;

            // player is attempting to crash clients
            if (type < -48 || type >= Main.maxItemTypes)
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }

            if (prefix > Item.maxPrefixes) //make sure the prefix is a legit value
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }

            if (type == 0) //Item removed, let client do this to prevent item duplication client side (but only if it passed the range check)
            {
                if (TShock.CheckRangePermission(args.Player, (int)(Main.item[id].position.X / 16f), (int)(Main.item[id].position.Y / 16f)))
                {
                    args.Player.SendData(PacketTypes.ItemDrop, "", id);
                    return true;
                }

                return false;
            }

            if (TShock.CheckRangePermission(args.Player, (int)(pos.X / 16f), (int)(pos.Y / 16f)))
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }

            if (Main.item[id].active && Main.item[id].netID != type) //stop the client from changing the item type of a drop but only if the client isn't picking up the item
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }

            Item item = new Item();
            item.netDefaults(type);
            if ((stacks > item.maxStack || stacks <= 0) || (TShock.Itembans.ItemIsBanned(item.name, args.Player) && !args.Player.Group.HasPermission(Permissions.allowdroppingbanneditems)))
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }
            if ((Main.ServerSideCharacter) && (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - args.Player.LoginMS < TShock.ServerSideCharacterConfig.LogonDiscardThreshold))
            {
                //Player is probably trying to sneak items onto the server in their hands!!!
                TShock.Log.ConsoleInfo("Player {0} tried to sneak {1} onto the server!", args.Player.Name, item.name);
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;

            }
            if (TShock.CheckIgnores(args.Player))
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }

            return false;
        }
开发者ID:CXUtk,项目名称:TShock,代码行数:72,代码来源:GetDataHandlers.cs

示例10: HandlePlayerSlot

        private static bool HandlePlayerSlot(GetDataHandlerArgs args)
        {
            byte plr = args.Data.ReadInt8();
            byte slot = args.Data.ReadInt8();
            short stack = args.Data.ReadInt16();
            byte prefix = args.Data.ReadInt8();
            short type = args.Data.ReadInt16();

            // Players send a slot update packet for each inventory slot right after they've joined.
            bool bypassTrashCanCheck = false;
            if (plr == args.Player.Index && !args.Player.HasSentInventory && slot == NetItem.MaxInventory)
            {
                args.Player.HasSentInventory = true;
                bypassTrashCanCheck = true;
            }

            if (OnPlayerSlot(plr, slot, stack, prefix, type) || plr != args.Player.Index || slot < 0 ||
                slot > NetItem.MaxInventory)
                return true;
            if (args.Player.IgnoreSSCPackets)
            {
                args.Player.SendData(PacketTypes.PlayerSlot, "", args.Player.Index, slot, prefix);
                return true;
            }

            // Garabage? Or will it cause some internal initialization or whatever?
            var item = new Item();
            item.netDefaults(type);
            item.Prefix(prefix);

            if (args.Player.IsLoggedIn)
            {
                args.Player.PlayerData.StoreSlot(slot, type, prefix, stack);
            }
            else if (Main.ServerSideCharacter && TShock.Config.DisableLoginBeforeJoin && !bypassTrashCanCheck &&
                args.Player.HasSentInventory && !args.Player.Group.HasPermission(Permissions.bypassssc))
            {
                // The player might have moved an item to their trash can before they performed a single login attempt yet.
                args.Player.IgnoreActionsForClearingTrashCan = true;
            }

            if (slot == 58) //this is the hand
            {
                item.stack = stack;
                args.Player.ItemInHand = item;
            }

            return false;
        }
开发者ID:CXUtk,项目名称:TShock,代码行数:49,代码来源:GetDataHandlers.cs

示例11: HandleItemDrop

        private static bool HandleItemDrop(GetDataHandlerArgs args)
        {
            var id = args.Data.ReadInt16();
            var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            var stacks = args.Data.ReadInt8();
            var prefix = args.Data.ReadInt8();
            var type = args.Data.ReadInt16();

            if (type == 0) //Item removed, let client do this to prevent item duplication client side
            {
                return false;
            }

            if (TShock.CheckRangePermission(args.Player, (int)(pos.X / 16f), (int)(pos.Y / 16f)))
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }

            Item item = new Item();
            item.netDefaults(type);
            if (stacks > item.maxStack || TShock.Itembans.ItemIsBanned(item.name, args.Player))
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }

            if (TShock.CheckIgnores(args.Player))
            {
                args.Player.SendData(PacketTypes.ItemDrop, "", id);
                return true;
            }

            return false;
        }
开发者ID:Icehawk78,项目名称:TShock,代码行数:36,代码来源:GetDataHandlers.cs

示例12: ItemIdSearch

 /* Search IDs */
 public static List<object> ItemIdSearch(string search)
 {
     try
     {
         var found = new List<object>();
         for (int i = -48; i < Main.maxItemTypes; i++)
         {
             Item item = new Item();
             item.netDefaults(i);
             if (item.name.ToLower().Contains(search.ToLower()))
                 found.Add(item);
         }
         return found;
     }
     catch { return new List<object>(); }
 }
开发者ID:Brunban2,项目名称:Essentials-SignCommands,代码行数:17,代码来源:esUtils.cs

示例13: GetData


//.........这里部分代码省略.........
                 if (text == "")
                 {
                     NetMessage.SendData(2, this.whoAmI, -1, "Empty name.", 0, 0f, 0f, 0f, 0);
                     return;
                 }
                 Netplay.serverSock[this.whoAmI].oldName = text;
                 Netplay.serverSock[this.whoAmI].name = text;
                 NetMessage.SendData(4, -1, this.whoAmI, text, num3, 0f, 0f, 0f, 0);
                 return;
             }
         }
         else
         {
             if (b == 5)
             {
                 int num5 = (int)this.readBuffer[start + 1];
                 if (Main.netMode == 2)
                 {
                     num5 = this.whoAmI;
                 }
                 if (num5 == Main.myPlayer && !Main.ServerSideCharacter)
                 {
                     return;
                 }
                 lock (Main.player[num5])
                 {
                     int num6 = (int)this.readBuffer[start + 2];
                     int stack = (int)BitConverter.ToInt16(this.readBuffer, start + 3);
                     byte b3 = this.readBuffer[start + 5];
                     int type = (int)BitConverter.ToInt16(this.readBuffer, start + 6);
                     if (num6 < 59)
                     {
                         Main.player[num5].inventory[num6] = new Item();
                         Main.player[num5].inventory[num6].netDefaults(type);
                         Main.player[num5].inventory[num6].stack = stack;
                         Main.player[num5].inventory[num6].Prefix((int)b3);
                         if (num5 == Main.myPlayer && num6 == 58)
                         {
                             Main.mouseItem = Main.player[num5].inventory[num6].Clone();
                         }
                     }
                     else if (num6 >= 75 && num6 <= 82)
                     {
                         int num7 = num6 - 58 - 17;
                         Main.player[num5].dye[num7] = new Item();
                         Main.player[num5].dye[num7].netDefaults(type);
                         Main.player[num5].dye[num7].stack = stack;
                         Main.player[num5].dye[num7].Prefix((int)b3);
                     }
                     else
                     {
                         Main.player[num5].armor[num6 - 58 - 1] = new Item();
                         Main.player[num5].armor[num6 - 58 - 1].netDefaults(type);
                         Main.player[num5].armor[num6 - 58 - 1].stack = stack;
                         Main.player[num5].armor[num6 - 58 - 1].Prefix((int)b3);
                     }
                     if (Main.netMode == 2 && num5 == this.whoAmI)
                     {
                         NetMessage.SendData(5, -1, this.whoAmI, "", num5, (float)num6, (float)b3, 0f, 0);
                     }
                     return;
                 }
             }
             if (b == 6)
             {
                 if (Main.netMode == 2)
开发者ID:Enerdy,项目名称:TerrariaAPI-Server,代码行数:67,代码来源:messageBuffer.cs

示例14: HackedInventory

        public static bool HackedInventory(TSPlayer player)
        {
            bool check = false;

            Item[] inventory = player.TPlayer.inventory;
            Item[] armor = player.TPlayer.armor;
            for (int i = 0; i < NetItem.maxNetInventory; i++)
            {
                if (i < 49)
                {
                    Item item = new Item();
                    if (inventory[i] != null && inventory[i].netID != 0)
                    {
                        item.netDefaults(inventory[i].netID);
                        item.Prefix(inventory[i].prefix);
                        item.AffixName();
                        if (inventory[i].stack > item.maxStack)
                        {
                            check = true;
                            player.SendMessage(
                                String.Format("Stack cheat detected. Remove item {0} ({1}) and then rejoin", item.name, inventory[i].stack),
                                Color.Cyan);
                        }
                    }
                }
                else
                {
                    Item item = new Item();
                    if (armor[i - 48] != null && armor[i - 48].netID != 0)
                    {
                        item.netDefaults(armor[i - 48].netID);
                        item.Prefix(armor[i - 48].prefix);
                        item.AffixName();
                        if (armor[i - 48].stack > item.maxStack)
                        {
                            check = true;
                            player.SendMessage(
                                String.Format("Stack cheat detected. Remove armor {0} ({1}) and then rejoin", item.name, armor[i - 48].stack),
                                Color.Cyan);
                        }
                    }
                }
            }

            return check;
        }
开发者ID:InanZen,项目名称:TShock,代码行数:46,代码来源:TShock.cs

示例15: ReadChest

 public static Chest ReadChest(this BinaryReader reader)
 {
     Chest chest = new Chest(false);
     chest.x = reader.ReadInt32();
     chest.y = reader.ReadInt32();
     chest.name = "World Chest";
     for (int l = 0; l < 40; l++)
     {
         Item item = new Item();
         int stack = reader.ReadInt16();
         if (stack > 0)
         {
             int netID = reader.ReadInt32();
             byte prefix = reader.ReadByte();
             item.netDefaults(netID);
             item.stack = stack;
             item.Prefix(prefix);
         }
         chest.item[l] = item;
     }            
     return chest;
 }
开发者ID:Marcus101RR,项目名称:WorldRegeneration,代码行数:22,代码来源:Utilities.cs


注:本文中的Terraria.Item.netDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。