Jump to content

Recommended Posts

Posted

Basically, I want to change a vanilla recipe to use slightly different ingredients. Many other solutions to this problem use this event:

@SubscribeEvent
public static void RegistryRecipe(RegistryEvent.Register<IRecipe> event){
    //remove recipe entry
}

 

However, this gives an error: " Type parameter 'net.minecraft.item.crafting.IRecipe' is not within its bound; should extend 'net.minecraftforge.registries.IForgeRegistryEntry<net.minecraft.item.crafting.IRecipe>' " So I believe this has changed in version 1.16. Additionally the Forge Documentation (1.15.x) states this should work. I am wondering if there is any way to do this now, or if it has changed to some other way, or maybe I am doing something wrong? Thanks!

 

Posted (edited)

I believe you mean just placing a .json file into the recipes folder. If I try to override the recipe by placing an edited .json of the same name into resources/data/minecraft/recipes nothing changes. If I put it into resources/data/mod-id/recipes it adds the recipe so both the vanilla and modded way works. I know my /minecraft folder works because I have successfully overridden a loot table there. I do have a number of non-datapack features in my mod if that makes any difference. 

Edited by NathaFred
typos
Posted

Okay so I figured it out. Maybe this is the normal way of doing it, but I don't know. The name of the recipe .json file doesn't matter since the output item is stated inside the .json. This way you create two files, one to override the old recipe and another with the updated recipe. The override recipe is identical to the vanilla one but with an output of air. Also both recipies must be in the resources/data/mod-id/recipes folder not the /minecraft folder. 

 

Please correct me if this isn't the best way to do this, but it works.

Posted
19 minutes ago, NathaFred said:

The name of the recipe .json file doesn't matter

One of them should name-match (I recommend the one that has the desired output, name the other one something like "{original}_override" or "{original}_dummy"). If for nothing else than so people know what it's for.

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

Yes that's true.On a very related subject, the problem now is that both recipes show up in the recipe book. The dummy one shows up for the normal advancement, and the override shows up once the dummy one is viewed. Is there any way to remove the dummy from the book? I think I can set up a custom advancement for the override.

Posted
1 hour ago, NathaFred said:

Is there any way to remove the dummy from the book? I think I can set up a custom advancement for the override.

That's exactly what you need to do.

Just remember to give a blank dummy for the original advancement.

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

Yes.

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 (edited)

Hmm... Well this is harder than I thought it would be. I can't find anything online or in the vanilla code... A lot of people have said the advancement should be added in the data pack as a .json, and the minecraft wiki agrees with that. However, I cannot find a good example of an advancement json. I found an advancement .json generator online, but it dosen't work so either it's outdated, or I did something wrong. Here is my .json file that the website generated.

 

{
  "display": {
    "description": "",
    "title": "",
    "show_toast": false,
    "announce_to_chat": false,
    "background": "minecraft:textures/blocks/stone.png"
  },
  "criteria": {
    "inv_changed-diamond": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "minecraft:diamond",
            "data": 0
          }
        ]
      }
    }
  },
  "rewards": {
    "recipes": [
      "grindstone_override"
    ]
  },
  "requirements": [
    [
      "inv_changed-diamond"
    ]
  ]
}

 

I placed this file in resources/data/mod-id/advancements  and  resources/data/minecraft/advancements. Neither did anything. I am assuming that the recipe string should hold the name of the recipe file, but I don't know if that is true. Also the   "data": 0   line is kinda sus...

 

 

Edited by NathaFred
Posted (edited)

Isn't it weird how when you explain things suddenly you realize whats wrong!? Well, I figured it out. I am not sure what specifically was wrong in that .json, but I changed a bunch of things and put it in the resources/data/minecraft/advancements folder, and it works! Here is the new .json. You have to use your mod-id namespace for the reward recipe, and it seems the  "data": 0 line was wrong.

 

So if you need an example of how to add a new recipe advancement, here one is!

 

 

{
  "criteria": {
    "inv_changed-diamond": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "item": "minecraft:diamond"
          }
        ]
      }
    }
  },
  "rewards": {
    "recipes": [
      "nmgrepair:grindstone_override"
    ]
  }
}

 

Now I just have to figure out how to override/ remove the other one...

 

Edited by NathaFred
Posted (edited)
2 minutes ago, NathaFred said:

Now I just have to figure out how to override/ remove the other one...

Should just be creating a dummy one that's essentially impossible to obtain.
I swear I have it around somewhere...

 

Ah ha there it is. Couldn't find it last night.

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/resources/data/minecraft/advancements/recipes/misc/bone_meal.json

Edited by Draco18s

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

Hmm... So when the player gets a stone slab, the advancement that I need to override gives you the grindstone recipe... I am not sure how your example works as it just creates a new impossible advancement. It doesn't seem like it is tied to bone meal at all unless the name matters. I have tried putting that file, with the name "grindstone.json" under

data/minecraft/advancements/

data/minecraft/advancements/recipes

data/minecraft/advancements/minecraft/recipes

data/advancements/recipes

data/advancements/minecraft/recipes

 

