mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 10:44:45 +00:00
* Fix serial handlers not searching catalysts
* Prevent null stack from being added
* Prevent duplicate stack from being added
* Prevent empty handlerID from being added
* Extract code to get modded items
* Use HANDLER_ID_FUNCTION to determine handler's id
This allows mods that don't implement getOverlayIdentifier to work with
* Implement priority
* Fix typo
* Allow catalysts to be loaded from csv
Add IC2 catalysts
* minor cleanup
* Add Avaritia, BM, Forestry
* Log if TransferRects fail
* Implement removing catalyst
* Add placeholder for version controlling
* Add a BUNCH of catalysts
* Add Schematics
* Add more NASA
* Add way to resolve conflict with handlerID
resolve conflict between IC2 Compressor and Mekanism Osmium Compressor
* Add more catalysts
* Add ALL GT catalysts
* Add more
* temporary "fix" for item rendering
reverts 9bbdd7b174
* enable by default
* forgot this one
* Add ability to skip search for catalysts
* resolve some todos
172 lines
4.9 KiB
Java
172 lines
4.9 KiB
Java
package codechicken.nei.recipe;
|
|
|
|
import codechicken.nei.NEIClientConfig;
|
|
import codechicken.nei.NEIServerUtils;
|
|
import codechicken.nei.drawable.DrawableBuilder;
|
|
import codechicken.nei.drawable.DrawableResource;
|
|
import cpw.mods.fml.common.FMLLog;
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.nbt.JsonToNBT;
|
|
import net.minecraft.nbt.NBTBase;
|
|
import net.minecraft.nbt.NBTException;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import org.apache.logging.log4j.Level;
|
|
|
|
public class HandlerInfo {
|
|
public static int DEFAULT_HEIGHT = 65;
|
|
public static int DEFAULT_WIDTH = 166;
|
|
public static int DEFAULT_MAX_PER_PAGE = 1;
|
|
|
|
private String handlerName;
|
|
|
|
private String modName;
|
|
private String modId;
|
|
private boolean requiresMod;
|
|
private String excludedModId;
|
|
|
|
private String itemId;
|
|
private String nbtString;
|
|
|
|
private int yShift = 0;
|
|
private int height = DEFAULT_HEIGHT;
|
|
private int width = DEFAULT_WIDTH;
|
|
private int maxRecipesPerPage = DEFAULT_MAX_PER_PAGE;
|
|
|
|
private ItemStack itemStack = null;
|
|
private DrawableResource image = null;
|
|
|
|
public HandlerInfo(String handlerName, String modName, String modId, boolean requiresMod, String excludedModId) {
|
|
this.handlerName = handlerName;
|
|
this.modName = modName;
|
|
this.modId = modId;
|
|
this.requiresMod = requiresMod;
|
|
this.excludedModId = excludedModId;
|
|
}
|
|
|
|
public void setHandlerDimensions(int height, int width, int maxRecipesPerPage) {
|
|
this.height = height;
|
|
this.width = width;
|
|
this.maxRecipesPerPage = maxRecipesPerPage;
|
|
}
|
|
|
|
public boolean setItem(String itemId, String nbtString) {
|
|
if(hasImageOrItem())
|
|
return false;
|
|
|
|
itemStack = NEIServerUtils.getModdedItem(itemId, nbtString);
|
|
if (itemStack == null)
|
|
NEIClientConfig.logger.info("Couldn't find " + modName + " - " + itemId);
|
|
else {
|
|
this.itemId = itemId;
|
|
this.nbtString = nbtString;
|
|
}
|
|
return (itemStack != null);
|
|
}
|
|
|
|
public boolean setImage(String resourceLocation, int imageX, int imageY, int imageWidth, int imageHeight) {
|
|
if(hasImageOrItem())
|
|
return false;
|
|
|
|
this.image = new DrawableBuilder(resourceLocation, imageX, imageY, imageWidth, imageHeight).build();
|
|
return true;
|
|
}
|
|
|
|
public DrawableResource getImage() {
|
|
return image;
|
|
}
|
|
|
|
public ItemStack getItemStack() {
|
|
return itemStack;
|
|
}
|
|
|
|
public String getModName() {
|
|
return modName;
|
|
}
|
|
|
|
public String getModId() {
|
|
return modId;
|
|
}
|
|
|
|
public int getHeight() {
|
|
return height;
|
|
}
|
|
|
|
public int getWidth() {
|
|
return width;
|
|
}
|
|
|
|
public int getMaxRecipesPerPage() {
|
|
return Math.max(maxRecipesPerPage, 1);
|
|
}
|
|
|
|
public int getYShift() {
|
|
return yShift;
|
|
}
|
|
|
|
public String getHandlerName() {
|
|
return handlerName;
|
|
}
|
|
|
|
public boolean hasImageOrItem() {
|
|
if (image != null) return true;
|
|
if (itemStack != null) return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
public void setYShift(int yShift) {
|
|
this.yShift = yShift;
|
|
}
|
|
|
|
public static class Builder {
|
|
private final HandlerInfo info;
|
|
|
|
public Builder(String handlerName, String modName, String modId) {
|
|
this.info = new HandlerInfo(handlerName, modName, modId, true, null);
|
|
setMaxRecipesPerPage(Integer.MAX_VALUE);
|
|
}
|
|
|
|
public Builder(Class<? extends IRecipeHandler> handlerClazz, String modName, String modId) {
|
|
this(handlerClazz.getName(), modName, modId);
|
|
}
|
|
|
|
public Builder setDisplayStack(ItemStack stack) {
|
|
info.image = null;
|
|
info.itemStack = stack;
|
|
return this;
|
|
}
|
|
|
|
public Builder setDisplayImage(ResourceLocation location, int imageX, int imageY, int imageWidth, int imageHeight) {
|
|
info.itemStack = null;
|
|
info.setImage(location.toString(), imageX, imageY, imageWidth, imageHeight);
|
|
return this;
|
|
}
|
|
|
|
public Builder setShiftY(int shiftY) {
|
|
info.setYShift(shiftY);
|
|
return this;
|
|
}
|
|
|
|
public Builder setWidth(int width) {
|
|
info.setHandlerDimensions(info.height, width, info.maxRecipesPerPage);
|
|
return this;
|
|
}
|
|
|
|
public Builder setHeight(int height) {
|
|
info.setHandlerDimensions(height, info.width, info.maxRecipesPerPage);
|
|
return this;
|
|
}
|
|
|
|
public Builder setMaxRecipesPerPage(int maxRecipesPerPage) {
|
|
info.setHandlerDimensions(info.height, info.width, maxRecipesPerPage);
|
|
return this;
|
|
}
|
|
|
|
public HandlerInfo build() {
|
|
return info;
|
|
}
|
|
}
|
|
}
|