Fix JABBA-related issues with crafting station slots (#54)

* Fix shift-merging tools voiding items

fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392>

* Change 0-sized ItemStacks into null stacks in crafting station attached slots

Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425>

* Update buildscript

* spotlessApply
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2022-09-22 20:51:23 +02:00
1 parent 18bfeaff32
commit 39be06c23b
571 files changed
+25959 -28223

No files matched your search

@@ -1,69 +1,60 @@
package tconstruct.plugins.nei;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.api.API;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerInputHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import tconstruct.client.ArmorControls;
public class BeltToggleFromGuiInputHandler implements IContainerInputHandler {
static final String KEY_IDENTIFIER = "gui.tinkers_belt";
public static void init() {
API.addKeyBind(KEY_IDENTIFIER, 0);
GuiContainerManager.addInputHandler(new BeltToggleFromGuiInputHandler());
}
@Override
public boolean keyTyped(GuiContainer guiContainer, char c, int i) {
if (i == 0) {
return false;
}
final int keyBinding = NEIClientConfig.getKeyBinding(KEY_IDENTIFIER);
if (keyBinding == 0 || i != keyBinding) {
return false;
}
return ArmorControls.doBeltSwapIfPossible();
}
@Override
public void onKeyTyped(GuiContainer guiContainer, char c, int i) {
}
@Override
public boolean lastKeyTyped(GuiContainer guiContainer, char c, int i) {
return false;
}
@Override
public boolean mouseClicked(GuiContainer guiContainer, int i, int i1, int i2) {
return false;
}
@Override
public void onMouseClicked(GuiContainer guiContainer, int i, int i1, int i2) {
}
@Override
public void onMouseUp(GuiContainer guiContainer, int i, int i1, int i2) {
}
@Override
public boolean mouseScrolled(GuiContainer guiContainer, int i, int i1, int i2) {
return false;
}
@Override
public void onMouseScrolled(GuiContainer guiContainer, int i, int i1, int i2) {
}
@Override
public void onMouseDragged(GuiContainer guiContainer, int i, int i1, int i2, long l) {
}
}
package tconstruct.plugins.nei;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.api.API;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerInputHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import tconstruct.client.ArmorControls;
public class BeltToggleFromGuiInputHandler implements IContainerInputHandler {
static final String KEY_IDENTIFIER = "gui.tinkers_belt";
public static void init() {
API.addKeyBind(KEY_IDENTIFIER, 0);
GuiContainerManager.addInputHandler(new BeltToggleFromGuiInputHandler());
}
@Override
public boolean keyTyped(GuiContainer guiContainer, char c, int i) {
if (i == 0) {
return false;
}
final int keyBinding = NEIClientConfig.getKeyBinding(KEY_IDENTIFIER);
if (keyBinding == 0 || i != keyBinding) {
return false;
}
return ArmorControls.doBeltSwapIfPossible();
}
@Override
public void onKeyTyped(GuiContainer guiContainer, char c, int i) {}
@Override
public boolean lastKeyTyped(GuiContainer guiContainer, char c, int i) {
return false;
}
@Override
public boolean mouseClicked(GuiContainer guiContainer, int i, int i1, int i2) {
return false;
}
@Override
public void onMouseClicked(GuiContainer guiContainer, int i, int i1, int i2) {}
@Override
public void onMouseUp(GuiContainer guiContainer, int i, int i1, int i2) {}
@Override
public boolean mouseScrolled(GuiContainer guiContainer, int i, int i1, int i2) {
return false;
}
@Override
public void onMouseScrolled(GuiContainer guiContainer, int i, int i1, int i2) {}
@Override
public void onMouseDragged(GuiContainer guiContainer, int i, int i1, int i2, long l) {}
}
@@ -11,16 +11,14 @@ import tconstruct.tools.logic.CraftingStationLogic;
/**
* Modified copy of DefaultOverlayHandler from NotEnoughItems
*/
public class CraftingStationOverlayHandler extends DefaultOverlayHandler
{
public class CraftingStationOverlayHandler extends DefaultOverlayHandler {
@Override
public void overlayRecipe(GuiContainer gui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
if(gui.inventorySlots instanceof CraftingStationContainer) {
final CraftingStationContainer station = (CraftingStationContainer)gui.inventorySlots;
if(station.logic.chest != null && gui instanceof CraftingStationGui) {
offsetx = 5 + ((CraftingStationGui)gui).getChestWidth();
}
else {
if (gui.inventorySlots instanceof CraftingStationContainer) {
final CraftingStationContainer station = (CraftingStationContainer) gui.inventorySlots;
if (station.logic.chest != null && gui instanceof CraftingStationGui) {
offsetx = 5 + ((CraftingStationGui) gui).getChestWidth();
} else {
offsetx = 5;
}
}
@@ -30,12 +28,10 @@ public class CraftingStationOverlayHandler extends DefaultOverlayHandler
@Override
public boolean canMoveFrom(Slot slot, GuiContainer gui) {
if(gui.inventorySlots instanceof CraftingStationContainer) {
if (gui.inventorySlots instanceof CraftingStationContainer) {
CraftingStationLogic logic = ((CraftingStationContainer) gui.inventorySlots).logic;
if(logic.chest != null && slot.inventory == logic.chest.get())
return true;
if(logic.doubleChest != null && slot.inventory == logic.doubleChest.get())
return true;
if (logic.chest != null && slot.inventory == logic.chest.get()) return true;
if (logic.doubleChest != null && slot.inventory == logic.doubleChest.get()) return true;
}
return super.canMoveFrom(slot, gui);
@@ -3,16 +3,15 @@ package tconstruct.plugins.nei;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.IStackPositioner;
import codechicken.nei.recipe.GuiRecipe;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import tconstruct.TConstruct;
import tconstruct.tools.gui.CraftingStationGui;
import java.util.ArrayList;
public class CraftingStationStackPositioner implements IStackPositioner {
@Override
public ArrayList<PositionedStack> positionStacks (ArrayList<PositionedStack> stacks) {
public ArrayList<PositionedStack> positionStacks(ArrayList<PositionedStack> stacks) {
if (Minecraft.getMinecraft().currentScreen instanceof GuiRecipe) {
GuiRecipe recipeGui = (GuiRecipe) Minecraft.getMinecraft().currentScreen;
@@ -35,5 +34,4 @@ public class CraftingStationStackPositioner implements IStackPositioner {
return stacks;
}
}
@@ -1,15 +1,13 @@
package tconstruct.plugins.nei;
import tconstruct.tools.gui.CraftingStationGui;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
import tconstruct.tools.gui.CraftingStationGui;
public class NEITConstructConfig implements IConfigureNEI
{
public class NEITConstructConfig implements IConfigureNEI {
@Override
public void loadConfig ()
{
public void loadConfig() {
API.registerGuiOverlay(CraftingStationGui.class, "crafting", new CraftingStationStackPositioner());
API.registerGuiOverlayHandler(CraftingStationGui.class, new CraftingStationOverlayHandler(), "crafting");
@@ -24,21 +22,17 @@ public class NEITConstructConfig implements IConfigureNEI
}
@Override
public String getName ()
{
public String getName() {
return "TConstruct";
}
@Override
public String getVersion ()
{
public String getVersion() {
return "${version}";
}
private static void registerHandler (RecipeHandlerBase handler)
{
private static void registerHandler(RecipeHandlerBase handler) {
API.registerRecipeHandler(handler);
API.registerUsageHandler(handler);
}
}
@@ -1,46 +1,36 @@
package tconstruct.plugins.nei;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import tconstruct.library.crafting.AlloyMix;
import tconstruct.library.crafting.Smeltery;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
public class RecipeHandlerAlloying extends RecipeHandlerBase
{
public class RecipeHandlerAlloying extends RecipeHandlerBase {
public static final Rectangle OUTPUT_TANK = new Rectangle(118, 9, 18, 32);
public class CachedAlloyingRecipe extends CachedBaseRecipe
{
public class CachedAlloyingRecipe extends CachedBaseRecipe {
private List<FluidTankElement> fluidTanks;
private int minAmount;
public CachedAlloyingRecipe(AlloyMix recipe)
{
public CachedAlloyingRecipe(AlloyMix recipe) {
this.fluidTanks = new ArrayList<FluidTankElement>();
int maxAmount = recipe.mixers.get(0).amount;
int mult = 1;
this.minAmount = maxAmount;
for (FluidStack stack : recipe.mixers)
{
if (stack.amount > maxAmount)
{
for (FluidStack stack : recipe.mixers) {
if (stack.amount > maxAmount) {
maxAmount = stack.amount;
}
if (stack.amount < this.minAmount)
{
if (stack.amount < this.minAmount) {
this.minAmount = stack.amount;
}
}
@@ -50,15 +40,13 @@ public class RecipeHandlerAlloying extends RecipeHandlerBase
int width = 36 / recipe.mixers.size();
int counter = 0;
for (FluidStack stack : recipe.mixers)
{
if (counter == recipe.mixers.size() - 1)
{
tank = new FluidTankElement(new Rectangle(21 + width * counter, 9, 36 - width * counter, 32), maxAmount * mult, stack);
}
else
{
tank = new FluidTankElement(new Rectangle(21 + width * counter, 9, width, 32), maxAmount * mult, stack);
for (FluidStack stack : recipe.mixers) {
if (counter == recipe.mixers.size() - 1) {
tank = new FluidTankElement(
new Rectangle(21 + width * counter, 9, 36 - width * counter, 32), maxAmount * mult, stack);
} else {
tank = new FluidTankElement(
new Rectangle(21 + width * counter, 9, width, 32), maxAmount * mult, stack);
}
tank.fluid.amount *= mult;
this.fluidTanks.add(tank);
@@ -67,102 +55,81 @@ public class RecipeHandlerAlloying extends RecipeHandlerBase
}
@Override
public PositionedStack getIngredient ()
{
public PositionedStack getIngredient() {
return null;
}
@Override
public PositionedStack getResult ()
{
public PositionedStack getResult() {
return null;
}
@Override
public List<FluidTankElement> getFluidTanks ()
{
public List<FluidTankElement> getFluidTanks() {
return this.fluidTanks;
}
}
@Override
public String getRecipeName ()
{
public String getRecipeName() {
return StatCollector.translateToLocal("tconstruct.nei.alloying");
}
@Override
public String getRecipeID ()
{
public String getRecipeID() {
return "tconstruct.smeltery.alloying";
}
@Override
public String getGuiTexture ()
{
public String getGuiTexture() {
return "tinker:textures/gui/nei/smeltery.png";
}
@Override
public void loadTransferRects ()
{
this.transferRects.add(new RecipeTransferRect(new Rectangle(76, 21, 22, 15), this.getRecipeID(), new Object[0]));
public void loadTransferRects() {
this.transferRects.add(
new RecipeTransferRect(new Rectangle(76, 21, 22, 15), this.getRecipeID(), new Object[0]));
}
@Override
public void drawBackground (int recipe)
{
public void drawBackground(int recipe) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(this.getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 0, 62, 160, 65);
}
@Override
public void loadCraftingRecipes (String outputId, Object... results)
{
if (outputId.equals(this.getRecipeID()))
{
for (AlloyMix recipe : Smeltery.getAlloyList())
{
if (!recipe.mixers.isEmpty())
{
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(this.getRecipeID())) {
for (AlloyMix recipe : Smeltery.getAlloyList()) {
if (!recipe.mixers.isEmpty()) {
this.arecipes.add(new CachedAlloyingRecipe(recipe));
}
}
}
else
{
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes (FluidStack result)
{
for (AlloyMix recipe : Smeltery.getAlloyList())
{
if (areFluidsEqual(recipe.result, result) && !recipe.mixers.isEmpty())
{
public void loadCraftingRecipes(FluidStack result) {
for (AlloyMix recipe : Smeltery.getAlloyList()) {
if (areFluidsEqual(recipe.result, result) && !recipe.mixers.isEmpty()) {
this.arecipes.add(new CachedAlloyingRecipe(recipe));
}
}
}
@Override
public void loadUsageRecipes (FluidStack ingredient)
{
for (Iterator<AlloyMix> i = Smeltery.getAlloyList().iterator(); i.hasNext();)
{
public void loadUsageRecipes(FluidStack ingredient) {
for (Iterator<AlloyMix> i = Smeltery.getAlloyList().iterator(); i.hasNext(); ) {
AlloyMix recipe = i.next();
for (FluidStack liquid : recipe.mixers)
{
if (areFluidsEqual(liquid, ingredient) && !recipe.mixers.isEmpty())
{
for (FluidStack liquid : recipe.mixers) {
if (areFluidsEqual(liquid, ingredient) && !recipe.mixers.isEmpty()) {
this.arecipes.add(new CachedAlloyingRecipe(recipe));
break;
}
}
}
}
}
@@ -1,10 +1,16 @@
package tconstruct.plugins.nei;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.GuiUsageRecipe;
import codechicken.nei.recipe.TemplateRecipeHandler;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
@@ -17,122 +23,82 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.IFluidContainerItem;
import org.lwjgl.opengl.GL11;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.GuiUsageRecipe;
import codechicken.nei.recipe.TemplateRecipeHandler;
public abstract class RecipeHandlerBase extends TemplateRecipeHandler {
public abstract class RecipeHandlerBase extends TemplateRecipeHandler
{
public abstract class CachedBaseRecipe extends CachedRecipe
{
public List<FluidTankElement> getFluidTanks ()
{
public abstract class CachedBaseRecipe extends CachedRecipe {
public List<FluidTankElement> getFluidTanks() {
return null;
}
}
public abstract String getRecipeID ();
public abstract String getRecipeID();
public void loadCraftingRecipes (FluidStack result)
{
}
public void loadCraftingRecipes(FluidStack result) {}
public void loadUsageRecipes (FluidStack ingredient)
{
}
public void loadUsageRecipes(FluidStack ingredient) {}
@Override
public void drawForeground (int recipe)
{
public void drawForeground(int recipe) {
super.drawForeground(recipe);
this.drawFluidTanks(recipe);
}
@Override
public void loadCraftingRecipes (String outputId, Object... results)
{
try
{
if (outputId.equals("liquid") && results.length == 1 && results[0] instanceof FluidStack)
{
public void loadCraftingRecipes(String outputId, Object... results) {
try {
if (outputId.equals("liquid") && results.length == 1 && results[0] instanceof FluidStack) {
this.loadCraftingRecipes((FluidStack) results[0]);
}
else
{
} else {
super.loadCraftingRecipes(outputId, results);
}
}
catch (Throwable ex)
{
} catch (Throwable ex) {
ex.printStackTrace();
}
}
@Override
public void loadCraftingRecipes (ItemStack result)
{
public void loadCraftingRecipes(ItemStack result) {
FluidStack fluid = getFluidStack(result);
if (fluid != null)
{
if (fluid != null) {
this.loadCraftingRecipes(fluid);
}
}
@Override
public void loadUsageRecipes (String inputId, Object... ingredients)
{
try
{
if (inputId.equals("liquid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack)
{
public void loadUsageRecipes(String inputId, Object... ingredients) {
try {
if (inputId.equals("liquid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) {
this.loadUsageRecipes((FluidStack) ingredients[0]);
}
else
{
} else {
super.loadUsageRecipes(inputId, ingredients);
}
}
catch (Throwable ex)
{
} catch (Throwable ex) {
ex.printStackTrace();
}
}
@Override
public void loadUsageRecipes (ItemStack ingred)
{
public void loadUsageRecipes(ItemStack ingred) {
FluidStack fluid = getFluidStack(ingred);
if (fluid != null)
{
if (fluid != null) {
this.loadUsageRecipes(fluid);
}
}
@Override
public List<String> handleTooltip (GuiRecipe guiRecipe, List<String> currenttip, int recipe)
{
public List<String> handleTooltip(GuiRecipe guiRecipe, List<String> currenttip, int recipe) {
super.handleTooltip(guiRecipe, currenttip, recipe);
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
if (GuiContainerManager.shouldShowTooltip(guiRecipe))
{
if (GuiContainerManager.shouldShowTooltip(guiRecipe)) {
Point mouse = GuiDraw.getMousePosition();
Point offset = guiRecipe.getRecipePosition(recipe);
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
if (crecipe.getFluidTanks() != null)
{
for (FluidTankElement tank : crecipe.getFluidTanks())
{
if (tank.position.contains(relMouse))
{
if (crecipe.getFluidTanks() != null) {
for (FluidTankElement tank : crecipe.getFluidTanks()) {
if (tank.position.contains(relMouse)) {
tank.handleTooltip(currenttip);
}
}
@@ -142,19 +108,13 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler
}
@Override
public boolean keyTyped (GuiRecipe gui, char keyChar, int keyCode, int recipe)
{
if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
{
if (this.transferFluidTank(gui, recipe, false))
{
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) {
if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) {
if (this.transferFluidTank(gui, recipe, false)) {
return true;
}
}
else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
{
if (this.transferFluidTank(gui, recipe, true))
{
} else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) {
if (this.transferFluidTank(gui, recipe, true)) {
return true;
}
}
@@ -162,51 +122,35 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler
}
@Override
public boolean mouseClicked (GuiRecipe gui, int button, int recipe)
{
if (button == 0)
{
if (this.transferFluidTank(gui, recipe, false))
{
public boolean mouseClicked(GuiRecipe gui, int button, int recipe) {
if (button == 0) {
if (this.transferFluidTank(gui, recipe, false)) {
return true;
}
}
else if (button == 1)
{
if (this.transferFluidTank(gui, recipe, true))
{
} else if (button == 1) {
if (this.transferFluidTank(gui, recipe, true)) {
return true;
}
}
return super.mouseClicked(gui, button, recipe);
}
protected boolean transferFluidTank (GuiRecipe guiRecipe, int recipe, boolean usage)
{
protected boolean transferFluidTank(GuiRecipe guiRecipe, int recipe, boolean usage) {
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
Point mouse = GuiDraw.getMousePosition();
Point offset = guiRecipe.getRecipePosition(recipe);
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
if (crecipe.getFluidTanks() != null)
{
for (FluidTankElement tank : crecipe.getFluidTanks())
{
if (tank.position.contains(relMouse))
{
if ((tank.fluid != null) && tank.fluid.amount > 0)
{
if (usage)
{
if (!GuiUsageRecipe.openRecipeGui("liquid", new Object[] { tank.fluid }))
{
if (crecipe.getFluidTanks() != null) {
for (FluidTankElement tank : crecipe.getFluidTanks()) {
if (tank.position.contains(relMouse)) {
if ((tank.fluid != null) && tank.fluid.amount > 0) {
if (usage) {
if (!GuiUsageRecipe.openRecipeGui("liquid", new Object[] {tank.fluid})) {
return false;
}
}
else
{
if (!GuiCraftingRecipe.openRecipeGui("liquid", new Object[] { tank.fluid }))
{
} else {
if (!GuiCraftingRecipe.openRecipeGui("liquid", new Object[] {tank.fluid})) {
return false;
}
}
@@ -219,79 +163,63 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler
return false;
}
public void drawFluidTanks (int recipe)
{
public void drawFluidTanks(int recipe) {
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
if (crecipe.getFluidTanks() != null)
{
for (FluidTankElement fluidTank : crecipe.getFluidTanks())
{
if (crecipe.getFluidTanks() != null) {
for (FluidTankElement fluidTank : crecipe.getFluidTanks()) {
fluidTank.draw();
}
}
}
public static List getSingleList (Object o)
{
public static List getSingleList(Object o) {
List list = new ArrayList();
list.add(o);
return list;
}
public static FluidStack getFluidStack (ItemStack stack)
{
if (stack == null)
{
public static FluidStack getFluidStack(ItemStack stack) {
if (stack == null) {
return null;
}
Item item = stack.getItem();
FluidStack fluidStack = null;
if ((item instanceof IFluidContainerItem))
{
if ((item instanceof IFluidContainerItem)) {
fluidStack = ((IFluidContainerItem) item).getFluid(stack);
}
if (fluidStack == null)
{
if (fluidStack == null) {
fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
}
if ((fluidStack == null) && (Block.getBlockFromItem(stack.getItem()) instanceof IFluidBlock))
{
if ((fluidStack == null) && (Block.getBlockFromItem(stack.getItem()) instanceof IFluidBlock)) {
Fluid fluid = ((IFluidBlock) Block.getBlockFromItem(stack.getItem())).getFluid();
if (fluid != null)
{
if (fluid != null) {
return new FluidStack(fluid, 1000);
}
}
return fluidStack;
}
public static boolean areFluidsEqual (FluidStack fluidStack1, FluidStack fluidStack2)
{
if (fluidStack1 == null || fluidStack2 == null)
{
public static boolean areFluidsEqual(FluidStack fluidStack1, FluidStack fluidStack2) {
if (fluidStack1 == null || fluidStack2 == null) {
return false;
}
return fluidStack1.isFluidEqual(fluidStack2);
}
public static class FluidTankElement
{
public static class FluidTankElement {
public Rectangle position;
public FluidStack fluid;
public int capacity;
public boolean flowingTexture = false;
public FluidTankElement(Rectangle position, int capacity, FluidStack fluid)
{
public FluidTankElement(Rectangle position, int capacity, FluidStack fluid) {
this.position = position;
this.capacity = capacity;
this.fluid = fluid;
}
public List<String> handleTooltip (List<String> currenttip)
{
if (this.fluid == null || this.fluid.getFluid() == null || this.fluid.amount <= 0)
{
public List<String> handleTooltip(List<String> currenttip) {
if (this.fluid == null || this.fluid.getFluid() == null || this.fluid.amount <= 0) {
return currenttip;
}
currenttip.add(this.fluid.getLocalizedName());
@@ -299,23 +227,16 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler
return currenttip;
}
public void draw ()
{
if (this.fluid == null || this.fluid.getFluid() == null || this.fluid.amount <= 0)
{
public void draw() {
if (this.fluid == null || this.fluid.getFluid() == null || this.fluid.amount <= 0) {
return;
}
IIcon fluidIcon = null;
if (this.flowingTexture && this.fluid.getFluid().getFlowingIcon() != null)
{
if (this.flowingTexture && this.fluid.getFluid().getFlowingIcon() != null) {
fluidIcon = this.fluid.getFluid().getFlowingIcon();
}
else if (this.fluid.getFluid().getStillIcon() != null)
{
} else if (this.fluid.getFluid().getStillIcon() != null) {
fluidIcon = this.fluid.getFluid().getStillIcon();
}
else
{
} else {
return;
}
@@ -324,13 +245,12 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler
GL11.glColor3ub((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF));
GL11.glDisable(GL11.GL_BLEND);
int amount = Math.max(Math.min(this.position.height, this.fluid.amount * this.position.height / this.capacity), 1);
int amount = Math.max(
Math.min(this.position.height, this.fluid.amount * this.position.height / this.capacity), 1);
int posY = this.position.y + this.position.height - amount;
for (int i = 0; i < this.position.width; i += 16)
{
for (int j = 0; j < amount; j += 16)
{
for (int i = 0; i < this.position.width; i += 16) {
for (int j = 0; j < amount; j += 16) {
int drawWidth = Math.min(this.position.width - i, 16);
int drawHeight = Math.min(amount - j, 16);
@@ -344,9 +264,16 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(drawX, drawY + drawHeight, 0, minU, minV + (maxV - minV) * drawHeight / 16F);
tessellator.addVertexWithUV(drawX + drawWidth, drawY + drawHeight, 0, minU + (maxU - minU) * drawWidth / 16F, minV + (maxV - minV) * drawHeight / 16F);
tessellator.addVertexWithUV(drawX + drawWidth, drawY, 0, minU + (maxU - minU) * drawWidth / 16F, minV);
tessellator.addVertexWithUV(
drawX, drawY + drawHeight, 0, minU, minV + (maxV - minV) * drawHeight / 16F);
tessellator.addVertexWithUV(
drawX + drawWidth,
drawY + drawHeight,
0,
minU + (maxU - minU) * drawWidth / 16F,
minV + (maxV - minV) * drawHeight / 16F);
tessellator.addVertexWithUV(
drawX + drawWidth, drawY, 0, minU + (maxU - minU) * drawWidth / 16F, minV);
tessellator.addVertexWithUV(drawX, drawY, 0, minU, minV);
tessellator.draw();
}
@@ -354,7 +281,5 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler
GL11.glEnable(GL11.GL_BLEND);
}
}
}
@@ -1,57 +1,47 @@
package tconstruct.plugins.nei;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.library.crafting.CastingRecipe;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
public abstract class RecipeHandlerCastingBase extends RecipeHandlerBase
{
public abstract class RecipeHandlerCastingBase extends RecipeHandlerBase {
public static final Rectangle MOLTEN_FLOW = new Rectangle(60, 8, 6, 11);
public static final Rectangle MOLTEN_FLOW_NO_ITEM = new Rectangle(60, 8, 6, 27);
public class CachedCastingRecipe extends CachedBaseRecipe
{
public class CachedCastingRecipe extends CachedBaseRecipe {
private List<PositionedStack> resources;
private FluidTankElement metal;
private PositionedStack output = null;
public CachedCastingRecipe(CastingRecipe recipe)
{
public CachedCastingRecipe(CastingRecipe recipe) {
this.metal = new FluidTankElement(MOLTEN_FLOW, recipe.castingMetal.amount, recipe.castingMetal);
this.metal.flowingTexture = true;
this.resources = new ArrayList<PositionedStack>();
if (recipe.cast != null)
{
if (recipe.cast != null) {
this.resources.add(new PositionedStack(recipe.cast, 55, 19));
}
else
{
} else {
this.metal.position = MOLTEN_FLOW_NO_ITEM;
}
this.output = new PositionedStack(recipe.output, 110, 18);
}
@Override
public List<PositionedStack> getIngredients ()
{
public List<PositionedStack> getIngredients() {
return getCycledIngredients(cycleticks / 20, this.resources);
}
@Override
public PositionedStack getResult ()
{
public PositionedStack getResult() {
return this.output;
}
@Override
public List<FluidTankElement> getFluidTanks ()
{
public List<FluidTankElement> getFluidTanks() {
List<FluidTankElement> res = new ArrayList<FluidTankElement>();
res.add(this.metal);
return res;
@@ -59,60 +49,47 @@ public abstract class RecipeHandlerCastingBase extends RecipeHandlerBase
}
@Override
public String getRecipeID ()
{
public String getRecipeID() {
return "tconstruct.smeltery.casting";
}
@Override
public String getGuiTexture ()
{
public String getGuiTexture() {
return "tinker:textures/gui/nei/casting.png";
}
@Override
public void loadTransferRects ()
{
this.transferRects.add(new RecipeTransferRect(new Rectangle(76, 18, 22, 15), this.getRecipeID(), new Object[0]));
public void loadTransferRects() {
this.transferRects.add(
new RecipeTransferRect(new Rectangle(76, 18, 22, 15), this.getRecipeID(), new Object[0]));
}
public abstract List<CastingRecipe> getCastingRecipes ();
public abstract List<CastingRecipe> getCastingRecipes();
@Override
public void loadCraftingRecipes (String outputId, Object... results)
{
if (outputId.equals(this.getRecipeID()))
{
for (CastingRecipe recipe : this.getCastingRecipes())
{
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(this.getRecipeID())) {
for (CastingRecipe recipe : this.getCastingRecipes()) {
this.arecipes.add(new CachedCastingRecipe(recipe));
}
}
else
{
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes (ItemStack result)
{
for (CastingRecipe recipe : getCastingRecipes())
{
if (NEIServerUtils.areStacksSameTypeCrafting(result, recipe.getResult()))
{
public void loadCraftingRecipes(ItemStack result) {
for (CastingRecipe recipe : getCastingRecipes()) {
if (NEIServerUtils.areStacksSameTypeCrafting(result, recipe.getResult())) {
this.arecipes.add(new CachedCastingRecipe(recipe));
}
}
}
@Override
public void loadUsageRecipes (ItemStack ingred)
{
for (CastingRecipe recipe : getCastingRecipes())
{
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.cast, ingred))
{
public void loadUsageRecipes(ItemStack ingred) {
for (CastingRecipe recipe : getCastingRecipes()) {
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.cast, ingred)) {
CachedCastingRecipe irecipe = new CachedCastingRecipe(recipe);
irecipe.setIngredientPermutation(irecipe.resources, ingred);
this.arecipes.add(irecipe);
@@ -121,15 +98,11 @@ public abstract class RecipeHandlerCastingBase extends RecipeHandlerBase
}
@Override
public void loadUsageRecipes (FluidStack ingredient)
{
for (CastingRecipe recipe : getCastingRecipes())
{
if (areFluidsEqual(recipe.castingMetal, ingredient))
{
public void loadUsageRecipes(FluidStack ingredient) {
for (CastingRecipe recipe : getCastingRecipes()) {
if (areFluidsEqual(recipe.castingMetal, ingredient)) {
this.arecipes.add(new CachedCastingRecipe(recipe));
}
}
}
}
@@ -1,43 +1,34 @@
package tconstruct.plugins.nei;
import codechicken.lib.gui.GuiDraw;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.crafting.LiquidCasting;
import codechicken.lib.gui.GuiDraw;
public class RecipeHandlerCastingBasin extends RecipeHandlerCastingBase
{
public class RecipeHandlerCastingBasin extends RecipeHandlerCastingBase {
@Override
public String getRecipeName ()
{
public String getRecipeName() {
return StatCollector.translateToLocal("tconstruct.nei.castingbasin");
}
@Override
public void drawBackground (int recipe)
{
public void drawBackground(int recipe) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(this.getGuiTexture());
GuiDraw.drawTexturedModalRect(30, 0, 0, 62, 112, 55);
}
@Override
public List<CastingRecipe> getCastingRecipes ()
{
public List<CastingRecipe> getCastingRecipes() {
LiquidCasting casting = TConstructRegistry.getBasinCasting();
if (casting == null)
{
if (casting == null) {
return new ArrayList<CastingRecipe>();
}
return casting.getCastingRecipes();
}
}
@@ -1,43 +1,34 @@
package tconstruct.plugins.nei;
import codechicken.lib.gui.GuiDraw;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.crafting.LiquidCasting;
import codechicken.lib.gui.GuiDraw;
public class RecipeHandlerCastingTable extends RecipeHandlerCastingBase
{
public class RecipeHandlerCastingTable extends RecipeHandlerCastingBase {
@Override
public String getRecipeName ()
{
public String getRecipeName() {
return StatCollector.translateToLocal("tconstruct.nei.castingtable");
}
@Override
public void drawBackground (int recipe)
{
public void drawBackground(int recipe) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(this.getGuiTexture());
GuiDraw.drawTexturedModalRect(30, 0, 0, 0, 112, 55);
}
@Override
public List<CastingRecipe> getCastingRecipes ()
{
public List<CastingRecipe> getCastingRecipes() {
LiquidCasting casting = TConstructRegistry.getTableCasting();
if (casting == null)
{
if (casting == null) {
return new ArrayList<CastingRecipe>();
}
return casting.getCastingRecipes();
}
}
@@ -1,128 +1,101 @@
package tconstruct.plugins.nei;
import java.awt.Rectangle;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import net.minecraft.util.StatCollector;
import tconstruct.library.crafting.DryingRackRecipes;
import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import java.awt.Rectangle;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import tconstruct.library.crafting.DryingRackRecipes;
import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
public class RecipeHandlerDryingRack extends RecipeHandlerBase
{
public class RecipeHandlerDryingRack extends RecipeHandlerBase {
public class CachedDryingRackRecipe extends CachedBaseRecipe
{
public class CachedDryingRackRecipe extends CachedBaseRecipe {
public PositionedStack input;
public PositionedStack output;
public int time;
public CachedDryingRackRecipe(DryingRecipe drying)
{
public CachedDryingRackRecipe(DryingRecipe drying) {
this.input = new PositionedStack(drying.input, 44, 18);
this.output = new PositionedStack(drying.result, 98, 18);
this.time = drying.time;
}
@Override
public PositionedStack getIngredient ()
{
public PositionedStack getIngredient() {
return this.input;
}
@Override
public PositionedStack getResult ()
{
public PositionedStack getResult() {
return this.output;
}
}
@Override
public String getRecipeName ()
{
public String getRecipeName() {
return StatCollector.translateToLocal("tconstruct.nei.dryingrack");
}
@Override
public String getRecipeID ()
{
public String getRecipeID() {
return "tconstruct.dryingrack";
}
@Override
public void loadTransferRects ()
{
this.transferRects.add(new RecipeTransferRect(new Rectangle(68, 20, 22, 15), this.getRecipeID(), new Object[0]));
public void loadTransferRects() {
this.transferRects.add(
new RecipeTransferRect(new Rectangle(68, 20, 22, 15), this.getRecipeID(), new Object[0]));
}
@Override
public String getGuiTexture ()
{
public String getGuiTexture() {
return "tinker:textures/gui/nei/dryingrack.png";
}
@Override
public void drawBackground (int recipe)
{
public void drawBackground(int recipe) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(this.getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 160, 65);
}
@Override
public void drawExtras (int recipe)
{
public void drawExtras(int recipe) {
int time = ((CachedDryingRackRecipe) this.arecipes.get(recipe)).time;
int seconds = time / 20;
GuiDraw.drawStringC(time + " ticks (" + seconds + " secs)", 81, 40, 0x808080, false);
}
@Override
public void loadCraftingRecipes (String outputId, Object... results)
{
if (outputId.equals(this.getRecipeID()))
{
for (DryingRecipe drying : DryingRackRecipes.recipes)
{
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(this.getRecipeID())) {
for (DryingRecipe drying : DryingRackRecipes.recipes) {
this.arecipes.add(new CachedDryingRackRecipe(drying));
}
}
else
{
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes (ItemStack result)
{
for (DryingRecipe drying : DryingRackRecipes.recipes)
{
if (NEIServerUtils.areStacksSameTypeCrafting(drying.result, result))
{
public void loadCraftingRecipes(ItemStack result) {
for (DryingRecipe drying : DryingRackRecipes.recipes) {
if (NEIServerUtils.areStacksSameTypeCrafting(drying.result, result)) {
this.arecipes.add(new CachedDryingRackRecipe(drying));
}
}
}
@Override
public void loadUsageRecipes (ItemStack ingred)
{
for (DryingRecipe drying : DryingRackRecipes.recipes)
{
if (NEIServerUtils.areStacksSameTypeCrafting(drying.input, ingred))
{
public void loadUsageRecipes(ItemStack ingred) {
for (DryingRecipe drying : DryingRackRecipes.recipes) {
if (NEIServerUtils.areStacksSameTypeCrafting(drying.input, ingred)) {
this.arecipes.add(new CachedDryingRackRecipe(drying));
}
}
}
}
@@ -1,36 +1,29 @@
package tconstruct.plugins.nei;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import mantle.utils.ItemMetaWrapper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import tconstruct.library.crafting.Smeltery;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
public class RecipeHandlerMelting extends RecipeHandlerBase
{
public class RecipeHandlerMelting extends RecipeHandlerBase {
public static final Rectangle MOLTEN_TANK = new Rectangle(115, 20, 18, 18);
public class CachedMeltingRecipe extends CachedBaseRecipe
{
public class CachedMeltingRecipe extends CachedBaseRecipe {
private PositionedStack input;
private int temperature;
private FluidTankElement output;
public CachedMeltingRecipe(ItemStack input)
{
public CachedMeltingRecipe(ItemStack input) {
this.input = new PositionedStack(input, 28, 21);
this.temperature = Smeltery.getLiquifyTemperature(input);
this.output = new FluidTankElement(MOLTEN_TANK, 1, Smeltery.getSmelteryResult(input));
@@ -38,20 +31,17 @@ public class RecipeHandlerMelting extends RecipeHandlerBase
}
@Override
public PositionedStack getIngredient ()
{
public PositionedStack getIngredient() {
return this.input;
}
@Override
public PositionedStack getResult ()
{
public PositionedStack getResult() {
return null;
}
@Override
public List<FluidTankElement> getFluidTanks ()
{
public List<FluidTankElement> getFluidTanks() {
List<FluidTankElement> tanks = new ArrayList<FluidTankElement>();
tanks.add(this.output);
return tanks;
@@ -59,82 +49,66 @@ public class RecipeHandlerMelting extends RecipeHandlerBase
}
@Override
public String getRecipeName ()
{
public String getRecipeName() {
return StatCollector.translateToLocal("tconstruct.nei.melting");
}
@Override
public String getRecipeID ()
{
public String getRecipeID() {
return "tconstruct.smeltery.melting";
}
@Override
public String getGuiTexture ()
{
public String getGuiTexture() {
return "tinker:textures/gui/nei/smeltery.png";
}
@Override
public void loadTransferRects ()
{
this.transferRects.add(new RecipeTransferRect(new Rectangle(72, 20, 16, 34), this.getRecipeID(), new Object[0]));
public void loadTransferRects() {
this.transferRects.add(
new RecipeTransferRect(new Rectangle(72, 20, 16, 34), this.getRecipeID(), new Object[0]));
}
@Override
public void drawBackground (int recipe)
{
public void drawBackground(int recipe) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(this.getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 160, 55);
}
@Override
public void drawExtras (int recipe)
{
public void drawExtras(int recipe) {
int temperature = ((CachedMeltingRecipe) this.arecipes.get(recipe)).temperature;
GuiDraw.drawStringC(temperature + " C", 81, 9, 0x808080, false);
}
@Override
public void loadCraftingRecipes (String outputId, Object... results)
{
if (outputId.equals(getRecipeID()))
{
for (ItemMetaWrapper key : Smeltery.getSmeltingList().keySet())
{
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(getRecipeID())) {
for (ItemMetaWrapper key : Smeltery.getSmeltingList().keySet()) {
this.arecipes.add(new CachedMeltingRecipe(new ItemStack(key.item, 1, key.meta)));
}
}
else
{
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes (FluidStack result)
{
for (Entry<ItemMetaWrapper, FluidStack> pair : Smeltery.getSmeltingList().entrySet())
{
if (areFluidsEqual(pair.getValue(), result))
{
public void loadCraftingRecipes(FluidStack result) {
for (Entry<ItemMetaWrapper, FluidStack> pair :
Smeltery.getSmeltingList().entrySet()) {
if (areFluidsEqual(pair.getValue(), result)) {
this.arecipes.add(new CachedMeltingRecipe(new ItemStack(pair.getKey().item, 1, pair.getKey().meta)));
}
}
}
@Override
public void loadUsageRecipes (ItemStack ingred)
{
for (ItemMetaWrapper key : Smeltery.getSmeltingList().keySet())
{
if (NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(key.item, 1, key.meta), ingred))
{
public void loadUsageRecipes(ItemStack ingred) {
for (ItemMetaWrapper key : Smeltery.getSmeltingList().keySet()) {
if (NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(key.item, 1, key.meta), ingred)) {
this.arecipes.add(new CachedMeltingRecipe(new ItemStack(key.item, 1, key.meta)));
}
}
}
}
@@ -1,15 +1,14 @@
package tconstruct.plugins.nei;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.crafting.PatternBuilder;
@@ -23,35 +22,27 @@ import tconstruct.library.util.HarvestLevels;
import tconstruct.library.util.IToolPart;
import tconstruct.tools.items.ToolPart;
import tconstruct.util.config.PHConstruct;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
public class RecipeHandlerToolMaterials extends RecipeHandlerBase
{
public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
public class CachedToolMaterialsRecipe extends CachedBaseRecipe
{
public class CachedToolMaterialsRecipe extends CachedBaseRecipe {
public List<PositionedStack> toolParts;
public ToolMaterial material;
public BowMaterial bowMaterial;
public ArrowMaterial arrowMaterial;
public CachedToolMaterialsRecipe(List<ItemStack> toolParts, int materialID)
{
public CachedToolMaterialsRecipe(List<ItemStack> toolParts, int materialID) {
this.toolParts = new ArrayList<PositionedStack>();
for (ItemStack stack : toolParts)
{
for (ItemStack stack : toolParts) {
this.toolParts.add(new PositionedStack(stack, 10, 10));
}
this.material = TConstructRegistry.getMaterial(materialID);
}
public CachedToolMaterialsRecipe(List<ItemStack> toolParts, int materialID, boolean arrowBow)
{
public CachedToolMaterialsRecipe(List<ItemStack> toolParts, int materialID, boolean arrowBow) {
this.toolParts = new ArrayList<PositionedStack>();
for (ItemStack stack : toolParts)
{
for (ItemStack stack : toolParts) {
this.toolParts.add(new PositionedStack(stack, 10, 10));
}
this.arrowMaterial = TConstructRegistry.getArrowMaterial(materialID);
@@ -59,239 +50,265 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase
}
@Override
public PositionedStack getIngredient ()
{
public PositionedStack getIngredient() {
return this.toolParts.get((cycleticks / 20) % this.toolParts.size());
}
@Override
public PositionedStack getResult ()
{
public PositionedStack getResult() {
return null;
}
}
@Override
public String getRecipeName ()
{
public String getRecipeName() {
return StatCollector.translateToLocal("tconstruct.nei.toolmaterials");
}
@Override
public String getRecipeID ()
{
public String getRecipeID() {
return "tconstruct.tools.materials";
}
@Override
public String getGuiTexture ()
{
public String getGuiTexture() {
return "tinker:textures/gui/nei/toolmaterials.png";
}
@Override
public int recipiesPerPage ()
{
public int recipiesPerPage() {
return 1;
}
@Override
public void drawBackground (int recipe)
{
public void drawBackground(int recipe) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(this.getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 160, 130);
}
@Override
public void loadTransferRects ()
{
this.transferRects.add(new RecipeTransferRect(new Rectangle(10, 30, 16, 16), this.getRecipeID(), new Object[0]));
public void loadTransferRects() {
this.transferRects.add(
new RecipeTransferRect(new Rectangle(10, 30, 16, 16), this.getRecipeID(), new Object[0]));
}
@Override
public void drawExtras (int recipe)
{
public void drawExtras(int recipe) {
CachedToolMaterialsRecipe crecipe = (CachedToolMaterialsRecipe) this.arecipes.get(recipe);
if (crecipe.material != null)
{
if (crecipe.material != null) {
GuiDraw.drawString(EnumChatFormatting.BOLD + crecipe.material.localizedName(), 35, 10, 0x404040, false);
GuiDraw.drawString(StatCollector.translateToLocal("gui.partcrafter4") + crecipe.material.durability, 35, 20, 0x404040, false);
GuiDraw.drawString(StatCollector.translateToLocal("gui.partcrafter5") + crecipe.material.handleModifier + "x", 35, 30, 0x404040, false);
GuiDraw.drawString(StatCollector.translateToLocal("gui.partcrafter11") + Math.round(crecipe.material.durability * crecipe.material.handleModifier), 35, 40, 0x404040, false);
GuiDraw.drawString(StatCollector.translateToLocal("gui.partcrafter6") + crecipe.material.miningspeed / 100F, 35, 50, 0x404040, false);
GuiDraw.drawString(StatCollector.translateToLocal("gui.partcrafter7") + HarvestLevels.getHarvestLevelName(crecipe.material.harvestLevel), 35, 60, 0x404040, false);
String heart = crecipe.material.attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
if (crecipe.material.attack() % 2 == 0)
{
GuiDraw.drawString(StatCollector.translateToLocal("gui.partcrafter10") + crecipe.material.attack / 2 + heart, 35, 70, 0x404040, false);
}
else
{
GuiDraw.drawString(StatCollector.translateToLocal("gui.partcrafter10") + crecipe.material.attack / 2F + heart, 35, 70, 0x404040, false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter4") + crecipe.material.durability,
35,
20,
0x404040,
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter5") + crecipe.material.handleModifier + "x",
35,
30,
0x404040,
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter11")
+ Math.round(crecipe.material.durability * crecipe.material.handleModifier),
35,
40,
0x404040,
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter6") + crecipe.material.miningspeed / 100F,
35,
50,
0x404040,
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter7")
+ HarvestLevels.getHarvestLevelName(crecipe.material.harvestLevel),
35,
60,
0x404040,
false);
String heart = crecipe.material.attack == 2
? StatCollector.translateToLocal("gui.partcrafter8")
: StatCollector.translateToLocal("gui.partcrafter9");
if (crecipe.material.attack() % 2 == 0) {
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter10") + crecipe.material.attack / 2 + heart,
35,
70,
0x404040,
false);
} else {
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter10") + crecipe.material.attack / 2F + heart,
35,
70,
0x404040,
false);
}
int abilityY = 85;
if (crecipe.material.reinforced > 0)
{
if (crecipe.material.reinforced > 0) {
GuiDraw.drawString(getReinforcedString(crecipe.material.reinforced), 35, 85, 0x404040, false);
abilityY += 10;
}
String ability = crecipe.material.ability();
if (ability != null)
{
if (crecipe.material.stonebound != 0)
{
GuiDraw.drawString(ability + " (" + Math.abs(crecipe.material.stonebound) + ")", 35, abilityY, 0x404040, false);
}
else
{
if (ability != null) {
if (crecipe.material.stonebound != 0) {
GuiDraw.drawString(
ability + " (" + Math.abs(crecipe.material.stonebound) + ")",
35,
abilityY,
0x404040,
false);
} else {
GuiDraw.drawString(ability, 35, abilityY, 0x404040, false);
}
}
}
if (crecipe.bowMaterial != null)
{
if (crecipe.bowMaterial != null) {
int y = 20;
int x = 35;
GuiDraw.drawString(EnumChatFormatting.BOLD + StatCollector.translateToLocal("tconstruct.nei.projectilematerials"), 35, 10, 0x404040, false);
GuiDraw.drawString(StatCollector.translateToLocal("gui.toolstation6") + crecipe.bowMaterial.drawspeed, x, y, 0x404040, false);
GuiDraw.drawString(
EnumChatFormatting.BOLD + StatCollector.translateToLocal("tconstruct.nei.projectilematerials"),
35,
10,
0x404040,
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.toolstation6") + crecipe.bowMaterial.drawspeed,
x,
y,
0x404040,
false);
y += 10;
GuiDraw.drawString(StatCollector.translateToLocal("gui.toolstation7") + crecipe.bowMaterial.flightSpeedMax, x, y, 0x404040, false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.toolstation7") + crecipe.bowMaterial.flightSpeedMax,
x,
y,
0x404040,
false);
}
if (crecipe.arrowMaterial != null)
{
if (crecipe.arrowMaterial != null) {
int y = 50;
int x = 35;
GuiDraw.drawString(StatCollector.translateToLocal("gui.toolstation8") + crecipe.arrowMaterial.mass, x, y, 0x404040, false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.toolstation8") + crecipe.arrowMaterial.mass,
x,
y,
0x404040,
false);
y += 10;
GuiDraw.drawString(StatCollector.translateToLocal("gui.toolstation22") + crecipe.arrowMaterial.breakChance, x, y, 0x404040, false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.toolstation22") + crecipe.arrowMaterial.breakChance,
x,
y,
0x404040,
false);
}
}
@Override
public void loadCraftingRecipes (String outputId, Object... results)
{
if (outputId.equals(this.getRecipeID()))
{
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(this.getRecipeID())) {
ToolMaterial mat;
for (int matID : TConstructRegistry.toolMaterials.keySet())
{
for (int matID : TConstructRegistry.toolMaterials.keySet()) {
List<ItemStack> toolParts = new ArrayList<ItemStack>();
mat = TConstructRegistry.toolMaterials.get(matID);
for (ItemKey key : PatternBuilder.instance.materials)
{
for (ItemKey key : PatternBuilder.instance.materials) {
MaterialSet set = PatternBuilder.instance.materialSets.get(key.key);
if (set.materialID == matID)
{
if (set.materialID == matID) {
ItemStack stack = new ItemStack(key.item, 1, key.damage);
toolParts.add(stack);
}
}
for (List list : TConstructRegistry.patternPartMapping.keySet())
{
if ((Integer) list.get(2) == matID)
{
for (List list : TConstructRegistry.patternPartMapping.keySet()) {
if ((Integer) list.get(2) == matID) {
toolParts.add(TConstructRegistry.patternPartMapping.get(list));
}
}
if (!PHConstruct.craftMetalTools)
{
for (CastingRecipe recipe : TConstructRegistry.getTableCasting().getCastingRecipes())
{
if (!PHConstruct.craftMetalTools) {
for (CastingRecipe recipe :
TConstructRegistry.getTableCasting().getCastingRecipes()) {
ItemStack castResult = recipe.getResult();
if (castResult.getItem() instanceof IToolPart)
{
if (((IToolPart) castResult.getItem()).getMaterialID(castResult) == matID)
{
if (castResult.getItem() instanceof IToolPart) {
if (((IToolPart) castResult.getItem()).getMaterialID(castResult) == matID) {
toolParts.add(castResult);
}
}
}
}
if(toolParts.size() > 0) {
if (toolParts.size() > 0) {
this.arecipes.add(new CachedToolMaterialsRecipe(toolParts, matID));
this.arecipes.add(new CachedToolMaterialsRecipe(toolParts, matID, true));
}
}
}
else
{
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadUsageRecipes (ItemStack ingred)
{
if (ingred.getItem() instanceof ToolPart || ingred.getItem() instanceof DynamicToolPart)
{
public void loadUsageRecipes(ItemStack ingred) {
if (ingred.getItem() instanceof ToolPart || ingred.getItem() instanceof DynamicToolPart) {
int materialID = ((IToolPart) ingred.getItem()).getMaterialID(ingred);
if (materialID >= 0)
{
if (materialID >= 0) {
List toolParts = getSingleList(ingred);
if(toolParts.size() > 0) {
if (toolParts.size() > 0) {
this.arecipes.add(new CachedToolMaterialsRecipe(toolParts, materialID));
this.arecipes.add(new CachedToolMaterialsRecipe(toolParts, materialID, true));
}
}
}
else if (PatternBuilder.instance.getPartID(ingred) < Short.MAX_VALUE)
{
} else if (PatternBuilder.instance.getPartID(ingred) < Short.MAX_VALUE) {
int materialID = PatternBuilder.instance.getPartID(ingred);
List toolParts = getSingleList(ingred);
if(toolParts.size() > 0) {
if (toolParts.size() > 0) {
this.arecipes.add(new CachedToolMaterialsRecipe(toolParts, materialID));
this.arecipes.add(new CachedToolMaterialsRecipe(toolParts, materialID, true));
}
}
else
{
} else {
super.loadUsageRecipes(ingred);
}
}
public static String getReinforcedString (int reinforced)
{
if (reinforced > 9)
return "Unbreakable";
public static String getReinforcedString(int reinforced) {
if (reinforced > 9) return "Unbreakable";
String ret = "Reinforced ";
switch (reinforced)
{
case 1:
ret += "I";
break;
case 2:
ret += "II";
break;
case 3:
ret += "III";
break;
case 4:
ret += "IV";
break;
case 5:
ret += "V";
break;
case 6:
ret += "VI";
break;
case 7:
ret += "VII";
break;
case 8:
ret += "VIII";
break;
case 9:
ret += "IX";
break;
default:
ret += "X";
break;
switch (reinforced) {
case 1:
ret += "I";
break;
case 2:
ret += "II";
break;
case 3:
ret += "III";
break;
case 4:
ret += "IV";
break;
case 5:
ret += "V";
break;
case 6:
ret += "VI";
break;
case 7:
ret += "VII";
break;
case 8:
ret += "VIII";
break;
case 9:
ret += "IX";
break;
default:
ret += "X";
break;
}
return ret;
}
}