MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Direction de bloc

    Planifier Épinglé Verrouillé Déplacé Les blocs
    1.6.x
    44 Messages 12 Publieurs 16.0k Vues 1 Watching
    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.
    • isadorI Hors-ligne
      isador Moddeurs confirmés Modérateurs
      dernière édition par

      et la metadata est obtenue par la fonction onplacedby?

      1 réponse Dernière réponse Répondre Citer 0
      • robin4002R Hors-ligne
        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
        dernière édition par

        Oui, sauf si tu as utilisé la deuxième méthode (pour les blocs qui ont déjà un métadata), il faut passer par le tile entity dans ce cas.

        1 réponse Dernière réponse Répondre Citer 0
        • isadorI Hors-ligne
          isador Moddeurs confirmés Modérateurs
          dernière édition par

          mes bloc n’ont pas de metadata.

          par contre

          
          public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
          {
          int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
          world.setBlockMetadataWithNotify(x, y, z, direction, 2);
          }
          
          @Override
          public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
          {
          GL11.glRotatef(90 * metadata, 0.0F, 1.0F, 0.0F);
          renderer.setRenderBounds( 0.0F, 0.0F, 0.0F, 3.0F, 3.0F, 1.0F); // cree un "etage" pour le rendu en jeu
          //renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
          renderer.renderStandardBlock(block, x, y, z); //sauvegarde "l'etage" pour le rendu en jeu
          //etc etc
          return true;
          }
          
          

          comment faire pour que le int direction renseigne la metadata?

          1 réponse Dernière réponse Répondre Citer 0
          • robin4002R Hors-ligne
            robin4002 Moddeurs confirmés Rédacteurs Administrateurs
            dernière édition par

            remplace metadata par world.getBlockMetadata(x, y, z)

            1 réponse Dernière réponse Répondre Citer 0
            • isadorI Hors-ligne
              isador Moddeurs confirmés Modérateurs
              dernière édition par

              À d’accord merci 🙂

              1 réponse Dernière réponse Répondre Citer 0
              • isadorI Hors-ligne
                isador Moddeurs confirmés Modérateurs
                dernière édition par

                cela ne fait rien….

                et le GL11.glRotatef(90 * world.getBlockMetadata(x, y, z), 0.0F, 1.0F, 0.0F); fait un bug d’affichage quand ca active la plaque

                1 réponse Dernière réponse Répondre Citer 0
                • robin4002R Hors-ligne
                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                  dernière édition par

                  Aucune idée dans ce cas, je suis pas un pro en ISBRH

                  1 réponse Dernière réponse Répondre Citer 0
                  • isadorI Hors-ligne
                    isador Moddeurs confirmés Modérateurs
                    dernière édition par

                    au pire je le transforme en entité et je teste l’autre technique

                    1 réponse Dernière réponse Répondre Citer 0
                    • isadorI Hors-ligne
                      isador Moddeurs confirmés Modérateurs
                      dernière édition par

                      en fait le GL11.glRotatef(90 * world.getBlockMetadata(x, y, z), 0.0F, 1.0F, 0.0F); permet de faire pivoter le rendu a l’écran

                      pour GL11.glRotatef(90 * world.getBlockMetadata(x, y, z), 0.0F, 0.0F, 0.0F); :

                      et avec GL11.glRotatef(90 * world.getBlockMetadata(x, y, z), 3.0F, 3.0F, 0.0F); :

                      1 réponse Dernière réponse Répondre Citer 0
                      • robin4002R Hors-ligne
                        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                        dernière édition par

                        Ha ouai, c’est … pas le résultat voulu x)
                        Et avec ça ?

                        GL11.glPushMatrix();
                        GL11.glRotatef(90 * world.getBlockMetadata(x, y, z), 0.0F, 1.0F, 0.0F);
                        GL11.glPopMatrix();
                        
                        1 réponse Dernière réponse Répondre Citer 0
                        • isadorI Hors-ligne
                          isador Moddeurs confirmés Modérateurs
                          dernière édition par

                          je doit le mettre dans mon bloc ou dans le rendu le:

                          
                          public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                          {
                          int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
                          world.setBlockMetadataWithNotify(x, y, z, direction, 2);
                          }
                          
                          

                          ?

                          1 réponse Dernière réponse Répondre Citer 0
                          • robin4002R Hors-ligne
                            robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                            dernière édition par

                            Dans le bloc.

                            1 réponse Dernière réponse Répondre Citer 0
                            • isadorI Hors-ligne
                              isador Moddeurs confirmés Modérateurs
                              dernière édition par

                              cela ne fait strictement rien…
                              mon rendu:

                              
                              package Portal;
                              
                              import net.minecraft.block.Block;
                              import net.minecraft.client.renderer.RenderBlocks;
                              import net.minecraft.client.renderer.Tessellator;
                              import net.minecraft.entity.EntityLivingBase;
                              import net.minecraft.item.ItemStack;
                              import net.minecraft.util.MathHelper;
                              import net.minecraft.world.IBlockAccess;
                              import net.minecraft.world.World;
                              
                              import org.lwjgl.opengl.GL11;
                              
                              import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
                              
                              public class RenderTable implements ISimpleBlockRenderingHandler
                              {
                              
                              @Override
                              public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
                              {
                              Tessellator tessellator = Tessellator.instance;
                              renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); // cree un "etage" pour le rendu de l'inventaire
                              this.renderInInventory(tessellator, renderer, block, metadata); // sauvegarde "l'etage" pour le rendu de l'inventaire
                              //etc etc
                              }
                              
                              private void renderInInventory(Tessellator tessellator, RenderBlocks renderer, Block block, int metadata)
                              
                              {
                              
                              tessellator.startDrawingQuads();
                              
                              tessellator.setNormal(1.0F, 1F, 1.0F);
                              
                              renderer.renderFaceYNeg(block, 1.0D, 1.0D, 1.0D, block.getIcon(0, metadata));
                              
                              tessellator.draw();
                              
                              tessellator.startDrawingQuads();
                              
                              tessellator.setNormal(1.0F, 1.0F, 1.0F);
                              
                              renderer.renderFaceYPos(block, 1.0D, 1.0D, 1.0D, block.getIcon(1, metadata));
                              
                              tessellator.draw();
                              
                              tessellator.startDrawingQuads();
                              
                              tessellator.setNormal(1.0F, 1.0F, 1F);
                              
                              renderer.renderFaceZNeg(block, 1.0D, 1.0D, 1.0D, block.getIcon(2, metadata));
                              
                              tessellator.draw();
                              
                              tessellator.startDrawingQuads();
                              
                              tessellator.setNormal(1.0F, 1.0F, 1.0F);
                              
                              renderer.renderFaceZPos(block, 1.0D, 1.0D, 1.0D, block.getIcon(3, metadata));
                              
                              tessellator.draw();
                              
                              tessellator.startDrawingQuads();
                              
                              tessellator.setNormal(1F, 1.0F, 1.0F);
                              
                              renderer.renderFaceXNeg(block, 1.0D, 1.0D, 1.0D, block.getIcon(4, metadata));
                              
                              tessellator.draw();
                              
                              tessellator.startDrawingQuads();
                              
                              tessellator.setNormal(1.0F, 1.0F, 1.0F);
                              
                              renderer.renderFaceXPos(block, 1.0D, 1.0D, 1.0D, block.getIcon(5, metadata));
                              
                              tessellator.draw();
                              
                              GL11.glTranslatef(1F, 1F, 1F);
                              
                              }
                              
                              public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                              {
                              int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
                              world.setBlockMetadataWithNotify(x, y, z, direction, 2);
                              }
                              
                              @Override
                              public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
                              {
                              GL11.glPushMatrix();
                              GL11.glRotatef(90 * world.getBlockMetadata(x, y, z), 0.0F, 1.0F, 0.0F);
                              GL11.glPopMatrix();
                              
                              renderer.setRenderBounds( 0.0F, 0.0F, 0.0F, 3.0F, 3.0F, 1.0F); // cree un "etage" pour le rendu en jeu
                              //renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ);
                              renderer.renderStandardBlock(block, x, y, z); //sauvegarde "l'etage" pour le rendu en jeu
                              
                              //etc etc
                              return true;
                              }
                              
                              @Override
                              public boolean shouldRender3DInInventory()
                              {
                              return true;
                              }
                              
                              @Override
                              public int getRenderId() {
                              // TODO Auto-generated method stub
                              return ClientProxy.renderTableId;
                              }
                              }
                              
                              

                              mon bloc:

                              
                              package Portal.Blocks;
                              
                              import java.util.Iterator;
                              import java.util.List;
                              import java.util.Random;
                              
                              import net.minecraft.block.Block;
                              import net.minecraft.block.material.Material;
                              import net.minecraft.creativetab.CreativeTabs;
                              import net.minecraft.entity.Entity;
                              import net.minecraft.util.AxisAlignedBB;
                              import net.minecraft.world.IBlockAccess;
                              import net.minecraft.world.World;
                              import Portal.ClientProxy;
                              import cpw.mods.fml.relauncher.Side;
                              import cpw.mods.fml.relauncher.SideOnly;
                              
                              public class portalwowe extends Block {
                              
                              public portalwowe(int id)
                              {
                              super(id, Material.portal);
                              this.setCreativeTab(CreativeTabs.tabBlock);
                              
                              }
                              /**
                              * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
                              * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
                              */
                              public boolean isOpaqueCube()
                              {
                              return false;
                              }
                              
                              /**
                              * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
                              */
                              public boolean renderAsNormalBlock()
                              {
                              return false;
                              }
                              
                              public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int x, int y, int z, int par5)
                              {
                              return this.getPowerSupply(par1IBlockAccess.getBlockMetadata(x, y, z));
                              }
                              
                              public void breakBlock(World world, int x, int y, int z, int par5, int par6)
                              {
                              if(this.getPowerSupply(par6) > 0)
                              {
                              this.notifyChange(world, x, y, z);
                              }
                              
                              super.breakBlock(world, x, y, z, par5, par6);
                              }
                              
                              protected void notifyChange(World world, int x, int y, int z)
                              {
                              world.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
                              world.notifyBlocksOfNeighborChange(x, y - 1, z, this.blockID);
                              }
                              
                              public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
                              {
                              if(!world.isRemote)
                              {
                              int l = this.getPowerSupply(world.getBlockMetadata(x, y, z));
                              
                              if(l == 0)
                              {
                              this.setStateIfMobInteractsWithPlate(world, x, y, z, l);
                              }
                              }
                              }
                              
                              protected void setStateIfMobInteractsWithPlate(World world, int x, int y, int z, int par5)
                              {
                              int i1 = this.getPlateState(world, x, y, z);
                              boolean flag = par5 > 0;
                              boolean flag1 = i1 > 0;
                              
                              if(par5 != i1)
                              {
                              world.setBlockMetadataWithNotify(x, y, z, this.getMetaFromWeight(i1), 2);
                              this.notifyChange(world, x, y, z);
                              world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
                              }
                              
                              if(!flag1 && flag)
                              {
                              world.playSoundEffect((double)x + 0.5D, (double)y + 0.1D, (double)z + 0.5D, "random.click", 0.3F, 0.5F);
                              }
                              else if(flag1 && !flag)
                              {
                              world.playSoundEffect((double)x + 0.5D, (double)y + 0.1D, (double)z + 0.5D, "random.click", 0.3F, 0.6F);
                              }
                              
                              if(flag1)
                              {
                              world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world));
                              }
                              }
                              
                              public void updateTick(World world, int x, int y, int z, Random rand)
                              {
                              if(!world.isRemote)
                              {
                              int l = this.getPowerSupply(world.getBlockMetadata(x, y, z));
                              
                              if(l > 0)
                              {
                              this.setStateIfMobInteractsWithPlate(world, x, y, z, l);
                              }
                              }
                              }
                              
                              public int tickRate(World world)
                              {
                              return 20;
                              }
                              
                              public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
                              {
                              return null;
                              }
                              
                              protected int getPowerSupply(int metadata)
                              {
                              return metadata == 1 ? 15 : 0;
                              }
                              
                              protected int getMetaFromWeight(int metadata)
                              {
                              return metadata > 0 ? 1 : 0;
                              }
                              
                              protected int getPlateState(World world, int x, int y, int z)
                              {
                              List list = world.getEntitiesWithinAABBExcludingEntity((Entity)null, this.getSensitiveAABB(x, y, z));
                              
                              //List list = world.getEntitiesWithinAABB(EntityLivingBase.class, this.getSensitiveAABB(x, y, z));
                              
                              //List list = world.getEntitiesWithinAABB(EntityPlayer.class, this.getSensitiveAABB(x, y, z));
                              
                              if(list != null && !list.isEmpty())
                              {
                              Iterator iterator = list.iterator();
                              
                              while(iterator.hasNext())
                              {
                              Entity entity = (Entity)iterator.next();
                              
                              if(!entity.doesEntityNotTriggerPressurePlate())
                              {
                              return 15;
                              }
                              }
                              }
                              
                              return 0;
                              }
                              
                              protected AxisAlignedBB getSensitiveAABB(int x, int y, int z)
                              {
                              float f = 0.125F;
                              return AxisAlignedBB.getAABBPool().getAABB((double)((float)x + f), (double)y, (double)((float)z + f), (double)((float)(x + 1) - f), (double)y + 0.25D, (double)((float)(z + 1) - f));
                              }
                              
                              public int isProvidingStrongPower(IBlockAccess blockAccess, int x, int y, int z, int side)
                              {
                              return side == 1 ? this.getPowerSupply(blockAccess.getBlockMetadata(x, y, z)) : 0;
                              }
                              
                              @SideOnly(Side.CLIENT)
                              public int getRenderType()
                              {
                              return ClientProxy.renderTableId;
                              }
                              @SideOnly(Side.CLIENT)
                              public boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side)
                              {
                              return true;
                              }
                              }
                              
                              
                              1 réponse Dernière réponse Répondre Citer 0
                              • 1
                              • 2
                              • 3
                              • 3 / 3
                              • Premier message
                                Dernier message
                              Design by Woryk
                              ContactMentions Légales

                              MINECRAFT FORGE FRANCE © 2024

                              Powered by NodeBB