Faire un bloc Techne avec une texture transparente



  • J'ai chercher sur plusieurs tutoriel mais je n'ai pas trouver de solution à mon problème. J'essaye de créer un bloc comme le bloc de slime de la 1.8, c'est à dire un bloc a l’intérieur d'un bloc. Quand j'essaye de le faire le bloc a l’intérieur n’apparaît pas. Comment faire pour que le bloc extérieur soit transparent et que le bloc intérieur soit visible.


  • Moddeurs confirmés

    Tu applique un modèle de bloc avec un plus petit à l'intérieur puis sur celui qui est à l'extérieur tu lui mets une texture semi-transparente.



  • J'ai essayer, mais même si je met une texture semi transparente sur le premier bloc, le deuxième à l’intérieur ne s'affiche pas comme s'il était invisible. (Je fait le bloc sur Techne).



  • Un peu comme mon problème ?

    http://www.minecraftforgefrance.fr/showthread.php?tid=504

    Il faudrait ajouté GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); avant model.render

    (perso, moi ça n'a pas marcher :3)



  • Tien j'ai ceci pour toi, mais je n'ai pas réussi à faire la texture du diamant correctement a l'intérieur car j'ai un erreur. Mais sa peut toujours t'aider.

    Main:

    
    package flufd.doubleRender.common;
    
    import net.minecraft.block.Block;
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.Init;
    import cpw.mods.fml.common.Mod.Instance;
    import cpw.mods.fml.common.Mod.PostInit;
    import cpw.mods.fml.common.Mod.PreInit;
    import cpw.mods.fml.common.SidedProxy;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.event.FMLPostInitializationEvent;
    import cpw.mods.fml.common.event.FMLPreInitializationEvent;
    import cpw.mods.fml.common.network.NetworkMod;
    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.common.registry.LanguageRegistry;
    import flufd.doubleRender.client.DoubleRenderClientProxy;
    
    @Mod(modid = "doublerender", name = "DoubleRenderMod", version = "0.1")
    @NetworkMod(clientSideRequired = true, serverSideRequired = false)
    public class DoubleRenderMain {
    
    @Instance("tutorial")
    public static DoubleRenderMain instance;
    
    @SidedProxy(clientSide="flufd.doubleRender.client.DoubleRenderClientProxy", serverSide="flufd.doubleRender.common.DoubleRenderCommonProxy")
    public static DoubleRenderCommonProxy proxy;
    
    public static Block frozenDiamond;
    @PreInit
    public void preInit(FMLPreInitializationEvent event) {
    
    }
    
    @Init
    public void init(FMLInitializationEvent event) {
    frozenDiamond = (new BlockFrozenDiamond(784,67));
    LanguageRegistry.addName(frozenDiamond, "Frozen Diamond");
    GameRegistry.registerBlock(frozenDiamond,"frozenDiamond");
    
    DoubleRenderClientProxy.setCustomRenderers();
    }
    
    @PostInit
    public static void postInit(FMLPostInitializationEvent event) {
    
    }
    }
    DoubleRenderClientProxy - the client proxy
    package flufd.doubleRender.client;
    
    import cpw.mods.fml.client.registry.RenderingRegistry;
    import flufd.doubleRender.common.DoubleRenderCommonProxy;
    
    public class DoubleRenderClientProxy extends DoubleRenderCommonProxy {
    
    public static int frozenDiamondRenderType;
    public static int renderPass;
    
    public static void setCustomRenderers()
    {
    frozenDiamondRenderType = RenderingRegistry.getNextAvailableRenderId();
    RenderingRegistry.registerBlockHandler(new FrozenDiamondRenderer());
    }
    
    }
    
    

    Block:

    
    package flufd.doubleRender.common;
    
    import java.util.ArrayList;
    
    import flufd.doubleRender.client.DoubleRenderClientProxy;
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.item.ItemStack;
    import net.minecraft.world.World;
    
    public class BlockFrozenDiamond extends Block{
    
    public BlockFrozenDiamond(int i, int j)
    {
    super(i, j, Material.ice );
    this.setCreativeTab(CreativeTabs.tabBlock);
    this.slipperiness = 0.98F;
    }
    
    @Override
    public boolean renderAsNormalBlock()
    {
    return false;
    }
    
    @Override
    public int getRenderType()
    {
    return DoubleRenderClientProxy.frozenDiamondRenderType;
    }
    
    @Override
    public boolean isOpaqueCube()
    {
    return false;
    }
    
    @Override
    public int getRenderBlockPass()
    {
    return 1;
    }
    
    @Override
    public boolean canRenderInPass(int pass)
    {
    //Set the static var in the client proxy
    DoubleRenderClientProxy.renderPass = pass;
    //the block can render in both passes, so return true always
    return true;
    }
    
    }
    
    

    Renderer:

    
    package flufd.doubleRender.client;
    
    import net.minecraft.block.Block;
    import net.minecraft.client.renderer.RenderBlocks;
    import net.minecraft.client.renderer.Tessellator;
    import net.minecraft.world.IBlockAccess;
    import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
    
    public class FrozenDiamondRenderer implements ISimpleBlockRenderingHandler {
    
    @Override
    public void renderInventoryBlock(Block block, int metadata, int modelID,
    RenderBlocks renderer) {
    
    }
    
    @Override
    public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,
    Block block, int modelId, RenderBlocks renderer) {
    
    //which render pass are we doing?
    if(DoubleRenderClientProxy.renderPass == 0)
    {
    //we are on the solid block render pass, lets render the solid diamond block
    drawDiamond(Block.blockDiamond,x,y,z);
    }
    else
    {
    //we are on the alpha render pass, draw the ice around the diamond
    renderer.renderStandardBlock(Block.ice, x, y, z);
    }
    
    return true;
    }
    
    //Our custom renderer for the diamond, draws a pair of crossed squares in the centre of the block
    public void drawDiamond(Block par1Block, int x, int y, int z)
    {
    //change the passed integer coordinates into double precision floats, and set the height on the y axis
    double par3 = (double)x;
    double par5 = (double)y + 0.25F;
    double par7 = (double)z;
    
    //this is the scale of the squares, in blocks
    float par9 = 0.5F;
    
    //get the tessellator instance
    Tessellator var10 = Tessellator.instance;
    
    //set the texture
    int var11 = Block.blockDiamond.getBlockTextureFromSide(0);
    
    //do texture mapping things here
    int var12 = (var11 & 15) << 4;
    int var13 = var11 & 240;
    
    //set the uv coordinates
    double var14 = (double)((float)var12 / 256.0F);
    double var16 = (double)(((float)var12 + 15.99F) / 256.0F);
    double var18 = (double)((float)var13 / 256.0F);
    double var20 = (double)(((float)var13 + 15.99F) / 256.0F);
    
    //here the scale is changed
    double var22 = 0.45D * (double)par9;
    
    //offset the vertices from the centre of the block
    double var24 = par3 + 0.5D - var22;
    double var26 = par3 + 0.5D + var22;
    double var28 = par7 + 0.5D - var22;
    double var30 = par7 + 0.5D + var22;
    
    //not create the vertices
    var10.addVertexWithUV(var24, par5 + (double)par9, var28, var14, var18);
    var10.addVertexWithUV(var24, par5 + 0.0D, var28, var14, var20);
    var10.addVertexWithUV(var26, par5 + 0.0D, var30, var16, var20);
    var10.addVertexWithUV(var26, par5 + (double)par9, var30, var16, var18);
    var10.addVertexWithUV(var26, par5 + (double)par9, var30, var14, var18);
    var10.addVertexWithUV(var26, par5 + 0.0D, var30, var14, var20);
    var10.addVertexWithUV(var24, par5 + 0.0D, var28, var16, var20);
    var10.addVertexWithUV(var24, par5 + (double)par9, var28, var16, var18);
    var10.addVertexWithUV(var24, par5 + (double)par9, var30, var14, var18);
    var10.addVertexWithUV(var24, par5 + 0.0D, var30, var14, var20);
    var10.addVertexWithUV(var26, par5 + 0.0D, var28, var16, var20);
    var10.addVertexWithUV(var26, par5 + (double)par9, var28, var16, var18);
    var10.addVertexWithUV(var26, par5 + (double)par9, var28, var14, var18);
    var10.addVertexWithUV(var26, par5 + 0.0D, var28, var14, var20);
    var10.addVertexWithUV(var24, par5 + 0.0D, var30, var16, var20);
    var10.addVertexWithUV(var24, par5 + (double)par9, var30, var16, var18);
    }
    
    @Override
    public boolean shouldRender3DInInventory() {
    
    return false;
    }
    
    @Override
    public int getRenderId() {
    
    return DoubleRenderClientProxy.frozenDiamondRenderType;
    }
    
    }
    
    

    ClientProxy:

    
    package flufd.doubleRender.client;
    
    import cpw.mods.fml.client.registry.RenderingRegistry;
    import flufd.doubleRender.common.DoubleRenderCommonProxy;
    
    public class DoubleRenderClientProxy extends DoubleRenderCommonProxy {
    
    public static int frozenDiamondRenderType;
    public static int renderPass;
    
    public static void setCustomRenderers()
    {
    frozenDiamondRenderType = RenderingRegistry.getNextAvailableRenderId();
    RenderingRegistry.registerBlockHandler(new FrozenDiamondRenderer());
    }
    
    }
    
    

Log in to reply