mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-20 12:19:48 +00:00
commit
b1e30d8ab8
12 files changed
+325
-63
No files matched your search
@@ -0,0 +1,15 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
public class GuiElement {
|
||||
public final int buttonIconX;
|
||||
public final int buttonIconY;
|
||||
public final String domain;
|
||||
public final String texture;
|
||||
|
||||
public GuiElement(int buttonIconX, int buttonIconY, String domain, String texture) {
|
||||
this.buttonIconX = buttonIconX;
|
||||
this.buttonIconY = buttonIconY;
|
||||
this.domain = domain;
|
||||
this.texture = texture;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
public class StencilGuiElement extends GuiElement {
|
||||
public final int stencilIndex;
|
||||
|
||||
public StencilGuiElement(int buttonIconX, int buttonIconY, int stencilIndex, String domain, String texture) {
|
||||
super(buttonIconX, buttonIconY, domain, texture);
|
||||
|
||||
this.stencilIndex = stencilIndex;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class TConstructClientRegistry
|
||||
{
|
||||
public static ArrayList<StencilGuiElement> stencilButtons = new ArrayList<StencilGuiElement>();
|
||||
public static ArrayList<StencilGuiElement> stencilButtons2 = new ArrayList<StencilGuiElement>();
|
||||
public static ArrayList<ToolGuiElement> toolButtons = new ArrayList<ToolGuiElement>(20);
|
||||
public static ArrayList<ToolGuiElement> tierTwoButtons = new ArrayList<ToolGuiElement>();
|
||||
public static Map<String, ItemStack> manualIcons = new HashMap<String, ItemStack>();
|
||||
@@ -103,6 +105,27 @@ public class TConstructClientRegistry
|
||||
}
|
||||
|
||||
//Gui
|
||||
public static void addStencilButton (StencilGuiElement element)
|
||||
{
|
||||
stencilButtons.add(element);
|
||||
}
|
||||
|
||||
public static void addStencilButton (int xButton, int yButton, int index, String domain, String texture)
|
||||
{
|
||||
stencilButtons.add(new StencilGuiElement(xButton, yButton, index, domain, texture));
|
||||
}
|
||||
|
||||
public static void addStencilButton2 (StencilGuiElement element)
|
||||
{
|
||||
stencilButtons.add(element);
|
||||
}
|
||||
|
||||
// adds a button to the right side of the stencil table
|
||||
public static void addStencilButton2 (int xButton, int yButton, int index, String domain, String texture)
|
||||
{
|
||||
stencilButtons2.add(new StencilGuiElement(xButton, yButton, index, domain, texture));
|
||||
}
|
||||
|
||||
public static void addToolButton (ToolGuiElement element)
|
||||
{
|
||||
toolButtons.add(element);
|
||||
|
||||
@@ -1,27 +1,20 @@
|
||||
package tconstruct.library.client;
|
||||
|
||||
public class ToolGuiElement
|
||||
public class ToolGuiElement extends GuiElement
|
||||
{
|
||||
public final int slotType;
|
||||
public final int buttonIconX;
|
||||
public final int buttonIconY;
|
||||
public final int[] iconsX;
|
||||
public final int[] iconsY;
|
||||
public final String title;
|
||||
public final String body;
|
||||
public final String domain;
|
||||
public final String texture;
|
||||
|
||||
public ToolGuiElement(int st, int bx, int by, int[] xi, int[] yi, String t, String b, String d, String tex)
|
||||
{
|
||||
super(bx, by, d, tex);
|
||||
slotType = st;
|
||||
buttonIconX = bx;
|
||||
buttonIconY = by;
|
||||
iconsX = xi;
|
||||
iconsY = yi;
|
||||
title = t;
|
||||
body = b;
|
||||
domain = d;
|
||||
texture = tex;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class StencilBuilder {
|
||||
public static StencilBuilder instance = new StencilBuilder();
|
||||
|
||||
public List<ItemStack> blanks = new LinkedList<ItemStack>(); // i wish ItemStack would support equals so i could use a Set here...
|
||||
public List<ItemStack> stencils = new ArrayList<ItemStack>();
|
||||
|
||||
/**
|
||||
* Returns whether the given ItemStack is a blank pattern and therefore usable for stencil crafting.
|
||||
*/
|
||||
public static boolean isBlank(ItemStack stack)
|
||||
{
|
||||
for(ItemStack blank : instance.blanks)
|
||||
if(OreDictionary.itemMatches(stack, blank, false)) // this has nothing to do with the oredictionary.
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void registerBlankStencil(ItemStack itemStack)
|
||||
{
|
||||
instance.blanks.add(itemStack);
|
||||
}
|
||||
|
||||
public static void registerStencil(Item item, int meta)
|
||||
{
|
||||
instance.stencils.add(new ItemStack(item, 1, meta));
|
||||
}
|
||||
|
||||
public static void registerStencil(ItemStack pattern)
|
||||
{
|
||||
instance.stencils.add(pattern);
|
||||
}
|
||||
|
||||
public static List<ItemStack> getStencils() { return instance.stencils; }
|
||||
|
||||
/**
|
||||
* Returns the index of the given stencil. If no stencil is found, returns -1.
|
||||
*/
|
||||
public static int getIndex(ItemStack stencil) {
|
||||
for(int i = 0; i < instance.stencils.size(); i++)
|
||||
if(OreDictionary.itemMatches(stencil, getStencil(i), false))
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// returns the stencil with the given index
|
||||
public static ItemStack getStencil(int num) {
|
||||
if(num >= instance.stencils.size())
|
||||
return null;
|
||||
|
||||
return instance.stencils.get(num).copy();
|
||||
}
|
||||
|
||||
public static int getStencilCount() { return instance.stencils.size(); }
|
||||
}
|
||||
Reference in new issue
Block a user