Esempio n. 1
0
        public override bool DoPlaceBlock(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel, ItemStack byItemStack)
        {
            bool ok = base.DoPlaceBlock(world, byPlayer, blockSel, byItemStack);

            if (!ok)
            {
                return(false);
            }

            BELantern be = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BELantern;

            if (be != null)
            {
                string material = byItemStack.Attributes.GetString("material");
                string lining   = byItemStack.Attributes.GetString("lining");
                string glass    = byItemStack.Attributes.GetString("glass");
                be.DidPlace(material, lining, glass);

                BlockPos targetPos = blockSel.DidOffset ? blockSel.Position.AddCopy(blockSel.Face.Opposite) : blockSel.Position;
                double   dx        = byPlayer.Entity.Pos.X - (targetPos.X + blockSel.HitPosition.X);
                double   dz        = byPlayer.Entity.Pos.Z - (targetPos.Z + blockSel.HitPosition.Z);
                float    angleHor  = (float)Math.Atan2(dx, dz);

                float deg22dot5rad = GameMath.PIHALF / 4;
                float roundRad     = ((int)Math.Round(angleHor / deg22dot5rad)) * deg22dot5rad;
                be.MeshAngle = roundRad;
            }

            return(true);
        }
Esempio n. 2
0
        public override void DoPlaceBlock(IWorldAccessor world, BlockPos pos, BlockFacing onBlockFace, ItemStack byItemStack)
        {
            base.DoPlaceBlock(world, pos, onBlockFace, byItemStack);

            //string sdf = this.Code.Path;

            BELantern be = world.BlockAccessor.GetBlockEntity(pos) as BELantern;

            if (be != null)
            {
                string material = byItemStack.Attributes.GetString("material");
                string lining   = byItemStack.Attributes.GetString("lining");
                be.DidPlace(material, lining);
            }
        }