public virtual void FromBytes(BinaryReader reader, IWorldAccessor resolver)
        {
            IsWildCard = reader.ReadBoolean();
            Type       = (EnumItemClass)reader.ReadInt32();
            Code       = new AssetLocation(reader.ReadString());
            Quantity   = reader.ReadInt32();
            if (!IsWildCard)
            {
                ResolvedItemstack = new ItemStack(reader, resolver);
            }

            IsTool             = reader.ReadBoolean();
            ToolDurabilityCost = reader.ReadInt32();

            bool haveVariants = reader.ReadBoolean();

            if (haveVariants)
            {
                AllowedVariants = new string[reader.ReadInt32()];
                for (int i = 0; i < AllowedVariants.Length; i++)
                {
                    AllowedVariants[i] = reader.ReadString();
                }
            }

            bool haveConsumedStack = reader.ReadBoolean();

            if (haveConsumedStack)
            {
                ReturnedStack = new JsonItemStack();
                ReturnedStack.FromBytes(reader, resolver.ClassRegistry);
                ReturnedStack.ResolvedItemstack.ResolveBlockOrItem(resolver);
            }
        }
Exemple #2
0
 public void FromBytes(BinaryReader reader, IClassRegistryAPI instancer)
 {
     Type              = (EnumTransitionType)reader.ReadUInt16();
     FreshHours        = NatFloat.createFromBytes(reader);
     TransitionHours   = NatFloat.createFromBytes(reader);
     TransitionedStack = new JsonItemStack();
     TransitionedStack.FromBytes(reader, instancer);
     TransitionRatio = reader.ReadSingle();
 }
Exemple #3
0
        /// <summary>
        /// Deserializes the alloy
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="resolver"></param>
        public void FromBytes(BinaryReader reader, IWorldAccessor resolver)
        {
            Ingredients = new MetalAlloyIngredient[reader.ReadInt32()];

            for (int i = 0; i < Ingredients.Length; i++)
            {
                Ingredients[i] = new MetalAlloyIngredient();
                Ingredients[i].FromBytes(reader, resolver.ClassRegistry);
                Ingredients[i].Resolve(resolver, "[FromBytes]");
            }

            Output = new JsonItemStack();
            Output.FromBytes(reader, resolver.ClassRegistry);
            Output.Resolve(resolver, "[FromBytes]");
        }
        /// <summary>
        /// Reads the blocks and items from the Json files and converts them to an array of tabs which contain those blocks and items.
        /// </summary>
        /// <param name="reader">The reader to read the json.</param>
        /// <param name="registry">The registry of blocks and items.</param>
        public void FromBytes(BinaryReader reader, IClassRegistryAPI registry)
        {
            Tabs = new string[reader.ReadInt32()];
            for (int i = 0; i < Tabs.Length; i++)
            {
                Tabs[i] = reader.ReadString();
            }

            Stacks = new JsonItemStack[reader.ReadInt32()];
            for (int i = 0; i < Stacks.Length; i++)
            {
                Stacks[i] = new JsonItemStack();
                Stacks[i].FromBytes(reader, registry);
            }
        }
Exemple #5
0
        /// <summary>
        /// Creates a deep copy of this object
        /// </summary>
        /// <returns></returns>
        public JsonItemStack Clone()
        {
            JsonItemStack stack = new JsonItemStack()
            {
                Code = Code.Clone(),
                ResolvedItemstack = ResolvedItemstack?.Clone(),
                StackSize         = StackSize,
                Type = Type,
            };

            if (Attributes != null)
            {
                stack.Attributes = Attributes.Clone();
            }

            return(stack);
        }
Exemple #6
0
        /// <summary>
        /// Deserializes the alloy
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="resolver"></param>
        public void FromBytes(BinaryReader reader, IWorldAccessor resolver)
        {
            Code        = reader.ReadString();
            Ingredients = new BarrelRecipeIngredient[reader.ReadInt32()];

            for (int i = 0; i < Ingredients.Length; i++)
            {
                Ingredients[i] = new BarrelRecipeIngredient();
                Ingredients[i].FromBytes(reader, resolver);
                Ingredients[i].Resolve(resolver, "Barrel Recipe (FromBytes)");
            }

            Output = new JsonItemStack();
            Output.FromBytes(reader, resolver.ClassRegistry);
            Output.Resolve(resolver, "Barrel Recipe (FromBytes)");

            SealHours = reader.ReadDouble();
        }
Exemple #7
0
        public override void FromBytes(BinaryReader reader, IClassRegistryAPI instancer)
        {
            base.FromBytes(reader, instancer);

            if (!reader.ReadBoolean())
            {
                ShapeElement = reader.ReadString();
            }

            if (!reader.ReadBoolean())
            {
                TextureMapping = new string[] { reader.ReadString(), reader.ReadString() };
            }

            if (!reader.ReadBoolean())
            {
                CookedStack = new JsonItemStack();
                CookedStack.FromBytes(reader, instancer);
            }
        }
        /// <summary>
        /// Deserializes the alloy
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="resolver"></param>
        public void FromBytes(BinaryReader reader, IWorldAccessor resolver)
        {
            Ingredient = new CraftingRecipeIngredient();
            RecipeId   = reader.ReadInt32();

            Ingredient.FromBytes(reader, resolver);

            int len = reader.ReadInt32();

            Pattern = new string[len][];
            for (int i = 0; i < Pattern.Length; i++)
            {
                Pattern[i] = reader.ReadStringArray();
            }

            Name = new AssetLocation(reader.ReadString());

            Output = new JsonItemStack();
            Output.FromBytes(reader, resolver.ClassRegistry);
            Output.Resolve(resolver, "[FromBytes]");
            GenVoxels();
        }