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

    Résolu Problème orientation Block Tesr

    1.7.x
    1.7.10
    2
    3
    819
    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.
    • checconio
      checconio dernière édition par

      Bonjour, après avoir je pense bien suivis les tutos pour l’orientation d’un block avec metadata avec rendu tesr mon jeu crash lorsque je pose le block après avoir entré ces fonction:
      (Sans l’enregistrement de la position avec ces fonction le block se pose et s’oriente correctement mais ne sauvegarde pas la position de la rotation en revenant sur la partie, ce qui est normal).

      public Packet getDescriptionPacket()
         {
             NBTTagCompound nbttagcompound = new NBTTagCompound();
             this.writeToNBT(nbttagcompound);
             return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound);
         }
      
         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);
         }
      

      Voici les autres class de mon Block

      BlockTesr:

      package com.test.mod.blocks;
      
      import java.util.List;
      
      import com.test.mod.Reference;
      import com.test.mod.init.BlocksMod;
      import com.test.mod.proxy.ClientProxy;
      import com.test.mod.tileentity.TileEntityBlockTesr;
      
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import net.minecraft.block.Block;
      import net.minecraft.block.material.Material;
      import net.minecraft.client.renderer.texture.IIconRegister;
      import net.minecraft.creativetab.CreativeTabs;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.init.Blocks;
      import net.minecraft.item.Item;
      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 BlockTesr extends Block
      {  
         public static String[] subBlock = new String[] {"block1", "block2", "block3", "block4"};
         private IIcon[][] icons = new IIcon[subBlock.length][3];
      
         //TileEntity
         public BlockTesr(Material p_i45394_1_)
         {
             super(p_i45394_1_);
         }
      
         @Override
         public TileEntity createTileEntity(World world, int metadata)
         {
             return new TileEntityBlockTesr();
         }
      
         @Override
         public boolean hasTileEntity(int metadata)
         {
             return true;
         }
      
         //Rendu
         public boolean isOpaqueCube()
         {
             return false;
         }
      
         public boolean renderAsNormalBlock()
         {
             return false;
         }
      
         public int getRenderType()
         {
             return ClientProxy.renderTesrId;
         }
      
         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 TileEntityBlockTesr)
                 {
                     int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
                     ((TileEntityBlockTesr)tile).setDirection((byte)direction);
                 }
             }
         }
      
         @SideOnly(Side.CLIENT)
         public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
         {
             if(world.getBlockMetadata(x, y, z) == 0)
             {
                 if(side == 0 || side == 1)
                 {
                     return this.icons[0][0];
                 }
                 TileEntity tile = world.getTileEntity(x, y, z);
                 if(tile instanceof TileEntityBlockTesr) // on vérifie son instance pour éviter un ClassCastException
                 {
                     byte direction = ((TileEntityBlockTesr)tile).getDirection(); // on obtient la valeur de la direction
                     return side == 3 && direction == 0 ? this.icons[0][1] : (side == 4 && direction == 1 ? this.icons[0][1] : (side == 2 && direction == 2 ? this.icons[0][1] : (side == 5 && direction == 3 ? this.icons[0][1] : this.icons[0][2]))); // et ici c'est la même condition ternaire que j'ai déjà utilisé dans le cas du bloc basique, sauf qu'on vérifie la direction et non le metadata
                 }
             }
             return this.getIcon(side, world.getBlockMetadata(x, y, z));
         }
      
         public IIcon getIcon(int side, int metadata)
         {
             if(metadata == 0)
             {
                 if(side == 0 || side == 1)
                 {
                     return this.icons[0][0];
                 }
                 else if(side == 3)
                 {
                     return this.icons[0][1];
                 }
                 else
                 {
                     return this.icons[0][2];
                 }
             }
             else if(side > 2)
             {
                 side = 2;
             }
             return metadata >= 0 && metadata < subBlock.length ? this.icons[metadata][side] : this.icons[0][0];
         }
      
         @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 TileEntityBlockTesr)
                 {
                     TileEntityBlockTesr tileDirectional = (TileEntityBlockTesr)tile;
                     byte direction = tileDirectional.getDirection();
                     direction++;
                     if(direction > 3)
                     {
                         direction = 0;
                     }
                     tileDirectional.setDirection(direction);
                     return true;
                 }
             }
             return false;
         }
      
         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;
         }
      }
      

      TileEntityBlockTesr:

      package com.test.mod.tileentity;
      
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.item.ItemStack;
      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;
      import net.minecraft.util.MathHelper;
      import net.minecraft.world.World;
      
      public class TileEntityBlockTesr extends TileEntity
      {
         private byte direction;
      
         @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);
         }
      
         public Packet getDescriptionPacket()
         {
             NBTTagCompound nbttagcompound = new NBTTagCompound();
             this.writeToNBT(nbttagcompound);
             return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound);
         }
      
         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);
         }
      }
      

      TileEntityBlockTesrSpecialRenderer:

      package com.test.mod.renderer;
      
      import org.lwjgl.opengl.GL11;
      
      import com.test.mod.Reference;
      import com.test.mod.render.ModelblockTesr;
      import com.test.mod.tileentity.TileEntityBlockTesr;
      
      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 TileEntityBlockTesrSpecialRenderer extends TileEntitySpecialRenderer
      {
         public static ModelblockTesr model = new ModelblockTesr();
         public static ResourceLocation texture = new ResourceLocation(Reference.MOD_ID, "textures/blocks/blockTesr.png");
      
         public TileEntityBlockTesrSpecialRenderer()
         {
             this.func_147497_a(TileEntityRendererDispatcher.instance);
         }
      
         @Override
         public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float renderTick)
         {
             this.renderTileEntityBlockTesrAt((TileEntityBlockTesr)entity, x, y, z, renderTick);
         }
      
         private void renderTileEntityBlockTesrAt(TileEntityBlockTesr tile, double x, double y, double z, float partialRenderTick)
         {
             GL11.glPushMatrix();
             GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D);
             GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
             GL11.glRotatef(90F * tile.getDirection(), 0.0F, 1.0F, 0.0F);
             this.bindTexture(texture);
             model.renderAll();
             GL11.glPopMatrix();
         }
      }
      

      Client Proxy:

      package com.test.mod.proxy;
      
      import com.test.mod.render.RenderBlockIsbrh;
      import com.test.mod.renderer.TESRInventoryRenderer;
      import com.test.mod.renderer.TileEntityBlockTesrSpecialRenderer;
      import com.test.mod.tileentity.TileEntityBlockTesr;
      
      import cpw.mods.fml.client.registry.ClientRegistry;
      import cpw.mods.fml.client.registry.RenderingRegistry;
      
      public class ClientProxy extends CommonProxy
      {  
         public static int renderBlockIsbrhId;
         public static int renderTesrId;
      
         @Override
         public void registerRenders()
         {
             //ISBRH
             renderBlockIsbrhId = RenderingRegistry.getNextAvailableRenderId();
             RenderingRegistry.registerBlockHandler(new RenderBlockIsbrh());
      
             //TESR
             ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlockTesr.class, new TileEntityBlockTesrSpecialRenderer());
      
             renderTesrId = RenderingRegistry.getNextAvailableRenderId();
             RenderingRegistry.registerBlockHandler(new TESRInventoryRenderer());
         }
      }
      
      

      Crash Report(qui au passage se nome comme un crash report de server: “crash-2016-03-17_07.42.52-server”):

      –-- Minecraft Crash Report ----
      // Oh - I know what I did wrong!
      
      Time: 17/03/16 07:42
      Description: Exception ticking world
      
      java.lang.RuntimeException: class com.test.mod.tileentity.TileEntityBlockTesr is missing a mapping! This is a bug!
      at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:96)
      at com.test.mod.tileentity.TileEntityBlockTesr.writeToNBT(TileEntityBlockTesr.java:27)
      at com.test.mod.tileentity.TileEntityBlockTesr.getDescriptionPacket(TileEntityBlockTesr.java:45)
      at net.minecraft.server.management.PlayerManager$PlayerInstance.sendTileToAllPlayersWatchingChunk(PlayerManager.java:632)
      at net.minecraft.server.management.PlayerManager$PlayerInstance.sendChunkUpdate(PlayerManager.java:574)
      at net.minecraft.server.management.PlayerManager.updatePlayerInstances(PlayerManager.java:80)
      at net.minecraft.world.WorldServer.tick(WorldServer.java:193)
      at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:692)
      at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
      at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
      at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
      at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
      
      A detailed walkthrough of the error, its code path and all known details is as follows:
      ---------------------------------------------------------------------------------------
      
      -- Head --
      Stacktrace:
      at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:96)
      at com.test.mod.tileentity.TileEntityBlockTesr.writeToNBT(TileEntityBlockTesr.java:27)
      at com.test.mod.tileentity.TileEntityBlockTesr.getDescriptionPacket(TileEntityBlockTesr.java:45)
      at net.minecraft.server.management.PlayerManager$PlayerInstance.sendTileToAllPlayersWatchingChunk(PlayerManager.java:632)
      at net.minecraft.server.management.PlayerManager$PlayerInstance.sendChunkUpdate(PlayerManager.java:574)
      at net.minecraft.server.management.PlayerManager.updatePlayerInstances(PlayerManager.java:80)
      at net.minecraft.world.WorldServer.tick(WorldServer.java:193)
      
      -- Affected level --
      Details:
      Level name: New World
      All players: 1 total; [EntityPlayerMP['Player904'/228, l='New World', x=-83,30, y=4,00, z=132,48]]
      Chunk stats: ServerChunkCache: 705 Drop: 0
      Level seed: 2818192979337325781
      Level generator: ID 01 - flat, ver 0\. Features enabled: false
      Level generator options:
      Level spawn location: World: (-71,4,125), Chunk: (at 9,0,13 in -5,7; contains blocks -80,0,112 to -65,255,127), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
      Level time: 24520 game time, 24520 day time
      Level dimension: 0
      Level storage version: 0x04ABD - Anvil
      Level weather: Rain time: 31374 (now: false), thunder time: 85691 (now: false)
      Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
      Stacktrace:
      at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:692)
      at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
      at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
      at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
      at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
      
      – System Details --
      Details:
      Minecraft Version: 1.7.10
      Operating System: Windows 10 (amd64) version 10.0
      Java Version: 1.8.0_74, Oracle Corporation
      Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
      Memory: 776506848 bytes (740 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
      JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
      AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
      IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
      FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 4 mods loaded, 4 mods active
      States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
      UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
      UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar)
      UCHIJAAAA Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar)
      UCHIJAAAA test{1.0.0} [Mod Test] (bin)
      GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
      Profiler Position: N/A (disabled)
      Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
      Player Count: 1 / 8; [EntityPlayerMP['Player904'/228, l='New World', x=-83,30, y=4,00, z=132,48]]
      Type: Integrated Server (map_client.txt)
      Is Modded: Definitely; Client brand changed to 'fml,forge'
      

      Voila j’espère que vous pourrez m’aider 🙂

      Youtubeur Minecraft: https://www.youtube.com/user/checconio84

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

        Salut,
        Tu as oublié d’enregistrer ton tile entity.

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

          @‘robin4002’:

          Salut,
          Tu as oublié d’enregistrer ton tile entity.

          Alors oui merci ^^ enfaite je l’avais mit dans une fonction void où je met mes TileEntity mais j’ai oublier d’initialiser cette fonction dans ma class principale.
          Merci et désoler du dérangement 🙂

          Youtubeur Minecraft: https://www.youtube.com/user/checconio84

          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