Jump to content

Recommended Posts

Posted

I am attempting to register a few custom crafting recipes in a server sided mod in 1.7.10

 

When putting the items in the crafting table, no item appears in the result slot. However when the seemingly empty result slot is clicked, the crafting happens successfully.

 

Is there any way I can fix this solely on the server side? Maybe using packets or something?

 

CustomRecipes class:

The register() method is called in the FMLServerStartingEvent

The LOTRItems references are non-vanilla items from another mod

import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;

public class CustomRecipes {	
	public static void register() {
		GameRegistry.addRecipe(new ItemStack(Blocks.dropper),
				"AAA",
				"A A",
				"ABA",
				'A', Blocks.cobblestone,
				'B', LOTRItems.rope
		);
		
		GameRegistry.addRecipe(new ItemStack(Blocks.dispenser),
				"AAA",
				"ACA",
				"ABA",
				'A', Blocks.cobblestone,
				'B', LOTRItems.rope,
				'C', Items.bow
		);
		
		GameRegistry.addRecipe(new ItemStack(Blocks.piston),
				"AAA",
				"BCB",
				"BDB",
				'A', Blocks.planks,
				'B', Blocks.cobblestone,
				'C', Items.iron_ingot,
				'D', LOTRItems.rope
		);
	}
}

 

Posted

1.7.10 is no longer supported here.

 

But the reason this probably doesn't work is because the client needs the recipe too.

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
15 minutes ago, robbo said:

I am attempting to register a few custom crafting recipes in a server sided mod in 1.7.10

1.7.10 is no longer supported on this forum, update to receive assistance.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Nevermind, figured out a workaround and it works now, using packets

 

Code:

import java.util.HashMap;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerWorkbench;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.network.play.server.S2FPacketSetSlot;

public class CustomRecipes {
	public static void register() {
		GameRegistry.addRecipe(new ItemStack(Blocks.dropper),
				"AAA",
				"A A",
				"ABA",
				'A', Blocks.cobblestone,
				'B', LOTRItems.rope
		);
		
		GameRegistry.addRecipe(new ItemStack(Blocks.dispenser),
				"AAA",
				"ACA",
				"ABA",
				'A', Blocks.cobblestone,
				'B', LOTRItems.rope,
				'C', Items.bow
		);
		
		GameRegistry.addRecipe(new ItemStack(Blocks.piston),
				"AAA",
				"BCB",
				"BDB",
				'A', Blocks.planks,
				'B', Blocks.cobblestone,
				'C', Items.iron_ingot,
				'D', LOTRItems.rope
		);
	}
	
	private static HashMap<EntityPlayerMP, int[]> synced = new HashMap<EntityPlayerMP, int[]>();
	
	public static void tick(EntityPlayerMP player) {
		if (player.openContainer instanceof ContainerWorkbench) {
			final ContainerWorkbench crafting = (ContainerWorkbench) player.openContainer;
			final ItemStack result = CraftingManager.getInstance().findMatchingRecipe(crafting.craftMatrix, player.worldObj);
			
			if (result != null) {
				if (synced.containsKey(player)) {
					final int[] info = synced.get(player);
					
					if (info[0] == player.currentWindowId && info[1] == Item.getIdFromItem(result.getItem())) {
						return;
					}
				}
				
				player.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(crafting.windowId, 0, result));
				synced.put(player, new int[] {player.currentWindowId, Item.getIdFromItem(result.getItem())});
			}
		}
	}
	
	@SubscribeEvent
	public void logOut(PlayerLoggedOutEvent event) {
		synced.remove(event.player);
	}
}

 

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • seguridad seguridad
    • I am creating a server with mods but when i try tostart it it say in the logs:   [29Jan2025 20:36:50.715] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/fmlcore/1.20.1-47.3.27/fmlcore-1.20.1-47.3.27.jar is missing mods.toml file 159[29Jan2025 20:36:50.717] [main/DEBUG] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Considering mod file candidate /server/libraries/net/minecraftforge/javafmllanguage/1.20.1-47.3.27/javafmllanguage-1.20.1-47.3.27.jar 160[29Jan2025 20:36:50.717] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/javafmllanguage/1.20.1-47.3.27/javafmllanguage-1.20.1-47.3.27.jar is missing mods.toml file 161[29Jan2025 20:36:50.718] [main/DEBUG] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Considering mod file candidate /server/libraries/net/minecraftforge/lowcodelanguage/1.20.1-47.3.27/lowcodelanguage-1.20.1-47.3.27.jar 162[29Jan2025 20:36:50.718] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/lowcodelanguage/1.20.1-47.3.27/lowcodelanguage-1.20.1-47.3.27.jar is missing mods.toml file 163[29Jan2025 20:36:50.719] [main/DEBUG] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Considering mod file candidate /server/libraries/net/minecraftforge/mclanguage/1.20.1-47.3.27/mclanguage-1.20.1-47.3.27.jar 164[29Jan2025 20:36:50.719] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/mclanguage/1.20.1-47.3.27/mclanguage-1.20.1-47.3.27.jar is missing mods.toml file
    • How do you configure the entity reach of a custom weapon? Asking for 1.21 Minecraft parchment
    • This topic is over a year old. If you are having an issue, please read the FAQ for the proper way to post logs, and create your own thread.
    • hello i have been trying to put this specific pack for a while now but ive been hit with a new error everytime. no matter if its a previous version or if i change the pack format it will just not work please help latest log:https://mclo.gs/b6Qra5d <----- this is with pack version 1.20 no changes done to it debug log: https://mclo.gs/jczkfRK
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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