Fixes how several UIs draw their item slots.
This commit is contained in:
parent
928f623f7e
commit
fdd75ef3a8
|
@ -54,6 +54,7 @@ import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||||
|
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
|
@ -62,7 +63,7 @@ import appeng.client.gui.widgets.ITooltip;
|
||||||
import appeng.client.me.InternalSlotME;
|
import appeng.client.me.InternalSlotME;
|
||||||
import appeng.client.me.SlotDisconnected;
|
import appeng.client.me.SlotDisconnected;
|
||||||
import appeng.client.me.SlotME;
|
import appeng.client.me.SlotME;
|
||||||
import appeng.client.render.AppEngRenderItem;
|
import appeng.client.render.StackSizeRenderer;
|
||||||
import appeng.container.AEBaseContainer;
|
import appeng.container.AEBaseContainer;
|
||||||
import appeng.container.slot.AppEngCraftingSlot;
|
import appeng.container.slot.AppEngCraftingSlot;
|
||||||
import appeng.container.slot.AppEngSlot;
|
import appeng.container.slot.AppEngSlot;
|
||||||
|
@ -76,6 +77,7 @@ import appeng.container.slot.SlotOutput;
|
||||||
import appeng.container.slot.SlotPatternTerm;
|
import appeng.container.slot.SlotPatternTerm;
|
||||||
import appeng.container.slot.SlotRestrictedInput;
|
import appeng.container.slot.SlotRestrictedInput;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
|
import appeng.core.AppEng;
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
import appeng.core.sync.packets.PacketInventoryAction;
|
import appeng.core.sync.packets.PacketInventoryAction;
|
||||||
import appeng.core.sync.packets.PacketSwapSlots;
|
import appeng.core.sync.packets.PacketSwapSlots;
|
||||||
|
@ -91,7 +93,7 @@ public abstract class AEBaseGui extends GuiContainer
|
||||||
private final List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>();
|
private final List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>();
|
||||||
// drag y
|
// drag y
|
||||||
private final Set<Slot> drag_click = new HashSet<Slot>();
|
private final Set<Slot> drag_click = new HashSet<Slot>();
|
||||||
private final AppEngRenderItem aeRenderItem = new AppEngRenderItem( Minecraft.getMinecraft().renderEngine, Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager(), Minecraft.getMinecraft().getItemColors() );
|
private final StackSizeRenderer stackSizeRenderer = new StackSizeRenderer();
|
||||||
private GuiScrollbar myScrollBar = null;
|
private GuiScrollbar myScrollBar = null;
|
||||||
private boolean disableShiftClick = false;
|
private boolean disableShiftClick = false;
|
||||||
private Stopwatch dbl_clickTimer = Stopwatch.createStarted();
|
private Stopwatch dbl_clickTimer = Stopwatch.createStarted();
|
||||||
|
@ -215,12 +217,12 @@ public abstract class AEBaseGui extends GuiContainer
|
||||||
lines = Lists.newArrayList( lines ); // Make a copy
|
lines = Lists.newArrayList( lines ); // Make a copy
|
||||||
|
|
||||||
// Make the first line white
|
// Make the first line white
|
||||||
lines.set( 0, "\u00a7f" + lines.get( 0 ) );
|
lines.set( 0, TextFormatting.WHITE + lines.get( 0 ) );
|
||||||
|
|
||||||
// All lines after the first are colored gray
|
// All lines after the first are colored gray
|
||||||
for( int i = 1; i < lines.size(); i++ )
|
for( int i = 1; i < lines.size(); i++ )
|
||||||
{
|
{
|
||||||
lines.set(i, "\u00a77" + lines.get(i));
|
lines.set(i, TextFormatting.GRAY + lines.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.drawHoveringText( lines, x, y, fontRendererObj );
|
this.drawHoveringText( lines, x, y, fontRendererObj );
|
||||||
|
@ -699,11 +701,14 @@ public abstract class AEBaseGui extends GuiContainer
|
||||||
return ( (AEBaseContainer) this.inventorySlots ).getCustomName();
|
return ( (AEBaseContainer) this.inventorySlots ).getCustomName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawSlot( final Slot s )
|
/**
|
||||||
|
* This overrides the base-class method through some access transformer hackery...
|
||||||
|
*/
|
||||||
|
public void drawSlot( final Slot s )
|
||||||
{
|
{
|
||||||
if( s instanceof SlotME )
|
if( s instanceof SlotME )
|
||||||
{
|
{
|
||||||
final RenderItem pIR = this.setItemRender( this.aeRenderItem );
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.zLevel = 100.0F;
|
this.zLevel = 100.0F;
|
||||||
|
@ -719,15 +724,17 @@ public abstract class AEBaseGui extends GuiContainer
|
||||||
this.zLevel = 0.0F;
|
this.zLevel = 0.0F;
|
||||||
this.itemRender.zLevel = 0.0F;
|
this.itemRender.zLevel = 0.0F;
|
||||||
|
|
||||||
this.aeRenderItem.setAeStack( ( (SlotME) s ).getAEStack() );
|
// Annoying but easier than trying to splice into render item
|
||||||
|
this.safeDrawSlot( new Size1Slot( s ) );
|
||||||
|
|
||||||
|
stackSizeRenderer.renderStackSize( fontRendererObj, ( (SlotME) s ).getAEStack(), s.getStack(), s.xDisplayPosition, s.yDisplayPosition );
|
||||||
|
|
||||||
this.safeDrawSlot( s );
|
|
||||||
}
|
}
|
||||||
catch( final Exception err )
|
catch( final Exception err )
|
||||||
{
|
{
|
||||||
AELog.warn( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
AELog.warn( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
||||||
}
|
}
|
||||||
this.setItemRender( pIR );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -759,18 +766,18 @@ public abstract class AEBaseGui extends GuiContainer
|
||||||
final float par4 = uv_y * 16;
|
final float par4 = uv_y * 16;
|
||||||
|
|
||||||
final Tessellator tessellator = Tessellator.getInstance();
|
final Tessellator tessellator = Tessellator.getInstance();
|
||||||
final VertexBuffer VertexBuffer = tessellator.getBuffer();
|
final VertexBuffer vb = tessellator.getBuffer();
|
||||||
|
|
||||||
|
vb.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR );
|
||||||
|
|
||||||
VertexBuffer.begin( GL11.GL_QUADS, DefaultVertexFormats.ITEM );
|
|
||||||
;
|
|
||||||
final float f1 = 0.00390625F;
|
final float f1 = 0.00390625F;
|
||||||
final float f = 0.00390625F;
|
final float f = 0.00390625F;
|
||||||
final float par6 = 16;
|
final float par6 = 16;
|
||||||
VertexBuffer.color( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() ).pos( par1 + 0, par2 + par6, this.zLevel ).tex( ( par3 + 0 ) * f, ( par4 + par6 ) * f1 ).endVertex();
|
vb.pos( par1 + 0, par2 + par6, this.zLevel ).tex( ( par3 + 0 ) * f, ( par4 + par6 ) * f1 ).color( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() ).endVertex();
|
||||||
final float par5 = 16;
|
final float par5 = 16;
|
||||||
VertexBuffer.color( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() ).pos( par1 + par5, par2 + par6, this.zLevel ).tex( ( par3 + par5 ) * f, ( par4 + par6 ) * f1 ).endVertex();
|
vb.pos( par1 + par5, par2 + par6, this.zLevel ).tex( ( par3 + par5 ) * f, ( par4 + par6 ) * f1 ).color( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() ).endVertex();
|
||||||
VertexBuffer.color( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() ).pos( par1 + par5, par2 + 0, this.zLevel ).tex( ( par3 + par5 ) * f, ( par4 + 0 ) * f1 ).endVertex();
|
vb.pos( par1 + par5, par2 + 0, this.zLevel ).tex( ( par3 + par5 ) * f, ( par4 + 0 ) * f1 ).color( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() ).endVertex();
|
||||||
VertexBuffer.color( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() ).pos( par1 + 0, par2 + 0, this.zLevel ).tex( ( par3 + 0 ) * f, ( par4 + 0 ) * f1 ).endVertex();
|
vb.pos( par1 + 0, par2 + 0, this.zLevel ).tex( ( par3 + 0 ) * f, ( par4 + 0 ) * f1 ).color( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() ).endVertex();
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
}
|
}
|
||||||
catch( final Exception err )
|
catch( final Exception err )
|
||||||
|
@ -866,7 +873,7 @@ public abstract class AEBaseGui extends GuiContainer
|
||||||
|
|
||||||
public void bindTexture( final String file )
|
public void bindTexture( final String file )
|
||||||
{
|
{
|
||||||
final ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/" + file );
|
final ResourceLocation loc = new ResourceLocation( AppEng.MOD_ID, "textures/" + file );
|
||||||
this.mc.getTextureManager().bindTexture( loc );
|
this.mc.getTextureManager().bindTexture( loc );
|
||||||
}
|
}
|
||||||
protected GuiScrollbar getScrollBar()
|
protected GuiScrollbar getScrollBar()
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Locale;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.client.me.SlotME;
|
import appeng.client.me.SlotME;
|
||||||
|
@ -69,7 +70,7 @@ public abstract class AEBaseMEGui extends AEBaseGui
|
||||||
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() );
|
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() );
|
||||||
final String format = String.format( local, formattedAmount );
|
final String format = String.format( local, formattedAmount );
|
||||||
|
|
||||||
currentToolTip.add( "\u00a77" + format );
|
currentToolTip.add( TextFormatting.GRAY + format );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( myStack.getCountRequestable() > 0 )
|
if( myStack.getCountRequestable() > 0 )
|
||||||
|
@ -78,7 +79,7 @@ public abstract class AEBaseMEGui extends AEBaseGui
|
||||||
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() );
|
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() );
|
||||||
final String format = String.format( local, formattedAmount );
|
final String format = String.format( local, formattedAmount );
|
||||||
|
|
||||||
currentToolTip.add( "\u00a77" + format );
|
currentToolTip.add( TextFormatting.GRAY + format );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( stack.stackSize > BigNumber || ( stack.stackSize > 1 && stack.isItemDamaged() ) )
|
else if( stack.stackSize > BigNumber || ( stack.stackSize > 1 && stack.isItemDamaged() ) )
|
||||||
|
@ -87,7 +88,7 @@ public abstract class AEBaseMEGui extends AEBaseGui
|
||||||
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize );
|
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize );
|
||||||
final String format = String.format( local, formattedAmount );
|
final String format = String.format( local, formattedAmount );
|
||||||
|
|
||||||
currentToolTip.add( "\u00a77" + format );
|
currentToolTip.add( TextFormatting.GRAY + format );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
116
src/main/java/appeng/client/gui/Size1Slot.java
Normal file
116
src/main/java/appeng/client/gui/Size1Slot.java
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
package appeng.client.gui;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A proxy for a slot that will always return an itemstack with size 1, if there is an item in the slot.
|
||||||
|
* Used to prevent the default item count from rendering.
|
||||||
|
*/
|
||||||
|
class Size1Slot extends Slot
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Slot delegate;
|
||||||
|
|
||||||
|
public Size1Slot( Slot delegate )
|
||||||
|
{
|
||||||
|
super( delegate.inventory, delegate.getSlotIndex(), delegate.xDisplayPosition, delegate.yDisplayPosition );
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public ItemStack getStack()
|
||||||
|
{
|
||||||
|
ItemStack orgStack = delegate.getStack();
|
||||||
|
if( orgStack != null )
|
||||||
|
{
|
||||||
|
ItemStack modifiedStack = orgStack.copy();
|
||||||
|
modifiedStack.stackSize = 1;
|
||||||
|
return modifiedStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getHasStack()
|
||||||
|
{
|
||||||
|
return delegate.getHasStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isHere( IInventory inv, int slotIn )
|
||||||
|
{
|
||||||
|
return delegate.isHere( inv, slotIn );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlotStackLimit()
|
||||||
|
{
|
||||||
|
return delegate.getSlotStackLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemStackLimit( ItemStack stack )
|
||||||
|
{
|
||||||
|
return delegate.getItemStackLimit( stack );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
@SideOnly( Side.CLIENT)
|
||||||
|
public String getSlotTexture()
|
||||||
|
{
|
||||||
|
return delegate.getSlotTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canTakeStack( EntityPlayer playerIn )
|
||||||
|
{
|
||||||
|
return delegate.canTakeStack( playerIn );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly( Side.CLIENT)
|
||||||
|
public boolean canBeHovered()
|
||||||
|
{
|
||||||
|
return delegate.canBeHovered();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly( Side.CLIENT)
|
||||||
|
public ResourceLocation getBackgroundLocation()
|
||||||
|
{
|
||||||
|
return delegate.getBackgroundLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly( Side.CLIENT)
|
||||||
|
public TextureAtlasSprite getBackgroundSprite()
|
||||||
|
{
|
||||||
|
return delegate.getBackgroundSprite();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlotIndex()
|
||||||
|
{
|
||||||
|
return delegate.getSlotIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSameInventory( Slot other )
|
||||||
|
{
|
||||||
|
return delegate.isSameInventory( other );
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,169 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of Applied Energistics 2.
|
|
||||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
||||||
*
|
|
||||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package appeng.client.render;
|
|
||||||
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
import net.minecraft.client.renderer.RenderItem;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.client.renderer.VertexBuffer;
|
|
||||||
import net.minecraft.client.renderer.block.model.ModelManager;
|
|
||||||
import net.minecraft.client.renderer.color.ItemColors;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
|
||||||
import appeng.core.AEConfig;
|
|
||||||
import appeng.core.localization.GuiText;
|
|
||||||
import appeng.util.ISlimReadableNumberConverter;
|
|
||||||
import appeng.util.IWideReadableNumberConverter;
|
|
||||||
import appeng.util.ReadableNumberConverter;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author AlgorithmX2
|
|
||||||
* @author thatsIch
|
|
||||||
* @version rv2
|
|
||||||
* @since rv0
|
|
||||||
*/
|
|
||||||
public class AppEngRenderItem extends RenderItem
|
|
||||||
{
|
|
||||||
public AppEngRenderItem( final TextureManager textureManager, final ModelManager modelManager, final ItemColors itemColors )
|
|
||||||
{
|
|
||||||
super( textureManager, modelManager, itemColors );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
|
|
||||||
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
|
|
||||||
|
|
||||||
private IAEItemStack aeStack = null;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderItemOverlayIntoGUI( final FontRenderer fontRenderer, final ItemStack is, final int xPos, final int yPos, final String text )
|
|
||||||
{
|
|
||||||
if( is != null )
|
|
||||||
{
|
|
||||||
final float scaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f;
|
|
||||||
final float inverseScaleFactor = 1.0f / scaleFactor;
|
|
||||||
final int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1;
|
|
||||||
|
|
||||||
final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
|
|
||||||
fontRenderer.setUnicodeFlag( false );
|
|
||||||
|
|
||||||
if( is.getItem().showDurabilityBar( is ) )
|
|
||||||
{
|
|
||||||
final double health = is.getItem().getDurabilityForDisplay( is );
|
|
||||||
final int j1 = (int) Math.round( 13.0D - health * 13.0D );
|
|
||||||
final int k = (int) Math.round( 255.0D - health * 255.0D );
|
|
||||||
GL11.glDisable( GL11.GL_LIGHTING );
|
|
||||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
|
||||||
GL11.glDisable( GL11.GL_TEXTURE_2D );
|
|
||||||
GL11.glDisable( GL11.GL_ALPHA_TEST );
|
|
||||||
GL11.glDisable( GL11.GL_BLEND );
|
|
||||||
final Tessellator tessellator = Tessellator.getInstance();
|
|
||||||
final VertexBuffer wr = tessellator.getBuffer();
|
|
||||||
final int l = 255 - k << 16 | k << 8;
|
|
||||||
final int i1 = ( 255 - k ) / 4 << 16 | 16128;
|
|
||||||
this.renderQuad( tessellator, xPos + 2, yPos + 13, 13, 2, 0 );
|
|
||||||
this.renderQuad( tessellator, xPos + 2, yPos + 13, 12, 1, i1 );
|
|
||||||
this.renderQuad( tessellator, xPos + 2, yPos + 13, j1, 1, l );
|
|
||||||
GL11.glEnable( GL11.GL_ALPHA_TEST );
|
|
||||||
GL11.glEnable( GL11.GL_TEXTURE_2D );
|
|
||||||
GL11.glEnable( GL11.GL_LIGHTING );
|
|
||||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
|
||||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( is.stackSize == 0 )
|
|
||||||
{
|
|
||||||
final String craftLabelText = AEConfig.instance.useTerminalUseLargeFont() ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft.getLocal();
|
|
||||||
GL11.glDisable( GL11.GL_LIGHTING );
|
|
||||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glScaled( scaleFactor, scaleFactor, scaleFactor );
|
|
||||||
final int X = (int) ( ( (float) xPos + offset + 16.0f - fontRenderer.getStringWidth( craftLabelText ) * scaleFactor ) * inverseScaleFactor );
|
|
||||||
final int Y = (int) ( ( (float) yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
|
|
||||||
fontRenderer.drawStringWithShadow( craftLabelText, X, Y, 16777215 );
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
GL11.glEnable( GL11.GL_LIGHTING );
|
|
||||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
|
||||||
}
|
|
||||||
|
|
||||||
final long amount = this.aeStack != null ? this.aeStack.getStackSize() : is.stackSize;
|
|
||||||
if( amount != 0 )
|
|
||||||
{
|
|
||||||
final String stackSize = this.getToBeRenderedStackSize( amount );
|
|
||||||
|
|
||||||
GL11.glDisable( GL11.GL_LIGHTING );
|
|
||||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glScaled( scaleFactor, scaleFactor, scaleFactor );
|
|
||||||
final int X = (int) ( ( (float) xPos + offset + 16.0f - fontRenderer.getStringWidth( stackSize ) * scaleFactor ) * inverseScaleFactor );
|
|
||||||
final int Y = (int) ( ( (float) yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
|
|
||||||
fontRenderer.drawStringWithShadow( stackSize, X, Y, 16777215 );
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
GL11.glEnable( GL11.GL_LIGHTING );
|
|
||||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
|
||||||
}
|
|
||||||
|
|
||||||
fontRenderer.setUnicodeFlag( unicodeFlag );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderQuad( final Tessellator par1Tessellator, final int par2, final int par3, final int par4, final int par5, final int par6 )
|
|
||||||
{
|
|
||||||
final VertexBuffer wr = par1Tessellator.getBuffer();
|
|
||||||
|
|
||||||
wr.begin( GL11.GL_QUADS, DefaultVertexFormats.ITEM );
|
|
||||||
|
|
||||||
wr.color( ( par6 >> 16 ) & 0xff, ( par6 >> 8 ) & 0xff, ( par6 ) & 0xff, ( par6 >> 24 ) & 0xff ).pos( par2, par3, 0.0D ).endVertex();
|
|
||||||
wr.color( ( par6 >> 16 ) & 0xff, ( par6 >> 8 ) & 0xff, ( par6 ) & 0xff, ( par6 >> 24 ) & 0xff ).pos( par2, par3 + par5, 0.0D ).endVertex();
|
|
||||||
wr.color( ( par6 >> 16 ) & 0xff, ( par6 >> 8 ) & 0xff, ( par6 ) & 0xff, ( par6 >> 24 ) & 0xff ).pos( par2 + par4, par3 + par5, 0.0D ).endVertex();
|
|
||||||
wr.color( ( par6 >> 16 ) & 0xff, ( par6 >> 8 ) & 0xff, ( par6 ) & 0xff, ( par6 >> 24 ) & 0xff ).pos( par2 + par4, par3, 0.0D ).endVertex();
|
|
||||||
|
|
||||||
par1Tessellator.draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getToBeRenderedStackSize( final long originalSize )
|
|
||||||
{
|
|
||||||
if( AEConfig.instance.useTerminalUseLargeFont() )
|
|
||||||
{
|
|
||||||
return SLIM_CONVERTER.toSlimReadableForm( originalSize );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return WIDE_CONVERTER.toWideReadableForm( originalSize );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IAEItemStack getAeStack()
|
|
||||||
{
|
|
||||||
return this.aeStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAeStack( @Nonnull final IAEItemStack aeStack )
|
|
||||||
{
|
|
||||||
this.aeStack = aeStack;
|
|
||||||
}
|
|
||||||
}
|
|
110
src/main/java/appeng/client/render/StackSizeRenderer.java
Normal file
110
src/main/java/appeng/client/render/StackSizeRenderer.java
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Applied Energistics 2.
|
||||||
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||||
|
*
|
||||||
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package appeng.client.render;
|
||||||
|
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
|
import appeng.core.AEConfig;
|
||||||
|
import appeng.core.localization.GuiText;
|
||||||
|
import appeng.util.ISlimReadableNumberConverter;
|
||||||
|
import appeng.util.IWideReadableNumberConverter;
|
||||||
|
import appeng.util.ReadableNumberConverter;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author AlgorithmX2
|
||||||
|
* @author thatsIch
|
||||||
|
* @version rv2
|
||||||
|
* @since rv0
|
||||||
|
*/
|
||||||
|
public class StackSizeRenderer
|
||||||
|
{
|
||||||
|
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||||
|
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||||
|
|
||||||
|
public void renderStackSize( FontRenderer fontRenderer, IAEItemStack aeStack, ItemStack is, int xPos, int yPos )
|
||||||
|
{
|
||||||
|
if( is != null )
|
||||||
|
{
|
||||||
|
final float scaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f;
|
||||||
|
final float inverseScaleFactor = 1.0f / scaleFactor;
|
||||||
|
final int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1;
|
||||||
|
|
||||||
|
final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
|
||||||
|
fontRenderer.setUnicodeFlag( false );
|
||||||
|
|
||||||
|
if( is.stackSize == 0 )
|
||||||
|
{
|
||||||
|
final String craftLabelText = AEConfig.instance.useTerminalUseLargeFont() ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft.getLocal();
|
||||||
|
GlStateManager.disableLighting();
|
||||||
|
GlStateManager.disableDepth();
|
||||||
|
GlStateManager.disableBlend();
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glScaled( scaleFactor, scaleFactor, scaleFactor );
|
||||||
|
final int X = (int) ( ( (float) xPos + offset + 16.0f - fontRenderer.getStringWidth( craftLabelText ) * scaleFactor ) * inverseScaleFactor );
|
||||||
|
final int Y = (int) ( ( (float) yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
|
||||||
|
fontRenderer.drawStringWithShadow( craftLabelText, X, Y, 16777215 );
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
GlStateManager.enableLighting();
|
||||||
|
GlStateManager.enableDepth();
|
||||||
|
GlStateManager.enableBlend();
|
||||||
|
}
|
||||||
|
|
||||||
|
final long amount = aeStack != null ? aeStack.getStackSize() : is.stackSize;
|
||||||
|
if( amount != 0 )
|
||||||
|
{
|
||||||
|
final String stackSize = this.getToBeRenderedStackSize( amount );
|
||||||
|
|
||||||
|
GlStateManager.disableLighting();
|
||||||
|
GlStateManager.disableDepth();
|
||||||
|
GlStateManager.disableBlend();
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glScaled( scaleFactor, scaleFactor, scaleFactor );
|
||||||
|
final int X = (int) ( ( (float) xPos + offset + 16.0f - fontRenderer.getStringWidth( stackSize ) * scaleFactor ) * inverseScaleFactor );
|
||||||
|
final int Y = (int) ( ( (float) yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
|
||||||
|
fontRenderer.drawStringWithShadow( stackSize, X, Y, 16777215 );
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
GlStateManager.enableLighting();
|
||||||
|
GlStateManager.enableDepth();
|
||||||
|
GlStateManager.enableBlend();
|
||||||
|
}
|
||||||
|
|
||||||
|
fontRenderer.setUnicodeFlag( unicodeFlag );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getToBeRenderedStackSize( final long originalSize )
|
||||||
|
{
|
||||||
|
if( AEConfig.instance.useTerminalUseLargeFont() )
|
||||||
|
{
|
||||||
|
return SLIM_CONVERTER.toSlimReadableForm( originalSize );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return WIDE_CONVERTER.toWideReadableForm( originalSize );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -20,7 +20,6 @@ package appeng.transformer.asm;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
|
@ -52,6 +51,7 @@ public final class ASMTweaker implements IClassTransformer
|
||||||
@Reflected
|
@Reflected
|
||||||
public ASMTweaker()
|
public ASMTweaker()
|
||||||
{
|
{
|
||||||
|
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new PublicLine( "drawSlot", "(Lnet/minecraft/inventory/Slot;)V" ) );
|
||||||
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new PublicLine( "func_146977_a", "(Lnet/minecraft/inventory/Slot;)V" ) );
|
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new PublicLine( "func_146977_a", "(Lnet/minecraft/inventory/Slot;)V" ) );
|
||||||
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new PublicLine( "a", "(Lzk;)V" ) );
|
this.privateToPublicMethods.put( "net.minecraft.client.gui.inventory.GuiContainer", new PublicLine( "a", "(Lzk;)V" ) );
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public final class ASMTweaker implements IClassTransformer
|
||||||
{
|
{
|
||||||
for( final MethodNode mn : classNode.methods )
|
for( final MethodNode mn : classNode.methods )
|
||||||
{
|
{
|
||||||
if( mn.name.equals( "func_146977_a" ) || ( mn.name.equals( "a" ) && mn.desc.equals( "(Lzk;)V" ) ) )
|
if( mn.name.equals( "drawSlot" ) || mn.name.equals( "func_146977_a" ) || ( mn.name.equals( "a" ) && mn.desc.equals( "(Lzk;)V" ) ) )
|
||||||
{
|
{
|
||||||
final MethodNode newNode = new MethodNode( Opcodes.ACC_PUBLIC, "func_146977_a_original", mn.desc, mn.signature, EXCEPTIONS );
|
final MethodNode newNode = new MethodNode( Opcodes.ACC_PUBLIC, "func_146977_a_original", mn.desc, mn.signature, EXCEPTIONS );
|
||||||
newNode.instructions.add( new VarInsnNode( Opcodes.ALOAD, 0 ) );
|
newNode.instructions.add( new VarInsnNode( Opcodes.ALOAD, 0 ) );
|
||||||
|
@ -115,7 +115,7 @@ public final class ASMTweaker implements IClassTransformer
|
||||||
if( in.getOpcode() == Opcodes.INVOKESPECIAL )
|
if( in.getOpcode() == Opcodes.INVOKESPECIAL )
|
||||||
{
|
{
|
||||||
final MethodInsnNode n = (MethodInsnNode) in;
|
final MethodInsnNode n = (MethodInsnNode) in;
|
||||||
if( n.name.equals( "func_146977_a" ) || ( n.name.equals( "a" ) && n.desc.equals( "(Lzk;)V" ) ) )
|
if( n.name.equals( "drawSlot" ) || n.name.equals( "func_146977_a" ) || ( n.name.equals( "a" ) && n.desc.equals( "(Lzk;)V" ) ) )
|
||||||
{
|
{
|
||||||
this.log( n.name + n.desc + " - Invoke Virtual" );
|
this.log( n.name + n.desc + " - Invoke Virtual" );
|
||||||
mn.instructions.insertBefore( n, new MethodInsnNode( Opcodes.INVOKEVIRTUAL, n.owner, n.name, n.desc, false ) );
|
mn.instructions.insertBefore( n, new MethodInsnNode( Opcodes.INVOKEVIRTUAL, n.owner, n.name, n.desc, false ) );
|
||||||
|
|
Loading…
Reference in a new issue