Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.15.2] Edit Minecraft Source Code or, more simply, hooks
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
WildTan

[1.15.2] Edit Minecraft Source Code or, more simply, hooks

By WildTan, September 20, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted September 20, 2020

How can I do that? I saw an example in one of your Forge repositories, but cannot find it again. There it was based on json....

  • Quote

Share this post


Link to post
Share on other sites

Beethoven92    69

Beethoven92

Beethoven92    69

  • Dragon Slayer
  • Beethoven92
  • Members
  • 69
  • 556 posts
Posted September 20, 2020

You should not want to modify minecraft source code...i think access transformers is what you are referring to. Those lets you change the accessibility of class members. Is that what you are searching for?

  • Quote

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

A little fun project: https://www.curseforge.com/minecraft/mc-mods/two-players-one-horse

Share this post


Link to post
Share on other sites

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted September 21, 2020

I need to add my own events to minectaft. I cant do it without hooks.

  • Quote

Share this post


Link to post
Share on other sites

LexManos    1616

LexManos

LexManos    1616

  • Reality Controller
  • LexManos
  • Forge Code God
  • 1616
  • 8922 posts
Posted September 21, 2020

Core modding, is not encouraged or endorsed on this forum.

Forge is designed to give you the hooks you need.

If it doesn't you should think about what you're trying to do, talk to the others in the community, and work together to come up with a solution that can be integrated into Forge.

  • Quote

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

Share this post


Link to post
Share on other sites

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted September 21, 2020 (edited)

Ok, for example food eating event. It will be necessary for making unusual food. I need ItemStack, Food and player in 1 place to do it. I saw similar idea, but with method in discord - 115

Edited September 21, 2020 by WildTan
  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2401

Draco18s

Draco18s    2401

  • Reality Controller
  • Draco18s
  • Members
  • 2401
  • 15917 posts
Posted September 21, 2020

Uh, Item#onItemUseFinish? The Food property is part of the Item class, all Item class methods accept an ItemStack parameter, and a LivingEntity paramter.

  • Quote

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.

Share this post


Link to post
Share on other sites

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted September 21, 2020 (edited)

And how do you propose to change the amount of hunger restored? See what kind of stack and remove or add the required amount? And that about things of other mods?

Edited September 21, 2020 by WildTan
  • Quote

Share this post


Link to post
Share on other sites

Beethoven92    69

Beethoven92

Beethoven92    69

  • Dragon Slayer
  • Beethoven92
  • Members
  • 69
  • 556 posts
Posted September 21, 2020
Food.Builder().hunger(hunger_bars_restored_number)

This is a thing ^^^, and also all the other operations you mentioned are already possibile. What are you exactly trying to do?

  • Quote

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

A little fun project: https://www.curseforge.com/minecraft/mc-mods/two-players-one-horse

Share this post


Link to post
Share on other sites

Draco18s    2401

Draco18s

Draco18s    2401

  • Reality Controller
  • Draco18s
  • Members
  • 2401
  • 15917 posts
Posted September 21, 2020
1 hour ago, WildTan said:

And how do you propose to change the amount of hunger restored?

Gosh, if only Vanilla had some differentiation in how much hunger vanilla food restored you could go look at those food stats...

 

  • Quote

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.

Share this post


Link to post
Share on other sites

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted September 22, 2020
7 hours ago, Beethoven92 said:

Food.Builder().hunger(hunger_bars_restored_number)

This is a thing ^^^, and also all the other operations you mentioned are already possibile. What are you exactly trying to do?

For example: I've tried making salt. It increases the amount of hunger restored by 2.

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2401

Draco18s

Draco18s    2401

  • Reality Controller
  • Draco18s
  • Members
  • 2401
  • 15917 posts
Posted September 22, 2020 (edited)
1 minute ago, WildTan said:

It increases the amount of hunger restored by 2.

Increases the amount of hunger restored of what item?

Edited September 22, 2020 by Draco18s
  • Quote

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.

Share this post


Link to post
Share on other sites

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted September 22, 2020 (edited)

Sorry for my language. Increases thу count of hunger gived by eating some food.

Edited September 22, 2020 by WildTan
  • Quote

Share this post


Link to post
Share on other sites

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted September 22, 2020 (edited)
7 minutes ago, Draco18s said:

what item?

Any salted (only ItemFood can be salted)

Edited September 22, 2020 by WildTan
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7581

diesieben07

diesieben07    7581

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7581
  • 54884 posts
Posted September 22, 2020

First of all, ItemFood is no longer a thing.

 

Then you need a new item which is able to contain any other item and represents it's "salted" form. You can use Item#getFood to get an item's food information (if any - although this might not be accurate for modded items, as they might do a custom system) and you can then use that to apply an increased saturation, etc.

  • Quote

