Basic JEI integration is back

This commit is contained in:
Sebastian Hartte
2020-06-10 20:27:19 +02:00
parent 19e7fd3544
commit 8ccc114f92
280 changed files with 1945 additions and 1374 deletions
@@ -0,0 +1,38 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration;
public interface IIntegrationModule
{
default boolean isEnabled()
{
return true;
}
class Stub implements IIntegrationModule
{
@Override
public boolean isEnabled()
{
return false;
}
}
}
@@ -0,0 +1,43 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.abstraction;
import appeng.integration.IIntegrationModule;
/**
* Abstracts access to the JEI API functionality.
*/
public interface IJEI extends IIntegrationModule
{
default String getSearchText()
{
return "";
}
default void setSearchText( String searchText )
{
}
class Stub extends IIntegrationModule.Stub implements IJEI
{
}
}
@@ -0,0 +1,213 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.jei;
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 mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.drawable.IDrawableAnimated;
import mezz.jei.api.gui.drawable.IDrawableStatic;
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.*;
class CondenserCategory implements IRecipeCategory<CondenserOutput>
{
public static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "condenser");
private final String localizedName;
private final IDrawable background;
private final IDrawable iconTrash;
private final IDrawableAnimated progress;
private final IDrawable iconButton;
private final IDrawable icon;
private final HoverChecker buttonHoverChecker;
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));
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();
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.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;
}
}
@Override
public ResourceLocation getUid()
{
return CondenserCategory.UID;
}
@Override
public Class<? extends CondenserOutput> getRecipeClass() {
return CondenserOutput.class;
}
@Override
public String getTitle()
{
return this.localizedName;
}
@Override
public IDrawable getBackground()
{
return this.background;
}
@Override
public IDrawable getIcon() {
return icon;
}
@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();
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 );
// 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 );
}
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 );
}
}
@Override
public List<String> getTooltipStrings(CondenserOutput output, double mouseX, double mouseY) {
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();
}
return Splitter.on( "\\n" ).splitToList( I18n.format( key, output.requiredPower ) );
}
return Collections.emptyList();
}
}
@@ -0,0 +1,149 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.jei;
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;
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;
class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipe>
{
public static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "grinder");
private final String localizedName;
private final IDrawable background;
private final IDrawable icon;
public GrinderRecipeCategory( IGuiHelper guiHelper )
{
this.localizedName = I18n.format( "tile.appliedenergistics2.grindstone.name" );
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));
}
@Override
public ResourceLocation getUid()
{
return GrinderRecipeCategory.UID;
}
@Override
public String getTitle()
{
return this.localizedName;
}
@Override
public IDrawable getBackground()
{
return this.background;
}
@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.set( ingredients );
}
@Override
public Class<? extends GrinderRecipe> getRecipeClass() {
return GrinderRecipe.class;
}
@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 );
}
// FIXME USE SPECIAL INGREDIENT TYPE
// FIXME @Override
// FIXME public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY )
// FIXME {
// FIXME
// FIXME FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
// FIXME
// FIXME int x = 118;
// FIXME
// FIXME final float scale = 0.85f;
// FIXME final float invScale = 1 / scale;
// FIXME GlStateManager.scale( scale, scale, 1 );
// FIXME
// FIXME if( this.recipe.getOptionalOutput() != null )
// FIXME {
// FIXME String text = String.format( "%d%%", (int) ( this.recipe.getOptionalChance() * 100 ) );
// FIXME float width = fr.getStringWidth( text ) * scale;
// FIXME int xScaled = Math.round( ( x + ( 18 - width ) / 2 ) * invScale );
// FIXME fr.drawString( text, xScaled, (int) ( 65 * invScale ), Color.gray.getRGB() );
// FIXME x += 18;
// FIXME }
// FIXME
// FIXME if( this.recipe.getSecondOptionalOutput() != null )
// FIXME {
// FIXME String text = String.format( "%d%%", (int) ( this.recipe.getSecondOptionalChance() * 100 ) );
// FIXME float width = fr.getStringWidth( text ) * scale;
// FIXME int xScaled = Math.round( ( x + ( 18 - width ) / 2 ) * invScale );
// FIXME fr.drawString( text, xScaled, (int) ( 65 * invScale ), Color.gray.getRGB() );
// FIXME }
// FIXME
// FIXME GlStateManager.scale( invScale, invScale, 1 );
// FIXME }
}
@@ -0,0 +1,127 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.jei;
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;
import mezz.jei.api.gui.drawable.IDrawableAnimated;
import mezz.jei.api.gui.drawable.IDrawableStatic;
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.util.ResourceLocation;
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;
static final ResourceLocation UID = new ResourceLocation(AppEng.MOD_ID, "appliedenergistics2.inscriber");
private final IDrawable background;
private final String localizedName;
private final IDrawableAnimated progress;
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( "tile.appliedenergistics2.inscriber.name" );
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));
}
@Override
public ResourceLocation getUid()
{
return UID;
}
@Override
public String getTitle()
{
return this.localizedName;
}
@Override
public IDrawable getBackground()
{
return this.background;
}
@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.set( ingredients );
}
@Override
public Class<? extends InscriberRecipe> getRecipeClass() {
return InscriberRecipe.class;
}
@Override
public IDrawable getIcon() {
return this.icon;
}
@Override
public void setIngredients(InscriberRecipe recipe, IIngredients ingredients) {
// FIXME List<List<ItemStack>> inputSlots = new ArrayList<>( 3 );
// FIXME inputSlots.add( Collections.singletonList( recipe.getTopOptional() ) );
// FIXME inputSlots.add( recipe.getInputs() );
// FIXME inputSlots.add( Collections.singletonList( recipe.getBottomOptional() ) );
// FIXME ingredients.setInputLists(VanillaTypes.ITEM, inputSlots );
ingredients.setOutput( VanillaTypes.ITEM, recipe.getOutput() );
}
@Override
public void draw(InscriberRecipe recipe, double mouseX, double mouseY) {
this.progress.draw();
}
}
@@ -0,0 +1,58 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.jei;
import appeng.integration.abstraction.IJEI;
public class JEIModule implements IJEI
{
private IJEI jei = new IJEI.Stub();
public void setJei( IJEI jei )
{
this.jei = jei;
}
public IJEI getJei()
{
return this.jei;
}
@Override
public String getSearchText()
{
return this.jei.getSearchText();
}
@Override
public void setSearchText( String searchText )
{
this.jei.setSearchText( searchText );
}
@Override
public boolean isEnabled()
{
return this.jei.isEnabled();
}
}
@@ -0,0 +1,190 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.jei;
import appeng.api.AEApi;
import appeng.api.config.CondenserOutput;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IMaterials;
import appeng.api.features.AEFeature;
import appeng.container.implementations.ContainerCraftingTerm;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.localization.GuiText;
import appeng.recipes.handlers.GrinderRecipe;
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");
@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 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 registerRecipes(IRecipeRegistration registration) {
IDefinitions definitions = AEApi.instance().definitions();
// FIXME Optional<Item> itemFacade = definitions.items().facade().maybeItem();
// FIXME Optional<ItemStack> cableAnchor = definitions.parts().cableAnchor().maybeStack( 1 );
// FIXME if( itemFacade.isPresent() && cableAnchor.isPresent() && AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_FACADE_CRAFTING ) )
// FIXME {
// FIXME registration.addRecipeRegistryPlugin( new FacadeRegistryPlugin( (ItemFacade) itemFacade.get(), cableAnchor.get() ) );
// FIXME }
ItemStack condenser = definitions.blocks().condenser().maybeStack( 1 ).orElse( ItemStack.EMPTY );
if(!condenser.isEmpty()) {
ItemStack matterBall = definitions.materials().matterBall().maybeStack(1).orElse(ItemStack.EMPTY);
if (!matterBall.isEmpty()) {
registration.addRecipes(ImmutableList.of(CondenserOutput.MATTER_BALLS), CondenserCategory.UID);
}
ItemStack singularity = definitions.materials().singularity().maybeStack(1).orElse(ItemStack.EMPTY);
if (!singularity.isEmpty()) {
registration.addRecipes(ImmutableList.of(CondenserOutput.SINGULARITY), CondenserCategory.UID);
}
}
RecipeManager recipeManager = Minecraft.getInstance().world.getRecipeManager();
registration.addRecipes(recipeManager.getRecipes(GrinderRecipe.TYPE).values(), GrinderRecipeCategory.UID);
// FIXME registration.addRecipes( recipeManager.getRecipes(InscriberRecipe.TYPE), InscriberRecipeCategory.UID );
registration.addRecipes(ImmutableList.of(CondenserOutput.MATTER_BALLS, CondenserOutput.SINGULARITY), CondenserCategory.UID);
}
@Override
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
IDefinitions definitions = AEApi.instance().definitions();
ItemStack grindstone = definitions.blocks().grindstone().maybeStack( 1 ).orElse( ItemStack.EMPTY );
if( !grindstone.isEmpty() )
{
registration.addRecipeCatalyst( grindstone, GrinderRecipeCategory.UID );
}
definitions.blocks().condenser().maybeStack( 1 ).ifPresent(condenser -> {
registration.addRecipeCatalyst(condenser, CondenserCategory.UID);
});
// Register the inscriber as the crafting item for the inscription category
definitions.blocks().inscriber().maybeStack( 1 ).ifPresent( inscriber ->
{
registration.addRecipeCatalyst( inscriber, InscriberRecipeCategory.UID );
} );
}
private void registerDescriptions(IDefinitions definitions, IRecipeRegistration registry )
{
IMaterials materials = definitions.materials();
final String message;
if( AEConfig.instance().isFeatureEnabled( AEFeature.CERTUS_QUARTZ_WORLD_GEN ) )
{
message = GuiText.ChargedQuartz.getLocal() + "\n\n" + GuiText.ChargedQuartzFind.getLocal();
}
else
{
message = GuiText.ChargedQuartzFind.getLocal();
}
this.addDescription( registry, materials.certusQuartzCrystalCharged(), message );
if( AEConfig.instance().isFeatureEnabled( AEFeature.METEORITE_WORLD_GEN ) )
{
this.addDescription( registry, materials.logicProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
this.addDescription( registry, materials.calcProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
this.addDescription( registry, materials.engProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
}
if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_FLUIX ) )
{
this.addDescription( registry, materials.fluixCrystal(), GuiText.inWorldFluix.getLocal() );
}
if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_SINGULARITY ) )
{
this.addDescription( registry, materials.qESingularity(), GuiText.inWorldSingularity.getLocal() );
}
if( AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_PURIFICATION ) )
{
this.addDescription( registry, materials.purifiedCertusQuartzCrystal(), GuiText.inWorldPurificationCertus.getLocal() );
this.addDescription( registry, materials.purifiedNetherQuartzCrystal(), GuiText.inWorldPurificationNether.getLocal() );
this.addDescription( registry, materials.purifiedFluixCrystal(), GuiText.inWorldPurificationFluix.getLocal() );
}
}
private void addDescription(IRecipeRegistration registry, IItemDefinition itemDefinition, String message )
{
itemDefinition.maybeStack( 1 ).ifPresent( itemStack -> registry.addIngredientInfo( itemStack, VanillaTypes.ITEM, message ) );
}
@Override
public void onRuntimeAvailable( IJeiRuntime jeiRuntime )
{
// FIXME JEIModule jeiModule = (JEIModule) Integrations.jei();
// FIXME jeiModule.setJei( new JeiRuntimeAdapter( jeiRuntime ) );
}
}
@@ -0,0 +1,53 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
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
{
private final IJeiRuntime runtime;
JeiRuntimeAdapter( IJeiRuntime jeiRuntime )
{
this.runtime = jeiRuntime;
}
@Override
public boolean isEnabled()
{
return true;
}
@Override
public String getSearchText()
{
return Strings.nullToEmpty( this.runtime.getIngredientFilter().getFilterText() );
}
@Override
public void setSearchText( String searchText )
{
this.runtime.getIngredientFilter().setFilterText( Strings.nullToEmpty( searchText ) );
}
}
@@ -0,0 +1,131 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.jei;
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;
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;
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T>
{
private final Class<T> containerClass;
RecipeTransferHandler( Class<T> containerClass )
{
this.containerClass = 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;
}
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks().getGuiIngredients();
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;
}
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 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 );
}
recipe.put( "#" + slot.getSlotIndex(), tags );
break;
}
}
}
slotIndex++;
}
NetworkHandler.instance().sendToServer( new PacketJEIRecipe( recipe ) );
return null;
}
}