mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 06:14:41 +00:00
Start on JEI plugin, bump Forge version, fixed Mod ID filters (ItemRegistryUtils)
This commit is contained in:
1 parent
ac7f2f9783
commit
89604ac199
7 files changed
+105
-24
No files matched your search
@@ -12,6 +12,7 @@ import mekanism.common.network.PacketNewFilter.NewFilterMessage;
|
||||
import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage;
|
||||
import mekanism.common.tile.TileEntityOredictionificator;
|
||||
import mekanism.common.tile.TileEntityOredictionificator.OredictionificatorFilter;
|
||||
import mekanism.common.util.ItemRegistryUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
@@ -176,7 +177,7 @@ public class GuiOredictionificatorFilter extends GuiMekanism
|
||||
{
|
||||
if(renderStack != null)
|
||||
{
|
||||
String name = MekanismUtils.getMod(renderStack);
|
||||
String name = ItemRegistryUtils.getMod(renderStack);
|
||||
String extra = name.equals("null") ? "" : " (" + name + ")";
|
||||
|
||||
drawCreativeTabHoveringText(renderStack.getDisplayName() + extra, xAxis, yAxis);
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package mekanism.client.jei;
|
||||
|
||||
import mezz.jei.api.IItemRegistry;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IJeiRuntime;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.IRecipeRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
|
||||
@JEIPlugin
|
||||
public class MekanismJEI implements IModPlugin
|
||||
{
|
||||
@Override
|
||||
public void register(IModRegistry registry)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRegistryAvailable(IItemRegistry registry)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJeiHelpersAvailable(IJeiHelpers helpers)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecipeRegistryAvailable(IRecipeRegistry registry)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime runtime)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.util.ItemInfo;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.ItemRegistryUtils;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -122,7 +122,7 @@ public final class OreDictCache
|
||||
for(ItemStack stack : OreDictionary.getOres(key))
|
||||
{
|
||||
ItemStack toAdd = stack.copy();
|
||||
String s = MekanismUtils.getMod(toAdd);
|
||||
String s = ItemRegistryUtils.getMod(toAdd);
|
||||
|
||||
if(!stacks.contains(stack) && toAdd.getItem() instanceof ItemBlock)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.content.transporter;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.util.ItemRegistryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -128,7 +129,7 @@ public abstract class Finder
|
||||
return false;
|
||||
}
|
||||
|
||||
String id = MekanismUtils.getMod(stack);
|
||||
String id = ItemRegistryUtils.getMod(stack);
|
||||
|
||||
if(modID.equals(id) || modID.equals("*"))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package mekanism.common.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
public class ItemRegistryUtils
|
||||
{
|
||||
private static final Map<String, String> modIDMap = new HashMap<String, String>();
|
||||
|
||||
private static void populateMap()
|
||||
{
|
||||
for(Map.Entry<String, ModContainer> entry : Loader.instance().getIndexedModList().entrySet())
|
||||
{
|
||||
modIDMap.put(entry.getKey().toLowerCase(), entry.getValue().getName());
|
||||
}
|
||||
}
|
||||
|
||||
/* Mod ID lookup thanks to JEI */
|
||||
public static String getMod(ItemStack stack)
|
||||
{
|
||||
if(stack == null || stack.getItem() == null)
|
||||
{
|
||||
return "null";
|
||||
}
|
||||
|
||||
if(modIDMap.isEmpty())
|
||||
{
|
||||
populateMap();
|
||||
}
|
||||
|
||||
ResourceLocation itemResourceLocation = Item.itemRegistry.getNameForObject(stack.getItem());
|
||||
String modId = itemResourceLocation.getResourceDomain();
|
||||
String lowercaseModId = modId.toLowerCase(Locale.ENGLISH);
|
||||
String modName = modIDMap.get(lowercaseModId);
|
||||
|
||||
if(modName == null)
|
||||
{
|
||||
modName = WordUtils.capitalize(modId);
|
||||
modIDMap.put(lowercaseModId, modName);
|
||||
}
|
||||
|
||||
return modName;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,6 @@ import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
@@ -91,7 +90,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -1370,8 +1368,8 @@ public final class MekanismUtils
|
||||
if((dmgItems[1] != null) && (dmgItems[0].getItem() == dmgItems[1].getItem()) && (dmgItems[0].stackSize == 1) && (dmgItems[1].stackSize == 1) && dmgItems[0].getItem().isRepairable())
|
||||
{
|
||||
Item theItem = dmgItems[0].getItem();
|
||||
int dmgDiff0 = theItem.getMaxDamage() - dmgItems[0].getItemDamage/*TODO:ForDisplay*/();
|
||||
int dmgDiff1 = theItem.getMaxDamage() - dmgItems[1].getItemDamage/*TODO:ForDisplay*/();
|
||||
int dmgDiff0 = theItem.getMaxDamage() - dmgItems[0].getItemDamage();
|
||||
int dmgDiff1 = theItem.getMaxDamage() - dmgItems[1].getItemDamage();
|
||||
int value = dmgDiff0 + dmgDiff1 + theItem.getMaxDamage() * 5 / 100;
|
||||
int solve = Math.max(0, theItem.getMaxDamage() - value);
|
||||
|
||||
@@ -1417,21 +1415,6 @@ public final class MekanismUtils
|
||||
return general.opsBypassRestrictions && player.mcServer.getConfigurationManager().canSendCommands(player.getGameProfile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mod ID of the mod owning the given ItemStack.
|
||||
* @param stack - ItemStack to check
|
||||
* @return mod ID of the ItemStack's owner
|
||||
*/
|
||||
public static String getMod(ItemStack stack)
|
||||
{
|
||||
try {
|
||||
ModContainer mod = null;//TODO:GameData.findModOwner(GameData.getItemRegistry().getNameForObject(stack.getItem()));
|
||||
return mod == null ? "Minecraft" : mod.getName();
|
||||
} catch(Exception e) {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item ID from a given ItemStack
|
||||
* @param itemStack - ItemStack to check
|
||||
|
||||
Reference in new issue
Block a user