Share this post


Link to post
Share on other sites

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted October 24, 2020
On 9/22/2020 at 10:03 AM, diesieben07 said:

item's food information

How i can verify what item is salted without itemstack?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7581

diesieben07

diesieben07    7581

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7581
  • 54884 posts
Posted October 26, 2020
On 10/24/2020 at 9:04 AM, WildTan said:

How i can verify what item is salted without itemstack?

You cannot. Why do you not have the ItemStack?

  • Quote

Share this post


Link to post
Share on other sites

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted October 27, 2020 (edited)

Item#getFood does not contain it. I can not get it from there.

Edited October 27, 2020 by WildTan
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7581

diesieben07

diesieben07    7581

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7581
  • 54884 posts
Posted October 27, 2020

Then override onItemRightClick where you do have it.

  • Quote

Share this post


Link to post
Share on other sites

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted October 28, 2020 (edited)
How do you imagine that? Yes, I can determine whether the item is salted or not, but how can I use it THERE? Should I write my entire food system or what? It sounds like a bicycle.
 
Edited October 28, 2020 by WildTan
  • Quote

Share this post


Link to post
Share on other sites

DavidM    179

DavidM

DavidM    179

  • World Shaper
  • DavidM
  • Members
  • 179
  • 1821 posts
Posted October 28, 2020

Personally, I would say that in this case it would be appropriate to add a hook for the eating event if there isn't already one, as editing food behaviors seems like quite a common feature. You can submit a PR to the Forge repo on GitHub with an adequate solution.

  • Like 1
  • Quote

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Share this post


Link to post
Share on other sites

diesieben07    7581

diesieben07

diesieben07    7581

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7581
  • 54884 posts
Posted October 28, 2020

Item#onItemRightClick is a very short method, so is onItemUseFinish. You can easily change these so that your food is stack-specific.

But yes, you could make a PR to forge.

  • Quote

Share this post


Link to post
Share on other sites

WildTan    1

WildTan

WildTan    1

  • Tree Puncher
  • WildTan
  • Members
  • 1
  • 40 posts
Posted January 4

PR  has already been there for a long time, why hasn't it been accepted yet?

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • kmann383
      Forge 35.1.37 crashes when i hit escape key

      By kmann383 · Posted 18 minutes ago

      ok thanks for the help, i suck at stuff like this
    • cadbane86140
      Minecraft: Creative Episode 22- Ben's Birthday Celebration!

      By cadbane86140 · Posted 22 minutes ago

      Hello There! Today we are back on Creative and this isn't no ordinary Creative episode, we are celebrating Ben's birthday! We wanted to make this video just to show our thanks to him for all his help and support with videos! There are actually so many hilarious moments in this video that I know you guys are gonna love! I hope you all enjoy this video and if you did don't forget to like and sub for more!  
    • LexManos
      why the files website did go down

      By LexManos · Posted 26 minutes ago

      No, you should always download Forge from our site: https://files.minecraftforge.net/ If its down for you then it's something on your end. As its been running just fine.
    • LexManos
      Forge 35.1.37 crashes when i hit escape key

      By LexManos · Posted 27 minutes ago

      `    at com._idrae.travelers_index.client.gui.OpenIndexButtonHandler.onGuiInit(OpenIndexButtonHandler.java:27) ~[?:1.15.2-1.0.1] {re:classloading}` Travelers index is broken.
    • BentiGorlich
      [1.16.4] Advanced Blockstate

      By BentiGorlich · Posted 37 minutes ago

      Any further advice would be appreciated
  • Topics

    • kmann383
      2
      Forge 35.1.37 crashes when i hit escape key

      By kmann383
      Started 2 hours ago

    • cadbane86140
      0
      Minecraft: Creative Episode 22- Ben's Birthday Celebration!

      By cadbane86140
      Started 22 minutes ago

    • LevelNaomi
      3
      why the files website did go down

      By LevelNaomi
      Started Tuesday at 04:25 PM

    • BentiGorlich
      3
      [1.16.4] Advanced Blockstate

      By BentiGorlich
      Started 20 hours ago

    • BentiGorlich
      17
      [1.16.4] Change Texture onBlockActivated

      By BentiGorlich
      Started Yesterday at 03:41 PM

  • Who's Online (See full list)

    • SwiftNinjaPro
    • Dunks1916
    • st4s1k
    • GenElectrovise
    • gottsch
    • Cheesepotato?
    • Lellian
    • kmann383
    • Shrayzz
    • cadbane86140
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.15.2] Edit Minecraft Source Code or, more simply, hooks
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community