pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,15 +18,15 @@
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.implementations.items.IStorageComponent;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.gui.HoverChecker;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
@@ -36,178 +36,169 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.gui.HoverChecker;
|
||||
|
||||
import java.util.*;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.implementations.items.IStorageComponent;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
|
||||
class CondenserCategory implements IRecipeCategory<CondenserOutput> {
|
||||
|
||||
class CondenserCategory implements IRecipeCategory<CondenserOutput>
|
||||
{
|
||||
public static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "condenser");
|
||||
|
||||
public static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "condenser");
|
||||
private final String localizedName;
|
||||
|
||||
private final String localizedName;
|
||||
private final IDrawable background;
|
||||
|
||||
private final IDrawable background;
|
||||
private final IDrawable iconTrash;
|
||||
|
||||
private final IDrawable iconTrash;
|
||||
private final IDrawableAnimated progress;
|
||||
|
||||
private final IDrawableAnimated progress;
|
||||
private final IDrawable iconButton;
|
||||
|
||||
private final IDrawable iconButton;
|
||||
private final IDrawable icon;
|
||||
|
||||
private final IDrawable icon;
|
||||
private final HoverChecker buttonHoverChecker;
|
||||
|
||||
private final HoverChecker buttonHoverChecker;
|
||||
private final Map<CondenserOutput, IDrawable> buttonIcons;
|
||||
|
||||
private final Map<CondenserOutput, IDrawable> buttonIcons;
|
||||
public CondenserCategory(IGuiHelper guiHelper) {
|
||||
this.localizedName = I18n.format("gui.appliedenergistics2.Condenser");
|
||||
this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().condenser().stack(1));
|
||||
|
||||
public CondenserCategory( IGuiHelper guiHelper )
|
||||
{
|
||||
this.localizedName = I18n.format( "gui.appliedenergistics2.Condenser" );
|
||||
this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().condenser().stack(1));
|
||||
ResourceLocation location = new ResourceLocation(AppEng.MOD_ID, "textures/guis/condenser.png");
|
||||
this.background = guiHelper.createDrawable(location, 50, 25, 94, 48);
|
||||
|
||||
ResourceLocation location = new ResourceLocation( AppEng.MOD_ID, "textures/guis/condenser.png" );
|
||||
this.background = guiHelper.createDrawable( location, 50, 25, 94, 48 );
|
||||
ResourceLocation statesLocation = new ResourceLocation(AppEng.MOD_ID, "textures/guis/states.png");
|
||||
this.iconTrash = guiHelper.drawableBuilder(statesLocation, 241, 81, 14, 14).addPadding(28, 0, 2, 0).build();
|
||||
this.iconButton = guiHelper.drawableBuilder(statesLocation, 240, 240, 16, 16).addPadding(28, 0, 78, 0).build();
|
||||
|
||||
ResourceLocation statesLocation = new ResourceLocation( AppEng.MOD_ID, "textures/guis/states.png" );
|
||||
this.iconTrash = guiHelper.drawableBuilder( statesLocation, 241, 81, 14, 14 )
|
||||
.addPadding(28, 0, 2, 0)
|
||||
.build();
|
||||
this.iconButton = guiHelper.drawableBuilder( statesLocation, 240, 240, 16, 16 )
|
||||
.addPadding(28, 0, 78, 0)
|
||||
.build();
|
||||
IDrawableStatic progressDrawable = guiHelper.drawableBuilder(location, 178, 25, 6, 18).addPadding(0, 0, 70, 0)
|
||||
.build();
|
||||
this.progress = guiHelper.createAnimatedDrawable(progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM,
|
||||
false);
|
||||
|
||||
IDrawableStatic progressDrawable = guiHelper.drawableBuilder( location, 178, 25, 6, 18 )
|
||||
.addPadding(0, 0, 70, 0)
|
||||
.build();
|
||||
this.progress = guiHelper.createAnimatedDrawable( progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM, false );
|
||||
this.buttonIcons = new EnumMap<>(CondenserOutput.class);
|
||||
|
||||
this.buttonIcons = new EnumMap<>(CondenserOutput.class);
|
||||
this.buttonIcons.put(CondenserOutput.MATTER_BALLS,
|
||||
guiHelper.drawableBuilder(statesLocation, 16, 112, 14, 14).addPadding(28, 0, 78, 0).build());
|
||||
this.buttonIcons.put(CondenserOutput.SINGULARITY,
|
||||
guiHelper.drawableBuilder(statesLocation, 32, 112, 14, 14).addPadding(28, 0, 78, 0).build());
|
||||
this.buttonHoverChecker = new HoverChecker(28, 28 + 16, 78, 78 + 16, 0);
|
||||
}
|
||||
|
||||
this.buttonIcons.put(CondenserOutput.MATTER_BALLS, guiHelper.drawableBuilder( statesLocation, 16, 112, 14, 14 ).addPadding(28, 0, 78, 0).build());
|
||||
this.buttonIcons.put(CondenserOutput.SINGULARITY, guiHelper.drawableBuilder( statesLocation, 32, 112, 14, 14).addPadding(28, 0, 78, 0).build());
|
||||
this.buttonHoverChecker = new HoverChecker( 28, 28 + 16, 78, 78 + 16, 0 );
|
||||
}
|
||||
private ItemStack getOutput(CondenserOutput recipe) {
|
||||
switch (recipe) {
|
||||
case MATTER_BALLS:
|
||||
return Api.INSTANCE.definitions().materials().matterBall().stack(1);
|
||||
case SINGULARITY:
|
||||
return Api.INSTANCE.definitions().materials().singularity().stack(1);
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack getOutput( CondenserOutput recipe )
|
||||
{
|
||||
switch( recipe )
|
||||
{
|
||||
case MATTER_BALLS:
|
||||
return Api.INSTANCE.definitions().materials().matterBall().stack(1);
|
||||
case SINGULARITY:
|
||||
return Api.INSTANCE.definitions().materials().singularity().stack(1);
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
return CondenserCategory.UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUid()
|
||||
{
|
||||
return CondenserCategory.UID;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends CondenserOutput> getRecipeClass() {
|
||||
return CondenserOutput.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends CondenserOutput> getRecipeClass() {
|
||||
return CondenserOutput.class;
|
||||
}
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return this.localizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return this.localizedName;
|
||||
}
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return this.background;
|
||||
}
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
@Override
|
||||
public void setIngredients(CondenserOutput recipe, IIngredients ingredients) {
|
||||
ingredients.setOutput(VanillaTypes.ITEM, getOutput(recipe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(CondenserOutput recipe, IIngredients ingredients) {
|
||||
ingredients.setOutput(VanillaTypes.ITEM, getOutput(recipe) );
|
||||
}
|
||||
@Override
|
||||
public void draw(CondenserOutput recipe, double mouseX, double mouseY) {
|
||||
this.progress.draw();
|
||||
this.iconTrash.draw();
|
||||
this.iconButton.draw();
|
||||
|
||||
@Override
|
||||
public void draw(CondenserOutput recipe, double mouseX, double mouseY) {
|
||||
this.progress.draw();
|
||||
this.iconTrash.draw();
|
||||
this.iconButton.draw();
|
||||
IDrawable buttonIcon = this.buttonIcons.get(recipe);
|
||||
if (buttonIcon != null) {
|
||||
buttonIcon.draw();
|
||||
}
|
||||
}
|
||||
|
||||
IDrawable buttonIcon = this.buttonIcons.get(recipe);
|
||||
if (buttonIcon != null) {
|
||||
buttonIcon.draw();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, CondenserOutput output, IIngredients ingredients) {
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
itemStacks.init(0, false, 54, 26);
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, CondenserOutput output, IIngredients ingredients )
|
||||
{
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
itemStacks.init( 0, false, 54, 26 );
|
||||
// Get all storage cells and cycle them through a fake input slot
|
||||
itemStacks.init(1, true, 50, 0);
|
||||
itemStacks.set(1, this.getViableStorageComponents(output));
|
||||
|
||||
// Get all storage cells and cycle them through a fake input slot
|
||||
itemStacks.init( 1, true, 50, 0 );
|
||||
itemStacks.set( 1, this.getViableStorageComponents( output ) );
|
||||
// This only sets the output
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
// This only sets the output
|
||||
itemStacks.set( ingredients );
|
||||
}
|
||||
private List<ItemStack> getViableStorageComponents(CondenserOutput condenserOutput) {
|
||||
IMaterials materials = AEApi.instance().definitions().materials();
|
||||
List<ItemStack> viableComponents = new ArrayList<>();
|
||||
materials.cell1kPart().maybeStack(1)
|
||||
.ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
materials.cell4kPart().maybeStack(1)
|
||||
.ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
materials.cell16kPart().maybeStack(1)
|
||||
.ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
materials.cell64kPart().maybeStack(1)
|
||||
.ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
return viableComponents;
|
||||
}
|
||||
|
||||
private List<ItemStack> getViableStorageComponents(CondenserOutput condenserOutput )
|
||||
{
|
||||
IMaterials materials = AEApi.instance().definitions().materials();
|
||||
List<ItemStack> viableComponents = new ArrayList<>();
|
||||
materials.cell1kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) );
|
||||
materials.cell4kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) );
|
||||
materials.cell16kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) );
|
||||
materials.cell64kPart().maybeStack( 1 ).ifPresent( itemStack -> this.addViableComponent( condenserOutput, viableComponents, itemStack ) );
|
||||
return viableComponents;
|
||||
}
|
||||
private void addViableComponent(CondenserOutput condenserOutput, List<ItemStack> viableComponents,
|
||||
ItemStack itemStack) {
|
||||
IStorageComponent comp = (IStorageComponent) itemStack.getItem();
|
||||
int storage = comp.getBytes(itemStack) * TileCondenser.BYTE_MULTIPLIER;
|
||||
if (storage >= condenserOutput.requiredPower) {
|
||||
viableComponents.add(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
private void addViableComponent(CondenserOutput condenserOutput, List<ItemStack> viableComponents, ItemStack itemStack )
|
||||
{
|
||||
IStorageComponent comp = (IStorageComponent) itemStack.getItem();
|
||||
int storage = comp.getBytes( itemStack ) * TileCondenser.BYTE_MULTIPLIER;
|
||||
if( storage >= condenserOutput.requiredPower )
|
||||
{
|
||||
viableComponents.add( itemStack );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public List<String> getTooltipStrings(CondenserOutput output, double mouseX, double mouseY) {
|
||||
|
||||
@Override
|
||||
public List<String> getTooltipStrings(CondenserOutput output, double mouseX, double mouseY) {
|
||||
if (this.buttonHoverChecker.checkHover((int) mouseX, (int) mouseY)) {
|
||||
String key;
|
||||
|
||||
if( this.buttonHoverChecker.checkHover( (int) mouseX, (int) mouseY ) )
|
||||
{
|
||||
String key;
|
||||
switch (output) {
|
||||
case MATTER_BALLS:
|
||||
key = "gui.tooltips.appliedenergistics2.MatterBalls";
|
||||
break;
|
||||
case SINGULARITY:
|
||||
key = "gui.tooltips.appliedenergistics2.Singularity";
|
||||
break;
|
||||
default:
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
switch( output )
|
||||
{
|
||||
case MATTER_BALLS:
|
||||
key = "gui.tooltips.appliedenergistics2.MatterBalls";
|
||||
break;
|
||||
case SINGULARITY:
|
||||
key = "gui.tooltips.appliedenergistics2.Singularity";
|
||||
break;
|
||||
default:
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Splitter.on( "\\n" ).splitToList( I18n.format( key, output.requiredPower ) );
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Splitter.on("\\n").splitToList(I18n.format(key, output.requiredPower));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,11 +18,15 @@
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.recipes.handlers.GrinderOptionalResult;
|
||||
import appeng.recipes.handlers.GrinderRecipe;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
@@ -30,88 +34,78 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.recipes.handlers.GrinderOptionalResult;
|
||||
import appeng.recipes.handlers.GrinderRecipe;
|
||||
|
||||
class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipe> {
|
||||
|
||||
class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipe>
|
||||
{
|
||||
public static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "grinder");
|
||||
|
||||
public static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "grinder");
|
||||
private final String localizedName;
|
||||
|
||||
private final String localizedName;
|
||||
private final IDrawable background;
|
||||
|
||||
private final IDrawable background;
|
||||
private final IDrawable icon;
|
||||
|
||||
private final IDrawable icon;
|
||||
public GrinderRecipeCategory(IGuiHelper guiHelper) {
|
||||
this.localizedName = I18n.format("block.appliedenergistics2.grindstone");
|
||||
|
||||
public GrinderRecipeCategory( IGuiHelper guiHelper )
|
||||
{
|
||||
this.localizedName = I18n.format( "block.appliedenergistics2.grindstone" );
|
||||
ResourceLocation location = new ResourceLocation(AppEng.MOD_ID, "textures/guis/grinder.png");
|
||||
this.background = guiHelper.createDrawable(location, 11, 16, 154, 70);
|
||||
|
||||
ResourceLocation location = new ResourceLocation( AppEng.MOD_ID, "textures/guis/grinder.png" );
|
||||
this.background = guiHelper.createDrawable( location, 11, 16, 154, 70 );
|
||||
this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().grindstone().stack(1));
|
||||
}
|
||||
|
||||
this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().grindstone().stack(1));
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
return GrinderRecipeCategory.UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUid()
|
||||
{
|
||||
return GrinderRecipeCategory.UID;
|
||||
}
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return this.localizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return this.localizedName;
|
||||
}
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return this.background;
|
||||
}
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, GrinderRecipe recipe, IIngredients ingredients) {
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, GrinderRecipe recipe, IIngredients ingredients )
|
||||
{
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
itemStacks.init(0, true, 0, 0);
|
||||
itemStacks.init(1, false, 100, 46);
|
||||
itemStacks.init(2, false, 118, 46);
|
||||
itemStacks.init(3, false, 136, 46);
|
||||
|
||||
itemStacks.init( 0, true, 0, 0 );
|
||||
itemStacks.init( 1, false, 100, 46 );
|
||||
itemStacks.init( 2, false, 118, 46 );
|
||||
itemStacks.init( 3, false, 136, 46 );
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
itemStacks.set( ingredients );
|
||||
}
|
||||
@Override
|
||||
public Class<? extends GrinderRecipe> getRecipeClass() {
|
||||
return GrinderRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GrinderRecipe> getRecipeClass() {
|
||||
return GrinderRecipe.class;
|
||||
}
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(GrinderRecipe recipe, IIngredients ingredients) {
|
||||
ingredients.setInputIngredients(Collections.singletonList(recipe.getIngredient()));
|
||||
List<ItemStack> outputs = new ArrayList<>( 3 );
|
||||
outputs.add( recipe.getRecipeOutput() );
|
||||
for (GrinderOptionalResult optionalResult : recipe.getOptionalResults()) {
|
||||
outputs.add(optionalResult.getResult());
|
||||
}
|
||||
ingredients.setOutputs( VanillaTypes.ITEM, outputs );
|
||||
}
|
||||
@Override
|
||||
public void setIngredients(GrinderRecipe recipe, IIngredients ingredients) {
|
||||
ingredients.setInputIngredients(Collections.singletonList(recipe.getIngredient()));
|
||||
List<ItemStack> outputs = new ArrayList<>(3);
|
||||
outputs.add(recipe.getRecipeOutput());
|
||||
for (GrinderOptionalResult optionalResult : recipe.getOptionalResults()) {
|
||||
outputs.add(optionalResult.getResult());
|
||||
}
|
||||
ingredients.setOutputs(VanillaTypes.ITEM, outputs);
|
||||
}
|
||||
|
||||
// FIXME USE SPECIAL INGREDIENT TYPE
|
||||
// FIXME @Override
|
||||
|
||||
@@ -18,10 +18,13 @@
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.*;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
@@ -31,95 +34,86 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
|
||||
class InscriberRecipeCategory implements IRecipeCategory<InscriberRecipe> {
|
||||
|
||||
class InscriberRecipeCategory implements IRecipeCategory<InscriberRecipe>
|
||||
{
|
||||
private static final int SLOT_INPUT_TOP = 0;
|
||||
private static final int SLOT_INPUT_MIDDLE = 1;
|
||||
private static final int SLOT_INPUT_BOTTOM = 2;
|
||||
private static final int SLOT_OUTPUT = 3;
|
||||
|
||||
private static final int SLOT_INPUT_TOP = 0;
|
||||
private static final int SLOT_INPUT_MIDDLE = 1;
|
||||
private static final int SLOT_INPUT_BOTTOM = 2;
|
||||
private static final int SLOT_OUTPUT = 3;
|
||||
static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "appliedenergistics2.inscriber");
|
||||
|
||||
static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "appliedenergistics2.inscriber");
|
||||
private final IDrawable background;
|
||||
|
||||
private final IDrawable background;
|
||||
private final String localizedName;
|
||||
|
||||
private final String localizedName;
|
||||
private final IDrawableAnimated progress;
|
||||
|
||||
private final IDrawableAnimated progress;
|
||||
private final IDrawable icon;
|
||||
|
||||
private final IDrawable icon;
|
||||
public InscriberRecipeCategory(IGuiHelper guiHelper) {
|
||||
ResourceLocation location = new ResourceLocation(AppEng.MOD_ID, "textures/guis/inscriber.png");
|
||||
this.background = guiHelper.createDrawable(location, 44, 15, 97, 64);
|
||||
this.localizedName = I18n.format("block.appliedenergistics2.inscriber");
|
||||
|
||||
public InscriberRecipeCategory( IGuiHelper guiHelper )
|
||||
{
|
||||
ResourceLocation location = new ResourceLocation( AppEng.MOD_ID, "textures/guis/inscriber.png" );
|
||||
this.background = guiHelper.createDrawable( location, 44, 15, 97, 64 );
|
||||
this.localizedName = I18n.format( "block.appliedenergistics2.inscriber" );
|
||||
IDrawableStatic progressDrawable = guiHelper.drawableBuilder(location, 135, 177, 6, 18).addPadding(24, 0, 91, 0)
|
||||
.build();
|
||||
this.progress = guiHelper.createAnimatedDrawable(progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM,
|
||||
false);
|
||||
|
||||
IDrawableStatic progressDrawable = guiHelper.drawableBuilder( location, 135, 177, 6, 18 )
|
||||
.addPadding(24, 0, 91, 0)
|
||||
.build();
|
||||
this.progress = guiHelper.createAnimatedDrawable( progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM, false );
|
||||
this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().inscriber().stack(1));
|
||||
}
|
||||
|
||||
this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().inscriber().stack(1));
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUid()
|
||||
{
|
||||
return UID;
|
||||
}
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return this.localizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return this.localizedName;
|
||||
}
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return this.background;
|
||||
}
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, InscriberRecipe recipeWrapper, IIngredients ingredients) {
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, InscriberRecipe recipeWrapper, IIngredients ingredients )
|
||||
{
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
itemStacks.init(SLOT_INPUT_TOP, true, 0, 0);
|
||||
itemStacks.init(SLOT_INPUT_MIDDLE, true, 18, 23);
|
||||
itemStacks.init(SLOT_INPUT_BOTTOM, true, 0, 46);
|
||||
itemStacks.init(SLOT_OUTPUT, false, 68, 24);
|
||||
|
||||
itemStacks.init( SLOT_INPUT_TOP, true, 0, 0 );
|
||||
itemStacks.init( SLOT_INPUT_MIDDLE, true, 18, 23 );
|
||||
itemStacks.init( SLOT_INPUT_BOTTOM, true, 0, 46 );
|
||||
itemStacks.init( SLOT_OUTPUT, false, 68, 24 );
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
itemStacks.set( ingredients );
|
||||
}
|
||||
@Override
|
||||
public Class<? extends InscriberRecipe> getRecipeClass() {
|
||||
return InscriberRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends InscriberRecipe> getRecipeClass() {
|
||||
return InscriberRecipe.class;
|
||||
}
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
@Override
|
||||
public void setIngredients(InscriberRecipe recipe, IIngredients ingredients) {
|
||||
ingredients.setInputIngredients(recipe.getIngredients());
|
||||
ingredients.setOutput(VanillaTypes.ITEM, recipe.getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(InscriberRecipe recipe, IIngredients ingredients) {
|
||||
ingredients.setInputIngredients(recipe.getIngredients());
|
||||
ingredients.setOutput( VanillaTypes.ITEM, recipe.getOutput() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(InscriberRecipe recipe, double mouseX, double mouseY) {
|
||||
this.progress.draw();
|
||||
}
|
||||
@Override
|
||||
public void draw(InscriberRecipe recipe, double mouseX, double mouseY) {
|
||||
this.progress.draw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,22 @@
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.RecipeManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.JeiPlugin;
|
||||
import mezz.jei.api.constants.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.registration.*;
|
||||
import mezz.jei.api.runtime.IJeiRuntime;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
@@ -33,62 +49,42 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.integration.abstraction.JEIFacade;
|
||||
import appeng.recipes.handlers.GrinderRecipe;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.JeiPlugin;
|
||||
import mezz.jei.api.constants.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.registration.*;
|
||||
import mezz.jei.api.runtime.IJeiRuntime;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.RecipeManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@JeiPlugin
|
||||
public class JEIPlugin implements IModPlugin
|
||||
{
|
||||
private static final ResourceLocation ID = new ResourceLocation(AppEng.MOD_ID, "core");
|
||||
public class JEIPlugin implements IModPlugin {
|
||||
private static final ResourceLocation ID = new ResourceLocation(AppEng.MOD_ID, "core");
|
||||
|
||||
@Override
|
||||
public ResourceLocation getPluginUid() {
|
||||
return ID;
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getPluginUid() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemSubtypes( ISubtypeRegistration subtypeRegistry )
|
||||
{
|
||||
final Optional<Item> maybeFacade = AEApi.instance().definitions().items().facade().maybeItem();
|
||||
maybeFacade.ifPresent( subtypeRegistry::useNbtForSubtypes );
|
||||
}
|
||||
@Override
|
||||
public void registerItemSubtypes(ISubtypeRegistration subtypeRegistry) {
|
||||
final Optional<Item> maybeFacade = AEApi.instance().definitions().items().facade().maybeItem();
|
||||
maybeFacade.ifPresent(subtypeRegistry::useNbtForSubtypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCategories( IRecipeCategoryRegistration registry )
|
||||
{
|
||||
registry.addRecipeCategories( new GrinderRecipeCategory( registry.getJeiHelpers().getGuiHelper() ),
|
||||
new CondenserCategory( registry.getJeiHelpers().getGuiHelper() ),
|
||||
new InscriberRecipeCategory( registry.getJeiHelpers().getGuiHelper() ) );
|
||||
}
|
||||
@Override
|
||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||
registry.addRecipeCategories(new GrinderRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new CondenserCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new InscriberRecipeCategory(registry.getJeiHelpers().getGuiHelper()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) {
|
||||
// Allow recipe transfer from JEI to crafting and pattern terminal
|
||||
registration
|
||||
.addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerCraftingTerm.class ),
|
||||
VanillaRecipeCategoryUid.CRAFTING );
|
||||
registration
|
||||
.addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerPatternTerm.class ),
|
||||
VanillaRecipeCategoryUid.CRAFTING );
|
||||
}
|
||||
@Override
|
||||
public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) {
|
||||
// Allow recipe transfer from JEI to crafting and pattern terminal
|
||||
registration.addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerCraftingTerm.class),
|
||||
VanillaRecipeCategoryUid.CRAFTING);
|
||||
registration.addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerPatternTerm.class),
|
||||
VanillaRecipeCategoryUid.CRAFTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes(IRecipeRegistration registration) {
|
||||
@Override
|
||||
public void registerRecipes(IRecipeRegistration registration) {
|
||||
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
// FIXME Optional<Item> itemFacade = definitions.items().facade().maybeItem();
|
||||
// FIXME Optional<ItemStack> cableAnchor = definitions.parts().cableAnchor().maybeStack( 1 );
|
||||
@@ -97,77 +93,75 @@ public class JEIPlugin implements IModPlugin
|
||||
// FIXME registration.addRecipeRegistryPlugin( new FacadeRegistryPlugin( (ItemFacade) itemFacade.get(), cableAnchor.get() ) );
|
||||
// FIXME }
|
||||
|
||||
RecipeManager recipeManager = Minecraft.getInstance().world.getRecipeManager();
|
||||
registration.addRecipes(recipeManager.getRecipes(GrinderRecipe.TYPE).values(), GrinderRecipeCategory.UID);
|
||||
registration.addRecipes(recipeManager.getRecipes(InscriberRecipe.TYPE).values(), InscriberRecipeCategory.UID );
|
||||
registration.addRecipes(ImmutableList.of(CondenserOutput.MATTER_BALLS, CondenserOutput.SINGULARITY), CondenserCategory.UID);
|
||||
RecipeManager recipeManager = Minecraft.getInstance().world.getRecipeManager();
|
||||
registration.addRecipes(recipeManager.getRecipes(GrinderRecipe.TYPE).values(), GrinderRecipeCategory.UID);
|
||||
registration.addRecipes(recipeManager.getRecipes(InscriberRecipe.TYPE).values(), InscriberRecipeCategory.UID);
|
||||
registration.addRecipes(ImmutableList.of(CondenserOutput.MATTER_BALLS, CondenserOutput.SINGULARITY),
|
||||
CondenserCategory.UID);
|
||||
|
||||
registerDescriptions(definitions, registration);
|
||||
}
|
||||
registerDescriptions(definitions, registration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
@Override
|
||||
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
ItemStack grindstone = definitions.blocks().grindstone().stack(1);
|
||||
registration.addRecipeCatalyst( grindstone, GrinderRecipeCategory.UID );
|
||||
ItemStack grindstone = definitions.blocks().grindstone().stack(1);
|
||||
registration.addRecipeCatalyst(grindstone, GrinderRecipeCategory.UID);
|
||||
|
||||
ItemStack condenser = definitions.blocks().condenser().stack(1);
|
||||
registration.addRecipeCatalyst(condenser, CondenserCategory.UID);
|
||||
ItemStack condenser = definitions.blocks().condenser().stack(1);
|
||||
registration.addRecipeCatalyst(condenser, CondenserCategory.UID);
|
||||
|
||||
ItemStack inscriber = definitions.blocks().inscriber().stack(1);
|
||||
registration.addRecipeCatalyst( inscriber, InscriberRecipeCategory.UID );
|
||||
}
|
||||
ItemStack inscriber = definitions.blocks().inscriber().stack(1);
|
||||
registration.addRecipeCatalyst(inscriber, InscriberRecipeCategory.UID);
|
||||
}
|
||||
|
||||
private void registerDescriptions(IDefinitions definitions, IRecipeRegistration registry )
|
||||
{
|
||||
IMaterials materials = definitions.materials();
|
||||
private void registerDescriptions(IDefinitions definitions, IRecipeRegistration registry) {
|
||||
IMaterials materials = definitions.materials();
|
||||
|
||||
final String[] message;
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.CERTUS_QUARTZ_WORLD_GEN ) )
|
||||
{
|
||||
message = new String[]{GuiText.ChargedQuartz.getTranslationKey(), "", GuiText.ChargedQuartzFind.getTranslationKey()};
|
||||
}
|
||||
else
|
||||
{
|
||||
message = new String[]{GuiText.ChargedQuartzFind.getTranslationKey()};
|
||||
}
|
||||
this.addDescription( registry, materials.certusQuartzCrystalCharged(), message );
|
||||
final String[] message;
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) {
|
||||
message = new String[] { GuiText.ChargedQuartz.getTranslationKey(), "",
|
||||
GuiText.ChargedQuartzFind.getTranslationKey() };
|
||||
} else {
|
||||
message = new String[] { GuiText.ChargedQuartzFind.getTranslationKey() };
|
||||
}
|
||||
this.addDescription(registry, materials.certusQuartzCrystalCharged(), message);
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.METEORITE_WORLD_GEN ) )
|
||||
{
|
||||
this.addDescription( registry, materials.logicProcessorPress(), GuiText.inWorldCraftingPresses.getTranslationKey() );
|
||||
this.addDescription( registry, materials.calcProcessorPress(), GuiText.inWorldCraftingPresses.getTranslationKey() );
|
||||
this.addDescription( registry, materials.engProcessorPress(), GuiText.inWorldCraftingPresses.getTranslationKey() );
|
||||
}
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) {
|
||||
this.addDescription(registry, materials.logicProcessorPress(),
|
||||
GuiText.inWorldCraftingPresses.getTranslationKey());
|
||||
this.addDescription(registry, materials.calcProcessorPress(),
|
||||
GuiText.inWorldCraftingPresses.getTranslationKey());
|
||||
this.addDescription(registry, materials.engProcessorPress(),
|
||||
GuiText.inWorldCraftingPresses.getTranslationKey());
|
||||
}
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_FLUIX ) )
|
||||
{
|
||||
this.addDescription( registry, materials.fluixCrystal(), GuiText.inWorldFluix.getTranslationKey() );
|
||||
}
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_FLUIX)) {
|
||||
this.addDescription(registry, materials.fluixCrystal(), GuiText.inWorldFluix.getTranslationKey());
|
||||
}
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_SINGULARITY ) )
|
||||
{
|
||||
this.addDescription( registry, materials.qESingularity(), GuiText.inWorldSingularity.getTranslationKey() );
|
||||
}
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_SINGULARITY)) {
|
||||
this.addDescription(registry, materials.qESingularity(), GuiText.inWorldSingularity.getTranslationKey());
|
||||
}
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_PURIFICATION ) )
|
||||
{
|
||||
this.addDescription( registry, materials.purifiedCertusQuartzCrystal(), GuiText.inWorldPurificationCertus.getTranslationKey() );
|
||||
this.addDescription( registry, materials.purifiedNetherQuartzCrystal(), GuiText.inWorldPurificationNether.getTranslationKey() );
|
||||
this.addDescription( registry, materials.purifiedFluixCrystal(), GuiText.inWorldPurificationFluix.getTranslationKey() );
|
||||
}
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_PURIFICATION)) {
|
||||
this.addDescription(registry, materials.purifiedCertusQuartzCrystal(),
|
||||
GuiText.inWorldPurificationCertus.getTranslationKey());
|
||||
this.addDescription(registry, materials.purifiedNetherQuartzCrystal(),
|
||||
GuiText.inWorldPurificationNether.getTranslationKey());
|
||||
this.addDescription(registry, materials.purifiedFluixCrystal(),
|
||||
GuiText.inWorldPurificationFluix.getTranslationKey());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void addDescription(IRecipeRegistration registry, IItemDefinition itemDefinition, String... message )
|
||||
{
|
||||
registry.addIngredientInfo( itemDefinition.stack(1), VanillaTypes.ITEM, message );
|
||||
}
|
||||
private void addDescription(IRecipeRegistration registry, IItemDefinition itemDefinition, String... message) {
|
||||
registry.addIngredientInfo(itemDefinition.stack(1), VanillaTypes.ITEM, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable( IJeiRuntime jeiRuntime )
|
||||
{
|
||||
JEIFacade.setInstance(new JeiRuntimeAdapter(jeiRuntime));
|
||||
}
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
|
||||
JEIFacade.setInstance(new JeiRuntimeAdapter(jeiRuntime));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,36 +18,32 @@
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import appeng.integration.abstraction.IJEI;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import mezz.jei.api.runtime.IJeiRuntime;
|
||||
|
||||
class JeiRuntimeAdapter implements IJEI
|
||||
{
|
||||
import appeng.integration.abstraction.IJEI;
|
||||
|
||||
private final IJeiRuntime runtime;
|
||||
class JeiRuntimeAdapter implements IJEI {
|
||||
|
||||
JeiRuntimeAdapter( IJeiRuntime jeiRuntime )
|
||||
{
|
||||
this.runtime = jeiRuntime;
|
||||
}
|
||||
private final IJeiRuntime runtime;
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
JeiRuntimeAdapter(IJeiRuntime jeiRuntime) {
|
||||
this.runtime = jeiRuntime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSearchText()
|
||||
{
|
||||
return Strings.nullToEmpty( this.runtime.getIngredientFilter().getFilterText() );
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSearchText( String searchText )
|
||||
{
|
||||
this.runtime.getIngredientFilter().setFilterText( Strings.nullToEmpty( searchText ) );
|
||||
}
|
||||
@Override
|
||||
public String getSearchText() {
|
||||
return Strings.nullToEmpty(this.runtime.getIngredientFilter().getFilterText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSearchText(String searchText) {
|
||||
this.runtime.getIngredientFilter().setFilterText(Strings.nullToEmpty(searchText));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,12 @@
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketJEIRecipe;
|
||||
import appeng.util.Platform;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.ingredient.IGuiIngredient;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
@@ -36,96 +31,89 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.ingredient.IGuiIngredient;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketJEIRecipe;
|
||||
import appeng.util.Platform;
|
||||
|
||||
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T>
|
||||
{
|
||||
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T> {
|
||||
|
||||
private final Class<T> containerClass;
|
||||
private final Class<T> containerClass;
|
||||
|
||||
RecipeTransferHandler( Class<T> containerClass )
|
||||
{
|
||||
this.containerClass = containerClass;
|
||||
}
|
||||
RecipeTransferHandler(Class<T> containerClass) {
|
||||
this.containerClass = containerClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getContainerClass()
|
||||
{
|
||||
return this.containerClass;
|
||||
}
|
||||
@Override
|
||||
public Class<T> getContainerClass() {
|
||||
return this.containerClass;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe(T container, IRecipeLayout recipeLayout, PlayerEntity player, boolean maxTransfer, boolean doTransfer) {
|
||||
if( !doTransfer )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe(T container, IRecipeLayout recipeLayout, PlayerEntity player,
|
||||
boolean maxTransfer, boolean doTransfer) {
|
||||
if (!doTransfer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks().getGuiIngredients();
|
||||
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks()
|
||||
.getGuiIngredients();
|
||||
|
||||
final CompoundNBT recipe = new CompoundNBT();
|
||||
final CompoundNBT recipe = new CompoundNBT();
|
||||
|
||||
int slotIndex = 0;
|
||||
for( Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> ingredientEntry : ingredients.entrySet() )
|
||||
{
|
||||
IGuiIngredient<ItemStack> ingredient = ingredientEntry.getValue();
|
||||
if( !ingredient.isInput() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int slotIndex = 0;
|
||||
for (Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> ingredientEntry : ingredients.entrySet()) {
|
||||
IGuiIngredient<ItemStack> ingredient = ingredientEntry.getValue();
|
||||
if (!ingredient.isInput()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for( final Slot slot : container.inventorySlots )
|
||||
{
|
||||
if( slot instanceof SlotCraftingMatrix || slot instanceof SlotFakeCraftingMatrix)
|
||||
{
|
||||
if( slot.getSlotIndex() == slotIndex )
|
||||
{
|
||||
final ListNBT tags = new ListNBT();
|
||||
final List<ItemStack> list = new ArrayList<>();
|
||||
final ItemStack displayed = ingredient.getDisplayedIngredient();
|
||||
for (final Slot slot : container.inventorySlots) {
|
||||
if (slot instanceof SlotCraftingMatrix || slot instanceof SlotFakeCraftingMatrix) {
|
||||
if (slot.getSlotIndex() == slotIndex) {
|
||||
final ListNBT tags = new ListNBT();
|
||||
final List<ItemStack> list = new ArrayList<>();
|
||||
final ItemStack displayed = ingredient.getDisplayedIngredient();
|
||||
|
||||
// prefer currently displayed item
|
||||
if( displayed != null && !displayed.isEmpty() )
|
||||
{
|
||||
list.add( displayed );
|
||||
}
|
||||
// prefer currently displayed item
|
||||
if (displayed != null && !displayed.isEmpty()) {
|
||||
list.add(displayed);
|
||||
}
|
||||
|
||||
// prefer pure crystals.
|
||||
for( ItemStack stack : ingredient.getAllIngredients() )
|
||||
{
|
||||
if( Platform.isRecipePrioritized( stack ) )
|
||||
{
|
||||
list.add( 0, stack );
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add( stack );
|
||||
}
|
||||
}
|
||||
// prefer pure crystals.
|
||||
for (ItemStack stack : ingredient.getAllIngredients()) {
|
||||
if (Platform.isRecipePrioritized(stack)) {
|
||||
list.add(0, stack);
|
||||
} else {
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
for( final ItemStack is : list )
|
||||
{
|
||||
final CompoundNBT tag = new CompoundNBT();
|
||||
is.write( tag );
|
||||
tags.add( tag );
|
||||
}
|
||||
for (final ItemStack is : list) {
|
||||
final CompoundNBT tag = new CompoundNBT();
|
||||
is.write(tag);
|
||||
tags.add(tag);
|
||||
}
|
||||
|
||||
recipe.put( "#" + slot.getSlotIndex(), tags );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
recipe.put("#" + slot.getSlotIndex(), tags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slotIndex++;
|
||||
}
|
||||
slotIndex++;
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketJEIRecipe( recipe ) );
|
||||
NetworkHandler.instance().sendToServer(new PacketJEIRecipe(recipe));
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user