Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

  • Author

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");
        
    }

}

 

...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.

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.

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.

  • Author

Actually I made the problematic class not used so it wasn't crashing when I was coding other things. Now, you should have the same problem on GitHub.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.