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

    Solved Probleme de chaise

    1.7.x
    1.7.2
    3
    5
    1134
    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.
    • BurningCraft
      BurningCraft last edited by

      Bijour, tout le monde

      Je Vient de Crée une chaise sans problème, j’ai réussi a faire en sorte que l’on puisse s’assoir mais le problème c’est que on vole sur la chaise XD, notre perso s’assoie en haut de la HitBox de la chaise

      Un petit Screen:
      http://www.noelshack.com/2015-52-1450709519-2015-12-21-15-51-25.png

      es-que quelqu’un aurait une solution pour que le joueur se place bien sur la chaise et pas au dessus X)

      La Class du bloc:

      package fr.burning.lfc.blocks;
      
      import java.util.List;
      
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import fr.burning.lfc.lib.ProxyClient;
      import fr.burning.lfc.tile.EntityChaiseSittable;
      import fr.burning.lfc.tile.TileEntityChaise;
      import net.minecraft.block.Block;
      import net.minecraft.block.material.Material;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.item.ItemStack;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.util.AxisAlignedBB;
      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 Chaise extends Block
      {
          private IIcon top, bottom;
      
          public Chaise(int i, Material material)
          {
              super(material);
      
              this.setBlockName("Chaise");
          }
      
          public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
          {
              return sitPlayer(world, x, y, z, player, 1.0F);
          }
      
          public static boolean sitPlayer(World world, int x, int y, int z, EntityPlayer player, float entityY)
          {
              return sitPlayer(world, x, y, z, player, 0.5F, entityY, 0.5F);
          }
      
          public static boolean sitPlayer(World world, int x, int y, int z, EntityPlayer player, float entityX, float entityY, float entityZ)
          {
              if(!world.isRemote)
              {
                  List <entitychaisesittable>listEMB = world.getEntitiesWithinAABB(EntityChaiseSittable.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D).expand(1.0D, 1.0D, 1.0D));
                  for(EntityChaiseSittable entitytocheck : listEMB)
                  {
                      if((entitytocheck.blockPosX == x) && (entitytocheck.blockPosY == y) && (entitytocheck.blockPosZ == z))
                      {
                          entitytocheck.interact(player);
                          return true;
                      }
                  }
      
                  EntityChaiseSittable entity = new EntityChaiseSittable(world, player, x, y, z, x + entityX, y + entityY, z + entityZ);
                  world.spawnEntityInWorld(entity);
                  entity.interact(player);
              }
              return true;
          }
      
          //–-----------
          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 TileEntityChaise)
                  {
                      int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
                      ((TileEntityChaise)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 TileEntityChaise)
                       {
                           TileEntityChaise tileTuto = (TileEntityChaise)tile;
      
                          byte direction = tileTuto.getDirection();
                         direction++;
                         if(direction > 3)
                           {
      
                              direction = 0;
                           }
      
                          tileTuto.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;
              }
      
            @Override
              public TileEntity createTileEntity(World world, int metadata)
              {
                  return new TileEntityChaise();
              }
      
              @Override
              public boolean hasTileEntity(int metadata)
              {
                  return true;
              }
      
              public boolean isOpaqueCube()
              {
                  return false;
              }
      
              public boolean renderAsNormalBlock()
              {
                  return false;
              }
      
              @SideOnly(Side.CLIENT)
              public int getRenderType()
              {
                  return ProxyClient.tesrRenderId;
              }
      
              public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
              {
                  this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.2F, 1.0F);
              }
      
      }
      
      

      L’entity du bloc

      package fr.burning.lfc.tile;
      
      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 TileEntityChaise 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);
      
                }
      
            }
      
      

      [size=largeLa Class EntityChaiseSittable]

      package fr.burning.lfc.tile;
      
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.world.World;
      
      public class EntityChaiseSittable extends Entity
      {
          public int blockPosX;
          public int blockPosY;
          public int blockPosZ;
      
          public EntityChaiseSittable(World world)
          {
              super(world);
              this.noClip = true;
              this.preventEntitySpawning = true;
              this.setSize(0.0F, 0.0F);
          }
      
          public EntityChaiseSittable(World world, EntityPlayer entityplayer, int x, int y, int z, float entityX, float entityY, float entityZ)
          {
              this(world);
              this.blockPosX = x;
              this.blockPosY = y;
              this.blockPosZ = z;
              this.setPosition(entityX, entityY, entityZ);
          }
      
          public boolean interact(EntityPlayer entityplayer)
          {
              if(this.riddenByEntity != null)
              {
                  return true;
              }
      
              if(!this.worldObj.isRemote)
              {
                  entityplayer.mountEntity(this);
              }
              return true;
          }
      
          public void onEntityUpdate()
          {
              if(this.riddenByEntity == null || this.riddenByEntity.isDead)
              {
                  this.setDead();
              }
              super.onEntityUpdate();
          }
      
          @Override
          public void readEntityFromNBT(NBTTagCompound compound)
          {
              this.blockPosX = compound.getInteger("blockPosX");
              this.blockPosY = compound.getInteger("blockPosY");
              this.blockPosZ = compound.getInteger("blockPosZ");
          }
      
          @Override
          public void writeEntityToNBT(NBTTagCompound compound)
          {
              compound.setInteger("blockPosX", this.blockPosX);
              compound.setInteger("blockPosY", this.blockPosY);
              compound.setInteger("blockPosZ", this.blockPosZ);
          }
      
          @Override
          protected void entityInit()
          {
      
          }
      }
      
      ```</entitychaisesittable>
      1 Reply Last reply Reply Quote 0
      • Folgansky
        Folgansky Correcteurs last edited by

        public double getMountedYOffset()
            {
                return (double)this.height + 0.35D;
            } 
        

        Tu mets plus ou moins la valeur que tu veux après.

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

          @‘Toutoune1008’:

          public double getMountedYOffset()
              {
                  return (double)this.height + 0.35D;
              } 
          

          Tu mets plus ou moins la valeur que tu veux après.

          j’ai mis ça dans la class du bloc et il me met une erreur sur le

          this.height
          

          je pourrais le remplacer par quoi ?

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

            Il faut mettre la fonction dans la classe l’entité (EntityChaiseSittable)

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

              @‘robin4002’:

              Il faut mettre la fonction dans la classe l’entité (EntityChaiseSittable)

              Ha oui sa marche mieux XD merci 🙂

              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