Move Forestry GUI icons to a new TextureMap

This commit is contained in:
mezz committed 2016-11-06 01:51:43 -08:00
1 parent d04713339c
commit 4c8d5e2f43
21 files changed
+347 -104

No files matched your search

@@ -6,7 +6,6 @@
package forestry.api.core;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -27,7 +26,10 @@ public interface IErrorState {
@SideOnly(Side.CLIENT)
void registerSprite();
@SideOnly(value = Side.CLIENT)
/**
* Sprite registered to the Gui Texture Map at {@link ITextureManager}
*/
@SideOnly(Side.CLIENT)
TextureAtlasSprite getSprite();
}
@@ -6,13 +6,29 @@
package forestry.api.core;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
/**
* Get the instance from {@link ForestryAPI#textureManager}.
*/
@SideOnly(Side.CLIENT)
public interface ITextureManager {
/**
* Location of the Forestry Gui Texture Map.
* Used for binding with {@link net.minecraft.client.renderer.texture.TextureManager#bindTexture(ResourceLocation)}
*/
ResourceLocation getGuiTextureMap();
/**
* Get a texture atlas sprite that has been registered by Forestry, for Forestry's Gui Texture Map.
*/
TextureAtlasSprite getDefault(String ident);
/**
* Register a sprite with Forestry's Gui Texture Map.
*/
TextureAtlasSprite registerGuiSprite(ResourceLocation location);
}
@@ -3,7 +3,7 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@API(apiVersion = "5.0.0", owner = "Forestry", provides = "ForestryAPI|core")
@API(apiVersion = "5.1.0", owner = "Forestry", provides = "ForestryAPI|core")
package forestry.api.core;
import net.minecraftforge.fml.common.API;
@@ -5,10 +5,10 @@
******************************************************************************/
package forestry.api.mail;
import forestry.api.core.ITextureManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -31,6 +31,10 @@ public interface IPostalCarrier {
*/
String getName();
/**
* Sprite registered to the Gui Texture Map at {@link ITextureManager}.
* Must be 26 pixels wide and 15 pixels tall. The texture itself must be 26x26 square to be accepted by the texture map.
*/
@SideOnly(Side.CLIENT)
TextureAtlasSprite getSprite();
@@ -3,7 +3,7 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@API(apiVersion = "3.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|mail")
@API(apiVersion = "3.1.0", owner = "ForestryAPI|core", provides = "ForestryAPI|mail")
package forestry.api.mail;
import net.minecraftforge.fml.common.API;
@@ -70,7 +70,7 @@ public class HabitatSlot extends Widget {
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
}
Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Proxies.render.bindTexture(TextureManager.getInstance().getGuiTextureMap());
manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, getIcon(), 16, 16);
}
}
@@ -5,16 +5,14 @@
******************************************************************************/
package forestry.core.errors;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorState;
import forestry.core.config.Constants;
import forestry.core.render.TextureManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public enum EnumErrorCode implements IErrorState {
@@ -112,7 +110,8 @@ public enum EnumErrorCode implements IErrorState {
@SideOnly(Side.CLIENT)
@Override
public void registerSprite() {
texture = TextureManager.registerSprite(new ResourceLocation(Constants.MOD_ID, "gui/errors/" + iconName));
ResourceLocation location = new ResourceLocation(Constants.MOD_ID, "gui/errors/" + iconName);
texture = TextureManager.getInstance().registerGuiSprite(location);
}
@SideOnly(Side.CLIENT)
@@ -13,18 +13,17 @@ package forestry.core.gui.ledgers;
import java.awt.Rectangle;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.ResourceLocation;
import forestry.core.config.Config;
import forestry.core.config.Constants;
import forestry.core.config.SessionVars;
import forestry.core.gui.GuiForestry;
import forestry.core.proxy.Proxies;
import forestry.core.render.ForestryResource;
import forestry.core.render.TextureManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
/**
* Side ledger for guis
@@ -214,9 +213,13 @@ public abstract class Ledger {
}
protected void drawSprite(TextureAtlasSprite sprite, int x, int y) {
drawSprite(TextureManager.getInstance().getGuiTextureMap(), sprite, x, y);
}
protected void drawSprite(ResourceLocation textureMap, TextureAtlasSprite sprite, int x, int y) {
if (sprite != null) {
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0F);
Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Proxies.render.bindTexture(textureMap);
manager.gui.drawTexturedModalRect(x, y, sprite, 16, 16);
}
}
@@ -10,14 +10,14 @@
******************************************************************************/
package forestry.core.gui.slots;
import forestry.core.gui.tooltips.IToolTipProvider;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.render.TextureManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import forestry.core.gui.tooltips.IToolTipProvider;
import forestry.core.gui.tooltips.ToolTip;
public class SlotForestry extends Slot implements IToolTipProvider {
private boolean isPhantom;
@@ -31,6 +31,7 @@ public class SlotForestry extends Slot implements IToolTipProvider {
if (inventory == null) {
throw new IllegalArgumentException("Inventory must not be null");
}
setBackgroundLocation(TextureManager.getInstance().getGuiTextureMap());
this.stackLimit = -1;
}
@@ -10,12 +10,6 @@
******************************************************************************/
package forestry.core.gui.widgets;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import forestry.core.gui.GuiUtil;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.network.packets.PacketGuiSelectRequest;
@@ -23,6 +17,10 @@ import forestry.core.proxy.Proxies;
import forestry.core.render.TextureManager;
import forestry.core.tiles.EscritoireGame;
import forestry.core.tiles.EscritoireGameToken;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
public class GameTokenWidget extends Widget {
private final ItemStack HIDDEN_TOKEN = new ItemStack(Items.BOOK);
@@ -70,8 +68,9 @@ public class GameTokenWidget extends Widget {
GlStateManager.disableDepth();
for (String ident : getToken().getOverlayIcons()) {
Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
TextureAtlasSprite icon = TextureManager.getInstance().getDefault(ident);
TextureManager textureManager = TextureManager.getInstance();
Proxies.render.bindTexture(textureManager.getGuiTextureMap());
TextureAtlasSprite icon = textureManager.getDefault(ident);
manager.gui.drawTexturedModalRect(startX + xPos + 3, startY + yPos + 3, icon, 16, 16);
}
GlStateManager.enableDepth();
@@ -10,39 +10,10 @@
******************************************************************************/
package forestry.core.proxy;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.animation.ITimeValue;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import com.google.common.collect.ImmutableMap;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IHiveTile;
@@ -66,12 +37,40 @@ import forestry.core.render.RenderEscritoire;
import forestry.core.render.RenderMachine;
import forestry.core.render.RenderMill;
import forestry.core.render.RenderNaturalistChest;
import forestry.core.render.TextureManager;
import forestry.core.render.TextureMapForestry;
import forestry.core.tiles.TileAnalyzer;
import forestry.core.tiles.TileBase;
import forestry.core.tiles.TileEscritoire;
import forestry.core.tiles.TileMill;
import forestry.core.tiles.TileNaturalistChest;
import forestry.core.utils.VectUtil;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.animation.ITimeValue;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
public class ProxyRenderClient extends ProxyRender {
@@ -85,6 +84,15 @@ public class ProxyRenderClient extends ProxyRender {
return true;
}
@Override
public void initRendering() {
TextureManager textureManager = TextureManager.getInstance();
TextureMapForestry textureMap = textureManager.getTextureMap();
Minecraft minecraft = Minecraft.getMinecraft();
minecraft.renderEngine.loadTickableTexture(TextureManager.getInstance().getGuiTextureMap(), textureMap);
}
@Override
public TileEntitySpecialRenderer<TileBase> getRenderDefaultMachine(String gfxBase) {
if (gfxBase == null) {
@@ -11,31 +11,27 @@
package forestry.core.render;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ISpriteRegister;
import forestry.api.core.ITextureManager;
import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class TextureManager implements ITextureManager {
public static final ResourceLocation LOCATION_FORESTRY_TEXTURE = new ResourceLocation("textures/atlas/forestry.png");
private static final TextureManager INSTANCE = new TextureManager();
private static final Map<String, TextureAtlasSprite> defaultIcons = new HashMap<>();
private final List<ISpriteRegister> spriteRegisters = new ArrayList<>();
private final TextureMapForestry textureMap;
static {
ForestryAPI.textureManager = INSTANCE;
@@ -46,6 +42,11 @@ public class TextureManager implements ITextureManager {
}
private TextureManager() {
this.textureMap = new TextureMapForestry("textures");
}
public TextureMapForestry getTextureMap() {
return textureMap;
}
public static void initDefaultSprites() {
@@ -59,22 +60,36 @@ public class TextureManager implements ITextureManager {
"slots/blocked", "slots/blocked_2", "slots/liquid", "slots/container", "slots/locked",
"mail/carrier.player", "mail/carrier.trader"};
for (String identifier : defaultIconNames) {
ResourceLocation resourceLocation = new ResourceLocation(Constants.MOD_ID, "gui/" + identifier);
TextureAtlasSprite icon = registerSprite(resourceLocation);
defaultIcons.put(identifier, icon);
ResourceLocation resourceLocation = getForestryGuiLocation(identifier);
INSTANCE.registerGuiSprite(resourceLocation);
}
}
private static ResourceLocation getForestryGuiLocation(String identifier) {
return new ResourceLocation(Constants.MOD_ID, "gui/" + identifier);
}
public static TextureAtlasSprite registerSprite(ResourceLocation location) {
TextureMap textureMap = Proxies.common.getClientInstance().getTextureMapBlocks();
return textureMap.registerSprite(location);
}
@Override
public TextureAtlasSprite getDefault(String ident) {
return defaultIcons.get(ident);
public TextureAtlasSprite getDefault(String identifier) {
ResourceLocation resourceLocation = getForestryGuiLocation(identifier);
return getTextureMap().getAtlasSprite(resourceLocation.toString());
}
@Override
public ResourceLocation getGuiTextureMap() {
return LOCATION_FORESTRY_TEXTURE;
}
@Override
public TextureAtlasSprite registerGuiSprite(ResourceLocation location) {
return getTextureMap().registerSprite(location);
}
public void registerBlock(Block block) {
if (block instanceof ISpriteRegister) {
spriteRegisters.add((ISpriteRegister) block);
@@ -0,0 +1,187 @@
package forestry.core.render;
import javax.annotation.Nonnull;
import java.io.Closeable;
import java.io.IOException;
import java.util.Map;
import com.google.common.collect.Maps;
import forestry.core.utils.Log;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.PngSizeInfo;
import net.minecraft.client.renderer.texture.Stitcher;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.crash.ICrashReportDetail;
import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.ProgressManager;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.io.IOUtils;
@SideOnly(Side.CLIENT)
public class TextureMapForestry extends TextureMap {
private boolean skipFirst = true;
public TextureMapForestry(String basePathIn) {
super(basePathIn, null, true);
}
@Override
public void loadTexture(@Nonnull IResourceManager resourceManager) throws IOException {
this.initMissingImage();
this.deleteGlTexture();
this.loadTextureAtlas(resourceManager);
}
@Override
public void loadTextureAtlas(@Nonnull IResourceManager resourceManager) {
int i = Minecraft.getGLMaximumTextureSize();
Stitcher stitcher = new Stitcher(i, i, 0, 0);
this.mapUploadedSprites.clear();
this.listAnimatedSprites.clear();
ProgressManager.ProgressBar bar = ProgressManager.push("Texture stitching", skipFirst ? 0 : this.mapRegisteredSprites.size());
if (!skipFirst) {
for (Map.Entry<String, TextureAtlasSprite> entry : this.mapRegisteredSprites.entrySet()) {
TextureAtlasSprite textureatlassprite = entry.getValue();
ResourceLocation resourcelocation = this.getResourceLocation(textureatlassprite);
bar.step(resourcelocation.getResourcePath());
IResource iresource = null;
if (textureatlassprite.hasCustomLoader(resourceManager, resourcelocation)) {
if (textureatlassprite.load(resourceManager, resourcelocation)) {
continue;
}
} else
try {
PngSizeInfo pngsizeinfo = PngSizeInfo.makeFromResource(resourceManager.getResource(resourcelocation));
iresource = resourceManager.getResource(resourcelocation);
boolean flag = iresource.getMetadata("animation") != null;
textureatlassprite.loadSprite(pngsizeinfo, flag);
} catch (RuntimeException runtimeexception) {
FMLClientHandler.instance().trackBrokenTexture(resourcelocation, runtimeexception.getMessage());
continue;
} catch (IOException ioexception) {
FMLClientHandler.instance().trackMissingTexture(resourcelocation);
continue;
} finally {
IOUtils.closeQuietly(iresource);
}
stitcher.addSprite(textureatlassprite);
}
}
ProgressManager.pop(bar);
this.missingImage.generateMipmaps(0);
stitcher.addSprite(this.missingImage);
skipFirst = false;
bar = ProgressManager.push("Texture creation", 2);
bar.step("Stitching");
stitcher.doStitch();
Log.info("Created: {}x{} {}-atlas", stitcher.getCurrentWidth(), stitcher.getCurrentHeight(), this.basePath);
bar.step("Allocating GL texture");
TextureUtil.allocateTextureImpl(this.getGlTextureId(), 0, stitcher.getCurrentWidth(), stitcher.getCurrentHeight());
Map<String, TextureAtlasSprite> map = Maps.<String, TextureAtlasSprite>newHashMap(this.mapRegisteredSprites);
ProgressManager.pop(bar);
bar = ProgressManager.push("Texture mipmap and upload", stitcher.getStichSlots().size());
for (TextureAtlasSprite textureatlassprite1 : stitcher.getStichSlots()) {
bar.step(textureatlassprite1.getIconName());
if (textureatlassprite1 == this.missingImage || this.generateMipmaps(resourceManager, textureatlassprite1)) {
String s = textureatlassprite1.getIconName();
map.remove(s);
this.mapUploadedSprites.put(s, textureatlassprite1);
try {
TextureUtil.uploadTextureMipmap(textureatlassprite1.getFrameTextureData(0), textureatlassprite1.getIconWidth(), textureatlassprite1.getIconHeight(), textureatlassprite1.getOriginX(), textureatlassprite1.getOriginY(), false, false);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Stitching texture atlas");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Texture being stitched together");
crashreportcategory.addCrashSection("Atlas path", this.basePath);
crashreportcategory.addCrashSection("Sprite", textureatlassprite1);
throw new ReportedException(crashreport);
}
if (textureatlassprite1.hasAnimationMetadata()) {
this.listAnimatedSprites.add(textureatlassprite1);
}
}
}
for (TextureAtlasSprite textureatlassprite2 : map.values()) {
textureatlassprite2.copyFrom(this.missingImage);
}
ProgressManager.pop(bar);
}
private boolean generateMipmaps(IResourceManager resourceManager, final TextureAtlasSprite texture) {
ResourceLocation resourcelocation = this.getResourceLocation(texture);
IResource iresource = null;
label9:
{
boolean flag;
if (texture.hasCustomLoader(resourceManager, resourcelocation)) break label9;
try {
iresource = resourceManager.getResource(resourcelocation);
texture.loadSpriteFrames(iresource, 1);
break label9;
} catch (RuntimeException runtimeexception) {
Log.error("Unable to parse metadata from {}", resourcelocation, runtimeexception);
flag = false;
} catch (IOException ioexception) {
Log.error("Using missing texture, unable to load {}", resourcelocation, ioexception);
flag = false;
return flag;
} finally {
IOUtils.closeQuietly((Closeable) iresource);
}
return flag;
}
try {
texture.generateMipmaps(0);
return true;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Applying mipmap");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Sprite being mipmapped");
crashreportcategory.setDetail("Sprite name", new ICrashReportDetail<String>() {
public String call() throws Exception {
return texture.getIconName();
}
});
crashreportcategory.setDetail("Sprite size", new ICrashReportDetail<String>() {
public String call() throws Exception {
return texture.getIconWidth() + " x " + texture.getIconHeight();
}
});
crashreportcategory.setDetail("Sprite frames", new ICrashReportDetail<String>() {
public String call() throws Exception {
return texture.getFrameCount() + " frames";
}
});
crashreportcategory.addCrashSection("Mipmap levels", 0);
throw new ReportedException(crashreport);
}
}
private ResourceLocation getResourceLocation(TextureAtlasSprite p_184396_1_) {
ResourceLocation resourcelocation = new ResourceLocation(p_184396_1_.getIconName());
return new ResourceLocation(resourcelocation.getResourceDomain(), String.format("%s/%s%s", this.basePath, resourcelocation.getResourcePath(), ".png"));
}
}
@@ -10,17 +10,15 @@
******************************************************************************/
package forestry.factory.gui.widgets;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import forestry.core.gui.widgets.ItemStackWidgetBase;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.core.render.TextureManager;
import forestry.factory.gui.ContainerWorktable;
import forestry.factory.recipes.RecipeMemory;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
public class MemorizedRecipeSlot extends ItemStackWidgetBase {
private static final TextureAtlasSprite lockIcon = TextureManager.getInstance().getDefault("slots/locked");
@@ -45,7 +43,7 @@ public class MemorizedRecipeSlot extends ItemStackWidgetBase {
GlStateManager.disableDepth();
if (recipeMemory.isLocked(slotNumber)) {
Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Proxies.render.bindTexture(TextureManager.getInstance().getGuiTextureMap());
manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, lockIcon, 16, 16);
}
@@ -10,14 +10,14 @@
******************************************************************************/
package forestry.farming.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import forestry.core.gui.ledgers.Ledger;
import forestry.core.gui.ledgers.LedgerManager;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StringUtil;
import forestry.core.utils.Translator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
public class FarmLedger extends Ledger {
private final IFarmLedgerDelegate delegate;
@@ -45,8 +45,7 @@ public class FarmLedger extends Ledger {
Minecraft minecraft = Proxies.common.getClientInstance();
TextureMap textureMapBlocks = minecraft.getTextureMapBlocks();
TextureAtlasSprite textureAtlasSprite = textureMapBlocks.getAtlasSprite("minecraft:items/bucket_water");
drawSprite(textureAtlasSprite, xIcon, y);
drawSprite(TextureMap.LOCATION_BLOCKS_TEXTURE, textureAtlasSprite, xIcon, y);
y += 4;
if (!isFullyOpened()) {
@@ -10,6 +10,11 @@
******************************************************************************/
package forestry.mail.gui;
import forestry.core.config.Config;
import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import forestry.core.render.ForestryResource;
import forestry.mail.POBoxInfo;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.FontRenderer;
@@ -21,12 +26,6 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import forestry.core.config.Config;
import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import forestry.core.render.ForestryResource;
import forestry.mail.POBoxInfo;
public class GuiMailboxInfo extends Gui {
public enum XPosition {
@@ -43,6 +42,7 @@ public class GuiMailboxInfo extends Gui {
private final FontRenderer fontRendererObj;
private POBoxInfo poInfo;
// TODO: this texture is a terrible waste of space in graphics memory, find a better way to do it.
private final ResourceLocation textureAlert = new ForestryResource(Constants.TEXTURE_PATH_GUI + "/mailalert.png");
private GuiMailboxInfo() {
@@ -10,17 +10,16 @@
******************************************************************************/
package forestry.mail.gui.widgets;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureMap;
import forestry.api.mail.IPostalCarrier;
import forestry.api.mail.PostManager;
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.core.render.TextureManager;
import forestry.core.utils.Translator;
import forestry.mail.gui.ContainerLetter;
import net.minecraft.client.renderer.GlStateManager;
public class AddresseeSlot extends Widget {
@@ -38,8 +37,8 @@ public class AddresseeSlot extends Widget {
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(containerLetter.getCarrierType());
if (carrier != null) {
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0F);
Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, carrier.getSprite(), 32, 32);
Proxies.render.bindTexture(TextureManager.getInstance().getGuiTextureMap());
manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, carrier.getSprite(), 26, 26);
}
}