Jump to content

Recommended Posts

Posted

Hi i'm new to modding and i require a bit of help, everything is explained in Professions topic in mods section. Link to GitHub

 

[sOLVED] Herbalism:

 

 

  Reveal hidden contents

 

Posted

What exactly do you need help with? The people on this forum are not going to code your mod for you if that's what you're asking.

Posted

"I'm currently having problems with Fishing (don't know how to check if player is fishing and if player fished anything), Herbalism (don't know how to check if wheat is fully grown)"

Posted

Oh, sorry, my bad. For some reason I didn't see that.

Posted

As for Herbalism - I belive the "age" of crop (includes wheat) is its metadata.

 

EDIT

"I belive..." == "It is"

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted

I tried checking if metadata is 7 but it still adds exp event if it isn't

 

 

  Reveal hidden contents

 

 

This isn't only way i checked but still doesn't work.

 

Posted

@Failender

I fixed that alredy but diesieben07 said i shouldn't use getMetaFromState so i am experimenting again.

 

  Quote
Never ever call getMetaFromState yourself. Interact with the IBlockState, it's there so that you don't have to work with stupid magic numbers (7) anymore.

The age is stored in the property BlockCrops.AGE.

 

@diesieben70

Can you explain why i shouldn't use getMetaFromState ? I also modified if statement, but not sure if it's correct way to do it. Don't really understand how Block States work.

 

 

  Reveal hidden contents

 

Posted

I am beginner programmer so i don't know much but i'm learning.

 

Here is another try:

 

  Reveal hidden contents

 

 

This way it works as intended but idk if it's considered right or wrong programming.

Posted
  On 7/7/2015 at 1:41 PM, diesieben07 said:

That looks fine as far as the block state handling goes.

 

Is there anything else that needs to be handled or done ?

Posted
  On 7/7/2015 at 2:51 PM, diesieben07 said:

Well, the "Professions.herbalism" makes me suspicious whether you actually handle the fact that there is more than one player.

 

I don't ... which classes should i check to see how it's done ?

Btw i added github link

 

also do i need to initiate save of players current exp and level on server  or world exit or is it automatic, i guess it's not ?

Posted

Okay i finished implementing IExtendedEntityProperties, is this alright:

 

Profession.java

 

  Reveal hidden contents

 

ProfEvents.java

 

  Reveal hidden contents

 

 

Professions is init class for all professions...

 

Professions

 

  Reveal hidden contents

 

Posted

Is this what you mean ?

 

  Reveal hidden contents

 

 

Also should i use datawatchers for exp and level or no ?

 

EDIT: no need for datawatchers cause players wont need to know about other player exp or level.

 

EDIT:

ProfEvent class

 

  Reveal hidden contents

 

 

do i need to cast event.player and event.getPlayer() to (EntityPlayer), seeing as they are already players i think they shouldn't.

Posted

No, that's not right.

 

Lemme explain. There is some EntityPlayer. Each living entity has a map looking +/- like this Map<KeyToProps, IEEP>.

You can assign class you create that inplements IEEP to given entity (by putting it into that map) - that happens in construction event - you literally assign "additional" "storage" (called IEEP) to given player.

 

Now - in that storage you can hold ANY kind of data. it doesn't need to be even saved to disk. It can be really anything - object, variable, object iwth other objects. Then if you decide - you can save it to given entity's NBT.

 

That's whole logic behind it.

 

Now - profession is something that is assigned to PLAYER, not all players. That's what you need to do - you need to make fields in your IEEP class that will hold profession data about given player.

 

Design you can do: (nice and readable)

 

EntityPlayer

--> ProfessionsMap implements IEEP

-----> Herbalism extends Profession

-----> Mining extends Profession

-----> Combat extends Profession.

 

Where "Profession" would be an object that holds data about specific profession for given player.

Then you can load/save that data using  load/saveNBTData(...).

 

P.S

I wonder how your code (one you posted in last post) is not givng OutOfMemeory. Unless it does (you are literally making infinite number of "Profession" there).

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted

Thanks for help, but before i can finish this project i should read more tutorials on java so i have base knowledge of java. I understand what you are saying but don't know how to fully implement it, so i will start with simpler things.

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.