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);
}
}