Add JEI transfer support for ContainerBuilder + Convert Compressor, Extractor and Grinder
This commit is contained in:
parent
1df2c84e16
commit
94a0616d8e
28 changed files with 401 additions and 433 deletions
|
@ -0,0 +1,61 @@
|
|||
package techreborn.compat.jei;
|
||||
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferInfo;
|
||||
|
||||
public class BuiltContainerTransferInfo implements IRecipeTransferInfo<BuiltContainer> {
|
||||
|
||||
private final String containerName, recipeCategory;
|
||||
|
||||
private final int recipeSlotStart, recipeSlotCount, inventorySlotStart, inventorySlotCount;
|
||||
|
||||
public BuiltContainerTransferInfo(final String containerName, final String recipeCategory,
|
||||
final int recipeSlotStart, final int recipeSlotCount, final int inventorySlotStart,
|
||||
final int inventorySlotCount) {
|
||||
this.containerName = containerName;
|
||||
this.recipeCategory = recipeCategory;
|
||||
|
||||
this.recipeSlotStart = recipeSlotStart;
|
||||
this.recipeSlotCount = recipeSlotCount;
|
||||
|
||||
this.inventorySlotStart = inventorySlotStart;
|
||||
this.inventorySlotCount = inventorySlotCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<BuiltContainer> getContainerClass() {
|
||||
return BuiltContainer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return this.recipeCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(final BuiltContainer container) {
|
||||
return container.getName().equals(this.containerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Slot> getRecipeSlots(final BuiltContainer container) {
|
||||
final List<Slot> slots = new ArrayList<>();
|
||||
for (int i = this.recipeSlotStart; i < this.recipeSlotStart + this.recipeSlotCount; i++)
|
||||
slots.add(container.getSlot(i));
|
||||
return slots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Slot> getInventorySlots(final BuiltContainer container) {
|
||||
final List<Slot> slots = new ArrayList<>();
|
||||
for (int i = this.inventorySlotStart; i < this.inventorySlotStart + this.inventorySlotCount; i++)
|
||||
slots.add(container.getSlot(i));
|
||||
return slots;
|
||||
}
|
||||
}
|
|
@ -1,16 +1,13 @@
|
|||
package techreborn.compat.jei;
|
||||
|
||||
import mezz.jei.api.BlankModPlugin;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
|
||||
import mezz.jei.config.Config;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
|
||||
import techreborn.Core;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.api.generator.GeneratorRecipeHelper;
|
||||
|
@ -62,26 +59,33 @@ import techreborn.items.ItemParts;
|
|||
import techreborn.parts.TechRebornParts;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mezz.jei.api.BlankModPlugin;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
|
||||
import mezz.jei.config.Config;
|
||||
|
||||
@mezz.jei.api.JEIPlugin
|
||||
public class TechRebornJeiPlugin extends BlankModPlugin {
|
||||
private static void addDebugRecipes(IModRegistry registry) {
|
||||
ItemStack diamondBlock = new ItemStack(Blocks.DIAMOND_BLOCK);
|
||||
ItemStack dirtBlock = new ItemStack(Blocks.DIRT);
|
||||
List<Object> debugRecipes = new ArrayList<>();
|
||||
private static void addDebugRecipes(final IModRegistry registry) {
|
||||
final ItemStack diamondBlock = new ItemStack(Blocks.DIAMOND_BLOCK);
|
||||
final ItemStack dirtBlock = new ItemStack(Blocks.DIRT);
|
||||
final List<Object> debugRecipes = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int time = (int) Math.round(200 + Math.random() * 100);
|
||||
AssemblingMachineRecipe assemblingMachineRecipe = new AssemblingMachineRecipe(diamondBlock, diamondBlock,
|
||||
dirtBlock, time, 120);
|
||||
final int time = (int) Math.round(200 + Math.random() * 100);
|
||||
final AssemblingMachineRecipe assemblingMachineRecipe = new AssemblingMachineRecipe(diamondBlock, diamondBlock,
|
||||
dirtBlock, time, 120);
|
||||
debugRecipes.add(assemblingMachineRecipe);
|
||||
}
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int time = (int) Math.round(200 + Math.random() * 100);
|
||||
ImplosionCompressorRecipe recipe = new ImplosionCompressorRecipe(diamondBlock, diamondBlock, dirtBlock,
|
||||
dirtBlock, time, 120);
|
||||
final int time = (int) Math.round(200 + Math.random() * 100);
|
||||
final ImplosionCompressorRecipe recipe = new ImplosionCompressorRecipe(diamondBlock, diamondBlock, dirtBlock,
|
||||
dirtBlock, time, 120);
|
||||
debugRecipes.add(recipe);
|
||||
}
|
||||
registry.addRecipes(debugRecipes);
|
||||
|
@ -89,10 +93,10 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
|
||||
@Override
|
||||
public void register(
|
||||
@Nonnull
|
||||
@Nonnull final
|
||||
IModRegistry registry) {
|
||||
IJeiHelpers jeiHelpers = registry.getJeiHelpers();
|
||||
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
|
||||
final IJeiHelpers jeiHelpers = registry.getJeiHelpers();
|
||||
final IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
|
||||
|
||||
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModFluids.BLOCK_BERYLLIUM));
|
||||
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModFluids.BLOCK_CALCIUM));
|
||||
|
@ -129,7 +133,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModItems.MISSING_RECIPE_PLACEHOLDER));
|
||||
|
||||
if(IC2Duplicates.deduplicate()){
|
||||
for(IC2Duplicates duplicate : IC2Duplicates.values()){
|
||||
for(final IC2Duplicates duplicate : IC2Duplicates.values()){
|
||||
if(duplicate.hasIC2Stack()){
|
||||
jeiHelpers.getItemBlacklist().addItemToBlacklist(duplicate.getTrStack());
|
||||
}
|
||||
|
@ -162,7 +166,7 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper),
|
||||
new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper));
|
||||
|
||||
for(EFluidGenerator type : EFluidGenerator.values())
|
||||
for(final EFluidGenerator type : EFluidGenerator.values())
|
||||
registry.addRecipeCategories(new FluidGeneratorRecipeCategory(type, guiHelper));
|
||||
|
||||
registry.addRecipeHandlers(new AlloySmelterRecipeHandler(jeiHelpers),
|
||||
|
@ -182,28 +186,28 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
|
||||
try {
|
||||
registry.addRecipes(RollingMachineRecipeMaker.getRecipes(jeiHelpers));
|
||||
} catch (RuntimeException e) {
|
||||
} catch (final RuntimeException e) {
|
||||
Core.logHelper
|
||||
.error("Could not register rolling machine recipes. JEI may have changed its internal recipe wrapper locations.");
|
||||
.error("Could not register rolling machine recipes. JEI may have changed its internal recipe wrapper locations.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (Config.isDebugModeEnabled()) {
|
||||
addDebugRecipes(registry);
|
||||
TechRebornJeiPlugin.addDebugRecipes(registry);
|
||||
}
|
||||
|
||||
registry.addDescription(ItemParts.getPartByName("rubberSap"),
|
||||
I18n.translateToLocal("techreborn.desc.rubberSap"));
|
||||
I18n.translateToLocal("techreborn.desc.rubberSap"));
|
||||
if (!ConfigTechReborn.ScrapboxDispenser) {
|
||||
registry.addDescription(new ItemStack(ModItems.SCRAP_BOX),
|
||||
I18n.translateToLocal("techreborn.desc.scrapBoxNoDispenser"));
|
||||
I18n.translateToLocal("techreborn.desc.scrapBoxNoDispenser"));
|
||||
} else {
|
||||
registry.addDescription(new ItemStack(ModItems.SCRAP_BOX),
|
||||
I18n.translateToLocal("techreborn.desc.scrapBox"));
|
||||
I18n.translateToLocal("techreborn.desc.scrapBox"));
|
||||
}
|
||||
|
||||
registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER,
|
||||
VanillaRecipeCategoryUid.FUEL);
|
||||
VanillaRecipeCategoryUid.FUEL);
|
||||
registry.addRecipeClickArea(GuiAlloySmelter.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER);
|
||||
registry.addRecipeClickArea(GuiAssemblingMachine.class, 85, 34, 24, 20, RecipeCategoryUids.ASSEMBLING_MACHINE);
|
||||
registry.addRecipeClickArea(GuiBlastFurnace.class, 63, 36, 24, 15, RecipeCategoryUids.BLAST_FURNACE);
|
||||
|
@ -215,16 +219,16 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
registry.addRecipeClickArea(GuiFusionReactor.class, 111, 34, 27, 19, RecipeCategoryUids.FUSION_REACTOR);
|
||||
registry.addRecipeClickArea(GuiIndustrialGrinder.class, 50, 35, 25, 16, RecipeCategoryUids.INDUSTRIAL_GRINDER);
|
||||
registry.addRecipeClickArea(GuiImplosionCompressor.class, 60, 37, 24, 15,
|
||||
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
|
||||
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
|
||||
registry.addRecipeClickArea(GuiIndustrialElectrolyzer.class, 72, 37, 33, 14,
|
||||
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
|
||||
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
|
||||
registry.addRecipeClickArea(GuiRollingMachine.class, 89, 32, 26, 25, RecipeCategoryUids.ROLLING_MACHINE);
|
||||
registry.addRecipeClickArea(GuiVacuumFreezer.class, 78, 36, 24, 16, RecipeCategoryUids.VACUUM_FREEZER);
|
||||
registry.addRecipeClickArea(GuiGrinder.class, 78, 36, 24, 16, RecipeCategoryUids.GRINDER);
|
||||
registry.addRecipeClickArea(GuiExtractor.class, 78, 36, 24, 16, RecipeCategoryUids.EXTRACTOR);
|
||||
registry.addRecipeClickArea(GuiCompressor.class, 78, 36, 24, 16, RecipeCategoryUids.COMPRESSOR);
|
||||
registry.addRecipeClickArea(GuiIronFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING,
|
||||
VanillaRecipeCategoryUid.FUEL);
|
||||
VanillaRecipeCategoryUid.FUEL);
|
||||
registry.addRecipeClickArea(GuiElectricFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING);
|
||||
|
||||
registry.addRecipeClickArea(GuiSemifluidGenerator.class, 79, 34, 18, 18,
|
||||
|
@ -240,23 +244,23 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IRON_ALLOY_FURNACE), RecipeCategoryUids.ALLOY_SMELTER);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ALLOY_SMELTER), RecipeCategoryUids.ALLOY_SMELTER);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ASSEMBLY_MACHINE),
|
||||
RecipeCategoryUids.ASSEMBLING_MACHINE);
|
||||
RecipeCategoryUids.ASSEMBLING_MACHINE);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_BLAST_FURNACE), RecipeCategoryUids.BLAST_FURNACE);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_CENTRIFUGE), RecipeCategoryUids.CENTRIFUGE);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.CHEMICAL_REACTOR),
|
||||
RecipeCategoryUids.CHEMICAL_REACTOR);
|
||||
RecipeCategoryUids.CHEMICAL_REACTOR);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.EXTRACTOR), RecipeCategoryUids.EXTRACTOR);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.FUSION_CONTROL_COMPUTER),
|
||||
RecipeCategoryUids.FUSION_REACTOR);
|
||||
RecipeCategoryUids.FUSION_REACTOR);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.GRINDER), RecipeCategoryUids.GRINDER);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.IMPLOSION_COMPRESSOR),
|
||||
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
|
||||
RecipeCategoryUids.IMPLOSION_COMPRESSOR);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_ELECTROLYZER),
|
||||
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
|
||||
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.INDUSTRIAL_GRINDER),
|
||||
RecipeCategoryUids.INDUSTRIAL_GRINDER);
|
||||
RecipeCategoryUids.INDUSTRIAL_GRINDER);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.ROLLING_MACHINE),
|
||||
RecipeCategoryUids.ROLLING_MACHINE);
|
||||
RecipeCategoryUids.ROLLING_MACHINE);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModItems.SCRAP_BOX), RecipeCategoryUids.SCRAPBOX);
|
||||
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.SEMIFLUID_GENERATOR),
|
||||
|
@ -268,43 +272,44 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.THERMAL_GENERATOR),
|
||||
EFluidGenerator.THERMAL.getRecipeID());
|
||||
|
||||
IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
|
||||
final IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36);
|
||||
.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerAlloySmelter.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 8, 36);
|
||||
.addRecipeTransferHandler(ContainerAlloySmelter.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 8, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerAlloyFurnace.class, VanillaRecipeCategoryUid.FUEL, 3, 1, 4, 36);
|
||||
.addRecipeTransferHandler(ContainerAlloyFurnace.class, VanillaRecipeCategoryUid.FUEL, 3, 1, 4, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerAssemblingMachine.class, RecipeCategoryUids.ASSEMBLING_MACHINE, 0, 2,
|
||||
.addRecipeTransferHandler(ContainerAssemblingMachine.class, RecipeCategoryUids.ASSEMBLING_MACHINE, 0, 2,
|
||||
8, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
|
||||
.addRecipeTransferHandler(ContainerBlastFurnace.class, RecipeCategoryUids.BLAST_FURNACE, 0, 2, 4, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerCentrifuge.class, RecipeCategoryUids.CENTRIFUGE, 0, 2, 11, 36);
|
||||
.addRecipeTransferHandler(ContainerCentrifuge.class, RecipeCategoryUids.CENTRIFUGE, 0, 2, 11, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerChemicalReactor.class, RecipeCategoryUids.CHEMICAL_REACTOR, 0, 2, 8,
|
||||
.addRecipeTransferHandler(ContainerChemicalReactor.class, RecipeCategoryUids.CHEMICAL_REACTOR, 0, 2, 8,
|
||||
36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
|
||||
.addRecipeTransferHandler(ContainerFusionReactor.class, RecipeCategoryUids.FUSION_REACTOR, 0, 2, 3, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerIndustrialGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36);
|
||||
.addRecipeTransferHandler(ContainerIndustrialGrinder.class, RecipeCategoryUids.GRINDER, 0, 2, 6, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerImplosionCompressor.class, RecipeCategoryUids.IMPLOSION_COMPRESSOR,
|
||||
.addRecipeTransferHandler(ContainerImplosionCompressor.class, RecipeCategoryUids.IMPLOSION_COMPRESSOR,
|
||||
0, 2, 4, 36);
|
||||
recipeTransferRegistry.addRecipeTransferHandler(ContainerIndustrialElectrolyzer.class,
|
||||
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36);
|
||||
RecipeCategoryUids.INDUSTRIAL_ELECTROLYZER, 0, 2, 7, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11,
|
||||
.addRecipeTransferHandler(ContainerRollingMachine.class, RecipeCategoryUids.ROLLING_MACHINE, 0, 9, 11,
|
||||
36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerGrinder.class, RecipeCategoryUids.GRINDER, 0, 1, 2, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerExtractor.class, RecipeCategoryUids.EXTRACTOR, 0, 1, 2, 36);
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerCompressor.class, RecipeCategoryUids.COMPRESSOR, 0, 1, 2, 36);
|
||||
.addRecipeTransferHandler(ContainerVacuumFreezer.class, RecipeCategoryUids.VACUUM_FREEZER, 0, 1, 2, 36);
|
||||
|
||||
recipeTransferRegistry.addRecipeTransferHandler(
|
||||
new BuiltContainerTransferInfo("grinder", RecipeCategoryUids.GRINDER, 36, 1, 0, 36));
|
||||
recipeTransferRegistry.addRecipeTransferHandler(
|
||||
new BuiltContainerTransferInfo("extractor", RecipeCategoryUids.EXTRACTOR, 36, 1, 0, 36));
|
||||
recipeTransferRegistry.addRecipeTransferHandler(
|
||||
new BuiltContainerTransferInfo("compressor", RecipeCategoryUids.COMPRESSOR, 36, 1, 0, 36));
|
||||
|
||||
if (CompatManager.isQuantumStorageLoaded) {
|
||||
registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.QUANTUM_CHEST));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue