Jump to content

Recommended Posts

Posted

Hello. I just added a tool to my mod, and I set the attack damage and attack speed, but when I launch the game and grab the item, it has no attributes, as if it were just a basic item. Here are the classes I used:

 

package bloopers.spearmod.items;

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.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class ItemPrimitiveSpearTool extends ItemTool
{
    private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(new Block[] {Blocks.SPONGE});

    public ItemPrimitiveSpearTool(Item.ToolMaterial material)
    {
        super(1.5F, -3.0F, material, EFFECTIVE_ON);
    }
}

 

package bloopers.spearmod.items;

import net.minecraft.item.Item;

public class ItemPrimitiveSpear extends Item {

public ItemPrimitiveSpear(ToolMaterial material) {
	this.setMaxStackSize(1);
}
}

 

And then my item init class:

package bloopers.spearmod.init;

import bloopers.spearmod.items.ItemPrimitiveSpear;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class SpearItems {

/**********|DECLARE|**********/
public static ItemPrimitiveSpear primitive_spear;

public static final Item.ToolMaterial primitive = EnumHelper.addToolMaterial("primitive", 1, 300, 6.0F, 1.0F, 1);


public static void init() {
/*********************************|INIT ITEMS|***************************************/
	//primitive_spear = new ItemPrimitiveSpear(primitive);

	primitive_spear = (ItemPrimitiveSpear)(new ItemPrimitiveSpear(primitive).setUnlocalizedName("primitive_spear"));

}
/***********************************************************************************/

public static void register() {	
/*********************************|REGISTER ITEMS|***************************************/
primitive_spear.setRegistryName("primitive_spear");
GameRegistry.register(primitive_spear);	

}
/***********************************************************************************/

public static void registerRenders() {
/*********************************|RENDER ITEMS|***************************************/
registerRender(primitive_spear);

}
/***********************************************************************************/


private static void registerRender(Item item) {
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,
			new ModelResourceLocation("spear" + ":" + item.getUnlocalizedName()
			.substring(5), "inventory"));
}
}

Posted

package bloopers.spearmod.items;

import net.minecraft.item.Item;

public class ItemPrimitiveSpear extends Item // I wonder why it doesn't have any modifiers // {

public ItemPrimitiveSpear(ToolMaterial material) {
	this.setMaxStackSize(1);
}
}

 

 

 

And then my item init class:

package bloopers.spearmod.init;

import bloopers.spearmod.items.ItemPrimitiveSpear;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class SpearItems {

/**********|DECLARE|**********/
public static ItemPrimitiveSpear primitive_spear;

public static final Item.ToolMaterial primitive = EnumHelper.addToolMaterial("primitive", 1, 300, 6.0F, 1.0F, 1);


public static void init() {
/*********************************|INIT ITEMS|***************************************/
	//primitive_spear = new ItemPrimitiveSpear(primitive);

	primitive_spear = (ItemPrimitiveSpear)(new ItemPrimitiveSpear(primitive).setUnlocalizedName("primitive_spear"));

}
/***********************************************************************************/

public static void register() {	
/*********************************|REGISTER ITEMS|***************************************/
primitive_spear.setRegistryName("primitive_spear");
GameRegistry.register(primitive_spear);	

}
/***********************************************************************************/

public static void registerRenders() {
/*********************************|RENDER ITEMS|***************************************/
registerRender(primitive_spear);

}
/***********************************************************************************/


private static void registerRender(Item item) {
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,
			new ModelResourceLocation("spear" + ":" + item.getUnlocalizedName()
			.substring(5), "inventory"));
}
}

 

Do not use Minecraft.getMinecraft.getRenderItem().getItemModelMesher() just use ModelLoader.setCustomModelResourceLocation(...)

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Why do you have this

ItemPrimitiveSpearTool

class which you never use?

Why do you have this

ToolMaterial

parameter in the

ItemPrimitiveSpear

constructor, which you never do anything with? What did you expect this to do?

Oh! I meant to have ItemPrimitiveSpear extend ItemPrimitiveSpearTool. Do I not even need the ItemPrimitiveSpearTool class?

 

I expect ToolMaterial to be able to set the durability, enchantability etc using the "primitive" tool material that I have, in the SpearItems class.

Posted

Why do you have this

ItemPrimitiveSpearTool

class which you never use?

Why do you have this

ToolMaterial

parameter in the

ItemPrimitiveSpear

constructor, which you never do anything with? What did you expect this to do?

Oh! I meant to have ItemPrimitiveSpear extend ItemPrimitiveSpearTool. Do I not even need the ItemPrimitiveSpearTool class?

 

I expect ToolMaterial to be able to set the durability, enchantability etc using the "primitive" tool material that I have, in the SpearItems class.

You do not unless it has a special effect like throwing.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Okay. I deleted ItemPrimitiveSpearTool and put all of the stuff like EFFECTIVE_ON, and the damage and speed into one class and the item works fine now. Thank you both!

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
    • Maybe you need to create file in assets/<modid>/items/<itemname>.json with content like this:   { "model": { "type": "minecraft:model", "model": "modname:item/itemname" } }  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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