• Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Solved Rendu animé TESR

    1.7.x
    1.7.10
    5
    15
    2146
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      avaloon last edited by

      Salut, j’ai suivi tous le tuto (http://www.minecraftforgefrance.fr/showthread.php?tid=2559), quand viens le moment du test quand je fait clic droit sur le coffre il n’y a pas l’animation (le GUI s’ouvre le container fonctionne)  et pas de son. J’ai essayé de vérifier le code grâce au github du tuto mais je trouve pas 😢

      J’en appelle donc à votre aide !
      Voici mes différents code :

      package fr.nidalia.nidalia.client;
      
      import org.lwjgl.opengl.GL11;
      
      import fr.nidalia.nidalia.common.ModNidalia;
      import fr.nidalia.nidalia.common.TileEntityShop;
      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 TileEntityShopSpecialRenderer extends
      TileEntitySpecialRenderer {
      
      public Shop model = new Shop();
      public static ResourceLocation texture = new ResourceLocation(ModNidalia.MODID, "textures/models/blocks/shop128.png");
      
      public TileEntityShopSpecialRenderer()
      {
      this.func_147497_a(TileEntityRendererDispatcher.instance);
      }
      @Override
      public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialRenderTick) {
      
      this.renderTileEntityShopAt((TileEntityShop)tile, x, y, z, partialRenderTick);
      }
      
      private void renderTileEntityShopAt(TileEntityShop tile, double x,
      double y, double z, float partialRenderTick) {
      GL11.glPushMatrix();
      GL11.glTranslated(x + 0.5F, y + 1.5F, z + 0.5F);
      GL11.glRotatef(180, 0.0F, 0.0F, 1.0F);
      GL11.glRotatef(90 * tile.getDirection(), 0.0F, 1.0F, 0.0F);
      this.bindTexture(texture);
             float f1 = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialRenderTick;
             f1 = 1.0F - f1;
             f1 = 1.0F - f1 * f1 * f1;
             this.model.haut.rotateAngleX = -(f1 * (float)Math.PI / 2.0F);
             this.model.render();
      GL11.glPopMatrix();
      }
      }
      
      package fr.nidalia.nidalia.common;
      
      import java.util.Iterator;
      import java.util.List;
      
      import net.minecraft.block.BlockChest;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.inventory.ContainerChest;
      import net.minecraft.inventory.IInventory;
      import net.minecraft.inventory.InventoryLargeChest;
      import net.minecraft.item.ItemStack;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.nbt.NBTTagList;
      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.AxisAlignedBB;
      import net.minecraftforge.common.util.Constants;
      
      public class TileEntityShop extends TileEntity implements IInventory{
      
         private byte direction;
         private ItemStack[] contents = new ItemStack[27];
         private String customName;
         public float lidAngle;
         public float prevLidAngle;
         public int numPlayersUsing;
         private int ticksSinceSync;
      
          @Override
         public void readFromNBT(NBTTagCompound compound)
          {
              super.readFromNBT(compound);
              this.direction = compound.getByte("Direction");
      
              if (compound.hasKey("CustomName", Constants.NBT.TAG_STRING))
              {
                  this.customName = compound.getString("CustomName");
              }
      
              NBTTagList nbttaglist = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
              this.contents = new ItemStack[this.getSizeInventory()];
              for (int i = 0; i < nbttaglist.tagCount(); ++i)
              {
                  NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                  int j = nbttagcompound1.getByte("Slot") & 255;
      
                  if (j >= 0 && j < this.contents.length)
                  {
                      this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                  }
              }
          }
      
          @Override
          public void writeToNBT(NBTTagCompound compound)
          {
              super.writeToNBT(compound);
              compound.setByte("Direction", this.direction);
      
              if (this.hasCustomInventoryName())
              {
                  compound.setString("CustomName", this.customName);
              }
      
              NBTTagList nbttaglist = new NBTTagList();
              for (int i = 0; i < this.contents.length; ++i)
              {
                  if (this.contents* != null)
                  {
                      NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                      nbttagcompound1.setByte("Slot", (byte)i);
                      this.contents*.writeToNBT(nbttagcompound1);
                      nbttaglist.appendTag(nbttagcompound1);
                  }
              }
      
              compound.setTag("Items", nbttaglist);
      
          }
      
          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);
          }
      
      @Override
      public int getSizeInventory() {
      
      return this.contents.length;
      }
      
      @Override
      public ItemStack getStackInSlot(int slotindex) {
      
      return this.contents[slotindex];
      }
      
      @Override
      public ItemStack decrStackSize(int slotindex, int amount) {
             if (this.contents[slotindex] != null)
      
             {
                 ItemStack itemstack;
      
                 if (this.contents[slotindex].stackSize <= amount)
                 {
                     itemstack = this.contents[slotindex];
                     this.contents[slotindex] = null;
                     this.markDirty();
                     return itemstack;
                 }
                 else
                 {
                     itemstack = this.contents[slotindex].splitStack(amount);
      
                     if (this.contents[slotindex].stackSize == 0)
                     {
                         this.contents[slotindex] = null;
                     }
      
                     this.markDirty();
                     return itemstack;
                 }
             }
             else
             {
                 return null;
             }
      }
      @Override
      public ItemStack getStackInSlotOnClosing(int slotindex) {
      if (this.contents[slotindex] != null)
             {
                 ItemStack itemstack = this.contents[slotindex];
                 this.contents[slotindex] = null;
                 return itemstack;
             }
             else
             {
                 return null;
             }
      }
      
      @Override
      public void setInventorySlotContents(int slotindex,
      ItemStack stack) {
      this.contents[slotindex] = stack;
      
             if (stack != null && stack.stackSize > this.getInventoryStackLimit())
             {
                 stack.stackSize = this.getInventoryStackLimit();
             }
      
             this.markDirty();
      }
      
      @Override
      public String getInventoryName() {
             return this.hasCustomInventoryName() ? this.customName : "tile.Shop";
      
      }
      
      @Override
      public boolean hasCustomInventoryName() {
      
      return this.customName != null && this.customName.isEmpty();
      }
      
      public void setCustomName(String customName) {
      this.customName = customName;
      }
      
      @Override
      public int getInventoryStackLimit() {
      
      return 64;
      }
      
      @Override
      public boolean isUseableByPlayer(EntityPlayer player) {
             return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
      }
      
         @Override
         public void openInventory()
         {
             if(this.numPlayersUsing < 0)
             {
                 this.numPlayersUsing = 0;
             }
      
             ++this.numPlayersUsing;
             this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing);
             this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
             this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
         }
      
         public void closeInventory()
         {
             –this.numPlayersUsing;
             this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing);
             this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
             this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
         }
      
      @Override
      public boolean isItemValidForSlot(int slotindex, ItemStack stack) {
      return true;
      }
      
         @Override
         public void updateEntity()
         {
             ++this.ticksSinceSync;
             float f;
      
             if(!this.worldObj.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0)
             {
                 this.numPlayersUsing = 0;
                 f = 5.0F;
                 List list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox((double)((float)this.xCoord - f), (double)((float)this.yCoord - f), (double)((float)this.zCoord - f), (double)((float)(this.xCoord + 1) + f), (double)((float)(this.yCoord + 1) + f), (double)((float)(this.zCoord + 1) + f)));
                 Iterator iterator = list.iterator();
      
                 while(iterator.hasNext())
                 {
                     EntityPlayer entityplayer = (EntityPlayer)iterator.next();
      
                     if(entityplayer.openContainer instanceof ContainerShop)
                     {
                         IInventory iinventory = ((ContainerShop)entityplayer.openContainer).getTileShop();
      
                         if(iinventory == this)
                         {
                             ++this.numPlayersUsing;
                         }
                     }
                 }
             }
      
             this.prevLidAngle = this.lidAngle;
             f = 0.1F;
      
             if(this.numPlayersUsing > 0 && this.lidAngle == 0.0F)
             {
      
                 this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
             }
      
             if(this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F)
             {
                 float f1 = this.lidAngle;
      
                 if(this.numPlayersUsing > 0)
                 {
                     this.lidAngle += f;
                 }
                 else
                 {
                     this.lidAngle -= f;
                 }
      
                 if(this.lidAngle > 1.0F)
                 {
                     this.lidAngle = 1.0F;
                 }
      
                 float f2 = 0.5F;
      
                 if(this.lidAngle < f2 && f1 >= f2)
                 {
                     this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
                 }
      
                 if(this.lidAngle < 0.0F)
                 {
                     this.lidAngle = 0.0F;
                 }
             }
         }
         @Override
         public boolean receiveClientEvent(int id, int value)
         {
             if(id == 1)
             {
                 this.numPlayersUsing = value;
                 return true;
             }
             return super.receiveClientEvent(id, value);
         }
      }
      
      
      package fr.nidalia.nidalia.common;
      
      import fr.nidalia.nidalia.proxy.ClientProxy;
      import net.minecraft.block.Block;
      import net.minecraft.block.BlockContainer;
      import net.minecraft.block.material.Material;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.entity.item.EntityItem;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.inventory.Container;
      import net.minecraft.inventory.IInventory;
      import net.minecraft.item.ItemStack;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.tileentity.TileEntityChest;
      import net.minecraft.util.MathHelper;
      import net.minecraft.world.World;
      
      public class blockCoffreShop extends Block{
      
      protected blockCoffreShop(Material material) {
      super(material);
      this.setBlockBounds(0.1F, 0, 0.1F, 0.9F, 0.8F, 0.9F);
      }
      
      @Override
      public boolean hasTileEntity(int metadata) {
      return true;
      }
      
      @Override
      public TileEntity createTileEntity(World world, int metadata) {
      return new TileEntityShop();
      
      }
         public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitx, float hity, float hitz)
         {
             if (world.isRemote)
             {
                 return true;
             }
             else
             {
      
                player.openGui(ModNidalia.instance, 0, world, x, y, z);;
                return true;
             }
         }
         public void breakBlock(World world, int x, int y, int z, Block block, int metadata)
         {
             TileEntity tileentity = (TileEntity)world.getTileEntity(x, y, z);
      
             if (tileentity instanceof IInventory)
             {
                 IInventory inv = (IInventory)tileentity;
              for (int i1 = 0; i1 < inv.getSizeInventory(); ++i1)
                 {
                     ItemStack itemstack = inv.getStackInSlot(i1);
      
                     if (itemstack != null)
                     {
                         float f = world.rand.nextFloat() * 0.8F + 0.1F;
                         float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
                         EntityItem entityitem;
      
                         for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
                         {
                             int j1 = world.rand.nextInt(21) + 10;
      
                             if (j1 > itemstack.stackSize)
                             {
                                 j1 = itemstack.stackSize;
                             }
      
                             itemstack.stackSize -= j1;
                             entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
                             float f3 = 0.05F;
                             entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3);
                             entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F);
                             entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3);
      
                             if (itemstack.hasTagCompound())
                             {
                                 entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                             }
                         }
                     }
                 }
      
                 world.func_147453_f(x, y, z, block);
             }
      
             super.breakBlock(world, x, y, z, block, metadata);
         }
      
      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 TileEntityShop)
      {
      int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 380.0F) + 2.5D) & 3;
      ((TileEntityShop)tile).setDirection((byte)direction);
      if(stack.hasDisplayName())
      {
      ((TileEntityShop)tile).setCustomName(stack.getDisplayName());
      }
      }
      }
      }
      
      public boolean isOpaqueCube()
      {
      return false;
      }
      
      public boolean renderAsNormalBlock()
      {
      return false;
      }
      
      public int getRenderType()
      {
      return ClientProxy.tesrRenderID;
      }
      
      public boolean hasComparatorInputOverride()
      {
         return true;
      }
      
      public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_)
      {
         return Container.calcRedstoneFromInventory((IInventory)p_149736_1_.getTileEntity(p_149736_2_, p_149736_3_, p_149736_4_));
      }
      public boolean onBlockEventReceived(World world, int x, int y, int z, int id, int value)
      {
         TileEntity tileentity = world.getTileEntity(x, y, z);
         return tileentity != null ? tileentity.receiveClientEvent(id, value) : false;
      }
      
      }
      

      En espérant que vous allez pouvoir m’aider !

      1 Reply Last reply Reply Quote 0
      • AymericRed
        AymericRed last edited by

        Dans ta fonction onBlockActivated, l’ouverture du gui n’est appelé que côté serveur, et comme le rendu est sur le client, ça doit être ça.

        Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

        AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

        Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
        Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

        1 Reply Last reply Reply Quote 0
        • A
          avaloon last edited by

          Le GUI fonctionne sans problème, c’est l’animation de l’ouverture du coffre et le son qui ne fonctionne pas.
           j’ai vérifié ma fonction onBlockActivated et elle est identique à celle de Robin4002

          1 Reply Last reply Reply Quote 0
          • AymericRed
            AymericRed last edited by

            Ah ok, mais ce que je me disais c’est que le serveur envoi un packet pour afficher le gui mais peut-être pas pour le rendu, mais si robin à la même chose et que ça marche. Je m’étais trompé.

            Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

            AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

            Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
            Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

            1 Reply Last reply Reply Quote 0
            • A
              avaloon last edited by

              Pas de soucis merci quand même 🙂
              je vais voir si quelqu’un a une solution 🙂

              1 Reply Last reply Reply Quote 0
              • Deleted
                Deleted last edited by

                Print la méthode qui gère l’animation dans ta classe tesr, voir si elle est bien appelée.

                1 Reply Last reply Reply Quote 0
                • A
                  avaloon last edited by

                  Si je me trompe pas c’est cela que tu veux ?

                  package fr.nidalia.nidalia.proxy;
                  
                  import cpw.mods.fml.client.registry.ClientRegistry;
                  import cpw.mods.fml.client.registry.RenderingRegistry;
                  import fr.nidalia.nidalia.client.TileEntityShopSpecialRenderer;
                  import fr.nidalia.nidalia.common.TileEntityShop;
                  import fr.nidalia.nidalia.common.blockCoffreShop;
                  import net.minecraft.client.model.ModelBiped;
                  
                  public class ClientProxy extends CommonProxy {
                  
                  public static int tesrRenderID;
                  @Override
                  public void registerRender(){
                  System.out.println("[Nidalia] ON CLIENT");
                  
                  tesrRenderID = RenderingRegistry.getNextAvailableRenderId();
                  RenderingRegistry.registerBlockHandler(new TESRInventoryRendrer());
                  ClientRegistry.bindTileEntitySpecialRenderer(TileEntityShop.class, new TileEntityShopSpecialRenderer());
                  }
                  }
                  
                  
                  1 Reply Last reply Reply Quote 0
                  • AymericRed
                    AymericRed last edited by

                    Non, je pense qu’il parle de le méthode renderTileEntityAt

                    Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                    AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                    Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                    Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

                    1 Reply Last reply Reply Quote 0
                    • Deleted
                      Deleted last edited by

                      Mais toute façon, ça m’étonnerait que ça vienne de là…Essaie de relire le tuto sinon

                      1 Reply Last reply Reply Quote 0
                      • A
                        avaloon last edited by

                        J’ai l’impression que tous le code est bon, est-ce que cela peux venir de mon schéma techne ?

                        1 Reply Last reply Reply Quote 0
                        • AymericRed
                          AymericRed last edited by

                          C’est possible, vérifie le point de rotation de ta partie qui doit bouger

                          Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                          AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                          Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                          Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

                          1 Reply Last reply Reply Quote 0
                          • A
                            avaloon last edited by

                            Je pense que c’est bon aussi.  Je ne vois pas du tout d’où cela proviens.

                            1 Reply Last reply Reply Quote 0
                            • DiabolicaTrix
                              DiabolicaTrix Correcteurs Moddeurs confirmés last edited by

                              Je ne connais pas trop les TESR et les animations, mais je crois qu’il faut que tu appelles openInventory(). Au pire, essaie de rajouter un System.out.println(). Pour voir si ta méthode est bien appelée.

                              1 Reply Last reply Reply Quote 0
                              • robin4002
                                robin4002 Moddeurs confirmés Rédacteurs Administrateurs last edited by

                                Salut,
                                Ajoutes un System.out.println(“quelque chose”); dans la fonction updateEntity du tile entity pour vérifier qu’elle est appelé.
                                Si ce n’est pas le cas vérifies que tu as enregistré l’entité de bloc.

                                Et s’il te plais, utilises la balise java. Et non une balise code dans une balise spoiler. C’est juste horrible … La balise java ajoute déjà automatiquement une barre de scroll dans c’est trop long.

                                1 Reply Last reply Reply Quote 0
                                • A
                                  avaloon last edited by

                                  Merci pour votre aide !
                                  La fonction updateEntity était bien appelée mais j’avais oublié la openInventory dans la classe du container ^^’

                                  Je penserais aux balises java la prochaine fois Robin, promis !

                                  1 Reply Last reply Reply Quote 0
                                  • 1 / 1
                                  • First post
                                    Last post
                                  Design by Woryk
                                  Contact / Mentions Légales

                                  MINECRAFT FORGE FRANCE © 2018

                                  Powered by NodeBB