Workaround for lack of GUI partial transparency.

master
einsteinsci 2015-08-11 14:40:01 -07:00
parent 99215b9007
commit 572c806e5c
6 changed files with 43 additions and 21 deletions

View File

@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge'
version = "MC1.8.0-b0.9.1"
version = "MC1.8.0-b0.9.1-pre1"
group= "net.einsteinsci.betterbeginnings" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "betterbeginnings"

View File

@ -6,6 +6,7 @@ import net.einsteinsci.betterbeginnings.register.recipe.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.block.model.ItemModelGenerator;
import net.minecraft.client.renderer.entity.RenderItem;
@ -26,13 +27,17 @@ import org.lwjgl.opengl.GL12;
public class GuiDoubleWorkbench extends GuiContainer
{
private static final ResourceLocation workbenchGuiTextures = new ResourceLocation(ModMain.MODID +
":textures/gui/container/doubleWorkbench.png");
":textures/gui/container/doubleWorkbench_MC18.png");
private final ContainerDoubleWorkbench container;
private boolean needsCatalystItems = false;
//protected final int trueXSize = xSize + 20;
public GuiDoubleWorkbench(InventoryPlayer invPlayer, World world, BlockPos pos)
{
super(new ContainerDoubleWorkbench(invPlayer, world, pos));
xSize += 20;
container = (ContainerDoubleWorkbench)inventorySlots;
}
@ -42,7 +47,7 @@ public class GuiDoubleWorkbench extends GuiContainer
{
super.drawScreen(xMouse, yMouse, par3);
renderTransparentItems();
//renderTransparentItems();
}
/**
@ -52,23 +57,31 @@ public class GuiDoubleWorkbench extends GuiContainer
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
// I'm guessing the really big number at the end is the z layer.
fontRendererObj.drawString(I18n.format("container.craftingdouble"), 33, 6, 4210752);
fontRendererObj.drawString(I18n.format("container.craftingdouble"), 33 + 20, 6, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(workbenchGuiTextures);
int k = (width - xSize) / 2;
int l = (height - ySize) / 2;
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
renderTransparentItems();
if (needsCatalystItems)
{
drawTexturedModalRect(k + 144, l + 30, xSize, 0, 26, 26);
}
renderTransparentItems(k, l);
}
public void renderTransparentItems()
public void renderTransparentItems(int k, int l)
{
final int CATALYST_X_OFFSET = -20;
needsCatalystItems = false;
if (AdvancedCraftingHandler.crafting().hasRecipe(container.craftMatrix, container.worldObj))
{
for (AdvancedRecipe recipe : AdvancedCraftingHandler.crafting().recipes)
@ -88,8 +101,8 @@ public class GuiDoubleWorkbench extends GuiContainer
Slot slot = container.matSlots[i];
if (container.addedMats.getStackInSlot(i) == null)
{
drawItemStack(needed, (width - xSize) / 2 + slot.xDisplayPosition, (height - ySize) / 2 +
slot.yDisplayPosition, "" + needed.stackSize);
drawItemStack(needed, k + slot.xDisplayPosition + CATALYST_X_OFFSET,
l + slot.yDisplayPosition, "" + needed.stackSize);
}
}
@ -97,9 +110,16 @@ public class GuiDoubleWorkbench extends GuiContainer
Slot slot = container.resultSlot;
if (container.craftResult.getStackInSlot(0) == null)
{
drawItemStack(result, (width - xSize) / 2 + slot.xDisplayPosition, (height - ySize) / 2 +
slot.yDisplayPosition, "");
if (result != null)
{
// Draw red output box
mc.getTextureManager().bindTexture(workbenchGuiTextures);
needsCatalystItems = true;
drawItemStack(result, k + slot.xDisplayPosition, l + slot.yDisplayPosition, "");
}
}
break;
}
}
}

View File

@ -9,7 +9,6 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
@ -19,7 +18,7 @@ import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiSmelter extends GuiContainer
{
private static final ResourceLocation smelterGuiTextures =
private static final ResourceLocation SMELTER_GUI_TEXTURES =
new ResourceLocation(ModMain.MODID + ":textures/gui/container/smelter.png");
private TileEntitySmelter tileSmelter;
@ -41,7 +40,7 @@ public class GuiSmelter extends GuiContainer
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
mc.getTextureManager().bindTexture(smelterGuiTextures);
mc.getTextureManager().bindTexture(SMELTER_GUI_TEXTURES);
int k = (width - xSize) / 2;
int l = (height - ySize) / 2;
@ -59,10 +58,11 @@ public class GuiSmelter extends GuiContainer
if (tileSmelter.getStackInSlot(TileEntitySmelter.GRAVEL) == null)
{
drawItemStack(new ItemStack(Blocks.gravel), k + 66, l + 17, "");
//drawItemStack(new ItemStack(Blocks.gravel), k + 66, l + 17, "");
}
}
// unused until partial transparency is working properly.
private void drawItemStack(ItemStack stack, int xPos, int yPos, String note)
{
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();

View File

@ -31,7 +31,10 @@ public class ContainerDoubleWorkbench extends Container
worldObj = world;
pos = loc;
resultSlot = new SlotAdvancedCrafting(invPlayer.player, craftMatrix, craftResult, addedMats, 0, 129, 35);
final int OFFSET = 20;
resultSlot = new SlotAdvancedCrafting(invPlayer.player, craftMatrix, craftResult, addedMats, 0,
129 + OFFSET, 35);
addSlotToContainer(resultSlot);
int i;
int j;
@ -41,7 +44,7 @@ public class ContainerDoubleWorkbench extends Container
{
for (j = 0; j < 3; ++j)
{
addSlotToContainer(new Slot(craftMatrix, j + i * 3, 35 + j * 18, 17 + i * 18));
addSlotToContainer(new Slot(craftMatrix, j + i * 3, 35 + OFFSET + j * 18, 17 + i * 18));
}
}
@ -50,21 +53,20 @@ public class ContainerDoubleWorkbench extends Container
{
for (j = 0; j < 9; ++j)
{
addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + OFFSET + j * 18, 84 + i * 18));
}
}
// Hotbar
for (i = 0; i < 9; ++i)
{
addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142));
addSlotToContainer(new Slot(invPlayer, i, 8 + OFFSET + i * 18, 142));
}
// Additional materials
for (i = 0; i < 4; ++i)
{
matSlots[i] = new Slot(addedMats, i, 8, 7 + i * 18);
// matSlots[i].setBackgroundIcon(Items.apple.getIconFromDamage(0));
matSlots[i] = new Slot(addedMats, i, 8 + OFFSET, 7 + i * 18);
addSlotToContainer(matSlots[i]);
onCraftMatrixChanged(craftMatrix);

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB