示例#1
0
 public void MountableToTreeAttributes(TreeAttribute tree)
 {
     tree.SetString("className", "bed");
     tree.SetInt("posx", pos.X);
     tree.SetInt("posy", pos.Y);
     tree.SetInt("posz", pos.Z);
 }
示例#2
0
        private void UpdateBlock(bool remove, BlockPos pos)
        {
            if (remove)
            {
                World.BlockAccessor.SetBlock(0, pos);
            }
            else
            {
                World.BlockAccessor.SetBlock(Block.BlockId, pos);
                if (blockEntityAttributes != null)
                {
                    BlockEntity be = World.BlockAccessor.GetBlockEntity(pos);

                    blockEntityAttributes.SetInt("posx", pos.X);
                    blockEntityAttributes.SetInt("posy", pos.Y);
                    blockEntityAttributes.SetInt("posz", pos.Z);

                    if (be != null)
                    {
                        be.FromTreeAtributes(blockEntityAttributes, World);
                    }
                }
            }

            NotifyNeighborsOfBlockChange(pos);
        }
        private void UpdateBlock(bool remove, BlockPos pos)
        {
            if (remove)
            {
                if (DoRemoveBlock)
                {
                    World.BlockAccessor.SetBlock(0, pos);
                    World.BlockAccessor.MarkBlockDirty(pos, () => OnChunkRetesselated(true));
                }
            }
            else
            {
                World.BlockAccessor.SetBlock(Block.BlockId, pos);
                World.BlockAccessor.MarkBlockDirty(pos, () => OnChunkRetesselated(false));

                if (blockEntityAttributes != null)
                {
                    BlockEntity be = World.BlockAccessor.GetBlockEntity(pos);

                    blockEntityAttributes.SetInt("posx", pos.X);
                    blockEntityAttributes.SetInt("posy", pos.Y);
                    blockEntityAttributes.SetInt("posz", pos.Z);

                    if (be != null)
                    {
                        be.FromTreeAttributes(blockEntityAttributes, World);
                    }
                }
            }

            NotifyNeighborsOfBlockChange(pos);
        }
示例#4
0
        public override void OnServerGameTick(IWorldAccessor world, BlockPos pos, object extra = null)
        {
            TreeAttribute tree = new TreeAttribute();

            tree.SetInt("x", pos.X);
            tree.SetInt("y", pos.Y);
            tree.SetInt("z", pos.Z);
            world.Api.Event.PushEvent("testForDecay", tree);
        }
        public override void OnBlockBroken(IWorldAccessor world, BlockPos pos, IPlayer byPlayer, ref EnumHandling handling)
        {
            handling = EnumHandling.PassThrough;

            if (byPlayer != null)
            {
                TreeAttribute tree = new TreeAttribute();
                tree.SetInt("x", pos.X);
                tree.SetInt("y", pos.Y);
                tree.SetInt("z", pos.Z);
                world.Api.Event.PushEvent(eventName, tree);
            }
        }
示例#6
0
        public EntityBehaviorNameTag(Entity entity) : base(entity)
        {
            ITreeAttribute nametagTree = entity.WatchedAttributes.GetTreeAttribute("nametag");

            if (nametagTree == null)
            {
                entity.WatchedAttributes.SetAttribute("nametag", nametagTree = new TreeAttribute());
                nametagTree.SetString("name", "");
                nametagTree.SetInt("showtagonlywhentargeted", 0);
                nametagTree.SetInt("renderRange", 999);
                entity.WatchedAttributes.MarkPathDirty("nametag");
            }
        }
示例#7
0
        public override void ToTreeAttributes(ITreeAttribute tree)
        {
            base.ToTreeAttributes(tree);


            tree.SetInt("scanIteration", scanIteration);

            tree.SetInt("quantityNearbyFlowers", quantityNearbyFlowers);
            tree.SetInt("quantityNearbyHives", quantityNearbyHives);
            TreeAttribute emptyskepTree = new TreeAttribute();

            for (int i = 0; i < emptySkeps.Count; i++)
            {
                emptyskepTree.SetInt("posX-" + i, emptySkeps[i].X);
                emptyskepTree.SetInt("posY-" + i, emptySkeps[i].Y);
                emptyskepTree.SetInt("posZ-" + i, emptySkeps[i].Z);
            }
            tree["emptyskeps"] = emptyskepTree;



            tree.SetInt("scanQuantityNearbyFlowers", scanQuantityNearbyFlowers);
            tree.SetInt("scanQuantityNearbyHives", scanQuantityNearbyHives);
            TreeAttribute scanEmptyskepTree = new TreeAttribute();

            for (int i = 0; i < scanEmptySkeps.Count; i++)
            {
                scanEmptyskepTree.SetInt("posX-" + i, scanEmptySkeps[i].X);
                scanEmptyskepTree.SetInt("posY-" + i, scanEmptySkeps[i].Y);
                scanEmptyskepTree.SetInt("posZ-" + i, scanEmptySkeps[i].Z);
            }
            tree["scanEmptySkeps"] = scanEmptyskepTree;


            tree.SetInt("isWildHive", isWildHive ? 1 : 0);
            tree.SetInt("harvestable", Harvestable ? 1 : 0);
            tree.SetInt("skepToPopX", skepToPop == null ? 0 : skepToPop.X);
            tree.SetInt("skepToPopY", skepToPop == null ? 0 : skepToPop.Y);
            tree.SetInt("skepToPopZ", skepToPop == null ? 0 : skepToPop.Z);
            tree.SetDouble("beginPopStartTotalHours", beginPopStartTotalHours);
            tree.SetFloat("popHiveAfterHours", popHiveAfterHours);
            tree.SetDouble("cooldownUntilTotalHours", cooldownUntilTotalHours);
            tree.SetDouble("harvestableAtTotalHours", harvestableAtTotalHours);
            tree.SetInt("hiveHealth", (int)hivePopSize);
            tree.SetFloat("roomness", roomness);
        }
        public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel)
        {
            if (byPlayer.WorldData.CurrentGameMode == EnumGameMode.Creative)
            {
                TreeAttribute tree = new TreeAttribute();
                tree.SetInt("posX", blockSel.Position.X);
                tree.SetInt("posY", blockSel.Position.Y);
                tree.SetInt("posZ", blockSel.Position.Z);
                tree.SetString("playerUid", byPlayer.PlayerUID);

                api.Event.PushEvent("configTeleporter", tree);

                return(true);
            }

            return(base.OnBlockInteractStart(world, byPlayer, blockSel));
        }
