Jump to content

How to change default crafting recipes and disable items in vanilla minecraft


Recommended Posts

Posted

Hi. I need help with changing vanilla minecraft default recipes and disabling items from vanilla minecraft.

I want to change in my mod entire logic of vanilla game and make custom progress system based on players progress in my mod.
Disabling item is for unlocking them after player get progress points something like in sevtech ages.

No code for now just item registers but i cant find any option to change registry with vanilla items and recipes without changing game files it self

Posted
1 hour ago, _KS_ said:

Hi. I need help with changing vanilla minecraft default recipes and disabling items from vanilla minecraft.

Replace the recipe JSONs by supplying ones with a similar name. If you want to make it such that recipes can't be crafted until a certain point, it is much simpler to create a new block that functions the same as a crafting workbench but checks the progress. You can then disable any vanilla items by making an uncraftable recipe. If you need to change how non-JSONable recipes work, there are events for those (`PotionBrewEvent$Pre`, `AnvilUpdateEvent`, etc.).

You should always avoid touching and reregistering registry objects or modifying vanilla methods as you would most likely break compatibility with any other mod. The best way is just to modify the JSONs when applicable.

  • Like 1
Posted (edited)
1 hour ago, ChampionAsh5357 said:

Replace the recipe JSONs by supplying ones with a similar name. If you want to make it such that recipes can't be crafted until a certain point, it is much simpler to create a new block that functions the same as a crafting workbench but checks the progress. You can then disable any vanilla items by making an uncraftable recipe. If you need to change how non-JSONable recipes work, there are events for those (`PotionBrewEvent$Pre`, `AnvilUpdateEvent`, etc.).

You should always avoid touching and reregistering registry objects or modifying vanilla methods as you would most likely break compatibility with any other mod. The best way is just to modify the JSONs when applicable.

Yes i know about problems with touching registry objects but i dont want to modify any of game file in assets because after uninstaling my mod this can generate problems.
About crafting table and any of blocks like anvil, etc. i made my own versions in my mod just for this purpose

I'm 100% sure i can change registry objects because i making mod to be incompatible with any other mod that adding any machines or upgrades to vanilla crafting methods

Edited by _KS_
Posted
1 hour ago, _KS_ said:

Yes i know about problems with touching registry objects but i dont want to modify any of game file in assets because after uninstaling my mod this can generate problems.

You wouldn't be modifying the game assets though? Additionally, if you want to make a mod that's backwards compatible with vanilla, I would suggest a datapack.

1 hour ago, _KS_ said:

I'm 100% sure i can change registry objects because i making mod to be incompatible with any other mod that adding any machines or upgrades to vanilla crafting methods

Sure, but I would not explain how to do it since nearly any instance of registry replacement will break the game because of all the static storages of vanilla registry objects which in most instances would cause the game to crash in some capacity. Hence, I suggested the solution above as an alternative. It would also allow you to have more compatibility with other mods if you provide an open API or create an addon that supports the mod even if you do not wish to support it.

  • Like 1
Posted
52 minutes ago, ChampionAsh5357 said:

You wouldn't be modifying the game assets though? Additionally, if you want to make a mod that's backwards compatible with vanilla, I would suggest a datapack.

Sure, but I would not explain how to do it since nearly any instance of registry replacement will break the game because of all the static storages of vanilla registry objects which in most instances would cause the game to crash in some capacity. Hence, I suggested the solution above as an alternative. It would also allow you to have more compatibility with other mods if you provide an open API or create an addon that supports the mod even if you do not wish to support it.

Ok if i good understand what u telling there.
The best idea cause of minecraft static storage is to make custom crafting table, furnace etc. to just track player progress in game.
But what with disabling items to make custom mining progress or better is to go around this and make something like this custom crafting blocks

Posted
3 hours ago, _KS_ said:

But what with disabling items to make custom mining progress or better is to go around this and make something like this custom crafting blocks

You can override any JSON, so loot tables and recipes can just be modified to handle that. You can even add a custom condition for loot tables that take in the player context such that you can check your player's progress before dropping that loot.

  • Like 1
Posted (edited)
14 hours ago, ChampionAsh5357 said:

You can override any JSON, so loot tables and recipes can just be modified to handle that. You can even add a custom condition for loot tables that take in the player context such that you can check your player's progress before dropping that loot.

What about uninstalling mod? Overriding json files can generate problem or game check control sums of files after any startup.

For safe change in game i propably need to change all loots via events to custom and make custom usable blocks

Edited by _KS_
Posted
1 hour ago, _KS_ said:

What about uninstalling mod? Overriding json files can generate problem or game check control sums of files after any startup.

How would that generate problems? It would just revert to vanilla behavior on uninstall.

  • Like 1
Posted (edited)
7 minutes ago, ChampionAsh5357 said:

How would that generate problems? It would just revert to vanilla behavior on uninstall.

 

Ok. How u want to do this.
Using just file operations or getting game variables and changing it.
Sorry for my misunderstood im new in forge coding.
I will propably do this by cancelling events and calculating my self everyting

Edited by _KS_
Posted
45 minutes ago, _KS_ said:

Sorry for my misunderstood im new in forge coding.

JSON replacement is a vanilla system using datapacks. You can modify behavior in any which way without worrying.

45 minutes ago, _KS_ said:

Ok. How u want to do this.

I've already explained above. Override recipes and loot table JSONs for changing/disabling things. If not supported, use an associated event. Since you want the recipes to be unlocked based upon the player, you will most likely need to create a new block which supports taking in the player as part of the recipe calculation.

  • Like 1
