Jump to content

1.2.5/1.3.2/1.4


Moritz

Recommended Posts

How should i start?

 

I am working on a Mod which is replaceing all Tools (Pickaxe, Axe, Shovel, Hoe) in the game with mine.

And i am nearly finishing my mod.

But i am Stuck at my damage System, because there is no code like this

 

 

 

public void tryHarvestBlock(ItemStack par1, Block par2, EntityPlayer par3)

{

// This code should detect if a block get mined. and should updated every 2 ticks.

}

 

 

 

 

Now my problem. I have the idea for the code. But i am to much noob to write it myself.

Now the question.

Can someone write me a code like this which will be activated when a block tries to get harvested?

and if not, is it Possible to make a function like this?

 

Thanks for reading.

 

Link to comment
Share on other sites

Use the newest version,

1.25 to 1.3 required mods to be rewritten, so unless you like doing things twice there is no point in back dating.

 

you'll want to use the event system

 

net.minecraftforge.event.entity.player.AttackEntityEvent;

net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;

net.minecraftforge.event.entity.player.PlayerEvent.HarvestCheck;

 

AttackEntityEvent will allow you to edit how much damage a weapon does.

 

HarvestCheck returns true if the current tool can harvest the block and false otherwise

BreakSpeed sets how fast a harvest-able block can be broken with the current tool

 

 

 

AtomicStryker has an Events HowTo:

http://www.minecraftforum.net/topic/1419836-forge-4x-events-howto/

 

 

Other helpful links:

http://www.minecraftforge.net/wiki/Tutorials

http://www.minecraftforge.net/wiki/Tutorials/Upgrading_To_Forge_for_1.3.1

 

 

Link to comment
Share on other sites

How should i start?

 

I am working on a Mod which is replaceing all Tools (Pickaxe, Axe, Shovel, Hoe) in the game with mine.

And i am nearly finishing my mod.

But i am Stuck at my damage System, because there is no code like this

 

 

 

public void tryHarvestBlock(ItemStack par1, Block par2, EntityPlayer par3)

{

// This code should detect if a block get mined. and should updated every 2 ticks.

}

 

 

 

 

Now my problem. I have the idea for the code. But i am to much noob to write it myself.

Now the question.

Can someone write me a code like this which will be activated when a block tries to get harvested?

and if not, is it Possible to make a function like this?

 

Thanks for reading.

This is not required. The proper way to do this now is by doing:

MinecraftForge.setToolClass(Item item, String toolclass, int harvestlevel)

 

The vanilla tool classes are: "shovel" "axe" "pickaxe". Also, many mods like to check the "sword" tool class to see if another mod added their sword there, although this is not vanilla, just a polite thing to do to help other mods work with yours more easily, it is nice to register it as such. 1 line that can give you free interoperability with another mod.

Link to comment
Share on other sites

Sorry for this now. :( But you are Stupid!!!

 

I do not ask for a function which make tools to tools.

 

I asked for a function which make it possible to make counts at the moment when you are breaking a block.

if you are using public boolean onBlockDistroyed(....)

than its only 1 count but my damage SYSTEM needs more than 1 count...

 

if you mine a block like obsidian it needs about 5 seconds. and every second you mine the tool should get damage that was my idea..

Here:

diamondpickaxe

 

9999 dirt mined = 0 damage.

25 cobblestone mined = 5 damage

5 Gold ore Mined = 5 Damage

1 Obsidian Mined = 5 Damage

 

and not like this

 

mod file:

 

public void load()

{

MinecraftForge.registerToolClass(diamondPickaxe, "pickaxe", 3);

}

 

 

why did i write this?

 

public void tryHarvestBlock(ItemStack par1, Block par2, EntityPlayer par3)

{

// This code should detect if a block get mined. and should updated every 2 ticks.

}

 

This code should detect if a block gets mined (when the damage pictures on a block comes) and this function can be used for count something. and this function i need.... thats why i called tryharvestBlock and not StrVsBlock.

 

sry for the stupid but i must say that for that answer....

Link to comment
Share on other sites

Take a closer look at the events I gave you, one will do what you want.

It provides the player and  block. It also gets called the entire time the block is being broken.

As for the held item goes, once you have the player getting that is very easy.

 

 

Oh and running others down results in less people willing to help, and if done enough no one will help with future problems.

Link to comment
Share on other sites

Sorry for this now. :( But you are Stupid!!!

 

I do not ask for a function which make tools to tools.

 

I asked for a function which make it possible to make counts at the moment when you are breaking a block.

if you are using public boolean onBlockDistroyed(....)

than its only 1 count but my damage SYSTEM needs more than 1 count...

 

if you mine a block like obsidian it needs about 5 seconds. and every second you mine the tool should get damage that was my idea..

Here:

diamondpickaxe

 

9999 dirt mined = 0 damage.

25 cobblestone mined = 5 damage

5 Gold ore Mined = 5 Damage

1 Obsidian Mined = 5 Damage

 

and not like this

 

mod file:

 

public void load()

{

MinecraftForge.registerToolClass(diamondPickaxe, "pickaxe", 3);

}

 

 

why did i write this?

 

public void tryHarvestBlock(ItemStack par1, Block par2, EntityPlayer par3)

{

// This code should detect if a block get mined. and should updated every 2 ticks.

}

 

This code should detect if a block gets mined (when the damage pictures on a block comes) and this function can be used for count something. and this function i need.... thats why i called tryharvestBlock and not StrVsBlock.

 

sry for the stupid but i must say that for that answer....

 

Look at your original post and tell me WHERE it says you need to do more than tell a block when it should be harvestable(the damn old hook you linked yourself).

Now my problem. I have the idea for the code. But i am to much noob to write it myself.

Now the question.

Can someone write me a code like this which will be activated when a block tries to get harvested?

and if not, is it Possible to make a function like this?

I guess everyone who is not psychic are stupid? How on earth are we to know exactly what you are trying to hook there...

 

Whatever, this attitude will not get you help from anyone.

Link to comment
Share on other sites

i should come much more online.. Sry for say Stuipid. I didn´t understood your answer and how ever. Sorry. I found a way to make it but i had to change it a little bit..

 

and im still on 1.2.5. Because its the version i can work with and having workspace there (workspace = Ice i can walk on it without breaking in).

 

but thanks for the answering. i have to learn more about java. bevor i start this kinda damage system which detecting Block and Material of the Block.

im now off and try to make my mod without helping (thats the best idea. i read only sources from other mods and try to learn from them.)

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.