Use it to create a group of a same Item.
 private void Awake() {
     baseScript = GetComponent<SimpleObject>();
     if(drop == null) {
         ItemEntities.Init();
         drop = new ItemStack(ItemEntities.items.Values.First());
     }
 }
Beispiel #2
0
 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     coordinates += MathHelper.BlockFaceToCoordinates(face);
     var descriptor = world.GetBlockData(coordinates);
     LadderDirection direction;
     switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
     {
         case Direction.North:
             direction = LadderDirection.North;
             break;
         case Direction.South:
             direction = LadderDirection.South;
             break;
         case Direction.East:
             direction = LadderDirection.East;
             break;
         default:
             direction = LadderDirection.West;
             break;
     }
     descriptor.Metadata = (byte)direction;
     if (IsSupported(descriptor, user.Server, world))
     {
         world.SetBlockID(descriptor.Coordinates, BlockID);
         world.SetMetadata(descriptor.Coordinates, (byte)direction);
         item.Count--;
         user.Inventory[user.SelectedSlot] = item;
     }
 }
Beispiel #3
0
 public override bool GetDrop(ToolItem tool, out ItemStack[] drop)
 {
     drop = new ItemStack[0];
     if (tool is ShovelItem)
         drop = new[] { new ItemStack(new SnowballItem(), 1) };
     return tool is ShovelItem;
 }
Beispiel #4
0
 public override void Click(Entity entity, ItemStack item)
 {
     if (!(entity is PlayerEntity))
     {
         return; // TODO: non-player support?
     }
     PlayerEntity player = (PlayerEntity)entity;
     if (player.Manipulator_Grabbed != null)
     {
         return;
     }
     Location eye = player.GetEyePosition();
     CollisionResult cr = player.TheRegion.Collision.RayTrace(eye, eye + player.ForwardVector() * 50, player.IgnoreThis);
     if (!cr.Hit || cr.HitEnt == null || cr.HitEnt.Mass <= 0)
     {
         return;
     }
     PhysicsEntity target = (PhysicsEntity)cr.HitEnt.Tag;
     player.Manipulator_Grabbed = target;
     player.Manipulator_Distance = (double)(eye - target.GetPosition()).Length();
     player.Manipulator_Beam = new ConnectorBeam() { type = BeamType.MULTICURVE };
     player.Manipulator_Beam.One = player;
     player.Manipulator_Beam.Two = target;
     player.Manipulator_Beam.color = Colors.BLUE;
     player.TheRegion.AddJoint(player.Manipulator_Beam);
 }
 public override void Click(Entity entity, ItemStack item)
 {
     // TODO: Should non-players be allowed here?
     if (!(entity is PlayerEntity))
     {
         return;
     }
     PlayerEntity player = (PlayerEntity)entity;
     // TODO: Generic 'player.gettargetblock'?
     Location eye = player.GetEyePosition();
     Location forw = player.ForwardVector();
     RayCastResult rcr;
     bool h = player.TheRegion.SpecialCaseRayTrace(eye, forw, 5, MaterialSolidity.ANY, player.IgnoreThis, out rcr);
     if (h)
     {
         if (rcr.HitObject != null && rcr.HitObject is EntityCollidable && ((EntityCollidable)rcr.HitObject).Entity != null)
         {
             // TODO: ???
         }
         else
         {
             Location block = (new Location(rcr.HitData.Location) - new Location(rcr.HitData.Normal).Normalize() * 0.01).GetBlockLocation();
             Material mat = player.TheRegion.GetBlockMaterial(block);
             if (mat != Material.AIR)
             {
                 player.Selection = new AABB() { Min = block, Max = block + Location.One };
                 player.NetworkSelection();
             }
         }
     }
 }
Beispiel #6
0
 public override void ReleaseAltClick(Entity entity, ItemStack item)
 {
     // TODO: Handle non-players
     if (!(entity is PlayerEntity))
     {
         return;
     }
     PlayerEntity player = (PlayerEntity)entity;
     if (player.TheRegion.GlobalTickTime - player.LastGunShot < fireRate)
     {
         return;
     }
     player.LastGunShot = player.TheRegion.GlobalTickTime;
     for (int i = 1; i < player.Breadcrumbs.Count; i++)
     {
         if ((player.GetPosition() - player.Breadcrumbs[i]).LengthSquared() < 4)
         {
             player.Breadcrumbs.RemoveRange(i, player.Breadcrumbs.Count - i);
         }
     }
     List<Location> locs = new List<Location>();
     Location cpos = player.GetPosition();
     for (int i = player.Breadcrumbs.Count - 1; i >= 0; i--)
     {
         if ((player.Breadcrumbs[i] - cpos).LengthSquared() > MaxRadius * MaxRadius)
         {
             break;
         }
         locs.Add(player.Breadcrumbs[i]);
     }
     if (locs.Count > 0)
     {
         player.Network.SendPacket(new PathPacketOut(locs));
     }
 }
Beispiel #7
0
 public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k,
     int l)
 {
     if (l == 0)
     {
         return false;
     }
     if (l == 1)
     {
         return false;
     }
     byte byte0 = 0;
     if (l == 4)
     {
         byte0 = 1;
     }
     if (l == 3)
     {
         byte0 = 2;
     }
     if (l == 5)
     {
         byte0 = 3;
     }
     var entitypainting = new EntityPainting(world, i, j, k, byte0);
     if (entitypainting.onValidSurface())
     {
         if (!world.singleplayerWorld)
         {
             world.entityJoinedWorld(entitypainting);
         }
         itemstack.stackSize--;
     }
     return true;
 }
Beispiel #8
0
 public void Split(ItemStack stack) {
     var nStack = stack.Split();
     if (nStack != null) {
         if (!AddNewStack(nStack))
             DropStack(nStack);
     }
 }
Beispiel #9
0
 public ItemEntity(Vector3 position, ItemStack item)
 {
     Position = position;
     Item = item;
     if (item.Empty)
         Despawned = true;
 }
