mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 11:59:14 +00:00
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:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user