Jump to content

Need help creating a new type of tool


Xergz

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.