Beispiel #10
0
 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     var bottom = coordinates + MathHelper.BlockFaceToCoordinates(face);
     var top = bottom + Coordinates3D.Up;
     if (world.GetBlockID(top) != 0 || world.GetBlockID(bottom) != 0)
         return;
     DoorFlags direction;
     switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
     {
         case Direction.North:
             direction = DoorFlags.Northwest;
             break;
         case Direction.South:
             direction = DoorFlags.Southeast;
             break;
         case Direction.East:
             direction = DoorFlags.Northeast;
             break;
         default: // Direction.West:
             direction = DoorFlags.Southwest;
             break;
     }
     user.Server.BlockUpdatesEnabled = false;
     world.SetBlockID(bottom, BlockID);
     world.SetMetadata(bottom, (byte)direction);
     world.SetBlockID(top, BlockID);
     world.SetMetadata(top, (byte)(direction | DoorFlags.Upper));
     user.Server.BlockUpdatesEnabled = true;
     item.Count--;
     user.Inventory[user.SelectedSlot] = item;
 }
Beispiel #11
0
 public override void Click(Entity entity, ItemStack item)
 {
     if (!(entity is CharacterEntity))
     {
         // TODO: Non-character support?
         return;
     }
     CharacterEntity character = (CharacterEntity)entity;
     double range = RangeBase * item.GetAttributeF("range_mod", 1f);
     double strength = StrengthBase * item.GetAttributeF("strength_mod", 1f) * GetStrength();
     Location start = character.GetEyePosition(); // TODO: ItemPosition?
     Location forw = character.ForwardVector();
     Location mid = start + forw * range;
     // TODO: base the pull on extent of the entity rather than its center. IE, if the side of a big ent is targeted, it should be rotated by the force.
     List<Entity> ents = character.TheRegion.GetEntitiesInRadius(mid, range);
     foreach (Entity ent in ents)
     {
         if (ent is PhysicsEntity) // TODO: Support for primitive ents?
         {
             PhysicsEntity pent = (PhysicsEntity)ent;
             Location rel = (start - ent.GetPosition());
             double distsq = rel.LengthSquared();
             if (distsq < 1)
             {
                 distsq = 1;
             }
             pent.ApplyForce((rel / distsq) * strength);
         }
     }
 }
Beispiel #12
0
    public static void addToInventory(int itemID, string pathToIcon)
    {
        itemHUD_Controls hud = GameObject.Find ("ItemHUD").GetComponent<itemHUD_Controls>();

        for(int i = 0; i < maxInventorySize; i++) {
            if(inv[i] == null) {
                inv[i] = new ItemStack(itemID, pathToIcon);

                //Update Icon in Inventory HUD
                hud.items[i].GetComponent<Image> ().sprite = Resources.Load<Sprite> (pathToIcon);
                hud.items[i].GetComponent<Image> ().color = new Color32(255, 255, 255, 255);
                inv[i].incrementStack();
                //Update stack counter
                hud.items[i].GetComponentInChildren<Text>().text = getSlotStackSize(i).ToString();
                Resources.UnloadUnusedAssets();

                break;
            } else {
                if(inv[i].getItemID() == itemID && !inv[i].checkStackFull()) {
                    inv[i].incrementStack();
                    hud.items[i].GetComponentInChildren<Text>().text = getSlotStackSize(i).ToString();
                    break;
                }
            }
        }
    }
Beispiel #13
0
 public void AddPart(ItemStack IS)
 {
     if (!Parts.Contains(IS))
     {
         Parts.Add(IS);
     }
 }
Beispiel #14
0
 public ItemFrameEntity(ItemStack item, ItemFrameDirection direction, Vector3 position)
 {
     Item = item;
     Position = position;
     Direction = direction;
     Pitch = GetRotation(Direction); // This should be Pitch, but it doesn't work. Not sure why.
 }
Beispiel #15
0
 public override void Click(Entity entity, ItemStack item)
 {
     if (!(entity is PlayerEntity))
     {
         // TODO: non-player support
         return;
     }
     PlayerEntity player = (PlayerEntity)entity;
     Location eye = player.GetEyePosition();
     Location forw = player.ForwardVector();
     RayCastResult rcr;
     bool h = player.TheRegion.SpecialCaseRayTrace(eye, forw, 5, MaterialSolidity.ANY, player.IgnoreThis, out rcr);
     if (h)
     {
         if (rcr.HitObject != null && rcr.HitObject is EntityCollidable && ((EntityCollidable)rcr.HitObject).Entity != null)
         {
             // TODO: ???
         }
         else if (player.Mode.GetDetails().CanPlace)
         {
             Location block = (new Location(rcr.HitData.Location) - new Location(rcr.HitData.Normal).Normalize() * 0.01).GetBlockLocation();
             block = block.GetBlockLocation();
             BlockInternal blockdat = player.TheRegion.GetBlockInternal(block);
             Material mat = (Material)blockdat.BlockMaterial;
             if (mat != Material.AIR)
             {
                 int paint = item.Datum;
                 player.TheRegion.SetBlockMaterial(block, mat, blockdat.BlockData, (byte)paint, (byte)(blockdat.BlockLocalData | (byte)BlockFlags.EDITED), blockdat.Damage);
             }
         }
     }
 }
    // Use this for initialization
    void Start()
    {
        _descriptors = new ItemDescriptors();
        _descriptors.Initialize();

        // TODO: Hook Descriptors

        StorageContainer sc = new StorageContainer();
        Storage s = (Storage)_descriptors.Find("Backpack").Create();

        // Add the Storage to our StorageContainer
        sc.Storages.Add(s);

        ItemStack stack = new ItemStack(_descriptors.Find("Whiskey Bottle"), s);
        stack.AddQuantity(80);
        // Automatically add the Stack to the first available storage of the Container.
        sc.AddStack(stack);

        stack = new ItemStack(_descriptors.Find("Botan"));
        stack.AddQuantity(1);
        // Automatically add the Stack to the first available storage of the Container.
        sc.AddStack(stack);

        foreach (IStorage storage in sc.Storages)
        {
            string msg = "";
            msg += "Total Storage weight: " + storage.Weight / 1000.0f + "kg, Content Weight: " + System.Math.Round(storage.ContentWeight / 1000.0f, 2) + "/" + storage.Capacity / 1000.0f + "kg\n";
            foreach (IItemStack itemStack in storage.Stacks)
            {
                msg += itemStack.Quantity + "x " + itemStack.Descriptor.Name + " (" + itemStack.Weight / 1000.0f + "kg)\n";
            }
            Debug.Log(msg);
        }
    }
