• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu Rendu 3D translucide / TESR

    1.7.x
    1.7.10
    2
    3
    654
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • Folgansky
      Folgansky Correcteurs dernière édition par

      Salut les gens,

      Je m’active actuellement pour diversifier les modèles de mon mod mais je bute fortement sur les blocs translucides.
      J’ai commencé par regarder la classe du bloc de verre et faire qqs tests concluants mais la transition bloc/TESR c’est pas ça.

      Ici, on peut voir que la lumière traverse bien le bloc mais la texture du bloc n’est pas translucide, alors que le rendu en inventaire est translucide.

      Voici mes classes en commençant par la seule que je pensais devoir modifier pour qu’il soit translucide:

      Classe du bloc:

      package fr.folgansky.powerdeco.common;
      
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import fr.folgansky.powerdeco.client.TileEntityBottle;
      import fr.folgansky.powerdeco.proxy.ClientProxy;
      import net.minecraft.block.Block;
      import net.minecraft.block.material.Material;
      import net.minecraft.client.renderer.texture.IIconRegister;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.item.ItemStack;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.util.IIcon;
      import net.minecraft.util.MathHelper;
      import net.minecraft.world.IBlockAccess;
      import net.minecraft.world.World;
      import net.minecraftforge.common.util.ForgeDirection;
      
      public class BlockBottle extends Block
      {
          protected BlockBottle(Material mat)
          {
              super(mat);
          }
      
          @Override
          public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
          {
              this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
          }
      
          @Override
          public int damageDropped(int metadata)
          {
              return metadata;
          }
      
          @Override
          public boolean hasTileEntity(int metadata)
          {
              return true;
          }
      
          @Override
          public TileEntity createTileEntity(World world, int metadata)
          {
              return new TileEntityBottle();
          }
      
          @Override
          public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
          {
              if (stack.getItemDamage() == 0)
              {
                  TileEntity tile = world.getTileEntity(x, y, z);
                  if (tile instanceof TileEntityBottle)
                  {
                      int direction = MathHelper.floor_double(living.rotationYaw * 4.0F / 360.0F + 2.5D) & 3;
                      ((TileEntityBottle) tile).setDirection((byte) direction);
                  }
              }
          }
      
          @Override
          public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
          {
              if ((axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) && !world.isRemote
                      && world.getBlockMetadata(x, y, z) == 0)
              {
                  TileEntity tile = world.getTileEntity(x, y, z);
                  if (tile instanceof TileEntityBottle)
                  {
                      TileEntityBottle tileDirectional = (TileEntityBottle) tile;
                      byte direction = tileDirectional.getDirection();
                      direction++;
                      if (direction > 3)
                          direction = 0;
                      tileDirectional.setDirection(direction);
                      return true;
                  }
              }
              return false;
          }
      
          @Override
          public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
          {
              return world.getBlockMetadata(x, y, z) == 0 ? new ForgeDirection[]
              { ForgeDirection.UP, ForgeDirection.DOWN } : ForgeDirection.VALID_DIRECTIONS;
          }
      
          @Override
          public boolean isOpaqueCube()
          {
              return false;
          }
      
          @Override
          public boolean renderAsNormalBlock()
          {
              return false;
          }
      
          public boolean canBeCollidedWith()
          {
              return true;
          }
      
          @Override
          @SideOnly(Side.CLIENT)
          public int getRenderType()
          {
              return ClientProxy.tesrRenderId;
          }
      
          public void registerBlockIcons(IIconRegister iiconRegister)
           {
               this.blockIcon = iiconRegister.registerIcon("ModPowerDeco:blockBottle");
           }
      
           @SideOnly(Side.CLIENT)
           public IIcon getIcon(int side, int metadata)
           {
               return this.blockIcon;
           }
      
           @SideOnly(Side.CLIENT)
           public int getRenderBlockPass()
           {
               return 1;
           }
      }
      

      Classe du TileEntity:

      package fr.folgansky.powerdeco.client;
      
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.network.NetworkManager;
      import net.minecraft.network.Packet;
      import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
      import net.minecraft.tileentity.TileEntity;
      
      public class TileEntityBottle extends TileEntity
      {
          private byte direction;
      
           @Override
           public boolean canUpdate()
           {
               return false;
           }
      
          @Override
          public void readFromNBT(NBTTagCompound compound)
          {
              super.readFromNBT(compound);
              this.direction = compound.getByte("Direction");
          }
      
          @Override
          public void writeToNBT(NBTTagCompound compound)
          {
              super.writeToNBT(compound);
              compound.setByte("Direction", this.direction);
          }
      
          public byte getDirection()
          {
              return direction;
          }
      
          public void setDirection(byte direction)
          {
              this.direction = direction;
              this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
          }
      
          @Override
          public Packet getDescriptionPacket()
          {
              NBTTagCompound nbttagcompound = new NBTTagCompound();
              this.writeToNBT(nbttagcompound);
              return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound);
          }
      
          @Override
          public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
          {
              this.readFromNBT(pkt.func_148857_g());
              this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord,
                      this.zCoord);
          }
      }
      

      Classe du TESR:

      package fr.folgansky.powerdeco.client;
      
      import org.lwjgl.opengl.GL11;
      
      import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
      import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.util.ResourceLocation;
      
      public class TileEntityBottleSpecialRenderer extends TileEntitySpecialRenderer
      {
          public static ModelBottle model = new ModelBottle();
          public static ResourceLocation texture = new ResourceLocation("ModPowerDeco:textures/models/blocks/Bottle.png");
      
          public TileEntityBottleSpecialRenderer()
          {
              this.func_147497_a(TileEntityRendererDispatcher.instance);
          }
      
          @Override
          public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialRenderTick)
          {
              this.renderTileEntityBottleAt((TileEntityBottle) tile, x, y, z, partialRenderTick);
          }
      
          private void renderTileEntityBottleAt(TileEntityBottle tile, double x, double y, double z, float partialRenderTick)
          {
              GL11.glPushMatrix();
              GL11.glTranslated(x + 0.5D, y + 1.05D, z + 0.5D);
              GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
              GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F);
              GL11.glScaled(0.7, 0.7, 0.7);
              this.bindTexture(texture);
              model.renderAll();
              GL11.glPopMatrix();
          }
      }
      

      Auriez-vous une piste à ce sujet svp?

      1 réponse Dernière réponse Répondre Citer 0
      • Deleted
        Deleted dernière édition par

        Dans ton tesr apres glPushMatrix, essaie d ajouter un GL11.glEnable(GL11.gl_Blend);

        Et juste avant le popMatrix, à la fin, rajoute la meme ligne en mettant glDisable a la place, puis dis moi si sa marche ?

        1 réponse Dernière réponse Répondre Citer 0
        • Folgansky
          Folgansky Correcteurs dernière édition par

          Nickel, merci pour ce coup de pouce ^^

          (Précision pour ceux qui passerons après c’est GL_BLEND)

          1 réponse Dernière réponse Répondre Citer 0
          • 1 / 1
          • Premier message
            Dernier message
          Design by Woryk
          Contact / Mentions Légales

          MINECRAFT FORGE FRANCE © 2018

          Powered by NodeBB