示例#1
0
        public override bool OnTesselation(ITerrainMeshPool mesher, ITesselatorAPI tessThreadTesselator)
        {
            mat.Identity();
            mat.RotateYDeg(block.Shape.rotateY);

            return(base.OnTesselation(mesher, tessThreadTesselator));
        }
示例#2
0
        public void InitForUse(float rotateYDeg)
        {
            Matrixf mat = new Matrixf();

            mat.RotateYDeg(rotateYDeg);

            BlockCodes         = new Dictionary <int, AssetLocation>();
            TransformedOffsets = new List <BlockOffsetAndNumber>();

            foreach (var val in BlockNumbers)
            {
                BlockCodes[val.Value] = val.Key;
            }

            for (int i = 0; i < Offsets.Count; i++)
            {
                Vec4i offset     = Offsets[i];
                Vec4f offsetTf   = new Vec4f(offset.X, offset.Y, offset.Z, 0);
                Vec4f tfedOffset = mat.TransformVector(offsetTf);

                TransformedOffsets.Add(new BlockOffsetAndNumber()
                {
                    X = (int)Math.Round(tfedOffset.X), Y = (int)Math.Round(tfedOffset.Y), Z = (int)Math.Round(tfedOffset.Z), W = offset.W
                });
            }
        }
示例#3
0
        public bool OnTesselation(ITerrainMeshPool mesher, ITesselatorAPI tessThreadTesselator)
        {
            ICoreClientAPI capi = api as ICoreClientAPI;

            Matrixf mat = new Matrixf();

            mat.RotateYDeg(block.Shape.rotateY);

            for (int i = 0; i < 8; i++)
            {
                if (inv[i].Empty)
                {
                    continue;
                }

                ItemStack  stack      = inv[i].Itemstack;
                BlockCrock crockblock = stack.Collectible as BlockCrock;
                Vec3f      rot        = new Vec3f(0, block.Shape.rotateY, 0);

                MeshData mesh = BlockEntityCrock.GetMesh(tessThreadTesselator, api, crockblock, crockblock.GetContents(api.World, stack), crockblock.GetRecipeCode(api.World, stack), rot);

                float y = i >= 4 ? 10 / 16f : 2 / 16f;
                float x = (i % 2 == 0) ? 4 / 16f : 12 / 16f;
                float z = ((i % 4) >= 2) ? 10 / 16f : 4 / 16f;

                Vec4f offset = mat.TransformVector(new Vec4f(x - 0.5f, y, z - 0.5f, 0));
                mesh.Translate(offset.XYZ);
                mesher.AddMeshData(mesh);
            }

            return(false);
        }
示例#4
0
        public override void Initialize(ICoreAPI api)
        {
            block = api.World.BlockAccessor.GetBlock(Pos);
            mat.RotateYDeg(block.Shape.rotateY);

            base.Initialize(api);
        }
示例#5
0
        static void initRotations()
        {
            for (int i = 0; i < 4; i++)
            {
                Matrixf m = new Matrixf();
                m.Translate(0.5f, 0.5f, 0.5f);
                m.RotateYDeg(i * 90);
                m.Translate(-0.5f, -0.5f, -0.5f);

                Vec3f[] poses = candleWickPositionsByRot[i] = new Vec3f[candleWickPositions.Length];
                for (int j = 0; j < poses.Length; j++)
                {
                    Vec4f rotated = m.TransformVector(new Vec4f(candleWickPositions[j].X / 16f, candleWickPositions[j].Y / 16f, candleWickPositions[j].Z / 16f, 1));
                    poses[j] = new Vec3f(rotated.X, rotated.Y, rotated.Z);
                }
            }
        }
示例#6
0
        public override void Initialize(ICoreAPI api)
        {
            Facing = BlockFacing.FromCode(Block.Variant["side"]);
            if (Facing == null)
            {
                Facing = BlockFacing.NORTH;
            }

            switch (Facing.Index)
            {
            case 0:
                rotateY = 180;
                break;

            case 1:
                rotateY = 90;
                break;

            case 3:
                rotateY = 270;
                break;

            default:
                break;
            }

            mat.Translate(0.5f, 0.5f, 0.5f);
            mat.RotateYDeg(rotateY);
            mat.Translate(-0.5f, -0.5f, -0.5f);

            base.Initialize(api);

            inv.LateInitialize(InventoryClassName + "-" + Pos, api);

            if (api.World.Side == EnumAppSide.Server)
            {
                RegisterGameTickListener(OnServerTick, 200);
            }

            pvBh = GetBehavior <BEBehaviorMPPulverizer>();
        }