Jump to content

Recommended Posts

Posted

Hello Everyone,

 

I am just a new modder in the scene, however it seems my ItemAxe Util isn't working and I can't for the life of me understand why it wouldn't be working,

the swordutil, spadeutil, and the pickaxeutil all work perfectly, while the ItemAxe is throwing an error on startup. Here's some code below, any help would

be appreciated! Thanks!

 

package com.demonly.netherexpansion.util.tools;

import net.minecraft.item.ItemAxe;

public class AxeUtil extends ItemAxe {

public AxeUtil(ToolMaterial material) {
	super(material);
}

}

 

package com.demonly.netherexpansion.init;

import java.rmi.registry.Registry;

import com.demonly.netherexpansion.Reference;
import com.demonly.netherexpansion.util.tools.AxeUtil;
import com.demonly.netherexpansion.util.tools.PickaxeUtil;
import com.demonly.netherexpansion.util.tools.SpadeUtil;
import com.demonly.netherexpansion.util.tools.SwordUtil;

import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class NetherItems {

public static SwordUtil nesword;
public static SwordUtil bone_sword;
public static PickaxeUtil bone_pickaxe;
public static SpadeUtil bone_shovel;
public static AxeUtil bone_axe;

public static ToolMaterial bone = EnumHelper.addToolMaterial("Bone", 3, 150, 4.9F, 2.3F, 14);

public static void init() {

	//This is building the Item Framework

	//Nether Sword - Build
	nesword = (SwordUtil) new SwordUtil(bone).setUnlocalizedName("nesword");
	nesword.isDamageable();
	nesword.setMaxStackSize(1);
	nesword.setMaxDamage(20);

	//Bone Tools - Build
	bone_sword = (SwordUtil) new SwordUtil(bone).setUnlocalizedName("bone_sword");
	bone_pickaxe = (PickaxeUtil) new PickaxeUtil(bone).setUnlocalizedName("bone_pickaxe");
	bone_shovel = (SpadeUtil) new SpadeUtil(bone).setUnlocalizedName("bone_shovel");
	bone_axe = (AxeUtil) new AxeUtil(bone).setUnlocalizedName("bone_axe");
}

public static void register() {

	//This is registering the ("Item")
	GameRegistry.registerItem(nesword, nesword.getUnlocalizedName().substring(5));

	GameRegistry.registerItem(bone_sword, bone_sword.getUnlocalizedName().substring(5));
	GameRegistry.registerItem(bone_pickaxe, bone_pickaxe.getUnlocalizedName().substring(5));
	GameRegistry.registerItem(bone_shovel, bone_shovel.getUnlocalizedName().substring(5));
	GameRegistry.registerItem(bone_axe, bone_axe.getUnlocalizedName().substring(5));

}

public static void registerRenders() {

	//This is registering the Render of the ("Item")
	registerRender(nesword);

	registerRender(bone_sword);
	registerRender(bone_pickaxe);
	registerRender(bone_shovel);
	registerRender(bone_axe);

}

public static void registerRender(Item item) {

	//This is registering the rendering of items.
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().
	register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + 
	item.getUnlocalizedName().substring(5), "inventory"));

}


}

 

 

Any help is appreciated!

 

UPDATE:

Forgot to include the launcher error:

