mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-25 14:34:54 +00:00
Unified build script (#175)
* Update build script * Update build script to import fix for shadow in dev and sources artifacts * Update fixed build script to shadow csv dependency in dev jar as well * Moved jitpack * Move new files
This commit is contained in:
1 parent
43b71b1de6
commit
a7ca6c8527
188 files changed
+646
-968
No files matched your search
@@ -0,0 +1,126 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import codechicken.nei.OffsetPositioner;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
import com.google.common.base.Objects;
|
||||
import net.minecraft.client.gui.inventory.GuiBrewingStand;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||
import net.minecraft.client.gui.inventory.GuiFurnace;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RecipeInfo
|
||||
{
|
||||
private static class OverlayKey
|
||||
{
|
||||
final String ident;
|
||||
final Class<? extends GuiContainer> guiClass;
|
||||
|
||||
public OverlayKey(Class<? extends GuiContainer> classz, String ident)
|
||||
{
|
||||
this.guiClass = classz;
|
||||
this.ident = ident;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(!(obj instanceof OverlayKey))
|
||||
return false;
|
||||
OverlayKey key = (OverlayKey)obj;
|
||||
return Objects.equal(ident, key.ident) && guiClass == key.guiClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(ident, guiClass);
|
||||
}
|
||||
}
|
||||
|
||||
static final HashMap<OverlayKey, IOverlayHandler> overlayMap = new HashMap<>();
|
||||
static final HashMap<OverlayKey, IStackPositioner> positionerMap = new HashMap<>();
|
||||
static final HashMap<Class<? extends GuiContainer>, int[]> offsets = new HashMap<>();
|
||||
|
||||
public static void registerOverlayHandler(Class<? extends GuiContainer> classz, IOverlayHandler handler, String ident)
|
||||
{
|
||||
overlayMap.put(new OverlayKey(classz, ident), handler);
|
||||
}
|
||||
|
||||
public static void registerGuiOverlay(Class<? extends GuiContainer> classz, String ident, IStackPositioner positioner)
|
||||
{
|
||||
positionerMap.put(new OverlayKey(classz, ident), positioner);
|
||||
if(positioner instanceof OffsetPositioner && !offsets.containsKey(classz))
|
||||
{
|
||||
OffsetPositioner p = (OffsetPositioner)positioner;
|
||||
setGuiOffset(classz, p.offsetx, p.offsety);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGuiOffset(Class<? extends GuiContainer> classz, int x, int y)
|
||||
{
|
||||
offsets.put(classz, new int[]{x, y});
|
||||
}
|
||||
|
||||
public static boolean hasDefaultOverlay(GuiContainer gui, String ident)
|
||||
{
|
||||
return positionerMap.containsKey(new OverlayKey(gui.getClass(), ident));
|
||||
}
|
||||
|
||||
public static boolean hasOverlayHandler(GuiContainer gui, String ident)
|
||||
{
|
||||
return overlayMap.containsKey(new OverlayKey(gui.getClass(), ident));
|
||||
}
|
||||
|
||||
public static IOverlayHandler getOverlayHandler(GuiContainer gui, String ident)
|
||||
{
|
||||
return overlayMap.get(new OverlayKey(gui.getClass(), ident));
|
||||
}
|
||||
|
||||
public static IStackPositioner getStackPositioner(GuiContainer gui, String ident)
|
||||
{
|
||||
return positionerMap.get(new OverlayKey(gui.getClass(), ident));
|
||||
}
|
||||
|
||||
public static int[] getGuiOffset(GuiContainer gui)
|
||||
{
|
||||
int[] offset = offsets.get(gui.getClass());
|
||||
return offset == null ? new int[]{5, 11} : offset;
|
||||
}
|
||||
|
||||
public static void load()
|
||||
{
|
||||
API.registerRecipeHandler(new ShapedRecipeHandler());
|
||||
API.registerUsageHandler(new ShapedRecipeHandler());
|
||||
API.registerRecipeHandler(new ShapelessRecipeHandler());
|
||||
API.registerUsageHandler(new ShapelessRecipeHandler());
|
||||
API.registerRecipeHandler(new FireworkRecipeHandler());
|
||||
API.registerUsageHandler(new FireworkRecipeHandler());
|
||||
API.registerRecipeHandler(new FurnaceRecipeHandler());
|
||||
API.registerUsageHandler(new FurnaceRecipeHandler());
|
||||
API.registerRecipeHandler(new BrewingRecipeHandler());
|
||||
API.registerUsageHandler(new BrewingRecipeHandler());
|
||||
API.registerRecipeHandler(new FuelRecipeHandler());
|
||||
API.registerUsageHandler(new FuelRecipeHandler());
|
||||
|
||||
API.registerGuiOverlay(GuiCrafting.class, "crafting");
|
||||
API.registerGuiOverlay(GuiInventory.class, "crafting2x2", 63, 20);
|
||||
API.registerGuiOverlay(GuiFurnace.class, "smelting");
|
||||
API.registerGuiOverlay(GuiFurnace.class, "fuel");
|
||||
API.registerGuiOverlay(GuiBrewingStand.class, "brewing");
|
||||
|
||||
API.registerGuiOverlayHandler(GuiCrafting.class, new DefaultOverlayHandler(), "crafting");
|
||||
API.registerGuiOverlayHandler(GuiInventory.class, new DefaultOverlayHandler(63, 20), "crafting2x2");
|
||||
API.registerGuiOverlayHandler(GuiBrewingStand.class, new BrewingOverlayHandler(), "brewing");
|
||||
|
||||
API.registerRecipeHandler(new ProfilerRecipeHandler(true));
|
||||
API.registerUsageHandler(new ProfilerRecipeHandler(false));
|
||||
|
||||
API.registerStackStringifyHandler(new StackStringifyHandler());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user