Jump to content

Recommended Posts

Posted

Hello  :)

 

Do you see the minecraft stat json file? (http://minecraft.gamepedia.com/Statistics) When I hit an ennemy it take sometimes more than 40 sec to update the damage count and I need it to be quicker (to update the same second I hit the mob).

 

So I Install Forge in the hope to find the part of the minecraft code that control the update rate and to change it. I install it and setup it with this tuto: http://bedrockminer.jimdo.com/modding-tutorials/#basic and every thing works fine with eclipse even if the tuto version is different than my version.

Then I looked how to access and modify the minecraft code but I can't find anything, all the tuto I found speaks of adding stuff not modifying directly minecraft code.

 

So as a noob in Forge (but not in java of course) I wonder if any of you could tell my if what I want to do is impossible (it would save me days of useless searching) or if it is simple (yes I admit I would love this answer) or if there is another way to have what I want (I just want to monitor some statistics in a external file, I don't care if it is the minecraft json stat file of a text file created by my mod).

 

If you just point me to a tuto where somebody access and change directly minecraft code it would be awesome to.

 

I use minecraft 1.10.2 with the corresponding forge version.

If it has any importance, I code the mod on windows 7 but I will use it on ubuntu 14.04

Also sorry if I made mistakes, english is not my native language.

 

 

Posted
adding stuff not modifying directly minecraft code

 

You do not modify Minecraft vanilla code.  Do not do it.  That is the wrong way to do anything.  Doing so is not Forge modding and may in fact not be compatible with any other mod.

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.

Posted

Oh I see, thank you. Too bad it would have solve my problem.

 

Then I guess there is still the solution of find a way to update my own file when a mob get damages or get killed. We can have access to this kind of information with Forge?

 

EDIT: Wait, I think I have found what I wanted: the event handler that "allow mod creators to execute their own code when certain events in Minecraft happen" (http://bedrockminer.jimdo.com/modding-tutorials/advanced-modding/event-handler/). I am on the right track right? To bad there is no description of these events because the names aren't very clear.

 

EDIT 2: Isn't that wonderfull http://www.minecraftforge.net/wiki/Event_Reference

 

 

Posted

@Epsi

 

This is ABSOLUTE basics of Forge API xD

 

Yes - you want @SubscribeEvent to LivingHurtEvent and can extract attacker from DamageSource.

Event fires on server side only!

 

Eventually there is also LivingAttackEvent or other stuff.

 

What EXACTLY are you trying to do? Describe.

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

Posted

@Epsi

 

This is ABSOLUTE basics of Forge API xD

I don't doubt it, when I say I was a Forge noob I was serious, I didn't even know its existence yesterday morning xD

 

Yes - you want @SubscribeEvent to LivingHurtEvent and can extract attacker from DamageSource.

Event fires on server side only!

 

Eventually there is also LivingAttackEvent or other stuff.

 

What EXACTLY are you trying to do? Describe.

 

Actually I'm trying to monitor four type of events: when the player receive damage, when the player inflict damage, when the player die and when the player kill a mob. Every time one of these even happened, I want a file to be update as fast as possible. I only want that in the classic offline client side. 

 

I won't have problem to create and update a file with java, I suppose I won't have problem with the event handler if I follow the tutorial (except if there were changes in envent handler between 1.8 and 1.10.2? :/), and finally I just have to find the 4 events I need. I will see the descriptions and those you mention :)

 

But what did you mean by "extract attacker from DamageSource."?

 

EDIT: LivingAttackEvent you mention and LivingDeathEvent may be what I need, but when it says "a living entity", it mean it is trigger when a mob get damage but also when the player get damage? I saw getEntity get the identity of the source of the damage but I saw nothing to get the identity of the victim...

 

EDIT2: Ok, I get it, I saw the DamageSource source field in the description of LivingAttackEvent so this is the way to get the attacker identity... However when I write

@SubscribeEvent
    public void onDamagesReceived(LivingAttackEvent e) {
	e.
    }

after e. eclipse propose me several methods like "getEntity(): Entity - EntityEvent",  "getEntityLiving(): EntityLivingBase - LivingEvent" and "getSource(): DamageSource- LivingAttackAvent". Won't one of these give me the attacker identity?

 

Posted

1. See - this is why I used "EXACTLY"...

 

As of now:

 

* Mod is client-sided.

* Data-saving is local (client files).

 

Where is my issue? "When player..." - what player? You (client) or maybe any player you see on client?

 

2. "extract attacker from DamageSource." - DamageSource ships type of damage and source of it, which can be player.

 

3. Player is also Entity. Entity = ANY, Living = Pretty much anything that has HP.

LivingEvents contain entityLiving which usually is target of event.

 

Quick EDIT:

Before you even start coding anything - please answer "1". Since we are dealing with client-sided mods things will get "different".

 

Also - when we ask "what are you after" we don't mean "What you want to do right now", but "what is your end goal". What you described can be converted to client stats-tracking mod or things like "popping out damage indicators" or pretty much anything else - to each of those you can have different approach.

 

EDIT 2: As you edit your prev post - stop digging in that shit. Answer and describe because with client-only mods some of those events are not even CALLED (are server-sided)!

1. Define goal.

2. State issues.

3. Start coding.

We don't even have 1st.

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

Posted

Ok, for 1., I want it to work only with the offline minecraft client, no server involved, so there can be only one player, me.

 

Concerning what I am after, my description was all I wanted to do with my mod. Having a quick update of these four value on a file is the only goal of this mod.

Posted

See, this (sadly) brings us to yet another design issue - sides.

 

There is a tiny difference in saying those things, but HUGE difference in their meaning:

"Client-sided Mod"

Works on SP and MP, is able to modify display, renderings, pretty much anything that you receive from server, but nothing that is actually used by the server to compute something (like damage being done).

 

"Singleplayer Mod"

Absolute HERESY since that time when Forge become side-universal API. Works only on SP, can modify pretty much anything as long as it doesn't connect to Dedicated or LAN server.

 

Now where lies biggest difference? Focus on meaning of this: "Singleplayer is Multiplayer with one player online". And here goes fact: You also have server (integrated) when you play in SP.

 

So then again - as we approach something "real" - with knowledge above, restate - what is your goal?

 

Before answering I also recommend this:

http://mcforge.readthedocs.org/en/latest/concepts/sides/

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

Posted

All right english not being my native language is not helping me with this stuff.

 

My goal is to have the mod only working into one of my computer (I don't care about mod compatibility, it's only for me) that is not even connected to the internet (thus a single player mod, but I don't get the Heresy part). I want, when I click on "Solo" and launch a world, to have a file monitoring the four events.

 

So from your link it is logical server informations on physical client I guess?

Posted

So from your link it is logical server informations on physical client I guess?

 

This is pretty much right.

 

Why heresy? Because it usually leads to retarded things and is very unstable, besides - writing stuff in non-universal way goes against everything last 3+ years has gave us in MC development. So by writing such stuff - you pretty much will only add more work to it and make it more unstable.

 

Here goes best (of worst) approach:

* Mod will handle everything on server thread and will work only on integrated server (SP).

 

1. Add clientSideOnly=true to @Mod (not required):

* Ensured mod will only ever work on Physical client, thus - the only time server thread is present - it MUST be integrated one (SP, because LAN or dedicated would mean server is elsewhere and we don't care).

 

2. Use LivingHurtEvent.

* #getEntityLiving() gives you entity that was hurt - you can use it for both "damage dealt by player" and "damage received by player".

2.1. "Damage dealt":

2.1.1. Check if event.getSource() != null && event.getSource().getEntity() instanceof EntityPlayer

2.1.2. If so - damage was dealt by some player (you).

2.2. "Damage received":

2.2.1. Check if event.getEntityLiving() instanceof EntityPlayer

2.2.2. If so - damage was dealt to some player (you).

 

3. Use LivingDeathEvent to track kills and deaths - here you will follow LITERALLY same logic as above.

* #getEntityLiving() is one dying and killer can be pulled from source.

 

4. All things above will happen on server thread, if you need them to be displayed somehow on e.g screen you should send packet to client thread (proper approach) or break every rule of sided modding and start sharing data between two threads (valid since it will be private mod, but can lead to bad stuff).

 

5. Writing to File should have its own thread in my opinion or be written only when needed (so e.g: on closing).

 

Future notes:

This mod can be easily be made universal but will require some more time to be made proper, above approach is breaking some rules and is simply bad - if you plan on modding in future, don't do it like above.

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

Posted

Awesome, it work perfectly and take about one second to update. That still a bit too much but it is far better than the 40 seconds of the normal stat file  ;D

 

Thanks Draco18s and Ernio for your time  :)

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.