none have nulled the original advancement. Is there something I am not realizing here? Also, I have so many worlds now because every time I test it I have to create a new one to test the advancement XD

Posted
1 hour ago, NathaFred said:

just creates a new impossible advancement.

No, it makes the advancement that unlocks the bone -> bonemeal recipe impossible to get. Its not a new advancement at all, notice where it lives.

If you create a similar advancement for the grindstone, then picking up a slab won't give you the grindstone recipe. Or you can alter the condition, unlock reward, etc.

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

Your file does indeed work when it is named bone_meal.json, however if I try to use it for the grindstone it doesn't work.

I tried a bunch of names and directories. None of these configurations work. How should I name this file, and where should I put it? 

 

Untitled-1.png.a233c41aa061c34111b34a62d846b915.png

 

Posted

What's the vanilla file named?

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 (edited)

Why do I keep doing this! I just found them 🤦‍♂️ okay it's under the decorations folder not decoration... and it is called grindstone.

 

Edit

It works...

 

For anyone wondering where the advancements and a bunch of other stuff is:

net.minecraft:client:extra:version-number

(at least for now)

Edited by NathaFred
Posted

Thank you for this thread! I was looking for the same info.

 

One thing I can add from my experience is that one item can have multiple recipes (I wanted to override a Wooden Pickaxe, which I found has a minecraft vanilla recipe AND a forge recipe (?)), so you will have to override all the recipes to fully get rid of the vanilla behavior.

Posted

The forge version overrides the vanilla version already.

  • Like 1

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

Hm, I tried to override the forge version only but I could still create a Wooden Pickaxe.
Maybe I didn't place the recipe correctly?
I placed both recipes in resources/data/minecraft/recipes

Posted

Whatever recipe you're using to replace the vanilla recipe needs to be named the same and placed in the same location (so, you have the location correct, I assume you've named it correctly).

I am aware of, but thought it got fixed, that any recipe forge overrides from vanilla could not, itself, be overridden. 

  • Like 1

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 (edited)
2 hours ago, nayna said:

one item can have multiple recipes

This is exactly the problem I was trying to solve in this thread. A recipe is only actually overridden if the shape and ingredients are the same. In other words, if you create an identical recipe to the wooden pickaxe but set the output to air, you will find that it is impossible to craft a wooden pickaxe. So the steps to take if you want to change or replace a recipe are:

1. create a recipe with the desired ingredients and output

2. create a recipe identical to the vanilla recipe, but outputting air

3. create an identical advancement to the vanilla and have it reward your custom recipe (and change criteria as needed)

4. create an impossible advancement to override the vanilla one, since the vanilla advacement will give the player a recipe that no longer works.

 

In step four the .json file must be named the same as the vanilla advancement and be placed in the same location in the data folder. Like I said before you can find all the vanilla advancements if you go to your external libraries and look under net.minecraft:client:extra:1.16.1. 

 

These are the steps that I went through in this thread and should get you the same result. :)

Edited by NathaFred
  • Like 1
Posted
16 minutes ago, NathaFred said:

These are the steps that I went through in this thread and should get you the same result.

I followed the steps you mentioned but I could still create the Wooden Pickaxe. The advancement worked first try.
I then found out there are 2 recipes:
vanilla:

{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "XXX",
    " # ",
    " # "
  ],
  "key": {
    "#": {
      "item": "minecraft:stick"
    },
    "X": {
      "tag": "minecraft:planks"
    }
  },
  "result": {
    "item": "minecraft:wooden_pickaxe",
  }
}

forge:

{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "XXX",
    " # ",
    " # "
  ],
  "key": {
    "#": {
      "tag": "forge:rods/wooden"
    },
    "X": {
      "tag": "minecraft:planks"
    }
  },
  "result": {
    "item": "minecraft:wooden_pickaxe",
  }
}

So I did an override for both of these recipes and then I could not create the Wooden Pickaxe.

 

I noticed this because I made the custom recipe for the Wooden Pickaxe, which had a different pattern (and it worked), and decided to result air on that one, and I could not create the Wooden Pickaxe with the new pattern! Therefore I searched through the forge and vanilla recipes and found the 2 recipes.


I assume that when the vanilla recipe is overrode alone, the forge recipe will work, and when the forge recipe is overrode alone, the vanilla one will work.

2 hours ago, Draco18s said:

I am aware of, but thought it got fixed, that any recipe forge overrides from vanilla could not, itself, be overridden. 

But the vanilla could be? Then would forge automatically know to make the pattern unavailable when the vanilla one is overrode?

 

Posted (edited)
38 minutes ago, nayna said:

But the vanilla could be? Then would forge automatically know to make the pattern unavailable when the vanilla one is overrode?

Forge overrides vanilla. Any override you create therefor must override Forge.

Note this is not a "I would like to override Forge" conscious decision. It is forced upon you by the very nature of the system's design.

Edited by Draco18s
  • Like 1

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.

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

    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
    • Okay, but does the modpack works with 1.12 or just with 1.12.2, because I need the Forge client specifically for Minecraft 1.12, not 1.12.2
    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
  • Topics

×
×
  • Create New...

Important Information

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