Beispiel #1
0
        public EntityBlockFallingRenderer(Entity entity, ICoreClientAPI api) : base(entity, api)
        {
            this.blockFallingEntity = (EntityBlockFalling)entity;
            this.block = blockFallingEntity.Block;

            entity.PhysicsUpdateWatcher = OnPhysicsTick;

            if (!blockFallingEntity.InitialBlockRemoved)
            {
                BlockEntity be = api.World.BlockAccessor.GetBlockEntity(blockFallingEntity.initialPos);
                be?.OnTesselation(this, capi.Tesselator);

                if (mesh.VerticesCount > 0)
                {
                    mesh.CustomBytes  = null;
                    mesh.CustomFloats = null;
                    mesh.CustomInts   = null;
                    this.meshRef      = capi.Render.UploadMesh(mesh);
                }
            }

            if (this.meshRef == null)
            {
                MeshData mesh = api.TesselatorManager.GetDefaultBlockMesh(block);
                this.meshRef = api.Render.UploadMesh(mesh);
            }

            int textureSubId = block.FirstTextureInventory.Baked.TextureSubId;

            this.atlasTextureId = api.BlockTextureAtlas.Positions[textureSubId].atlasTextureId;

            prevPos.Set(entity.Pos.X + entity.CollisionBox.X1, entity.Pos.Y + entity.CollisionBox.Y1, entity.Pos.Z + entity.CollisionBox.Z1);
        }