Move JEI integration to other package

This commit is contained in:
Raoul Van den Berge
2016-08-02 20:36:35 +02:00
parent 64d67889a7
commit 4eb7a447f4
9 changed files with 194 additions and 193 deletions

View File

@@ -142,10 +142,6 @@ public final class RefinedStorage {
PROXY.postInit(e);
}
public static boolean hasJei() {
return Loader.isModLoaded("JEI");
}
public static boolean hasTesla() {
return Loader.isModLoaded("Tesla");
}

View File

@@ -21,7 +21,7 @@ import refinedstorage.gui.Scrollbar;
import refinedstorage.gui.grid.sorting.GridSortingName;
import refinedstorage.gui.grid.sorting.GridSortingQuantity;
import refinedstorage.gui.sidebutton.*;
import refinedstorage.jei.RefinedStorageJEIPlugin;
import refinedstorage.integration.jei.JEIIntegration;
import refinedstorage.network.MessageGridCraftingClear;
import refinedstorage.network.MessageGridInsertHeld;
import refinedstorage.network.MessageGridPatternCreate;
@@ -394,8 +394,8 @@ public class GuiGrid extends GuiBase {
}
private void updateJEI() {
if (RefinedStorage.hasJei() && (grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED || grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED)) {
RefinedStorageJEIPlugin.INSTANCE.getRuntime().getItemListOverlay().setFilterText(searchField.getText());
if (JEIIntegration.isLoaded() && (grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED || grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED)) {
JEIIntegration.INSTANCE.getRuntime().getItemListOverlay().setFilterText(searchField.getText());
}
}

View File

@@ -1,9 +1,9 @@
package refinedstorage.gui.sidebutton;
import net.minecraft.util.text.TextFormatting;
import refinedstorage.RefinedStorage;
import refinedstorage.gui.GuiBase;
import refinedstorage.gui.grid.GuiGrid;
import refinedstorage.integration.jei.JEIIntegration;
import refinedstorage.tile.grid.TileGrid;
public class SideButtonGridSearchBoxMode extends SideButton {
@@ -31,7 +31,7 @@ public class SideButtonGridSearchBoxMode extends SideButton {
if (mode == TileGrid.SEARCH_BOX_MODE_NORMAL) {
mode = TileGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED;
} else if (mode == TileGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED) {
if (RefinedStorage.hasJei()) {
if (JEIIntegration.isLoaded()) {
mode = TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED;
} else {
mode = TileGrid.SEARCH_BOX_MODE_NORMAL;

View File

@@ -1,15 +1,16 @@
package refinedstorage.jei;
package refinedstorage.integration.jei;
import mezz.jei.api.IJeiRuntime;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import refinedstorage.RefinedStorageBlocks;
@JEIPlugin
public class RefinedStorageJEIPlugin implements IModPlugin {
public static RefinedStorageJEIPlugin INSTANCE;
public class JEIIntegration implements IModPlugin {
public static JEIIntegration INSTANCE;
private IJeiRuntime runtime;
@@ -36,4 +37,8 @@ public class RefinedStorageJEIPlugin implements IModPlugin {
public IJeiRuntime getRuntime() {
return runtime;
}
public static boolean isLoaded() {
return Loader.isModLoaded("JEI");
}
}

View File

@@ -1,4 +1,4 @@
package refinedstorage.jei;
package refinedstorage.integration.jei;
import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.gui.IRecipeLayout;

View File

@@ -1,69 +1,69 @@
package refinedstorage.jei;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class SoldererRecipeCategory implements IRecipeCategory {
public static final String ID = "refinedstorage.solderer";
private IDrawable background;
public SoldererRecipeCategory(IGuiHelper helper) {
background = helper.createDrawable(new ResourceLocation("refinedstorage", "textures/gui/solderer.png"), 8, 5, 162, 83);
}
@Override
public String getUid() {
return ID;
}
@Override
public String getTitle() {
return I18n.format("gui.refinedstorage:solderer");
}
@Override
public IDrawable getBackground() {
return background;
}
@Override
public void drawExtras(Minecraft minecraft) {
}
@Override
public void drawAnimations(Minecraft minecraft) {
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup group = recipeLayout.getItemStacks();
int x = 44 - 9;
int y = 20 - 6;
for (int i = 0; i < 3; ++i) {
group.init(i, true, x, y);
y += 18;
}
group.init(3, false, 127 - 9, 38 - 6);
if (recipeWrapper instanceof SoldererRecipeWrapper) {
for (int i = 0; i < 3; ++i) {
group.set(i, (ItemStack) recipeWrapper.getInputs().get(i));
}
group.set(3, (ItemStack) recipeWrapper.getOutputs().get(0));
}
}
}
package refinedstorage.integration.jei;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class SoldererRecipeCategory implements IRecipeCategory {
public static final String ID = "refinedstorage.solderer";
private IDrawable background;
public SoldererRecipeCategory(IGuiHelper helper) {
background = helper.createDrawable(new ResourceLocation("refinedstorage", "textures/gui/solderer.png"), 8, 5, 162, 83);
}
@Override
public String getUid() {
return ID;
}
@Override
public String getTitle() {
return I18n.format("gui.refinedstorage:solderer");
}
@Override
public IDrawable getBackground() {
return background;
}
@Override
public void drawExtras(Minecraft minecraft) {
}
@Override
public void drawAnimations(Minecraft minecraft) {
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup group = recipeLayout.getItemStacks();
int x = 44 - 9;
int y = 20 - 6;
for (int i = 0; i < 3; ++i) {
group.init(i, true, x, y);
y += 18;
}
group.init(3, false, 127 - 9, 38 - 6);
if (recipeWrapper instanceof SoldererRecipeWrapper) {
for (int i = 0; i < 3; ++i) {
group.set(i, (ItemStack) recipeWrapper.getInputs().get(i));
}
group.set(3, (ItemStack) recipeWrapper.getOutputs().get(0));
}
}
}

View File

@@ -1,34 +1,34 @@
package refinedstorage.jei;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull;
public class SoldererRecipeHandler implements IRecipeHandler<SoldererRecipeWrapper> {
@Override
public Class<SoldererRecipeWrapper> getRecipeClass() {
return SoldererRecipeWrapper.class;
}
@Override
public String getRecipeCategoryUid() {
return SoldererRecipeCategory.ID;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull SoldererRecipeWrapper recipe) {
return SoldererRecipeCategory.ID;
}
@Override
public IRecipeWrapper getRecipeWrapper(SoldererRecipeWrapper recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(SoldererRecipeWrapper recipe) {
return true;
}
}
package refinedstorage.integration.jei;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull;
public class SoldererRecipeHandler implements IRecipeHandler<SoldererRecipeWrapper> {
@Override
public Class<SoldererRecipeWrapper> getRecipeClass() {
return SoldererRecipeWrapper.class;
}
@Override
public String getRecipeCategoryUid() {
return SoldererRecipeCategory.ID;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull SoldererRecipeWrapper recipe) {
return SoldererRecipeCategory.ID;
}
@Override
public IRecipeWrapper getRecipeWrapper(SoldererRecipeWrapper recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(SoldererRecipeWrapper recipe) {
return true;
}
}

View File

@@ -1,28 +1,28 @@
package refinedstorage.jei;
import net.minecraft.item.ItemStack;
import refinedstorage.api.RefinedStorageAPI;
import refinedstorage.api.solderer.ISoldererRecipe;
import java.util.ArrayList;
import java.util.List;
public class SoldererRecipeMaker {
public static List<SoldererRecipeWrapper> getRecipes() {
List<SoldererRecipeWrapper> recipes = new ArrayList<SoldererRecipeWrapper>();
for (ISoldererRecipe recipe : RefinedStorageAPI.SOLDERER_REGISTRY.getRecipes()) {
List<ItemStack> inputs = new ArrayList<ItemStack>();
inputs.add(recipe.getRow(0));
inputs.add(recipe.getRow(1));
inputs.add(recipe.getRow(2));
ItemStack output = recipe.getResult();
recipes.add(new SoldererRecipeWrapper(inputs, output));
}
return recipes;
}
}
package refinedstorage.integration.jei;
import net.minecraft.item.ItemStack;
import refinedstorage.api.RefinedStorageAPI;
import refinedstorage.api.solderer.ISoldererRecipe;
import java.util.ArrayList;
import java.util.List;
public class SoldererRecipeMaker {
public static List<SoldererRecipeWrapper> getRecipes() {
List<SoldererRecipeWrapper> recipes = new ArrayList<SoldererRecipeWrapper>();
for (ISoldererRecipe recipe : RefinedStorageAPI.SOLDERER_REGISTRY.getRecipes()) {
List<ItemStack> inputs = new ArrayList<ItemStack>();
inputs.add(recipe.getRow(0));
inputs.add(recipe.getRow(1));
inputs.add(recipe.getRow(2));
ItemStack output = recipe.getResult();
recipes.add(new SoldererRecipeWrapper(inputs, output));
}
return recipes;
}
}

View File

@@ -1,49 +1,49 @@
package refinedstorage.jei;
import mezz.jei.plugins.vanilla.VanillaRecipeWrapper;
import net.minecraft.item.ItemStack;
import java.util.Collections;
import java.util.List;
public class SoldererRecipeWrapper extends VanillaRecipeWrapper {
private List<ItemStack> inputs;
private ItemStack output;
public SoldererRecipeWrapper(List<ItemStack> inputs, ItemStack output) {
this.inputs = inputs;
this.output = output;
}
@Override
public List<ItemStack> getInputs() {
return inputs;
}
@Override
public List<ItemStack> getOutputs() {
return Collections.singletonList(output);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof SoldererRecipeWrapper)) {
return false;
}
SoldererRecipeWrapper other = (SoldererRecipeWrapper) obj;
for (int i = 0; i < inputs.size(); i++) {
if (!ItemStack.areItemStacksEqual(inputs.get(i), other.inputs.get(i))) {
return false;
}
}
return ItemStack.areItemStacksEqual(output, other.output);
}
@Override
public String toString() {
return inputs + " = " + output;
}
}
package refinedstorage.integration.jei;
import mezz.jei.plugins.vanilla.VanillaRecipeWrapper;
import net.minecraft.item.ItemStack;
import java.util.Collections;
import java.util.List;
public class SoldererRecipeWrapper extends VanillaRecipeWrapper {
private List<ItemStack> inputs;
private ItemStack output;
public SoldererRecipeWrapper(List<ItemStack> inputs, ItemStack output) {
this.inputs = inputs;
this.output = output;
}
@Override
public List<ItemStack> getInputs() {
return inputs;
}
@Override
public List<ItemStack> getOutputs() {
return Collections.singletonList(output);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof SoldererRecipeWrapper)) {
return false;
}
SoldererRecipeWrapper other = (SoldererRecipeWrapper) obj;
for (int i = 0; i < inputs.size(); i++) {
if (!ItemStack.areItemStacksEqual(inputs.get(i), other.inputs.get(i))) {
return false;
}
}
return ItemStack.areItemStacksEqual(output, other.output);
}
@Override
public String toString() {
return inputs + " = " + output;
}
}