Jump to content

robbo

Members
  • Posts

    2
  • Joined

  • Last visited

robbo's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. 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); } }
  2. 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 ); } }
×
×
  • Create New...

Important Information

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