Beispiel #17
0
 protected override ItemStack[] GetDrop(BlockDescriptor descriptor, ItemStack item)
 {
     if (descriptor.Metadata >= 7)
         return new[] { new ItemStack(WheatItem.ItemID), new ItemStack(SeedsItem.ItemID, (sbyte)MathHelper.Random.Next(3)) };
     else
         return new[] { new ItemStack(SeedsItem.ItemID) };
 }
Beispiel #18
0
 public void InitItem(ItemStack itemStack) {
     GetComponent<Image>().sprite = itemStack.TypeItem.Icon;
     Count.text = itemStack.Count.ToString();
     currentItemStack = itemStack;
     itemStack.OnChangeCount += ChangeCount;
     itemStack.OnNullCount += Delete;
 }
        public BinderItem(ItemValue itemValue)
        {
            bindItemData(DataItem.getItemDataByItemValue(itemValue));

            itemStack = createItemStack(DataItem.getItemDataByItemValue(itemValue), itemValue);
            bindItemValue(itemValue);
        }
Beispiel #20
0
 protected internal virtual int MoveOrMergeItem(int index, ItemStack item, WindowArea from)
 {
     int emptyIndex = -1;
     for (int i = 0; i < Length; i++)
     {
         if (this[i].Empty && emptyIndex == -1)
             emptyIndex = i;
         else if (this[i].Id == item.Id &&
             this[i].Metadata == item.Metadata &&
             this[i].Count < item.AsItem().MaximumStack)
         {
             // Merging takes precedence over empty slots
             emptyIndex = -1;
             if (from != null)
                 from[index] = ItemStack.EmptyStack;
             if (this[i].Count + item.Count > item.AsItem().MaximumStack)
             {
                 item = new ItemStack(item.Id, (sbyte)(item.Count - (item.AsItem().MaximumStack - this[i].Count)),
                     item.Metadata, item.Nbt);
                 this[i] = new ItemStack(item.Id, (sbyte)item.AsItem().MaximumStack, item.Metadata, item.Nbt);
                 continue;
             }
             this[i] = new ItemStack(item.Id, (sbyte)(this[i].Count + item.Count), item.Metadata);
             return i;
         }
     }
     if (emptyIndex != -1)
     {
         if (from != null)
             from[index] = ItemStack.EmptyStack;
         this[emptyIndex] = item;
     }
     return emptyIndex;
 }
Beispiel #21
0
        public void GenerateDropEntity(BlockDescriptor descriptor, IWorld world, IMultiplayerServer server, ItemStack item)
        {
            var entityManager = server.GetEntityManagerForWorld(world);
            var items = new ItemStack[0];
            var type = ToolType.None;
            var material = ToolMaterial.None;
            var held = ItemRepository.GetItemProvider(item.ID);

            if (held is ToolItem)
            {
                var tool = held as ToolItem;
                material = tool.Material;
                type = tool.ToolType;
            }

            if ((EffectiveTools & type) > 0)
            {
                if ((EffectiveToolMaterials & material) > 0)
                    items = GetDrop(descriptor, item);
            }

            foreach (var i in items)
            {
                if (i.Empty) continue;
                var entity = new ItemEntity(new Vector3(descriptor.Coordinates) + new Vector3(0.5), i);
                entityManager.SpawnEntity(entity);
            }
        }
Beispiel #22
0
        public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
        {
            if (face == BlockFace.PositiveY || face == BlockFace.NegativeY)
            {
                // Trapdoors are not placed when the user clicks on the top or bottom of a block
                return;
            }

            // NOTE: These directions are rotated by 90 degrees so that the hinge of the trapdoor is placed
            // where the user had their cursor.
            switch (face)
            {
                case BlockFace.NegativeZ:
                    item.Metadata = (byte)TrapdoorDirection.West;
                    break;
                case BlockFace.PositiveZ:
                    item.Metadata = (byte)TrapdoorDirection.East;
                    break;
                case BlockFace.NegativeX:
                    item.Metadata = (byte)TrapdoorDirection.South;
                    break;
                case BlockFace.PositiveX:
                    item.Metadata = (byte)TrapdoorDirection.North;
                    break;
                default:
                    return;
            }

            base.ItemUsedOnBlock(coordinates, item, face, world, user);
        }
Beispiel #23
0
 protected override ItemStack[] GetDrop(BlockDescriptor descriptor, ItemStack item)
 {
     //Gravel has a 10% chance of dropping flint.
     if (MathHelper.Random.Next(10) == 0)
         return new[] { new ItemStack(FlintItem.ItemID, 1, descriptor.Metadata) };
     else
         return new ItemStack[0];
 }
Beispiel #24
0
 protected override ItemStack[] GetDrop(BlockDescriptor descriptor, ItemStack item)
 {
     var provider = ItemRepository.GetItemProvider(item.ID);
     if (provider is PickaxeItem)
         return new[] { new ItemStack(CobblestoneBlock.BlockID, 1, descriptor.Metadata) };
     else
         return new ItemStack[0];
 }
Beispiel #25
0
 public WindowArea(int startIndex, int length)
 {
     StartIndex = startIndex;
     Length = length;
     Items = new ItemStack[Length];
     for (int i = 0; i < Items.Length; i++)
         Items[i] = ItemStack.EmptyStack;
 }
