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

    Un siége

    Sans suite
    4
    9
    2031
    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.
    • Nolan-XX
      Nolan-XX dernière édition par

      Après avoir passé une bonne demi-heure a modéliser mon siège ( non j’abconne 5 min ), j’aimerais bien que l’on puisse s’assoir via un clique droit dessus. Sans plus tarder voila le code :

      package assets.city01.Blocks;
      
      import net.minecraft.block.BlockContainer;
      import net.minecraft.block.material.Material;
      import net.minecraft.client.renderer.texture.IconRegister;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.item.ItemStack;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.util.AxisAlignedBB;
      import net.minecraft.util.Icon;
      import net.minecraft.util.MathHelper;
      import net.minecraft.world.IBlockAccess;
      import net.minecraft.world.World;
      import assets.city01.Data.ClientProxy;
      import assets.city01.Data.HL2;
      import assets.city01.TileEntity.TileEntitySiege;
      import assets.city01.TileEntity.TileEntitySiege;
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      
      public class B_Siege extends BlockContainer {
      private Icon icontop, iconbottom, iconfront;
      
      public B_Siege(int par1) {
      super(par1, Material.wood);
      this.setCreativeTab(HL2.Tab);
      
      }
      
      /*
      * public void registerIcons(IconRegister iconRegister) { blockIcon =
      * iconRegister.registerIcon("city01:nope"); iconfront =
      * iconRegister.registerIcon("city01:a"); icontop =
      * iconRegister.registerIcon("city01:b"); iconbottom =
      * iconRegister.registerIcon("city01:c"); }
      */
      
      public void registerIcons(IconRegister iconregister) {
      icontop = iconregister.registerIcon("city01:nope");
      iconbottom = iconregister.registerIcon("city01:nope");
      iconfront = iconregister.registerIcon("city01:nope");
      
      }
      
      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;
      TileEntity te = world.getBlockTileEntity(x, y, z);
      if (te != null && stack.getItemDamage() == 2
      && te instanceof TileEntitySiege) {
      ((TileEntitySiege) te).setDirection((byte) direction);
      world.markBlockForUpdate(x, y, z);
      }
      }
      
      @SideOnly(Side.CLIENT)
      public Icon getIcon(int side, int metadata) {
      /*
      * return side == 1 ? this.icontop : (side == 0 ? this.iconbottom :
      * (metadata == 2 && side == 2 ? this.iconfront : (metadata == 3 && side
      * == 5 ? this.iconfront : (metadata == 0 && side == 3 ? this.iconfront
      * : (metadata == 1 && side == 4 ? this.iconfront : this.blockIcon)))));
      */
      
      return blockIcon;
      }
      
      @Override
      public TileEntity createNewTileEntity(World world) {
      return new TileEntitySiege();
      }
      
      public boolean renderAsNormalBlock() {
      return false;
      }
      
      public boolean isOpaqueCube() {
      return false;
      }
      
      @SideOnly(Side.CLIENT)
      public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x,
      int y, int z) {
      return AxisAlignedBB.getAABBPool().getAABB(
      (double) x + this.minX , (double) y + this.minY,
      (double) z + this.minZ , (double) x + this.maxX ,
      (double) y + this.maxY , (double) z + this.maxZ );
      }
      
      public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x,
      int y, int z) {
      return AxisAlignedBB.getAABBPool().getAABB(
      (double) x + this.minX , (double) y + this.minY,
      (double) z + this.minZ , (double) x + this.maxX ,
      (double) y + this.maxY , (double) z + this.maxZ );
      }
      
      @SideOnly(Side.CLIENT)
      public int getRenderType() {
      return ClientProxy.renderInventoryTESRId;
      }
      
      @SideOnly(Side.CLIENT)
      public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z,
      int side) {
      TileEntity te = blockAccess.getBlockTileEntity(x, y, z);
      if (te != null && te instanceof TileEntitySiege) {
      TileEntitySiege panneau = (TileEntitySiege) te;
      int direction = panneau.getDirection();
      
      }
      return this.getIcon(side, blockAccess.getBlockMetadata(x, y, z));
      }
      
      }
      

      Merci d’avance.

      1 réponse Dernière réponse Répondre Citer 0
      • Superloup10
        Superloup10 Modérateurs dernière édition par

        Je pense que le mieux, c’est de faire une entity pour que tu puisses asseoir le joueur. Pour le code, tu peux regardé les class du bateau, du wagon, ou du cheval.

        Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

        Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

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

          onBlockActivated. Et après, je plussoie ce de Superloup10 à dit.

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

            J’avais déjà fait une chaise, le mieux est de faire une entité qui meurt au bout de 20 ticks si personne n’est dessus, et qui spawn lors d’un click droit sur la chaise.

            "If you have a comprehensive explanation for everything then it decreases uncertainty and anxiety and reduces your cognitive load. And if you can use that simplifying algorithm to put yourself on the side of moral virtue then you’re constantly a good person with a minimum of effort."
            ― Jordan B. Peterson

            1 réponse Dernière réponse Répondre Citer 0
            • Nolan-XX
              Nolan-XX dernière édition par

              
              package assets.city01.Entity;
              
              import net.minecraft.entity.Entity;
              import net.minecraft.entity.player.EntityPlayer;
              import net.minecraft.nbt.NBTTagCompound;
              import net.minecraft.world.World;
              
              public class EntitySitable extends Entity {
              
              public static int Timer;
              
              public EntitySitable(World par1World) {
              super(par1World);
              
              }
              
              @Override
              protected void entityInit()
              {
              Timer = 0;
              }
              
              @Override
              protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {
              
              }
              
              @Override
              protected void writeEntityToNBT(NBTTagCompound nbttagcompound) {
              
              }
              
              public boolean interactFirst(EntityPlayer par1EntityPlayer)
              {
              if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer)
              {
              return true;
              }
              else
              {
              if (!this.worldObj.isRemote)
              {
              par1EntityPlayer.mountEntity(this);
              Timer = 0;
              }
              
              return true;
              }
              }
              
              public void onEntityUpdate(EntityPlayer par1EntityPlayer)
              {
              if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer)
              {
              Timer += 1;
              }
              
              if(Timer == 20)
              {
              this.setDead;
              }
              }
              
              }
              
              

              J’ai une erreur sur le

              this.setDead;
              

              C’est le bon morceau de code ou je dois en mettre un autre ?

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

                C’est une méthode setDead ^^

                setDead();

                Et Timer est une variable, selon la convention Java, pas de majuscule ^^

                "If you have a comprehensive explanation for everything then it decreases uncertainty and anxiety and reduces your cognitive load. And if you can use that simplifying algorithm to put yourself on the side of moral virtue then you’re constantly a good person with a minimum of effort."
                ― Jordan B. Peterson

                1 réponse Dernière réponse Répondre Citer 0
                • Nolan-XX
                  Nolan-XX dernière édition par

                  
                  public void onBlockActivated(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
                  {
                  EntitySitable Entity = new EntitySitable(world);
                  Entity.setLocationAndAngles(x, y, z, 0, 0.0F);
                  world.spawnEntityInWorld(Entity);
                  }
                  
                  

                  Dans ma classe du block, aucun effet lorsque j’appuie dessus.

                  L’entité :

                  package assets.city01.Entity;
                  
                  import net.minecraft.entity.Entity;
                  import net.minecraft.entity.player.EntityPlayer;
                  import net.minecraft.nbt.NBTTagCompound;
                  import net.minecraft.world.World;
                  
                  public class EntitySitable extends Entity {
                  
                  public static int timer;
                  
                  public EntitySitable(World par1World) {
                  super(par1World);
                  
                  }
                  
                  @Override
                  protected void entityInit()
                  {
                  timer = 0;
                  }
                  
                  @Override
                  protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {
                  
                  }
                  
                  @Override
                  protected void writeEntityToNBT(NBTTagCompound nbttagcompound) {
                  
                  }
                  
                  public boolean interactFirst(EntityPlayer par1EntityPlayer)
                  {
                  if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer)
                  {
                  return true;
                  }
                  else
                  {
                  if (!this.worldObj.isRemote)
                  {
                  par1EntityPlayer.mountEntity(this);
                  timer = 0;
                  }
                  
                  return true;
                  }
                  }
                  
                  public void onEntityUpdate(EntityPlayer par1EntityPlayer)
                  {
                  if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer)
                  {
                  timer += 1;
                  }
                  
                  if(timer == 20)
                  {
                  setDead();
                  }
                  }
                  
                  }
                  
                  1 réponse Dernière réponse Répondre Citer 0
                  • robin4002
                    robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par

                    j’aurai mit player.mountEntity(Entity); à la fin du onBlockActivated.

                    1 réponse Dernière réponse Répondre Citer 0
                    • Nolan-XX
                      Nolan-XX dernière édition par

                      ça ne change rien.

                      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