Exemple #1
0
        /// <summary>
        /// Renders an ItemStack on the screen.  Used by containers.
        /// </summary>
        public static void renderStack(ItemStack stack, Vector3 position, Quaternion rotation)
        {
            Item             item             = stack.item;
            MutableTransform mutableTransform = item.getContainerTransfrom();

            mutableTransform.position += position;
            mutableTransform.rotation *= rotation;
            Graphics.DrawMesh(RenderManager.getItemMesh(stack.item, stack.meta, false), mutableTransform.toMatrix4x4(), References.list.blockMaterial, 8, null, 0, null, false, false);
        }
Exemple #2
0
        public Block(int id)
        {
            if (Block.BLOCK_LIST[id] != null)
            {
                throw new Exception("Two blocks may not have the same id of " + this.id);
            }

            this.id = id;
            Block.BLOCK_LIST[this.id] = this;
            this.renderer             = RenderManager.CUBE;
            this.setTexture(0, 0);
            this.statesUsed         = 1;
            this.containerTransfrom = new MutableTransform(Vector3.zero, Quaternion.Euler(-9.2246f, 45.7556f, -9.346399f), new Vector3(0.125f, 0.125f, 0.125f));
        }
Exemple #3
0
    /// <summary>
    /// Renders an ItemStack on the screen.  Used by containers.
    /// </summary>
    public static void renderItemMesh(ItemData itemData, Vector3 position, Quaternion rotation, Vector3 scale, Camera camera = null)
    {
        MutableTransform mt = itemData.getContainerMT();

        mt.position += position;
        mt.rotation *= rotation;
        mt.scale     = new Vector3(mt.scale.x * scale.x, mt.scale.y * scale.y, mt.scale.z * scale.z);

        // Move the mesh away from the GUI element
        mt.position += Vector3.forward * -2;

        // Figure out what material to use.
        Material material = itemData.getMaterialNumber() == 0 ? References.list.itemMaterialUnlit_0 : References.list.itemMaterialUnlit_1;

        Graphics.DrawMesh(itemData.getMesh(), mt.toMatrix4x4(), material, 9, camera, 0, null, false, false);

        Debug.DrawLine(new Vector3(200, 0, 0), mt.position, Color.yellow);
    }
Exemple #4
0
        /// <summary>
        /// Renders the item in the players hand.  Override for special held renderings.
        /// </summary>
        public virtual void renderAsHeldItem(EntityPlayer player, int meta, int count, Transform handTransfrom)
        {
            MutableTransform mt     = this.getHandTransform();
            Matrix4x4        matrix = Matrix4x4.TRS(
                handTransfrom.position + mt.position + new Vector3(),
                handTransfrom.rotation * mt.rotation,
                mt.scale);
            MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();
            BlockPos playerPos = new BlockPos(player.transform.position);

            materialPropertyBlock.SetColor(36, RenderManager.instance.lightColors.getColorFromBrightness(player.world.getLight(playerPos.x, playerPos.y + 1, playerPos.z)));
            Graphics.DrawMesh(
                RenderManager.getItemMesh(this, meta, true),
                matrix,
                References.list.blockMaterial,
                0,
                null,
                0,
                materialPropertyBlock,
                false,
                false);
        }
Exemple #5
0
 public Block setContainerTransfrom(MutableTransform transfrom)
 {
     this.containerTransfrom = transfrom;
     return(this);
 }