Skip to content

Commit

Permalink
Add config option to show all Ender IO powered spwner variants in NEI (
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba6000 authored Jul 15, 2023
1 parent 7998214 commit c9308ba
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 20 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/kuba6000/mobsinfo/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ private static void load(Configuration configuration) {
public static class Compatibility {

public static boolean enableMobHandlerInfernal = true;
public static boolean addAllEnderIOSpawnersToNEI = false;

private static void load(Configuration configuration) {
Category category = Category.COMPATIBILITY;
Expand All @@ -130,6 +131,13 @@ private static void load(Configuration configuration) {
true,
"Enables \"Infernal Drops\" NEI page if Infernal-Mobs mod is loaded.")
.getBoolean();
addAllEnderIOSpawnersToNEI = configuration
.get(
category.get(),
"addAllEnderIOSpawnersToNEI",
false,
"Adds all mob variants EnderIO powered spawners to NEI.")
.getBoolean();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.kuba6000.mobsinfo.mixin.EnderIO;

import net.minecraft.item.ItemStack;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import crazypants.enderio.machine.spawner.BlockPoweredSpawner;

@Mixin(value = BlockPoweredSpawner.class, remap = false)
public interface BlockPoweredSpawnerAccessor {

@Invoker
ItemStack callCreateItemStackForMob(String mob);

}
1 change: 1 addition & 0 deletions src/main/java/com/kuba6000/mobsinfo/mixin/Mixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public enum Mixin {

// Ender IO
ItemSoulVesselAccessor("EnderIO.ItemSoulVesselAccessor", ENDER_IO),
BlockPoweredSpawnerAccessor("EnderIO.BlockPoweredSpawnerAccessor", ENDER_IO),

// Draconic Evolution
MinecraftForgeEventHandlerAccessor("DraconicEvolution.MinecraftForgeEventHandlerAccessor", DRACONIC_EVOLUTION),
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/kuba6000/mobsinfo/nei/EnderIOGetter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.kuba6000.mobsinfo.nei;

import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;

import com.kuba6000.mobsinfo.mixin.EnderIO.BlockPoweredSpawnerAccessor;

import crazypants.enderio.EnderIO;

class EnderIOGetter {

public static Block blockPoweredSpawner() {
return EnderIO.blockPoweredSpawner;
}

public static ItemStack BlockPoweredSpawner$createItemStackForMob(String type) {
return ((BlockPoweredSpawnerAccessor) EnderIO.blockPoweredSpawner).callCreateItemStackForMob(type);
}
}
21 changes: 1 addition & 20 deletions src/main/java/com/kuba6000/mobsinfo/nei/MobHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Objects;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiInventory;
Expand All @@ -44,7 +43,6 @@
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.MinecraftForge;
Expand Down Expand Up @@ -80,8 +78,6 @@
import codechicken.nei.recipe.RecipeCatalysts;
import codechicken.nei.recipe.TemplateRecipeHandler;
import cpw.mods.fml.common.event.FMLInterModComms;
import crazypants.enderio.EnderIO;
import crazypants.enderio.machine.spawner.BlockPoweredSpawner;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.objects.ItemData;
import gregtech.api.util.GT_OreDictUnificator;
Expand Down Expand Up @@ -596,11 +592,7 @@ public MobCachedRecipe(EntityLiving mob, List<MobPositionedStack> mOutputs, int
this.mInput.add(new ItemStack(Blocks.mob_spawner, 1, id));
}
if (LoaderReference.EnderIO) {
ItemStack s = new ItemStack(EnderIOGetter.blockPoweredSpawner(), 1);
NBTTagCompound nbt = new NBTTagCompound();
EnderIOGetter.BlockPoweredSpawner$writeMobTypeToNBT(nbt, mobname);
s.setTagCompound(nbt);
this.mInput.add(0, s);
this.mInput.add(0, EnderIOGetter.BlockPoweredSpawner$createItemStackForMob(mobname));
} else if (id == 0) this.mInput.add(new ItemStack(Items.spawn_egg, 1, 0)); // ???
ingredient = new PositionedStack(this.mInput.get(0), 38, 44, false);
this.isUsableInVial = EnderIOHelper.canEntityBeCapturedWithSoulVial(mob, mobname);
Expand Down Expand Up @@ -633,17 +625,6 @@ public List<PositionedStack> getOtherStacks() {
}
}

private static class EnderIOGetter {

public static Block blockPoweredSpawner() {
return EnderIO.blockPoweredSpawner;
}

public static void BlockPoweredSpawner$writeMobTypeToNBT(NBTTagCompound nbt, String type) {
BlockPoweredSpawner.writeMobTypeToNBT(nbt, type);
}
}

private static class GT5Helper {

public static List<ItemStack> getAssociated(ItemStack aResult) {
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/kuba6000/mobsinfo/nei/NEI_Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@

package com.kuba6000.mobsinfo.nei;

import net.minecraft.item.Item;

import com.kuba6000.mobsinfo.Tags;
import com.kuba6000.mobsinfo.api.LoaderReference;
import com.kuba6000.mobsinfo.api.MobRecipe;
import com.kuba6000.mobsinfo.config.Config;

import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;

public class NEI_Config implements IConfigureNEI {
Expand All @@ -35,6 +40,14 @@ public void loadConfig() {
new MobHandler();
if (LoaderReference.InfernalMobs) new MobHandlerInfernal();
isAdded = true;

if (LoaderReference.EnderIO && Config.Compatibility.addAllEnderIOSpawnersToNEI) {
for (String s : MobRecipe.MobNameToRecipeMap.keySet()) {
API.addItemVariant(
Item.getItemFromBlock(EnderIOGetter.blockPoweredSpawner()),
EnderIOGetter.BlockPoweredSpawner$createItemStackForMob(s));
}
}
}

@Override
Expand Down

0 comments on commit c9308ba

Please sign in to comment.