Jump to content

[1.13.2] Some forge questions from a novice


Torq

Recommended Posts

Hello, I am new to the development of mods and I occasionally have questions. Perhaps they are stupid or something else, but I can not find some answer. English is not my native language, so I use a translator and there may be some errors. Most likely I will write additional questions here and I hope this topic will help someone. I also have plans to help with documentation and lessons, but for this I need to learn Forge.


1) How to add to the block the level of the tool used? I mean that the ore added by me could be mined with a pick not lower than iron. In the tool, this is set to ItemTier. I saw something similar at the end of the Block class and in ForgeHooks class.
2) How can I disable, delete or change vanilla blocks.
3) How can I make an intermediate advancement? For example, to have a copper pick between a stone pick and an iron ingot. How do I add opening recipes for this advancement? For example, how to open iron tools and armor after receiving an iron ingot.

4) How can I make my recipes go to the correct tabs in the recipe book? net.minecraft.client.util.RecipeBookClient
5) Can I just redefine some classes and somehow integrate them into the game, replacing the original ones? This would solve many problems.

I am a beginner and therefore it is difficult for me to understand how forge works, mainly due to the lack of documentation and the small amount of comments to the code.  Forge 1.13.2 is already sufficient to develop mods or I misunderstood and it is just being developed? This would explain the lack of simple and clear interfaces, factories and classes for the rapid development of modifications. Or maybe I'm blind and do not see (not understand) how to use Forge. I will be glad to receive any answer. For example, a link to an article, class, or at least a hint. If you add code samples or an explanation, it will be just fine.
 

Spoiler

source code of my first mod added



 

src.zip

Edited by Torq

If I helped you, don't forget like. I'm using a translator, sorry.

Link to comment
Share on other sites

5 hours ago, Torq said:

I am a beginner and therefore it is difficult for me to understand how forge works, mainly due to the lack of documentation and the small amount of comments to the code.  Forge 1.13.2 is already sufficient to develop mods or I misunderstood and it is just being developed? This would explain the lack of simple and clear interfaces, factories and classes for the rapid development of modifications. Or maybe I'm blind and do not see (not understand) how to use Forge. I will be glad to receive any answer. For example, a link to an article, class, or at least a hint. If you add code samples or an explanation, it will be just fine.

Forge for 1.13.2 is mostly done. However, Forge is built on top of Mojang’s minecraft code which doesn’t have “simple and clear interfaces, factories and classes for the rapid development of modifications”. Minecraft is not built with modding in mind at all and doesn’t have any code related to mods at all. Forge has many of these things though like event subscribing and Modder-friendly extensions to the vanilla system (like registries & capabilities). The documentation for vanilla methods is usually lacking or non-existent, but Forges methods are usually well documented. The Forge documentation (at https://mcforge.readthedocs.io/en/latest) hasn’t been (fully) updated for 1.13.2 yet. The Forge team is mostly focussed on fixing major bugs in 1.13 and preparing for 1.14. 

 

5 hours ago, Torq said:

 

  Reveal hidden contents

source code of my first mod added



 

src.zip

In future please upload your code as a working GitHub repository. People on these forums are unlikely to download random files from people they don’t know, and people on mobile can’t open zip files. 

Edited by Cadiboo
Fixed link
  • Like 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Thank you, you have explained a lot. I haven't made a repository yet, but I'm working on it. Nevertheless, I think it is worthwhile to work on the classes, factories and interfaces (at least basic ones) inside Forge. If only because the Block class is the horror of the engineer. The remaining questions are still relevant, I will try to study myself how Forge and Minecraft work, but you can speed up this process.

If I helped you, don't forget like. I'm using a translator, sorry.

Link to comment
Share on other sites

12 hours ago, Torq said:

1) How to add to the block the level of the tool used? I mean that the ore added by me could be mined with a pick not lower than iron. In the tool, this is set to ItemTier. I saw something similar at the end of the Block class and in ForgeHooks class.

Override Block#getHarvestLevel.

 