Beispiel #26
0
 public void Init(ItemStack stack)
 {
     this.stack = stack;
     Image image = transform.FindChild ("Content/Image").GetComponent<Image>();
     Text name = transform.FindChild ("Content/Name").GetComponent<Text> ();
     image.sprite = Resources.Load<Sprite> ("Texture/Item/"+ stack.item.info.id);
     name.text = stack.item.info.name;
 }
 public ServerEntityDroppedItem(int x, int y, Vector2 velocity, ItemStack stack, short id)
 {
     ServerItem i = ServerItem.GetItem(stack.ItemID);
     EntityPosition = new Vector2(x, y);
     Stack = stack;
     DroppedItemID = id;
     EntityVelocity = velocity;
 }
        public IPacket ReadPacket(IMinecraftDataReader reader)
        {
            WindowId = reader.ReadSByte();
            Slot = reader.ReadShort();
            SlotData = ItemStack.FromReader(reader);

            return this;
        }
        public IPacket ReadPacket(IMinecraftDataReader reader)
        {
            EntityID = reader.ReadVarInt();
            Slot = (EntityEquipmentSlot) reader.ReadShort();
            Item = ItemStack.FromReader(reader);

            return this;
        }
        public BinderItem(DataItem itemData)
        {
            bindItemData(itemData);

            itemValue = new ItemValue();
            populateItemValue(itemValue, itemData);
            itemStack = createItemStack(itemData, itemValue);
        }
Beispiel #31
0
        public override bool DoPlaceBlock(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel, ItemStack byItemStack, ref EnumHandling handling)
        {
            if (world is IServerWorldAccessor)
            {
                world.RegisterCallbackUnique(OnDelayedWaterUpdateCheck, blockSel.Position, spreadDelay);
            }

            return(base.DoPlaceBlock(world, byPlayer, blockSel, byItemStack, ref handling));
        }
Beispiel #32
0
        protected virtual void dropOffToConveyors()
        {
            bool ignore;
            List <ConveyorEntity> list = VicisMod.checkSurrounding <ConveyorEntity>(this, out ignore);

            VicisMod.log(getPrefix(), "Found " + list.Count + " ConveyorEntities");
            string msg = items.Count + ": ";

            foreach (ItemBase it in items)
            {
                msg += it.GetDisplayString() + ", ";
            }
            VicisMod.log(getPrefix(), "Currently storing " + msg);
            for (int i = 0; i < list.Count && items.Count > 0; ++i)
            {
                ConveyorEntity c = list[i] as ConveyorEntity;
                if (!isConveyorNotFacingMe(c))
                {
                    VicisMod.log(getPrefix(), "Conveyor is either not facing somewhere else: " + isConveyorNotFacingMe(c));
                    continue;
                }
                if (c.mbReadyToConvey && c.mrLockTimer == 0f)
                {
                    VicisMod.log(getPrefix(), "Ready to convey, will be giving " + items[0].GetDisplayString() + ", a " + items[0].mType);
                    if (items[0].mType == ItemType.ItemCubeStack)
                    {
                        ItemCubeStack a = items[0] as ItemCubeStack;
                        c.AddCube(a.mCubeType, a.mCubeValue, 1);
                        c.mItemForwards = forwards;
                        --a.mnAmount;
                        if (a.mnAmount == 0)
                        {
                            VicisMod.log(getPrefix(), "Removing cube " + a.GetDisplayString() + " from items list");
                            items.RemoveAt(0);
                        }
                    }
                    else if (items[0].mType == ItemType.ItemStack)
                    {
                        ItemStack a = Util.ItemBaseUtil.newInstance(items[0]) as ItemStack;
                        a.mnAmount = 1;
                        Util.ItemBaseUtil.decrementStack(items[0], 1);
                        c.AddItem(a);
                        c.mItemForwards = forwards;
                        if (Util.ItemBaseUtil.getAmount(items[0]) == 0)
                        {
                            VicisMod.log(getPrefix(), "Removing item " + a.GetDisplayString() + " from items list");
                            items.RemoveAt(0);
                        }
                    }
                    else
                    {
                        c.AddItem(items[0]);
                        c.mrCarryTimer       = 1f;
                        c.mrVisualCarryTimer = 1f;
                        c.mItemForwards      = forwards;
                        items.RemoveAt(0);
                    }
                }
                else
                {
                    VicisMod.log(getPrefix(), "Conveyor is not ready to convey");
                }
            }
        }
Beispiel #33
0
        public ItemStack ApplyModifier(Plant plant, ItemStack item, User user)
        {
            var newQuantity = item.Quantity * (plant.Tended ? 1 : this.Value);

            return(new ItemStack(item.Item, (int)newQuantity));
        }
Beispiel #34
0
        public void FloodFillAt(WorldEdit worldEdit, Block blockToPlace, ItemStack withItemStack, int posX, int posY, int posZ)
        {
            bfsQueue.Clear();
            fillablePositions.Clear();


            if (posY <= 0 || posY >= mapheight - 1)
            {
                return;
            }

            bfsQueue.Enqueue(new Vec4i(posX, posY, posZ, 0));
            fillablePositions.Add(new BlockPos(posX, posY, posZ));

            float radius = SearchRadius;

            int repl = blockToPlace.Id == 0 ? 0 : ReplaceableLevel;

            BlockFacing[] faces = Mode == 2 ? BlockFacing.HORIZONTALS : BlockFacing.ALLFACES;
            if (Mode == 1)
            {
                faces = BlockFacing.HORIZONTALS.Append(BlockFacing.DOWN);
            }

            BlockPos curPos = new BlockPos();

            while (bfsQueue.Count > 0)
            {
                Vec4i bpos = bfsQueue.Dequeue();

                foreach (BlockFacing facing in faces)
                {
                    curPos.Set(bpos.X + facing.Normali.X, bpos.Y + facing.Normali.Y, bpos.Z + facing.Normali.Z);

                    Block block    = blockAccessRev.GetBlock(curPos);
                    bool  inBounds = bpos.W < radius;

                    if (inBounds)
                    {
                        if ((block.Replaceable >= repl || block.BlockMaterial == EnumBlockMaterial.Plant) && !fillablePositions.Contains(curPos))
                        {
                            bfsQueue.Enqueue(new Vec4i(curPos.X, curPos.Y, curPos.Z, bpos.W + 1));
                            fillablePositions.Add(curPos.Copy());
                        }
                    }
                    else
                    {
                        if (CheckEnclosure)
                        {
                            fillablePositions.Clear();
                            bfsQueue.Clear();
                            worldEdit.Bad("Cannot flood fill here, not enclosed area. Enforce enclosed area or disable enclosure check.");
                            break;
                        }
                    }
                }
            }

            foreach (BlockPos p in fillablePositions)
            {
                blockAccessRev.SetBlock(blockToPlace.BlockId, p, withItemStack);
            }

            worldEdit.Bad(fillablePositions.Count + " blocks placed");
        }
 public void OpenEquipmentEquip(ItemStack stack)
 {
     equipment.Setup(Player.player.equipment, ItemAction.EQUIP, stack);
     equipment.Activate();
 }
