Clean up widgets and OpenGL gui lighting issues

This commit is contained in:
mezz committed 2015-11-13 23:12:40 -08:00
1 parent 430115a7d4
commit 5f2de3026e
32 files changed
+642 -700

No files matched your search

@@ -10,15 +10,17 @@
******************************************************************************/
package forestry.apiculture.gui;
import com.google.common.collect.LinkedListMultimap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
import java.util.List;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.biome.BiomeGenBase;
@@ -26,30 +28,30 @@ import net.minecraftforge.common.BiomeDictionary;
import org.lwjgl.opengl.GL11;
import forestry.apiculture.gui.widgets.HabitatSlot;
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestry;
import forestry.core.gui.widgets.Widget;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.render.TextureManager;
public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, ItemInventoryHabitatLocator> {
private static final LinkedListMultimap<String, BiomeDictionary.Type> habitats = LinkedListMultimap.create();
private final HabitatSlot[] habitatSlots = new HabitatSlot[]{
new HabitatSlot(0, "Ocean"), // ocean, beach
new HabitatSlot(1, "Plains"),
new HabitatSlot(2, "Desert"), // desert, desert hills
new HabitatSlot(3, "Forest"), // forest, forestHills, river
new HabitatSlot(4, "Jungle"), // jungle, jungleHills
new HabitatSlot(5, "Taiga"), // taiga, taigaHills
new HabitatSlot(6, "Hills"), // extremeHills, extremeHillsEdge
new HabitatSlot(7, "Swamp"),
new HabitatSlot(8, "Snow"), // Ice plains, mountains, frozen rivers, frozen oceans
new HabitatSlot(9, "Mushroom"),
new HabitatSlot(10, "Nether"),
new HabitatSlot(11, "End")};
private final Map<BiomeDictionary.Type, HabitatSlot> biomeToHabitat = new EnumMap<>(BiomeDictionary.Type.class);
static {
habitats.putAll("Ocean", Arrays.asList(BiomeDictionary.Type.OCEAN, BiomeDictionary.Type.BEACH));
habitats.put("Plains", BiomeDictionary.Type.PLAINS);
habitats.put("Desert", BiomeDictionary.Type.SANDY);
habitats.putAll("Forest", Arrays.asList(BiomeDictionary.Type.FOREST, BiomeDictionary.Type.RIVER));
habitats.put("Jungle", BiomeDictionary.Type.JUNGLE);
habitats.put("Taiga", BiomeDictionary.Type.CONIFEROUS);
habitats.put("Hills", BiomeDictionary.Type.MOUNTAIN);
habitats.put("Swamp", BiomeDictionary.Type.SWAMP);
habitats.put("Snow", BiomeDictionary.Type.SNOWY);
habitats.put("Mushroom", BiomeDictionary.Type.MUSHROOM);
habitats.put("Nether", BiomeDictionary.Type.NETHER);
habitats.put("End", BiomeDictionary.Type.END);
}
private final List<HabitatSlot> habitatSlots = new ArrayList<>(habitats.size());
private int startX;
private int startY;
@@ -60,36 +62,23 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Item
xSize = 176;
ySize = 184;
int x;
int y;
for (HabitatSlot slot : habitatSlots) {
if (slot.slot > 5) {
x = 18 + (slot.slot - 6) * 20;
int slot = 0;
for (String habitatName : habitats.keySet()) {
int x;
int y;
if (slot > 5) {
x = 18 + (slot - 6) * 20;
y = 50;
} else {
x = 18 + slot.slot * 20;
x = 18 + slot * 20;
y = 32;
}
slot.setPosition(x, y);
this.widgetManager.add(slot);
Collection<BiomeDictionary.Type> biomes = habitats.get(habitatName);
HabitatSlot habitatSlot = new HabitatSlot(widgetManager, x, y, habitatName, biomes);
habitatSlots.add(habitatSlot);
widgetManager.add(habitatSlot);
slot++;
}
biomeToHabitat.put(BiomeDictionary.Type.OCEAN, habitatSlots[0]);
biomeToHabitat.put(BiomeDictionary.Type.BEACH, habitatSlots[0]);
biomeToHabitat.put(BiomeDictionary.Type.PLAINS, habitatSlots[1]);
biomeToHabitat.put(BiomeDictionary.Type.SANDY, habitatSlots[2]);
biomeToHabitat.put(BiomeDictionary.Type.FOREST, habitatSlots[3]);
biomeToHabitat.put(BiomeDictionary.Type.RIVER, habitatSlots[3]);
biomeToHabitat.put(BiomeDictionary.Type.JUNGLE, habitatSlots[4]);
biomeToHabitat.put(BiomeDictionary.Type.CONIFEROUS, habitatSlots[5]);
biomeToHabitat.put(BiomeDictionary.Type.MOUNTAIN, habitatSlots[6]);
biomeToHabitat.put(BiomeDictionary.Type.SWAMP, habitatSlots[7]);
biomeToHabitat.put(BiomeDictionary.Type.SNOWY, habitatSlots[8]);
biomeToHabitat.put(BiomeDictionary.Type.MUSHROOM, habitatSlots[9]);
biomeToHabitat.put(BiomeDictionary.Type.NETHER, habitatSlots[10]);
biomeToHabitat.put(BiomeDictionary.Type.END, habitatSlots[11]);
}
@Override
@@ -101,27 +90,18 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Item
// Set active according to valid biomes.
Set<BiomeDictionary.Type> activeBiomeTypes = EnumSet.noneOf(BiomeDictionary.Type.class);
for (HabitatSlot habitatSlot : habitatSlots) {
habitatSlot.isActive = false;
}
for (BiomeGenBase biome : inventory.getBiomesToSearch()) {
Collections.addAll(activeBiomeTypes, BiomeDictionary.getTypesForBiome(biome));
}
for (BiomeDictionary.Type biomeType : activeBiomeTypes) {
HabitatSlot habitatSlot = biomeToHabitat.get(biomeType);
if (habitatSlot != null) {
habitatSlot.isActive = true;
}
for (HabitatSlot habitatSlot : habitatSlots) {
habitatSlot.setActive(activeBiomeTypes);
}
for (HabitatSlot slot : habitatSlots) {
slot.draw(startX, startY);
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // Reset afterwards.
}
@Override
@@ -131,53 +111,4 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Item
startX = (this.width - this.xSize) / 2;
startY = (this.height - this.ySize) / 2;
}
public class HabitatSlot extends Widget {
private final int slot;
private final String name;
private final String iconIndex;
public boolean isActive = false;
public HabitatSlot(int slot, String name) {
super(widgetManager, 0, 0);
this.slot = slot;
this.name = name;
this.iconIndex = "habitats/" + name.toLowerCase(Locale.ENGLISH);
}
@Override
public String getLegacyTooltip(EntityPlayer player) {
return name;
}
public IIcon getIcon() {
return TextureManager.getInstance().getDefault(iconIndex);
}
public void setPosition(int x, int y) {
this.xPos = x;
this.yPos = y;
}
@Override
public void draw(int startX, int startY) {
if (getIcon() != null) {
GL11.glDisable(GL11.GL_LIGHTING);
if (!isActive) {
GL11.glColor4f(0.2f, 0.2f, 0.2f, 0.2f);
} else {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
Proxies.render.bindTexture(SpriteSheet.ITEMS);
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIcon(), 16, 16);
GL11.glEnable(GL11.GL_LIGHTING);
}
}
}
}
@@ -15,7 +15,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -26,6 +25,7 @@ import forestry.apiculture.items.ItemBeeGE;
import forestry.core.config.Constants;
import forestry.core.config.ForestryItem;
import forestry.core.gui.GuiForestry;
import forestry.core.gui.GuiUtil;
import forestry.core.network.PacketGuiSelectRequest;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StringUtil;
@@ -75,9 +75,7 @@ public class GuiImprinter extends GuiForestry<ContainerImprinter, ItemInventoryI
}
private void drawBeeSpeciesIcon(IAlleleBeeSpecies bee, int x, int y) {
RenderHelper.enableStandardItemLighting();
drawItemStack(iconStacks.get(bee.getUID()), x, y);
RenderHelper.disableStandardItemLighting();
GuiUtil.drawItemStack(this, iconStacks.get(bee.getUID()), x, y);
}
private static int getHabitatSlotAtPosition(int i, int j) {
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui.widgets;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.BiomeDictionary;
import org.lwjgl.opengl.GL11;
import forestry.core.gui.widgets.Widget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.render.TextureManager;
public class HabitatSlot extends Widget {
private final Collection<BiomeDictionary.Type> biomes;
private final String name;
private final String iconIndex;
public boolean isActive = false;
public HabitatSlot(WidgetManager widgetManager, int xPos, int yPos, String name, Collection<BiomeDictionary.Type> biomes) {
super(widgetManager, xPos, yPos);
this.biomes = biomes;
this.name = name;
this.iconIndex = "habitats/" + name.toLowerCase(Locale.ENGLISH);
}
@Override
public String getLegacyTooltip(EntityPlayer player) {
return name;
}
public IIcon getIcon() {
return TextureManager.getInstance().getDefault(iconIndex);
}
public void setActive(Collection<BiomeDictionary.Type> biomes) {
isActive = !Collections.disjoint(this.biomes, biomes);
}
@Override
public void draw(int startX, int startY) {
if (getIcon() != null) {
if (!isActive) {
GL11.glColor4f(0.2f, 0.2f, 0.2f, 0.2f);
} else {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
Proxies.render.bindTexture(SpriteSheet.ITEMS);
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIcon(), 16, 16);
}
}
}
@@ -33,6 +33,7 @@ public class HabitatLocatorLogic {
private static final int maxChecksPerTick = 100;
private static final int maxSearchRadiusIterations = 500;
private static final int spacing = 20;
private static final int minBiomeRadius = 8;
private static final Set<BiomeGenBase> waterBiomes = new HashSet<>();
private static final Set<BiomeGenBase> netherBiomes = new HashSet<>();
@@ -151,10 +152,6 @@ public class HabitatLocatorLogic {
}
private static ChunkCoordinates getChunkCoordinates(Vect pos, World world, Collection<BiomeGenBase> biomesToSearch) {
// to avoid reporting very tiny patches, check around the point want
final int minBiomeRadius = 8;
BiomeGenBase biome;
biome = world.getBiomeGenForCoords(pos.x, pos.z);
@@ -107,7 +107,6 @@ public class RenderBeeItem implements IItemRenderer {
float pitch = 1;
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
@@ -152,7 +151,6 @@ public class RenderBeeItem implements IItemRenderer {
*/
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
RenderHelper.enableStandardItemLighting();
@@ -113,10 +113,8 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
textLayout.drawLine(text0, textLayout.column0);
int columnwidth = textLayout.column2 - textLayout.column1 - 2;
RenderHelper.enableStandardItemLighting();
drawItemStack(iconStacks.get(primary.getUID()), guiLeft + textLayout.column1 + (columnwidth - 20), guiTop + 10);
drawItemStack(iconStacks.get(secondary.getUID()), guiLeft + textLayout.column2 + (columnwidth - 20), guiTop + 10);
RenderHelper.disableStandardItemLighting();
GuiUtil.drawItemStack(this, iconStacks.get(primary.getUID()), guiLeft + textLayout.column1 + (columnwidth - 20), guiTop + 10);
GuiUtil.drawItemStack(this, iconStacks.get(secondary.getUID()), guiLeft + textLayout.column2 + (columnwidth - 20), guiTop + 10);
String primaryName = customPrimaryName == null ? primary.getName() : customPrimaryName;
String secondaryName = customSecondaryName == null ? secondary.getName() : customSecondaryName;
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.core.gui;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -82,13 +81,10 @@ public class GuiEscritoire extends GuiForestry<ContainerEscritoire, TileEscritoi
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
for (int i = 0; i <= inventory.getGame().getBountyLevel() / 4; i++) {
RenderHelper.enableGUIStandardItemLighting();
GuiForestry.itemRender.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, LEVEL_ITEM, guiLeft + 170 + i * 8, guiTop + 7);
RenderHelper.disableStandardItemLighting();
GuiUtil.drawItemStack(this, LEVEL_ITEM, guiLeft + 170 + i * 8, guiTop + 7);
}
textLayout.startPage();
GL11.glPushMatrix();
{
GL11.glScaled(0.5, 0.5, 0.5);
GL11.glTranslated(guiLeft + 170, guiTop + 10, 0.0);
@@ -102,7 +98,6 @@ public class GuiEscritoire extends GuiForestry<ContainerEscritoire, TileEscritoi
String escritoireText = textSource.getText(inventory.getGame());
textLayout.drawSplitLine(escritoireText, 170, 90, fontColor.get("gui.mail.lettertext"));
}
GL11.glPopMatrix();
textLayout.endPage();
}
}
+33 -152
View File
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.core.gui;
import java.awt.Color;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -26,7 +24,6 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.common.Optional;
@@ -43,9 +40,6 @@ import forestry.core.gui.ledgers.HintLedger;
import forestry.core.gui.ledgers.LedgerManager;
import forestry.core.gui.ledgers.OwnerLedger;
import forestry.core.gui.ledgers.PowerLedger;
import forestry.core.gui.tooltips.IToolTipProvider;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.gui.tooltips.ToolTipLine;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.core.render.FontColour;
@@ -139,6 +133,10 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
return fontColor;
}
public FontRenderer getFontRenderer() {
return fontRendererObj;
}
@Override
protected void mouseClicked(int xPos, int yPos, int mouseButton) {
super.mouseClicked(xPos, yPos, mouseButton);
@@ -179,146 +177,55 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
return this.func_146978_c(par1Slot.xDisplayPosition, par1Slot.yDisplayPosition, 16, 16, par2, par3);
}
private void drawToolTips(ToolTip toolTips, int mouseX, int mouseY) {
if (toolTips == null) {
return;
}
if (toolTips.isEmpty()) {
return;
}
int left = this.guiLeft;
int top = this.guiTop;
int length = 0;
int height = 0;
int x;
int y;
for (ToolTipLine tip : toolTips) {
y = this.fontRendererObj.getStringWidth(tip.toString());
height += 10 + tip.getSpacing();
if (y > length) {
length = y;
}
}
x = mouseX - left + 12;
y = mouseY - top - 12;
this.zLevel = 300.0F;
itemRender.zLevel = 300.0F;
Color backgroundColor = new Color(16, 0, 16, 240);
int backgroundColorInt = backgroundColor.getRGB();
this.drawGradientRect(x - 3, y - 4, x + length + 2, y - 3, backgroundColorInt, backgroundColorInt);
this.drawGradientRect(x - 3, y + height + 1, x + length + 2, y + height + 2, backgroundColorInt, backgroundColorInt);
this.drawGradientRect(x - 3, y - 3, x + length + 2, y + height + 1, backgroundColorInt, backgroundColorInt);
this.drawGradientRect(x - 4, y - 3, x - 3, y + height + 1, backgroundColorInt, backgroundColorInt);
this.drawGradientRect(x + length + 2, y - 3, x + length + 3, y + height + 1, backgroundColorInt, backgroundColorInt);
Color borderColorTop = new Color(80, 0, 255, 80);
int borderColorTopInt = borderColorTop.getRGB();
Color borderColorBottom = new Color((borderColorTopInt & 0xfefefe) >> 1 | borderColorTopInt & -0x1000000, true);
int borderColorBottomInt = borderColorBottom.getRGB();
this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + height, borderColorTopInt, borderColorBottomInt);
this.drawGradientRect(x + length + 1, y - 3 + 1, x + length + 2, y + height, borderColorTopInt, borderColorBottomInt);
this.drawGradientRect(x - 3, y - 3, x + length + 2, y - 3 + 1, borderColorTopInt, borderColorTopInt);
this.drawGradientRect(x - 3, y + height, x + length + 2, y + height + 1, borderColorBottomInt, borderColorBottomInt);
boolean firstLine = true;
for (ToolTipLine tip : toolTips) {
String line = tip.toString();
if (!firstLine) {
line = EnumChatFormatting.GRAY + line;
}
this.fontRendererObj.drawStringWithShadow(line, x, y, -1);
y += 10 + tip.getSpacing();
firstLine = false;
}
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glPushMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
{
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
ledgerManager.drawTooltips(mouseX, mouseY);
ledgerManager.drawTooltips(mouseX, mouseY);
InventoryPlayer playerInv = mc.thePlayer.inventory;
InventoryPlayer playerInv = mc.thePlayer.inventory;
if (playerInv.getItemStack() == null) {
drawToolTips(widgetManager.getWidgets(), mouseX, mouseY);
drawToolTips(buttonList, mouseX, mouseY);
drawToolTips(inventorySlots.inventorySlots, mouseX, mouseY);
if (playerInv.getItemStack() == null) {
GuiUtil.drawToolTips(this, widgetManager.getWidgets(), mouseX, mouseY);
GuiUtil.drawToolTips(this, buttonList, mouseX, mouseY);
GuiUtil.drawToolTips(this, inventorySlots.inventorySlots, mouseX, mouseY);
}
}
GL11.glPopMatrix();
GL11.glPopAttrib();
}
private void drawToolTips(Collection<?> objects, int mouseX, int mouseY) {
for (Object obj : objects) {
if (!(obj instanceof IToolTipProvider)) {
continue;
}
IToolTipProvider provider = (IToolTipProvider) obj;
if (!provider.isToolTipVisible()) {
continue;
}
ToolTip tips = provider.getToolTip();
if (tips == null) {
continue;
}
boolean mouseOver = provider.isMouseOver(mouseX - guiLeft, mouseY - guiTop);
tips.onTick(mouseOver);
if (mouseOver && tips.isReady()) {
tips.refresh();
drawToolTips(tips, mouseX, mouseY);
}
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
bindTexture(textureFile);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
int left = this.guiLeft;
int top = this.guiTop;
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glPushMatrix();
GL11.glTranslatef(left, top, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
{
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glPushMatrix();
{
GL11.glTranslatef(guiLeft, guiTop, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
drawWidgets();
GL11.glPopMatrix();
drawWidgets();
}
GL11.glPopMatrix();
}
GL11.glPopAttrib();
bindTexture(textureFile);
@@ -363,32 +270,6 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
super.drawGradientRect(par1, par2, par3, par4, par5, par6);
}
public void drawItemStack(ItemStack stack, int xPos, int yPos) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
this.zLevel = 100.0F;
itemRender.zLevel = 100.0F;
FontRenderer font = null;
if (stack != null) {
font = stack.getItem().getFontRenderer(stack);
}
if (font == null) {
font = fontRendererObj;
}
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), stack, xPos, yPos);
itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), stack, xPos, yPos);
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
RenderHelper.disableStandardItemLighting();
GL11.glPopAttrib();
}
/* NEI */
@Override
@Optional.Method(modid = "NotEnoughItems")
@@ -29,5 +29,6 @@ public abstract class GuiForestryTitled<C extends Container, I extends ITitled &
String name = StatCollector.translateToLocal(inventory.getUnlocalizedTitle());
textLayout.line = 6;
textLayout.drawCenteredLine(name, 0, fontColor.get("gui.title"));
bindTexture(textureFile);
}
}
@@ -158,9 +158,7 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
}
textLayout.drawLine(species.getName(), x);
RenderHelper.enableGUIStandardItemLighting();
drawItemStack(iconStack, guiLeft + x + 69, guiTop + textLayout.getLineY() - 2);
RenderHelper.disableStandardItemLighting();
GuiUtil.drawItemStack(this, iconStack, guiLeft + x + 69, guiTop + textLayout.getLineY() - 2);
textLayout.newLine();
@@ -191,10 +189,7 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
}
private void drawMutationIcon(IMutation combination, IAlleleSpecies species, int x) {
RenderHelper.enableGUIStandardItemLighting();
drawItemStack(iconStacks.get(combination.getPartner(species).getUID()), guiLeft + x, guiTop + textLayout.getLineY());
RenderHelper.disableStandardItemLighting();
GuiUtil.drawItemStack(this, iconStacks.get(combination.getPartner(species).getUID()), guiLeft + x, guiTop + textLayout.getLineY());
int line = 48;
int column;
@@ -0,0 +1,148 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.gui;
import java.awt.Color;
import java.util.Collection;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
import forestry.core.gui.tooltips.IToolTipProvider;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.gui.tooltips.ToolTipLine;
public class GuiUtil {
public static void drawItemStack(GuiForestry gui, ItemStack stack, int xPos, int yPos) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
RenderItem itemRender = GuiForestry.getItemRenderer();
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
gui.setZLevel(100.0F);
itemRender.zLevel = 100.0F;
FontRenderer font = null;
if (stack != null) {
font = stack.getItem().getFontRenderer(stack);
}
if (font == null) {
font = gui.getFontRenderer();
}
itemRender.renderItemAndEffectIntoGUI(font, gui.mc.getTextureManager(), stack, xPos, yPos);
itemRender.renderItemOverlayIntoGUI(font, gui.mc.getTextureManager(), stack, xPos, yPos);
gui.setZLevel(0.0F);
itemRender.zLevel = 0.0F;
RenderHelper.disableStandardItemLighting();
GL11.glPopAttrib();
}
public static void drawToolTips(GuiForestry gui, ToolTip toolTips, int mouseX, int mouseY) {
if (toolTips == null) {
return;
}
if (toolTips.isEmpty()) {
return;
}
RenderItem itemRender = GuiForestry.getItemRenderer();
FontRenderer fontRendererObj = gui.getFontRenderer();
int left = gui.getGuiLeft();
int top = gui.getGuiTop();
int length = 0;
int height = 0;
int x;
int y;
for (ToolTipLine tip : toolTips) {
y = fontRendererObj.getStringWidth(tip.toString());
height += 10 + tip.getSpacing();
if (y > length) {
length = y;
}
}
x = mouseX - left + 12;
y = mouseY - top - 12;
gui.setZLevel(300.0F);
itemRender.zLevel = 300.0F;
Color backgroundColor = new Color(16, 0, 16, 240);
int backgroundColorInt = backgroundColor.getRGB();
gui.drawGradientRect(x - 3, y - 4, x + length + 2, y - 3, backgroundColorInt, backgroundColorInt);
gui.drawGradientRect(x - 3, y + height + 1, x + length + 2, y + height + 2, backgroundColorInt, backgroundColorInt);
gui.drawGradientRect(x - 3, y - 3, x + length + 2, y + height + 1, backgroundColorInt, backgroundColorInt);
gui.drawGradientRect(x - 4, y - 3, x - 3, y + height + 1, backgroundColorInt, backgroundColorInt);
gui.drawGradientRect(x + length + 2, y - 3, x + length + 3, y + height + 1, backgroundColorInt, backgroundColorInt);
Color borderColorTop = new Color(80, 0, 255, 80);
int borderColorTopInt = borderColorTop.getRGB();
Color borderColorBottom = new Color((borderColorTopInt & 0xfefefe) >> 1 | borderColorTopInt & -0x1000000, true);
int borderColorBottomInt = borderColorBottom.getRGB();
gui.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + height, borderColorTopInt, borderColorBottomInt);
gui.drawGradientRect(x + length + 1, y - 3 + 1, x + length + 2, y + height, borderColorTopInt, borderColorBottomInt);
gui.drawGradientRect(x - 3, y - 3, x + length + 2, y - 3 + 1, borderColorTopInt, borderColorTopInt);
gui.drawGradientRect(x - 3, y + height, x + length + 2, y + height + 1, borderColorBottomInt, borderColorBottomInt);
boolean firstLine = true;
for (ToolTipLine tip : toolTips) {
String line;
if (firstLine) {
line = tip.toString();
} else {
line = EnumChatFormatting.GRAY + tip.toString();
}
fontRendererObj.drawStringWithShadow(line, x, y, -1);
y += 10 + tip.getSpacing();
firstLine = false;
}
gui.setZLevel(0.0F);
itemRender.zLevel = 0.0F;
}
public static void drawToolTips(GuiForestry gui, Collection<?> objects, int mouseX, int mouseY) {
for (Object obj : objects) {
if (!(obj instanceof IToolTipProvider)) {
continue;
}
IToolTipProvider provider = (IToolTipProvider) obj;
if (!provider.isToolTipVisible()) {
continue;
}
ToolTip tips = provider.getToolTip(mouseX - gui.getGuiLeft(), mouseY - gui.getGuiTop());
if (tips == null) {
continue;
}
boolean mouseOver = provider.isMouseOver(mouseX - gui.getGuiLeft(), mouseY - gui.getGuiTop());
tips.onTick(mouseOver);
if (mouseOver && tips.isReady()) {
tips.refresh();
drawToolTips(gui, tips, mouseX, mouseY);
}
}
}
}
@@ -112,7 +112,7 @@ public class GuiBetterButton extends GuiButton implements IToolTipProvider {
}
@Override
public ToolTip getToolTip() {
public ToolTip getToolTip(int mouseX, int mouseY) {
return toolTip;
}
@@ -197,13 +197,10 @@ public abstract class Ledger {
}
protected void drawIcon(IIcon icon, int x, int y) {
if (icon != null) {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
Proxies.render.bindTexture(SpriteSheet.ITEMS);
manager.gui.drawTexturedModelRectFromIcon(x, y, icon, 16, 16);
GL11.glEnable(GL11.GL_LIGHTING);
}
}
@@ -10,13 +10,9 @@
******************************************************************************/
package forestry.core.gui.ledgers;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
import forestry.api.core.IErrorSource;
@@ -24,10 +20,10 @@ import forestry.api.core.IErrorState;
import forestry.core.config.SessionVars;
import forestry.core.errors.FakeErrorSource;
import forestry.core.gui.GuiForestry;
import forestry.core.proxy.Proxies;
import forestry.core.gui.GuiUtil;
import forestry.core.gui.tooltips.ToolTip;
public class LedgerManager {
private final List<Ledger> ledgers = new ArrayList<>();
private final List<ErrorLedger> errorLedgers = new ArrayList<>();
@@ -75,7 +71,6 @@ public class LedgerManager {
}
private Ledger getAtPosition(int mX, int mY) {
if (ledgers.size() > 0) {
final int xShift = ((gui.width - gui.getSizeX()) / 2) + gui.getSizeX();
int yShift = ((gui.height - gui.getSizeY()) / 2) + 8;
@@ -116,7 +111,6 @@ public class LedgerManager {
}
public void drawLedgers() {
int yPos = 8;
for (Ledger ledger : ledgers) {
@@ -154,19 +148,12 @@ public class LedgerManager {
}
public void drawTooltips(int mouseX, int mouseY) {
Ledger ledger = getAtPosition(mouseX, mouseY);
if (ledger != null) {
int startX = mouseX - ((gui.width - gui.getSizeX()) / 2) + 12;
int startY = mouseY - ((gui.height - gui.getSizeY()) / 2) - 12;
String tooltip = ledger.getTooltip();
Minecraft minecraft = Proxies.common.getClientInstance();
int textWidth = minecraft.fontRenderer.getStringWidth(tooltip);
gui.drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3, 0xc0000000, 0xc0000000);
minecraft.fontRenderer.drawStringWithShadow(tooltip, startX, startY, -1);
ToolTip toolTip = new ToolTip();
toolTip.add(ledger.getTooltip());
GuiUtil.drawToolTips(gui, toolTip, mouseX, mouseY);
}
}
public void handleMouseClicked(int x, int y, int mouseButton) {
@@ -96,9 +96,11 @@ public class SlotForestry extends Slot implements IToolTipProvider {
/**
* @return the toolTips
* @param mouseX
* @param mouseY
*/
@Override
public ToolTip getToolTip() {
public ToolTip getToolTip(int mouseX, int mouseY) {
return toolTips;
}
@@ -15,7 +15,7 @@ package forestry.core.gui.tooltips;
*/
public interface IToolTipProvider {
ToolTip getToolTip();
ToolTip getToolTip(int mouseX, int mouseY);
boolean isToolTipVisible();
@@ -14,9 +14,11 @@ import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import org.lwjgl.opengl.GL11;
import forestry.core.gui.GuiUtil;
import forestry.core.network.PacketGuiSelectRequest;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
@@ -65,18 +67,14 @@ public class GameTokenWidget extends Widget {
tokenStack = token.getTokenStack();
}
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableGUIStandardItemLighting();
manager.gui.drawItemStack(tokenStack, startX + xPos + 3, startY + yPos + 3);
RenderHelper.disableStandardItemLighting();
GL11.glPopAttrib();
GuiUtil.drawItemStack(manager.gui, tokenStack, startX + xPos + 3, startY + yPos + 3);
manager.gui.setZLevel(150f);
for (String ident : getToken().getOverlayIcons()) {
RenderHelper.enableGUIStandardItemLighting();
Proxies.render.bindTexture(SpriteSheet.ITEMS);
manager.gui.drawTexturedModelRectFromIcon(startX + xPos + 3, startY + yPos + 3, TextureManager.getInstance().getDefault(ident), 16, 16);
IIcon icon = TextureManager.getInstance().getDefault(ident);
manager.gui.drawTexturedModelRectFromIcon(startX + xPos + 3, startY + yPos + 3, icon, 16, 16);
RenderHelper.disableStandardItemLighting();
}
manager.gui.setZLevel(0f);
@@ -13,6 +13,7 @@ package forestry.core.gui.widgets;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.core.gui.GuiUtil;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.proxy.Proxies;
@@ -27,12 +28,12 @@ public abstract class ItemStackWidgetBase extends Widget {
public void draw(int startX, int startY) {
ItemStack itemStack = getItemStack();
if (itemStack != null) {
manager.gui.drawItemStack(itemStack, xPos + startX, yPos + startY);
GuiUtil.drawItemStack(manager.gui, itemStack, xPos + startX, yPos + startY);
}
}
@Override
public ToolTip getToolTip() {
public ToolTip getToolTip(int mouseX, int mouseY) {
EntityPlayer player = Proxies.common.getPlayer();
ItemStack itemStack = getItemStack();
ToolTip tip = new ToolTip();
@@ -10,61 +10,10 @@
******************************************************************************/
package forestry.core.gui.widgets;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
public class ReservoirWidget extends TankWidget {
public ReservoirWidget(WidgetManager manager, int xPos, int yPos, int slot) {
super(manager, xPos, yPos, slot);
this.height = 16;
}
@Override
public void draw(int startX, int startY) {
FluidStack contents = getTank().getFluid();
if (contents == null || contents.amount <= 0 || contents.getFluid() == null) {
return;
}
IIcon liquidIcon = contents.getFluid().getIcon(contents);
if (liquidIcon == null) {
return;
}
int squaled = (contents.amount * height) / getTank().getCapacity();
if (squaled > height) {
squaled = height;
}
Proxies.render.bindTexture(SpriteSheet.BLOCKS);
int start = 0;
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
while (true) {
int x;
if (squaled > 16) {
x = 16;
squaled -= 16;
} else {
x = squaled;
squaled = 0;
}
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos + height - x - start, liquidIcon, 16, 16 - (16 - x));
start = start + 16;
if (x == 0 || squaled == 0) {
break;
}
}
this.drawOverlay = false;
}
}
@@ -45,7 +45,7 @@ public class SocketWidget extends Widget {
}
@Override
public ToolTip getToolTip() {
public ToolTip getToolTip(int mouseX, int mouseY) {
return toolTip;
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.core.gui.widgets;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -36,6 +37,7 @@ public class TankWidget extends Widget {
private int overlayTexX = 176;
private int overlayTexY = 0;
private int slot = 0;
protected boolean drawOverlay = true;
public TankWidget(WidgetManager manager, int xPos, int yPos, int slot) {
super(manager, xPos, yPos);
@@ -62,7 +64,7 @@ public class TankWidget extends Widget {
@Override
public void draw(int startX, int startY) {
IFluidTank tank = getTank();
if (tank == null) {
if (tank == null || tank.getCapacity() <= 0) {
return;
}
@@ -70,44 +72,49 @@ public class TankWidget extends Widget {
if (contents == null || contents.amount <= 0 || contents.getFluid() == null) {
return;
}
IIcon liquidIcon = contents.getFluid().getIcon(contents);
if (liquidIcon == null) {
return;
}
int squaled = (contents.amount * height) / getTank().getCapacity();
Proxies.render.bindTexture(SpriteSheet.BLOCKS);
int start = 0;
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
while (true) {
int x;
if (squaled > 16) {
x = 16;
squaled -= 16;
} else {
x = squaled;
squaled = 0;
}
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos + height - x - start, liquidIcon, 16, 16 - (16 - x));
start = start + 16;
if (x == 0 || squaled == 0) {
break;
}
int scaledLiquid = (contents.amount * height) / tank.getCapacity();
if (scaledLiquid > height) {
scaledLiquid = height;
}
Proxies.render.bindTexture(manager.gui.textureFile);
manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, overlayTexX, overlayTexY, 16, 60);
Proxies.render.bindTexture(SpriteSheet.BLOCKS);
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
{
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
int start = 0;
while (scaledLiquid > 0) {
int x;
if (scaledLiquid > 16) {
x = 16;
scaledLiquid -= 16;
} else {
x = scaledLiquid;
scaledLiquid = 0;
}
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos + height - x - start, liquidIcon, 16, x);
start += 16;
}
if (drawOverlay) {
Proxies.render.bindTexture(manager.gui.textureFile);
manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, overlayTexX, overlayTexY, 16, 60);
}
}
GL11.glPopAttrib();
}
@Override
public ToolTip getToolTip() {
public ToolTip getToolTip(int mouseX, int mouseY) {
IFluidTank tank = getTank();
if (!(tank instanceof StandardTank)) {
return null;
@@ -117,14 +124,16 @@ public class TankWidget extends Widget {
@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
ItemStack itemstack = manager.minecraft.thePlayer.inventory.getItemStack();
EntityPlayer player = manager.minecraft.thePlayer;
ItemStack itemstack = player.inventory.getItemStack();
if (itemstack == null) {
return;
}
Item held = itemstack.getItem();
if (held instanceof IToolPipette && manager.gui.inventorySlots instanceof IContainerLiquidTanks) {
((IContainerLiquidTanks) manager.gui.inventorySlots).handlePipetteClickClient(slot, manager.minecraft.thePlayer);
Container container = manager.gui.inventorySlots;
if (held instanceof IToolPipette && container instanceof IContainerLiquidTanks) {
((IContainerLiquidTanks) container).handlePipetteClickClient(slot, player);
}
}
}
@@ -20,10 +20,9 @@ import forestry.core.proxy.Proxies;
* Basic non-ItemStack slot
*/
public abstract class Widget implements IToolTipProvider {
protected final WidgetManager manager;
protected int xPos;
protected int yPos;
protected final int xPos;
protected final int yPos;
protected int width = 16;
protected int height = 16;
@@ -44,7 +43,7 @@ public abstract class Widget implements IToolTipProvider {
public abstract void draw(int startX, int startY);
@Override
public ToolTip getToolTip() {
public ToolTip getToolTip(int mouseX, int mouseY) {
String line = getLegacyTooltip(Proxies.common.getClientInstance().thePlayer);
if (line != null && !line.isEmpty()) {
ToolTip tip = new ToolTip();
@@ -169,7 +169,6 @@ public class RenderCrateItem implements IItemRenderer {
}
private void renderIn3D(ItemStack stack) {
GL11.glPushMatrix();
Tessellator tessellator = Tessellator.instance;
if (RenderManager.instance.renderEngine == null) {
return;
@@ -205,37 +204,45 @@ public class RenderCrateItem implements IItemRenderer {
ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), PIXEL);
if (stack.hasEffect(pass)) {
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
RenderManager.instance.renderEngine.bindTexture(GLINT_TEXTURE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
float f13 = 0.76F;
GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
float f14 = 0.125F;
GL11.glScalef(f14, f14, f14);
float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
GL11.glTranslatef(f15, 0.0F, 0.0F);
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, PIXEL);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glScalef(f14, f14, f14);
f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
GL11.glTranslatef(-f15, 0.0F, 0.0F);
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, PIXEL);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
{
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
RenderManager.instance.renderEngine.bindTexture(GLINT_TEXTURE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
float f13 = 0.76F;
float f14 = 0.125F;
float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
{
GL11.glScalef(f14, f14, f14);
GL11.glTranslatef(f15, 0.0F, 0.0F);
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, PIXEL);
}
GL11.glPopMatrix();
GL11.glPushMatrix();
{
GL11.glScalef(f14, f14, f14);
f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
GL11.glTranslatef(-f15, 0.0F, 0.0F);
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, PIXEL);
}
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
GL11.glPopAttrib();
}
}
GL11.glPopMatrix();
}
private void renderAsEntityFlat(ItemStack stack) {
@@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
import forestry.api.core.INBTTagable;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IIndividual;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamable;
@@ -99,7 +100,8 @@ public class EscritoireGameToken implements INBTTagable, IStreamable {
return 0xffffff;
}
int iconColor = AlleleManager.alleleRegistry.getIndividual(tokenStack).getGenome().getPrimary().getIconColour(0);
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(tokenStack);
int iconColor = individual.getGenome().getPrimary().getIconColour(0);
if (state == State.MATCHED) {
return ColourUtil.multiplyRGBComponents(iconColor, 0.7f);
@@ -10,112 +10,32 @@
******************************************************************************/
package forestry.energy.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import forestry.core.config.Constants;
import forestry.core.gui.widgets.TankWidget;
import forestry.core.gui.widgets.Widget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.utils.StringUtil;
import forestry.energy.gui.widgets.BiogasSlot;
import forestry.energy.tiles.TileEngineBiogas;
public class GuiEngineBiogas extends GuiEngine<ContainerEngineBiogas, TileEngineBiogas> {
protected class BiogasSlot extends Widget {
public BiogasSlot(WidgetManager manager, int xPos, int yPos) {
super(manager, xPos, yPos);
this.height = 16;
}
@Override
public void draw(int startX, int startY) {
if (inventory == null || inventory.getTotalTime() <= 0) {
return;
}
Fluid fluid = FluidRegistry.getFluid(inventory.getCurrentFluidId());
if (fluid == null) {
return;
}
IIcon liquidIcon = fluid.getIcon();
if (liquidIcon == null) {
return;
}
int squaled = (inventory.getBurnTime() * height) / inventory.getTotalTime();
if (squaled > height) {
squaled = height;
}
Proxies.render.bindTexture(SpriteSheet.BLOCKS);
int start = 0;
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
while (true) {
int x;
if (squaled > 16) {
x = 16;
squaled -= 16;
} else {
x = squaled;
squaled = 0;
}
// drawTexturedModalRect(startX + xPos, startY + yPos + height - x - start, imgColumn * 16, imgLine * 16, 16, 16 - (16 - x));
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos + height - x - start, liquidIcon, 16, 16 - (16 - x));
start = start + 16;
if (x == 0 || squaled == 0) {
break;
}
}
Proxies.render.bindTexture(textureFile);
}
@Override
public String getLegacyTooltip(EntityPlayer player) {
Fluid fluid = FluidRegistry.getFluid(inventory.getCurrentFluidId());
if (fluid == null) {
return StringUtil.localize("gui.empty");
}
return fluid.getLocalizedName(new FluidStack(fluid, 1));
}
}
public GuiEngineBiogas(InventoryPlayer inventory, TileEngineBiogas tile) {
super(Constants.TEXTURE_PATH_GUI + "/bioengine.png", new ContainerEngineBiogas(inventory, tile), tile);
widgetManager.add(new TankWidget(this.widgetManager, 89, 19, 0));
widgetManager.add(new TankWidget(this.widgetManager, 107, 19, 1));
widgetManager.add(new TankWidget(widgetManager, 89, 19, 0));
widgetManager.add(new TankWidget(widgetManager, 107, 19, 1));
widgetManager.add(new BiogasSlot(this.widgetManager, 30, 47));
widgetManager.add(new BiogasSlot(widgetManager, 30, 47, 2));
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
int temp = inventory.getOperatingTemperatureScaled(16);
if (temp > 16) {
temp = 16;
int temperature = inventory.getOperatingTemperatureScaled(16);
if (temperature > 16) {
temperature = 16;
}
if (temp > 0) {
drawTexturedModalRect(guiLeft + 53, guiTop + 47 + 16 - temp, 176, 60 + 16 - temp, 4, temp);
if (temperature > 0) {
drawTexturedModalRect(guiLeft + 53, guiTop + 47 + 16 - temperature, 176, 60 + 16 - temperature, 4, temperature);
}
}
}
@@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.energy.gui.widgets;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.gui.widgets.ReservoirWidget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.utils.StringUtil;
public class BiogasSlot extends ReservoirWidget {
public BiogasSlot(WidgetManager manager, int xPos, int yPos, int slot) {
super(manager, xPos, yPos, slot);
}
@Override
public ToolTip getToolTip(int mouseX, int mouseY) {
IFluidTank tank = getTank();
ToolTip toolTip = new ToolTip();
FluidStack fluid = tank.getFluid();
if (fluid == null) {
toolTip.add(StringUtil.localize("gui.empty"));
} else {
toolTip.add(fluid.getLocalizedName());
}
return toolTip;
}
@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
// do not allow pipette
}
}
@@ -44,11 +44,9 @@ import forestry.energy.inventory.InventoryEngineBiogas;
public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILiquidTankTile, IFluidHandler {
private final FilteredTank fuelTank;
private final FilteredTank heatingTank;
private final StandardTank burnTank;
private final TankManager tankManager;
private int burnTime;
private int totalTime;
private int currentFluidId = -1;
private boolean shutdown; // true if the engine is too cold and needs to warm itself up.
public TileEngineBiogas() {
@@ -60,19 +58,9 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
fuelTank.tankMode = StandardTank.TankMode.DEFAULT;
heatingTank = new FilteredTank(Constants.ENGINE_TANK_CAPACITY, FluidRegistry.LAVA);
heatingTank.tankMode = StandardTank.TankMode.INPUT;
this.tankManager = new TankManager(this, fuelTank, heatingTank);
}
public int getBurnTime() {
return burnTime;
}
public int getTotalTime() {
return totalTime;
}
public int getCurrentFluidId() {
return currentFluidId;
burnTank = new StandardTank(Constants.BUCKET_VOLUME);
burnTank.tankMode = StandardTank.TankMode.INTERNAL;
this.tankManager = new TankManager(this, fuelTank, heatingTank, burnTank);
}
@Override
@@ -80,6 +68,10 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
return tankManager;
}
public Fluid getBurnTankFluidType() {
return burnTank.getFluidType();
}
@Override
public void updateServerSide() {
super.updateServerSide();
@@ -95,7 +87,7 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
boolean hasHeat = getHeatLevel() > 0.2 || heatingTank.getFluidAmount() > 0;
errorLogic.setCondition(!hasHeat, EnumErrorCode.NO_HEAT);
boolean hasFuel = burnTime > 0 || fuelTank.getFluidAmount() > 0;
boolean hasFuel = burnTank.getFluidAmount() > 0 || fuelTank.getFluidAmount() > 0;
errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL);
}
@@ -107,7 +99,7 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
currentOutput = 0;
if (isRedstoneActivated() && (fuelTank.getFluidAmount() >= Constants.BUCKET_VOLUME || burnTime > 0)) {
if (isRedstoneActivated() && (fuelTank.getFluidAmount() >= Constants.BUCKET_VOLUME || burnTank.getFluidAmount() > 0)) {
double heatStage = getHeatLevel();
@@ -124,26 +116,22 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
}
// We need a minimum temperature to generate energy
if (heatStage > 0.2)
{
if (burnTime > 0) {
burnTime--;
currentOutput = determineFuelValue(FluidRegistry.getFluid(currentFluidId));
if (heatStage > 0.2) {
if (burnTank.getFluidAmount() > 0) {
FluidStack drained = burnTank.drain(1, true);
currentOutput = determineFuelValue(drained.getFluid());
energyManager.generateEnergy(currentOutput);
} else {
burnTime = totalTime = determineBurnTime(fuelTank.getFluid().getFluid());
currentFluidId = fuelTank.getFluid().getFluid().getID();
fuelTank.drain(Constants.BUCKET_VOLUME, true);
FluidStack fuel = fuelTank.drain(Constants.BUCKET_VOLUME, true);
int burnTime = determineBurnTime(fuel.getFluid());
fuel.amount = burnTime;
burnTank.setCapacity(burnTime);
burnTank.setFluid(fuel);
}
} else {
shutdown(true);
}
}
if (burnTime <= 0) {
currentFluidId = -1;
}
}
private void shutdown(boolean val) {
@@ -185,7 +173,7 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
int generate = 0;
if (isRedstoneActivated() && burnTime > 0) {
if (isRedstoneActivated() && burnTank.getFluidAmount() > 0) {
double heatStage = getHeatLevel();
if (heatStage >= 0.75) {
generate += Constants.ENGINE_BRONZE_HEAT_GENERATION_ENERGY * 3;
@@ -226,16 +214,16 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
// / STATE INFORMATION
@Override
protected boolean isBurning() {
return mayBurn() && burnTime > 0;
return mayBurn() && burnTank.getFluidAmount() > 0;
}
@Override
public int getBurnTimeRemainingScaled(int i) {
if (totalTime == 0) {
if (burnTank.getCapacity() == 0) {
return 0;
}
return (burnTime * i) / totalTime;
return (burnTank.getFluidAmount() * i) / burnTank.getCapacity();
}
public int getOperatingTemperatureScaled(int i) {
@@ -246,32 +234,29 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
burnTime = nbt.getInteger("EngineBurnTime");
totalTime = nbt.getInteger("EngineTotalTime");
if (nbt.hasKey("currentFluid")) {
Fluid fluid = FluidRegistry.getFluid(nbt.getString("currentFluid"));
if (fluid != null) {
currentFluidId = fluid.getID();
//legacy
{
if (nbt.hasKey("currentFluid")) {
Fluid fluid = FluidRegistry.getFluid(nbt.getString("currentFluid"));
if (fluid != null) {
int burnTime = nbt.getInteger("EngineBurnTime");
int totalTime = nbt.getInteger("EngineTotalTime");
burnTank.setCapacity(totalTime);
burnTank.setFluid(new FluidStack(fluid, burnTime));
}
}
}
if (nbt.hasKey("shutdown")) {
shutdown = nbt.getBoolean("shutdown");
}
tankManager.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("EngineBurnTime", burnTime);
nbt.setInteger("EngineTotalTime", totalTime);
Fluid fluid = FluidRegistry.getFluid(currentFluidId);
if (fluid != null) {
nbt.setString("currentFluid", fluid.getName());
}
nbt.setBoolean("shutdown", shutdown);
tankManager.writeToNBT(nbt);
}
@@ -295,34 +280,26 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
public void getGUINetworkData(int id, int data) {
switch (id) {
case 0:
burnTime = data;
break;
case 1:
totalTime = data;
break;
case 2:
currentOutput = data;
break;
case 3:
case 1:
energyManager.fromGuiInt(data);
break;
case 4:
case 2:
heat = data;
break;
case 5:
currentFluidId = data;
case 3:
burnTank.setCapacity(data);
break;
}
}
@Override
public void sendGUINetworkData(Container containerEngine, ICrafting iCrafting) {
iCrafting.sendProgressBarUpdate(containerEngine, 0, burnTime);
iCrafting.sendProgressBarUpdate(containerEngine, 1, totalTime);
iCrafting.sendProgressBarUpdate(containerEngine, 2, currentOutput);
iCrafting.sendProgressBarUpdate(containerEngine, 3, energyManager.toGuiInt());
iCrafting.sendProgressBarUpdate(containerEngine, 4, heat);
iCrafting.sendProgressBarUpdate(containerEngine, 5, currentFluidId);
iCrafting.sendProgressBarUpdate(containerEngine, 0, currentOutput);
iCrafting.sendProgressBarUpdate(containerEngine, 1, energyManager.toGuiInt());
iCrafting.sendProgressBarUpdate(containerEngine, 2, heat);
iCrafting.sendProgressBarUpdate(containerEngine, 3, burnTank.getCapacity());
}
// IFluidHandler
@@ -11,22 +11,15 @@
package forestry.farming.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import org.lwjgl.opengl.GL11;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmLogic;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.gui.ledgers.ClimateLedger;
import forestry.core.gui.ledgers.OwnerLedger;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.gui.widgets.SocketWidget;
import forestry.core.gui.widgets.TankWidget;
import forestry.core.gui.widgets.Widget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.farming.gui.widgets.FarmLogicSlot;
import forestry.farming.multiblock.IFarmControllerInternal;
import forestry.farming.tiles.TileFarm;
@@ -39,10 +32,12 @@ public class GuiFarm extends GuiForestryTitled<ContainerFarm, TileFarm> {
widgetManager.add(new SocketWidget(widgetManager, 69, 40, tile, 0));
widgetManager.add(new FarmLogicSlot(widgetManager, 69, 22, FarmDirection.NORTH));
widgetManager.add(new FarmLogicSlot(widgetManager, 69, 58, FarmDirection.SOUTH));
widgetManager.add(new FarmLogicSlot(widgetManager, 51, 40, FarmDirection.WEST));
widgetManager.add(new FarmLogicSlot(widgetManager, 87, 40, FarmDirection.EAST));
IFarmControllerInternal farmController = inventory.getMultiblockLogic().getController();
widgetManager.add(new FarmLogicSlot(farmController, widgetManager, 69, 22, FarmDirection.NORTH));
widgetManager.add(new FarmLogicSlot(farmController, widgetManager, 69, 58, FarmDirection.SOUTH));
widgetManager.add(new FarmLogicSlot(farmController, widgetManager, 51, 40, FarmDirection.WEST));
widgetManager.add(new FarmLogicSlot(farmController, widgetManager, 87, 40, FarmDirection.EAST));
this.xSize = 216;
this.ySize = 220;
@@ -68,58 +63,4 @@ public class GuiFarm extends GuiForestryTitled<ContainerFarm, TileFarm> {
}
}
private class FarmLogicSlot extends Widget {
private final FarmDirection farmDirection;
public FarmLogicSlot(WidgetManager manager, int xPos, int yPos, FarmDirection farmDirection) {
super(manager, xPos, yPos);
this.farmDirection = farmDirection;
}
private IFarmLogic getLogic() {
return inventory.getMultiblockLogic().getController().getFarmLogic(farmDirection);
}
private IIcon getIconIndex() {
if (getLogic() == null) {
return null;
}
return getLogic().getIcon();
}
@Override
public void draw(int startX, int startY) {
if (getLogic() == null) {
return;
}
if (getIconIndex() != null) {
GL11.glDisable(GL11.GL_LIGHTING);
Proxies.render.bindTexture(getLogic().getSpriteSheet());
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIconIndex(), 16, 16);
GL11.glEnable(GL11.GL_LIGHTING);
}
}
@Override
public ToolTip getToolTip() {
return toolTip;
}
protected final ToolTip toolTip = new ToolTip(250) {
@Override
public void refresh() {
toolTip.clear();
if (getLogic() == null) {
return;
}
toolTip.add(getLogic().getName());
toolTip.add("Fertilizer: " + getLogic().getFertilizerConsumption());
toolTip.add("Water: " + getLogic().getWaterConsumption(inventory.getMultiblockLogic().getController().getFarmLedgerDelegate().getHydrationModifier()));
}
};
}
}
@@ -0,0 +1,74 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.farming.gui.widgets;
import net.minecraft.util.IIcon;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmLogic;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.gui.widgets.Widget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.farming.multiblock.IFarmControllerInternal;
public class FarmLogicSlot extends Widget {
private final IFarmControllerInternal farmController;
private final FarmDirection farmDirection;
public FarmLogicSlot(IFarmControllerInternal farmController, WidgetManager manager, int xPos, int yPos, FarmDirection farmDirection) {
super(manager, xPos, yPos);
this.farmController = farmController;
this.farmDirection = farmDirection;
}
private IFarmLogic getLogic() {
return farmController.getFarmLogic(farmDirection);
}
private IIcon getIconIndex() {
if (getLogic() == null) {
return null;
}
return getLogic().getIcon();
}
@Override
public void draw(int startX, int startY) {
if (getIconIndex() != null) {
Proxies.render.bindTexture(getLogic().getSpriteSheet());
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIconIndex(), 16, 16);
}
}
@Override
public ToolTip getToolTip(int mouseX, int mouseY) {
if (isMouseOver(mouseX, mouseY)) {
return toolTip;
} else {
return null;
}
}
protected final ToolTip toolTip = new ToolTip(250) {
@Override
public void refresh() {
toolTip.clear();
if (getLogic() == null) {
return;
}
toolTip.add(getLogic().getName());
toolTip.add("Fertilizer: " + getLogic().getFertilizerConsumption());
toolTip.add("Water: " + getLogic().getWaterConsumption(farmController.getFarmLedgerDelegate().getHydrationModifier()));
}
};
}
+3 -38
View File
@@ -22,8 +22,6 @@ import org.lwjgl.opengl.GL11;
import forestry.api.mail.EnumAddressee;
import forestry.api.mail.IMailAddress;
import forestry.api.mail.IPostalCarrier;
import forestry.api.mail.PostManager;
import forestry.core.config.Constants;
import forestry.core.config.SessionVars;
import forestry.core.gui.GuiForestry;
@@ -31,8 +29,8 @@ import forestry.core.gui.GuiTextBox;
import forestry.core.gui.widgets.ItemStackWidget;
import forestry.core.gui.widgets.Widget;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.utils.StringUtil;
import forestry.mail.gui.widgets.AddresseeSlot;
import forestry.mail.inventory.ItemInventoryLetter;
import forestry.mail.network.PacketLetterInfoRequest;
@@ -55,7 +53,7 @@ public class GuiLetter extends GuiForestry<ContainerLetter, ItemInventoryLetter>
this.ySize = 227;
this.isProcessedLetter = container.getLetter().isProcessed();
this.widgetManager.add(new AddresseeSlot(16, 12));
this.widgetManager.add(new AddresseeSlot(widgetManager, 16, 12, container));
this.tradeInfoWidgets = new ArrayList<>();
}
@@ -181,9 +179,8 @@ public class GuiLetter extends GuiForestry<ContainerLetter, ItemInventoryLetter>
addTradeInfoWidget(new ItemStackWidget(widgetManager, x, y + 10, container.getTradeInfo().tradegood));
GL11.glDisable(GL11.GL_LIGHTING);
fontRendererObj.drawString(StringUtil.localize("gui.mail.foreveryattached"), guiLeft + x, guiTop + y + 28, fontColor.get("gui.mail.lettertext"));
GL11.glEnable(GL11.GL_LIGHTING);
for (int i = 0; i < container.getTradeInfo().required.length; i++) {
addTradeInfoWidget(new ItemStackWidget(widgetManager, x + i * 18, y + 38, container.getTradeInfo().required[i]));
}
@@ -252,36 +249,4 @@ public class GuiLetter extends GuiForestry<ContainerLetter, ItemInventoryLetter>
container.setText(this.text.getText());
}
protected class AddresseeSlot extends Widget {
public AddresseeSlot(int xPos, int yPos) {
super(widgetManager, xPos, yPos);
this.width = 26;
this.height = 15;
}
@Override
public void draw(int startX, int startY) {
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(container.getCarrierType());
if (carrier != null) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
Proxies.render.bindTexture(SpriteSheet.ITEMS);
drawTexturedModelRectFromIcon(startX + xPos, startY + yPos - 5, carrier.getIcon(), 26, 26);
}
}
@Override
protected String getLegacyTooltip(EntityPlayer player) {
return StringUtil.localize("gui.addressee." + container.getCarrierType().toString());
}
@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
if (!isProcessedLetter) {
container.advanceCarrierType();
}
}
}
}
@@ -11,6 +11,7 @@
package forestry.mail.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestry;
@@ -27,7 +28,7 @@ public class GuiTrader extends GuiForestry<ContainerTrader, TileTrader> {
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
String name = StringUtil.localizeTile(inventory.getUnlocalizedTitle());
String name = StatCollector.translateToLocal(inventory.getUnlocalizedTitle());
this.fontRendererObj.drawString(name, textLayout.getCenteredOffset(name), 6, fontColor.get("gui.mail.text"));
String receive = StringUtil.localize("gui.mail.receive");
@@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.mail.gui.widgets;
import net.minecraft.entity.player.EntityPlayer;
import org.lwjgl.opengl.GL11;
import forestry.api.mail.IPostalCarrier;
import forestry.api.mail.PostManager;
import forestry.core.gui.widgets.Widget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.utils.StringUtil;
import forestry.mail.gui.ContainerLetter;
public class AddresseeSlot extends Widget {
private final ContainerLetter containerLetter;
public AddresseeSlot(WidgetManager widgetManager, int xPos, int yPos, ContainerLetter containerLetter) {
super(widgetManager, xPos, yPos);
this.containerLetter = containerLetter;
this.width = 26;
this.height = 15;
}
@Override
public void draw(int startX, int startY) {
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(containerLetter.getCarrierType());
if (carrier != null) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
Proxies.render.bindTexture(SpriteSheet.ITEMS);
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos - 5, carrier.getIcon(), 26, 26);
}
}
@Override
protected String getLegacyTooltip(EntityPlayer player) {
return StringUtil.localize("gui.addressee." + containerLetter.getCarrierType().toString());
}
@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
if (!containerLetter.getLetter().isProcessed()) {
containerLetter.advanceCarrierType();
}
}
}