13 hours ago, Torq said:

 2) How can I disable, delete or change vanilla blocks.

Override their entries in the blocks registry by registering a new block with the same registry name as the old one. This works with many registries, not just blocks.

However do consider using events before doing this. Overriding blocks won't really work well if multiple mods are overriding the same block. Maybe an event can do what you want.

 

13 hours ago, Torq said:

 3) How can I make an intermediate advancement? For example, to have a copper pick between a stone pick and an iron ingot. How do I add opening recipes for this advancement? For example, how to open iron tools and armor after receiving an iron ingot.

 

https://minecraft.gamepedia.com/Advancements#JSON_Format

Forge doesn't change the way datapacks register advancements or much about them really. You would do the same things you would when making a datapack.

 

Can't actually answer #4 since i've never really worked with the recipe book, but I don't think many players care since pretty much everybody uses JEI anyway. In theory it should assign a recipe to a tab based on the creative tab of the resulting item.

 

13 hours ago, Torq said:

5) Can I just redefine some classes and somehow integrate them into the game, replacing the original ones? This would solve many problems.

It is possible, but not with that mindset. It is a very invasive way that creates a ton of compatibility issues and is not going to be supported here. Use forge events or if something can't be acheived by an event/registry override/inserting other object into a field consider making a PR instead.

  • Like 1
Link to comment
Share on other sites

Thanks for answers.

I tried to insert advancement between vanilla advancement, but in the advancement menu I had 2 copies of advancement each. Vanilla and mine, but wrong, because One of my advancement got attached to vanilla. I thought it would be possible for me to override advancement if I write the same name, but the game loads two options, from minecraft and mod. There is a hunch that i need to find where minecraft stores these values and try to do something about it. But maybe I’m wrong again and there is a better way.

smelt_iron.json

Spoiler

{
  "parent": "torqmod:story/copper_tools",
  "display": {
    "icon": {
      "item": "minecraft:iron_ingot"
    },
    "title": {
      "translate": "advancements.story.smelt_iron.title"
    },
    "description": {
      "translate": "advancements.story.smelt_iron.description"
    },
    "frame": "task",
    "show_toast": true,
    "announce_to_chat": true,
    "hidden": false
  },
  "criteria": {
    "iron": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "minecraft:iron_ingot"
          }
        ]
      }
    }
  },
  "requirements": [
    [
      "iron"
    ]
  ]
}

 

iron_tools.json

Spoiler

{
  "parent": "minecraft:story/smelt_iron",
  "display": {
    "icon": {
      "item": "minecraft:iron_pickaxe"
    },
    "title": {
      "translate": "advancements.story.iron_tools.title"
    },
    "description": {
      "translate": "advancements.story.iron_tools.description"
    },
    "frame": "task",
    "show_toast": true,
    "announce_to_chat": true,
    "hidden": false
  },
  "criteria": {
    "iron_pickaxe": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "minecraft:iron_pickaxe"
          }
        ]
      }
    }
  },
  "requirements": [
    [
      "iron_pickaxe"
    ]
  ]
}

 

 

At the expense of question 5, I agree that this is a very aggressive way of solving a problem and it will cause a lot of problems in the work of the game itself. I realized this when I began to analyze possible examples of this approach. What is pr?

If I helped you, don't forget like. I'm using a translator, sorry.

Link to comment
Share on other sites

7 minutes ago, Torq said:

I thought it would be possible for me to override advancement if I write the same name, but the game loads two options

Override it by overriding the entry in the datapack. Bascially have a datapack with the modid of minecraft provided by your mod that overrides that one specific advancement.

 

8 minutes ago, Torq said:

What is pr?

Pull Request

Link to comment
Share on other sites

1 hour ago, V0idWa1k3r said:

Override it by overriding the entry in the datapack. Bascially have a datapack with the modid of minecraft provided by your mod that overrides that one specific advancement.

You want to say that this functionality already exists, I just do not know about it and therefore did not use it? I do not fully understand because of the language. You mean a specific parameter that I write in my advancment. Will it cancel vanilla advancment?

 

