probleme pour creer un minerais



  • public class sapphire_ore {
    
       public sapphire_ore(){
    
       }
    
    
       public static BlockSapphire_ore block;
    
       public static Object instance;
    
       public int addFuel(ItemStack fuel) {
          return 0;
       }
    
       public void serverLoad(FMLServerStartingEvent event) {
       }
    
       public void preInit(FMLPreInitializationEvent event) {
          block.setRegistryName("sapphire_ore");
          register(block);
          register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
       }
    
       public void registerRenderers() {
       }
    
       public void load(FMLInitializationEvent event) {
          if (event.getSide() == Side.CLIENT) {
             Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
                     .register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("rainbowworld:sapphire_ore", "inventory"));
          }
       }
    
       static {
    
          block = (BlockSapphire_ore) (new BlockSapphire_ore().setHardness(7.75F).setResistance(15.0F).setLightLevel(0.0F)
                  .setUnlocalizedName("sapphire_ore").setLightOpacity(255).setCreativeTab(CreativeTabs.BUILDING_BLOCKS));
          block.setHarvestLevel("pickaxe", 2);
       }
    
       public void generateSurface(World world, java.util.Random rand, int chunkX, int chunkZ) {
          for (int i = 0; i < 5; i++) {
             int randPosX = chunkX + rand.nextInt(16);
             int randPosY = rand.nextInt(21) + 7;
             int randPosZ = chunkZ + rand.nextInt(16);
             (new WorldGenMinable(sapphire_ore.block.getDefaultState(), 4)).generate(world, rand, new BlockPos(randPosX, randPosY,
                     randPosZ));
          }
       }
    
       public void generateNether(World world, Random random, int chunkX, int chunkZ) {
       }
    
       static class BlockSapphire_ore extends Block {
    
          int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
    
          boolean red = false;
    
          protected BlockSapphire_ore() {
             super(Material.ROCK);
    
             setSoundType(SoundType.STONE);
    
          }
    
          @Override
          public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
             int i = pos.getX();
             int j = pos.getY();
             int k = pos.getZ();
             world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
    
          }
    
          @Override
          public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
             return red ? 15 : 0;
          }
    
          @Override
          public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
             return red ? 15 : 0;
          }
    
          @SideOnly(Side.CLIENT)
          @Override
          public BlockRenderLayer getBlockLayer() {
             return BlockRenderLayer.SOLID;
          }
    
          @Override
          public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
             return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
          }
    
          @Override
          public int tickRate(World world) {
             return 10;
          }
    
          @Override
          public int quantityDropped(Random par1Random) {
             return 1;
          }
    
          @Override
          public Item getItemDropped(IBlockState state, Random par2Random, int par3) {
             return new ItemStack(ModItems.sapphir).getItem();
          }
       }
    }
    

    le code complet

       public void preInit(FMLPreInitializationEvent event) {
          block.setRegistryName("sapphire_ore");
          register(block);
          register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
       }
    

    la partie qui me pose probleme c'est les register


  • Administrateurs

    Je ne sais pas du tout comment tu as pu arriver à un tel code, le mieux est de reprendre les tutoriels (présent sur le forum) depuis le début.