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

I want to make hoes which are already in Minecraft a new type of tool that can accelerate the gathering of certain blocks. In this case, straw.

 

Here's my main code:

 

 

package xergz.minecraft.medievalCivilization;

 

import java.util.Arrays;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.MapColor;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.MinecraftForge;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.Mod.PostInit;

import cpw.mods.fml.common.Mod.PreInit;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

@Mod(modid = "XergzMedievalCivilization", name = "Medieval Civilization", version = "Alpha 1.0")

@NetworkMod(clientSideRequired = true, serverSideRequired = false)

 

public class MedievalCivilization {

 

public static final Block straw = new BlockStraw(3000, 0, Material.cloth)

.setHardness(0.8F).setStepSound(Block.soundGrassFootstep)

.setBlockName("Straw").setCreativeTab(CreativeTabs.tabBlock);

 

// The instance of your mod that Forge uses.

@Instance("XergzMedievalCivilization")

public static MedievalCivilization instance;

 

// Says where the client and server 'proxy' code is loaded.

@SidedProxy(clientSide = "xergz.minecraft.medievalCivilization.client.ClientProxy", serverSide = "xergz.minecraft.medievalCivilization.CommonProxy")

public static CommonProxy proxy;

 

@PreInit

public void preInit(FMLPreInitializationEvent event){

// Stub Method

}

 

@Init

public void load(FMLInitializationEvent event){

proxy.registerRenderers();

 

MinecraftForge.setToolClass(Item.hoeWood, "hoe", 0);

MinecraftForge.setToolClass(Item.hoeStone, "hoe", 1);

MinecraftForge.setToolClass(Item.hoeSteel, "hoe", 2);

MinecraftForge.setToolClass(Item.hoeGold, "hoe", 2);

MinecraftForge.setToolClass(Item.hoeDiamond, "hoe", 3);

 

GameRegistry.registerBlock(straw, "Straw");

LanguageRegistry.addName(straw, "Straw");

MinecraftForge.setBlockHarvestLevel(straw, "hoe", 0);

 

ItemStack wheatStack = new ItemStack(Item.wheat);

ItemStack strawStack = new ItemStack(straw);

 

GameRegistry.addShapelessRecipe(strawStack,

wheatStack, wheatStack, wheatStack,

wheatStack, wheatStack, wheatStack,

wheatStack, wheatStack, wheatStack);

 

}

 

@PostInit

public void postInit(FMLPostInitializationEvent event){

// Stub Method

}

}

 

 

 

And here's my block code if ever you need it.

 

 

package xergz.minecraft.medievalCivilization;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

 

public class BlockStraw extends Block {

 

public BlockStraw(int id, int texture, Material material){

super(id, texture, material);

}

 

@Override

public String getTextureFile(){

return CommonProxy.BLOCK_PNG;

}

 

}

 

 

There is no mistake when I run it, but hoes don't accelerate the gathering of straw blocks...

 

If anyone can explain me what I'm missing in this I'd be very thankful.

Each day's a gift and not a given right, so live them all like your last.

I'm not sure since I'm on my mobile right now but I think in your hoe class you should add a method that you can find in Item.java. Not completely sure what it was called but I think it was getStrengthVsBlock(some stuff here) and I think you can then return that it is stronger when it hits your block.

  • Author

But ain't that method just returning the strength of the item? I can't modify that strenght using this... Or if I can't I don't know how.

Each day's a gift and not a given right, so live them all like your last.

  • Author

I want the existing hoes to be better to mine a block I've created.

Each day's a gift and not a given right, so live them all like your last.

Findthis package in eclipse asuming your useing that: net.minecraft.item

 

And open up the file called EnumToolMaterial.

 

This is were the tools power comes from.

 

read the NOTES under the materiel types and you should be able to change the existing tools power and durability.

 

If you need help doing that just ask.

  • Author

It wouldn't work since if I change the material strength it won't just make hoes stronger against a specific block, it's going to make every tool stronger against all blocks. And if I change that it could create incompatibilities with other mod. I'd know how to do it, but I'd have to modify  the ItemHoe class which would, again, create possible incompatibilities... I want to make it without creating any incompatibilities.

Each day's a gift and not a given right, so live them all like your last.

There is a thing called enum helper which lets you make a material in 1 line of code, you should look into it

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

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.