Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge remote-tracking branch 'origin/1.8'
- Loading branch information
Showing
81 changed files
with
1,893 additions
and
623 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,51 @@ | ||
package mezz.jei; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fml.client.event.ConfigChangedEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.common.SidedProxy; | ||
import net.minecraftforge.fml.common.event.FMLInitializationEvent; | ||
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
|
||
import mezz.jei.api.IModPlugin; | ||
import mezz.jei.api.IPluginRegistry; | ||
import mezz.jei.api.JEIManager; | ||
import mezz.jei.api.recipe.IRecipeCategory; | ||
import mezz.jei.api.recipe.IRecipeHandler; | ||
import mezz.jei.config.Config; | ||
import mezz.jei.config.Constants; | ||
import mezz.jei.config.KeyBindings; | ||
import mezz.jei.gui.GuiHelper; | ||
import mezz.jei.gui.ItemListOverlay; | ||
import mezz.jei.plugins.vanilla.VanillaPlugin; | ||
import mezz.jei.util.ModList; | ||
import mezz.jei.network.PacketHandler; | ||
|
||
@Mod(modid = Constants.MOD_ID, | ||
name = Constants.NAME, | ||
version = Constants.VERSION, | ||
guiFactory = "mezz.jei.config.JEIModGuiFactory", | ||
dependencies = "required-after:Forge@[11.14.0.1269,);") | ||
public class JustEnoughItems implements IPluginRegistry { | ||
public class JustEnoughItems { | ||
|
||
@SidedProxy(clientSide = "mezz.jei.ProxyCommonClient", serverSide = "mezz.jei.ProxyCommon") | ||
public static ProxyCommon common; | ||
|
||
@Mod.Instance(Constants.MOD_ID) | ||
public static JustEnoughItems instance; | ||
|
||
@Nonnull | ||
private final List<IModPlugin> plugins = new ArrayList<>(); | ||
private boolean pluginsCanRegister = true; | ||
private boolean jeiStarted = false; | ||
public static PacketHandler packetHandler; | ||
|
||
public JustEnoughItems() { | ||
JEIManager.guiHelper = new GuiHelper(); | ||
JEIManager.pluginRegistry = this; | ||
} | ||
public static PluginRegistry pluginRegistry; | ||
|
||
@Mod.EventHandler | ||
public void preInit(@Nonnull FMLPreInitializationEvent event) { | ||
Config.preInit(event); | ||
|
||
JEIManager.pluginRegistry.registerPlugin(new VanillaPlugin()); | ||
} | ||
|
||
@Override | ||
public void registerPlugin(IModPlugin plugin) { | ||
if (!pluginsCanRegister) { | ||
throw new IllegalStateException("Plugins must be registered during FMLPreInitializationEvent."); | ||
} | ||
|
||
if (plugin.isModLoaded()) { | ||
plugins.add(plugin); | ||
} | ||
packetHandler = new PacketHandler(); | ||
JEIManager.pluginRegistry = pluginRegistry = new PluginRegistry(); | ||
JEIManager.guiHelper = new GuiHelper(); | ||
common.preInit(event); | ||
} | ||
|
||
@Mod.EventHandler | ||
public void init(FMLInitializationEvent event) { | ||
pluginsCanRegister = false; | ||
KeyBindings.init(); | ||
|
||
MinecraftForge.EVENT_BUS.register(instance); | ||
public void init(@Nonnull FMLInitializationEvent event) { | ||
pluginRegistry.init(); | ||
common.init(event); | ||
} | ||
|
||
@Mod.EventHandler | ||
public void aboutToStart(FMLServerAboutToStartEvent event) { | ||
if (jeiStarted) { | ||
return; | ||
} | ||
jeiStarted = true; | ||
|
||
ModList modList = new ModList(); | ||
|
||
JEIManager.itemRegistry = new ItemRegistry(modList); | ||
|
||
ImmutableList.Builder<IRecipeCategory> recipeCategories = ImmutableList.builder(); | ||
ImmutableList.Builder<IRecipeHandler> recipeHandlers = ImmutableList.builder(); | ||
ImmutableList.Builder<Object> recipes = ImmutableList.builder(); | ||
|
||
for (IModPlugin plugin : plugins) { | ||
recipeCategories.addAll(plugin.getRecipeCategories()); | ||
recipeHandlers.addAll(plugin.getRecipeHandlers()); | ||
recipes.addAll(plugin.getRecipes()); | ||
} | ||
|
||
JEIManager.recipeRegistry = new RecipeRegistry(recipeCategories.build(), recipeHandlers.build(), recipes.build()); | ||
|
||
ItemFilter itemFilter = new ItemFilter(JEIManager.itemRegistry.getItemList()); | ||
ItemListOverlay itemListOverlay = new ItemListOverlay(itemFilter); | ||
GuiEventHandler guiEventHandler = new GuiEventHandler(itemListOverlay); | ||
MinecraftForge.EVENT_BUS.register(guiEventHandler); | ||
|
||
TooltipEventHandler tooltipEventHandler = new TooltipEventHandler(); | ||
MinecraftForge.EVENT_BUS.register(tooltipEventHandler); | ||
public void loadComplete(@Nonnull FMLLoadCompleteEvent event) { | ||
common.loadComplete(event); | ||
} | ||
|
||
@SubscribeEvent | ||
public void onConfigChanged(@Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { | ||
Config.onConfigChanged(eventArgs); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package mezz.jei; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import mezz.jei.api.IModPlugin; | ||
import mezz.jei.api.IPluginRegistry; | ||
import mezz.jei.api.recipe.IRecipeCategory; | ||
import mezz.jei.api.recipe.IRecipeHandler; | ||
import mezz.jei.api.recipe.IRecipeTransferHelper; | ||
|
||
public class PluginRegistry implements IPluginRegistry { | ||
private boolean pluginsCanRegister = true; | ||
@Nonnull | ||
private final List<IModPlugin> plugins = new ArrayList<>(); | ||
|
||
@Override | ||
public void registerPlugin(IModPlugin plugin) { | ||
if (!pluginsCanRegister) { | ||
throw new IllegalStateException("Plugins must be registered during FMLPreInitializationEvent."); | ||
} | ||
|
||
if (plugin.isModLoaded()) { | ||
plugins.add(plugin); | ||
} | ||
} | ||
|
||
public void init() { | ||
pluginsCanRegister = false; | ||
} | ||
|
||
public RecipeRegistry createRecipeRegistry() { | ||
ImmutableList.Builder<IRecipeCategory> recipeCategories = ImmutableList.builder(); | ||
ImmutableList.Builder<IRecipeHandler> recipeHandlers = ImmutableList.builder(); | ||
ImmutableList.Builder<IRecipeTransferHelper> recipeTransferHelpers = ImmutableList.builder(); | ||
ImmutableList.Builder<Object> recipes = ImmutableList.builder(); | ||
|
||
for (IModPlugin plugin : plugins) { | ||
recipeCategories.addAll(plugin.getRecipeCategories()); | ||
recipeHandlers.addAll(plugin.getRecipeHandlers()); | ||
recipeTransferHelpers.addAll(plugin.getRecipeTransferHelpers()); | ||
recipes.addAll(plugin.getRecipes()); | ||
} | ||
|
||
return new RecipeRegistry(recipeCategories.build(), recipeHandlers.build(), recipeTransferHelpers.build(), recipes.build()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package mezz.jei; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.entity.player.EntityPlayerMP; | ||
|
||
import net.minecraftforge.common.util.FakePlayer; | ||
import net.minecraftforge.fml.common.event.FMLInitializationEvent; | ||
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
|
||
import mezz.jei.network.packets.PacketJEI; | ||
import mezz.jei.util.Log; | ||
|
||
public class ProxyCommon { | ||
|
||
public void preInit(@Nonnull FMLPreInitializationEvent event) { | ||
|
||
} | ||
|
||
public void init(@Nonnull FMLInitializationEvent event) { | ||
|
||
} | ||
|
||
public void loadComplete(@Nonnull FMLLoadCompleteEvent event) { | ||
|
||
} | ||
|
||
public void sendPacketToServer(PacketJEI packet) { | ||
Log.error("Tried to send packet to the server from the server: {}", packet); | ||
} | ||
|
||
public void sendPacketToPlayer(PacketJEI packet, EntityPlayer entityplayer) { | ||
if (!(entityplayer instanceof EntityPlayerMP) || (entityplayer instanceof FakePlayer)) { | ||
return; | ||
} | ||
|
||
EntityPlayerMP player = (EntityPlayerMP) entityplayer; | ||
JustEnoughItems.packetHandler.sendPacket(packet.getPacket(), player); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package mezz.jei; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import net.minecraft.client.network.NetHandlerPlayClient; | ||
|
||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fml.client.FMLClientHandler; | ||
import net.minecraftforge.fml.client.event.ConfigChangedEvent; | ||
import net.minecraftforge.fml.common.FMLCommonHandler; | ||
import net.minecraftforge.fml.common.event.FMLInitializationEvent; | ||
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
|
||
import mezz.jei.api.JEIManager; | ||
import mezz.jei.config.Config; | ||
import mezz.jei.config.KeyBindings; | ||
import mezz.jei.gui.ItemListOverlay; | ||
import mezz.jei.network.packets.PacketJEI; | ||
import mezz.jei.plugins.vanilla.VanillaPlugin; | ||
|
||
public class ProxyCommonClient extends ProxyCommon { | ||
@Override | ||
public void preInit(@Nonnull FMLPreInitializationEvent event) { | ||
Config.preInit(event); | ||
JEIManager.pluginRegistry.registerPlugin(new VanillaPlugin()); | ||
} | ||
|
||
@Override | ||
public void init(@Nonnull FMLInitializationEvent event) { | ||
KeyBindings.init(); | ||
FMLCommonHandler.instance().bus().register(this); | ||
} | ||
|
||
@Override | ||
public void loadComplete(@Nonnull FMLLoadCompleteEvent event) { | ||
JEIManager.itemRegistry = new ItemRegistry(); | ||
JEIManager.recipeRegistry = JustEnoughItems.pluginRegistry.createRecipeRegistry(); | ||
|
||
ItemFilter itemFilter = new ItemFilter(JEIManager.itemRegistry.getItemList()); | ||
ItemListOverlay itemListOverlay = new ItemListOverlay(itemFilter); | ||
GuiEventHandler guiEventHandler = new GuiEventHandler(itemListOverlay); | ||
MinecraftForge.EVENT_BUS.register(guiEventHandler); | ||
FMLCommonHandler.instance().bus().register(guiEventHandler); | ||
|
||
TooltipEventHandler tooltipEventHandler = new TooltipEventHandler(); | ||
MinecraftForge.EVENT_BUS.register(tooltipEventHandler); | ||
} | ||
|
||
@Override | ||
public void sendPacketToServer(PacketJEI packet) { | ||
NetHandlerPlayClient netHandler = FMLClientHandler.instance().getClient().getNetHandler(); | ||
if (netHandler != null) { | ||
netHandler.addToSendQueue(packet.getPacket()); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void onConfigChanged(@Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { | ||
Config.onConfigChanged(eventArgs); | ||
} | ||
} |
Oops, something went wrong.