Jump to content

Crash when initializing a block


The_Brook

Recommended Posts

Hi !

I'm making a mod for the first time and I have some problems when initializing a block. In the crash report, it's said it has been caused an item. I don't understand why.

The crash report is attached to the post.

Thank you for your help !

The block class :

public class BlockCryingObsidian extends BlockBase {
    
    public BlockCryingObsidian(String name, Material material) {
        super(name, material);
        
        setSoundType(SoundType.STONE);
        setLightLevel(5);
        setHardness(25.0F);
    }

    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
        boolean activate = true;
            if(playerIn.experienceLevel >= 10 || playerIn.isCreative()) {
                
                playerIn.addExperienceLevel(-10);
                playerIn.setSpawnPoint(playerIn.getPosition(), true);
                worldIn.playSound(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.BLOCK_NOTE_CHIME, SoundCategory.BLOCKS, 0.5F, 1F);
                
                double rx = pos.getX() + worldIn.rand.nextFloat();
                double ry = pos.getY() + worldIn.rand.nextFloat();
                double rz = pos.getZ() + worldIn.rand.nextFloat();
                for(int i = 0; i <= 50; i++) {
                    worldIn.spawnParticle(EnumParticleTypes.TOTEM, rx, ry, rz, worldIn.rand.nextFloat(), worldIn.rand.nextFloat(), worldIn.rand.nextFloat());
                    worldIn.spawnParticle(EnumParticleTypes.TOTEM, rx, ry, rz, -worldIn.rand.nextFloat(), worldIn.rand.nextFloat(), -worldIn.rand.nextFloat());
                }
                
            } else {

                worldIn.playSound(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.BLOCK_WOOD_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.5F, 1F);
                activate = false;
            }
            
            return activate;
    }

}

The item class

public class ItemXPInfusedAxe extends ItemAxe {
    
    public static int MIN_XP_ORBS = 1;
    public static int MAX_XP_ORBS = 3;

    public ItemXPInfusedAxe() {
        this(AstreaAPI.infusedIngotToolMaterial, AstreaNames.XP_INFUSED_AXE);
    }

    public ItemXPInfusedAxe(ToolMaterial toolMaterial, String name) {
        super(toolMaterial);
        setCreativeTab(AstreaTab.INSTANCE);
        setRegistryName(new ResourceLocation(Reference.MOD_ID, name));
    }
    
    @Override
    public boolean onBlockDestroyed(@Nonnull ItemStack stack, @Nonnull World world, @Nonnull IBlockState state, @Nonnull BlockPos pos, @Nonnull EntityLivingBase entity) {
        if(state.getBlockHardness(world, pos) != 0F) {
            ToolCommons.damageItem(stack, 1, entity);
        }
        if (world.isRemote) {
            for (int i = 0 ; i < 10 ; i++) {
                world.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f, world.rand.nextGaussian() / 3.0f, world.rand.nextGaussian() / 3.0f, world.rand.nextGaussian() / 3.0f);
            }
        }
        return true;
    }
    
}

 

crash-2018-04-13_21.25.10-client.txt

Edited by The_Brook
Link to comment
Share on other sites

Caused by: java.lang.ArrayIndexOutOfBoundsException: 5

  at BlockBase.java:24

 

You have not posted this code.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Yeah, sorry I forgot...

public class BlockBase extends Block implements IHasModel {
    
    public BlockBase(String name, Material material) {
        super(material);
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(AstreaTab.INSTANCE);
        
        ModBlocks.BLOCKS.add(this);
        ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
    }

    @Override
    public void registerModels() {
        
        Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
        
    }

}

 

Link to comment
Share on other sites

...and which line is like 24?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

13 minutes ago, The_Brook said:

This one


ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));

 

That line cannot cause that error.

Post your entire mod, preferably on a complete git repository, so I can run it.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I do not get the indicated problem.

2018-04-13_15.27.48.png

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.