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

Hey all! So I'm trying to add tools based on what I learned from a tutorial.

Other code in github repo here

SO this work for regular items

Spoiler

package com.majicmaj.majcraft.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.ToolType;

public class AdamantineOre extends Block{
	
	public AdamantineOre() {
		super(Properties.create(Material.IRON)
				.sound(SoundType.METAL)
				.hardnessAndResistance(5.0f)
				//.lightValue(14)
				.harvestLevel(2)
				.harvestTool(ToolType.PICKAXE)
		);
		setRegistryName("adamantine_ore");
	}
}

 


Would you say this is an acceptable way of making a pickaxe? How can I make it better/refactor it? also, if this is the right way, how would you added the repair ingredient?
 

Spoiler

package com.majicmaj.majcraft.items;

import com.majicmaj.majcraft.Majcraft;
import com.majicmaj.majcraft.blocks.ModBlocks;

import net.minecraft.block.material.Material;
import net.minecraft.item.IItemTier;
import net.minecraft.item.Item;
import net.minecraft.item.PickaxeItem;
import net.minecraft.item.TieredItem;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.common.ToolType;

public class AdamantinePickaxe extends PickaxeItem{
	public AdamantinePickaxe() {
		super(new IItemTier() {
			
			@Override
			public Ingredient getRepairMaterial() {
				return null;
			}
			
			@Override
			public int getMaxUses() {
				return 556;
			}
			
			@Override
			public int getHarvestLevel() {
				return 3;
			}
			
			@Override
			public int getEnchantability() {
				return 5;
			}
			
			@Override
			public float getEfficiency() {
				return 6;
			}
			
			@Override
			public float getAttackDamage() {
				return 6;
			}
		},
				1,
				1.0f,
				new Item.Properties()
				.addToolType(ToolType.PICKAXE, 2)
				.maxStackSize(1)
				.group(Majcraft.setup.itemGroup));
		
		setRegistryName("adamantine_pickaxe");
	}
}

 

 

Edited by majicmaj

new PickaxeItem(...)? Seriously, you don't need to make a new class for it. Also don't make your ItemTier an anonymous class.

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
11 minutes ago, Draco18s said:

new PickaxeItem(...)? Seriously, you don't need to make a new class for it. Also don't make your ItemTier an anonymous class.

In the tutorial that I followed that showed the creation of 1 item and 1 block, he used a new class for each one and so now that I have like 10 items and a few blocks I have a class for each on... I'm guessing this is not the best way to go about it...

1 hour ago, majicmaj said:

I'm guessing this is not the best way to go about it

Usually not. The only reason to create a new class is if you need custom behavior that is different from the parent class. You want a new pickaxe. You want it to function exactly like the existing pickaxes. The only difference is the tool material (the item tier). Which is a parameter to the constructor. Passing a parameter does not require a class.

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.

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.