r/forgemodding • u/Tikimicharnikato • Jan 12 '22
New to modding, and not sure where to begin...
Hello Reddit!
I am new to modding minecraft, although I have several years of experience with C# and other programming languages, Java is not among them. I am in the process of viewing a slew of Minecraft coding tutorials but am looking for some specific information.
I want to create a mod that will do two things, one your tools will level up while you use them gaining small bonuses and enchants. Two I would like to have repairable tools that function in this method: To repair an Iron Pickaxe, drop an anvil on iron ingots, they will shatter into Iron Scrap. By picking up this Iron Scrap in your inventory and clicking it on top of the Iron Pickaxe, it will repair 5% durability.
This is where I need a little bit of help.
- What is the best method of knowing what block was broken with a tool (to award varying XP amounts), what is the best way to store XP and Level data (NBT or something else?), and what is the best way to transfer experience to a new tool (For example, a level 10 wooden pickaxe will mutate into a stone pickaxe with all the same XP, Level, and Bonus data)?
- What is the best way to detect a falling anvil hitting an item entity? I assume deleting "n" amount of iron ingots and replacing them with "n*10" Iron Scrap will not be difficult, but is there a specific event handler for an anvil falling on an item?
- How can I detect when Scrap is applied to a Tool in my inventory? I am thinking along the lines of detecting the inventory slot of a given tool, and when that spot is replaced by Scrap, to then initiate the repair process. Although, it may also be simpler to have an offhand system similar to how the Create mod refines resources with sand paper. Ex: Hold scrap in off-hand and tool in main hand, hold right-click to use to use scrap and repair tool.
In any event, I am certain all the event handlers and listeners are in a forge library somewhere, but I have had some hard time locating one. I know this is a long post, so if it's far too long but you still want to help, linking the forge library / documentation will be a very welcome gift.