-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Huge code cleanup, Grinder support, should close #3
- Loading branch information
Showing
19 changed files
with
265 additions
and
250 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
Binary file renamed
BIN
+3.88 MB
libs/Pam's+HarvestCraft+1.12.2q.jar → libs/Pam's+HarvestCraft+1.12.2r.jar
Binary file not shown.
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,44 +1,53 @@ | ||
package ru.pearx.jehc.jei; | ||
|
||
import mezz.jei.api.IGuiHelper; | ||
import mezz.jei.api.IModPlugin; | ||
import mezz.jei.api.IModRegistry; | ||
import mezz.jei.api.JEIPlugin; | ||
import mezz.jei.api.recipe.IRecipeCategoryRegistration; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import ru.pearx.jehc.jei.apiary.ApiaryRecipeCategory; | ||
import ru.pearx.jehc.jei.presser.PresserRecipeCategory; | ||
import ru.pearx.jehc.jei.machine.GrinderRecipeCategory; | ||
import ru.pearx.jehc.jei.machine.PresserRecipeCategory; | ||
import ru.pearx.jehc.jei.sbm.MarketRecipeCategory; | ||
import ru.pearx.jehc.jei.sbm.ShippingBinRecipeCategory; | ||
import ru.pearx.jehc.jei.trap.GroundTrapRecipeCategory; | ||
import ru.pearx.jehc.jei.trap.WaterTrapRecipeCategory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/* | ||
* Created by mrAppleXZ on 20.05.17 16:23. | ||
*/ | ||
@JEIPlugin | ||
@SideOnly(Side.CLIENT) | ||
public class JEHCPlugin implements IModPlugin | ||
{ | ||
private List<JehcRecipeCategory> cats = new ArrayList<>(); | ||
|
||
@Override | ||
public void register(IModRegistry registry) | ||
{ | ||
PresserRecipeCategory.setup(registry); | ||
ShippingBinRecipeCategory.setup(registry); | ||
MarketRecipeCategory.setup(registry); | ||
ApiaryRecipeCategory.setup(registry); | ||
GroundTrapRecipeCategory.setup(registry); | ||
WaterTrapRecipeCategory.setup(registry); | ||
for(JehcRecipeCategory cat : cats) | ||
cat.setup(registry); | ||
} | ||
|
||
@Override | ||
public void registerCategories(IRecipeCategoryRegistration reg) | ||
{ | ||
reg.addRecipeCategories(new PresserRecipeCategory(reg.getJeiHelpers().getGuiHelper())); | ||
reg.addRecipeCategories(new ShippingBinRecipeCategory(reg.getJeiHelpers().getGuiHelper())); | ||
reg.addRecipeCategories(new MarketRecipeCategory(reg.getJeiHelpers().getGuiHelper())); | ||
reg.addRecipeCategories(new ApiaryRecipeCategory(reg.getJeiHelpers().getGuiHelper())); | ||
reg.addRecipeCategories(new GroundTrapRecipeCategory(reg.getJeiHelpers().getGuiHelper())); | ||
reg.addRecipeCategories(new WaterTrapRecipeCategory(reg.getJeiHelpers().getGuiHelper())); | ||
IGuiHelper h = reg.getJeiHelpers().getGuiHelper(); | ||
cats.add(new PresserRecipeCategory(h)); | ||
cats.add(new ShippingBinRecipeCategory(h)); | ||
cats.add(new MarketRecipeCategory(h)); | ||
cats.add(new ApiaryRecipeCategory(h)); | ||
cats.add(new GroundTrapRecipeCategory(h)); | ||
cats.add(new WaterTrapRecipeCategory(h)); | ||
cats.add(new GrinderRecipeCategory(h)); | ||
for(JehcRecipeCategory cat : cats) | ||
{ | ||
reg.addRecipeCategories(cat); | ||
} | ||
} | ||
} |
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,56 @@ | ||
package ru.pearx.jehc.jei; | ||
|
||
import com.pam.harvestcraft.Reference; | ||
import mezz.jei.api.IModRegistry; | ||
import mezz.jei.api.gui.IDrawable; | ||
import mezz.jei.api.gui.IRecipeLayout; | ||
import mezz.jei.api.ingredients.IIngredients; | ||
import mezz.jei.api.recipe.IRecipeCategory; | ||
import mezz.jei.api.recipe.IRecipeWrapper; | ||
import net.minecraft.client.resources.I18n; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
/* | ||
* Created by mrAppleXZ on 22.03.18 20:48. | ||
*/ | ||
@SideOnly(Side.CLIENT) | ||
public abstract class JehcRecipeCategory<T extends IRecipeWrapper> implements IRecipeCategory<T> | ||
{ | ||
private String uid; | ||
private String unlocalizedTitle; | ||
private IDrawable background; | ||
|
||
public JehcRecipeCategory(String uid, String unlocalizedTitle, IDrawable background) | ||
{ | ||
this.uid = uid; | ||
this.unlocalizedTitle = unlocalizedTitle; | ||
this.background = background; | ||
} | ||
|
||
public abstract void setup(IModRegistry reg); | ||
|
||
@Override | ||
public String getUid() | ||
{ | ||
return uid; | ||
} | ||
|
||
@Override | ||
public String getTitle() | ||
{ | ||
return I18n.format(unlocalizedTitle); | ||
} | ||
|
||
@Override | ||
public String getModName() | ||
{ | ||
return Reference.NAME; | ||
} | ||
|
||
@Override | ||
public IDrawable getBackground() | ||
{ | ||
return background; | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
src/main/java/ru/pearx/jehc/jei/machine/GrinderRecipeCategory.java
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,44 @@ | ||
package ru.pearx.jehc.jei.machine; | ||
|
||
import com.pam.harvestcraft.Reference; | ||
import com.pam.harvestcraft.blocks.BlockRegistry; | ||
import com.pam.harvestcraft.item.GrinderRecipes; | ||
import mezz.jei.api.IGuiHelper; | ||
import mezz.jei.api.IModRegistry; | ||
import mezz.jei.api.gui.IDrawable; | ||
import mezz.jei.api.gui.IRecipeLayout; | ||
import mezz.jei.api.ingredients.IIngredients; | ||
import mezz.jei.api.recipe.IRecipeCategory; | ||
import net.minecraft.client.resources.I18n; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.fml.common.network.IGuiHandler; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import org.apache.commons.lang3.reflect.FieldUtils; | ||
import ru.pearx.jehc.JEHC; | ||
import ru.pearx.jehc.jei.machine.MachineRecipeCategory; | ||
import ru.pearx.jehc.jei.machine.MachineRecipeWrapper; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/* | ||
* Created by mrAppleXZ on 22.03.18 20:29. | ||
*/ | ||
@SideOnly(Side.CLIENT) | ||
public class GrinderRecipeCategory extends MachineRecipeCategory | ||
{ | ||
public GrinderRecipeCategory(IGuiHelper helper) | ||
{ | ||
super("jehc.grinder", "jehc.grinder.name", "grinder", GrinderRecipes.class, "grindingList", helper); | ||
} | ||
|
||
@Override | ||
public void setup(IModRegistry registry) | ||
{ | ||
registry.addRecipeCatalyst(new ItemStack(BlockRegistry.grinderItemBlock), getUid()); | ||
super.setup(registry); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/ru/pearx/jehc/jei/machine/MachineRecipeCategory.java
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,65 @@ | ||
package ru.pearx.jehc.jei.machine; | ||
|
||
import com.pam.harvestcraft.blocks.BlockRegistry; | ||
import com.pam.harvestcraft.item.GrinderRecipes; | ||
import mezz.jei.api.IGuiHelper; | ||
import mezz.jei.api.IModRegistry; | ||
import mezz.jei.api.gui.IDrawable; | ||
import mezz.jei.api.gui.IRecipeLayout; | ||
import mezz.jei.api.ingredients.IIngredients; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.apache.commons.lang3.reflect.FieldUtils; | ||
import ru.pearx.jehc.JEHC; | ||
import ru.pearx.jehc.jei.JehcRecipeCategory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/* | ||
* Created by mrAppleXZ on 22.03.18 20:46. | ||
*/ | ||
public class MachineRecipeCategory extends JehcRecipeCategory<MachineRecipeWrapper> | ||
{ | ||
private Class recClass; | ||
private String recField; | ||
|
||
public MachineRecipeCategory(String uid, String unlocalizedTitle, String png, Class recClass, String recField, IGuiHelper helper) | ||
{ | ||
super(uid, unlocalizedTitle, helper.createDrawable(new ResourceLocation("harvestcraft", "textures/gui/" + png + ".png"), 3, 8, 170, 66)); | ||
this.recClass = recClass; | ||
this.recField = recField; | ||
} | ||
|
||
@Override | ||
public void setup(IModRegistry registry) | ||
{ | ||
List<MachineRecipeWrapper> rec = new ArrayList<>(); | ||
try | ||
{ | ||
for (Map.Entry<ItemStack, ItemStack[]> entr : ((Map<ItemStack, ItemStack[]>)FieldUtils.readStaticField(recClass, recField, true)).entrySet()) | ||
{ | ||
rec.add(new MachineRecipeWrapper(entr.getKey(), entr.getValue())); | ||
} | ||
} catch (IllegalAccessException e) | ||
{ | ||
JEHC.INSTANCE.getLog().error("An IllegalAccessException occurred while setting up the " + recClass.getSimpleName() + " recipes.", e); | ||
} | ||
registry.addRecipes(rec, getUid()); | ||
} | ||
|
||
@Override | ||
public void setRecipe(IRecipeLayout recipeLayout, MachineRecipeWrapper recipeWrapper, IIngredients ingredients) | ||
{ | ||
recipeLayout.getItemStacks().init(0, true, 76, 14); | ||
recipeLayout.getItemStacks().set(0, ingredients.getInputs(ItemStack.class).get(0)); | ||
recipeLayout.getItemStacks().init(1, false, 58, 45); | ||
recipeLayout.getItemStacks().set(1, ingredients.getOutputs(ItemStack.class).get(0)); | ||
if(ingredients.getOutputs(ItemStack.class).size() == 2) | ||
{ | ||
recipeLayout.getItemStacks().init(2, false, 94, 45); | ||
recipeLayout.getItemStacks().set(2, ingredients.getOutputs(ItemStack.class).get(1)); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.