Beispiel #36
0
 void RemoveItem(ItemStack item)
 {
     currentInventory.Remove(item.Item, item.Amount);
 }
        public Sea_pickleBlock() : base()
        {
            PossibleStates = new BlockState[]
            {
                new BlockState(8466, new Dictionary <string, string>
                {
                    { "pickles", "1" },

                    { "waterlogged", "true" },
                }),

                new BlockState(8467, new Dictionary <string, string>
                {
                    { "pickles", "1" },

                    { "waterlogged", "false" },
                }),

                new BlockState(8468, new Dictionary <string, string>
                {
                    { "pickles", "2" },

                    { "waterlogged", "true" },
                }),

                new BlockState(8469, new Dictionary <string, string>
                {
                    { "pickles", "2" },

                    { "waterlogged", "false" },
                }),

                new BlockState(8470, new Dictionary <string, string>
                {
                    { "pickles", "3" },

                    { "waterlogged", "true" },
                }),

                new BlockState(8471, new Dictionary <string, string>
                {
                    { "pickles", "3" },

                    { "waterlogged", "false" },
                }),

                new BlockState(8472, new Dictionary <string, string>
                {
                    { "pickles", "4" },

                    { "waterlogged", "true" },
                }),

                new BlockState(8473, new Dictionary <string, string>
                {
                    { "pickles", "4" },

                    { "waterlogged", "false" },
                }),
            };
            State = PossibleStates[0];

            Drops = new ItemStack[] { new Sea_pickleItem() };
        }
Beispiel #38
0
 public virtual bool PickUpStack(ItemStack slot)
 {
     throw new NotSupportedException();
 }
Beispiel #39
0
 public void AddItem(ItemStack i)
 {
     _Inventory.AddItem(i);
 }
Beispiel #40
0
 public override string GetHeldItemName(ItemStack itemStack)
 {
     return(base.GetHeldItemName(itemStack));
 }
Beispiel #41
0
 public ItemStack GetBaseMaterial(ItemStack stack)
 {
     return(stack);
 }
Beispiel #42
0
 public void EquipItemEventRaised(ItemStack item)
 {
     throw new NotImplementedException();
 }
Beispiel #43
0
 public void UseItemEventRaised(ItemStack item)
 {
     RemoveItem(item);
 }
Beispiel #44
0
 // Setter of type ItemStack for setting the current selected item stack
 public void SetSelectedStack(ItemStack oStack)
 {
     m_oCurrentStack = oStack;
 }
Beispiel #45
0
 void AddItem(ItemStack item)
 {
     currentInventory.Add(item.Item, item.Amount);
 }
Beispiel #46
0
 public override void OnBuild(WorldEdit worldEdit, int oldBlockId, BlockSelection blockSel, ItemStack withItemStack)
 {
     ApplyTool(worldEdit, blockSel.Position, oldBlockId, blockSel.Face, withItemStack);
 }
Beispiel #47
0
 /// <summary>
 /// When shift-clicking items between areas, this method is used
 /// to determine which area links to which.
 /// </summary>
 /// <param name="index">The index of the area the item is coming from</param>
 /// <param name="slot">The item being moved</param>
 /// <returns>The area to place the item into</returns>
 protected abstract IWindowArea GetLinkedArea(int index, ItemStack slot);
Beispiel #48
0
        private void ApplyTool(WorldEdit worldEdit, BlockPos pos, int oldBlockId, BlockFacing onBlockFace, ItemStack withItemstack, bool remove = false)
        {
            mapheight = worldEdit.sapi.WorldManager.MapSizeY;

            Block block = blockAccessRev.GetBlock(pos);

            if (oldBlockId >= 0)
            {
                worldEdit.sapi.World.BlockAccessor.SetBlock(oldBlockId, pos);
            }
            else
            {
                block = worldEdit.sapi.World.GetBlock(0);
            }

            FloodFillAt(worldEdit, block, withItemstack, pos.X, pos.Y, pos.Z);

            blockAccessRev.Commit();
        }