Posted (edited)
9 minutes ago, ChampionAsh5357 said:

JSON replacement is a vanilla system using datapacks. You can modify behavior in any which way without worrying.

I've already explained above. Override recipes and loot table JSONs for changing/disabling things. If not supported, use an associated event. Since you want the recipes to be unlocked based upon the player, you will most likely need to create a new block which supports taking in the player as part of the recipe calculation.

Thx i will stay with my method because now i recognize i need to change all block inventories (player too)to make my mod work correctly. Still thx so much for help 

Edited by _KS_

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello everyone, i'm new with programing Mods, and will need a lot of your help if possible,  Im trying to make a new GUI interface responsible to control the Droprate of game, it will control de loot drop and loot table for mobs and even blocks, but i try to make a simple Gui Screen, and wenever i try to use it, the game crash's with the error message in the subject, here is the code im using to:  IDE: IntelliJ Comunity - latest version Forge: 47.3.0 Minecraft version: 1.20.1 mapping_channel: parchment mapping_version=2023.09.03-1.20.1   Code im using is:    package createchronical.droprateconfig; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import java.util.HashMap; import java.util.Map; public class ConfigScreen extends Screen { private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation("droprateconfig", "textures/gui/config_background.png"); // Mapa de mobs e itens com seus respectivos drop rates private final Map<String, Integer> dropRates = new HashMap<>(); public ConfigScreen() { super(Component.literal("Configurações de Drop Rate")); // Inicializa com valores de drop rate padrão dropRates.put("Zombie", 10); // Exemplo de mob dropRates.put("Creeper", 5); // Exemplo de mob dropRates.put("Iron Ore", 50); // Exemplo de item dropRates.put("Diamond", 2); // Exemplo de item } @Override protected void init() { // Cria um botão para cada mob/item e adiciona na tela int yOffset = this.height / 2 - 100; // Posicionamento inicial for (Map.Entry<String, Integer> entry : dropRates.entrySet()) { String itemName = entry.getKey(); int dropRate = entry.getValue(); // Cria um botão para cada mob/item this.addRenderableWidget(Button.builder( Component.literal(itemName + ": " + dropRate + "%"), button -> onDropRateButtonPressed(itemName) ).bounds(this.width / 2 - 100, yOffset, 200, 20).build()); yOffset += 25; // Incrementa a posição Y para o próximo botão } // Adiciona o botão de "Salvar Configurações" this.addRenderableWidget(Button.builder(Component.literal("Salvar Configurações"), button -> onSavePressed()) .bounds(this.width / 2 - 100, yOffset, 200, 20) .build()); } private void onDropRateButtonPressed(String itemName) { // Lógica para alterar o drop rate do item/mob selecionado // Aqui, vamos apenas incrementar o valor como exemplo int currentRate = dropRates.get(itemName); dropRates.put(itemName, currentRate + 5); // Aumenta o drop rate em 5% } private void onSavePressed() { // Lógica para salvar as configurações (temporariamente apenas na memória) // Vamos apenas imprimir para verificar dropRates.forEach((item, rate) -> { System.out.println("Item: " + item + " | Novo Drop Rate: " + rate + "%"); }); // Fecha a tela após salvar Screen pGuiScreen = null; assert this.minecraft != null; this.minecraft.setScreen(pGuiScreen); } @Override public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { this.renderBackground(guiGraphics); guiGraphics.blit(BACKGROUND_TEXTURE, this.width / 2 - 128, this.height / 2 - 128, 0, 0, 256, 256, 256, 256); super.render(guiGraphics, mouseX, mouseY, partialTicks); } }  
    • Also add the latest.log from /logs/
    • I was hoping I could get some help with this weird crash. I've hosted many servers before and never had this issue. Now and then the server crashed with "Exception ticking world". Everywhere I looked I rarely found any info on it (usually found ticking entity instead). Any advice I did get (mostly from the modpack owner's discord) was "We don't know and it's near impossible to find out what it is". Here is the crash report:   Description: Exception ticking world java.util.ConcurrentModificationException     at java.util.HashMap$HashIterator.nextNode(Unknown Source)     at java.util.HashMap$KeyIterator.next(Unknown Source)     at net.minecraft.entity.EntityTracker.sendLeashedEntitiesInChunk(EntityTracker.java:386)     at net.minecraft.server.management.PlayerChunkMapEntry.sendToPlayers(PlayerChunkMapEntry.java:162)     at net.minecraft.server.management.PlayerChunkMap.tick(SourceFile:165)     at net.minecraft.world.WorldServer.tick(WorldServer.java:227)     at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:756)     at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:397)     at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668)     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)     at java.lang.Thread.run(Unknown Source)   If you want the full version, I can link a pastebin if needed. Modpack link: https://www.curseforge.com/minecraft/modpacks/multiblock-madness Some helpful information is that: It seems to only happen when I leave my void world to enter the overworld. Only happens 5-10% of the time. Only happens when leaving the void world, and only the void world. I know it's a slim chance someone could help, but it'd be greatly appreciated.
    • thanks a lot bro i knew i shouldve gone on the actual website instead of the discord
    • Minecraft Version? Reinstall Java 17 and/or Java 21 If this is still not working, run jarfix https://johann.loefflmann.net/de/software/jarfix/index.html
  • Topics

×
×
  • Create New...

Important Information

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