*update
I need to make the minecraft folder (in resources\data) , where should I put the redefinable advancement? Will there be problems with other mods that override advancement?

 

Edited by Torq

If I helped you, don't forget like. I'm using a translator, sorry.

Link to comment
Share on other sites

12 hours ago, V0idWa1k3r said:

Override Block#getHarvestLevel.

Should I constantly override Block # getHarvestLevel? And if I have 15 blocks and all have different levels? Should I do 15 classes? If I understand correctly, then harvestLevel is private so that programmers cannot change the blocks in the registry. But do I understand correctly that I must now redefine getHarvestLevel to all classes from net.minecraft.block? For example, if I want to create my own block of each type from vanilla minecraft? Am I already starting to write my library so that I would not override these types for every reason? Or is it not so gloomy? I just do not want to make a separate class for each block, as some mods do.

Edited by Torq

If I helped you, don't forget like. I'm using a translator, sorry.

Link to comment
Share on other sites

18 minutes ago, Torq said:

Should I constantly override Block # getHarvestLevel? And if I have 15 blocks and all have different levels? Should I do 15 classes?

Not necessarily, but yes, that would work. 

(There are only 4 or 5 actually levels in vanilla, but that's quibbling)

18 minutes ago, Torq said:

For example, if I want to create my own block of each type from vanilla minecraft?

What do you mean? 

18 minutes ago, Torq said:

Am I already starting to write my library so that I would not override these types for every reason? Or is it not so gloomy? I just do not want to make a separate class for each block, as some mods do.

You can reuse classes, you're just creating new instances with different data. For example, both the vanilla stick and iron ingots ate both instances of the Item class. They don't have a ItemStick or ItemIronIngot classes. 

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.

Link to comment
Share on other sites

20 minutes ago, Draco18s said:

What do you mean? 

For example, I made 10 ItemTier (0-3 wood-diamond 4-13 my). I need to make all the blocks of each type (BlockClay, BlockGlowstone and other) from vanilla minecraft and set harvestLevel (private) to them. I need to override getHarvestTool () and getHarvestLevel () + add two fields to return values (and maybe even properties and a new constructor with these fields). To do this, I will need to inherit (duplicate) all classes in the mod and make such changes in each one. If I understand what I am offered to do.

 

upd*
I can override Block and rewrite everything else, inheriting from Block, but then ModBlockGlowstone! = BlockGlowstone, although they will be exactly the same. That's why I say that I will have to override every class in net.minecraft.block

Edited by Torq

If I helped you, don't forget like. I'm using a translator, sorry.

Link to comment
Share on other sites

2 hours ago, Torq said:

I can override Block and rewrite everything else, inheriting from Block, but then ModBlockGlowstone! = BlockGlowstone, although they will be exactly the same. That's why I say that I will have to override every class in net.minecraft.block

BlockGlowstone inherits the method from Block because it extends it. You can override it just fine while still extending BlockGlowstone

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

9 hours ago, Cadiboo said:

BlockGlowstone inherits the method from Block because it extends it. You can override it just fine while still extending BlockGlowstone

I'm writing that I should inherit all the classes in net.minecraft.block and override each of them getHarvestLevel () and getHarvestTool (). And I will have a package with the same classes, but with overridden methods. There it is written over these methods // TODO: RE-Evaluate, where can I see what should be done with them?

 

upd*

I would like to use the standard classes if they suit me, but I still have to inherit for each type of block. I want to be inherited only in order to expand the block, and not to set the type and level of the tool, this is some kind of garbage. Can I solve this problem differently?

Edited by Torq

If I helped you, don't forget like. I'm using a translator, sorry.

Link to comment
Share on other sites

Do I have to do this for every class in net.minecraft.block?

Spoiler

package torq.torqmod.block;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockOre;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;

/**
 * 
 * 
 * @author torq
 * @version 0.1
 */
public class ModBlockOre extends BlockOre {

	public int harvestLevel = 3;
	public ToolType toolType = ToolType.PICKAXE;

	public ModBlockOre(Block.Properties builder) {
		super(builder);
	}

	@Override
	public IItemProvider getItemDropped(IBlockState state, World worldIn, BlockPos pos, int fortune) {
		return (IItemProvider) this;
	}

	@Override
	public int quantityDropped(IBlockState state, Random random) {
		return 1;
	}

	@Override
	public int getHarvestLevel(IBlockState state) {
		return harvestLevel;
	}

	@Override
	public ToolType getHarvestTool(IBlockState state) {
		return toolType;
	}
}

 

 

Edited by Torq

If I helped you, don't forget like. I'm using a translator, sorry.

Link to comment
Share on other sites

2 hours ago, Torq said:

Do I have to do this for every class in net.minecraft.block?

  Reveal hidden contents


package torq.torqmod.block;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockOre;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;

/**
 * 
 * 
 * @author torq
 * @version 0.1
 */
public class ModBlockOre extends BlockOre {

	public int harvestLevel = 3;
	public ToolType toolType = ToolType.PICKAXE;

	public ModBlockOre(Block.Properties builder) {
		super(builder);
	}

	@Override
	public IItemProvider getItemDropped(IBlockState state, World worldIn, BlockPos pos, int fortune) {
		return (IItemProvider) this;
	}

	@Override
	public int quantityDropped(IBlockState state, Random random) {
		return 1;
	}

	@Override
	public int getHarvestLevel(IBlockState state) {
		return harvestLevel;
	}

	@Override
	public ToolType getHarvestTool(IBlockState state) {
		return toolType;
	}
}

 

 

No. Can you please clarify what you’re trying to do again? 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

51 minutes ago, Cadiboo said:

No. Can you please clarify what you’re trying to do again? 

I have written the same thing several times. I have vanilla block classes. I want to make my object for each type (in order to study each type). I want to assign them harvestLevel and toolType, and they are private! I was told to override getHarvestLevel() and getToolType(). I have to duplicate all classes from net.minecraft.block (like ModBlock extend Block, ModBlockGlowstone extend BlockGlowstone, ModBlockClay extend BlockClay and all others) and override them with getHarvestLevel () and getToolType (). If I want (and I WANT) to use these classes to create all the objects and not to create 100 classes of blocks for each case (harvestLevel = 1,2,3,4 and toolType = axe, pickaxe and other), I will have to endure my classes in the library, override some of the methods and private them (which are deprecated), make normal constructors taking into account the new harvestLevel and toolType and can add some methods (for example setHarvestLevel() and setToolType() ) for the convenience of using these classes. So, I have to do this or have an option where I can normally set harvestLevel and toolType without overriding methods. Or maybe all the same the Forge team plans to make this mechanism normal for use?

 

upd*
Why do I want to inherit every class? What would be compatibility with vanilla types. Therefore, I wrote:

15 hours ago, Torq said:

I can override Block and rewrite everything else, inheriting from Block, but then ModBlockGlowstone! = BlockGlowstone, although they will be exactly the same. That's why I say that I will have to override every class in net.minecraft.block

I repeat the question. Should I make a library for modders (for myself), so that I would have my overridden classes that are fully compatible with net.minecraft.block, but with normal class constructors and private methods (which are depricated and will be deleted)? Although it will be necessary to look, they are not used anywhere other than the class itself and there already to think what to do with them.
What I want to do is normal, or not? Does this make sense or will the Forge team add it? Or maybe there is already something similar? Or it makes no sense, because it will not work or will the update come out and everything will break?

 
Or would it be better to inherit from "extends net.minecraftforge.registries.ForgeRegistryEntry <Block> implements IItemProvider, net.minecraftforge.common.extensions.IForgeBlock" and rewrite all other types, but without inheriting the garbage code? But I am afraid to imagine what will come of it and whether the game mechanisms will work normally. Forge type registries are Block, so this option is most likely not suitable.
 
Edited by Torq

If I helped you, don't forget like. I'm using a translator, sorry.

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.