Beispiel #49
0
        public Blue_bedBlock() : base()
        {
            PossibleStates = new BlockState[]
            {
                new BlockState(906, new Dictionary <string, string>
                {
                    { "facing", "north" },

                    { "occupied", "true" },

                    { "part", "head" },
                }),

                new BlockState(907, new Dictionary <string, string>
                {
                    { "facing", "north" },

                    { "occupied", "true" },

                    { "part", "foot" },
                }),

                new BlockState(908, new Dictionary <string, string>
                {
                    { "facing", "north" },

                    { "occupied", "false" },

                    { "part", "head" },
                }),

                new BlockState(909, new Dictionary <string, string>
                {
                    { "facing", "north" },

                    { "occupied", "false" },

                    { "part", "foot" },
                }),

                new BlockState(910, new Dictionary <string, string>
                {
                    { "facing", "east" },

                    { "occupied", "true" },

                    { "part", "head" },
                }),

                new BlockState(911, new Dictionary <string, string>
                {
                    { "facing", "east" },

                    { "occupied", "true" },

                    { "part", "foot" },
                }),

                new BlockState(912, new Dictionary <string, string>
                {
                    { "facing", "east" },

                    { "occupied", "false" },

                    { "part", "head" },
                }),

                new BlockState(913, new Dictionary <string, string>
                {
                    { "facing", "east" },

                    { "occupied", "false" },

                    { "part", "foot" },
                }),

                new BlockState(914, new Dictionary <string, string>
                {
                    { "facing", "south" },

                    { "occupied", "true" },

                    { "part", "head" },
                }),

                new BlockState(915, new Dictionary <string, string>
                {
                    { "facing", "south" },

                    { "occupied", "true" },

                    { "part", "foot" },
                }),

                new BlockState(916, new Dictionary <string, string>
                {
                    { "facing", "south" },

                    { "occupied", "false" },

                    { "part", "head" },
                }),

                new BlockState(917, new Dictionary <string, string>
                {
                    { "facing", "south" },

                    { "occupied", "false" },

                    { "part", "foot" },
                }),

                new BlockState(918, new Dictionary <string, string>
                {
                    { "facing", "west" },

                    { "occupied", "true" },

                    { "part", "head" },
                }),

                new BlockState(919, new Dictionary <string, string>
                {
                    { "facing", "west" },

                    { "occupied", "true" },

                    { "part", "foot" },
                }),

                new BlockState(920, new Dictionary <string, string>
                {
                    { "facing", "west" },

                    { "occupied", "false" },

                    { "part", "head" },
                }),

                new BlockState(921, new Dictionary <string, string>
                {
                    { "facing", "west" },

                    { "occupied", "false" },

                    { "part", "foot" },
                }),
            };
            State = PossibleStates[3];

            Drops = new ItemStack[] { new Blue_bedItem() };
        }
        public static void mint(User user, string action = "", string param = "", string arg = "")
        {
            /*
             *      config[ "mint_daily" ] = mint_daily;
             *      config[ "mint_max_per_day" ] = mint_max_per_day;
             */

            Currency astr = EconomyManager.Currency.GetCurrency("Astrum");

            switch (action)
            {
            case "status":
                string white  = "#FFFFFF";
                string green  = "#44FF44";
                string yellow = "#FFFF44";
                string orange = "#FFCC44";
                string red    = "#FF4444";

                string status = "<b>Mint Status Report</b>";
                status += "<br> <color=#44FF44>*</color> <i>Mint Pool:</i>  <b>";

                if ((int)astr.GetAccount(" _MintPool").Val >= 8000)
                {
                    status += "<color=" + green + ">" + (int)astr.GetAccount(" _MintPool").Val + "</color></b>";
                }
                else if ((int)astr.GetAccount(" _MintPool").Val >= 4000)
                {
                    status += "<color=" + yellow + ">" + (int)astr.GetAccount(" _MintPool").Val + "</color></b>";
                }
                else if ((int)astr.GetAccount(" _MintPool").Val >= 2000)
                {
                    status += "<color=" + orange + ">" + (int)astr.GetAccount(" _MintPool").Val + "</color></b>";
                }
                else
                {
                    status += "<color=" + red + ">" + (int)astr.GetAccount(" _MintPool").Val + "</color></b>";
                }

                status += "<br> <color=#44FF44>*</color> <i>Treasury Balance:</i>  <b>";
                if ((int)astr.GetAccount(" _Treasury").Val >= 1500)
                {
                    status += "<color=" + green + ">" + (int)astr.GetAccount(" _Treasury").Val + "</color></b>";
                }
                else if ((int)astr.GetAccount(" _Treasury").Val >= 1000)
                {
                    status += "<color=" + yellow + ">" + (int)astr.GetAccount(" _Treasury").Val + "</color></b>";
                }
                else if ((int)astr.GetAccount(" _Treasury").Val >= 500)
                {
                    status += "<color=" + orange + ">" + (int)astr.GetAccount(" _Treasury").Val + "</color></b>";
                }
                else
                {
                    status += "<color=" + red + ">" + (int)astr.GetAccount(" _Treasury").Val + "</color></b>";
                }

                status += "<br><br> <color=#44FF44>*</color> <i>Max Minted/Day:</i>  <b>";
                status += "<color=" + white + ">" + config["mint_max_per_day"] + "</color></b>";
                status += "<br> <color=#44FF44>*</color> <i>Minted Today:</i>  - <b>";
                status += "<color=" + white + ">" + minted_today + "</color></b>";

                status += "<br> <color=#44FF44>*</color> <i>Available " + astr.UILink() + " Today:</i>  <b>";

                if ((config["mint_max_per_day"] - minted_today) >= (config["mint_max_per_day"] * 0.75))
                {
                    status += "<color=" + green + ">" + (config["mint_max_per_day"] - minted_today) + "</color></b>";
                }
                else if ((config["mint_max_per_day"] - minted_today) >= (config["mint_max_per_day"] * 0.5))
                {
                    status += "<color=" + yellow + ">" + (config["mint_max_per_day"] - minted_today) + "</color></b>";
                }
                else if ((config["mint_max_per_day"] - minted_today) >= (config["mint_max_per_day"] * 0.25))
                {
                    status += "<color=" + orange + ">" + (config["mint_max_per_day"] - minted_today) + "</color></b>";
                }
                else
                {
                    status += "<color=" + red + ">" + minted_today + "</color></b>";
                }

                send_pm(status, user.Player, ChatCategory.Default, DefaultChatTags.Government);
                break;

            case "init":
                if (UserManager.IsAdmin(user))
                {
                    if (param != "")
                    {
                        if (astr.GetAccount(" _MintPool").Val == 0)
                        {
                            astr.GetAccount(" _MintPool").Val += int.Parse(param);
                            astr.GetAccount(user.Name).Val    -= int.Parse(param);

                            send_msg(
                                "<color=#88FF44>NOTICE:</color> " +
                                "<color=#AAFF44>" + arg + "</color> <color=#44FF44>" + astr.UILink() + " " +
                                "added to the mint pool, <color=#AAFF44>(PoolBalance: " +
                                astr.GetAccount(" _MintPool").Val + ").</color>",
                                ChatCategory.Default, DefaultChatTags.Government
                                );

                            // save config
                            save_config();
                        }
                        else
                        {
                            send_pm(
                                "<color=#FF6666>ERROR:</color> " +
                                "<color=#FF4444>The mint pool has a non-zero balance, " +
                                "you most likely meant to do <color=#FF6666>/mint add, [number]</color>",
                                user.Player, ChatCategory.Default, DefaultChatTags.Government
                                );
                        }
                    }
                    else
                    {
                        send_pm(
                            "<color=#FF6666>ERROR:</color> " +
                            "<color=#FF4444>You must initialize the mint pool with an integer value.</color>",
                            user.Player, ChatCategory.Default, DefaultChatTags.Government
                            );
                    }
                }
                break;

            case "add":
                if (UserManager.IsAdmin(user))
                {
                    if (param != "")
                    {
                        astr.GetAccount(" _MintPool").Val += int.Parse(param);
                        astr.GetAccount(user.Name).Val    -= int.Parse(param);

                        send_msg(
                            "<color=#88FF44>NOTICE:</color> " +
                            "<color=#AAFF44>" + arg + "</color> <color=#44FF44>" + astr.UILink() + " " +
                            "added to the mint pool. <color=#AAFF44>New balance: " +
                            astr.GetAccount(" _MintPool").Val + "</color>",
                            ChatCategory.Default, DefaultChatTags.Government
                            );

                        // save config
                        save_config();
                    }
                    else
                    {
                        send_pm(
                            "<color=#FF6666>ERROR:</color> " +
                            "<color=#FF4444>You must initialize the mint pool with an integer value.</color>",
                            user.Player, ChatCategory.Default, DefaultChatTags.Government
                            );
                    }
                }
                break;

            case "set":
                if (UserManager.IsAdmin(user))
                {
                    if (param == "mint_daily" || param == "mint_max_per_day")
                    {
                        config[param] = int.Parse(arg);
                        send_pm(
                            "<color=#44FF44>NOTE: " + param + " set to " + config[param] + ".</color>",
                            user.Player, ChatCategory.Default, DefaultChatTags.Government
                            );

                        // save config
                        save_config();
                    }
                }
                break;

            default:
                // load config
                //load_config();

                if (minting.ContainsKey(user.Name))
                {
                    //DateTime last = minting[user.Name];
                    //DateTime now = new DateTime();

                    //TimeSpan t = last - now;
                    //int delta = (24 - (int) t.TotalHours);

                    //if (delta > 0) {

                    /*
                     * send_pm(
                     *      "<color=#FF4444>ERROR: You may only access the mint pool once per 24 hours.<br>" +
                     *      "more hours to <i>/mint</i> again.</color>",
                     *      " more hours to <i>/mint</i> again.</color>",
                     *      user.Player, ChatCategory.Default, DefaultChatTags.Government
                     * );
                     */
                    send_pm(
                        "<color=#FF4444>ERROR: You may only access the mint pool once per 24 hours.<br>" +
                        "You must wait until the daily server restart at 12:00 PST/PDT (approx.), " +
                        " before you can <i>/mint</i> again.</color>",
                        user.Player, ChatCategory.Default, DefaultChatTags.Government
                        );
                    return;
                    //}
                }

                if (minted_today >= config["mint_max_per_day"])
                {
                    send_pm(
                        "<color=#FF4444>ERROR: Mint max-per-day has been reached, please try again tomorrow.</color>",
                        user.Player, ChatCategory.Default, DefaultChatTags.Government
                        );
                    return;
                }

                ItemStack itemStack = user.Inventory.NonEmptyStacks.Where(
                    stack => stack.Item.FriendlyName == "Gold Ore"
                    ).FirstOrDefault();

                if (itemStack != null)
                {
                    bool refund = false;
                    int  items  = 0;
                    for (var i = 0; i < config["mint_daily"]; i++)
                    {
                        bool worked = user.Inventory.TryRemoveItem <GoldOreItem>(user);
                        if (!worked)
                        {
                            // failed
                            break;
                        }
                        items++;
                    }

                    float amount = (float)items;
                    float val    = amount * 10f;

                    // checks
                    if (items == 0)
                    {
                        send_pm(
                            "<color=#FF4444>ERROR: You must mint something, get some GoldOre.</color>",
                            user.Player, ChatCategory.Default, DefaultChatTags.Government
                            );
                    }
                    else if (astr.GetAccount(" _MintPool").Val < val)
                    {
                        refund = true;
                        send_pm(
                            "<color=#FF4444>ERROR: The mint pool does not have enough " + astr.UILink() +
                            " to cover that, (PoolBalance:" + astr.GetAccount(" _MintPool").Val + ").</color>",
                            user.Player, ChatCategory.Default, DefaultChatTags.Government
                            );
                    }
                    else
                    {
                        // award
                        minted_today += (int)val;

                        astr.GetAccount(" _MintPool").Val -= val;
                        astr.GetAccount(user.Name).Val    += val;

                        minting[user.Name] = new DateTime();

                        send_msg(
                            "<color=#AAFF44>NOTICE:</color> " +
                            "<color=#44FF44>" + UserManager.UILink(user.Name) + " has converted " +
                            "<color=#AAFF44>" + val + "</color> <color=#44FF44>" + astr.UILink() +
                            " from the mint pool, <color=#AAFF44>(PoolBalance:" +
                            astr.GetAccount(" _MintPool").Val + ").</color>",
                            ChatCategory.Default, DefaultChatTags.Government
                            );

                        // save config
                        save_config();
                    }

                    if (refund)
                    {
                        InventoryChangeSet changes = new InventoryChangeSet(user.Inventory, user);
                        changes.AddItems <GoldOreItem>(items);
                    }
                }
                else
                {
                    // not enough
                    send_pm(
                        "<color=#FF4444>ERROR: You must mint <i>something</i>, go get some GoldOre.</color>",
                        user.Player, ChatCategory.Default, DefaultChatTags.Government
                        );
                    return;
                }

                break;
            }
        }