java.lang.ArrayIndexOutOfBoundsException: 5
at net.minecraft.item.ItemAxe.<init>(SourceFile:32)
at com.demonly.netherexpansion.util.tools.AxeUtil.<init>(AxeUtil.java:
at com.demonly.netherexpansion.init.NetherItems.init(NetherItems.java:48)
at com.demonly.netherexpansion.NetherExpansion.preInit(NetherExpansion.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:560)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:228)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:206)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:556)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:240)
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:434)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:346)
at net.minecraft.client.main.Main.main(SourceFile:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

Posted

Had the same problem i now i fixed it with this axeutil class

 

 

import java.util.Set;

import com.google.common.collect.Sets;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;

public class Axe extends ItemTool {

private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(new Block[] {Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin, Blocks.melon_block, Blocks.ladder, Blocks.wooden_button, Blocks.wooden_pressure_plate});
    
public Axe(ToolMaterial material) {
	super(material, EFFECTIVE_ON);
        this.damageVsEntity = material.getDamageVsEntity();
        this.attackSpeed = -3.0F;
	// TODO Auto-generated constructor stub
}

public float getStrVsBlock(ItemStack stack, IBlockState state)
    {
        Material material = state.getMaterial();
        return material != Material.wood && material != Material.plants && material != Material.vine ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial;
    }

}

Posted

Had the same problem i now i fixed it with this axeutil class

 

 

import java.util.Set;

import com.google.common.collect.Sets;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;

public class Axe extends ItemTool {

private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(new Block[] {Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin, Blocks.melon_block, Blocks.ladder, Blocks.wooden_button, Blocks.wooden_pressure_plate});
    
public Axe(ToolMaterial material) {
	super(material, EFFECTIVE_ON);
        this.damageVsEntity = material.getDamageVsEntity();
        this.attackSpeed = -3.0F;
	// TODO Auto-generated constructor stub
}

public float getStrVsBlock(ItemStack stack, IBlockState state)
    {
        Material material = state.getMaterial();
        return material != Material.wood && material != Material.plants && material != Material.vine ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial;
    }

}

 

Thanks! This worked perfectly. 1+ Rep

Posted

ItemAxe

can no longer be used with custom

ToolMaterial

s due to hardcoding the attack damage/speed for each

ToolMaterial

and using the

ToolMaterial

's ordinal as an array index. See this issue for more details and an explanation of what the current plans to fix this are.

 

In the meantime, extend

ItemTool

and use

Item#setHarvestLevel

to set the tool class to

"axe"

and the harvest level to the

ToolMaterial

's harvest level.

 

Some issues with your code that aren't directly related to axes:

 

Use the new

GameRegistry.register

method instead of

GameRegistry.registerItem

/

registerBlock

. If you can't see it, update Forge.

 

Don't use unlocalised names as registry names, the registry name methods were introduced in 1.8.9 to stop people doing that. If an

Item

should have the same registry and unlocalised names, set the registry name (

IForgeRegistryEntry#setRegistryName

or one of the overloads from

IForgeRegistryEntry.Impl

) and then set the unlocalised name to the full registry name (

IForgeRegistryEntry#getRegistryName

). This also applies to

Block

s.

 

As an example,

setRegistryName("foo"); setUnlocalizedName(getRegistryName().toString())

results in the registry name being

modid:foo

and the full unlocalised name being

item.modid:foo.name

. Most of my mod's

Item

s use this method to set their registry and unlocalised names, but some have completely separate registry and unlocalised names that they set manually (e.g. records).

 

Don't use

ItemModelMesher#register

to register models, use

ModelLoader.setCustomModelResourceLocation

/

setCustomMeshDefinition

in preInit.

 

Don't use unlocalised names for model registration. The default model for every

Item

is the one with its registry name.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

ItemAxe

can no longer be used with custom

ToolMaterial

s due to hardcoding the attack damage/speed for each

ToolMaterial

and using the

ToolMaterial

's ordinal as an array index. See this issue for more details and an explanation of what the current plans to fix this are.

 

In the meantime, extend

ItemTool

and use

Item#setHarvestLevel

to set the tool class to

"axe"

and the harvest level to the

ToolMaterial

's harvest level.

 

Some issues with your code that aren't directly related to axes:

 

Use the new

GameRegistry.register

method instead of

GameRegistry.registerItem

/

registerBlock

. If you can't see it, update Forge.

 

Don't use unlocalised names as registry names, the registry name methods were introduced in 1.8.9 to stop people doing that. If an

Item

should have the same registry and unlocalised names, set the registry name (

IForgeRegistryEntry#setRegistryName

or one of the overloads from

IForgeRegistryEntry.Impl

) and then set the unlocalised name to the full registry name (

IForgeRegistryEntry#getRegistryName

). This also applies to

Block

s.

 

As an example,

setRegistryName("foo"); setUnlocalizedName(getRegistryName().toString())

results in the registry name being

modid:foo

and the full unlocalised name being

item.modid:foo.name

. Most of my mod's

Item

s use this method to set their registry and unlocalised names, but some have completely separate registry and unlocalised names that they set manually (e.g. records).

 

Don't use

ItemModelMesher#register

to register models, use

ModelLoader.setCustomModelResourceLocation

/

setCustomMeshDefinition

in preInit.

 

Don't use unlocalised names for model registration. The default model for every

Item

is the one with its registry name.

 

Thank you, I know I'm new haha. Following a variety of tutorials from text - video - mrcrashfish - x.

Much appreciated!

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.

Announcements



×
×
  • Create New...

Important Information

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