示例#9
0
        private void UpdateBlock(bool remove, BlockPos pos)
        {
            if (remove)
            {
                World.BlockAccessor.SetBlock(0, pos);
            }
            else
            {
                Block blockAtFinalPos = World.BlockAccessor.GetBlock(pos);


                if (blockAtFinalPos.Code.Path.Split('-')[0] == Block.Code.Path.Split('-')[0])
                {
                    // need to check for fullblock true
                    int layer = 0;
                    int.TryParse(Block.Code.Path.Split('-')[1], out layer);
                    ((BlockSpreadable)blockAtFinalPos).FallBlock(World, pos, layer);
                }
                else
                {
                    World.BlockAccessor.SetBlock(Block.BlockId, pos);
                }

                if (blockEntityAttributes != null)
                {
                    BlockEntity be = World.BlockAccessor.GetBlockEntity(pos);

                    blockEntityAttributes.SetInt("posx", pos.X);
                    blockEntityAttributes.SetInt("posy", pos.Y);
                    blockEntityAttributes.SetInt("posz", pos.Z);

                    if (be != null)
                    {
                        be.FromTreeAtributes(blockEntityAttributes, World);
                    }
                }
            }

            NotifyNeighborsOfBlockChange(pos);
        }
        ITreeAttribute chunkGenParams()
        {
            TreeAttribute tree = new TreeAttribute();
            TreeAttribute subtree;

            tree["structureChanceModifier"] = subtree = new TreeAttribute();
            subtree.SetFloat("gates", 10);

            tree["structureMaxCount"] = subtree = new TreeAttribute();
            subtree.SetInt("gates", 1);

            return(tree);
        }
示例#11
0
        static bool Prefix(BlockTeleporter __instance, IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel, ref bool __result)
        {
            if (byPlayer.WorldData.CurrentGameMode == EnumGameMode.Survival)
            {
                ItemStack heldItem = byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack;
                if (heldItem != null && heldItem.Item is ItemPadlock)
                {
                    world.BlockAccessor.BreakBlock(blockSel.Position, byPlayer);
                    __result = true;
                    return(false);
                }
                TreeAttribute tree = new TreeAttribute();
                tree.SetInt("posX", blockSel.Position.X);
                tree.SetInt("posY", blockSel.Position.Y);
                tree.SetInt("posZ", blockSel.Position.Z);
                tree.SetString("playerUid", byPlayer.PlayerUID);

                world.Api.Event.PushEvent("configTeleporter", tree);
                __result = true;
            }
            return(false);
        }
示例#12
0
        public void MoveBlock(BlockPos fromPos, BlockPos toPos)
        {
            Block block = bA.GetBlock(fromPos);

            if (block.EntityClass != null)
            {
                TreeAttribute attribs = new TreeAttribute();
                BlockEntity   be      = bA.GetBlockEntity(fromPos);
                if (be != null)
                {
                    be.ToTreeAttributes(attribs);
                    attribs.SetInt("posx", toPos.X);
                    attribs.SetInt("posy", toPos.Y);
                    attribs.SetInt("posz", toPos.Z);

                    bA.SetBlock(0, fromPos);
                    bA.SetBlock(block.BlockId, toPos);

                    BlockEntity be2 = bA.GetBlockEntity(toPos);

                    if (be2 != null)
                    {
                        be2.FromTreeAtributes(attribs, api.World);
                    }
                }
            }
            else
            {
                bA.SetBlock(0, fromPos);
                bA.SetBlock(block.BlockId, toPos);
                if (bA.GetBlock(toPos).Id != 0)
                {
                    api.World.SpawnCubeParticles(toPos, toPos.ToVec3d().Add(0.5), 4, 32);
                }
            }
        }
示例#13
0
        public override void OnHeldInteractStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, bool firstEvent, ref EnumHandHandling handHandling)
        {
            IPlayer byPlayer = (byEntity as EntityPlayer).Player;

            if (byPlayer == null)
            {
                return;
            }


            TreeAttribute tree = new TreeAttribute();

            tree.SetString("inventoryId", slot.Inventory.InventoryID);
            tree.SetInt("slotId", slot.Inventory.GetSlotId(slot));
            api.Event.PushEvent("OpenLootRandomizerDialog", tree);
        }
        public override void OnHeldInteractStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, bool firstEvent, ref EnumHandHandling handling)
        {
            IPlayer byPlayer = null;

            if (byEntity is EntityPlayer)
            {
                byPlayer = byEntity.World.PlayerByUid(((EntityPlayer)byEntity).PlayerUID);
            }
            if (byPlayer == null)
            {
                return;
            }


            TreeAttribute tree = new TreeAttribute();

            tree.SetFloat("totalChance", slot.Itemstack.Attributes.GetFloat("totalChance", 1));

            tree.SetString("inventoryId", slot.Inventory.InventoryID);
            tree.SetInt("slotId", slot.Inventory.GetSlotId(slot));

            api.Event.PushEvent("OpenStackRandomizerDialog", tree);
        }