Beispiel #51
0
        public static void HandleClickPacket(ClickWindowPacket packet, IWindow window, ref ItemStack itemStaging)
        {
            if (packet.SlotIndex >= window.Length || packet.SlotIndex < 0)
            {
                return;
            }
            var existing = window[packet.SlotIndex];

            if (window.ReadOnlySlots.Contains(packet.SlotIndex))
            {
                if (itemStaging.ID == existing.ID || itemStaging.Empty)
                {
                    if (itemStaging.Empty)
                    {
                        itemStaging = existing;
                    }
                    else
                    {
                        itemStaging.Count += existing.Count;
                    }
                    window[packet.SlotIndex] = ItemStack.EmptyStack;
                }
                return;
            }
            if (itemStaging.Empty) // Picking up something
            {
                if (packet.Shift)
                {
                    window.MoveToAlternateArea(packet.SlotIndex);
                }
                else
                {
                    if (packet.RightClick)
                    {
                        sbyte mod = (sbyte)(existing.Count % 2);
                        existing.Count          /= 2;
                        itemStaging              = existing;
                        itemStaging.Count       += mod;
                        window[packet.SlotIndex] = existing;
                    }
                    else
                    {
                        itemStaging = window[packet.SlotIndex];
                        window[packet.SlotIndex] = ItemStack.EmptyStack;
                    }
                }
            }
            else // Setting something down
            {
                if (existing.Empty) // Replace empty slot
                {
                    if (packet.RightClick)
                    {
                        var newItem = (ItemStack)itemStaging.Clone();
                        newItem.Count = 1;
                        itemStaging.Count--;
                        window[packet.SlotIndex] = newItem;
                    }
                    else
                    {
                        window[packet.SlotIndex] = itemStaging;
                        itemStaging = ItemStack.EmptyStack;
                    }
                }
                else
                {
                    if (existing.CanMerge(itemStaging)) // Merge items
                    {
                        // TODO: Consider the maximum stack size
                        if (packet.RightClick)
                        {
                            existing.Count++;
                            itemStaging.Count--;
                            window[packet.SlotIndex] = existing;
                        }
                        else
                        {
                            existing.Count          += itemStaging.Count;
                            window[packet.SlotIndex] = existing;
                            itemStaging = ItemStack.EmptyStack;
                        }
                    }
                    else // Swap items
                    {
                        window[packet.SlotIndex] = itemStaging;
                        itemStaging = existing;
                    }
                }
            }
        }
