Missing Files :(

This commit is contained in:
AlgorithmX2 2014-01-28 23:28:39 -06:00
parent 7270261963
commit bdc48457ec
2 changed files with 203 additions and 0 deletions

View file

@ -0,0 +1,122 @@
package appeng.client.render.items;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import appeng.api.util.AEColor;
import appeng.util.Platform;
public class ToolBiometricCardRender implements IItemRenderer
{
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
return helper == ItemRendererHelper.ENTITY_BOBBING || helper == ItemRendererHelper.ENTITY_ROTATION;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
Icon par2Icon = item.getIconIndex();
float f4 = ((Icon) par2Icon).getMinU();
float f5 = ((Icon) par2Icon).getMaxU();
float f6 = ((Icon) par2Icon).getMinV();
float f7 = ((Icon) par2Icon).getMaxV();
float f8 = 1.0F;
float f9 = 0.0F;
float f10 = 0.0F;
float f12 = 0.0625F;
Tessellator tessellator = Tessellator.instance;
GL11.glPushMatrix();
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
if ( type == ItemRenderType.INVENTORY )
{
GL11.glColor4f( 1, 1, 1, 1.0F );
GL11.glScalef( 16F, 16F, 10F );
GL11.glTranslatef( 0.0F, 1.0F, 0.0F );
GL11.glRotatef( 180F, 1.0F, 0.0F, 0.0F );
tessellator.startDrawingQuads();
tessellator.setNormal( 0.0F, 1.0F, 0.0F );
tessellator.addVertexWithUV( 0, 0, 0, (double) f4, (double) f7 );
tessellator.addVertexWithUV( 1, 0, 0, (double) f5, (double) f7 );
tessellator.addVertexWithUV( 1, 1, 0, (double) f5, (double) f6 );
tessellator.addVertexWithUV( 0, 1, 0, (double) f4, (double) f6 );
tessellator.draw();
}
else
{
GL11.glTranslatef( -0.5F, -0.3F, 0.01F );
ItemRenderer.renderItemIn2D( tessellator, f5, f6, f4, f7, ((Icon) par2Icon).getIconWidth(), ((Icon) par2Icon).getIconHeight(), f12 );
GL11.glDisable( GL11.GL_CULL_FACE );
GL11.glColor4f( 1, 1, 1, 1.0F );
GL11.glScalef( 1F, 1.1F, 1F );
GL11.glTranslatef( 0.0F, 1.07F, f12 / -2.0f );
GL11.glRotatef( 180F, 1.0F, 0.0F, 0.0F );
}
float u = Item.snowball.getIconFromDamage( 0 ).getInterpolatedU( 8.1 );
float v = Item.snowball.getIconFromDamage( 0 ).getInterpolatedV( 8.1 );
NBTTagCompound myTag = Platform.openNbtData( item );
String username = myTag.getString( "username" );
int hash = username.length() > 0 ? username.hashCode() : 0;
GL11.glScalef( 1F / 16F, 1F / 16F, 1F );
GL11.glTranslatef( 4, 6, 0 );
GL11.glDisable( GL11.GL_LIGHTING );
tessellator.startDrawingQuads();
float z = 0;
AEColor col = AEColor.values()[Math.abs( 3 + hash ) % AEColor.values().length];
if ( hash == 0 )
col = AEColor.Black;
for (int x = 0; x < 8; x++)// 8
{
for (int y = 0; y < 6; y++)// 6
{
boolean isLit = false;
float scale = 0.3f / 255.0f;
if ( x == 0 || y == 0 || x == 7 || y == 5 )
isLit = false;
else
isLit = (hash & (1 << x)) != 0 || (hash & (1 << y)) != 0;
if ( isLit )
tessellator.setColorOpaque_I( col.mediumVariant );
else
tessellator.setColorOpaque_F( ((col.blackVariant >> 16) & 0xff) * scale, ((col.blackVariant >> 8) & 0xff) * scale,
(col.blackVariant & 0xff) * scale );
tessellator.addVertexWithUV( x, y, z, (double) u, (double) v );
tessellator.addVertexWithUV( x + 1, y, z, (double) u, (double) v );
tessellator.addVertexWithUV( x + 1, y + 1, z, (double) u, (double) v );
tessellator.addVertexWithUV( x, y + 1, z, (double) u, (double) v );
}
}
tessellator.draw();
GL11.glPopAttrib();
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,81 @@
package appeng.items.tools;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import appeng.client.render.items.ToolBiometricCardRender;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
public class ToolBiometricCard extends AEBaseItem
{
public ToolBiometricCard() {
super( ToolBiometricCard.class );
setfeature( EnumSet.of( AEFeature.Security ) );
setMaxStackSize( 1 );
if ( Platform.isClient() )
MinecraftForgeClient.registerItemRenderer( itemID, new ToolBiometricCardRender() );
}
@Override
public String getItemDisplayName(ItemStack is)
{
NBTTagCompound tag = Platform.openNbtData( is );
String username = tag.getString( "username" );
return username != null ? super.getItemDisplayName( is ) + " - " + GuiText.Encoded.getLocal() : super.getItemDisplayName( is );
}
@Override
public boolean itemInteractionForEntity(ItemStack is, EntityPlayer par2EntityPlayer, EntityLivingBase target)
{
if ( target instanceof EntityPlayer )
{
if ( par2EntityPlayer.capabilities.isCreativeMode )
is = par2EntityPlayer.getCurrentEquippedItem();
encode( is, (EntityPlayer) target );
return true;
}
return false;
}
@Override
public boolean onItemUse(ItemStack is, EntityPlayer p, World w, int x, int y, int z, int side, float hitx, float hity, float hitz)
{
if ( p.isSneaking() )
{
encode( is, p );
return true;
}
return false;
}
private void encode(ItemStack is, EntityPlayer p)
{
NBTTagCompound tag = Platform.openNbtData( is );
String username = tag.getString( "username" );
if ( p.username.equals( username ) )
is.setTagCompound( null );
else
tag.setString( "username", p.username );
}
@Override
public void addInformation(ItemStack is, EntityPlayer p, List l, boolean b)
{
NBTTagCompound tag = Platform.openNbtData( is );
String username = tag.getString( "username" );
if ( username.length() > 0 )
l.add( username );
}
}