Beispiel #52
0
 private static float GetDynamicAttackRange(ItemStack stack, EntityPlayer player)
 {
     return(stack.Item is IDynamicAttackRange ?
            ((IDynamicAttackRange)stack.Item).GetDynamicAttackRange(player, stack) :
            stack.Collectible.GetAttackRange(stack));
 }
Beispiel #53
0
 protected override ItemStack[] GetDrop(BlockDescriptor descriptor, ItemStack item)
 {
     return(new ItemStack[0]);
 }
Beispiel #54
0
 public static void Set(this IAttribute attr, ItemStack value, params string[] keys)
 => Set(attr, (value != null) ? new ItemstackAttribute(value) : null, keys);
Beispiel #55
0
 public MeshData GenMesh(ICoreClientAPI capi, ItemStack stack)
 {
     return(null);
 }
Beispiel #56
0
        public Heavy_weighted_pressure_plateBlock() : base()
        {
            PossibleStates = new BlockState[]
            {
                new BlockState(5601, new Dictionary <string, string>
                {
                    { "power", "0" },
                }),

                new BlockState(5602, new Dictionary <string, string>
                {
                    { "power", "1" },
                }),

                new BlockState(5603, new Dictionary <string, string>
                {
                    { "power", "2" },
                }),

                new BlockState(5604, new Dictionary <string, string>
                {
                    { "power", "3" },
                }),

                new BlockState(5605, new Dictionary <string, string>
                {
                    { "power", "4" },
                }),

                new BlockState(5606, new Dictionary <string, string>
                {
                    { "power", "5" },
                }),

                new BlockState(5607, new Dictionary <string, string>
                {
                    { "power", "6" },
                }),

                new BlockState(5608, new Dictionary <string, string>
                {
                    { "power", "7" },
                }),

                new BlockState(5609, new Dictionary <string, string>
                {
                    { "power", "8" },
                }),

                new BlockState(5610, new Dictionary <string, string>
                {
                    { "power", "9" },
                }),

                new BlockState(5611, new Dictionary <string, string>
                {
                    { "power", "10" },
                }),

                new BlockState(5612, new Dictionary <string, string>
                {
                    { "power", "11" },
                }),

                new BlockState(5613, new Dictionary <string, string>
                {
                    { "power", "12" },
                }),

                new BlockState(5614, new Dictionary <string, string>
                {
                    { "power", "13" },
                }),

                new BlockState(5615, new Dictionary <string, string>
                {
                    { "power", "14" },
                }),

                new BlockState(5616, new Dictionary <string, string>
                {
                    { "power", "15" },
                }),
            };
            State = PossibleStates[0];

            Drops = new ItemStack[] { new Heavy_weighted_pressure_plateItem() };
        }
Beispiel #57
0
 public int GetWorkItemHashCode(ItemStack stack)
 {
     return(stack.Attributes.GetHashCode());
 }
Beispiel #58
0
 public int GetRequiredAnvilTier(ItemStack stack)
 {
     return(2);
 }
Beispiel #59
0
 public EnumHelveWorkableMode GetHelveWorkableMode(ItemStack stack, BlockEntityAnvil beAnvil)
 {
     return(EnumHelveWorkableMode.FullyWorkable);
 }
Beispiel #60
0
 internal void SetContent(ItemStack stack)
 {
     inventory[0].Itemstack = stack;
     MarkDirty(true);
 }