Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,407 @@
|
||||
package appeng.client;
|
||||
|
||||
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.ENTITY;
|
||||
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.TESRWrapper;
|
||||
import appeng.client.render.WorldRender;
|
||||
import appeng.client.render.effects.AssemblerFX;
|
||||
import appeng.client.render.effects.CraftingFx;
|
||||
import appeng.client.render.effects.EnergyFx;
|
||||
import appeng.client.render.effects.LightningArcFX;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.client.render.effects.VibrantFX;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.client.texture.ExtraItemTextures;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.entity.EntityFloatingItem;
|
||||
import appeng.entity.EntityTinyTNTPrimed;
|
||||
import appeng.entity.RenderFloatingItem;
|
||||
import appeng.entity.RenderTinyTNTPrimed;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
import appeng.server.ServerHelper;
|
||||
import appeng.transformer.MissingCoreMod;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class ClientHelper extends ServerHelper
|
||||
{
|
||||
|
||||
private static RenderItem itemRenderer = new RenderItem();
|
||||
private static RenderBlocks blockRenderer = new RenderBlocks();
|
||||
|
||||
@Override
|
||||
public CableRenderMode getRenderMode()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
return super.getRenderMode();
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
|
||||
return renderModeForPlayer( player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void triggerUpdates()
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if ( mc == null || mc.thePlayer == null || mc.theWorld == null )
|
||||
return;
|
||||
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
|
||||
if ( player == null )
|
||||
return;
|
||||
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
|
||||
int range = 16 * 16;
|
||||
|
||||
mc.theWorld.markBlockRangeForRenderUpdate( x - range, y - range, z - range, x + range, y + range, z + range );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void postPlayerRender(RenderLivingEvent.Pre p)
|
||||
{
|
||||
PlayerColor player = TickHandler.instance.getPlayerColors().get( p.entity.getEntityId() );
|
||||
if ( player != null )
|
||||
{
|
||||
AEColor col = player.myColor;
|
||||
|
||||
float r = (float) (0xff & (col.mediumVariant >> 16));
|
||||
float g = (float) (0xff & (col.mediumVariant >> 8));
|
||||
float b = (float) (0xff & (col.mediumVariant));
|
||||
GL11.glColor3f( r / 255.0f, g / 255.0f, b / 255.0f );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRenderItem(ItemStack itemstack, World w)
|
||||
{
|
||||
if ( itemstack != null )
|
||||
{
|
||||
EntityItem entityitem = new EntityItem( w, 0.0D, 0.0D, 0.0D, itemstack );
|
||||
entityitem.getEntityItem().stackSize = 1;
|
||||
|
||||
// set all this stuff and then do shit? meh?
|
||||
entityitem.hoverStart = 0;
|
||||
entityitem.age = 0;
|
||||
entityitem.rotationYaw = 0;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef( 0, -0.04F, 0 );
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
// GL11.glDisable( GL11.GL_CULL_FACE );
|
||||
|
||||
if ( itemstack.isItemEnchanted() || itemstack.getItem().requiresMultipleRenderPasses() )
|
||||
{
|
||||
GL11.glTranslatef( 0.0f, -0.05f, -0.25f );
|
||||
GL11.glScalef( 1.0f / 1.5f, 1.0f / 1.5f, 1.0f / 1.5f );
|
||||
// GL11.glTranslated( -8.0, -12.2, -10.6 );
|
||||
GL11.glScalef( 1.0f, -1.0f, 0.005f );
|
||||
// GL11.glScalef( 1.0f , -1.0f, 1.0f );
|
||||
|
||||
Block block = Block.getBlockFromItem( itemstack.getItem() );
|
||||
if ( (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d( block.getRenderType() )) )
|
||||
{
|
||||
GL11.glRotatef( 25.0f, 1.0f, 0.0f, 0.0f );
|
||||
GL11.glRotatef( 15.0f, 0.0f, 1.0f, 0.0f );
|
||||
GL11.glRotatef( 30.0f, 0.0f, 1.0f, 0.0f );
|
||||
}
|
||||
|
||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer( itemstack, ENTITY );
|
||||
if ( customRenderer != null && !(itemstack.getItem() instanceof ItemBlock) )
|
||||
{
|
||||
if ( customRenderer.shouldUseRenderHelper( ENTITY, itemstack, BLOCK_3D ) )
|
||||
{
|
||||
GL11.glTranslatef( 0, -0.04F, 0 );
|
||||
GL11.glScalef( 0.7f, 0.7f, 0.7f );
|
||||
GL11.glRotatef( 35, 1, 0, 0 );
|
||||
GL11.glRotatef( 45, 0, 1, 0 );
|
||||
GL11.glRotatef( -90, 0, 1, 0 );
|
||||
}
|
||||
}
|
||||
else if ( itemstack.getItem() instanceof ItemBlock )
|
||||
{
|
||||
GL11.glTranslatef( 0, -0.04F, 0 );
|
||||
GL11.glScalef( 1.1f, 1.1f, 1.1f );
|
||||
GL11.glRotatef( -90, 0, 1, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glTranslatef( 0, -0.14F, 0 );
|
||||
GL11.glScalef( 0.8f, 0.8f, 0.8f );
|
||||
}
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw( entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F );
|
||||
RenderItem.renderInFrame = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glScalef( 1.0f / 42.0f, 1.0f / 42.0f, 1.0f / 42.0f );
|
||||
GL11.glTranslated( -8.0, -10.2, -10.4 );
|
||||
GL11.glScalef( 1.0f, 1.0f, 0.005f );
|
||||
|
||||
RenderItem.renderInFrame = false;
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
if ( !ForgeHooksClient.renderInventoryItem( blockRenderer, Minecraft.getMinecraft().renderEngine, itemstack, true, 0, (float) 0, (float) 0 ) )
|
||||
{
|
||||
itemRenderer.renderItemIntoGUI( fr, Minecraft.getMinecraft().renderEngine, itemstack, 0, 0, false );
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postinit()
|
||||
{
|
||||
RenderingRegistry.registerBlockHandler( WorldRender.instance );
|
||||
RenderManager.instance.entityRenderMap.put( EntityTinyTNTPrimed.class, new RenderTinyTNTPrimed() );
|
||||
RenderManager.instance.entityRenderMap.put( EntityFloatingItem.class, new RenderFloatingItem() );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void wheelEvent(MouseEvent me)
|
||||
{
|
||||
if ( me.isCanceled() || me.dwheel == 0 )
|
||||
return;
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
ItemStack is = player.getHeldItem();
|
||||
|
||||
if ( is != null && is.getItem() instanceof IMouseWheelItem && player.isSneaking() )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Item", me.dwheel > 0 ? "WheelUp" : "WheelDown" ) );
|
||||
me.setCanceled( true );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void updateTextureSheet(TextureStitchEvent.Pre ev)
|
||||
{
|
||||
if ( ev.map.getTextureType() == 1 )
|
||||
{
|
||||
for (ExtraItemTextures et : ExtraItemTextures.values())
|
||||
et.registerIcon( ev.map );
|
||||
}
|
||||
|
||||
if ( ev.map.getTextureType() == 0 )
|
||||
{
|
||||
for (ExtraBlockTextures et : ExtraBlockTextures.values())
|
||||
et.registerIcon( ev.map );
|
||||
|
||||
for (CableBusTextures cb : CableBusTextures.values())
|
||||
cb.registerIcon( ev.map );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return Minecraft.getMinecraft().theWorld;
|
||||
else
|
||||
return super.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTileEntitySpecialRenderer(Class tile, AEBaseBlock blk)
|
||||
{
|
||||
BaseBlockRender bbr = blk.getRendererInstance().rendererInstance;
|
||||
if ( bbr.hasTESR && tile != null )
|
||||
ClientRegistry.bindTileEntitySpecialRenderer( tile, new TESRWrapper( bbr ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntityPlayer> getPlayers()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
{
|
||||
List<EntityPlayer> o = new ArrayList();
|
||||
o.add( Minecraft.getMinecraft().thePlayer );
|
||||
return o;
|
||||
}
|
||||
else
|
||||
return super.getPlayers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnEffect(EffectType effect, World worldObj, double posX, double posY, double posZ, Object o)
|
||||
{
|
||||
if ( AEConfig.instance.enableEffects )
|
||||
{
|
||||
switch (effect)
|
||||
{
|
||||
case Assembler:
|
||||
spawnAssembler( worldObj, posX, posY, posZ, o );
|
||||
return;
|
||||
case Vibrant:
|
||||
spawnVibrant( worldObj, posX, posY, posZ );
|
||||
return;
|
||||
case Crafting:
|
||||
spawnCrafting( worldObj, posX, posY, posZ );
|
||||
return;
|
||||
case Energy:
|
||||
spawnEnergy( worldObj, posX, posY, posZ );
|
||||
return;
|
||||
case Lightning:
|
||||
spawnLightning( worldObj, posX, posY, posZ );
|
||||
return;
|
||||
case LightningArc:
|
||||
spawnLightningArc( worldObj, posX, posY, posZ, (Vec3) o );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnAssembler(World worldObj, double posX, double posY, double posZ, Object o)
|
||||
{
|
||||
PacketAssemblerAnimation paa = (PacketAssemblerAnimation) o;
|
||||
|
||||
AssemblerFX fx = new AssemblerFX( Minecraft.getMinecraft().theWorld, posX, posY, posZ, 0.0D, 0.0D, 0.0D, paa.rate, paa.is );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
|
||||
private void spawnVibrant(World w, double x, double y, double z)
|
||||
{
|
||||
if ( CommonHelper.proxy.shouldAddParticles( Platform.getRandom() ) )
|
||||
{
|
||||
double d0 = (double) (Platform.getRandomFloat() - 0.5F) * 0.26D;
|
||||
double d1 = (double) (Platform.getRandomFloat() - 0.5F) * 0.26D;
|
||||
double d2 = (double) (Platform.getRandomFloat() - 0.5F) * 0.26D;
|
||||
|
||||
VibrantFX fx = new VibrantFX( w, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnLightningArc(World worldObj, double posX, double posY, double posZ, Vec3 second)
|
||||
{
|
||||
LightningFX fx = new LightningArcFX( worldObj, posX, posY, posZ, second.xCoord, second.yCoord, second.zCoord, 0.0f, 0.0f, 0.0f );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
|
||||
private void spawnLightning(World worldObj, double posX, double posY, double posZ)
|
||||
{
|
||||
LightningFX fx = new LightningFX( worldObj, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
|
||||
private void spawnEnergy(World w, double posX, double posY, double posZ)
|
||||
{
|
||||
float x = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
|
||||
float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
|
||||
float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
|
||||
|
||||
EnergyFx fx = new EnergyFx( w, posX + x, posY + y, posZ + z, Items.diamond );
|
||||
|
||||
fx.motionX = -x * 0.1;
|
||||
fx.motionY = -y * 0.1;
|
||||
fx.motionZ = -z * 0.1;
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
|
||||
private void spawnCrafting(World w, double posX, double posY, double posZ)
|
||||
{
|
||||
float x = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
|
||||
float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
|
||||
float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
|
||||
|
||||
CraftingFx fx = new CraftingFx( w, posX + x, posY + y, posZ + z, Items.diamond );
|
||||
|
||||
fx.motionX = -x * 0.2;
|
||||
fx.motionY = -y * 0.2;
|
||||
fx.motionZ = -z * 0.2;
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAddParticles(Random r)
|
||||
{
|
||||
int setting = Minecraft.getMinecraft().gameSettings.particleSetting;
|
||||
if ( setting == 2 )
|
||||
return false;
|
||||
if ( setting == 0 )
|
||||
return true;
|
||||
return r.nextInt( 2 * (setting + 1) ) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getMOP()
|
||||
{
|
||||
return Minecraft.getMinecraft().objectMouseOver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void missingCoreMod()
|
||||
{
|
||||
throw new MissingCoreMod();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package appeng.client;
|
||||
|
||||
public enum EffectType
|
||||
{
|
||||
Energy, Lightning, Vibrant, Crafting, Assembler, LightningArc
|
||||
}
|
||||
@@ -0,0 +1,952 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import appeng.container.slot.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.AppEngSlot.hasCalculatedValidness;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketSwapSlots;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.INEI;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
public abstract class AEBaseGui extends GuiContainer
|
||||
{
|
||||
|
||||
protected List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>();
|
||||
protected GuiScrollbar myScrollBar = null;
|
||||
static public boolean switchingGuis;
|
||||
private boolean subGui;
|
||||
|
||||
public AEBaseGui(Container container)
|
||||
{
|
||||
super( container );
|
||||
subGui = switchingGuis;
|
||||
switchingGuis = false;
|
||||
}
|
||||
|
||||
protected int getQty(GuiButton btn)
|
||||
{
|
||||
try
|
||||
{
|
||||
DecimalFormat df = new DecimalFormat( "+#;-#" );
|
||||
return df.parse( btn.displayString ).intValue();
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSubGui()
|
||||
{
|
||||
return subGui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
Iterator<Slot> i = inventorySlots.inventorySlots.iterator();
|
||||
while (i.hasNext())
|
||||
if ( i.next() instanceof SlotME )
|
||||
i.remove();
|
||||
|
||||
for (InternalSlotME me : meSlots)
|
||||
inventorySlots.inventorySlots.add( new SlotME( me ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput()
|
||||
{
|
||||
super.handleMouseInput();
|
||||
|
||||
int i = Mouse.getEventDWheel();
|
||||
if ( i != 0 && isShiftKeyDown() )
|
||||
{
|
||||
int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
|
||||
int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
|
||||
mouseWheelEvent( x, y, i / Math.abs( i ) );
|
||||
}
|
||||
else if ( i != 0 && myScrollBar != null )
|
||||
myScrollBar.wheel( i );
|
||||
}
|
||||
|
||||
protected void mouseWheelEvent(int x, int y, int wheel)
|
||||
{
|
||||
Slot slot = getSlot( x, y );
|
||||
if ( slot instanceof SlotME )
|
||||
{
|
||||
IAEItemStack item = ((SlotME) slot).getAEStack();
|
||||
if ( item != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
((AEBaseContainer) inventorySlots).setTargetStack( item );
|
||||
InventoryAction direction = wheel > 0 ? InventoryAction.ROLLDOWN : InventoryAction.ROLLUP;
|
||||
int times = Math.abs( wheel );
|
||||
for (int h = 0; h < times; h++)
|
||||
{
|
||||
PacketInventoryAction p = new PacketInventoryAction( direction, inventorySlots.inventorySlots.size(), 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed()
|
||||
{
|
||||
super.onGuiClosed();
|
||||
subGui = true; // in case the gui is reopened later ( i'm looking at you NEI )
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int xCoord, int yCoord, int btn)
|
||||
{
|
||||
drag_click.clear();
|
||||
|
||||
if ( btn == 1 )
|
||||
{
|
||||
for (Object o : this.buttonList)
|
||||
{
|
||||
GuiButton guibutton = (GuiButton) o;
|
||||
if ( guibutton.mousePressed( this.mc, xCoord, yCoord ) )
|
||||
{
|
||||
super.mouseClicked( xCoord, yCoord, 0 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.mouseClicked( xCoord, yCoord, btn );
|
||||
}
|
||||
|
||||
boolean disableShiftClick = false;
|
||||
Stopwatch dbl_clickTimer = Stopwatch.createStarted();
|
||||
ItemStack dbl_whichItem;
|
||||
Slot bl_clicked;
|
||||
|
||||
// dragy
|
||||
Set<Slot> drag_click = new HashSet();
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int key)
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
if ( slot instanceof SlotFake )
|
||||
{
|
||||
InventoryAction action = null;
|
||||
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
|
||||
|
||||
if ( drag_click.size() > 1 )
|
||||
return;
|
||||
|
||||
if ( action != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( slot instanceof SlotPatternTerm )
|
||||
{
|
||||
if ( key == 6 )
|
||||
return; // prevent weird double clicks..
|
||||
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( ((SlotPatternTerm) slot).getRequest( key == 1 ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
else if ( slot instanceof SlotCraftingTerm )
|
||||
{
|
||||
if ( key == 6 )
|
||||
return; // prevent weird double clicks..
|
||||
|
||||
InventoryAction action = null;
|
||||
if ( key == 1 )
|
||||
action = InventoryAction.CRAFT_SHIFT;
|
||||
else
|
||||
action = ctrlDown == 1 ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
|
||||
|
||||
if ( action != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Keyboard.isKeyDown( Keyboard.KEY_SPACE ) )
|
||||
{
|
||||
if ( enableSpaceClicking() )
|
||||
{
|
||||
IAEItemStack stack = null;
|
||||
if ( slot instanceof SlotME )
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
|
||||
try
|
||||
{
|
||||
int slotNum = inventorySlots.inventorySlots.size();
|
||||
|
||||
if ( !(slot instanceof SlotME) && slot != null )
|
||||
slotNum = slot.slotNumber;
|
||||
|
||||
((AEBaseContainer) inventorySlots).setTargetStack( stack );
|
||||
PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( slot instanceof SlotDisconnected )
|
||||
{
|
||||
InventoryAction action = null;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 0: // pickup / set-down.
|
||||
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
|
||||
break;
|
||||
case 1:
|
||||
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
|
||||
break;
|
||||
|
||||
case 3: // creative dupe:
|
||||
|
||||
if ( player.capabilities.isCreativeMode )
|
||||
{
|
||||
action = InventoryAction.CREATIVE_DUPLICATE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
case 4: // drop item:
|
||||
case 6:
|
||||
}
|
||||
|
||||
if ( action != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketInventoryAction p = new PacketInventoryAction( action, slot.getSlotIndex(), ((SlotDisconnected) slot).mySlot.id );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( slot instanceof SlotME )
|
||||
{
|
||||
InventoryAction action = null;
|
||||
IAEItemStack stack = null;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 0: // pickup / set-down.
|
||||
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
|
||||
if ( stack != null && action == InventoryAction.PICKUP_OR_SETDOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null )
|
||||
action = InventoryAction.AUTOCRAFT;
|
||||
|
||||
break;
|
||||
case 1:
|
||||
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
break;
|
||||
|
||||
case 3: // creative dupe:
|
||||
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
if ( stack != null && stack.isCraftable() )
|
||||
action = InventoryAction.AUTOCRAFT;
|
||||
|
||||
else if ( player.capabilities.isCreativeMode )
|
||||
{
|
||||
IAEItemStack slotItem = ((SlotME) slot).getAEStack();
|
||||
if ( slotItem != null )
|
||||
{
|
||||
action = InventoryAction.CREATIVE_DUPLICATE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 4: // drop item:
|
||||
case 6:
|
||||
}
|
||||
|
||||
if ( action != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
((AEBaseContainer) inventorySlots).setTargetStack( stack );
|
||||
PacketInventoryAction p = new PacketInventoryAction( action, inventorySlots.inventorySlots.size(), 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( disableShiftClick == false && isShiftKeyDown() )
|
||||
{
|
||||
disableShiftClick = true;
|
||||
|
||||
if ( dbl_whichItem == null || bl_clicked != slot || dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 150 )
|
||||
{
|
||||
// some simple double click logic.
|
||||
bl_clicked = slot;
|
||||
dbl_clickTimer = Stopwatch.createStarted();
|
||||
if ( slot != null )
|
||||
dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : null;
|
||||
else
|
||||
dbl_whichItem = null;
|
||||
}
|
||||
else if ( dbl_whichItem != null )
|
||||
{
|
||||
// a replica of the weird broken vanilla feature.
|
||||
Iterator iterator = this.inventorySlots.inventorySlots.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Slot targetSlot = (Slot) iterator.next();
|
||||
|
||||
if ( targetSlot != null && targetSlot.canTakeStack( this.mc.thePlayer ) && targetSlot.getHasStack()
|
||||
&& targetSlot.inventory == slot.inventory && Container.func_94527_a( targetSlot, dbl_whichItem, true ) )
|
||||
{
|
||||
this.handleMouseClick( targetSlot, targetSlot.slotNumber, ctrlDown, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
disableShiftClick = false;
|
||||
}
|
||||
|
||||
super.handleMouseClick( slot, slotIdx, ctrlDown, key );
|
||||
}
|
||||
|
||||
protected void mouseClickMove(int x, int y, int c, long d)
|
||||
{
|
||||
Slot slot = this.getSlot( x, y );
|
||||
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
|
||||
|
||||
if ( slot instanceof SlotFake && itemstack != null )
|
||||
{
|
||||
drag_click.add( slot );
|
||||
if ( drag_click.size() > 1 )
|
||||
{
|
||||
try
|
||||
{
|
||||
for (Slot dr : drag_click)
|
||||
{
|
||||
PacketInventoryAction p = new PacketInventoryAction( c == 0 ? InventoryAction.PICKUP_OR_SETDOWN : InventoryAction.PLACE_SINGLE,
|
||||
dr.slotNumber, 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
super.mouseClickMove( x, y, c, d );
|
||||
}
|
||||
|
||||
protected boolean enableSpaceClicking()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkHotbarKeys(int p_146983_1_)
|
||||
{
|
||||
Slot theSlot;
|
||||
|
||||
try
|
||||
{
|
||||
theSlot = ObfuscationReflectionHelper.getPrivateValue( GuiContainer.class, this, "theSlot", "field_147006_u", "f" );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( this.mc.thePlayer.inventory.getItemStack() == null && theSlot != null )
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
if ( p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode() )
|
||||
{
|
||||
for (Slot s : (List<Slot>) inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) inventorySlots).getPlayerInv() )
|
||||
{
|
||||
if ( !s.canTakeStack( ((AEBaseContainer) inventorySlots).getPlayerInv().player ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( theSlot.getSlotStackLimit() == 64 )
|
||||
{
|
||||
this.handleMouseClick( theSlot, theSlot.slotNumber, j, 2 );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
for (Slot s : (List<Slot>) inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) inventorySlots).getPlayerInv() )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwapSlots( s.slotNumber, theSlot.slotNumber ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
|
||||
boolean hasClicked = Mouse.isButtonDown( 0 );
|
||||
if ( hasClicked && myScrollBar != null )
|
||||
myScrollBar.click( this, mouse_x - guiLeft, mouse_y - guiTop );
|
||||
|
||||
for (Object c : buttonList)
|
||||
{
|
||||
if ( c instanceof ITooltip )
|
||||
{
|
||||
ITooltip tooltip = (ITooltip) c;
|
||||
int x = tooltip.xPos(); // ((GuiImgButton) c).xPosition;
|
||||
int y = tooltip.yPos(); // ((GuiImgButton) c).yPosition;
|
||||
|
||||
if ( x < mouse_x && x + tooltip.getWidth() > mouse_x && tooltip.isVisible() )
|
||||
{
|
||||
if ( y < mouse_y && y + tooltip.getHeight() > mouse_y )
|
||||
{
|
||||
if ( y < 15 )
|
||||
y = 15;
|
||||
|
||||
String msg = tooltip.getMsg();
|
||||
if ( msg != null )
|
||||
drawTooltip( x + 11, y + 4, 0, msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drawTooltip(int par2, int par3, int forceWidth, String Msg)
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
||||
String[] var4 = Msg.split( "\n" );
|
||||
|
||||
if ( var4.length > 0 )
|
||||
{
|
||||
int var5 = 0;
|
||||
int var6;
|
||||
int var7;
|
||||
|
||||
for (var6 = 0; var6 < var4.length; ++var6)
|
||||
{
|
||||
var7 = fontRendererObj.getStringWidth( (String) var4[var6] );
|
||||
|
||||
if ( var7 > var5 )
|
||||
{
|
||||
var5 = var7;
|
||||
}
|
||||
}
|
||||
|
||||
var6 = par2 + 12;
|
||||
var7 = par3 - 12;
|
||||
int var9 = 8;
|
||||
|
||||
if ( var4.length > 1 )
|
||||
{
|
||||
var9 += 2 + (var4.length - 1) * 10;
|
||||
}
|
||||
|
||||
if ( this.guiTop + var7 + var9 + 6 > this.height )
|
||||
{
|
||||
var7 = this.height - var9 - this.guiTop - 6;
|
||||
}
|
||||
|
||||
if ( forceWidth > 0 )
|
||||
var5 = forceWidth;
|
||||
|
||||
this.zLevel = 300.0F;
|
||||
itemRender.zLevel = 300.0F;
|
||||
int var10 = -267386864;
|
||||
this.drawGradientRect( var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10 );
|
||||
this.drawGradientRect( var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10 );
|
||||
this.drawGradientRect( var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10 );
|
||||
this.drawGradientRect( var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10 );
|
||||
this.drawGradientRect( var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10 );
|
||||
int var11 = 1347420415;
|
||||
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
|
||||
this.drawGradientRect( var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12 );
|
||||
this.drawGradientRect( var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12 );
|
||||
this.drawGradientRect( var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11 );
|
||||
this.drawGradientRect( var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12 );
|
||||
|
||||
for (int var13 = 0; var13 < var4.length; ++var13)
|
||||
{
|
||||
String var14 = (String) var4[var13];
|
||||
|
||||
if ( var13 == 0 )
|
||||
{
|
||||
var14 = "\u00a7" + Integer.toHexString( 15 ) + var14;
|
||||
}
|
||||
else
|
||||
{
|
||||
var14 = "\u00a77" + var14;
|
||||
}
|
||||
|
||||
this.fontRendererObj.drawStringWithShadow( var14, var6, var7, -1 );
|
||||
|
||||
if ( var13 == 0 )
|
||||
{
|
||||
var7 += 2;
|
||||
}
|
||||
|
||||
var7 += 10;
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRender.zLevel = 0.0F;
|
||||
}
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
public abstract void drawBG(int offsetX, int offsetY, int mouseX, int mouseY);
|
||||
|
||||
public abstract void drawFG(int offsetX, int offsetY, int mouseX, int mouseY);
|
||||
|
||||
public void bindTexture(String base, String file)
|
||||
{
|
||||
ResourceLocation loc = new ResourceLocation( base, "textures/" + file );
|
||||
this.mc.getTextureManager().bindTexture( loc );
|
||||
}
|
||||
|
||||
public void bindTexture(String file)
|
||||
{
|
||||
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/" + file );
|
||||
this.mc.getTextureManager().bindTexture( loc );
|
||||
}
|
||||
|
||||
protected void drawItem(int x, int y, ItemStack is)
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
itemRender.zLevel = 100.0F;
|
||||
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
itemRender.renderItemAndEffectIntoGUI( this.fontRendererObj, this.mc.renderEngine, is, x, y );
|
||||
GL11.glPopAttrib();
|
||||
|
||||
itemRender.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
final protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
|
||||
{
|
||||
int ox = guiLeft; // (width - xSize) / 2;
|
||||
int oy = guiTop; // (height - ySize) / 2;
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
drawBG( ox, oy, x, y );
|
||||
|
||||
for (Object o : inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( o instanceof OptionalSlotFake )
|
||||
{
|
||||
OptionalSlotFake fs = (OptionalSlotFake) o;
|
||||
if ( fs.renderDisabled() )
|
||||
{
|
||||
if ( fs.isEnabled() )
|
||||
{
|
||||
this.drawTexturedModalRect( ox + fs.xDisplayPosition - 1, oy + fs.yDisplayPosition - 1, fs.srcX - 1, fs.srcY - 1, 18, 18 );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 0.4F );
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
this.drawTexturedModalRect( ox + fs.xDisplayPosition - 1, oy + fs.yDisplayPosition - 1, fs.srcX - 1, fs.srcY - 1, 18, 18 );
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final protected void drawGuiContainerForegroundLayer(int x, int y)
|
||||
{
|
||||
int ox = guiLeft; // (width - xSize) / 2;
|
||||
int oy = guiTop; // (height - ySize) / 2;
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
if ( myScrollBar != null )
|
||||
myScrollBar.draw( this );
|
||||
|
||||
drawFG( ox, oy, x, y );
|
||||
}
|
||||
|
||||
protected String getGuiDisplayName(String in)
|
||||
{
|
||||
return hasCustomInventoryName() ? getInventoryName() : in;
|
||||
}
|
||||
|
||||
private String getInventoryName()
|
||||
{
|
||||
return ((AEBaseContainer) inventorySlots).customName;
|
||||
}
|
||||
|
||||
private boolean hasCustomInventoryName()
|
||||
{
|
||||
if ( inventorySlots instanceof AEBaseContainer )
|
||||
return ((AEBaseContainer) inventorySlots).customName != null;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Slot getSlot(int mousex, int mousey)
|
||||
{
|
||||
for (int j1 = 0; j1 < this.inventorySlots.inventorySlots.size(); ++j1)
|
||||
{
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get( j1 );
|
||||
|
||||
// isPointInRegion
|
||||
if ( func_146978_c( slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mousex, mousey ) )
|
||||
{
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static String join(Collection<?> s, String delimiter)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Iterator iter = s.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
builder.append( iter.next() );
|
||||
if ( !iter.hasNext() )
|
||||
{
|
||||
break;
|
||||
}
|
||||
builder.append( delimiter );
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
boolean useNEI = false;
|
||||
|
||||
private RenderItem setItemRender(RenderItem aeri2)
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.NEI ) )
|
||||
{
|
||||
return ((INEI) AppEng.instance.getIntegration( IntegrationType.NEI )).setItemRender( aeri2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderItem ri = itemRender;
|
||||
itemRender = aeri2;
|
||||
return ri;
|
||||
}
|
||||
}
|
||||
|
||||
private void safeDrawSlot(Slot s)
|
||||
{
|
||||
try
|
||||
{
|
||||
// drawSlotInventory
|
||||
// super.func_146977_a( s );r
|
||||
GuiContainer.class.getDeclaredMethod( "func_146977_a_original", Slot.class ).invoke( this, s );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
if ( Platform.isDrawing( tessellator ) )
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
AppEngRenderItem aeri = new AppEngRenderItem();
|
||||
|
||||
protected boolean isPowered()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void a(Slot s)
|
||||
{
|
||||
drawSlot( s );
|
||||
}
|
||||
|
||||
public void func_146977_a(Slot s)
|
||||
{
|
||||
drawSlot( s );
|
||||
}
|
||||
|
||||
public void drawSlot(Slot s)
|
||||
{
|
||||
if ( s instanceof SlotME )
|
||||
{
|
||||
RenderItem pIR = setItemRender( aeri );
|
||||
try
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
itemRender.zLevel = 100.0F;
|
||||
|
||||
if ( !isPowered() )
|
||||
{
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
super.drawRect( s.xDisplayPosition, s.yDisplayPosition, 16 + s.xDisplayPosition, 16 + s.yDisplayPosition, 0x66111111 );
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRender.zLevel = 0.0F;
|
||||
|
||||
if ( s instanceof SlotME )
|
||||
aeri.aestack = ((SlotME) s).getAEStack();
|
||||
else
|
||||
aeri.aestack = null;
|
||||
|
||||
safeDrawSlot( s );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AELog.warning( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
||||
if ( Platform.isDrawing( Tessellator.instance ) )
|
||||
Tessellator.instance.draw();
|
||||
}
|
||||
setItemRender( pIR );
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemStack is = s.getStack();
|
||||
if ( s instanceof AppEngSlot && (((AppEngSlot) s).renderIconWithItem() || is == null) && (((AppEngSlot) s).shouldDisplay()) )
|
||||
{
|
||||
AppEngSlot aes = (AppEngSlot) s;
|
||||
if ( aes.getIcon() >= 0 )
|
||||
{
|
||||
bindTexture( "guis/states.png" );
|
||||
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
try
|
||||
{
|
||||
int uv_y = (int) Math.floor( aes.getIcon() / 16 );
|
||||
int uv_x = aes.getIcon() - uv_y * 16;
|
||||
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL11.GL_TEXTURE_2D );
|
||||
GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
float par1 = aes.xDisplayPosition;
|
||||
float par2 = aes.yDisplayPosition;
|
||||
float par3 = uv_x * 16;
|
||||
float par4 = uv_y * 16;
|
||||
float par5 = 16;
|
||||
float par6 = 16;
|
||||
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() );
|
||||
tessellator.addVertexWithUV( (double) (par1 + 0), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + 0) * f),
|
||||
(double) ((float) (par4 + par6) * f1) );
|
||||
tessellator.addVertexWithUV( (double) (par1 + par5), (double) (par2 + par6), (double) this.zLevel,
|
||||
(double) ((float) (par3 + par5) * f), (double) ((float) (par4 + par6) * f1) );
|
||||
tessellator.addVertexWithUV( (double) (par1 + par5), (double) (par2 + 0), (double) this.zLevel,
|
||||
(double) ((float) (par3 + par5) * f), (double) ((float) (par4 + 0) * f1) );
|
||||
tessellator.addVertexWithUV( (double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + 0) * f),
|
||||
(double) ((float) (par4 + 0) * f1) );
|
||||
tessellator.setColorRGBA_F( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
tessellator.draw();
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
if ( Platform.isDrawing( tessellator ) )
|
||||
tessellator.draw();
|
||||
}
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
if ( is != null && s instanceof AppEngSlot )
|
||||
{
|
||||
if ( ((AppEngSlot) s).isValid == hasCalculatedValidness.NotAvailable )
|
||||
{
|
||||
boolean isValid = s.isItemValid( is ) || s instanceof SlotOutput || s instanceof AppEngCraftingSlot || s instanceof SlotDisabled
|
||||
|| s instanceof SlotInaccessible || s instanceof SlotFake || s instanceof SlotRestrictedInput || s instanceof SlotDisconnected;
|
||||
if ( isValid && s instanceof SlotRestrictedInput )
|
||||
{
|
||||
try
|
||||
{
|
||||
isValid = ((SlotRestrictedInput) s).isValid( is, this.mc.theWorld );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AELog.error( err );
|
||||
}
|
||||
}
|
||||
((AppEngSlot) s).isValid = isValid ? hasCalculatedValidness.Valid : hasCalculatedValidness.Invalid;
|
||||
}
|
||||
|
||||
if ( ((AppEngSlot) s).isValid == hasCalculatedValidness.Invalid )
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
itemRender.zLevel = 100.0F;
|
||||
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
super.drawRect( s.xDisplayPosition, s.yDisplayPosition, 16 + s.xDisplayPosition, 16 + s.yDisplayPosition, 0x66ff6666 );
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRender.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
if ( s instanceof AppEngSlot )
|
||||
{
|
||||
((AppEngSlot) s).isDisplay = true;
|
||||
safeDrawSlot( s );
|
||||
}
|
||||
else
|
||||
safeDrawSlot( s );
|
||||
|
||||
return;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AELog.warning( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
||||
}
|
||||
}
|
||||
// do the usual for non-ME Slots.
|
||||
safeDrawSlot( s );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
public abstract class AEBaseMEGui extends AEBaseGui
|
||||
{
|
||||
|
||||
public AEBaseMEGui(Container container) {
|
||||
super( container );
|
||||
}
|
||||
|
||||
public List<String> handleItemTooltip(ItemStack stack, int mousex, int mousey, List<String> currenttip)
|
||||
{
|
||||
if ( stack != null )
|
||||
{
|
||||
Slot s = getSlot( mousex, mousey );
|
||||
if ( s instanceof SlotME )
|
||||
{
|
||||
int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;
|
||||
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try
|
||||
{
|
||||
SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
{
|
||||
}
|
||||
|
||||
if ( myStack != null )
|
||||
{
|
||||
if ( myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged()) )
|
||||
currenttip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );
|
||||
|
||||
if ( myStack.getCountRequestable() > 0 )
|
||||
currenttip.add( "\u00a77Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );
|
||||
}
|
||||
else if ( stack.stackSize > BigNumber || (stack.stackSize > 1 && stack.isItemDamaged()) )
|
||||
{
|
||||
currenttip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
// Vanilla version...
|
||||
// protected void drawItemStackTooltip(ItemStack stack, int x, int y)
|
||||
@Override
|
||||
protected void renderToolTip(ItemStack stack, int x, int y)
|
||||
{
|
||||
Slot s = getSlot( x, y );
|
||||
if ( s instanceof SlotME && stack != null )
|
||||
{
|
||||
int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;
|
||||
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try
|
||||
{
|
||||
SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
{
|
||||
}
|
||||
|
||||
if ( myStack != null )
|
||||
{
|
||||
List currenttip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
|
||||
|
||||
if ( myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged()) )
|
||||
currenttip.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );
|
||||
|
||||
if ( myStack.getCountRequestable() > 0 )
|
||||
currenttip.add( "Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );
|
||||
|
||||
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
|
||||
}
|
||||
else if ( stack != null && stack.stackSize > BigNumber )
|
||||
{
|
||||
List var4 = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
|
||||
var4.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
|
||||
drawTooltip( x, y, 0, join( var4, "\n" ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.renderToolTip( stack, x, y );
|
||||
// super.drawItemStackTooltip( stack, x, y );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class GuiNull extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiNull(Container container) {
|
||||
super( container );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.client.gui.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import cpw.mods.fml.client.config.GuiConfig;
|
||||
import cpw.mods.fml.client.config.IConfigElement;
|
||||
|
||||
public class AEConfigGui extends GuiConfig
|
||||
{
|
||||
|
||||
private static List<IConfigElement> getConfigElements()
|
||||
{
|
||||
List<IConfigElement> list = new ArrayList<IConfigElement>();
|
||||
|
||||
for (String cat : AEConfig.instance.getCategoryNames())
|
||||
{
|
||||
if ( cat.equals( "versionchecker" ) )
|
||||
continue;
|
||||
|
||||
if ( cat.equals( "settings" ) )
|
||||
continue;
|
||||
|
||||
ConfigCategory cc = AEConfig.instance.getCategory( cat );
|
||||
|
||||
if ( cc.isChild() )
|
||||
continue;
|
||||
|
||||
ConfigElement ce = new ConfigElement( cc );
|
||||
list.add( ce );
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public AEConfigGui(GuiScreen parent) {
|
||||
super( parent, getConfigElements(), AppEng.modid, false, false, GuiConfig.getAbridgedConfigPath( AEConfig.instance.getFilePath() ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package appeng.client.gui.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
|
||||
public class AEConfigGuiFactory implements IModGuiFactory
|
||||
{
|
||||
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass()
|
||||
{
|
||||
return AEConfigGui.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.CopyMode;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiCellWorkbench extends GuiUpgradeable
|
||||
{
|
||||
|
||||
ContainerCellWorkbench ccwb;
|
||||
TileCellWorkbench tcw;
|
||||
|
||||
GuiImgButton clear;
|
||||
GuiImgButton partition;
|
||||
GuiToggleButton copyMode;
|
||||
|
||||
public GuiCellWorkbench(InventoryPlayer inventoryPlayer, TileCellWorkbench te) {
|
||||
super( new ContainerCellWorkbench( inventoryPlayer, te ) );
|
||||
ccwb = (ContainerCellWorkbench) inventorySlots;
|
||||
ySize = 251;
|
||||
tcw = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawUpgrades()
|
||||
{
|
||||
return ccwb.availableUpgrades() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
handleButtonVisibility();
|
||||
|
||||
bindTexture( getBackground() );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, ySize );
|
||||
if ( drawUpgrades() )
|
||||
{
|
||||
if ( ccwb.availableUpgrades() <= 8 )
|
||||
{
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + ccwb.availableUpgrades() * 18 );
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY + (7 + (ccwb.availableUpgrades()) * 18), 177, 151, 35, 7 );
|
||||
}
|
||||
else if ( ccwb.availableUpgrades() <= 16 )
|
||||
{
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18 );
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7 );
|
||||
|
||||
int dx = ccwb.availableUpgrades() - 8;
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18 );
|
||||
if ( dx == 8 )
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7 );
|
||||
else
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151, 35 - 8, 7 );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18 );
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7 );
|
||||
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + 8 * 18 );
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY + (7 + (8) * 18), 186, 151, 35 - 8, 7 );
|
||||
|
||||
int dx = ccwb.availableUpgrades() - 16;
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18 );
|
||||
if ( dx == 8 )
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7 );
|
||||
else
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27 + 18 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151, 35 - 8, 7 );
|
||||
}
|
||||
}
|
||||
if ( hasToolbox() )
|
||||
this.drawTexturedModalRect( offsetX + 178, offsetY + ySize - 90, 178, 161, 68, 68 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( btn == copyMode )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "CopyMode" ) );
|
||||
}
|
||||
else if ( btn == partition )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
|
||||
}
|
||||
else if ( btn == clear )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Clear" ) );
|
||||
}
|
||||
else if ( btn == fuzzyMode )
|
||||
{
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
FuzzyMode fz = (FuzzyMode) fuzzyMode.getCurrentValue();
|
||||
fz = Platform.rotateEnum( fz, backwards, Settings.FUZZY_MODE.getPossibleValues() );
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) );
|
||||
}
|
||||
else
|
||||
super.actionPerformed( btn );
|
||||
}
|
||||
catch (IOException err)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
clear = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
partition = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
|
||||
copyMode = new GuiToggleButton( this.guiLeft - 18, guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc.getLocal() );
|
||||
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
|
||||
buttonList.add( fuzzyMode );
|
||||
buttonList.add( partition );
|
||||
buttonList.add( clear );
|
||||
buttonList.add( copyMode );
|
||||
}
|
||||
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
copyMode.setState( ccwb.copyMode == CopyMode.CLEAR_ON_REMOVE );
|
||||
|
||||
boolean hasFuzzy = false;
|
||||
IInventory inv = ccwb.getCellUpgradeInventory();
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack is = inv.getStackInSlot( x );
|
||||
if ( is != null && is.getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
if ( ((IUpgradeModule) is.getItem()).getType( is ) == Upgrades.FUZZY )
|
||||
hasFuzzy = true;
|
||||
}
|
||||
}
|
||||
fuzzyMode.setVisibility( hasFuzzy );
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/cellworkbench.png";
|
||||
}
|
||||
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.CellWorkbench;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.tile.storage.TileChest;
|
||||
|
||||
public class GuiChest extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiTabButton priority;
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton)
|
||||
{
|
||||
super.actionPerformed( par1GuiButton );
|
||||
|
||||
if ( par1GuiButton == priority )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
|
||||
}
|
||||
|
||||
public GuiChest(InventoryPlayer inventoryPlayer, TileChest te) {
|
||||
super( new ContainerChest( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/chest.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Chest.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerCondenser;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
|
||||
public class GuiCondenser extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerCondenser cvc;
|
||||
GuiProgressBar pb;
|
||||
GuiImgButton mode;
|
||||
|
||||
public GuiCondenser(InventoryPlayer inventoryPlayer, TileCondenser te) {
|
||||
super( new ContainerCondenser( inventoryPlayer, te ) );
|
||||
cvc = (ContainerCondenser) inventorySlots;
|
||||
this.ySize = 197;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( mode == btn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.CONDENSER_OUTPUT, backwards ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
pb = new GuiProgressBar( "guis/condenser.png", 120 + guiLeft, 25 + guiTop, 178, 25, 6, 18, Direction.VERTICAL );
|
||||
pb.TitleName = GuiText.StoredEnergy.getLocal();
|
||||
|
||||
mode = new GuiImgButton( 128 + guiLeft, 52 + guiTop, Settings.CONDENSER_OUTPUT, cvc.output );
|
||||
|
||||
this.buttonList.add( pb );
|
||||
this.buttonList.add( mode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/condenser.png" );
|
||||
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Condenser.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
mode.set( cvc.output );
|
||||
mode.FillVar = "" + cvc.output.requiredPower;
|
||||
|
||||
pb.max = (int) cvc.requiredEnergy;
|
||||
pb.current = (int) cvc.storedPower;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCraftRequest;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
|
||||
public class GuiCraftAmount extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiNumberBox amountToCraft;
|
||||
GuiTabButton originalGuiBtn;
|
||||
|
||||
GuiButton next;
|
||||
|
||||
GuiButton plus1, plus10, plus100, plus1000;
|
||||
GuiButton minus1, minus10, minus100, minus1000;
|
||||
|
||||
GuiBridge OriginalGui;
|
||||
|
||||
public GuiCraftAmount(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( new ContainerCraftAmount( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
int a = AEConfig.instance.craftItemsByStackAmounts( 0 );
|
||||
int b = AEConfig.instance.craftItemsByStackAmounts( 1 );
|
||||
int c = AEConfig.instance.craftItemsByStackAmounts( 2 );
|
||||
int d = AEConfig.instance.craftItemsByStackAmounts( 3 );
|
||||
|
||||
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a ) );
|
||||
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b ) );
|
||||
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c ) );
|
||||
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d ) );
|
||||
|
||||
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a ) );
|
||||
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b ) );
|
||||
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c ) );
|
||||
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d ) );
|
||||
|
||||
buttonList.add( next = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) );
|
||||
|
||||
ItemStack myIcon = null;
|
||||
Object target = ((AEBaseContainer) inventorySlots).getTarget();
|
||||
|
||||
if ( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
myIcon = AEApi.instance().items().itemWirelessTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if ( target instanceof PartTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if ( target instanceof PartCraftingTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partCraftingTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if ( target instanceof PartPatternTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partPatternTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if ( OriginalGui != null )
|
||||
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||
|
||||
amountToCraft = new GuiNumberBox( fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, fontRendererObj.FONT_HEIGHT, Integer.class );
|
||||
amountToCraft.setEnableBackgroundDrawing( false );
|
||||
amountToCraft.setMaxStringLength( 16 );
|
||||
amountToCraft.setTextColor( 0xFFFFFF );
|
||||
amountToCraft.setVisible( true );
|
||||
amountToCraft.setFocused( true );
|
||||
amountToCraft.setText( "1" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if ( btn == originalGuiBtn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
|
||||
}
|
||||
|
||||
if ( btn == next )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
|
||||
}
|
||||
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// nope..
|
||||
amountToCraft.setText( "1" );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
boolean isPlus = btn == plus1 || btn == plus10 || btn == plus100 || btn == plus1000;
|
||||
boolean isMinus = btn == minus1 || btn == minus10 || btn == minus100 || btn == minus1000;
|
||||
|
||||
if ( isPlus || isMinus )
|
||||
addQty( getQty( btn ) );
|
||||
}
|
||||
|
||||
private void addQty(int i)
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = amountToCraft.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
amountToCraft.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
long result = Integer.parseInt( Out );
|
||||
|
||||
if ( result == 1 && i > 1 )
|
||||
result = 0;
|
||||
|
||||
result += i;
|
||||
if ( result < 1 )
|
||||
result = 1;
|
||||
|
||||
Out = Long.toString( result );
|
||||
Integer.parseInt( Out );
|
||||
amountToCraft.setText( Out );
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( key == 28 )
|
||||
{
|
||||
actionPerformed( next );
|
||||
}
|
||||
if ( (key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ))
|
||||
&& amountToCraft.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = amountToCraft.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
amountToCraft.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
long result = Long.parseLong( Out );
|
||||
if ( result < 0 )
|
||||
{
|
||||
amountToCraft.setText( "1" );
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
|
||||
|
||||
bindTexture( "guis/craftAmt.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
|
||||
try
|
||||
{
|
||||
Long.parseLong( amountToCraft.getText() );
|
||||
next.enabled = amountToCraft.getText().length() > 0;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
next.enabled = false;
|
||||
}
|
||||
|
||||
amountToCraft.drawTextBox();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,519 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
public class GuiCraftConfirm extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerCraftConfirm ccc;
|
||||
|
||||
int rows = 5;
|
||||
|
||||
IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
||||
IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
||||
IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
|
||||
|
||||
List<IAEItemStack> visual = new ArrayList();
|
||||
|
||||
GuiBridge OriginalGui;
|
||||
|
||||
boolean isAutoStart()
|
||||
{
|
||||
return ((ContainerCraftConfirm) inventorySlots).autoStart;
|
||||
}
|
||||
|
||||
boolean isSimulation()
|
||||
{
|
||||
return ((ContainerCraftConfirm) inventorySlots).simulation;
|
||||
}
|
||||
|
||||
public GuiCraftConfirm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( new ContainerCraftConfirm( inventoryPlayer, te ) );
|
||||
xSize = 238;
|
||||
ySize = 206;
|
||||
myScrollBar = new GuiScrollbar();
|
||||
|
||||
ccc = (ContainerCraftConfirm) this.inventorySlots;
|
||||
|
||||
if ( te instanceof WirelessTerminalGuiObject )
|
||||
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
|
||||
if ( te instanceof PartTerminal )
|
||||
OriginalGui = GuiBridge.GUI_ME;
|
||||
|
||||
if ( te instanceof PartCraftingTerminal )
|
||||
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
|
||||
if ( te instanceof PartPatternTerminal )
|
||||
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
|
||||
}
|
||||
|
||||
GuiButton cancel;
|
||||
GuiButton start;
|
||||
GuiButton selectcpu;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
start = new GuiButton( 0, this.guiLeft + 162, this.guiTop + ySize - 25, 50, 20, GuiText.Start.getLocal() );
|
||||
start.enabled = false;
|
||||
buttonList.add( start );
|
||||
|
||||
selectcpu = new GuiButton( 0, this.guiLeft + (219 - 180) / 2, this.guiTop + ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": "
|
||||
+ GuiText.Automatic );
|
||||
selectcpu.enabled = false;
|
||||
buttonList.add( selectcpu );
|
||||
|
||||
if ( OriginalGui != null )
|
||||
cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
|
||||
|
||||
buttonList.add( cancel );
|
||||
}
|
||||
|
||||
private void updateCPUButtonText()
|
||||
{
|
||||
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
|
||||
if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
|
||||
{
|
||||
if ( ccc.myName.length() > 0 )
|
||||
{
|
||||
String name = ccc.myName.substring( 0, Math.min( 20, ccc.myName.length() ) );
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
|
||||
}
|
||||
else
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + ccc.selectedCpu;
|
||||
}
|
||||
|
||||
if ( ccc.noCPU )
|
||||
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
||||
|
||||
selectcpu.displayString = btnTextText;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == selectcpu )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( btn == cancel )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( btn == start )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) );
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private long getTotal(IAEItemStack is)
|
||||
{
|
||||
IAEItemStack a = storage.findPrecise( is );
|
||||
IAEItemStack c = pending.findPrecise( is );
|
||||
IAEItemStack m = missing.findPrecise( is );
|
||||
|
||||
long total = 0;
|
||||
|
||||
if ( a != null )
|
||||
total += a.getStackSize();
|
||||
|
||||
if ( c != null )
|
||||
total += c.getStackSize();
|
||||
|
||||
if ( m != null )
|
||||
total += m.getStackSize();
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list, byte ref)
|
||||
{
|
||||
switch (ref)
|
||||
{
|
||||
case 0:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( storage, l );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( pending, l );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( missing, l );
|
||||
break;
|
||||
}
|
||||
|
||||
for (IAEItemStack l : list)
|
||||
{
|
||||
long amt = getTotal( l );
|
||||
|
||||
if ( amt <= 0 )
|
||||
deleteVisualStack( l );
|
||||
else
|
||||
{
|
||||
IAEItemStack is = findVisualStack( l );
|
||||
is.setStackSize( amt );
|
||||
}
|
||||
}
|
||||
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(IItemList<IAEItemStack> s, IAEItemStack l)
|
||||
{
|
||||
IAEItemStack a = s.findPrecise( l );
|
||||
|
||||
if ( l.getStackSize() <= 0 )
|
||||
{
|
||||
if ( a != null )
|
||||
a.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( a == null )
|
||||
{
|
||||
s.add( l.copy() );
|
||||
a = s.findPrecise( l );
|
||||
}
|
||||
|
||||
if ( a != null )
|
||||
a.setStackSize( l.getStackSize() );
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack(IAEItemStack l)
|
||||
{
|
||||
Iterator<IAEItemStack> i = visual.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
IAEItemStack o = i.next();
|
||||
if ( o.equals( l ) )
|
||||
return o;
|
||||
}
|
||||
|
||||
IAEItemStack stack = l.copy();
|
||||
visual.add( stack );
|
||||
return stack;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(IAEItemStack l)
|
||||
{
|
||||
Iterator<IAEItemStack> i = visual.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
IAEItemStack o = i.next();
|
||||
if ( o.equals( l ) )
|
||||
{
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
int size = visual.size();
|
||||
|
||||
myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 114 );
|
||||
myScrollBar.setRange( 0, (size + 2) / 3 - rows, 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( key == 28 )
|
||||
{
|
||||
actionPerformed( start );
|
||||
}
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
setScrollBar();
|
||||
bindTexture( "guis/craftingreport.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
int tooltip = -1;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
updateCPUButtonText();
|
||||
|
||||
start.enabled = ccc.noCPU || isSimulation() ? false : true;
|
||||
selectcpu.enabled = isSimulation() ? false : true;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
int gx = (width - xSize) / 2;
|
||||
int gy = (height - ySize) / 2;
|
||||
int yoff = 23;
|
||||
|
||||
tooltip = -1;
|
||||
|
||||
for (int z = 0; z <= 4 * 5; z++)
|
||||
{
|
||||
int minX = gx + 9 + x * 67;
|
||||
int minY = gy + 22 + y * yoff;
|
||||
|
||||
if ( minX < mouse_x && minX + 67 > mouse_x )
|
||||
{
|
||||
if ( minY < mouse_y && minY + yoff - 2 > mouse_y )
|
||||
{
|
||||
tooltip = z;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
long BytesUsed = ccc.bytesUsed;
|
||||
String byteUsed = NumberFormat.getInstance().format( BytesUsed );
|
||||
String Add = BytesUsed > 0 ? (byteUsed + " " + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal();
|
||||
fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 );
|
||||
|
||||
String dsp = null;
|
||||
|
||||
if ( isSimulation() )
|
||||
dsp = GuiText.Simulation.getLocal();
|
||||
else
|
||||
dsp = ccc.cpuBytesAvail > 0 ? (GuiText.Bytes.getLocal() + ": " + ccc.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + ccc.cpuCoProcessors)
|
||||
: GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
|
||||
|
||||
int offset = (219 - fontRendererObj.getStringWidth( dsp )) / 2;
|
||||
fontRendererObj.drawString( dsp, offset, 165, 4210752 );
|
||||
|
||||
int sectionLength = 67;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int xo = 0 + 9;
|
||||
int yo = 0 + 22;
|
||||
int viewStart = myScrollBar.getCurrentScroll() * 3;
|
||||
int viewEnd = viewStart + 3 * rows;
|
||||
|
||||
String dspToolTip = "";
|
||||
List<String> lineList = new LinkedList();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
int offY = 23;
|
||||
|
||||
for (int z = viewStart; z < Math.min( viewEnd, visual.size() ); z++)
|
||||
{
|
||||
IAEItemStack refStack = visual.get( z );// repo.getReferenceItem( z );
|
||||
if ( refStack != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( 0.5, 0.5, 0.5 );
|
||||
|
||||
IAEItemStack stored = storage.findPrecise( refStack );
|
||||
IAEItemStack pendingStack = pending.findPrecise( refStack );
|
||||
IAEItemStack missingStack = missing.findPrecise( refStack );
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if ( stored != null && stored.getStackSize() > 0 )
|
||||
lines++;
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
lines++;
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
lines++;
|
||||
|
||||
int negY = ((lines - 1) * 5) / 2;
|
||||
int downY = 0;
|
||||
boolean red = false;
|
||||
|
||||
if ( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( stored.getStackSize() );
|
||||
if ( stored.getStackSize() >= 10000 )
|
||||
str = Long.toString( stored.getStackSize() / 1000 ) + "k";
|
||||
if ( stored.getStackSize() >= 10000000 )
|
||||
str = Long.toString( stored.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.FromStorage.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if ( missingStack != null && missingStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( missingStack.getStackSize() );
|
||||
if ( missingStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( missingStack.getStackSize() / 1000 ) + "k";
|
||||
if ( missingStack.getStackSize() >= 10000000 )
|
||||
str = Long.toString( missingStack.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.Missing.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) );
|
||||
|
||||
red = true;
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( pendingStack.getStackSize() );
|
||||
if ( pendingStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000 ) + "k";
|
||||
if ( pendingStack.getStackSize() >= 10000000 )
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.ToCraft.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
|
||||
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
|
||||
int posY = y * offY + yo;
|
||||
|
||||
ItemStack is = refStack.copy().getItemStack();
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
{
|
||||
dspToolTip = Platform.getItemDisplayName( is );
|
||||
|
||||
if ( lineList.size() > 0 )
|
||||
dspToolTip = dspToolTip + "\n" + Joiner.on( "\n" ).join( lineList );
|
||||
|
||||
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
}
|
||||
|
||||
drawItem( posX, posY, is );
|
||||
|
||||
if ( red )
|
||||
{
|
||||
int startX = x * (1 + sectionLength) + xo;
|
||||
int startY = posY - 4;
|
||||
drawRect( startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000 );
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( tooltip >= 0 && dspToolTip.length() > 0 )
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
{
|
||||
|
||||
int rows = 6;
|
||||
|
||||
IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
||||
IItemList<IAEItemStack> active = AEApi.instance().storage().createItemList();
|
||||
IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
||||
|
||||
List<IAEItemStack> visual = new ArrayList();
|
||||
|
||||
public void clearItems()
|
||||
{
|
||||
storage = AEApi.instance().storage().createItemList();
|
||||
active = AEApi.instance().storage().createItemList();
|
||||
pending = AEApi.instance().storage().createItemList();
|
||||
visual = new ArrayList();
|
||||
}
|
||||
|
||||
protected GuiCraftingCPU(ContainerCraftingCPU container) {
|
||||
super( container );
|
||||
this.ySize = 184;
|
||||
this.xSize = 238;
|
||||
myScrollBar = new GuiScrollbar();
|
||||
}
|
||||
|
||||
public GuiCraftingCPU(InventoryPlayer inventoryPlayer, Object te) {
|
||||
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
GuiButton cancel;
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if ( cancel == btn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
setScrollBar();
|
||||
cancel = new GuiButton( 0, this.guiLeft + 163, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
|
||||
buttonList.add( cancel );
|
||||
}
|
||||
|
||||
private long getTotal(IAEItemStack is)
|
||||
{
|
||||
IAEItemStack a = storage.findPrecise( is );
|
||||
IAEItemStack b = active.findPrecise( is );
|
||||
IAEItemStack c = pending.findPrecise( is );
|
||||
|
||||
long total = 0;
|
||||
|
||||
if ( a != null )
|
||||
total += a.getStackSize();
|
||||
|
||||
if ( b != null )
|
||||
total += b.getStackSize();
|
||||
|
||||
if ( c != null )
|
||||
total += c.getStackSize();
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list, byte ref)
|
||||
{
|
||||
switch (ref)
|
||||
{
|
||||
case 0:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( storage, l );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( active, l );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( pending, l );
|
||||
break;
|
||||
}
|
||||
|
||||
for (IAEItemStack l : list)
|
||||
{
|
||||
long amt = getTotal( l );
|
||||
|
||||
if ( amt <= 0 )
|
||||
deleteVisualStack( l );
|
||||
else
|
||||
{
|
||||
IAEItemStack is = findVisualStack( l );
|
||||
is.setStackSize( amt );
|
||||
}
|
||||
}
|
||||
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(IItemList<IAEItemStack> s, IAEItemStack l)
|
||||
{
|
||||
IAEItemStack a = s.findPrecise( l );
|
||||
|
||||
if ( l.getStackSize() <= 0 )
|
||||
{
|
||||
if ( a != null )
|
||||
a.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( a == null )
|
||||
{
|
||||
s.add( l.copy() );
|
||||
a = s.findPrecise( l );
|
||||
}
|
||||
|
||||
if ( a != null )
|
||||
a.setStackSize( l.getStackSize() );
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack(IAEItemStack l)
|
||||
{
|
||||
Iterator<IAEItemStack> i = visual.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
IAEItemStack o = i.next();
|
||||
if ( o.equals( l ) )
|
||||
return o;
|
||||
}
|
||||
|
||||
IAEItemStack stack = l.copy();
|
||||
visual.add( stack );
|
||||
return stack;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(IAEItemStack l)
|
||||
{
|
||||
Iterator<IAEItemStack> i = visual.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
IAEItemStack o = i.next();
|
||||
if ( o.equals( l ) )
|
||||
{
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
int size = visual.size();
|
||||
|
||||
myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 137 );
|
||||
myScrollBar.setRange( 0, (size + 2) / 3 - rows, 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/craftingcpu.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
int tooltip = -1;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
cancel.enabled = !visual.isEmpty();
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
int gx = (width - xSize) / 2;
|
||||
int gy = (height - ySize) / 2;
|
||||
int yoff = 23;
|
||||
|
||||
tooltip = -1;
|
||||
|
||||
for (int z = 0; z <= 4 * 5; z++)
|
||||
{
|
||||
int minX = gx + 9 + x * 67;
|
||||
int minY = gy + 22 + y * yoff;
|
||||
|
||||
if ( minX < mouse_x && minX + 67 > mouse_x )
|
||||
{
|
||||
if ( minY < mouse_y && minY + yoff - 2 > mouse_y )
|
||||
{
|
||||
tooltip = z;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.CraftingStatus.getLocal() ), 8, 7, 4210752 );
|
||||
|
||||
int sectionLength = 67;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int xo = 0 + 9;
|
||||
int yo = 0 + 22;
|
||||
int viewStart = myScrollBar.getCurrentScroll() * 3;
|
||||
int viewEnd = viewStart + 3 * 6;
|
||||
|
||||
String dspToolTip = "";
|
||||
List<String> lineList = new LinkedList();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
int offY = 23;
|
||||
|
||||
for (int z = viewStart; z < Math.min( viewEnd, visual.size() ); z++)
|
||||
{
|
||||
IAEItemStack refStack = visual.get( z );// repo.getReferenceItem( z );
|
||||
if ( refStack != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( 0.5, 0.5, 0.5 );
|
||||
|
||||
IAEItemStack stored = storage.findPrecise( refStack );
|
||||
IAEItemStack activeStack = active.findPrecise( refStack );
|
||||
IAEItemStack pendingStack = pending.findPrecise( refStack );
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if ( stored != null && stored.getStackSize() > 0 )
|
||||
lines++;
|
||||
if ( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
lines++;
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
lines++;
|
||||
|
||||
int negY = ((lines - 1) * 5) / 2;
|
||||
int downY = 0;
|
||||
|
||||
if ( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( stored.getStackSize() );
|
||||
if ( stored.getStackSize() >= 10000 )
|
||||
str = Long.toString( stored.getStackSize() / 1000 ) + "k";
|
||||
if ( stored.getStackSize() >= 10000000 )
|
||||
str = Long.toString( stored.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.Stored.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if ( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( activeStack.getStackSize() );
|
||||
if ( activeStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( activeStack.getStackSize() / 1000 ) + "k";
|
||||
if ( activeStack.getStackSize() >= 10000000 )
|
||||
str = Long.toString( activeStack.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.Crafting.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) );
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( pendingStack.getStackSize() );
|
||||
if ( pendingStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000 ) + "k";
|
||||
if ( pendingStack.getStackSize() >= 10000000 )
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.Scheduled.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
|
||||
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
|
||||
int posY = y * offY + yo;
|
||||
|
||||
ItemStack is = refStack.copy().getItemStack();
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
{
|
||||
dspToolTip = Platform.getItemDisplayName( is );
|
||||
|
||||
if ( lineList.size() > 0 )
|
||||
dspToolTip = dspToolTip + "\n" + Joiner.on( "\n" ).join( lineList );
|
||||
|
||||
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
}
|
||||
|
||||
drawItem( posX, posY, is );
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( tooltip >= 0 && dspToolTip.length() > 0 )
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDir()
|
||||
{
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDisplay()
|
||||
{
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
|
||||
public class GuiCraftingStatus extends GuiCraftingCPU
|
||||
{
|
||||
|
||||
ContainerCraftingStatus ccc;
|
||||
GuiButton selectcpu;
|
||||
|
||||
GuiTabButton originalGuiBtn;
|
||||
GuiBridge OriginalGui;
|
||||
ItemStack myIcon = null;
|
||||
|
||||
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( new ContainerCraftingStatus( inventoryPlayer, te ) );
|
||||
|
||||
ccc = (ContainerCraftingStatus) inventorySlots;
|
||||
Object target = ccc.getTarget();
|
||||
|
||||
if ( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
myIcon = AEApi.instance().items().itemWirelessTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if ( target instanceof PartTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if ( target instanceof PartCraftingTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partCraftingTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if ( target instanceof PartPatternTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partPatternTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == selectcpu )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( btn == originalGuiBtn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGuiDisplayName(String in)
|
||||
{
|
||||
return in; // the cup name is on the button
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
selectcpu = new GuiButton( 0, this.guiLeft + 8, this.guiTop + ySize - 25, 150, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.NoCraftingCPUs );
|
||||
// selectcpu.enabled = false;
|
||||
buttonList.add( selectcpu );
|
||||
|
||||
if ( myIcon != null )
|
||||
{
|
||||
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||
originalGuiBtn.hideEdge = 13;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCPUButtonText()
|
||||
{
|
||||
String btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
|
||||
if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
|
||||
{
|
||||
if ( ccc.myName.length() > 0 )
|
||||
{
|
||||
String name = ccc.myName.substring( 0, Math.min( 20, ccc.myName.length() ) );
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
|
||||
}
|
||||
else
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": #" + ccc.selectedCpu;
|
||||
}
|
||||
|
||||
if ( ccc.noCPU )
|
||||
btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
|
||||
selectcpu.displayString = btnTextText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
updateCPUButtonText();
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.helpers.InventoryAction;
|
||||
|
||||
public class GuiCraftingTerm extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
GuiImgButton clearBtn;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
buttonList.add( clearBtn = new GuiImgButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, Settings.ACTIONS, ActionItems.STASH ) );
|
||||
clearBtn.halfSize = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if ( clearBtn == btn )
|
||||
{
|
||||
Slot s = null;
|
||||
Container c = inventorySlots;
|
||||
for (Object j : c.inventorySlots)
|
||||
{
|
||||
if ( j instanceof SlotCraftingMatrix )
|
||||
s = (Slot) j;
|
||||
}
|
||||
|
||||
if ( s != null )
|
||||
{
|
||||
PacketInventoryAction p;
|
||||
try
|
||||
{
|
||||
p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GuiCraftingTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( inventoryPlayer, te, new ContainerCraftingTerm( inventoryPlayer, te ) );
|
||||
reservedSpace = 73;
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/crafting.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
fontRendererObj.drawString( GuiText.CraftingTerminal.getLocal(), 8, ySize - 96 + 1 - reservedSpace, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
|
||||
public class GuiDrive extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiTabButton priority;
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton)
|
||||
{
|
||||
super.actionPerformed( par1GuiButton );
|
||||
|
||||
if ( par1GuiButton == priority )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
|
||||
}
|
||||
|
||||
public GuiDrive(InventoryPlayer inventoryPlayer, TileDrive te) {
|
||||
super( new ContainerDrive( inventoryPlayer, te ) );
|
||||
this.ySize = 199;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/drive.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Drive.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerFormationPlane;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
|
||||
public class GuiFormationPlane extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiTabButton priority;
|
||||
|
||||
public GuiFormationPlane(InventoryPlayer inventoryPlayer, PartFormationPlane te) {
|
||||
super( new ContainerFormationPlane( inventoryPlayer, te ) );
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.FormationPlane.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
if ( fuzzyMode != null )
|
||||
fuzzyMode.set( cvb.fzMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
|
||||
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
|
||||
|
||||
buttonList.add( fuzzyMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if ( btn == priority )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerGrinder;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
|
||||
public class GuiGrinder extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiGrinder(InventoryPlayer inventoryPlayer, TileGrinder te) {
|
||||
super( new ContainerGrinder( inventoryPlayer, te ) );
|
||||
this.ySize = 176;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/grinder.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.GrindStone.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerIOPort;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
|
||||
public class GuiIOPort extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiImgButton fullMode;
|
||||
GuiImgButton operationMode;
|
||||
|
||||
public GuiIOPort(InventoryPlayer inventoryPlayer, TileIOPort te) {
|
||||
super( new ContainerIOPort( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
this.drawItem( offsetX + 66 - 8, offsetY + 17, AEApi.instance().items().itemCell1k.stack( 1 ) );
|
||||
this.drawItem( offsetX + 94 + 8, offsetY + 17, AEApi.instance().blocks().blockDrive.stack( 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.IOPort.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
if ( redstoneMode != null )
|
||||
redstoneMode.set( cvb.rsMode );
|
||||
|
||||
if ( operationMode != null )
|
||||
operationMode.set( ((ContainerIOPort) cvb).opMode );
|
||||
|
||||
if ( fullMode != null )
|
||||
fullMode.set( ((ContainerIOPort) cvb).fMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
fullMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY );
|
||||
operationMode = new GuiImgButton( this.guiLeft + 80, guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY );
|
||||
|
||||
buttonList.add( operationMode );
|
||||
buttonList.add( redstoneMode );
|
||||
buttonList.add( fullMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == fullMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( fullMode.getSetting(), backwards ) );
|
||||
|
||||
if ( btn == operationMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( operationMode.getSetting(), backwards ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/ioport.png";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
|
||||
public class GuiInscriber extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerInscriber cvc;
|
||||
GuiProgressBar pb;
|
||||
|
||||
public GuiInscriber(InventoryPlayer inventoryPlayer, TileInscriber te) {
|
||||
super( new ContainerInscriber( inventoryPlayer, te ) );
|
||||
cvc = (ContainerInscriber) inventorySlots;
|
||||
this.ySize = 176;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
pb = new GuiProgressBar( "guis/inscriber.png", 135, 39, 179, 39, 6, 18, Direction.VERTICAL );
|
||||
this.buttonList.add( pb );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/inscriber.png" );
|
||||
pb.xPosition = 135 + guiLeft;
|
||||
pb.yPosition = 39 + guiTop;
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
pb.max = cvc.maxProcessingTime;
|
||||
pb.current = cvc.processingTime;
|
||||
pb.FullMsg = (pb.current * 100 / pb.max) + "%";
|
||||
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Inscriber.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
|
||||
public class GuiInterface extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiTabButton priority;
|
||||
GuiImgButton BlockMode;
|
||||
GuiToggleButton interfaceMode;
|
||||
|
||||
public GuiInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
|
||||
super( new ContainerInterface( inventoryPlayer, te ) );
|
||||
this.ySize = 211;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == priority )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == interfaceMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
|
||||
|
||||
if ( btn == BlockMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( BlockMode.getSetting(), backwards ) );
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender );
|
||||
buttonList.add( priority );
|
||||
|
||||
BlockMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.BLOCK, YesNo.NO );
|
||||
buttonList.add( BlockMode );
|
||||
|
||||
interfaceMode = new GuiToggleButton( this.guiLeft - 18, guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(),
|
||||
GuiText.InterfaceTerminalHint.getLocal() );
|
||||
buttonList.add( interfaceMode );
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/interface.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
if ( BlockMode != null )
|
||||
BlockMode.set( ((ContainerInterface) cvb).bMode );
|
||||
|
||||
if ( interfaceMode != null )
|
||||
interfaceMode.setState( ((ContainerInterface) cvb).iTermMode == YesNo.YES );
|
||||
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Interface.getLocal() ), 8, 6, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( GuiText.Config.getLocal(), 18, 6 + 11 + 7, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.StoredItems.getLocal(), 18, 6 + 60 + 7, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.me.ClientDCInternalInv;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.container.implementations.ContainerInterfaceTerminal;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.parts.reporting.PartMonitor;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
||||
public class GuiInterfaceTerminal extends AEBaseGui
|
||||
{
|
||||
|
||||
HashMap<Long, ClientDCInternalInv> byId = new HashMap();
|
||||
HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
|
||||
ArrayList<String> names = new ArrayList();
|
||||
|
||||
ArrayList<Object> lines = new ArrayList();
|
||||
|
||||
private int getTotalRows()
|
||||
{
|
||||
return names.size() + byId.size();// unique names, and each inv row.
|
||||
}
|
||||
|
||||
public GuiInterfaceTerminal(InventoryPlayer inventoryPlayer, PartMonitor te) {
|
||||
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
|
||||
myScrollBar = new GuiScrollbar();
|
||||
xSize = 195;
|
||||
ySize = 222;
|
||||
}
|
||||
|
||||
LinkedList<SlotDisconnected> dcSlots = new LinkedList();
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
myScrollBar.setLeft( 175 );
|
||||
myScrollBar.setHeight( 106 );
|
||||
myScrollBar.setTop( 18 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/interfaceterminal.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
|
||||
int offset = 17;
|
||||
int ex = myScrollBar.getCurrentScroll();
|
||||
int linesOnPage = 6;
|
||||
|
||||
for (int x = 0; x < linesOnPage; x++)
|
||||
{
|
||||
if ( ex + x < lines.size() )
|
||||
{
|
||||
Object lineObj = lines.get( ex + x );
|
||||
if ( lineObj instanceof ClientDCInternalInv )
|
||||
{
|
||||
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
|
||||
GL11.glColor4f( 1, 1, 1, 1 );
|
||||
for (int z = 0; z < inv.inv.getSizeInventory(); z++)
|
||||
this.drawTexturedModalRect( offsetX + z * 18 + 7, offsetY + offset, 7, 139, 18, 18 );
|
||||
}
|
||||
}
|
||||
offset += 18;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
int offset = 17;
|
||||
|
||||
// for (String name : lines)
|
||||
int ex = myScrollBar.getCurrentScroll();
|
||||
int linesOnPage = 6;
|
||||
|
||||
Iterator<Object> o = inventorySlots.inventorySlots.iterator();
|
||||
while (o.hasNext())
|
||||
{
|
||||
if ( o.next() instanceof SlotDisconnected )
|
||||
o.remove();
|
||||
}
|
||||
|
||||
for (int x = 0; x < linesOnPage; x++)
|
||||
{
|
||||
if ( ex + x < lines.size() )
|
||||
{
|
||||
Object lineObj = lines.get( ex + x );
|
||||
if ( lineObj instanceof ClientDCInternalInv )
|
||||
{
|
||||
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
for (int z = 0; z < inv.inv.getSizeInventory(); z++)
|
||||
{
|
||||
inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) );
|
||||
}
|
||||
}
|
||||
else if ( lineObj instanceof String )
|
||||
{
|
||||
String name = (String) lineObj;
|
||||
int rows = byName.get( name ).size();
|
||||
if ( rows > 1 )
|
||||
name = name + " (" + rows + ")";
|
||||
|
||||
while (name.length() > 2 && fontRendererObj.getStringWidth( name ) > 155)
|
||||
name = name.substring( 0, name.length() - 1 );
|
||||
|
||||
fontRendererObj.drawString( name, 10, 6 + offset, 4210752 );
|
||||
}
|
||||
offset += 18;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean refreshList = false;
|
||||
|
||||
public void postUpdate(NBTTagCompound in)
|
||||
{
|
||||
if ( in.getBoolean( "clear" ) )
|
||||
{
|
||||
byId.clear();
|
||||
refreshList = true;
|
||||
}
|
||||
|
||||
for (Object oKey : in.func_150296_c())
|
||||
{
|
||||
String key = (String) oKey;
|
||||
if ( key.startsWith( "=" ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX );
|
||||
NBTTagCompound invData = in.getCompoundTag( key );
|
||||
ClientDCInternalInv current = getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
|
||||
|
||||
for (int x = 0; x < current.inv.getSizeInventory(); x++)
|
||||
{
|
||||
String which = Integer.toString( x );
|
||||
if ( invData.hasKey( which ) )
|
||||
current.inv.setInventorySlotContents( x, ItemStack.loadItemStackFromNBT( invData.getCompoundTag( which ) ) );
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( refreshList )
|
||||
{
|
||||
refreshList = false;
|
||||
|
||||
byName.clear();
|
||||
for (ClientDCInternalInv o : byId.values())
|
||||
byName.put( o.getName(), o );
|
||||
|
||||
names.clear();
|
||||
names.addAll( byName.keySet() );
|
||||
|
||||
Collections.sort( names );
|
||||
|
||||
lines = new ArrayList( getTotalRows() );
|
||||
for (String n : names)
|
||||
{
|
||||
lines.add( n );
|
||||
|
||||
ArrayList<ClientDCInternalInv> lset = new ArrayList();
|
||||
lset.addAll( byName.get( n ) );
|
||||
|
||||
Collections.sort( lset );
|
||||
|
||||
for (ClientDCInternalInv i : lset)
|
||||
{
|
||||
lines.add( i );
|
||||
}
|
||||
}
|
||||
|
||||
myScrollBar.setRange( 0, getTotalRows() - 6, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
private ClientDCInternalInv getById(long id, long sortBy, String string)
|
||||
{
|
||||
ClientDCInternalInv o = byId.get( id );
|
||||
|
||||
if ( o == null )
|
||||
{
|
||||
byId.put( id, o = new ClientDCInternalInv( 9, id, sortBy, string ) );
|
||||
refreshList = true;
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.LevelType;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.container.implementations.ContainerLevelEmitter;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
|
||||
public class GuiLevelEmitter extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiNumberBox level;
|
||||
|
||||
GuiButton plus1, plus10, plus100, plus1000;
|
||||
GuiButton minus1, minus10, minus100, minus1000;
|
||||
|
||||
GuiImgButton levelMode;
|
||||
GuiImgButton craftingMode;
|
||||
|
||||
public GuiLevelEmitter(InventoryPlayer inventoryPlayer, PartLevelEmitter te) {
|
||||
super( new ContainerLevelEmitter( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
level = new GuiNumberBox( fontRendererObj, this.guiLeft + 24, this.guiTop + 43, 79, fontRendererObj.FONT_HEIGHT, Long.class );
|
||||
level.setEnableBackgroundDrawing( false );
|
||||
level.setMaxStringLength( 16 );
|
||||
level.setTextColor( 0xFFFFFF );
|
||||
level.setVisible( true );
|
||||
level.setFocused( true );
|
||||
((ContainerLevelEmitter) inventorySlots).setTextField( level );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
levelMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
|
||||
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL );
|
||||
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
craftingMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO );
|
||||
|
||||
int a = AEConfig.instance.levelByStackAmounts( 0 );
|
||||
int b = AEConfig.instance.levelByStackAmounts( 1 );
|
||||
int c = AEConfig.instance.levelByStackAmounts( 2 );
|
||||
int d = AEConfig.instance.levelByStackAmounts( 3 );
|
||||
|
||||
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a ) );
|
||||
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b ) );
|
||||
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c ) );
|
||||
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d ) );
|
||||
|
||||
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a ) );
|
||||
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b ) );
|
||||
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c ) );
|
||||
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d ) );
|
||||
|
||||
buttonList.add( levelMode );
|
||||
buttonList.add( redstoneMode );
|
||||
buttonList.add( fuzzyMode );
|
||||
buttonList.add( craftingMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == craftingMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( craftingMode.getSetting(), backwards ) );
|
||||
|
||||
if ( btn == levelMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( levelMode.getSetting(), backwards ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
boolean isPlus = btn == plus1 || btn == plus10 || btn == plus100 || btn == plus1000;
|
||||
boolean isMinus = btn == minus1 || btn == minus10 || btn == minus100 || btn == minus1000;
|
||||
|
||||
if ( isPlus || isMinus )
|
||||
addQty( getQty( btn ) );
|
||||
}
|
||||
|
||||
private void addQty(long i)
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
level.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
long result = Long.parseLong( Out );
|
||||
result += i;
|
||||
if ( result < 0 )
|
||||
result = 0;
|
||||
|
||||
level.setText( Out = Long.toString( result ) );
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// nope..
|
||||
level.setText( "0" );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
craftingMode.setVisibility( bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
|
||||
fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( (key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit( character )) && level.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
level.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
boolean notCraftingMode = bc.getInstalledUpgrades( Upgrades.CRAFTING ) == 0;
|
||||
|
||||
// configure enabled status...
|
||||
level.setEnabled( notCraftingMode );
|
||||
plus1.enabled = notCraftingMode;
|
||||
plus10.enabled = notCraftingMode;
|
||||
plus100.enabled = notCraftingMode;
|
||||
plus1000.enabled = notCraftingMode;
|
||||
minus1.enabled = notCraftingMode;
|
||||
minus10.enabled = notCraftingMode;
|
||||
minus100.enabled = notCraftingMode;
|
||||
minus1000.enabled = notCraftingMode;
|
||||
levelMode.enabled = notCraftingMode;
|
||||
redstoneMode.enabled = notCraftingMode;
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
|
||||
if ( craftingMode != null )
|
||||
craftingMode.set( ((ContainerLevelEmitter) cvb).cmType );
|
||||
|
||||
if ( levelMode != null )
|
||||
levelMode.set( ((ContainerLevelEmitter) cvb).lvType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
level.drawTextBox();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/lvlemitter.png";
|
||||
}
|
||||
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.LevelEmitter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerMAC;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
|
||||
public class GuiMAC extends GuiUpgradeable
|
||||
{
|
||||
|
||||
ContainerMAC cmac;
|
||||
GuiProgressBar pb;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
pb = new GuiProgressBar( "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL );
|
||||
this.buttonList.add( pb );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
pb.xPosition = 148 + guiLeft;
|
||||
pb.yPosition = 48 + guiTop;
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
pb.max = 100;
|
||||
pb.current = cmac.craftProgress;
|
||||
pb.FullMsg = pb.current + "%";
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
buttonList.add( redstoneMode );
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/mac.png";
|
||||
}
|
||||
|
||||
public GuiMAC(InventoryPlayer inventoryPlayer, TileMolecularAssembler te) {
|
||||
super( new ContainerMAC( inventoryPlayer, te ) );
|
||||
this.ySize = 197;
|
||||
this.cmac = (ContainerMAC) this.inventorySlots;
|
||||
}
|
||||
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.MolecularAssembler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,472 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.tile.misc.TileSecurity;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfigManagerHost
|
||||
{
|
||||
|
||||
GuiTabButton craftingStatusBtn;
|
||||
|
||||
MEGuiTextField searchField;
|
||||
private static String memoryText = "";
|
||||
|
||||
public static int CraftingGridOffsetX;
|
||||
public static int CraftingGridOffsetY;
|
||||
|
||||
ItemRepo repo;
|
||||
|
||||
GuiText myName;
|
||||
|
||||
int xoffset = 9;
|
||||
int perRow = 9;
|
||||
int reservedSpace = 0;
|
||||
int lowerTextureOffset = 0;
|
||||
boolean customSortOrder = true;
|
||||
|
||||
int rows = 0;
|
||||
int maxRows = Integer.MAX_VALUE;
|
||||
|
||||
int standardSize;
|
||||
|
||||
IConfigManager configSrc;
|
||||
|
||||
GuiImgButton ViewBox;
|
||||
GuiImgButton SortByBox;
|
||||
GuiImgButton SortDirBox;
|
||||
|
||||
GuiImgButton searchBoxSettings, terminalStyleBox;
|
||||
boolean viewCell;
|
||||
|
||||
ItemStack myCurrentViewCells[] = new ItemStack[5];
|
||||
ContainerMEMonitorable mecontainer;
|
||||
|
||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
this( inventoryPlayer, te, new ContainerMEMonitorable( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te, ContainerMEMonitorable c) {
|
||||
|
||||
super( c );
|
||||
myScrollBar = new GuiScrollbar();
|
||||
repo = new ItemRepo( myScrollBar, this );
|
||||
|
||||
xSize = 185;
|
||||
ySize = 204;
|
||||
|
||||
if ( te instanceof IViewCellStorage )
|
||||
xSize += 33;
|
||||
|
||||
standardSize = xSize;
|
||||
|
||||
configSrc = ((IConfigurableObject) inventorySlots).getConfigManager();
|
||||
(mecontainer = (ContainerMEMonitorable) inventorySlots).gui = this;
|
||||
|
||||
viewCell = te instanceof IViewCellStorage;
|
||||
|
||||
if ( te instanceof TileSecurity )
|
||||
myName = GuiText.Security;
|
||||
else if ( te instanceof WirelessTerminalGuiObject )
|
||||
myName = GuiText.WirelessTerminal;
|
||||
else if ( te instanceof IPortableCell )
|
||||
myName = GuiText.PortableCell;
|
||||
else if ( te instanceof IMEChest )
|
||||
myName = GuiText.Chest;
|
||||
else if ( te instanceof PartTerminal )
|
||||
myName = GuiText.Terminal;
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list)
|
||||
{
|
||||
for (IAEItemStack is : list)
|
||||
repo.postUpdate( is );
|
||||
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
myScrollBar.setTop( 18 ).setLeft( 175 ).setHeight( rows * 18 - 2 );
|
||||
myScrollBar.setRange( 0, (repo.size() + perRow - 1) / perRow - rows, Math.max( 1, rows / 6 ) );
|
||||
}
|
||||
|
||||
public void re_init()
|
||||
{
|
||||
this.buttonList.clear();
|
||||
this.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed()
|
||||
{
|
||||
super.onGuiClosed();
|
||||
memoryText = searchField.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
maxRows = getMaxRows();
|
||||
perRow = AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ((width - standardSize) / 18);
|
||||
|
||||
boolean hasNEI = AppEng.instance.isIntegrationEnabled( IntegrationType.NEI );
|
||||
|
||||
int NEI = hasNEI ? 0 : 0;
|
||||
int top = hasNEI ? 22 : 0;
|
||||
|
||||
int magicNumber = 114 + 1;
|
||||
int extraSpace = height - magicNumber - NEI - top - reservedSpace;
|
||||
|
||||
rows = (int) Math.floor( extraSpace / 18 );
|
||||
if ( rows > maxRows )
|
||||
{
|
||||
top += (rows - maxRows) * 18 / 2;
|
||||
rows = maxRows;
|
||||
}
|
||||
|
||||
if ( hasNEI )
|
||||
rows--;
|
||||
|
||||
if ( rows < 3 )
|
||||
rows = 3;
|
||||
|
||||
meSlots.clear();
|
||||
for (int y = 0; y < rows; y++)
|
||||
{
|
||||
for (int x = 0; x < perRow; x++)
|
||||
{
|
||||
meSlots.add( new InternalSlotME( repo, x + y * perRow, xoffset + x * 18, 18 + y * 18 ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL )
|
||||
this.xSize = standardSize + ((perRow - 9) * 18);
|
||||
else
|
||||
this.xSize = standardSize;
|
||||
|
||||
super.initGui();
|
||||
// full size : 204
|
||||
// extra slots : 72
|
||||
// slot 18
|
||||
|
||||
this.ySize = magicNumber + rows * 18 + reservedSpace;
|
||||
// this.guiTop = top;
|
||||
int unusedSpace = height - ySize;
|
||||
guiTop = (int) Math.floor( (float) unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f) );
|
||||
|
||||
int offset = guiTop + 8;
|
||||
|
||||
if ( customSortOrder )
|
||||
{
|
||||
buttonList.add( SortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, configSrc.getSetting( Settings.SORT_BY ) ) );
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
if ( viewCell || this instanceof GuiWirelessTerm )
|
||||
{
|
||||
buttonList.add( ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, configSrc.getSetting( Settings.VIEW_MODE ) ) );
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
buttonList.add( SortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, configSrc.getSetting( Settings.SORT_DIRECTION ) ) );
|
||||
offset += 20;
|
||||
|
||||
buttonList.add( searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings
|
||||
.getSetting( Settings.SEARCH_MODE ) ) );
|
||||
offset += 20;
|
||||
|
||||
if ( !(this instanceof GuiMEPortableCell) || this instanceof GuiWirelessTerm )
|
||||
{
|
||||
buttonList.add( terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings
|
||||
.getSetting( Settings.TERMINAL_STYLE ) ) );
|
||||
}
|
||||
|
||||
searchField = new MEGuiTextField( fontRendererObj, this.guiLeft + Math.max( 82, xoffset ), this.guiTop + 6, 89, fontRendererObj.FONT_HEIGHT );
|
||||
searchField.setEnableBackgroundDrawing( false );
|
||||
searchField.setMaxStringLength( 25 );
|
||||
searchField.setTextColor( 0xFFFFFF );
|
||||
searchField.setVisible( true );
|
||||
|
||||
if ( viewCell || this instanceof GuiWirelessTerm )
|
||||
{
|
||||
buttonList.add( craftingStatusBtn = new GuiTabButton( this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(),
|
||||
itemRender ) );
|
||||
craftingStatusBtn.hideEdge = 13;
|
||||
}
|
||||
|
||||
// Enum setting = AEConfig.instance.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
|
||||
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
|
||||
searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
|
||||
|
||||
if ( isSubGui() )
|
||||
{
|
||||
searchField.setText( memoryText );
|
||||
repo.searchString = memoryText;
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
CraftingGridOffsetX = Integer.MAX_VALUE;
|
||||
CraftingGridOffsetY = Integer.MAX_VALUE;
|
||||
|
||||
for (Object s : inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( s instanceof AppEngSlot )
|
||||
{
|
||||
if ( ((AppEngSlot) s).xDisplayPosition < 197 )
|
||||
repositionSlot( (AppEngSlot) s );
|
||||
}
|
||||
|
||||
if ( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix )
|
||||
{
|
||||
Slot g = (Slot) s;
|
||||
if ( g.xDisplayPosition > 0 && g.yDisplayPosition > 0 )
|
||||
{
|
||||
CraftingGridOffsetX = Math.min( CraftingGridOffsetX, g.xDisplayPosition );
|
||||
CraftingGridOffsetY = Math.min( CraftingGridOffsetY, g.yDisplayPosition );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CraftingGridOffsetX -= 25;
|
||||
CraftingGridOffsetY -= 6;
|
||||
}
|
||||
|
||||
protected void repositionSlot(AppEngSlot s)
|
||||
{
|
||||
s.yDisplayPosition = s.defY + ySize - 78 - 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
if ( btn == craftingStatusBtn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( btn instanceof GuiImgButton )
|
||||
{
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
if ( iBtn.getSetting() != Settings.ACTIONS )
|
||||
{
|
||||
Enum cv = iBtn.getCurrentValue();
|
||||
Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
|
||||
|
||||
if ( btn == terminalStyleBox )
|
||||
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
||||
else if ( btn == searchBoxSettings )
|
||||
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
iBtn.set( next );
|
||||
|
||||
if ( next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class )
|
||||
re_init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int xCoord, int yCoord, int btn)
|
||||
{
|
||||
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
|
||||
if ( !(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting) )
|
||||
searchField.mouseClicked( xCoord, yCoord, btn );
|
||||
|
||||
if ( btn == 1 && searchField.isMouseIn( xCoord, yCoord ) )
|
||||
{
|
||||
searchField.setText( "" );
|
||||
repo.searchString = "";
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
super.mouseClicked( xCoord, yCoord, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( character == ' ' && this.searchField.getText().length() == 0 )
|
||||
return;
|
||||
|
||||
if ( searchField.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
repo.searchString = this.searchField.getText();
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
repo.setPower( mecontainer.hasPower );
|
||||
super.updateScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
int x_width = 197;
|
||||
|
||||
bindTexture( getBackground() );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
|
||||
|
||||
if ( viewCell || (this instanceof GuiSecurity) )
|
||||
this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 );
|
||||
|
||||
for (int x = 0; x < rows; x++)
|
||||
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
|
||||
|
||||
this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18 + lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + reservedSpace - lowerTextureOffset );
|
||||
|
||||
if ( viewCell )
|
||||
{
|
||||
boolean update = false;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if ( myCurrentViewCells[i] != mecontainer.cellView[i].getStack() )
|
||||
{
|
||||
update = true;
|
||||
myCurrentViewCells[i] = mecontainer.cellView[i].getStack();
|
||||
}
|
||||
}
|
||||
|
||||
if ( update )
|
||||
repo.setViewCell( myCurrentViewCells );
|
||||
}
|
||||
|
||||
if ( searchField != null )
|
||||
searchField.drawTextBox();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/terminal.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( myName.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return configSrc.getSetting( Settings.SORT_BY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDir()
|
||||
{
|
||||
return configSrc.getSetting( Settings.SORT_DIRECTION );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDisplay()
|
||||
{
|
||||
return configSrc.getSetting( Settings.VIEW_MODE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
if ( SortByBox != null )
|
||||
SortByBox.set( configSrc.getSetting( Settings.SORT_BY ) );
|
||||
|
||||
if ( SortDirBox != null )
|
||||
SortDirBox.set( configSrc.getSetting( Settings.SORT_DIRECTION ) );
|
||||
|
||||
if ( ViewBox != null )
|
||||
ViewBox.set( configSrc.getSetting( Settings.VIEW_MODE ) );
|
||||
|
||||
repo.updateView();
|
||||
}
|
||||
|
||||
protected boolean isPowered()
|
||||
{
|
||||
return repo.hasPower();
|
||||
}
|
||||
|
||||
int getMaxRows()
|
||||
{
|
||||
return AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
|
||||
public class GuiMEPortableCell extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
public GuiMEPortableCell(InventoryPlayer inventoryPlayer, IPortableCell te) {
|
||||
super( inventoryPlayer, te, new ContainerMEPortableCell( inventoryPlayer, null ) );
|
||||
}
|
||||
|
||||
int defaultGetMaxRows()
|
||||
{
|
||||
return super.getMaxRows();
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.implementations.ContainerNetworkStatus;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiNetworkStatus extends AEBaseGui implements ISortSource
|
||||
{
|
||||
|
||||
ItemRepo repo;
|
||||
GuiImgButton units;
|
||||
|
||||
int rows = 4;
|
||||
|
||||
public GuiNetworkStatus(InventoryPlayer inventoryPlayer, INetworkTool te) {
|
||||
super( new ContainerNetworkStatus( inventoryPlayer, te ) );
|
||||
this.ySize = 153;
|
||||
this.xSize = 195;
|
||||
myScrollBar = new GuiScrollbar();
|
||||
repo = new ItemRepo( myScrollBar, this );
|
||||
repo.rowSize = 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == units )
|
||||
{
|
||||
AEConfig.instance.nextPowerUnit( backwards );
|
||||
units.set( AEConfig.instance.selectedPowerUnit() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
|
||||
buttonList.add( units );
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list)
|
||||
{
|
||||
repo.clear();
|
||||
|
||||
for (IAEItemStack is : list)
|
||||
repo.postUpdate( is );
|
||||
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
int size = repo.size();
|
||||
myScrollBar.setTop( 39 ).setLeft( 175 ).setHeight( 78 );
|
||||
myScrollBar.setRange( 0, (size + 4) / 5 - rows, 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/networkstatus.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
int tooltip = -1;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
int gx = (width - xSize) / 2;
|
||||
int gy = (height - ySize) / 2;
|
||||
|
||||
tooltip = -1;
|
||||
|
||||
for (int z = 0; z <= 4 * 5; z++)
|
||||
{
|
||||
int minX = gx + 14 + x * 31;
|
||||
int minY = gy + 41 + y * 18;
|
||||
|
||||
if ( minX < mouse_x && minX + 28 > mouse_x )
|
||||
{
|
||||
if ( minY < mouse_y && minY + 20 > mouse_y )
|
||||
{
|
||||
tooltip = z;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 4 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
ContainerNetworkStatus ns = (ContainerNetworkStatus) inventorySlots;
|
||||
|
||||
fontRendererObj.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( ns.currentPower, false ), 13, 16, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( ns.maxPower, false ), 13, 26, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong( ns.avgAddition, true ), 13, 143 - 10, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( ns.powerUsage, true ), 13, 143 - 20, 4210752 );
|
||||
|
||||
int sectionLength = 30;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int xo = 0 + 12;
|
||||
int yo = 0 + 42;
|
||||
int viewStart = 0;// myScrollBar.getCurrentScroll() * 5;
|
||||
int viewEnd = viewStart + 5 * 4;
|
||||
|
||||
String ToolTip = "";
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
for (int z = viewStart; z < Math.min( viewEnd, repo.size() ); z++)
|
||||
{
|
||||
IAEItemStack refStack = repo.getReferenceItem( z );
|
||||
if ( refStack != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( 0.5, 0.5, 0.5 );
|
||||
|
||||
String str = Long.toString( refStack.getStackSize() );
|
||||
if ( refStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( refStack.getStackSize() / 1000 ) + "k";
|
||||
|
||||
int w = fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * sectionLength + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * 18 + yo + 6) * 2),
|
||||
4210752 );
|
||||
|
||||
GL11.glPopMatrix();
|
||||
int posX = x * sectionLength + xo + sectionLength - 18;
|
||||
int posY = y * 18 + yo;
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
{
|
||||
ToolTip = Platform.getItemDisplayName( repo.getItem( z ) );
|
||||
|
||||
ToolTip = ToolTip + ("\n" + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
|
||||
if ( refStack.getCountRequestable() > 0 )
|
||||
ToolTip = ToolTip + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true ));
|
||||
|
||||
toolPosX = x * sectionLength + xo + sectionLength - 8;
|
||||
toolPosY = y * 18 + yo;
|
||||
}
|
||||
|
||||
drawItem( posX, posY, repo.getItem( z ) );
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 4 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( tooltip >= 0 && ToolTip.length() > 0 )
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
drawTooltip( toolPosX, toolPosY + 10, 0, ToolTip );
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @Override - NEI
|
||||
public List<String> handleItemTooltip(ItemStack stack, int mousex, int mousey, List<String> currenttip)
|
||||
{
|
||||
if ( stack != null )
|
||||
{
|
||||
Slot s = getSlot( mousex, mousey );
|
||||
if ( s instanceof SlotME )
|
||||
{
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try
|
||||
{
|
||||
SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
{
|
||||
}
|
||||
|
||||
if ( myStack != null )
|
||||
{
|
||||
while (currenttip.size() > 1)
|
||||
currenttip.remove( 1 );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
// Vanilla version...
|
||||
protected void drawItemStackTooltip(ItemStack stack, int x, int y)
|
||||
{
|
||||
Slot s = getSlot( x, y );
|
||||
if ( s instanceof SlotME && stack != null )
|
||||
{
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try
|
||||
{
|
||||
SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
{
|
||||
}
|
||||
|
||||
if ( myStack != null )
|
||||
{
|
||||
List currenttip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
|
||||
|
||||
while (currenttip.size() > 1)
|
||||
currenttip.remove( 1 );
|
||||
|
||||
currenttip.add( GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()) );
|
||||
currenttip.add( GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( myStack.getCountRequestable(), true ) );
|
||||
|
||||
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
|
||||
}
|
||||
}
|
||||
// super.drawItemStackTooltip( stack, x, y );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDir()
|
||||
{
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDisplay()
|
||||
{
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerNetworkTool;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class GuiNetworkTool extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiToggleButton tFacades;
|
||||
|
||||
public GuiNetworkTool(InventoryPlayer inventoryPlayer, INetworkTool te) {
|
||||
super( new ContainerNetworkTool( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == tFacades )
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
tFacades = new GuiToggleButton( this.guiLeft - 18, guiTop + 8, 23, 22, GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint.getLocal() );
|
||||
|
||||
buttonList.add( tFacades );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/toolbox.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
if ( tFacades != null )
|
||||
tFacades.setState( ((ContainerNetworkTool) inventorySlots).facadeMode );
|
||||
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.NetworkTool.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class GuiPatternTerm extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
ContainerPatternTerm container;
|
||||
|
||||
GuiTabButton tabCraftButton;
|
||||
GuiTabButton tabProcessButton;
|
||||
// GuiImgButton substitutionsBtn;
|
||||
GuiImgButton encodeBtn;
|
||||
GuiImgButton clearBtn;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
buttonList.add( tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.crafting_table ),
|
||||
GuiText.CraftingPattern.getLocal(), itemRender ) );
|
||||
buttonList.add( tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.furnace ),
|
||||
GuiText.ProcessingPattern.getLocal(), itemRender ) );
|
||||
|
||||
// buttonList.add( substitutionsBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163,
|
||||
// Settings.ACTIONS, ActionItems.SUBSTITUTION ) );
|
||||
// substitutionsBtn.halfSize = true;
|
||||
|
||||
buttonList.add( clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE ) );
|
||||
clearBtn.halfSize = true;
|
||||
|
||||
buttonList.add( encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if ( tabCraftButton == btn || tabProcessButton == btn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", tabProcessButton == btn ? "1" : "0" ) );
|
||||
}
|
||||
|
||||
if ( encodeBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
|
||||
}
|
||||
|
||||
if ( clearBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) );
|
||||
}
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// if ( substitutionsBtn == btn )
|
||||
// {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
protected void repositionSlot(AppEngSlot s)
|
||||
{
|
||||
if ( s.isPlayerSide() )
|
||||
s.yDisplayPosition = s.defY + ySize - 78 - 5;
|
||||
else
|
||||
s.yDisplayPosition = s.defY + ySize - 78 - 3;
|
||||
}
|
||||
|
||||
public GuiPatternTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( inventoryPlayer, te, new ContainerPatternTerm( inventoryPlayer, te ) );
|
||||
container = (ContainerPatternTerm) this.inventorySlots;
|
||||
reservedSpace = 81;
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
if ( container.craftingMode )
|
||||
return "guis/pattern.png";
|
||||
return "guis/pattern2.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
if ( !container.craftingMode )
|
||||
{
|
||||
tabCraftButton.visible = false;
|
||||
tabProcessButton.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
tabCraftButton.visible = true;
|
||||
tabProcessButton.visible = false;
|
||||
}
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, ySize - 96 + 2 - reservedSpace, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
|
||||
public class GuiPriority extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiNumberBox priority;
|
||||
GuiTabButton originalGuiBtn;
|
||||
|
||||
GuiButton plus1, plus10, plus100, plus1000;
|
||||
GuiButton minus1, minus10, minus100, minus1000;
|
||||
|
||||
GuiBridge OriginalGui;
|
||||
|
||||
public GuiPriority(InventoryPlayer inventoryPlayer, IPriorityHost te) {
|
||||
super( new ContainerPriority( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
int a = AEConfig.instance.priorityByStacksAmounts( 0 );
|
||||
int b = AEConfig.instance.priorityByStacksAmounts( 1 );
|
||||
int c = AEConfig.instance.priorityByStacksAmounts( 2 );
|
||||
int d = AEConfig.instance.priorityByStacksAmounts( 3 );
|
||||
|
||||
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) );
|
||||
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) );
|
||||
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) );
|
||||
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d ) );
|
||||
|
||||
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a ) );
|
||||
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b ) );
|
||||
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) );
|
||||
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
|
||||
|
||||
ItemStack myIcon = null;
|
||||
Object target = ((AEBaseContainer) inventorySlots).getTarget();
|
||||
|
||||
if ( target instanceof PartStorageBus )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partStorageBus.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_STORAGEBUS;
|
||||
}
|
||||
|
||||
if ( target instanceof PartFormationPlane )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partFormationPlane.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_FPLANE;
|
||||
}
|
||||
|
||||
if ( target instanceof TileDrive )
|
||||
{
|
||||
myIcon = AEApi.instance().blocks().blockDrive.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_DRIVE;
|
||||
}
|
||||
|
||||
if ( target instanceof TileChest )
|
||||
{
|
||||
myIcon = AEApi.instance().blocks().blockChest.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_CHEST;
|
||||
}
|
||||
|
||||
if ( target instanceof TileInterface )
|
||||
{
|
||||
myIcon = AEApi.instance().blocks().blockInterface.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
if ( target instanceof PartInterface )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partInterface.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
if ( OriginalGui != null )
|
||||
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||
|
||||
priority = new GuiNumberBox( fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, fontRendererObj.FONT_HEIGHT, Long.class );
|
||||
priority.setEnableBackgroundDrawing( false );
|
||||
priority.setMaxStringLength( 16 );
|
||||
priority.setTextColor( 0xFFFFFF );
|
||||
priority.setVisible( true );
|
||||
priority.setFocused( true );
|
||||
((ContainerPriority) inventorySlots).setTextField( priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if ( btn == originalGuiBtn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
boolean isPlus = btn == plus1 || btn == plus10 || btn == plus100 || btn == plus1000;
|
||||
boolean isMinus = btn == minus1 || btn == minus10 || btn == minus100 || btn == minus1000;
|
||||
|
||||
if ( isPlus || isMinus )
|
||||
addQty( getQty( btn ) );
|
||||
}
|
||||
|
||||
private void addQty(int i)
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = priority.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
priority.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
long result = Long.parseLong( Out );
|
||||
result += i;
|
||||
|
||||
priority.setText( Out = Long.toString( result ) );
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", Out ) );
|
||||
}
|
||||
catch(NumberFormatException e )
|
||||
{
|
||||
// nope..
|
||||
priority.setText( "0" );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( (key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ))
|
||||
&& priority.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = priority.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
priority.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", Out ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/priority.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
|
||||
priority.drawTextBox();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/priority.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
|
||||
public class GuiQNB extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiQNB(InventoryPlayer inventoryPlayer, TileQuantumBridge te) {
|
||||
super( new ContainerQNB( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/chest.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.QuantumLinkChamber.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
|
||||
public class GuiQuartzKnife extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiTextField name;
|
||||
|
||||
public GuiQuartzKnife(InventoryPlayer inventoryPlayer, QuartzKnifeObj te) {
|
||||
super( new ContainerQuartzKnife( inventoryPlayer, te ) );
|
||||
this.ySize = 184;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
name = new GuiTextField( fontRendererObj, this.guiLeft + 24, this.guiTop + 32, 79, fontRendererObj.FONT_HEIGHT );
|
||||
name.setEnableBackgroundDrawing( false );
|
||||
name.setMaxStringLength( 32 );
|
||||
name.setTextColor( 0xFFFFFF );
|
||||
name.setVisible( true );
|
||||
name.setFocused( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/quartzknife.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
name.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( name.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = name.getText();
|
||||
((ContainerQuartzKnife) inventorySlots).setName( Out );
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.QuartzCuttingKnife.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerSecurity;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class GuiSecurity extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
public GuiSecurity(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( inventoryPlayer, te, new ContainerSecurity( inventoryPlayer, te ) );
|
||||
customSortOrder = false;
|
||||
reservedSpace = 33;
|
||||
|
||||
// increase size so that the slot is over the gui.
|
||||
xSize += 56;
|
||||
standardSize = xSize;
|
||||
}
|
||||
|
||||
GuiToggleButton inject, extract, craft, build, security;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
int top = this.guiTop + this.ySize - 116;
|
||||
buttonList.add( inject = new GuiToggleButton( this.guiLeft + 56 + 18 * 0, top, 11 * 16 + 0, 12 * 16 + 0, SecurityPermissions.INJECT
|
||||
.getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip() ) );
|
||||
|
||||
buttonList.add( extract = new GuiToggleButton( this.guiLeft + 56 + 18 * 1, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
|
||||
.getUnlocalizedName(), SecurityPermissions.EXTRACT.getUnlocalizedTip() ) );
|
||||
|
||||
buttonList.add( craft = new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT.getUnlocalizedName(),
|
||||
SecurityPermissions.CRAFT.getUnlocalizedTip() ) );
|
||||
|
||||
buttonList.add( build = new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD.getUnlocalizedName(),
|
||||
SecurityPermissions.BUILD.getUnlocalizedTip() ) );
|
||||
|
||||
buttonList.add( security = new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
|
||||
.getUnlocalizedName(), SecurityPermissions.SECURITY.getUnlocalizedTip() ) );
|
||||
}
|
||||
|
||||
protected void actionPerformed(net.minecraft.client.gui.GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
SecurityPermissions toggleSetting = null;
|
||||
|
||||
if ( btn == inject )
|
||||
toggleSetting = SecurityPermissions.INJECT;
|
||||
if ( btn == extract )
|
||||
toggleSetting = SecurityPermissions.EXTRACT;
|
||||
if ( btn == craft )
|
||||
toggleSetting = SecurityPermissions.CRAFT;
|
||||
if ( btn == build )
|
||||
toggleSetting = SecurityPermissions.BUILD;
|
||||
if ( btn == security )
|
||||
toggleSetting = SecurityPermissions.SECURITY;
|
||||
|
||||
if ( toggleSetting != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileSecurity.ToggleOption", toggleSetting.name() ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
ContainerSecurity cs = (ContainerSecurity) inventorySlots;
|
||||
|
||||
inject.setState( (cs.security & (1 << SecurityPermissions.INJECT.ordinal())) > 0 );
|
||||
extract.setState( (cs.security & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0 );
|
||||
craft.setState( (cs.security & (1 << SecurityPermissions.CRAFT.ordinal())) > 0 );
|
||||
build.setState( (cs.security & (1 << SecurityPermissions.BUILD.ordinal())) > 0 );
|
||||
security.setState( (cs.security & (1 << SecurityPermissions.SECURITY.ordinal())) > 0 );
|
||||
|
||||
return "guis/security.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
fontRendererObj.drawString( GuiText.SecurityCardEditor.getLocal(), 8, ySize - 96 + 1 - reservedSpace, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
|
||||
public class GuiSkyChest extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiSkyChest(InventoryPlayer inventoryPlayer, TileSkyChest te) {
|
||||
super( new ContainerSkyChest( inventoryPlayer, te ) );
|
||||
this.ySize = 195;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/skychest.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.SkyChest.getLocal() ), 8, 8, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 2, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean enableSpaceClicking()
|
||||
{
|
||||
return !AppEng.instance.isIntegrationEnabled( IntegrationType.InvTweaks );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerSpatialIOPort;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.spatial.TileSpatialIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiSpatialIOPort extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerSpatialIOPort csiop;
|
||||
GuiImgButton units;
|
||||
|
||||
public GuiSpatialIOPort(InventoryPlayer inventoryPlayer, TileSpatialIOPort te) {
|
||||
super( new ContainerSpatialIOPort( inventoryPlayer, te ) );
|
||||
this.ySize = 199;
|
||||
csiop = (ContainerSpatialIOPort) inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == units )
|
||||
{
|
||||
AEConfig.instance.nextPowerUnit( backwards );
|
||||
units.set( AEConfig.instance.selectedPowerUnit() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
|
||||
buttonList.add( units );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/spatialio.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.currentPower, false ), 13, 21, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( csiop.maxPower, false ), 13, 31, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.reqPower, false ), 13, 78, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.Efficiency.getLocal() + ": " + (((float) csiop.eff) / 100) + "%", 13, 88, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerStorageBus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
|
||||
public class GuiStorageBus extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiImgButton rwMode;
|
||||
GuiImgButton storageFilter;
|
||||
GuiTabButton priority;
|
||||
GuiImgButton partition;
|
||||
GuiImgButton clear;
|
||||
|
||||
public GuiStorageBus(InventoryPlayer inventoryPlayer, PartStorageBus te) {
|
||||
super( new ContainerStorageBus( inventoryPlayer, te ) );
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.StorageBus.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
if ( fuzzyMode != null )
|
||||
fuzzyMode.set( cvb.fzMode );
|
||||
|
||||
if ( storageFilter != null )
|
||||
storageFilter.set( ((ContainerStorageBus) cvb).storageFilter );
|
||||
|
||||
if ( rwMode != null )
|
||||
rwMode.set( ((ContainerStorageBus) cvb).rwMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
clear = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
partition = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
|
||||
rwMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
|
||||
storageFilter = new GuiImgButton( this.guiLeft - 18, guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
|
||||
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
|
||||
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
|
||||
|
||||
buttonList.add( storageFilter );
|
||||
buttonList.add( fuzzyMode );
|
||||
buttonList.add( rwMode );
|
||||
buttonList.add( partition );
|
||||
buttonList.add( clear );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == partition )
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
|
||||
|
||||
else if ( btn == clear )
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
|
||||
|
||||
else if ( btn == priority )
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
|
||||
else if ( btn == fuzzyMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( fuzzyMode.getSetting(), backwards ) );
|
||||
|
||||
else if ( btn == rwMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( rwMode.getSetting(), backwards ) );
|
||||
|
||||
else if ( btn == storageFilter )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( storageFilter.getSetting(), backwards ) );
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.parts.automation.PartImportBus;
|
||||
|
||||
public class GuiUpgradeable extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerUpgradeable cvb;
|
||||
IUpgradeableHost bc;
|
||||
|
||||
GuiImgButton redstoneMode;
|
||||
GuiImgButton fuzzyMode;
|
||||
GuiImgButton craftMode;
|
||||
|
||||
public GuiUpgradeable(InventoryPlayer inventoryPlayer, IUpgradeableHost te) {
|
||||
this( new ContainerUpgradeable( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
public GuiUpgradeable(ContainerUpgradeable te) {
|
||||
super( te );
|
||||
cvb = (ContainerUpgradeable) te;
|
||||
|
||||
bc = (IUpgradeableHost) te.getTarget();
|
||||
this.xSize = hasToolbox() ? 246 : 211;
|
||||
this.ySize = 184;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
addButtons();
|
||||
}
|
||||
|
||||
protected void addButtons()
|
||||
{
|
||||
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
craftMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
|
||||
|
||||
buttonList.add( craftMode );
|
||||
buttonList.add( redstoneMode );
|
||||
buttonList.add( fuzzyMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == redstoneMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( redstoneMode.getSetting(), backwards ) );
|
||||
|
||||
if ( btn == craftMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( craftMode.getSetting(), backwards ) );
|
||||
|
||||
if ( btn == fuzzyMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( fuzzyMode.getSetting(), backwards ) );
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean hasToolbox()
|
||||
{
|
||||
return ((ContainerUpgradeable) inventorySlots).hasToolbox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
handleButtonVisibility();
|
||||
|
||||
bindTexture( getBackground() );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, ySize );
|
||||
if ( drawUpgrades() )
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + cvb.availableUpgrades() * 18 );
|
||||
if ( hasToolbox() )
|
||||
this.drawTexturedModalRect( offsetX + 178, offsetY + ySize - 90, 178, ySize - 90, 68, 68 );
|
||||
}
|
||||
|
||||
protected boolean drawUpgrades()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/bus.png";
|
||||
}
|
||||
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
if ( redstoneMode != null )
|
||||
redstoneMode.setVisibility( bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
|
||||
if ( fuzzyMode != null )
|
||||
fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
|
||||
if ( craftMode != null )
|
||||
craftMode.setVisibility( bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( getName().getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
if ( redstoneMode != null )
|
||||
redstoneMode.set( cvb.rsMode );
|
||||
|
||||
if ( fuzzyMode != null )
|
||||
fuzzyMode.set( cvb.fzMode );
|
||||
|
||||
if ( craftMode != null )
|
||||
craftMode.set( cvb.cMode );
|
||||
}
|
||||
|
||||
protected GuiText getName()
|
||||
{
|
||||
return bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerVibrationChamber;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.misc.TileVibrationChamber;
|
||||
|
||||
public class GuiVibrationChamber extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerVibrationChamber cvc;
|
||||
GuiProgressBar pb;
|
||||
|
||||
public GuiVibrationChamber(InventoryPlayer inventoryPlayer, TileVibrationChamber te) {
|
||||
super( new ContainerVibrationChamber( inventoryPlayer, te ) );
|
||||
cvc = (ContainerVibrationChamber) inventorySlots;
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
pb = new GuiProgressBar( "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL );
|
||||
this.buttonList.add( pb );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/vibchamber.png" );
|
||||
pb.xPosition = 99 + guiLeft;
|
||||
pb.yPosition = 36 + guiTop;
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.VibrationChamber.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
int k = 25;
|
||||
int l = -15;
|
||||
|
||||
pb.max = 200;
|
||||
pb.current = cvc.burnProgress > 0 ? cvc.burnSpeed : 0;
|
||||
pb.FullMsg = (cvc.aePerTick * pb.current / 100) + " ae/t";
|
||||
|
||||
if ( cvc.burnProgress > 0 )
|
||||
{
|
||||
int i1 = cvc.burnProgress;
|
||||
bindTexture( "guis/vibchamber.png" );
|
||||
GL11.glColor3f( 1, 1, 1 );
|
||||
this.drawTexturedModalRect( k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiWireless extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiImgButton units;
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == units )
|
||||
{
|
||||
AEConfig.instance.nextPowerUnit( backwards );
|
||||
units.set( AEConfig.instance.selectedPowerUnit() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
|
||||
buttonList.add( units );
|
||||
}
|
||||
|
||||
public GuiWireless(InventoryPlayer inventoryPlayer, TileWireless te) {
|
||||
super( new ContainerWireless( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/wireless.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Wireless.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
ContainerWireless cw = (ContainerWireless) inventorySlots;
|
||||
|
||||
if ( cw.range > 0 )
|
||||
{
|
||||
String msga = GuiText.Range.getLocal() + ": " + ((double) cw.range / 10.0) + " m";
|
||||
String msgb = GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( cw.drain, true );
|
||||
|
||||
int strWidth = Math.max( fontRendererObj.getStringWidth( msga ), fontRendererObj.getStringWidth( msgb ) );
|
||||
int cOffset = (this.xSize / 2) - (strWidth / 2);
|
||||
fontRendererObj.drawString( msga, cOffset, 20, 4210752 );
|
||||
fontRendererObj.drawString( msgb, cOffset, 20 + 12, 4210752 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
|
||||
public class GuiWirelessTerm extends GuiMEPortableCell
|
||||
{
|
||||
|
||||
public GuiWirelessTerm(InventoryPlayer inventoryPlayer, IPortableCell te) {
|
||||
super( inventoryPlayer, te );
|
||||
maxRows = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows()
|
||||
{
|
||||
return defaultGetMaxRows();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.LevelType;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.RelativeDirection;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
public class GuiImgButton extends GuiButton implements ITooltip
|
||||
{
|
||||
|
||||
class EnumPair
|
||||
{
|
||||
|
||||
Enum setting;
|
||||
Enum value;
|
||||
|
||||
EnumPair(Enum a, Enum b) {
|
||||
setting = a;
|
||||
value = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return setting.hashCode() ^ value.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
EnumPair d = (EnumPair) obj;
|
||||
return d.setting.equals( setting ) && d.value.equals( value );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class BtnAppearance
|
||||
{
|
||||
|
||||
public int index;
|
||||
public String DisplayName;
|
||||
public String DisplayValue;
|
||||
};
|
||||
|
||||
public boolean halfSize = false;
|
||||
public String FillVar;
|
||||
|
||||
private final Enum buttonSetting;
|
||||
private Enum currentValue;
|
||||
|
||||
static private Map<EnumPair, BtnAppearance> Appearances;
|
||||
|
||||
private void registerApp(int IIcon, Settings setting, Enum val, ButtonToolTips title, Object hint)
|
||||
{
|
||||
BtnAppearance a = new BtnAppearance();
|
||||
a.DisplayName = title.getUnlocalized();
|
||||
a.DisplayValue = (String) (hint instanceof String ? hint : ((ButtonToolTips) hint).getUnlocalized());
|
||||
a.index = IIcon;
|
||||
Appearances.put( new EnumPair( setting, val ), a );
|
||||
}
|
||||
|
||||
public void setVisibility(boolean vis)
|
||||
{
|
||||
visible = vis;
|
||||
enabled = vis;
|
||||
}
|
||||
|
||||
public GuiImgButton(int x, int y, Enum idx, Enum val) {
|
||||
super( 0, 0, 16, "" );
|
||||
buttonSetting = idx;
|
||||
currentValue = val;
|
||||
xPosition = x;
|
||||
yPosition = y;
|
||||
width = 16;
|
||||
height = 16;
|
||||
|
||||
if ( Appearances == null )
|
||||
{
|
||||
Appearances = new HashMap();
|
||||
registerApp( 16 * 7 + 0, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, ButtonToolTips.Trash );
|
||||
registerApp( 16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS, ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls );
|
||||
registerApp( 16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY, ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity );
|
||||
|
||||
registerApp( 16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode, ButtonToolTips.Read );
|
||||
registerApp( 16 * 9 + 0, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write );
|
||||
registerApp( 16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, ButtonToolTips.ReadWrite );
|
||||
|
||||
registerApp( 16 * 10 + 0, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.unlocalizedName );
|
||||
registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName );
|
||||
registerApp( 16 * 10 + 2, Settings.POWER_UNITS, PowerUnits.MJ, ButtonToolTips.PowerUnits, PowerUnits.MJ.unlocalizedName );
|
||||
registerApp( 16 * 10 + 3, Settings.POWER_UNITS, PowerUnits.MK, ButtonToolTips.PowerUnits, PowerUnits.MK.unlocalizedName );
|
||||
registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.WA, ButtonToolTips.PowerUnits, PowerUnits.WA.unlocalizedName );
|
||||
registerApp( 16 * 10 + 5, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName );
|
||||
|
||||
registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive );
|
||||
registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal );
|
||||
registerApp( 1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithSignal );
|
||||
registerApp( 2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveOnPulse );
|
||||
|
||||
registerApp( 0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelsBelow );
|
||||
registerApp( 1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelAbove );
|
||||
|
||||
registerApp( 51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
|
||||
registerApp( 50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
|
||||
|
||||
registerApp( 51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
|
||||
registerApp( 50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
|
||||
|
||||
registerApp( 48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
|
||||
registerApp( 49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
|
||||
|
||||
registerApp( 16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Auto );
|
||||
registerApp( 16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Standard );
|
||||
registerApp( 16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.NEI_AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_NEIAuto );
|
||||
registerApp( 16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.NEI_MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_NEIStandard );
|
||||
|
||||
registerApp( 16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Energy );
|
||||
registerApp( 16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Item );
|
||||
|
||||
registerApp( 16 * 13 + 0, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Tall );
|
||||
registerApp( 16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Small );
|
||||
registerApp( 16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Full );
|
||||
|
||||
registerApp( 64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName );
|
||||
registerApp( 65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems );
|
||||
registerApp( 68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, ButtonToolTips.InventoryTweaks );
|
||||
registerApp( 69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod );
|
||||
|
||||
registerApp( 66, Settings.ACTIONS, ActionItems.WRENCH, ButtonToolTips.PartitionStorage, ButtonToolTips.PartitionStorageHint );
|
||||
registerApp( 6, Settings.ACTIONS, ActionItems.CLOSE, ButtonToolTips.Clear, ButtonToolTips.ClearSettings );
|
||||
registerApp( 6, Settings.ACTIONS, ActionItems.STASH, ButtonToolTips.Stash, ButtonToolTips.StashDesc );
|
||||
|
||||
registerApp( 8, Settings.ACTIONS, ActionItems.ENCODE, ButtonToolTips.Encode, ButtonToolTips.EncodeDescription );
|
||||
registerApp( 4 + 3 * 16, Settings.ACTIONS, ActionItems.SUBSTITUTION, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDesc );
|
||||
|
||||
registerApp( 16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems );
|
||||
registerApp( 18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable );
|
||||
registerApp( 19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable );
|
||||
|
||||
registerApp( 16 * 6 + 0, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_25 );
|
||||
registerApp( 16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_50 );
|
||||
registerApp( 16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_75 );
|
||||
registerApp( 16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_99 );
|
||||
registerApp( 16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode, ButtonToolTips.FZIgnoreAll );
|
||||
|
||||
registerApp( 80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenEmpty );
|
||||
registerApp( 81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenWorkIsDone );
|
||||
registerApp( 82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenFull );
|
||||
|
||||
registerApp( 16 * 1 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.Blocking );
|
||||
registerApp( 16 * 1 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.NonBlocking );
|
||||
|
||||
registerApp( 16 * 1 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly );
|
||||
registerApp( 16 * 1 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither );
|
||||
|
||||
registerApp( 16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode, ButtonToolTips.CraftViaRedstone );
|
||||
registerApp( 16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode, ButtonToolTips.EmitWhenCrafting );
|
||||
|
||||
registerApp( 16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, ButtonToolTips.ReportInaccessibleItems,
|
||||
ButtonToolTips.ReportInaccessibleItemsNo );
|
||||
registerApp( 16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems,
|
||||
ButtonToolTips.ReportInaccessibleItemsYes );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
if ( this.visible )
|
||||
{
|
||||
int iconIndex = getIconIndex();
|
||||
|
||||
if ( halfSize )
|
||||
{
|
||||
width = 8;
|
||||
height = 8;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef( this.xPosition, this.yPosition, 0.0F );
|
||||
GL11.glScalef( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
if ( enabled )
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
else
|
||||
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
|
||||
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width
|
||||
&& par3 < this.yPosition + this.height;
|
||||
|
||||
int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( enabled )
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
else
|
||||
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
|
||||
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width
|
||||
&& par3 < this.yPosition + this.height;
|
||||
|
||||
int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
}
|
||||
}
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
|
||||
private int getIconIndex()
|
||||
{
|
||||
if ( buttonSetting != null && currentValue != null )
|
||||
{
|
||||
BtnAppearance app = Appearances.get( new EnumPair( buttonSetting, currentValue ) );
|
||||
if ( app == null )
|
||||
return 256 - 1;
|
||||
return app.index;
|
||||
}
|
||||
return 256 - 1;
|
||||
}
|
||||
|
||||
public Settings getSetting()
|
||||
{
|
||||
return (Settings) buttonSetting;
|
||||
}
|
||||
|
||||
public Enum getCurrentValue()
|
||||
{
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg()
|
||||
{
|
||||
String DisplayName = null;
|
||||
String DisplayValue = null;
|
||||
|
||||
if ( buttonSetting != null && currentValue != null )
|
||||
{
|
||||
BtnAppearance ba = Appearances.get( new EnumPair( buttonSetting, currentValue ) );
|
||||
if ( ba == null )
|
||||
return "No Such Message";
|
||||
|
||||
DisplayName = ba.DisplayName;
|
||||
DisplayValue = ba.DisplayValue;
|
||||
}
|
||||
|
||||
if ( DisplayName != null )
|
||||
{
|
||||
String Name = StatCollector.translateToLocal( DisplayName );
|
||||
String Value = StatCollector.translateToLocal( DisplayValue );
|
||||
|
||||
if ( Name == null || Name.equals( "" ) )
|
||||
Name = DisplayName;
|
||||
if ( Value == null || Value.equals( "" ) )
|
||||
Value = DisplayValue;
|
||||
|
||||
if ( FillVar != null )
|
||||
Value = Value.replaceFirst( "%s", FillVar );
|
||||
|
||||
Value = Value.replace( "\\n", "\n" );
|
||||
StringBuilder sb = new StringBuilder( Value );
|
||||
|
||||
int i = sb.lastIndexOf( "\n" );
|
||||
if ( i <= 0 )
|
||||
i = 0;
|
||||
while (i + 30 < sb.length() && (i = sb.lastIndexOf( " ", i + 30 )) != -1)
|
||||
{
|
||||
sb.replace( i, i + 1, "\n" );
|
||||
}
|
||||
|
||||
return Name + "\n" + sb.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return xPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return yPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
public void set(Enum e)
|
||||
{
|
||||
if ( currentValue != e )
|
||||
{
|
||||
currentValue = e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
|
||||
public class GuiNumberBox extends GuiTextField
|
||||
{
|
||||
|
||||
final Class type;
|
||||
|
||||
public GuiNumberBox(FontRenderer p_i1032_1_, int p_i1032_2_, int p_i1032_3_, int p_i1032_4_, int p_i1032_5_,Class type) {
|
||||
super( p_i1032_1_, p_i1032_2_, p_i1032_3_, p_i1032_4_, p_i1032_5_ );
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeText(String p_146191_1_)
|
||||
{
|
||||
String original = getText();
|
||||
super.writeText( p_146191_1_ );
|
||||
|
||||
try
|
||||
{
|
||||
if ( type == int.class || type == Integer.class )
|
||||
Integer.parseInt( getText() );
|
||||
else if ( type == long.class || type == Long.class )
|
||||
Long.parseLong( getText() );
|
||||
else if ( type == double.class || type == Double.class )
|
||||
Double.parseDouble( getText() );
|
||||
}
|
||||
catch(NumberFormatException e )
|
||||
{
|
||||
setText( original );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class GuiProgressBar extends GuiButton implements ITooltip
|
||||
{
|
||||
|
||||
public enum Direction
|
||||
{
|
||||
HORIZONTAL, VERTICAL
|
||||
};
|
||||
|
||||
private ResourceLocation texture;
|
||||
private int fill_u;
|
||||
private int fill_v;
|
||||
private Direction layout;
|
||||
|
||||
public String FullMsg;
|
||||
|
||||
public String TitleName;
|
||||
public int current;
|
||||
public int max;
|
||||
|
||||
public GuiProgressBar(String string, int posX, int posY, int u, int y, int _width, int _height, Direction dir) {
|
||||
super( posX, posY, _width, "" );
|
||||
this.xPosition = posX;
|
||||
this.yPosition = posY;
|
||||
texture = new ResourceLocation( "appliedenergistics2", "textures/" + string );
|
||||
width = _width;
|
||||
height = _height;
|
||||
fill_u = u;
|
||||
fill_v = y;
|
||||
current = 0;
|
||||
max = 100;
|
||||
layout = dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
if ( this.visible )
|
||||
{
|
||||
par1Minecraft.getTextureManager().bindTexture( texture );
|
||||
|
||||
if ( layout == Direction.VERTICAL )
|
||||
{
|
||||
int diff = height - (max > 0 ? (height * current) / max : 0);
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition + diff, fill_u, fill_v + diff, width, height - diff );
|
||||
}
|
||||
else
|
||||
{
|
||||
int diff = width - (max > 0 ? (width * current) / max : 0);
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, fill_u + diff, fill_v, width - diff, height );
|
||||
}
|
||||
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg()
|
||||
{
|
||||
if ( FullMsg != null )
|
||||
return FullMsg;
|
||||
|
||||
return (TitleName != null ? TitleName : "") + "\n" + current + " " + GuiText.Of.getLocal() + " " + max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return xPosition - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return yPosition - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return width + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return height + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
|
||||
public class GuiScrollbar implements IScrollSource
|
||||
{
|
||||
|
||||
private int displayX = 0;
|
||||
private int displayY = 0;
|
||||
private int width = 12;
|
||||
private int height = 16;
|
||||
private int pageSize = 1;
|
||||
|
||||
private int maxScroll = 0;
|
||||
private int minScroll = 0;
|
||||
private int currentScroll = 0;
|
||||
|
||||
private void applyRange()
|
||||
{
|
||||
currentScroll = Math.max( Math.min( currentScroll, maxScroll ), minScroll );
|
||||
}
|
||||
|
||||
public void draw(AEBaseGui g)
|
||||
{
|
||||
g.bindTexture( "minecraft", "gui/container/creative_inventory/tabs.png" );
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
if ( getRange() == 0 )
|
||||
{
|
||||
g.drawTexturedModalRect( displayX, displayY, 232 + width, 0, width, 15 );
|
||||
}
|
||||
else
|
||||
{
|
||||
int offset = (currentScroll - minScroll) * (height - 15) / getRange();
|
||||
g.drawTexturedModalRect( displayX, offset + displayY, 232, 0, width, 15 );
|
||||
}
|
||||
}
|
||||
|
||||
public int getRange()
|
||||
{
|
||||
return maxScroll - minScroll;
|
||||
}
|
||||
|
||||
public int getLeft()
|
||||
{
|
||||
return displayX;
|
||||
}
|
||||
|
||||
public int getTop()
|
||||
{
|
||||
return displayY;
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public GuiScrollbar setLeft(int v)
|
||||
{
|
||||
displayX = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiScrollbar setTop(int v)
|
||||
{
|
||||
displayY = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiScrollbar setWidth(int v)
|
||||
{
|
||||
width = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiScrollbar setHeight(int v)
|
||||
{
|
||||
height = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setRange(int min, int max, int pageSize)
|
||||
{
|
||||
minScroll = min;
|
||||
maxScroll = max;
|
||||
this.pageSize = pageSize;
|
||||
|
||||
if ( minScroll > maxScroll )
|
||||
maxScroll = minScroll;
|
||||
|
||||
applyRange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentScroll()
|
||||
{
|
||||
return currentScroll;
|
||||
}
|
||||
|
||||
public void click(AEBaseGui aeBaseGui, int x, int y)
|
||||
{
|
||||
if ( getRange() == 0 )
|
||||
return;
|
||||
|
||||
if ( x > displayX && x <= displayX + width )
|
||||
{
|
||||
if ( y > displayY && y <= displayY + height )
|
||||
{
|
||||
currentScroll = (y - displayY);
|
||||
currentScroll = minScroll + ((currentScroll * 2 * getRange() / height));
|
||||
currentScroll = (currentScroll + 1) >> 1;
|
||||
applyRange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void wheel(int delta)
|
||||
{
|
||||
delta = Math.max( Math.min( -delta, 1 ), -1 );
|
||||
currentScroll += delta * pageSize;
|
||||
applyRange();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
|
||||
public class GuiTabButton extends GuiButton implements ITooltip
|
||||
{
|
||||
|
||||
RenderItem itemRenderer;
|
||||
|
||||
int myIcon = -1;
|
||||
public int hideEdge = 0;
|
||||
|
||||
ItemStack myItem;
|
||||
|
||||
String Msg;
|
||||
|
||||
public void setVisibility(boolean vis)
|
||||
{
|
||||
visible = vis;
|
||||
enabled = vis;
|
||||
}
|
||||
|
||||
public GuiTabButton(int x, int y, int ico, String Msg, RenderItem ir) {
|
||||
super( 0, 0, 16, "" );
|
||||
xPosition = x;
|
||||
yPosition = y;
|
||||
width = 22;
|
||||
height = 22;
|
||||
myIcon = ico;
|
||||
this.Msg = Msg;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
public GuiTabButton(int x, int y, ItemStack ico, String Msg, RenderItem ir) {
|
||||
super( 0, 0, 16, "" );
|
||||
xPosition = x;
|
||||
yPosition = y;
|
||||
width = 22;
|
||||
height = 22;
|
||||
myItem = ico;
|
||||
this.Msg = Msg;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
if ( this.visible )
|
||||
{
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
|
||||
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
|
||||
|
||||
int uv_y = (int) Math.floor( 13 / 16 );
|
||||
int uv_x = (hideEdge > 0 ? 11 : 13) - uv_y * 16;
|
||||
|
||||
int offsetX = hideEdge > 0 ? 1 : 0;
|
||||
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 25, 22 );
|
||||
|
||||
if ( myIcon >= 0 )
|
||||
{
|
||||
uv_y = (int) Math.floor( myIcon / 16 );
|
||||
uv_x = myIcon - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( offsetX + this.xPosition + 3, this.yPosition + 3, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
}
|
||||
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
|
||||
if ( myItem != null )
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
itemRenderer.zLevel = 100.0F;
|
||||
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
FontRenderer fontrenderer = par1Minecraft.fontRenderer;
|
||||
itemRenderer.renderItemAndEffectIntoGUI( fontrenderer, par1Minecraft.renderEngine, myItem, offsetX + this.xPosition + 3, this.yPosition + 3 );
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg()
|
||||
{
|
||||
return Msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return xPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return yPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
|
||||
public class GuiToggleButton extends GuiButton implements ITooltip
|
||||
{
|
||||
|
||||
int iconIdxOn;
|
||||
int iconIdxOff;
|
||||
|
||||
String Name;
|
||||
String Hint;
|
||||
|
||||
boolean on;
|
||||
|
||||
public void setState(boolean isOn)
|
||||
{
|
||||
on = isOn;
|
||||
}
|
||||
|
||||
public void setVisibility(boolean vis)
|
||||
{
|
||||
visible = vis;
|
||||
enabled = vis;
|
||||
}
|
||||
|
||||
public GuiToggleButton(int x, int y, int on, int off, String Name, String Hint) {
|
||||
super( 0, 0, 16, "" );
|
||||
iconIdxOn = on;
|
||||
iconIdxOff = off;
|
||||
this.Name = Name;
|
||||
this.Hint = Hint;
|
||||
xPosition = x;
|
||||
yPosition = y;
|
||||
width = 16;
|
||||
height = 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
if ( this.visible )
|
||||
{
|
||||
int iconIndex = getIconIndex();
|
||||
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
|
||||
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
|
||||
|
||||
int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
}
|
||||
}
|
||||
|
||||
private int getIconIndex()
|
||||
{
|
||||
return on ? iconIdxOn : iconIdxOff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg()
|
||||
{
|
||||
String DisplayName = Name;
|
||||
String DisplayValue = Hint;
|
||||
|
||||
if ( DisplayName != null )
|
||||
{
|
||||
String Name = StatCollector.translateToLocal( DisplayName );
|
||||
String Value = StatCollector.translateToLocal( DisplayValue );
|
||||
|
||||
if ( Name == null || Name.equals( "" ) )
|
||||
Name = DisplayName;
|
||||
if ( Value == null || Value.equals( "" ) )
|
||||
Value = DisplayValue;
|
||||
|
||||
Value = Value.replace( "\\n", "\n" );
|
||||
StringBuilder sb = new StringBuilder( Value );
|
||||
|
||||
int i = sb.lastIndexOf( "\n" );
|
||||
if ( i <= 0 )
|
||||
i = 0;
|
||||
while (i + 30 < sb.length() && (i = sb.lastIndexOf( " ", i + 30 )) != -1)
|
||||
{
|
||||
sb.replace( i, i + 1, "\n" );
|
||||
}
|
||||
|
||||
return Name + "\n" + sb.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return xPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return yPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
public interface IScrollSource
|
||||
{
|
||||
|
||||
int getCurrentScroll();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.ViewItems;
|
||||
|
||||
public interface ISortSource
|
||||
{
|
||||
|
||||
/**
|
||||
* @return Sor
|
||||
*/
|
||||
Enum getSortBy();
|
||||
|
||||
/**
|
||||
* @return {@link SortDir}
|
||||
*/
|
||||
Enum getSortDir();
|
||||
|
||||
/**
|
||||
* @return {@link ViewItems}
|
||||
*/
|
||||
Enum getSortDisplay();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
/**
|
||||
* AEBaseGui controlled Tooltip Interface.
|
||||
*
|
||||
*/
|
||||
public interface ITooltip
|
||||
{
|
||||
|
||||
/**
|
||||
* returns the tooltip message.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getMsg();
|
||||
|
||||
/**
|
||||
* x Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return xPosition
|
||||
*/
|
||||
int xPos();
|
||||
|
||||
/**
|
||||
* y Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return yPosition
|
||||
*/
|
||||
int yPos();
|
||||
|
||||
/**
|
||||
* Width of the object that triggers the tooltip.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* Height for the object that triggers the tooltip.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* @return true if button being drawn
|
||||
*/
|
||||
boolean isVisible();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
public class MEGuiTextField extends GuiTextField
|
||||
{
|
||||
|
||||
int posX;
|
||||
int posY;
|
||||
|
||||
int myWidth;
|
||||
int myHeight;
|
||||
|
||||
public MEGuiTextField(FontRenderer par1FontRenderer, int xPos, int yPos, int width, int height) {
|
||||
super( par1FontRenderer, xPos, yPos, width, height );
|
||||
posX = xPos;
|
||||
posY = yPos;
|
||||
myWidth = width;
|
||||
myHeight = height;
|
||||
}
|
||||
|
||||
public boolean isMouseIn(int xCoord, int yCoord)
|
||||
{
|
||||
return xCoord >= posX && xCoord < posX + myWidth && yCoord >= posY && yCoord < posY + myHeight;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package appeng.client.me;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ItemSorters;
|
||||
|
||||
public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
|
||||
{
|
||||
|
||||
final public String unlocalizedName;
|
||||
final public AppEngInternalInventory inv;
|
||||
final public long id;
|
||||
final public long sortBy;
|
||||
|
||||
public ClientDCInternalInv(int size, long id, long sortBy, String unlocalizedName) {
|
||||
inv = new AppEngInternalInventory( null, size );
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.id = id;
|
||||
this.sortBy = sortBy;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
String s = StatCollector.translateToLocal( unlocalizedName + ".name" );
|
||||
if ( s.equals( unlocalizedName + ".name" ) )
|
||||
return StatCollector.translateToLocal( unlocalizedName );
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ClientDCInternalInv o)
|
||||
{
|
||||
return ItemSorters.compareLong( sortBy, o.sortBy );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package appeng.client.me;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
public class InternalSlotME
|
||||
{
|
||||
|
||||
private final ItemRepo repo;
|
||||
|
||||
public int offset;
|
||||
public int xPos;
|
||||
public int yPos;
|
||||
|
||||
public InternalSlotME(ItemRepo def, int offset, int displayX, int displayY) {
|
||||
this.repo = def;
|
||||
this.offset = offset;
|
||||
this.xPos = displayX;
|
||||
this.yPos = displayY;
|
||||
}
|
||||
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return repo.getItem( offset );
|
||||
}
|
||||
|
||||
public IAEItemStack getAEStack()
|
||||
{
|
||||
return repo.getReferenceItem( offset );
|
||||
}
|
||||
|
||||
public boolean hasPower()
|
||||
{
|
||||
return repo.hasPower();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
package appeng.client.me;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.util.ItemSorters;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.prioitylist.IPartitionList;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class ItemRepo
|
||||
{
|
||||
|
||||
final private IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
final private ArrayList<IAEItemStack> view = new ArrayList<IAEItemStack>();
|
||||
final private ArrayList<ItemStack> dsp = new ArrayList<ItemStack>();
|
||||
final private IScrollSource src;
|
||||
final private ISortSource sortSrc;
|
||||
|
||||
public int rowSize = 9;
|
||||
|
||||
public String searchString = "";
|
||||
private String innerSearch = "";
|
||||
|
||||
public ItemRepo(IScrollSource src, ISortSource sortSrc)
|
||||
{
|
||||
this.src = src;
|
||||
this.sortSrc = sortSrc;
|
||||
}
|
||||
|
||||
public IAEItemStack getReferenceItem(int idx)
|
||||
{
|
||||
idx += src.getCurrentScroll() * rowSize;
|
||||
|
||||
if ( idx >= view.size() )
|
||||
return null;
|
||||
return view.get( idx );
|
||||
}
|
||||
|
||||
public ItemStack getItem(int idx)
|
||||
{
|
||||
idx += src.getCurrentScroll() * rowSize;
|
||||
|
||||
if ( idx >= dsp.size() )
|
||||
return null;
|
||||
return dsp.get( idx );
|
||||
}
|
||||
|
||||
void setSearch(String search)
|
||||
{
|
||||
searchString = search == null ? "" : search;
|
||||
}
|
||||
|
||||
public void postUpdate(IAEItemStack is)
|
||||
{
|
||||
IAEItemStack st = list.findPrecise( is );
|
||||
|
||||
if ( st != null )
|
||||
{
|
||||
st.reset();
|
||||
st.add( is );
|
||||
}
|
||||
else
|
||||
list.add( is );
|
||||
}
|
||||
|
||||
IPartitionList<IAEItemStack> myPartitionList;
|
||||
|
||||
public void setViewCell(ItemStack[] list)
|
||||
{
|
||||
myPartitionList = ItemViewCell.createFilter( list );
|
||||
updateView();
|
||||
}
|
||||
|
||||
private String NEIWord = null;
|
||||
|
||||
private void updateNEI(String filter)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( NEIWord == null || !NEIWord.equals( filter ) )
|
||||
{
|
||||
Class c = ReflectionHelper.getClass( getClass().getClassLoader(), "codechicken.nei.LayoutManager" );
|
||||
Field fldSearchField = c.getField( "searchField" );
|
||||
Object searchField = fldSearchField.get( c );
|
||||
|
||||
Method a = searchField.getClass().getMethod( "setText", String.class );
|
||||
Method b = searchField.getClass().getMethod( "onTextChange", String.class );
|
||||
|
||||
NEIWord = filter;
|
||||
a.invoke( searchField, new String( filter ) );
|
||||
b.invoke( searchField, "" );
|
||||
}
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void updateView()
|
||||
{
|
||||
view.clear();
|
||||
dsp.clear();
|
||||
|
||||
view.ensureCapacity( list.size() );
|
||||
dsp.ensureCapacity( list.size() );
|
||||
|
||||
Enum vmode = sortSrc.getSortDisplay();
|
||||
Enum mode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
|
||||
if ( mode == SearchBoxMode.NEI_AUTOSEARCH || mode == SearchBoxMode.NEI_MANUAL_SEARCH )
|
||||
updateNEI( searchString );
|
||||
|
||||
innerSearch = searchString;
|
||||
boolean terminalSearchToolTips = AEConfig.instance.settings.getSetting( Settings.SEARCH_TOOLTIPS ) != YesNo.NO;
|
||||
// boolean terminalSearchMods = Configuration.instance.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO;
|
||||
|
||||
boolean searchMod = false;
|
||||
if ( innerSearch.startsWith( "@" ) )
|
||||
{
|
||||
searchMod = true;
|
||||
innerSearch = innerSearch.substring( 1 );
|
||||
}
|
||||
|
||||
Pattern m = null;
|
||||
try
|
||||
{
|
||||
m = Pattern.compile( innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE );
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
{
|
||||
try
|
||||
{
|
||||
m = Pattern.compile( Pattern.quote( innerSearch.toLowerCase() ), Pattern.CASE_INSENSITIVE );
|
||||
}
|
||||
catch (Throwable __)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean notDone = false;
|
||||
for (IAEItemStack is : list)
|
||||
{
|
||||
if ( myPartitionList != null )
|
||||
{
|
||||
if ( !myPartitionList.isListed( is ) )
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( vmode == ViewItems.CRAFTABLE && !is.isCraftable() )
|
||||
continue;
|
||||
|
||||
if ( vmode == ViewItems.CRAFTABLE )
|
||||
{
|
||||
is = is.copy();
|
||||
is.setStackSize( 0 );
|
||||
}
|
||||
|
||||
if ( vmode == ViewItems.STORED && is.getStackSize() == 0 )
|
||||
continue;
|
||||
|
||||
String dspName = searchMod ? Platform.getModId( is ) : Platform.getItemDisplayName( is );
|
||||
notDone = true;
|
||||
|
||||
if ( m.matcher( dspName.toLowerCase() ).find() )
|
||||
{
|
||||
view.add( is );
|
||||
notDone = false;
|
||||
}
|
||||
|
||||
if ( terminalSearchToolTips && notDone )
|
||||
{
|
||||
for (Object lp : Platform.getTooltip( is ))
|
||||
if ( lp instanceof String && m.matcher( (String) lp ).find() )
|
||||
{
|
||||
view.add( is );
|
||||
notDone = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if ( terminalSearchMods && notDone ) { if ( m.matcher( Platform.getMod( is.getItemStack() ) ).find() ) {
|
||||
* view.add( is ); notDone = false; } }
|
||||
*/
|
||||
}
|
||||
|
||||
Enum SortBy = sortSrc.getSortBy();
|
||||
Enum SortDir = sortSrc.getSortDir();
|
||||
|
||||
ItemSorters.Direction = (appeng.api.config.SortDir) SortDir;
|
||||
ItemSorters.init();
|
||||
|
||||
if ( SortBy == SortOrder.MOD )
|
||||
Collections.sort( view, ItemSorters.ConfigBased_SortByMod );
|
||||
else if ( SortBy == SortOrder.AMOUNT )
|
||||
Collections.sort( view, ItemSorters.ConfigBased_SortBySize );
|
||||
else if ( SortBy == SortOrder.INVTWEAKS )
|
||||
Collections.sort( view, ItemSorters.ConfigBased_SortByInvTweaks );
|
||||
else
|
||||
Collections.sort( view, ItemSorters.ConfigBased_SortByName );
|
||||
|
||||
for (IAEItemStack is : view)
|
||||
dsp.add( is.getItemStack() );
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return view.size();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
list.resetStatus();
|
||||
}
|
||||
|
||||
private boolean hasPower;
|
||||
|
||||
public boolean hasPower()
|
||||
{
|
||||
return hasPower;
|
||||
}
|
||||
|
||||
public void setPower(boolean hasPower)
|
||||
{
|
||||
this.hasPower = hasPower;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package appeng.client.me;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class SlotDisconnected extends AppEngSlot
|
||||
{
|
||||
|
||||
public ClientDCInternalInv mySlot;
|
||||
|
||||
public SlotDisconnected(ClientDCInternalInv me, int which, int x, int y) {
|
||||
super( me.inv, which, x, y );
|
||||
mySlot = me;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
if ( Platform.isClient() )// && (which == PlaceableItemType.ENCODED_PATTERN) )
|
||||
{
|
||||
ItemStack is = super.getStack();
|
||||
if ( is != null && is.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
ItemStack out = iep.getOutput( is );
|
||||
if ( out != null )
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack par1ItemStack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack()
|
||||
{
|
||||
return getStack() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotInInventory(IInventory par1iInventory, int par2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package appeng.client.me;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
public class SlotME extends Slot
|
||||
{
|
||||
|
||||
public InternalSlotME mySlot;
|
||||
|
||||
public SlotME(InternalSlotME me) {
|
||||
super( null, 0, me.xPos, me.yPos );
|
||||
mySlot = me;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if ( mySlot.hasPower() )
|
||||
return mySlot.getStack();
|
||||
return null;
|
||||
}
|
||||
|
||||
public IAEItemStack getAEStack()
|
||||
{
|
||||
if ( mySlot.hasPower() )
|
||||
return mySlot.getAEStack();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack par1ItemStack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack()
|
||||
{
|
||||
if ( mySlot.hasPower() )
|
||||
return getStack() != null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotInInventory(IInventory par1iInventory, int par2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
public class AppEngRenderItem extends RenderItem
|
||||
{
|
||||
|
||||
public IAEItemStack aestack;
|
||||
|
||||
private void renderQuad(Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
par1Tessellator.startDrawingQuads();
|
||||
par1Tessellator.setColorOpaque_I( par6 );
|
||||
par1Tessellator.addVertex( par2 + 0, par3 + 0, 0.0D );
|
||||
par1Tessellator.addVertex( par2 + 0, par3 + par5, 0.0D );
|
||||
par1Tessellator.addVertex( par2 + par4, par3 + par5, 0.0D );
|
||||
par1Tessellator.addVertex( par2 + par4, par3 + 0, 0.0D );
|
||||
par1Tessellator.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItemOverlayIntoGUI(FontRenderer par1FontRenderer, TextureManager par2RenderEngine, ItemStack par3ItemStack, int par4, int par5)
|
||||
{
|
||||
this.renderItemOverlayIntoGUI( par1FontRenderer, par2RenderEngine, par3ItemStack, par4, par5, (String) null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItemOverlayIntoGUI(FontRenderer par1FontRenderer, TextureManager par2RenderEngine, ItemStack is, int par4, int par5, String par6Str)
|
||||
{
|
||||
if ( is != null )
|
||||
{
|
||||
float ScaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f;
|
||||
float RScaleFactor = 1.0f / ScaleFactor;
|
||||
int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1;
|
||||
|
||||
boolean unicodeFlag = par1FontRenderer.getUnicodeFlag();
|
||||
par1FontRenderer.setUnicodeFlag( false );
|
||||
|
||||
if ( is.getItem().showDurabilityBar( is ) )
|
||||
{
|
||||
double health = is.getItem().getDurabilityForDisplay( is );
|
||||
int j1 = (int) Math.round( 13.0D - health * 13.0D );
|
||||
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 );
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
int l = 255 - k << 16 | k << 8;
|
||||
int i1 = (255 - k) / 4 << 16 | 16128;
|
||||
this.renderQuad( tessellator, par4 + 2, par5 + 13, 13, 2, 0 );
|
||||
this.renderQuad( tessellator, par4 + 2, par5 + 13, 12, 1, i1 );
|
||||
this.renderQuad( tessellator, par4 + 2, par5 + 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 )
|
||||
{
|
||||
String var6 = AEConfig.instance.useTerminalUseLargeFont() ? "+" : "Craft";
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( ScaleFactor, ScaleFactor, ScaleFactor );
|
||||
int X = (int) (((float) par4 + offset + 16.0f - par1FontRenderer.getStringWidth( var6 ) * ScaleFactor) * RScaleFactor);
|
||||
int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * ScaleFactor) * RScaleFactor);
|
||||
par1FontRenderer.drawStringWithShadow( var6, X, Y, 16777215 );
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
||||
}
|
||||
|
||||
long amount = aestack != null ? aestack.getStackSize() : is.stackSize;
|
||||
if ( amount > 999999999999L )
|
||||
amount = 999999999999L;
|
||||
|
||||
if ( amount != 0 )
|
||||
{
|
||||
String var6 = "" + Math.abs( amount );
|
||||
|
||||
if ( AEConfig.instance.useTerminalUseLargeFont() )
|
||||
{
|
||||
if ( amount > 999999999 )
|
||||
{
|
||||
var6 = "" + (int) Math.floor( amount / 1000000000.0 ) + "B";
|
||||
}
|
||||
else if ( amount > 99999999 )
|
||||
{
|
||||
var6 = "." + (int) Math.floor( amount / 100000000.0 ) + "B";
|
||||
}
|
||||
else if ( amount > 999999 )
|
||||
{
|
||||
var6 = "" + (int) Math.floor( amount / 1000000.0 ) + "M";
|
||||
}
|
||||
else if ( amount > 99999 )
|
||||
{
|
||||
var6 = "." + (int) Math.floor( amount / 100000.0 ) + "M";
|
||||
}
|
||||
else if ( amount > 999 )
|
||||
{
|
||||
var6 = "" + (int) Math.floor( amount / 1000.0 ) + "K";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( amount > 999999999 )
|
||||
{
|
||||
var6 = "" + (int) Math.floor( amount / 1000000000.0 ) + "B";
|
||||
}
|
||||
else if ( amount > 999999999 )
|
||||
{
|
||||
var6 = "" + (int) Math.floor( amount / 1000000000.0 ) + "B";
|
||||
}
|
||||
else if ( amount > 999999 )
|
||||
{
|
||||
var6 = "" + (int) Math.floor( amount / 1000000.0 ) + "M";
|
||||
}
|
||||
else if ( amount > 9999 )
|
||||
{
|
||||
var6 = "" + (int) Math.floor( amount / 1000.0 ) + "K";
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( ScaleFactor, ScaleFactor, ScaleFactor );
|
||||
int X = (int) (((float) par4 + offset + 16.0f - par1FontRenderer.getStringWidth( var6 ) * ScaleFactor) * RScaleFactor);
|
||||
int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * ScaleFactor) * RScaleFactor);
|
||||
par1FontRenderer.drawStringWithShadow( var6, X, Y, 16777215 );
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
||||
}
|
||||
|
||||
par1FontRenderer.setUnicodeFlag( unicodeFlag );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,789 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BaseBlockRender
|
||||
{
|
||||
|
||||
final int ORIENTATION_BITS = 7;
|
||||
final static int FLIP_H_BIT = 8;
|
||||
final static int FLIP_V_BIT = 16;
|
||||
|
||||
final double MAX_DISTANCE;
|
||||
final public boolean hasTESR;
|
||||
final static private byte OrientationMap[][][] = new byte[6][6][6];
|
||||
|
||||
protected int adjustBrightness(int v, double d)
|
||||
{
|
||||
int r = 0xff & (v >> 16);
|
||||
int g = 0xff & (v >> 8);
|
||||
int b = 0xff & (v >> 0);
|
||||
|
||||
r *= d;
|
||||
g *= d;
|
||||
b *= d;
|
||||
|
||||
r = Math.min( 255, Math.max( 0, r ) );
|
||||
g = Math.min( 255, Math.max( 0, g ) );
|
||||
b = Math.min( 255, Math.max( 0, b ) );
|
||||
|
||||
return (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
static public int getOrientation(ForgeDirection in, ForgeDirection forward, ForgeDirection up)
|
||||
{
|
||||
if ( in == null || in.equals( ForgeDirection.UNKNOWN ) // 1
|
||||
|| forward == null || forward.equals( ForgeDirection.UNKNOWN ) // 2
|
||||
|| up == null || up.equals( ForgeDirection.UNKNOWN ) )
|
||||
return 0;
|
||||
|
||||
int a = in.ordinal();
|
||||
int b = forward.ordinal();
|
||||
int c = up.ordinal();
|
||||
|
||||
return OrientationMap[a][b][c];
|
||||
}
|
||||
|
||||
static public void setOriMap()
|
||||
{
|
||||
// pointed up...
|
||||
OrientationMap[0][3][1] = 0;
|
||||
OrientationMap[1][3][1] = 0;
|
||||
OrientationMap[2][3][1] = 0;
|
||||
OrientationMap[3][3][1] = 0;
|
||||
OrientationMap[4][3][1] = 0;
|
||||
OrientationMap[5][3][1] = 0;
|
||||
|
||||
OrientationMap[0][5][1] = 1;
|
||||
OrientationMap[1][5][1] = 2;
|
||||
OrientationMap[2][5][1] = 0;
|
||||
OrientationMap[3][5][1] = 0;
|
||||
OrientationMap[4][5][1] = 0;
|
||||
OrientationMap[5][5][1] = 0;
|
||||
|
||||
OrientationMap[0][2][1] = 3;
|
||||
OrientationMap[1][2][1] = 3;
|
||||
OrientationMap[2][2][1] = 0;
|
||||
OrientationMap[3][2][1] = 0;
|
||||
OrientationMap[4][2][1] = 0;
|
||||
OrientationMap[5][2][1] = 0;
|
||||
|
||||
OrientationMap[0][4][1] = 2;
|
||||
OrientationMap[1][4][1] = 1;
|
||||
OrientationMap[2][4][1] = 0;
|
||||
OrientationMap[3][4][1] = 0;
|
||||
OrientationMap[4][4][1] = 0;
|
||||
OrientationMap[5][4][1] = 0;
|
||||
|
||||
// upside down
|
||||
OrientationMap[0][3][0] = 0 | FLIP_H_BIT;
|
||||
OrientationMap[1][3][0] = 0 | FLIP_H_BIT;
|
||||
OrientationMap[2][3][0] = 3;
|
||||
OrientationMap[3][3][0] = 3;
|
||||
OrientationMap[4][3][0] = 3;
|
||||
OrientationMap[5][3][0] = 3;
|
||||
|
||||
OrientationMap[0][4][0] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[1][4][0] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[2][4][0] = 3;
|
||||
OrientationMap[3][4][0] = 3;
|
||||
OrientationMap[4][4][0] = 3;
|
||||
OrientationMap[5][4][0] = 3;
|
||||
|
||||
OrientationMap[0][5][0] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[1][5][0] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[2][5][0] = 3;
|
||||
OrientationMap[3][5][0] = 3;
|
||||
OrientationMap[4][5][0] = 3;
|
||||
OrientationMap[5][5][0] = 3;
|
||||
|
||||
OrientationMap[0][2][0] = 3 | FLIP_H_BIT;
|
||||
OrientationMap[1][2][0] = 3 | FLIP_H_BIT;
|
||||
OrientationMap[2][2][0] = 3;
|
||||
OrientationMap[3][2][0] = 3;
|
||||
OrientationMap[4][2][0] = 3;
|
||||
OrientationMap[5][2][0] = 3;
|
||||
|
||||
// side 1
|
||||
OrientationMap[0][3][5] = 1 | FLIP_V_BIT;
|
||||
OrientationMap[1][3][5] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[2][3][5] = 1;
|
||||
OrientationMap[3][3][5] = 1;
|
||||
OrientationMap[4][3][5] = 1;
|
||||
OrientationMap[5][3][5] = 1 | FLIP_V_BIT;
|
||||
|
||||
OrientationMap[0][1][5] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[1][1][5] = 1;
|
||||
OrientationMap[2][1][5] = 3 | FLIP_V_BIT;
|
||||
OrientationMap[3][1][5] = 3;
|
||||
OrientationMap[4][1][5] = 1 | FLIP_V_BIT;
|
||||
OrientationMap[5][1][5] = 1;
|
||||
|
||||
OrientationMap[0][2][5] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[1][2][5] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[2][2][5] = 1;
|
||||
OrientationMap[3][2][5] = 2 | FLIP_V_BIT;
|
||||
OrientationMap[4][2][5] = 1 | FLIP_V_BIT;
|
||||
OrientationMap[5][2][5] = 1;
|
||||
|
||||
OrientationMap[0][0][5] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[1][0][5] = 1;
|
||||
OrientationMap[2][0][5] = 0;
|
||||
OrientationMap[3][0][5] = 0 | FLIP_V_BIT;
|
||||
OrientationMap[4][0][5] = 1;
|
||||
OrientationMap[5][0][5] = 1 | FLIP_V_BIT;
|
||||
|
||||
// side 2
|
||||
OrientationMap[0][1][2] = 0 | FLIP_H_BIT;
|
||||
OrientationMap[1][1][2] = 0;
|
||||
OrientationMap[2][1][2] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[3][1][2] = 1;
|
||||
OrientationMap[4][1][2] = 3;
|
||||
OrientationMap[5][1][2] = 3 | FLIP_H_BIT;
|
||||
|
||||
OrientationMap[0][4][2] = 0 | FLIP_H_BIT;
|
||||
OrientationMap[1][4][2] = 0 | FLIP_H_BIT;
|
||||
OrientationMap[2][4][2] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[3][4][2] = 1;
|
||||
OrientationMap[4][4][2] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[5][4][2] = 2;
|
||||
|
||||
OrientationMap[0][0][2] = 0 | FLIP_V_BIT;
|
||||
OrientationMap[1][0][2] = 0;
|
||||
OrientationMap[2][0][2] = 2;
|
||||
OrientationMap[3][0][2] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[4][0][2] = 3 | FLIP_H_BIT;
|
||||
OrientationMap[5][0][2] = 0;
|
||||
|
||||
OrientationMap[0][5][2] = 0 | FLIP_H_BIT;
|
||||
OrientationMap[1][5][2] = 0 | FLIP_H_BIT;
|
||||
OrientationMap[2][5][2] = 2;
|
||||
OrientationMap[3][5][2] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[4][5][2] = 2;
|
||||
OrientationMap[5][5][2] = 1 | FLIP_H_BIT;
|
||||
|
||||
// side 3
|
||||
OrientationMap[0][0][3] = 3 | FLIP_H_BIT;
|
||||
OrientationMap[1][0][3] = 3;
|
||||
OrientationMap[2][0][3] = 1;
|
||||
OrientationMap[3][0][3] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[4][0][3] = 0;
|
||||
OrientationMap[5][0][3] = 0 | FLIP_H_BIT;
|
||||
|
||||
OrientationMap[0][4][3] = 3;
|
||||
OrientationMap[1][4][3] = 3;
|
||||
OrientationMap[2][4][3] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[3][4][3] = 2;
|
||||
OrientationMap[4][4][3] = 1;
|
||||
OrientationMap[5][4][3] = 2 | FLIP_H_BIT;
|
||||
|
||||
OrientationMap[0][1][3] = 3 | FLIP_V_BIT;
|
||||
OrientationMap[1][1][3] = 3;
|
||||
OrientationMap[2][1][3] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[3][1][3] = 2;
|
||||
OrientationMap[4][1][3] = 3 | FLIP_H_BIT;
|
||||
OrientationMap[5][1][3] = 0;
|
||||
|
||||
OrientationMap[0][5][3] = 3;
|
||||
OrientationMap[1][5][3] = 3;
|
||||
OrientationMap[2][5][3] = 1;
|
||||
OrientationMap[3][5][3] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[4][5][3] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[5][5][3] = 1;
|
||||
|
||||
// side 4
|
||||
OrientationMap[0][3][4] = 1;
|
||||
OrientationMap[1][3][4] = 2;
|
||||
OrientationMap[2][3][4] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[3][3][4] = 1;
|
||||
OrientationMap[4][3][4] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[5][3][4] = 1;
|
||||
|
||||
OrientationMap[0][0][4] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[1][0][4] = 2;
|
||||
OrientationMap[2][0][4] = 0;
|
||||
OrientationMap[3][0][4] = 0 | FLIP_H_BIT;
|
||||
OrientationMap[4][0][4] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[5][0][4] = 1;
|
||||
|
||||
OrientationMap[0][1][4] = 1 | FLIP_H_BIT;
|
||||
OrientationMap[1][1][4] = 2;
|
||||
OrientationMap[2][1][4] = 3 | FLIP_H_BIT;
|
||||
OrientationMap[3][1][4] = 3;
|
||||
OrientationMap[4][1][4] = 2;
|
||||
OrientationMap[5][1][4] = 1 | FLIP_H_BIT;
|
||||
|
||||
OrientationMap[0][2][4] = 1;
|
||||
OrientationMap[1][2][4] = 2;
|
||||
OrientationMap[2][2][4] = 1;
|
||||
OrientationMap[3][2][4] = 2 | FLIP_H_BIT;
|
||||
OrientationMap[4][2][4] = 2;
|
||||
OrientationMap[5][2][4] = 1 | FLIP_H_BIT;
|
||||
}
|
||||
|
||||
public BaseBlockRender() {
|
||||
this( false, 20 );
|
||||
}
|
||||
|
||||
public BaseBlockRender(boolean enableTESR, double TESRrange) {
|
||||
hasTESR = enableTESR;
|
||||
MAX_DISTANCE = TESRrange;
|
||||
setOriMap();
|
||||
}
|
||||
|
||||
public double getTesrRenderDistance()
|
||||
{
|
||||
return MAX_DISTANCE;
|
||||
}
|
||||
|
||||
public IIcon firstNotNull(IIcon... s)
|
||||
{
|
||||
for (IIcon o : s)
|
||||
if ( o != null )
|
||||
return o;
|
||||
return ExtraBlockTextures.getMissing();
|
||||
}
|
||||
|
||||
public void renderInvBlock(EnumSet<ForgeDirection> sides, AEBaseBlock block, ItemStack item, Tessellator tess, int color, RenderBlocks renderer)
|
||||
{
|
||||
if ( Platform.isDrawing( tess ) )
|
||||
tess.draw();
|
||||
|
||||
int meta = 0;
|
||||
if ( block != null && block.hasSubtypes() && item != null )
|
||||
meta = item.getItemDamage();
|
||||
|
||||
if ( sides.contains( ForgeDirection.DOWN ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( 0.0F, -1.0F, 0.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceYNeg(
|
||||
block,
|
||||
0.0D,
|
||||
0.0D,
|
||||
0.0D,
|
||||
firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.DOWN ),
|
||||
block.getIcon( ForgeDirection.DOWN.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
if ( sides.contains( ForgeDirection.UP ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( 0.0F, 1.0F, 0.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceYPos(
|
||||
block,
|
||||
0.0D,
|
||||
0.0D,
|
||||
0.0D,
|
||||
firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.UP ),
|
||||
block.getIcon( ForgeDirection.UP.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
if ( sides.contains( ForgeDirection.NORTH ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( 0.0F, 0.0F, -1.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceZNeg(
|
||||
block,
|
||||
0.0D,
|
||||
0.0D,
|
||||
0.0D,
|
||||
firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.NORTH ),
|
||||
block.getIcon( ForgeDirection.NORTH.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
if ( sides.contains( ForgeDirection.SOUTH ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( 0.0F, 0.0F, 1.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceZPos(
|
||||
block,
|
||||
0.0D,
|
||||
0.0D,
|
||||
0.0D,
|
||||
firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.SOUTH ),
|
||||
block.getIcon( ForgeDirection.SOUTH.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
if ( sides.contains( ForgeDirection.WEST ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( -1.0F, 0.0F, 0.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceXNeg(
|
||||
block,
|
||||
0.0D,
|
||||
0.0D,
|
||||
0.0D,
|
||||
firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.WEST ),
|
||||
block.getIcon( ForgeDirection.WEST.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
if ( sides.contains( ForgeDirection.EAST ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( 1.0F, 0.0F, 0.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceXPos(
|
||||
block,
|
||||
0.0D,
|
||||
0.0D,
|
||||
0.0D,
|
||||
firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.EAST ),
|
||||
block.getIcon( ForgeDirection.EAST.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
}
|
||||
}
|
||||
|
||||
public void renderInventory(AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type, Object[] data)
|
||||
{
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
BlockRenderInfo info = block.getRendererInstance();
|
||||
if ( info.isValid() )
|
||||
{
|
||||
if ( block.hasSubtypes() )
|
||||
block.setRenderStateByMeta( item.getItemDamage() );
|
||||
|
||||
renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip(
|
||||
getOrientation( ForgeDirection.DOWN, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( getOrientation( ForgeDirection.UP, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
|
||||
renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip(
|
||||
getOrientation( ForgeDirection.EAST, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip(
|
||||
getOrientation( ForgeDirection.WEST, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
|
||||
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip(
|
||||
getOrientation( ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip(
|
||||
getOrientation( ForgeDirection.SOUTH, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
}
|
||||
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), block, item, tess, 0xffffff, renderer );
|
||||
|
||||
if ( block.hasSubtypes() )
|
||||
info.setTemporaryRenderIcon( null );
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
}
|
||||
|
||||
public IOrientable getOrientable(AEBaseBlock block, IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
if ( block.hasBlockTileEntity() )
|
||||
return (AEBaseTile) block.getTileEntity( w, x, y, z );
|
||||
else if ( block instanceof IOrientableBlock )
|
||||
return ((IOrientableBlock) block).getOrientable( w, x, y, z );
|
||||
return null;
|
||||
}
|
||||
|
||||
public void preRenderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
ForgeDirection forward = ForgeDirection.SOUTH;
|
||||
ForgeDirection up = ForgeDirection.UP;
|
||||
|
||||
BlockRenderInfo info = block.getRendererInstance();
|
||||
IOrientable te = getOrientable( block, world, x, y, z );
|
||||
if ( te != null )
|
||||
{
|
||||
forward = te.getForward();
|
||||
up = te.getUp();
|
||||
|
||||
renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( getOrientation( ForgeDirection.DOWN, forward, up ) );
|
||||
renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( getOrientation( ForgeDirection.UP, forward, up ) );
|
||||
|
||||
renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( getOrientation( ForgeDirection.EAST, forward, up ) );
|
||||
renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( getOrientation( ForgeDirection.WEST, forward, up ) );
|
||||
|
||||
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( getOrientation( ForgeDirection.NORTH, forward, up ) );
|
||||
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( getOrientation( ForgeDirection.SOUTH, forward, up ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void postRenderInWorld(RenderBlocks renderer)
|
||||
{
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
}
|
||||
|
||||
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
preRenderInWorld( block, world, x, y, z, renderer );
|
||||
|
||||
boolean o = renderer.renderStandardBlock( block, x, y, z );
|
||||
|
||||
postRenderInWorld( renderer );
|
||||
return o;
|
||||
}
|
||||
|
||||
final FloatBuffer rotMat = BufferUtils.createFloatBuffer( 16 );
|
||||
|
||||
protected void applyTESRRotation(double x, double y, double z, ForgeDirection forward, ForgeDirection up)
|
||||
{
|
||||
if ( forward != null && up != null )
|
||||
{
|
||||
if ( forward == ForgeDirection.UNKNOWN )
|
||||
forward = ForgeDirection.SOUTH;
|
||||
|
||||
if ( up == ForgeDirection.UNKNOWN )
|
||||
up = ForgeDirection.UP;
|
||||
|
||||
ForgeDirection west = Platform.crossProduct( forward, up );
|
||||
|
||||
rotMat.put( 0, west.offsetX );
|
||||
rotMat.put( 1, west.offsetY );
|
||||
rotMat.put( 2, west.offsetZ );
|
||||
rotMat.put( 3, 0 );
|
||||
|
||||
rotMat.put( 4, up.offsetX );
|
||||
rotMat.put( 5, up.offsetY );
|
||||
rotMat.put( 6, up.offsetZ );
|
||||
rotMat.put( 7, 0 );
|
||||
|
||||
rotMat.put( 8, forward.offsetX );
|
||||
rotMat.put( 9, forward.offsetY );
|
||||
rotMat.put( 10, forward.offsetZ );
|
||||
rotMat.put( 11, 0 );
|
||||
|
||||
rotMat.put( 12, 0 );
|
||||
rotMat.put( 13, 0 );
|
||||
rotMat.put( 14, 0 );
|
||||
rotMat.put( 15, 1 );
|
||||
GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 );
|
||||
GL11.glMultMatrix( rotMat );
|
||||
GL11.glTranslated( -0.5, -0.5, -0.5 );
|
||||
GL11.glCullFace( GL11.GL_FRONT );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glTranslated( x, y, z );
|
||||
}
|
||||
}
|
||||
|
||||
protected void setInvRenderBounds(RenderBlocks renderer, int i, int j, int k, int l, int m, int n)
|
||||
{
|
||||
renderer.setRenderBounds( i / 16.0, j / 16.0, k / 16.0, l / 16.0, m / 16.0, n / 16.0 );
|
||||
}
|
||||
|
||||
protected void renderBlockBounds(RenderBlocks renderer,
|
||||
|
||||
double minX, double minY, double minZ,
|
||||
|
||||
double maxX, double maxY, double maxZ,
|
||||
|
||||
ForgeDirection x, ForgeDirection y, ForgeDirection z)
|
||||
{
|
||||
minX /= 16.0;
|
||||
minY /= 16.0;
|
||||
minZ /= 16.0;
|
||||
maxX /= 16.0;
|
||||
maxY /= 16.0;
|
||||
maxZ /= 16.0;
|
||||
|
||||
double aX = minX * x.offsetX + minY * y.offsetX + minZ * z.offsetX;
|
||||
double aY = minX * x.offsetY + minY * y.offsetY + minZ * z.offsetY;
|
||||
double aZ = minX * x.offsetZ + minY * y.offsetZ + minZ * z.offsetZ;
|
||||
|
||||
double bX = maxX * x.offsetX + maxY * y.offsetX + maxZ * z.offsetX;
|
||||
double bY = maxX * x.offsetY + maxY * y.offsetY + maxZ * z.offsetY;
|
||||
double bZ = maxX * x.offsetZ + maxY * y.offsetZ + maxZ * z.offsetZ;
|
||||
|
||||
if ( x.offsetX + y.offsetX + z.offsetX < 0 )
|
||||
{
|
||||
aX += 1;
|
||||
bX += 1;
|
||||
}
|
||||
|
||||
if ( x.offsetY + y.offsetY + z.offsetY < 0 )
|
||||
{
|
||||
aY += 1;
|
||||
bY += 1;
|
||||
}
|
||||
|
||||
if ( x.offsetZ + y.offsetZ + z.offsetZ < 0 )
|
||||
{
|
||||
aZ += 1;
|
||||
bZ += 1;
|
||||
}
|
||||
|
||||
renderer.renderMinX = Math.min( aX, bX );
|
||||
renderer.renderMinY = Math.min( aY, bY );
|
||||
renderer.renderMinZ = Math.min( aZ, bZ );
|
||||
renderer.renderMaxX = Math.max( aX, bX );
|
||||
renderer.renderMaxY = Math.max( aY, bY );
|
||||
renderer.renderMaxZ = Math.max( aZ, bZ );
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void renderFace(Tessellator tess, double offsetX, double offsetY, double offsetZ, double ax, double ay, double az, double bx, double by, double bz,
|
||||
double ua, double ub, double va, double vb, IIcon ico, boolean flip)
|
||||
{
|
||||
if ( flip )
|
||||
{
|
||||
tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ),
|
||||
ico.getInterpolatedV( va * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ),
|
||||
ico.getInterpolatedV( vb * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ),
|
||||
ico.getInterpolatedV( vb * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ),
|
||||
ico.getInterpolatedV( va * 16.0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ),
|
||||
ico.getInterpolatedV( va * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ),
|
||||
ico.getInterpolatedV( va * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ),
|
||||
ico.getInterpolatedV( vb * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ),
|
||||
ico.getInterpolatedV( vb * 16.0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void renderCutoutFace(Block block, IIcon ico, int x, int y, int z, RenderBlocks renderer, ForgeDirection orientation, float edgeThickness)
|
||||
{
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
double offsetX = 0.0, offsetY = 0.0, offsetZ = 0.0;
|
||||
double layaX = 0.0, layaY = 0.0, layaZ = 0.0;
|
||||
double laybX = 0.0, laybY = 0.0, laybZ = 0.0;
|
||||
|
||||
boolean flip = false;
|
||||
switch (orientation)
|
||||
{
|
||||
case NORTH:
|
||||
|
||||
layaX = 1.0;
|
||||
laybY = 1.0;
|
||||
flip = true;
|
||||
|
||||
break;
|
||||
case SOUTH:
|
||||
|
||||
layaX = 1.0;
|
||||
laybY = 1.0;
|
||||
offsetZ = 1.0;
|
||||
|
||||
break;
|
||||
case EAST:
|
||||
|
||||
flip = true;
|
||||
layaZ = 1.0;
|
||||
laybY = 1.0;
|
||||
offsetX = 1.0;
|
||||
|
||||
break;
|
||||
case WEST:
|
||||
|
||||
layaZ = 1.0;
|
||||
laybY = 1.0;
|
||||
|
||||
break;
|
||||
case UP:
|
||||
|
||||
flip = true;
|
||||
layaX = 1.0;
|
||||
laybZ = 1.0;
|
||||
offsetY = 1.0;
|
||||
|
||||
break;
|
||||
case DOWN:
|
||||
|
||||
layaX = 1.0;
|
||||
laybZ = 1.0;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
offsetX += x;
|
||||
offsetY += y;
|
||||
offsetZ += z;
|
||||
|
||||
renderFace( tess, offsetX, offsetY, offsetZ, layaX, layaY, layaZ, laybX, laybY, laybZ,
|
||||
// u -> u
|
||||
0, 1.0,
|
||||
// v -> v
|
||||
0, edgeThickness, ico, flip );
|
||||
|
||||
renderFace( tess, offsetX, offsetY, offsetZ, layaX, layaY, layaZ, laybX, laybY, laybZ,
|
||||
// u -> u
|
||||
0.0, edgeThickness,
|
||||
// v -> v
|
||||
edgeThickness, 1.0 - edgeThickness, ico, flip );
|
||||
|
||||
renderFace( tess, offsetX, offsetY, offsetZ, layaX, layaY, layaZ, laybX, laybY, laybZ,
|
||||
// u -> u
|
||||
1.0 - edgeThickness, 1.0,
|
||||
// v -> v
|
||||
edgeThickness, 1.0 - edgeThickness, ico, flip );
|
||||
|
||||
renderFace( tess, offsetX, offsetY, offsetZ, layaX, layaY, layaZ, laybX, laybY, laybZ,
|
||||
// u -> u
|
||||
0, 1.0,
|
||||
// v -> v
|
||||
1.0 - edgeThickness, 1.0, ico, flip );
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void renderFace(int x, int y, int z, Block block, IIcon ico, RenderBlocks renderer, ForgeDirection orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case NORTH:
|
||||
renderer.renderFaceZNeg( block, x, y, z, ico );
|
||||
break;
|
||||
case SOUTH:
|
||||
renderer.renderFaceZPos( block, x, y, z, ico );
|
||||
break;
|
||||
case EAST:
|
||||
renderer.renderFaceXPos( block, x, y, z, ico );
|
||||
break;
|
||||
case WEST:
|
||||
renderer.renderFaceXNeg( block, x, y, z, ico );
|
||||
break;
|
||||
case UP:
|
||||
renderer.renderFaceYPos( block, x, y, z, ico );
|
||||
break;
|
||||
case DOWN:
|
||||
renderer.renderFaceYNeg( block, x, y, z, ico );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void selectFace(RenderBlocks renderer, ForgeDirection west, ForgeDirection up, ForgeDirection forward, int u1, int u2, int v1, int v2)
|
||||
{
|
||||
v1 = 16 - v1;
|
||||
v2 = 16 - v2;
|
||||
|
||||
double minX = (forward.offsetX > 0 ? 1 : 0) + mapFaceUV( west.offsetX, u1 ) + mapFaceUV( up.offsetX, v1 );
|
||||
double minY = (forward.offsetY > 0 ? 1 : 0) + mapFaceUV( west.offsetY, u1 ) + mapFaceUV( up.offsetY, v1 );
|
||||
double minZ = (forward.offsetZ > 0 ? 1 : 0) + mapFaceUV( west.offsetZ, u1 ) + mapFaceUV( up.offsetZ, v1 );
|
||||
|
||||
double maxX = (forward.offsetX > 0 ? 1 : 0) + mapFaceUV( west.offsetX, u2 ) + mapFaceUV( up.offsetX, v2 );
|
||||
double maxY = (forward.offsetY > 0 ? 1 : 0) + mapFaceUV( west.offsetY, u2 ) + mapFaceUV( up.offsetY, v2 );
|
||||
double maxZ = (forward.offsetZ > 0 ? 1 : 0) + mapFaceUV( west.offsetZ, u2 ) + mapFaceUV( up.offsetZ, v2 );
|
||||
|
||||
renderer.renderMinX = Math.max( 0.0, Math.min( minX, maxX ) - (forward.offsetX != 0 ? 0 : 0.001) );
|
||||
renderer.renderMaxX = Math.min( 1.0, Math.max( minX, maxX ) + (forward.offsetX != 0 ? 0 : 0.001) );
|
||||
|
||||
renderer.renderMinY = Math.max( 0.0, Math.min( minY, maxY ) - (forward.offsetY != 0 ? 0 : 0.001) );
|
||||
renderer.renderMaxY = Math.min( 1.0, Math.max( minY, maxY ) + (forward.offsetY != 0 ? 0 : 0.001) );
|
||||
|
||||
renderer.renderMinZ = Math.max( 0.0, Math.min( minZ, maxZ ) - (forward.offsetZ != 0 ? 0 : 0.001) );
|
||||
renderer.renderMaxZ = Math.min( 1.0, Math.max( minZ, maxZ ) + (forward.offsetZ != 0 ? 0 : 0.001) );
|
||||
}
|
||||
|
||||
private double mapFaceUV(int offset, int uv)
|
||||
{
|
||||
if ( offset == 0 )
|
||||
return 0;
|
||||
|
||||
if ( offset > 0 )
|
||||
return (double) uv / 16.0;
|
||||
|
||||
return (16.0 - (double) uv) / 16.0;
|
||||
}
|
||||
|
||||
public void renderTile(AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer)
|
||||
{
|
||||
ForgeDirection forward = ForgeDirection.SOUTH;
|
||||
ForgeDirection up = ForgeDirection.UP;
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateTop = renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = 0;
|
||||
|
||||
applyTESRRotation( x, y, z, forward, up );
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.locationBlocksTexture );
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
if ( Minecraft.isAmbientOcclusionEnabled() )
|
||||
GL11.glShadeModel( GL11.GL_SMOOTH );
|
||||
else
|
||||
GL11.glShadeModel( GL11.GL_FLAT );
|
||||
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
tess.setTranslation( -tile.xCoord, -tile.yCoord, -tile.zCoord );
|
||||
tess.startDrawingQuads();
|
||||
|
||||
// note that this is a terrible approach...
|
||||
renderer.setRenderBoundsFromBlock( block );
|
||||
renderer.renderStandardBlock( block, tile.xCoord, tile.yCoord, tile.zCoord );
|
||||
|
||||
tess.draw();
|
||||
tess.setTranslation( 0, 0, 0 );
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateTop = renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = 0;
|
||||
}
|
||||
|
||||
public void doRenderItem(ItemStack itemstack, TileEntity par1EntityItemFrame)
|
||||
{
|
||||
if ( itemstack != null )
|
||||
{
|
||||
EntityItem entityitem = new EntityItem( par1EntityItemFrame.getWorldObj(), 0.0D, 0.0D, 0.0D, itemstack );
|
||||
entityitem.getEntityItem().stackSize = 1;
|
||||
|
||||
// set all this stuff and then do shit? meh?
|
||||
entityitem.hoverStart = 0;
|
||||
entityitem.age = 0;
|
||||
entityitem.rotationYaw = 0;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef( 0, -0.14F, 0 );
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw( entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F );
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import appeng.client.texture.FlippableIcon;
|
||||
import appeng.client.texture.TmpFlippableIcon;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockRenderInfo
|
||||
{
|
||||
|
||||
public BlockRenderInfo(BaseBlockRender inst) {
|
||||
rendererInstance = inst;
|
||||
}
|
||||
|
||||
final public BaseBlockRender rendererInstance;
|
||||
|
||||
private boolean useTmp = false;
|
||||
private TmpFlippableIcon tmpTopIcon = new TmpFlippableIcon();
|
||||
private TmpFlippableIcon tmpBottomIcon = new TmpFlippableIcon();
|
||||
private TmpFlippableIcon tmpSouthIcon = new TmpFlippableIcon();
|
||||
private TmpFlippableIcon tmpNorthIcon = new TmpFlippableIcon();
|
||||
private TmpFlippableIcon tmpEastIcon = new TmpFlippableIcon();
|
||||
private TmpFlippableIcon tmpWestIcon = new TmpFlippableIcon();
|
||||
|
||||
private FlippableIcon topIcon = null;
|
||||
private FlippableIcon bottomIcon = null;
|
||||
private FlippableIcon southIcon = null;
|
||||
private FlippableIcon northIcon = null;
|
||||
private FlippableIcon eastIcon = null;
|
||||
private FlippableIcon westIcon = null;
|
||||
|
||||
public void updateIcons(FlippableIcon Bottom, FlippableIcon Top, FlippableIcon North, FlippableIcon South, FlippableIcon East, FlippableIcon West)
|
||||
{
|
||||
topIcon = Top;
|
||||
bottomIcon = Bottom;
|
||||
southIcon = South;
|
||||
northIcon = North;
|
||||
eastIcon = East;
|
||||
westIcon = West;
|
||||
|
||||
}
|
||||
|
||||
public void setTemporaryRenderIcon(IIcon IIcon)
|
||||
{
|
||||
if ( IIcon == null )
|
||||
useTmp = false;
|
||||
else
|
||||
{
|
||||
useTmp = true;
|
||||
tmpTopIcon.setOriginal( IIcon );
|
||||
tmpBottomIcon.setOriginal( IIcon );
|
||||
tmpSouthIcon.setOriginal( IIcon );
|
||||
tmpNorthIcon.setOriginal( IIcon );
|
||||
tmpEastIcon.setOriginal( IIcon );
|
||||
tmpWestIcon.setOriginal( IIcon );
|
||||
}
|
||||
}
|
||||
|
||||
public void setTemporaryRenderIcons(IIcon nTopIcon, IIcon nBottomIcon, IIcon nSouthIcon, IIcon nNorthIcon, IIcon nEastIcon, IIcon nWestIcon)
|
||||
{
|
||||
tmpTopIcon.setOriginal( nTopIcon == null ? getTexture( ForgeDirection.UP ) : nTopIcon );
|
||||
tmpBottomIcon.setOriginal( nBottomIcon == null ? getTexture( ForgeDirection.DOWN ) : nBottomIcon );
|
||||
tmpSouthIcon.setOriginal( nSouthIcon == null ? getTexture( ForgeDirection.SOUTH ) : nSouthIcon );
|
||||
tmpNorthIcon.setOriginal( nNorthIcon == null ? getTexture( ForgeDirection.NORTH ) : nNorthIcon );
|
||||
tmpEastIcon.setOriginal( nEastIcon == null ? getTexture( ForgeDirection.EAST ) : nEastIcon );
|
||||
tmpWestIcon.setOriginal( nWestIcon == null ? getTexture( ForgeDirection.WEST ) : nWestIcon );
|
||||
useTmp = true;
|
||||
}
|
||||
|
||||
public FlippableIcon getTexture(ForgeDirection dir)
|
||||
{
|
||||
if ( useTmp )
|
||||
{
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
return tmpBottomIcon;
|
||||
case UP:
|
||||
return tmpTopIcon;
|
||||
case NORTH:
|
||||
return tmpNorthIcon;
|
||||
case SOUTH:
|
||||
return tmpSouthIcon;
|
||||
case EAST:
|
||||
return tmpEastIcon;
|
||||
case WEST:
|
||||
return tmpWestIcon;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
return bottomIcon;
|
||||
case UP:
|
||||
return topIcon;
|
||||
case NORTH:
|
||||
return northIcon;
|
||||
case SOUTH:
|
||||
return southIcon;
|
||||
case EAST:
|
||||
return eastIcon;
|
||||
case WEST:
|
||||
return westIcon;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return topIcon;
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return topIcon != null && bottomIcon != null && southIcon != null && northIcon != null && eastIcon != null && westIcon != null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,495 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IBoxProvider;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.parts.ISimplifiedBundle;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BusRenderHelper implements IPartRenderHelper
|
||||
{
|
||||
|
||||
final public static BusRenderHelper instance = new BusRenderHelper();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 16;
|
||||
double maxY = 16;
|
||||
double maxZ = 16;
|
||||
|
||||
AEBaseBlock blk = (AEBaseBlock) AEApi.instance().blocks().blockMultiPart.block();
|
||||
BaseBlockRender bbr = new BaseBlockRender();
|
||||
|
||||
private ForgeDirection ax = ForgeDirection.EAST;
|
||||
private ForgeDirection ay = ForgeDirection.UP;
|
||||
private ForgeDirection az = ForgeDirection.SOUTH;
|
||||
|
||||
int color = 0xffffff;
|
||||
|
||||
class BoundBoxCalculator implements IPartCollisionHelper
|
||||
{
|
||||
|
||||
public boolean started = false;
|
||||
|
||||
float minX;
|
||||
float minY;
|
||||
float minZ;
|
||||
|
||||
float maxX;
|
||||
float maxY;
|
||||
float maxZ;
|
||||
|
||||
@Override
|
||||
public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
|
||||
{
|
||||
if ( started )
|
||||
{
|
||||
this.minX = Math.min( this.minX, (float) minX );
|
||||
this.minY = Math.min( this.minY, (float) minY );
|
||||
this.minZ = Math.min( this.minZ, (float) minZ );
|
||||
this.maxX = Math.max( this.maxX, (float) maxX );
|
||||
this.maxY = Math.max( this.maxY, (float) maxY );
|
||||
this.maxZ = Math.max( this.maxZ, (float) maxZ );
|
||||
}
|
||||
else
|
||||
{
|
||||
started = true;
|
||||
this.minX = (float) minX;
|
||||
this.minY = (float) minY;
|
||||
this.minZ = (float) minZ;
|
||||
this.maxX = (float) maxX;
|
||||
this.maxY = (float) maxY;
|
||||
this.maxZ = (float) maxZ;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldX()
|
||||
{
|
||||
return ax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldY()
|
||||
{
|
||||
return ay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldZ()
|
||||
{
|
||||
return az;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBBCollision()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BoundBoxCalculator bbc = new BoundBoxCalculator();
|
||||
|
||||
int renderingForPass = 0;
|
||||
int currentPass = 0;
|
||||
int itemsRendered = 0;
|
||||
boolean noAlphaPass = AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) == false;
|
||||
|
||||
public int getItemsRendered()
|
||||
{
|
||||
return itemsRendered;
|
||||
}
|
||||
|
||||
public void setPass(int pass)
|
||||
{
|
||||
renderingForPass = 0;
|
||||
currentPass = pass;
|
||||
itemsRendered = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderForPass(int pass)
|
||||
{
|
||||
renderingForPass = pass;
|
||||
}
|
||||
|
||||
public boolean renderThis()
|
||||
{
|
||||
if ( renderingForPass == currentPass || noAlphaPass )
|
||||
{
|
||||
itemsRendered++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void normalRendering()
|
||||
{
|
||||
RenderBlocksWorkaround rbw = BusRenderer.instance.renderer;
|
||||
rbw.calculations = true;
|
||||
rbw.useTextures = true;
|
||||
rbw.enableAO = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISimplifiedBundle useSimplifiedRendering(int x, int y, int z, IBoxProvider p, ISimplifiedBundle sim)
|
||||
{
|
||||
RenderBlocksWorkaround rbw = BusRenderer.instance.renderer;
|
||||
|
||||
if ( sim != null && rbw.similarLighting( blk, rbw.blockAccess, x, y, z, sim ) )
|
||||
{
|
||||
rbw.populate( sim );
|
||||
rbw.faces = EnumSet.allOf( ForgeDirection.class );
|
||||
rbw.calculations = false;
|
||||
rbw.useTextures = false;
|
||||
|
||||
return sim;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean allFaces = rbw.renderAllFaces;
|
||||
rbw.renderAllFaces = true;
|
||||
rbw.calculations = true;
|
||||
rbw.faces.clear();
|
||||
|
||||
bbc.started = false;
|
||||
if ( p == null )
|
||||
{
|
||||
bbc.minX = bbc.minY = bbc.minZ = 0;
|
||||
bbc.maxX = bbc.maxY = bbc.maxZ = 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getBoxes( bbc );
|
||||
|
||||
if ( bbc.minX < 1 )
|
||||
bbc.minX = 1;
|
||||
if ( bbc.minY < 1 )
|
||||
bbc.minY = 1;
|
||||
if ( bbc.minZ < 1 )
|
||||
bbc.minZ = 1;
|
||||
|
||||
if ( bbc.maxX > 15 )
|
||||
bbc.maxX = 15;
|
||||
if ( bbc.maxY > 15 )
|
||||
bbc.maxY = 15;
|
||||
if ( bbc.maxZ > 15 )
|
||||
bbc.maxZ = 15;
|
||||
}
|
||||
|
||||
setBounds( bbc.minX, bbc.minY, bbc.minZ, bbc.maxX, bbc.maxY, bbc.maxZ );
|
||||
|
||||
bbr.renderBlockBounds( rbw, minX, minY, minZ, maxX, maxY, maxZ, ax, ay, az );
|
||||
rbw.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
rbw.faces = EnumSet.allOf( ForgeDirection.class );
|
||||
rbw.renderAllFaces = allFaces;
|
||||
rbw.calculations = false;
|
||||
rbw.useTextures = false;
|
||||
|
||||
return rbw.getLightingCache();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBounds(float minx, float miny, float minz, float maxx, float maxy, float maxz)
|
||||
{
|
||||
minX = minx;
|
||||
minY = miny;
|
||||
minZ = minz;
|
||||
maxX = maxx;
|
||||
maxY = maxy;
|
||||
maxZ = maxz;
|
||||
}
|
||||
|
||||
public double getBound(ForgeDirection side)
|
||||
{
|
||||
switch (side)
|
||||
{
|
||||
default:
|
||||
case UNKNOWN:
|
||||
return 0.5;
|
||||
case DOWN:
|
||||
return minY;
|
||||
case EAST:
|
||||
return maxX;
|
||||
case NORTH:
|
||||
return minZ;
|
||||
case SOUTH:
|
||||
return maxZ;
|
||||
case UP:
|
||||
return maxY;
|
||||
case WEST:
|
||||
return minX;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInvColor(int newColor)
|
||||
{
|
||||
color = newColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexture(IIcon ico)
|
||||
{
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ico );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexture(IIcon Down, IIcon Up, IIcon North, IIcon South, IIcon West, IIcon East)
|
||||
{
|
||||
IIcon list[] = new IIcon[6];
|
||||
|
||||
list[0] = Down;
|
||||
list[1] = Up;
|
||||
list[2] = North;
|
||||
list[3] = South;
|
||||
list[4] = West;
|
||||
list[5] = East;
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcons( list[mapRotation( ForgeDirection.UP ).ordinal()],
|
||||
list[mapRotation( ForgeDirection.DOWN ).ordinal()], list[mapRotation( ForgeDirection.SOUTH ).ordinal()],
|
||||
list[mapRotation( ForgeDirection.NORTH ).ordinal()], list[mapRotation( ForgeDirection.EAST ).ordinal()],
|
||||
list[mapRotation( ForgeDirection.WEST ).ordinal()] );
|
||||
}
|
||||
|
||||
public ForgeDirection mapRotation(ForgeDirection dir)
|
||||
{
|
||||
ForgeDirection forward = az;
|
||||
ForgeDirection up = ay;
|
||||
ForgeDirection west = ForgeDirection.UNKNOWN;
|
||||
|
||||
if ( forward == null || up == null )
|
||||
return dir;
|
||||
|
||||
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
|
||||
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
|
||||
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
|
||||
|
||||
for (ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS)
|
||||
if ( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z )
|
||||
west = dx;
|
||||
|
||||
if ( dir.equals( forward ) )
|
||||
return ForgeDirection.SOUTH;
|
||||
if ( dir.equals( forward.getOpposite() ) )
|
||||
return ForgeDirection.NORTH;
|
||||
|
||||
if ( dir.equals( up ) )
|
||||
return ForgeDirection.UP;
|
||||
if ( dir.equals( up.getOpposite() ) )
|
||||
return ForgeDirection.DOWN;
|
||||
|
||||
if ( dir.equals( west ) )
|
||||
return ForgeDirection.WEST;
|
||||
if ( dir.equals( west.getOpposite() ) )
|
||||
return ForgeDirection.EAST;
|
||||
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBox(RenderBlocks renderer)
|
||||
{
|
||||
renderer.setRenderBounds( minX / 16.0, minY / 16.0, minZ / 16.0, maxX / 16.0, maxY / 16.0, maxZ / 16.0 );
|
||||
bbr.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, null, Tessellator.instance, color, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryFace(IIcon IIcon, ForgeDirection face, RenderBlocks renderer)
|
||||
{
|
||||
renderer.setRenderBounds( minX / 16.0, minY / 16.0, minZ / 16.0, maxX / 16.0, maxY / 16.0, maxZ / 16.0 );
|
||||
setTexture( IIcon );
|
||||
bbr.renderInvBlock( EnumSet.of( face ), blk, null, Tessellator.instance, color, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBlock(int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
if ( !renderThis() )
|
||||
return;
|
||||
|
||||
AEBaseBlock blk = (AEBaseBlock) AEApi.instance().blocks().blockMultiPart.block();
|
||||
BlockRenderInfo info = blk.getRendererInstance();
|
||||
ForgeDirection forward = BusRenderHelper.instance.az;
|
||||
ForgeDirection up = BusRenderHelper.instance.ay;
|
||||
|
||||
renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.DOWN, forward, up ) );
|
||||
renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.UP, forward, up ) );
|
||||
|
||||
renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.EAST, forward, up ) );
|
||||
renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.WEST, forward, up ) );
|
||||
|
||||
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.NORTH, forward, up ) );
|
||||
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.SOUTH, forward, up ) );
|
||||
|
||||
bbr.renderBlockBounds( renderer, minX, minY, minZ, maxX, maxY, maxZ, ax, ay, az );
|
||||
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock()
|
||||
{
|
||||
return AEApi.instance().blocks().blockMultiPart.block();
|
||||
}
|
||||
|
||||
public void setRenderColor(int color)
|
||||
{
|
||||
BlockCableBus blk = (BlockCableBus) AEApi.instance().blocks().blockMultiPart.block();
|
||||
blk.setRenderColor( color );
|
||||
}
|
||||
|
||||
public void prepareBounds(RenderBlocks renderer)
|
||||
{
|
||||
bbr.renderBlockBounds( renderer, minX, minY, minZ, maxX, maxY, maxZ, ax, ay, az );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacesToRender(EnumSet<ForgeDirection> faces)
|
||||
{
|
||||
BusRenderer.instance.renderer.renderFaces = faces;
|
||||
}
|
||||
|
||||
public void renderBlockCurrentBounds(int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
if ( !renderThis() )
|
||||
return;
|
||||
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceCutout(int x, int y, int z, IIcon ico, ForgeDirection face, float edgeThickness, RenderBlocks renderer)
|
||||
{
|
||||
if ( !renderThis() )
|
||||
return;
|
||||
|
||||
switch (face)
|
||||
{
|
||||
case DOWN:
|
||||
face = ay.getOpposite();
|
||||
break;
|
||||
case EAST:
|
||||
face = ax;
|
||||
break;
|
||||
case NORTH:
|
||||
face = az.getOpposite();
|
||||
break;
|
||||
case SOUTH:
|
||||
face = az;
|
||||
break;
|
||||
case UP:
|
||||
face = ay;
|
||||
break;
|
||||
case WEST:
|
||||
face = ax.getOpposite();
|
||||
break;
|
||||
case UNKNOWN:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
bbr.renderCutoutFace( blk, ico, x, y, z, renderer, face, edgeThickness );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFace(int x, int y, int z, IIcon ico, ForgeDirection face, RenderBlocks renderer)
|
||||
{
|
||||
if ( !renderThis() )
|
||||
return;
|
||||
|
||||
prepareBounds( renderer );
|
||||
switch (face)
|
||||
{
|
||||
case DOWN:
|
||||
face = ay.getOpposite();
|
||||
break;
|
||||
case EAST:
|
||||
face = ax;
|
||||
break;
|
||||
case NORTH:
|
||||
face = az.getOpposite();
|
||||
break;
|
||||
case SOUTH:
|
||||
face = az;
|
||||
break;
|
||||
case UP:
|
||||
face = ay;
|
||||
break;
|
||||
case WEST:
|
||||
face = ax.getOpposite();
|
||||
break;
|
||||
case UNKNOWN:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
bbr.renderFace( x, y, z, blk, ico, renderer, face );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldX()
|
||||
{
|
||||
return ax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldY()
|
||||
{
|
||||
return ay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldZ()
|
||||
{
|
||||
return az;
|
||||
}
|
||||
|
||||
public void setOrientation(ForgeDirection dx, ForgeDirection dy, ForgeDirection dz)
|
||||
{
|
||||
ax = dx == null ? ForgeDirection.EAST : dx;
|
||||
ay = dy == null ? ForgeDirection.UP : dy;
|
||||
az = dz == null ? ForgeDirection.SOUTH : dz;
|
||||
}
|
||||
|
||||
public double[] getBounds()
|
||||
{
|
||||
return new double[] { minX, minY, minZ, maxX, maxY, maxZ };
|
||||
}
|
||||
|
||||
public void setBounds(double[] bounds)
|
||||
{
|
||||
if ( bounds == null || bounds.length != 6 )
|
||||
return;
|
||||
|
||||
minX = bounds[0];
|
||||
minY = bounds[1];
|
||||
minZ = bounds[2];
|
||||
maxX = bounds[3];
|
||||
maxY = bounds[4];
|
||||
maxZ = bounds[5];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.parts.IAlphaPassItem;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.facade.IFacadeItem;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BusRenderer implements IItemRenderer
|
||||
{
|
||||
|
||||
public static final BusRenderer instance = new BusRenderer();
|
||||
|
||||
public RenderBlocksWorkaround renderer = new RenderBlocksWorkaround();
|
||||
public static final HashMap<Integer, IPart> renderPart = new HashMap();
|
||||
|
||||
public IPart getRenderer(ItemStack is, IPartItem c)
|
||||
{
|
||||
int id = (Item.getIdFromItem( is.getItem() ) << Platform.DEF_OFFSET) | is.getItemDamage();
|
||||
|
||||
IPart part = renderPart.get( id );
|
||||
if ( part == null )
|
||||
{
|
||||
part = c.createPartFromItemStack( is );
|
||||
if ( part != null )
|
||||
renderPart.put( id, part );
|
||||
}
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
if ( item == null )
|
||||
return;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
||||
GL11.glEnable( GL11.GL_TEXTURE_2D );
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) && item.getItem() instanceof IAlphaPassItem
|
||||
&& ((IAlphaPassItem) item.getItem()).useAlphaPass( item ) )
|
||||
{
|
||||
GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
GL11.glDisable( GL11.GL_ALPHA_TEST );
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glAlphaFunc( GL11.GL_GREATER, 0.4f );
|
||||
GL11.glEnable( GL11.GL_ALPHA_TEST );
|
||||
GL11.glDisable( GL11.GL_BLEND );
|
||||
}
|
||||
|
||||
if ( type == ItemRenderType.EQUIPPED_FIRST_PERSON )
|
||||
{
|
||||
GL11.glTranslatef( -0.2f, -0.1f, -0.3f );
|
||||
}
|
||||
|
||||
if ( type == ItemRenderType.ENTITY )
|
||||
{
|
||||
GL11.glRotatef( 90.0f, 0.0f, 1.0f, 0.0f );
|
||||
GL11.glScalef( 0.8f, 0.8f, 0.8f );
|
||||
GL11.glTranslatef( -0.8f, -0.87f, -0.7f );
|
||||
}
|
||||
|
||||
if ( type == ItemRenderType.INVENTORY )
|
||||
GL11.glTranslatef( 0.0f, -0.1f, 0.0f );
|
||||
|
||||
GL11.glTranslated( 0.2, 0.3, 0.1 );
|
||||
GL11.glScaled( 1.2, 1.2, 1. );
|
||||
|
||||
GL11.glColor4f( 1, 1, 1, 1 );
|
||||
Tessellator.instance.setColorOpaque_F( 1, 1, 1 );
|
||||
Tessellator.instance.setBrightness( 14 << 20 | 14 << 4 );
|
||||
|
||||
BusRenderHelper.instance.setBounds( 0, 0, 0, 1, 1, 1 );
|
||||
BusRenderHelper.instance.setTexture( null );
|
||||
BusRenderHelper.instance.setInvColor( 0xffffff );
|
||||
renderer.blockAccess = ClientHelper.proxy.getWorld();
|
||||
|
||||
BusRenderHelper.instance.setOrientation( ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH );
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
renderer.useInventoryTint = false;
|
||||
renderer.overrideBlockTexture = null;
|
||||
|
||||
if ( item.getItem() instanceof IFacadeItem )
|
||||
{
|
||||
IFacadeItem fi = (IFacadeItem) item.getItem();
|
||||
IFacadePart fp = fi.createPartFromItemStack( item, ForgeDirection.SOUTH );
|
||||
|
||||
if ( type == ItemRenderType.EQUIPPED_FIRST_PERSON )
|
||||
{
|
||||
GL11.glRotatef( 160.0f, 0.0f, 1.0f, 0.0f );
|
||||
GL11.glTranslated( -0.4, 0.1, -1.6 );
|
||||
}
|
||||
|
||||
if ( fp != null )
|
||||
fp.renderInventory( BusRenderHelper.instance, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
IPart ip = getRenderer( item, (IPartItem) item.getItem() );
|
||||
if ( ip != null )
|
||||
{
|
||||
if ( type == ItemRenderType.ENTITY )
|
||||
{
|
||||
int depth = ip.cableConnectionRenderTo();
|
||||
GL11.glTranslatef( 0.0f, 0.0f, -0.04f * (8 - depth) - 0.06f );
|
||||
}
|
||||
|
||||
ip.renderInventory( BusRenderHelper.instance, renderer );
|
||||
}
|
||||
}
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.parts.IFacadeContainer;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.parts.BusCollisionHelper;
|
||||
import appeng.parts.CableBusContainer;
|
||||
|
||||
public class CableRenderHelper
|
||||
{
|
||||
|
||||
private static final CableRenderHelper instance = new CableRenderHelper();
|
||||
|
||||
public static CableRenderHelper getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void setSide(ForgeDirection s)
|
||||
{
|
||||
ForgeDirection ax, ay, az;
|
||||
|
||||
switch (s)
|
||||
{
|
||||
case DOWN:
|
||||
ax = ForgeDirection.EAST;
|
||||
ay = ForgeDirection.NORTH;
|
||||
az = ForgeDirection.DOWN;
|
||||
break;
|
||||
case UP:
|
||||
ax = ForgeDirection.EAST;
|
||||
ay = ForgeDirection.SOUTH;
|
||||
az = ForgeDirection.UP;
|
||||
break;
|
||||
case EAST:
|
||||
ax = ForgeDirection.SOUTH;
|
||||
ay = ForgeDirection.UP;
|
||||
az = ForgeDirection.EAST;
|
||||
break;
|
||||
case WEST:
|
||||
ax = ForgeDirection.NORTH;
|
||||
ay = ForgeDirection.UP;
|
||||
az = ForgeDirection.WEST;
|
||||
break;
|
||||
case NORTH:
|
||||
ax = ForgeDirection.WEST;
|
||||
ay = ForgeDirection.UP;
|
||||
az = ForgeDirection.NORTH;
|
||||
break;
|
||||
case SOUTH:
|
||||
ax = ForgeDirection.EAST;
|
||||
ay = ForgeDirection.UP;
|
||||
az = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
ax = ForgeDirection.EAST;
|
||||
ay = ForgeDirection.UP;
|
||||
az = ForgeDirection.SOUTH;
|
||||
break;
|
||||
}
|
||||
|
||||
BusRenderHelper.instance.setOrientation( ax, ay, az );
|
||||
}
|
||||
|
||||
public void renderStatic(CableBusContainer cableBusContainer, IFacadeContainer iFacadeContainer)
|
||||
{
|
||||
TileEntity te = cableBusContainer.getTile();
|
||||
RenderBlocksWorkaround renderer = BusRenderer.instance.renderer;
|
||||
|
||||
if ( renderer.overrideBlockTexture != null )
|
||||
BusRenderHelper.instance.setPass( 0 );
|
||||
|
||||
if ( renderer.blockAccess == null )
|
||||
renderer.blockAccess = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPart part = cableBusContainer.getPart( s );
|
||||
if ( part != null )
|
||||
{
|
||||
setSide( s );
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
renderer.flipTexture = false;
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
|
||||
part.renderStatic( te.xCoord, te.yCoord, te.zCoord, BusRenderHelper.instance, renderer );
|
||||
|
||||
renderer.faces = EnumSet.allOf( ForgeDirection.class );
|
||||
renderer.calculations = true;
|
||||
renderer.useTextures = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !iFacadeContainer.isEmpty() )
|
||||
{
|
||||
/**
|
||||
* snag list of boxes...
|
||||
*/
|
||||
List<AxisAlignedBB> boxes = new ArrayList();
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPart part = cableBusContainer.getPart( s );
|
||||
if ( part != null )
|
||||
{
|
||||
setSide( s );
|
||||
BusRenderHelper brh = BusRenderHelper.instance;
|
||||
BusCollisionHelper bch = new BusCollisionHelper( boxes, brh.getWorldX(), brh.getWorldY(), brh.getWorldZ(), null, true );
|
||||
part.getBoxes( bch );
|
||||
}
|
||||
}
|
||||
|
||||
boolean useThinFacades = false;
|
||||
double min = 2.0 / 16.0;
|
||||
double max = 14.0 / 16.0;
|
||||
|
||||
for (AxisAlignedBB bb : boxes)
|
||||
{
|
||||
int o = 0;
|
||||
o += bb.maxX > max ? 1 : 0;
|
||||
o += bb.maxY > max ? 1 : 0;
|
||||
o += bb.maxZ > max ? 1 : 0;
|
||||
o += bb.minX < min ? 1 : 0;
|
||||
o += bb.minY < min ? 1 : 0;
|
||||
o += bb.minZ < min ? 1 : 0;
|
||||
|
||||
if ( o >= 2 )
|
||||
useThinFacades = true;
|
||||
}
|
||||
|
||||
for (ForgeDirection s : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
IFacadePart fPart = iFacadeContainer.getFacade( s );
|
||||
if ( fPart != null )
|
||||
{
|
||||
AxisAlignedBB b = null;
|
||||
fPart.setThinFacades( useThinFacades );
|
||||
AxisAlignedBB pb = fPart.getPrimaryBox();
|
||||
for (AxisAlignedBB bb : boxes)
|
||||
{
|
||||
if ( bb.intersectsWith( pb ) )
|
||||
{
|
||||
if ( b == null )
|
||||
b = bb;
|
||||
else
|
||||
{
|
||||
b.maxX = Math.max( b.maxX, bb.maxX );
|
||||
b.maxY = Math.max( b.maxY, bb.maxY );
|
||||
b.maxZ = Math.max( b.maxZ, bb.maxZ );
|
||||
b.minX = Math.min( b.minX, bb.minX );
|
||||
b.minY = Math.min( b.minY, bb.minY );
|
||||
b.minZ = Math.min( b.minZ, bb.minZ );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderer.flipTexture = false;
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
|
||||
setSide( s );
|
||||
fPart.renderStatic( te.xCoord, te.yCoord, te.zCoord, BusRenderHelper.instance, renderer, iFacadeContainer, b,
|
||||
cableBusContainer.getPart( s ) == null );
|
||||
}
|
||||
}
|
||||
|
||||
renderer.isFacade = false;
|
||||
renderer.enableAO = false;
|
||||
renderer.setTexture( null );
|
||||
renderer.calculations = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void renderDynamic(CableBusContainer cableBusContainer, double x, double y, double z)
|
||||
{
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPart part = cableBusContainer.getPart( s );
|
||||
if ( part != null )
|
||||
{
|
||||
ForgeDirection ax, ay, az;
|
||||
|
||||
switch (s)
|
||||
{
|
||||
case DOWN:
|
||||
ax = ForgeDirection.EAST;
|
||||
ay = ForgeDirection.NORTH;
|
||||
az = ForgeDirection.DOWN;
|
||||
break;
|
||||
case UP:
|
||||
ax = ForgeDirection.EAST;
|
||||
ay = ForgeDirection.SOUTH;
|
||||
az = ForgeDirection.UP;
|
||||
break;
|
||||
case EAST:
|
||||
ax = ForgeDirection.SOUTH;
|
||||
ay = ForgeDirection.UP;
|
||||
az = ForgeDirection.EAST;
|
||||
break;
|
||||
case WEST:
|
||||
ax = ForgeDirection.NORTH;
|
||||
ay = ForgeDirection.UP;
|
||||
az = ForgeDirection.WEST;
|
||||
break;
|
||||
case NORTH:
|
||||
ax = ForgeDirection.WEST;
|
||||
ay = ForgeDirection.UP;
|
||||
az = ForgeDirection.NORTH;
|
||||
break;
|
||||
case SOUTH:
|
||||
ax = ForgeDirection.EAST;
|
||||
ay = ForgeDirection.UP;
|
||||
az = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
ax = ForgeDirection.EAST;
|
||||
ay = ForgeDirection.UP;
|
||||
az = ForgeDirection.SOUTH;
|
||||
break;
|
||||
}
|
||||
|
||||
BusRenderHelper.instance.setOrientation( ax, ay, az );
|
||||
part.renderDynamic( x, y, z, BusRenderHelper.instance, BusRenderer.instance.renderer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ItemRenderer implements IItemRenderer
|
||||
{
|
||||
|
||||
public static final ItemRenderer instance = new ItemRenderer();
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
GL11.glEnable( GL11.GL_ALPHA_TEST );
|
||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
if ( type == ItemRenderType.ENTITY )
|
||||
GL11.glTranslatef( -0.5f, -0.5f, -0.5f );
|
||||
if ( type == ItemRenderType.INVENTORY )
|
||||
GL11.glTranslatef( 0.0f, -0.1f, 0.0f );
|
||||
|
||||
WorldRender.instance.renderItemBlock( item, type, data );
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,686 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.parts.ISimplifiedBundle;
|
||||
import appeng.core.AELog;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderBlocksWorkaround extends RenderBlocks
|
||||
{
|
||||
|
||||
public boolean calculations = true;
|
||||
public EnumSet<ForgeDirection> renderFaces = EnumSet.allOf( ForgeDirection.class );
|
||||
public EnumSet<ForgeDirection> faces = EnumSet.allOf( ForgeDirection.class );
|
||||
|
||||
private class LightingCache implements ISimplifiedBundle
|
||||
{
|
||||
|
||||
public IIcon rXPos;
|
||||
public IIcon rXNeg;
|
||||
public IIcon rYPos;
|
||||
public IIcon rYNeg;
|
||||
public IIcon rZPos;
|
||||
public IIcon rZNeg;
|
||||
|
||||
public boolean isAO;
|
||||
|
||||
public int bXPos;
|
||||
public int bXNeg;
|
||||
public int bYPos;
|
||||
public int bYNeg;
|
||||
public int bZPos;
|
||||
public int bZNeg;
|
||||
|
||||
public int aoXPos[];
|
||||
public int aoXNeg[];
|
||||
public int aoYPos[];
|
||||
public int aoYNeg[];
|
||||
public int aoZPos[];
|
||||
public int aoZNeg[];
|
||||
|
||||
public float foXPos[];
|
||||
public float foXNeg[];
|
||||
public float foYPos[];
|
||||
public float foYNeg[];
|
||||
public float foZPos[];
|
||||
public float foZNeg[];
|
||||
|
||||
public int lightHash;
|
||||
|
||||
public LightingCache(LightingCache secondCSrc) {
|
||||
rXPos = secondCSrc.rXPos;
|
||||
rXNeg = secondCSrc.rXNeg;
|
||||
rYPos = secondCSrc.rYPos;
|
||||
rYNeg = secondCSrc.rYNeg;
|
||||
rZPos = secondCSrc.rZPos;
|
||||
rZNeg = secondCSrc.rZNeg;
|
||||
|
||||
isAO = secondCSrc.isAO;
|
||||
|
||||
bXPos = secondCSrc.bXPos;
|
||||
bXNeg = secondCSrc.bXNeg;
|
||||
bYPos = secondCSrc.bYPos;
|
||||
bYNeg = secondCSrc.bYNeg;
|
||||
bZPos = secondCSrc.bZPos;
|
||||
bZNeg = secondCSrc.bZNeg;
|
||||
|
||||
aoXPos = secondCSrc.aoXPos.clone();
|
||||
aoXNeg = secondCSrc.aoXNeg.clone();
|
||||
aoYPos = secondCSrc.aoYPos.clone();
|
||||
aoYNeg = secondCSrc.aoYNeg.clone();
|
||||
aoZPos = secondCSrc.aoZPos.clone();
|
||||
aoZNeg = secondCSrc.aoZNeg.clone();
|
||||
|
||||
foXPos = secondCSrc.foXPos.clone();
|
||||
foXNeg = secondCSrc.foXNeg.clone();
|
||||
foYPos = secondCSrc.foYPos.clone();
|
||||
foYNeg = secondCSrc.foYNeg.clone();
|
||||
foZPos = secondCSrc.foZPos.clone();
|
||||
foZNeg = secondCSrc.foZNeg.clone();
|
||||
|
||||
lightHash = secondCSrc.lightHash;
|
||||
}
|
||||
|
||||
public LightingCache() {
|
||||
rXPos = null;
|
||||
rXNeg = null;
|
||||
rYPos = null;
|
||||
rYNeg = null;
|
||||
rZPos = null;
|
||||
rZNeg = null;
|
||||
|
||||
isAO = false;
|
||||
|
||||
bXPos = 0;
|
||||
bXNeg = 0;
|
||||
bYPos = 0;
|
||||
bYNeg = 0;
|
||||
bZPos = 0;
|
||||
bZNeg = 0;
|
||||
|
||||
aoXPos = new int[5];
|
||||
aoXNeg = new int[5];
|
||||
aoYPos = new int[5];
|
||||
aoYNeg = new int[5];
|
||||
aoZPos = new int[5];
|
||||
aoZNeg = new int[5];
|
||||
|
||||
foXPos = new float[12];
|
||||
foXNeg = new float[12];
|
||||
foYPos = new float[12];
|
||||
foYNeg = new float[12];
|
||||
foZPos = new float[12];
|
||||
foZNeg = new float[12];
|
||||
|
||||
lightHash = 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private LightingCache lightState = new LightingCache();
|
||||
|
||||
public boolean isFacade = false;
|
||||
public boolean useTextures = true;
|
||||
|
||||
Field fBrightness;
|
||||
Field fColor;
|
||||
|
||||
public int getCurrentColor()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( fColor == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
fColor = Tessellator.class.getDeclaredField( "color" );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
fColor = Tessellator.class.getDeclaredField( "field_78402_m" );
|
||||
}
|
||||
fColor.setAccessible( true );
|
||||
}
|
||||
return (Integer) fColor.get( Tessellator.instance );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCurrentBrightness()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( fBrightness == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
fBrightness = Tessellator.class.getDeclaredField( "brightness" );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
fBrightness = Tessellator.class.getDeclaredField( "field_78401_l" );
|
||||
}
|
||||
fBrightness.setAccessible( true );
|
||||
}
|
||||
return (Integer) fBrightness.get( Tessellator.instance );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTexture(IIcon ico)
|
||||
{
|
||||
lightState.rXPos = lightState.rXNeg = lightState.rYPos = lightState.rYNeg = lightState.rZPos = lightState.rZNeg = ico;
|
||||
}
|
||||
|
||||
public void setTexture(IIcon rYNeg, IIcon rYPos, IIcon rZNeg, IIcon rZPos, IIcon rXNeg, IIcon rXPos)
|
||||
{
|
||||
lightState.rXPos = rXPos;
|
||||
lightState.rXNeg = rXNeg;
|
||||
lightState.rYPos = rYPos;
|
||||
lightState.rYNeg = rYNeg;
|
||||
lightState.rZPos = rZPos;
|
||||
lightState.rZNeg = rZNeg;
|
||||
}
|
||||
|
||||
public boolean renderStandardBlockNoCalculations(Block b, int x, int y, int z)
|
||||
{
|
||||
Tessellator.instance.setBrightness( lightState.bXPos );
|
||||
restoreAO( lightState.aoXPos, lightState.foXPos );
|
||||
renderFaceXPos( b, x, y, z, useTextures ? lightState.rXPos : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.EAST.ordinal() ) );
|
||||
|
||||
Tessellator.instance.setBrightness( lightState.bXNeg );
|
||||
restoreAO( lightState.aoXNeg, lightState.foXNeg );
|
||||
renderFaceXNeg( b, x, y, z, useTextures ? lightState.rXNeg : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.WEST.ordinal() ) );
|
||||
|
||||
Tessellator.instance.setBrightness( lightState.bYPos );
|
||||
restoreAO( lightState.aoYPos, lightState.foYPos );
|
||||
renderFaceYPos( b, x, y, z, useTextures ? lightState.rYPos : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.UP.ordinal() ) );
|
||||
|
||||
Tessellator.instance.setBrightness( lightState.bYNeg );
|
||||
restoreAO( lightState.aoYNeg, lightState.foYNeg );
|
||||
renderFaceYNeg( b, x, y, z, useTextures ? lightState.rYNeg : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.DOWN.ordinal() ) );
|
||||
|
||||
Tessellator.instance.setBrightness( lightState.bZPos );
|
||||
restoreAO( lightState.aoZPos, lightState.foZPos );
|
||||
renderFaceZPos( b, x, y, z, useTextures ? lightState.rZPos : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.SOUTH.ordinal() ) );
|
||||
|
||||
Tessellator.instance.setBrightness( lightState.bZNeg );
|
||||
restoreAO( lightState.aoZNeg, lightState.foZNeg );
|
||||
renderFaceZNeg( b, x, y, z, useTextures ? lightState.rZNeg : getBlockIcon( b, this.blockAccess, x, y, z, ForgeDirection.NORTH.ordinal() ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void restoreAO(int[] z, float[] c)
|
||||
{
|
||||
brightnessBottomLeft = z[0];
|
||||
brightnessBottomRight = z[1];
|
||||
brightnessTopLeft = z[2];
|
||||
brightnessTopRight = z[3];
|
||||
Tessellator.instance.setColorRGBA_I( z[4], (int) (opacity * 255) );
|
||||
|
||||
colorRedTopLeft = c[0];
|
||||
colorGreenTopLeft = c[1];
|
||||
colorBlueTopLeft = c[2];
|
||||
colorRedBottomLeft = c[3];
|
||||
colorGreenBottomLeft = c[4];
|
||||
colorBlueBottomLeft = c[5];
|
||||
colorRedBottomRight = c[6];
|
||||
colorGreenBottomRight = c[7];
|
||||
colorBlueBottomRight = c[8];
|
||||
colorRedTopRight = c[9];
|
||||
colorGreenTopRight = c[10];
|
||||
colorBlueTopRight = c[11];
|
||||
}
|
||||
|
||||
private void saveAO(int[] z, float[] c)
|
||||
{
|
||||
z[0] = brightnessBottomLeft;
|
||||
z[1] = brightnessBottomRight;
|
||||
z[2] = brightnessTopLeft;
|
||||
z[3] = brightnessTopRight;
|
||||
z[4] = getCurrentColor();
|
||||
|
||||
c[0] = colorRedTopLeft;
|
||||
c[1] = colorGreenTopLeft;
|
||||
c[2] = colorBlueTopLeft;
|
||||
c[3] = colorRedBottomLeft;
|
||||
c[4] = colorGreenBottomLeft;
|
||||
c[5] = colorBlueBottomLeft;
|
||||
c[6] = colorRedBottomRight;
|
||||
c[7] = colorGreenBottomRight;
|
||||
c[8] = colorBlueBottomRight;
|
||||
c[9] = colorRedTopRight;
|
||||
c[10] = colorGreenTopRight;
|
||||
c[11] = colorBlueTopRight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block blk, int x, int y, int z)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( calculations )
|
||||
{
|
||||
lightState.lightHash = getLightingHash( blk, this.blockAccess, x, y, z );
|
||||
return super.renderStandardBlock( blk, x, y, z );
|
||||
}
|
||||
else
|
||||
{
|
||||
enableAO = lightState.isAO;
|
||||
boolean out = renderStandardBlockNoCalculations( blk, x, y, z );
|
||||
enableAO = false;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
// meh
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block par1Block, double par2, double par4, double par6, IIcon par8Icon)
|
||||
{
|
||||
if ( faces.contains( ForgeDirection.WEST ) )
|
||||
{
|
||||
if ( !renderFaces.contains( ForgeDirection.WEST ) )
|
||||
return;
|
||||
|
||||
if ( isFacade )
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
double d3 = (double) par8Icon.getInterpolatedU( this.renderMinZ * 16.0D );
|
||||
double d4 = (double) par8Icon.getInterpolatedU( this.renderMaxZ * 16.0D );
|
||||
double d5 = (double) par8Icon.getInterpolatedV( 16.0D - this.renderMaxY * 16.0D );
|
||||
double d6 = (double) par8Icon.getInterpolatedV( 16.0D - this.renderMinY * 16.0D );
|
||||
|
||||
double d11 = par2 + this.renderMinX;
|
||||
double d12 = par4 + this.renderMinY;
|
||||
double d13 = par4 + this.renderMaxY;
|
||||
double d14 = par6 + this.renderMinZ;
|
||||
double d15 = par6 + this.renderMaxZ;
|
||||
|
||||
if ( this.enableAO )
|
||||
{
|
||||
partialLightingColoring( renderMaxY, renderMaxZ );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d4, d5 );
|
||||
partialLightingColoring( renderMaxY, renderMinZ );
|
||||
tessellator.addVertexWithUV( d11, d13, d14, d3, d5 );
|
||||
partialLightingColoring( renderMinY, renderMinZ );
|
||||
tessellator.addVertexWithUV( d11, d12, d14, d3, d6 );
|
||||
partialLightingColoring( renderMinY, renderMaxZ );
|
||||
tessellator.addVertexWithUV( d11, d12, d15, d4, d6 );
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d4, d5 );
|
||||
tessellator.addVertexWithUV( d11, d13, d14, d3, d5 );
|
||||
tessellator.addVertexWithUV( d11, d12, d14, d3, d6 );
|
||||
tessellator.addVertexWithUV( d11, d12, d15, d4, d6 );
|
||||
}
|
||||
}
|
||||
else
|
||||
super.renderFaceXNeg( par1Block, par2, par4, par6, par8Icon );
|
||||
}
|
||||
else
|
||||
{
|
||||
lightState.isAO = enableAO;
|
||||
lightState.rXNeg = par8Icon;
|
||||
saveAO( lightState.aoXNeg, lightState.foXNeg );
|
||||
lightState.bXNeg = getCurrentBrightness();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block par1Block, double par2, double par4, double par6, IIcon par8Icon)
|
||||
{
|
||||
if ( faces.contains( ForgeDirection.EAST ) )
|
||||
{
|
||||
if ( !renderFaces.contains( ForgeDirection.EAST ) )
|
||||
return;
|
||||
|
||||
if ( isFacade )
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
double d3 = (double) par8Icon.getInterpolatedU( 16.0D - this.renderMinZ * 16.0D );
|
||||
double d4 = (double) par8Icon.getInterpolatedU( 16.0D - this.renderMaxZ * 16.0D );
|
||||
double d5 = (double) par8Icon.getInterpolatedV( 16.0D - this.renderMaxY * 16.0D );
|
||||
double d6 = (double) par8Icon.getInterpolatedV( 16.0D - this.renderMinY * 16.0D );
|
||||
|
||||
double d11 = par2 + this.renderMaxX;
|
||||
double d12 = par4 + this.renderMinY;
|
||||
double d13 = par4 + this.renderMaxY;
|
||||
double d14 = par6 + this.renderMinZ;
|
||||
double d15 = par6 + this.renderMaxZ;
|
||||
|
||||
if ( this.enableAO )
|
||||
{
|
||||
partialLightingColoring( 1.0 - renderMinY, renderMaxZ );
|
||||
tessellator.addVertexWithUV( d11, d12, d15, d4, d6 );
|
||||
partialLightingColoring( 1.0 - renderMinY, renderMinZ );
|
||||
tessellator.addVertexWithUV( d11, d12, d14, d3, d6 );
|
||||
partialLightingColoring( 1.0 - renderMaxY, renderMinZ );
|
||||
tessellator.addVertexWithUV( d11, d13, d14, d3, d5 );
|
||||
partialLightingColoring( 1.0 - renderMaxY, renderMaxZ );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d4, d5 );
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV( d11, d12, d15, d4, d6 );
|
||||
tessellator.addVertexWithUV( d11, d12, d14, d3, d6 );
|
||||
tessellator.addVertexWithUV( d11, d13, d14, d3, d5 );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d4, d5 );
|
||||
}
|
||||
}
|
||||
else
|
||||
super.renderFaceXPos( par1Block, par2, par4, par6, par8Icon );
|
||||
}
|
||||
else
|
||||
{
|
||||
lightState.isAO = enableAO;
|
||||
lightState.rXPos = par8Icon;
|
||||
saveAO( lightState.aoXPos, lightState.foXPos );
|
||||
lightState.bXPos = getCurrentBrightness();
|
||||
}
|
||||
}
|
||||
|
||||
private void partialLightingColoring(double u, double v)
|
||||
{
|
||||
double rA = colorRedTopLeft * u + (1.0 - u) * colorRedTopRight;
|
||||
double rB = colorRedBottomLeft * u + (1.0 - u) * colorRedBottomRight;
|
||||
float r = (float) (rA * v + rB * (1.0 - v));
|
||||
|
||||
double gA = colorGreenTopLeft * u + (1.0 - u) * colorGreenTopRight;
|
||||
double gB = colorGreenBottomLeft * u + (1.0 - u) * colorGreenBottomRight;
|
||||
float g = (float) (gA * v + gB * (1.0 - v));
|
||||
|
||||
double bA = colorBlueTopLeft * u + (1.0 - u) * colorBlueTopRight;
|
||||
double bB = colorBlueBottomLeft * u + (1.0 - u) * colorBlueBottomRight;
|
||||
float b = (float) (bA * v + bB * (1.0 - v));
|
||||
|
||||
double highA = (brightnessTopLeft >> 16 & 255) * u + (1.0 - u) * (brightnessTopRight >> 16 & 255);
|
||||
double highB = (brightnessBottomLeft >> 16 & 255) * u + (1.0 - u) * (brightnessBottomRight >> 16 & 255);
|
||||
int high = ((int) (highA * v + highB * (1.0 - v))) & 255;
|
||||
|
||||
double lowA = ((brightnessTopLeft & 255)) * u + (1.0 - u) * ((brightnessTopRight & 255));
|
||||
double lowB = ((brightnessBottomLeft & 255)) * u + (1.0 - u) * ((brightnessBottomRight & 255));
|
||||
int low = ((int) (lowA * v + lowB * (1.0 - v))) & 255;
|
||||
|
||||
int out = (high << 16) | low;
|
||||
|
||||
Tessellator.instance.setColorRGBA_F( r, g, b, opacity );
|
||||
Tessellator.instance.setBrightness( out );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYNeg(Block par1Block, double par2, double par4, double par6, IIcon par8Icon)
|
||||
{
|
||||
if ( faces.contains( ForgeDirection.DOWN ) )
|
||||
{
|
||||
if ( !renderFaces.contains( ForgeDirection.DOWN ) )
|
||||
return;
|
||||
|
||||
if ( isFacade )
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
double d3 = (double) par8Icon.getInterpolatedU( this.renderMinX * 16.0D );
|
||||
double d4 = (double) par8Icon.getInterpolatedU( this.renderMaxX * 16.0D );
|
||||
double d5 = (double) par8Icon.getInterpolatedV( this.renderMinZ * 16.0D );
|
||||
double d6 = (double) par8Icon.getInterpolatedV( this.renderMaxZ * 16.0D );
|
||||
|
||||
double d11 = par2 + this.renderMinX;
|
||||
double d12 = par2 + this.renderMaxX;
|
||||
double d13 = par4 + this.renderMinY;
|
||||
double d14 = par6 + this.renderMinZ;
|
||||
double d15 = par6 + this.renderMaxZ;
|
||||
|
||||
if ( this.enableAO )
|
||||
{
|
||||
partialLightingColoring( 1.0 - renderMinX, renderMaxZ );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d3, d6 );
|
||||
partialLightingColoring( 1.0 - renderMinX, renderMinZ );
|
||||
tessellator.addVertexWithUV( d11, d13, d14, d3, d5 );
|
||||
partialLightingColoring( 1.0 - renderMaxX, renderMinZ );
|
||||
tessellator.addVertexWithUV( d12, d13, d14, d4, d5 );
|
||||
partialLightingColoring( 1.0 - renderMaxX, renderMaxZ );
|
||||
tessellator.addVertexWithUV( d12, d13, d15, d4, d6 );
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d3, d6 );
|
||||
tessellator.addVertexWithUV( d11, d13, d14, d3, d5 );
|
||||
tessellator.addVertexWithUV( d12, d13, d14, d4, d5 );
|
||||
tessellator.addVertexWithUV( d12, d13, d15, d4, d6 );
|
||||
}
|
||||
}
|
||||
else
|
||||
super.renderFaceYNeg( par1Block, par2, par4, par6, par8Icon );
|
||||
}
|
||||
else
|
||||
{
|
||||
lightState.isAO = enableAO;
|
||||
lightState.rYNeg = par8Icon;
|
||||
saveAO( lightState.aoYNeg, lightState.foYNeg );
|
||||
lightState.bYNeg = getCurrentBrightness();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYPos(Block par1Block, double par2, double par4, double par6, IIcon par8Icon)
|
||||
{
|
||||
if ( faces.contains( ForgeDirection.UP ) )
|
||||
{
|
||||
if ( !renderFaces.contains( ForgeDirection.UP ) )
|
||||
return;
|
||||
|
||||
if ( isFacade )
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
double d3 = (double) par8Icon.getInterpolatedU( this.renderMinX * 16.0D );
|
||||
double d4 = (double) par8Icon.getInterpolatedU( this.renderMaxX * 16.0D );
|
||||
double d5 = (double) par8Icon.getInterpolatedV( this.renderMinZ * 16.0D );
|
||||
double d6 = (double) par8Icon.getInterpolatedV( this.renderMaxZ * 16.0D );
|
||||
|
||||
double d11 = par2 + this.renderMinX;
|
||||
double d12 = par2 + this.renderMaxX;
|
||||
double d13 = par4 + this.renderMaxY;
|
||||
double d14 = par6 + this.renderMinZ;
|
||||
double d15 = par6 + this.renderMaxZ;
|
||||
|
||||
if ( this.enableAO )
|
||||
{
|
||||
partialLightingColoring( this.renderMaxX, renderMaxZ );
|
||||
tessellator.addVertexWithUV( d12, d13, d15, d4, d6 );
|
||||
partialLightingColoring( this.renderMaxX, renderMinZ );
|
||||
tessellator.addVertexWithUV( d12, d13, d14, d4, d5 );
|
||||
partialLightingColoring( this.renderMinX, renderMinZ );
|
||||
tessellator.addVertexWithUV( d11, d13, d14, d3, d5 );
|
||||
partialLightingColoring( this.renderMinX, renderMaxZ );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d3, d6 );
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV( d12, d13, d15, d4, d6 );
|
||||
tessellator.addVertexWithUV( d12, d13, d14, d4, d5 );
|
||||
tessellator.addVertexWithUV( d11, d13, d14, d3, d5 );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d3, d6 );
|
||||
}
|
||||
}
|
||||
else
|
||||
super.renderFaceYPos( par1Block, par2, par4, par6, par8Icon );
|
||||
}
|
||||
else
|
||||
{
|
||||
lightState.isAO = enableAO;
|
||||
lightState.rYPos = par8Icon;
|
||||
saveAO( lightState.aoYPos, lightState.foYPos );
|
||||
lightState.bYPos = getCurrentBrightness();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block par1Block, double par2, double par4, double par6, IIcon par8Icon)
|
||||
{
|
||||
if ( faces.contains( ForgeDirection.NORTH ) )
|
||||
{
|
||||
if ( !renderFaces.contains( ForgeDirection.NORTH ) )
|
||||
return;
|
||||
|
||||
if ( isFacade )
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
double d3 = (double) par8Icon.getInterpolatedU( 16.0D - this.renderMinX * 16.0D );
|
||||
double d4 = (double) par8Icon.getInterpolatedU( 16.0D - this.renderMaxX * 16.0D );
|
||||
double d5 = (double) par8Icon.getInterpolatedV( 16.0D - this.renderMaxY * 16.0D );
|
||||
double d6 = (double) par8Icon.getInterpolatedV( 16.0D - this.renderMinY * 16.0D );
|
||||
|
||||
double d11 = par2 + this.renderMinX;
|
||||
double d12 = par2 + this.renderMaxX;
|
||||
double d13 = par4 + this.renderMinY;
|
||||
double d14 = par4 + this.renderMaxY;
|
||||
double d15 = par6 + this.renderMinZ;
|
||||
|
||||
if ( this.enableAO )
|
||||
{
|
||||
partialLightingColoring( renderMaxY, 1.0 - renderMinX );
|
||||
tessellator.addVertexWithUV( d11, d14, d15, d3, d5 );
|
||||
partialLightingColoring( renderMaxY, 1.0 - renderMaxX );
|
||||
tessellator.addVertexWithUV( d12, d14, d15, d4, d5 );
|
||||
partialLightingColoring( renderMinY, 1.0 - renderMaxX );
|
||||
tessellator.addVertexWithUV( d12, d13, d15, d4, d6 );
|
||||
partialLightingColoring( renderMinY, 1.0 - renderMinX );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d3, d6 );
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV( d11, d14, d15, d3, d5 );
|
||||
tessellator.addVertexWithUV( d12, d14, d15, d4, d5 );
|
||||
tessellator.addVertexWithUV( d12, d13, d15, d4, d6 );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d3, d6 );
|
||||
}
|
||||
}
|
||||
else
|
||||
super.renderFaceZNeg( par1Block, par2, par4, par6, par8Icon );
|
||||
}
|
||||
else
|
||||
{
|
||||
lightState.isAO = enableAO;
|
||||
lightState.rZNeg = par8Icon;
|
||||
saveAO( lightState.aoZNeg, lightState.foZNeg );
|
||||
lightState.bZNeg = getCurrentBrightness();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block par1Block, double par2, double par4, double par6, IIcon par8Icon)
|
||||
{
|
||||
if ( faces.contains( ForgeDirection.SOUTH ) )
|
||||
{
|
||||
if ( !renderFaces.contains( ForgeDirection.SOUTH ) )
|
||||
return;
|
||||
|
||||
if ( isFacade )
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
double d3 = (double) par8Icon.getInterpolatedU( this.renderMinX * 16.0D );
|
||||
double d4 = (double) par8Icon.getInterpolatedU( this.renderMaxX * 16.0D );
|
||||
double d5 = (double) par8Icon.getInterpolatedV( 16.0D - this.renderMaxY * 16.0D );
|
||||
double d6 = (double) par8Icon.getInterpolatedV( 16.0D - this.renderMinY * 16.0D );
|
||||
|
||||
double d11 = par2 + this.renderMinX;
|
||||
double d12 = par2 + this.renderMaxX;
|
||||
double d13 = par4 + this.renderMinY;
|
||||
double d14 = par4 + this.renderMaxY;
|
||||
double d15 = par6 + this.renderMaxZ;
|
||||
|
||||
if ( this.enableAO )
|
||||
{
|
||||
partialLightingColoring( 1.0 - renderMinX, renderMaxY );
|
||||
tessellator.addVertexWithUV( d11, d14, d15, d3, d5 );
|
||||
partialLightingColoring( 1.0 - renderMinX, renderMinY );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d3, d6 );
|
||||
partialLightingColoring( 1.0 - renderMaxX, renderMinY );
|
||||
tessellator.addVertexWithUV( d12, d13, d15, d4, d6 );
|
||||
partialLightingColoring( 1.0 - renderMaxX, renderMaxY );
|
||||
tessellator.addVertexWithUV( d12, d14, d15, d4, d5 );
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV( d11, d14, d15, d3, d5 );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d3, d6 );
|
||||
tessellator.addVertexWithUV( d12, d13, d15, d4, d6 );
|
||||
tessellator.addVertexWithUV( d12, d14, d15, d4, d5 );
|
||||
}
|
||||
}
|
||||
else
|
||||
super.renderFaceZPos( par1Block, par2, par4, par6, par8Icon );
|
||||
}
|
||||
else
|
||||
{
|
||||
lightState.isAO = enableAO;
|
||||
lightState.rZPos = par8Icon;
|
||||
saveAO( lightState.aoZPos, lightState.foZPos );
|
||||
lightState.bZPos = getCurrentBrightness();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean similarLighting(Block blk, IBlockAccess w, int x, int y, int z, ISimplifiedBundle sim)
|
||||
{
|
||||
int lh = getLightingHash( blk, w, x, y, z );
|
||||
return ((LightingCache) sim).lightHash == lh;
|
||||
}
|
||||
|
||||
int lightHashTmp[] = new int[27];
|
||||
public float opacity = 1.0f;
|
||||
|
||||
private int getLightingHash(Block blk, IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
int o = 0;
|
||||
|
||||
for (int i = -1; i <= 1; i++)
|
||||
for (int j = -1; j <= 1; j++)
|
||||
for (int k = -1; k <= 1; k++)
|
||||
{
|
||||
|
||||
lightHashTmp[o++] = blk.getMixedBrightnessForBlock( this.blockAccess, x + i, y + j, z + k );
|
||||
}
|
||||
|
||||
return Arrays.hashCode( lightHashTmp );
|
||||
}
|
||||
|
||||
public void populate(ISimplifiedBundle sim)
|
||||
{
|
||||
lightState = new LightingCache( (LightingCache) sim );
|
||||
}
|
||||
|
||||
public ISimplifiedBundle getLightingCache()
|
||||
{
|
||||
return new LightingCache( lightState );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraftforge.client.IRenderHandler;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class SpatialSkyRender extends IRenderHandler
|
||||
{
|
||||
|
||||
private static SpatialSkyRender instance = new SpatialSkyRender();
|
||||
|
||||
private Random random = new Random();
|
||||
private long cycle = 0;
|
||||
private int dspList;
|
||||
|
||||
public SpatialSkyRender() {
|
||||
dspList = GLAllocation.generateDisplayLists( 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(float partialTicks, WorldClient world, Minecraft mc)
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
if ( now - cycle > 2000 )
|
||||
{
|
||||
cycle = now;
|
||||
GL11.glNewList( dspList, GL11.GL_COMPILE );
|
||||
renderTwinkles();
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
float fade = now - cycle;
|
||||
fade /= 1000;
|
||||
fade = 0.15f * (1.0f - Math.abs( (fade - 1.0f) * (fade - 1.0f) ));
|
||||
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
|
||||
GL11.glDisable(GL11.GL_FOG);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glColor4f( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (i == 2)
|
||||
{
|
||||
GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (i == 3)
|
||||
{
|
||||
GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (i == 4)
|
||||
{
|
||||
GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if (i == 5)
|
||||
{
|
||||
GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_I(0);
|
||||
tessellator.addVertexWithUV(-100.0D, -100.0D, -100.0D, 0.0D, 0.0D);
|
||||
tessellator.addVertexWithUV(-100.0D, -100.0D, 100.0D, 0.0D, 16.0D);
|
||||
tessellator.addVertexWithUV(100.0D, -100.0D, 100.0D, 16.0D, 16.0D);
|
||||
tessellator.addVertexWithUV(100.0D, -100.0D, -100.0D, 16.0D, 0.0D);
|
||||
tessellator.draw();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
|
||||
if ( fade > 0.0f )
|
||||
{
|
||||
GL11.glDisable( GL11.GL_FOG );
|
||||
GL11.glDisable( GL11.GL_ALPHA_TEST );
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
GL11.glDepthMask( false );
|
||||
GL11.glEnable( GL11.GL_FOG );
|
||||
GL11.glDisable( GL11.GL_FOG );
|
||||
GL11.glDisable( GL11.GL_ALPHA_TEST );
|
||||
GL11.glDisable( GL11.GL_TEXTURE_2D );
|
||||
OpenGlHelper.glBlendFunc( 770, 771, 1, 0 );
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDepthMask( false );
|
||||
|
||||
GL11.glColor4f( fade, fade, fade, 1.0f );
|
||||
GL11.glCallList( dspList );
|
||||
}
|
||||
|
||||
GL11.glPopAttrib();
|
||||
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
private void renderTwinkles()
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
for (int i = 0; i < 50; ++i)
|
||||
{
|
||||
double iX = (double) (random.nextFloat() * 2.0F - 1.0F);
|
||||
double iY = (double) (random.nextFloat() * 2.0F - 1.0F);
|
||||
double iZ = (double) (random.nextFloat() * 2.0F - 1.0F);
|
||||
double d3 = (double) (0.05F + random.nextFloat() * 0.1F);
|
||||
double dist = iX * iX + iY * iY + iZ * iZ;
|
||||
|
||||
if ( dist < 1.0D && dist > 0.01D )
|
||||
{
|
||||
dist = 1.0D / Math.sqrt( dist );
|
||||
iX *= dist;
|
||||
iY *= dist;
|
||||
iZ *= dist;
|
||||
double x = iX * 100.0D;
|
||||
double y = iY * 100.0D;
|
||||
double z = iZ * 100.0D;
|
||||
double d8 = Math.atan2( iX, iZ );
|
||||
double d9 = Math.sin( d8 );
|
||||
double d10 = Math.cos( d8 );
|
||||
double d11 = Math.atan2( Math.sqrt( iX * iX + iZ * iZ ), iY );
|
||||
double d12 = Math.sin( d11 );
|
||||
double d13 = Math.cos( d11 );
|
||||
double d14 = random.nextDouble() * Math.PI * 2.0D;
|
||||
double d15 = Math.sin( d14 );
|
||||
double d16 = Math.cos( d14 );
|
||||
|
||||
for (int j = 0; j < 4; ++j)
|
||||
{
|
||||
double d17 = 0.0D;
|
||||
double d18 = (double) ((j & 2) - 1) * d3;
|
||||
double d19 = (double) ((j + 1 & 2) - 1) * d3;
|
||||
double d20 = d18 * d16 - d19 * d15;
|
||||
double d21 = d19 * d16 + d18 * d15;
|
||||
double d22 = d20 * d12 + d17 * d13;
|
||||
double d23 = d17 * d12 - d20 * d13;
|
||||
double d24 = d23 * d9 - d21 * d10;
|
||||
double d25 = d21 * d9 + d23 * d10;
|
||||
tessellator.addVertex( x + d24, y + d22, z + d25 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static IRenderHandler getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.AELog;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TESRWrapper extends TileEntitySpecialRenderer
|
||||
{
|
||||
|
||||
final public RenderBlocks rbinstance = new RenderBlocks();
|
||||
|
||||
final BaseBlockRender blkRender;
|
||||
final double MAX_DISTANCE;
|
||||
|
||||
public TESRWrapper(BaseBlockRender render) {
|
||||
blkRender = render;
|
||||
MAX_DISTANCE = blkRender.getTesrRenderDistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f)
|
||||
{
|
||||
if ( te instanceof AEBaseTile )
|
||||
{
|
||||
Block b = te.getBlockType();
|
||||
|
||||
if ( b instanceof AEBaseBlock && ((AEBaseTile) te).requiresTESR() )
|
||||
{
|
||||
if ( Math.abs( x ) > MAX_DISTANCE || Math.abs( y ) > MAX_DISTANCE || Math.abs( z ) > MAX_DISTANCE )
|
||||
return;
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
if ( Platform.isDrawing( tess ) )
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
|
||||
rbinstance.blockAccess = te.getWorldObj();
|
||||
blkRender.renderTile( (AEBaseBlock) b, (AEBaseTile) te, tess, x, y, z, f, rbinstance );
|
||||
|
||||
if ( Platform.isDrawing( tess ) )
|
||||
throw new RuntimeException( "Error during rendering." );
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.severe( "Hi, Looks like there was a crash while rendering something..." );
|
||||
t.printStackTrace();
|
||||
AELog.severe( "MC will now crash ( probably )!" );
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package appeng.client.render;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.AELog;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class WorldRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
|
||||
private RenderBlocks renderer = new RenderBlocks();
|
||||
final int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
public static final WorldRender instance = new WorldRender();
|
||||
boolean hasError = false;
|
||||
|
||||
public HashMap<AEBaseBlock, BaseBlockRender> blockRenders = new HashMap();
|
||||
|
||||
void setRender(AEBaseBlock in, BaseBlockRender r)
|
||||
{
|
||||
blockRenders.put( in, r );
|
||||
}
|
||||
|
||||
private WorldRender() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
// wtf is this for?
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
AEBaseBlock blk = (AEBaseBlock) block;
|
||||
renderer.setRenderBoundsFromBlock( block );
|
||||
return getRender( blk ).renderInWorld( blk, world, x, y, z, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId()
|
||||
{
|
||||
return renderID;
|
||||
}
|
||||
|
||||
public void renderItemBlock(ItemStack item, ItemRenderType type, Object[] data)
|
||||
{
|
||||
Block blk = Block.getBlockFromItem( item.getItem() );
|
||||
if ( blk instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock block = (AEBaseBlock) blk;
|
||||
renderer.setRenderBoundsFromBlock( block );
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
getRender( block ).renderInventory( block, item, renderer, type, data );
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !hasError )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Invalid render - item/block mismatch" );
|
||||
AELog.severe( " item: " + item.getUnlocalizedName() );
|
||||
AELog.severe( " block: " + blk.getUnlocalizedName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BaseBlockRender getRender(AEBaseBlock block)
|
||||
{
|
||||
return block.getRendererInstance().rendererInstance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.parts.IBoxProvider;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.crafting.BlockMolecularAssembler;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BusRenderHelper;
|
||||
import appeng.client.render.BusRenderer;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.client.texture.TaughtIcon;
|
||||
import appeng.parts.networking.PartCable;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class RenderBlockAssembler extends BaseBlockRender implements IBoxProvider
|
||||
{
|
||||
|
||||
IIcon getConnectedCable(IBlockAccess world, int x, int y, int z, ForgeDirection d, boolean covered)
|
||||
{
|
||||
TileEntity ne = world.getTileEntity( x + d.offsetX, y + d.offsetY, z + d.offsetZ );
|
||||
if ( ne instanceof IGridHost && ne instanceof IPartHost )
|
||||
{
|
||||
IPartHost ph = (IPartHost) ne;
|
||||
IPart pcx = (IPart) ph.getPart( ForgeDirection.UNKNOWN );
|
||||
if ( pcx instanceof PartCable )
|
||||
{
|
||||
PartCable pc = (PartCable) pcx;
|
||||
if ( pc.isConnected( d.getOpposite() ) )
|
||||
{
|
||||
if ( covered )
|
||||
return pc.getCoveredTexture( pc.getCableColor() );
|
||||
return pc.getGlassTexture( pc.getCableColor() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void renderCableAt(double Thickness, IBlockAccess world, int x, int y, int z, AEBaseBlock block, RenderBlocks renderer, double pull, boolean covered)
|
||||
{
|
||||
IIcon texture = null;
|
||||
|
||||
block.getRendererInstance().setTemporaryRenderIcon( texture = getConnectedCable( world, x, y, z, ForgeDirection.WEST, covered ) );
|
||||
if ( texture != null )
|
||||
{
|
||||
renderer.setRenderBounds( 0.0D, 0.5D - Thickness, 0.5D - Thickness, 0.5D - Thickness - pull, 0.5D + Thickness, 0.5D + Thickness );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
block.getRendererInstance().setTemporaryRenderIcon( texture = getConnectedCable( world, x, y, z, ForgeDirection.EAST, covered ) );
|
||||
if ( texture != null )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D + Thickness + pull, 0.5D - Thickness, 0.5D - Thickness, 1.0D, 0.5D + Thickness, 0.5D + Thickness );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
block.getRendererInstance().setTemporaryRenderIcon( texture = getConnectedCable( world, x, y, z, ForgeDirection.NORTH, covered ) );
|
||||
if ( texture != null )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D - Thickness, 0.5D - Thickness, 0.0D, 0.5D + Thickness, 0.5D + Thickness, 0.5D - Thickness - pull );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
block.getRendererInstance().setTemporaryRenderIcon( texture = getConnectedCable( world, x, y, z, ForgeDirection.SOUTH, covered ) );
|
||||
if ( texture != null )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D - Thickness, 0.5D - Thickness, 0.5D + Thickness + pull, 0.5D + Thickness, 0.5D + Thickness, 1.0D );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
block.getRendererInstance().setTemporaryRenderIcon( texture = getConnectedCable( world, x, y, z, ForgeDirection.DOWN, covered ) );
|
||||
if ( texture != null )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D - Thickness, 0.0D, 0.5D - Thickness, 0.5D + Thickness, 0.5D - Thickness - pull, 0.5D + Thickness );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
block.getRendererInstance().setTemporaryRenderIcon( texture = getConnectedCable( world, x, y, z, ForgeDirection.UP, covered ) );
|
||||
if ( texture != null )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D - Thickness, 0.5D + Thickness + pull, 0.5D - Thickness, 0.5D + Thickness, 1.0D, 0.5D + Thickness );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
block.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
}
|
||||
|
||||
public RenderBlockAssembler() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
renderer.setOverrideBlockTexture( blk.getIcon( 0, 0 ) );
|
||||
|
||||
setInvRenderBounds( renderer, 2, 14, 0, 14, 16, 2 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 0, 14, 2, 2, 16, 14 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 2, 0, 14, 14, 2, 16 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 14, 0, 2, 16, 2, 14 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 0, 0, 0, 16, 2, 2 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 0, 2, 0, 2, 16, 2 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 0, 0, 2, 2, 2, 16 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 0, 14, 14, 16, 16, 16 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 14, 0, 14, 16, 14, 16 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 14, 14, 0, 16, 16, 14 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 14, 2, 0, 16, 14, 2 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 0, 2, 14, 2, 14, 16 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 1, 1, 1, 15, 15, 15 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, Tessellator.instance, 0xffffff, renderer );
|
||||
|
||||
renderer.setOverrideBlockTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
BlockMolecularAssembler blk = (BlockMolecularAssembler) block;
|
||||
TileMolecularAssembler tma = blk.getTileEntity( world, x, y, z );
|
||||
|
||||
if ( BlockMolecularAssembler.booleanAlphaPass )
|
||||
{
|
||||
if ( tma.isPowered() )
|
||||
{
|
||||
renderBlockBounds( renderer, 1, 1, 1, 15, 15, 15, ForgeDirection.WEST, ForgeDirection.UP, ForgeDirection.SOUTH );
|
||||
TaughtIcon lights = new TaughtIcon( ExtraBlockTextures.BlockMolecularAssemblerLights.getIcon(), -2.0f );
|
||||
Tessellator.instance.setColorRGBA_F( 1, 1, 1, 0.3f );
|
||||
Tessellator.instance.setBrightness( 14 << 20 | 14 << 4 );
|
||||
renderer.renderFaceXNeg( blk, x, y, z, lights );
|
||||
renderer.renderFaceXPos( blk, x, y, z, lights );
|
||||
renderer.renderFaceYNeg( blk, x, y, z, lights );
|
||||
renderer.renderFaceYPos( blk, x, y, z, lights );
|
||||
renderer.renderFaceZNeg( blk, x, y, z, lights );
|
||||
renderer.renderFaceZPos( blk, x, y, z, lights );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
BusRenderer.instance.renderer.blockAccess = renderer.blockAccess;
|
||||
renderer = BusRenderer.instance.renderer;
|
||||
|
||||
preRenderInWorld( block, world, x, y, z, renderer );
|
||||
|
||||
tma.lightCache = BusRenderHelper.instance.useSimplifiedRendering( x, y, z, this, tma.lightCache );
|
||||
|
||||
BusRenderer.instance.renderer.isFacade = true;
|
||||
IOrientable te = getOrientable( block, world, x, y, z );
|
||||
|
||||
ForgeDirection fdy = te.getUp();
|
||||
ForgeDirection fdz = te.getForward();
|
||||
ForgeDirection fdx = Platform.crossProduct( fdz, fdy ).getOpposite();
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
renderCableAt( 0.11D, world, x, y, z, block, renderer, 0.141D, false );
|
||||
renderCableAt( 0.188D, world, x, y, z, block, renderer, 0.1875D, true );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( blk.getIcon( 0, 0 ) );
|
||||
|
||||
renderBlockBounds( renderer, 2, 14, 0, 14, 16, 2, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 0, 14, 2, 2, 16, 14, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 2, 0, 14, 14, 2, 16, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 14, 0, 2, 16, 2, 14, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
// sides...
|
||||
renderBlockBounds( renderer, 0, 0, 0, 16, 2, 2, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 0, 2, 0, 2, 16, 2, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 0, 0, 2, 2, 2, 16, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 0, 14, 14, 16, 16, 16, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 14, 0, 14, 16, 14, 16, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 14, 14, 0, 16, 16, 14, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 14, 2, 0, 16, 14, 2, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 0, 2, 14, 2, 14, 16, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 1, 1, 1, 15, 15, 15, fdx, fdy, fdz );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
BusRenderHelper.instance.normalRendering();
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
BusRenderer.instance.renderer.isFacade = false;
|
||||
|
||||
postRenderInWorld( renderer );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch)
|
||||
{
|
||||
bch.addBox( 0, 0, 0, 16, 16, 16 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.misc.BlockCharger;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.AELog;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class RenderBlockCharger extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderBlockCharger() {
|
||||
super( true, 30 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
setInvRenderBounds( renderer, 6, 1, 0, 10, 15, 2 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcons( ExtraBlockTextures.BlockChargerInside.getIcon(), null, null, null, null, null );
|
||||
|
||||
setInvRenderBounds( renderer, 2, 0, 2, 14, 3, 14 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 3, 3, 3, 13, 4, 13 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcons( null, ExtraBlockTextures.BlockChargerInside.getIcon(), null, null, null, null );
|
||||
|
||||
setInvRenderBounds( renderer, 2, 13, 2, 14, 16, 14 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 3, 12, 3, 13, 13, 13 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
preRenderInWorld( block, world, x, y, z, renderer );
|
||||
|
||||
BlockCharger blk = (BlockCharger) block;
|
||||
|
||||
IOrientable te = getOrientable( block, world, x, y, z );
|
||||
|
||||
ForgeDirection fdy = te.getUp();
|
||||
ForgeDirection fdz = te.getForward();
|
||||
ForgeDirection fdx = Platform.crossProduct( fdz, fdy ).getOpposite();
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
renderBlockBounds( renderer, 6, 1, 0, 10, 15, 2, fdx, fdy, fdz );
|
||||
boolean out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcons( ExtraBlockTextures.BlockChargerInside.getIcon(), null, null, null, null, null );
|
||||
|
||||
renderBlockBounds( renderer, 2, 0, 2, 14, 3, 14, fdx, fdy, fdz );
|
||||
out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 3, 3, 3, 13, 4, 13, fdx, fdy, fdz );
|
||||
out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcons( null, ExtraBlockTextures.BlockChargerInside.getIcon(), null, null, null, null );
|
||||
|
||||
renderBlockBounds( renderer, 2, 13, 2, 14, 16, 14, fdx, fdy, fdz );
|
||||
out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 3, 12, 3, 13, 13, 13, fdx, fdy, fdz );
|
||||
out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
postRenderInWorld( renderer );
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTile(AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer)
|
||||
{
|
||||
ItemStack sis = null;
|
||||
if ( tile instanceof IInventory )
|
||||
sis = ((IInventory) tile).getStackInSlot( 0 );
|
||||
|
||||
if ( sis != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
applyTESRRotation( x, y, z, tile.getForward(), tile.getUp() );
|
||||
|
||||
try
|
||||
{
|
||||
GL11.glTranslatef( 0.5f, 0.45f, 0.5f );
|
||||
GL11.glScalef( 1.0f / 1.1f, 1.0f / 1.1f, 1.0f / 1.1f );
|
||||
GL11.glScalef( 1.0f, 1.0f, 1.0f );
|
||||
|
||||
Block blk = Block.getBlockFromItem( sis.getItem() );
|
||||
if ( sis.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d( blk.getRenderType() ) )
|
||||
{
|
||||
GL11.glRotatef( 25.0f, 1.0f, 0.0f, 0.0f );
|
||||
GL11.glRotatef( 15.0f, 0.0f, 1.0f, 0.0f );
|
||||
GL11.glRotatef( 30.0f, 0.0f, 1.0f, 0.0f );
|
||||
}
|
||||
|
||||
int light = tile.getWorldObj().getLightBrightnessForSkyBlocks( tile.xCoord, tile.yCoord, tile.zCoord, 0 );
|
||||
int br = light;// << 20 | light << 4;
|
||||
int var11 = br % 65536;
|
||||
int var12 = br / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11, var12 );
|
||||
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
|
||||
tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
|
||||
|
||||
doRenderItem( sis, tile );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AELog.error( err );
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.networking.TileController;
|
||||
|
||||
public class RenderBlockController extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderBlockController() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock blk, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
|
||||
boolean xx = getTileEntity( world, x - 1, y, z ) instanceof TileController && getTileEntity( world, x + 1, y, z ) instanceof TileController;
|
||||
boolean yy = getTileEntity( world, x, y - 1, z ) instanceof TileController && getTileEntity( world, x, y + 1, z ) instanceof TileController;
|
||||
boolean zz = getTileEntity( world, x, y, z - 1 ) instanceof TileController && getTileEntity( world, x, y, z + 1 ) instanceof TileController;
|
||||
|
||||
int meta = world.getBlockMetadata( x, y, z );
|
||||
boolean hasPower = meta > 0;
|
||||
boolean isConflict = meta == 2;
|
||||
|
||||
ExtraBlockTextures lights = null;
|
||||
|
||||
if ( xx && !yy && !zz )
|
||||
{
|
||||
if ( hasPower )
|
||||
{
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumnPowered.getIcon() );
|
||||
if ( isConflict )
|
||||
lights = ExtraBlockTextures.BlockControllerColumnConflict;
|
||||
else
|
||||
lights = ExtraBlockTextures.BlockControllerColumnLights;
|
||||
}
|
||||
else
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumn.getIcon() );
|
||||
|
||||
renderer.uvRotateEast = 1;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
}
|
||||
else if ( !xx && yy && !zz )
|
||||
{
|
||||
if ( hasPower )
|
||||
{
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumnPowered.getIcon() );
|
||||
if ( isConflict )
|
||||
lights = ExtraBlockTextures.BlockControllerColumnConflict;
|
||||
else
|
||||
lights = ExtraBlockTextures.BlockControllerColumnLights;
|
||||
}
|
||||
else
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumn.getIcon() );
|
||||
|
||||
renderer.uvRotateEast = 0;
|
||||
renderer.uvRotateNorth = 0;
|
||||
}
|
||||
else if ( !xx && !yy && zz )
|
||||
{
|
||||
if ( hasPower )
|
||||
{
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumnPowered.getIcon() );
|
||||
if ( isConflict )
|
||||
lights = ExtraBlockTextures.BlockControllerColumnConflict;
|
||||
else
|
||||
lights = ExtraBlockTextures.BlockControllerColumnLights;
|
||||
}
|
||||
else
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumn.getIcon() );
|
||||
|
||||
renderer.uvRotateNorth = 1;
|
||||
renderer.uvRotateSouth = 1;
|
||||
renderer.uvRotateTop = 0;
|
||||
}
|
||||
else if ( (xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) >= 2 )
|
||||
{
|
||||
int v = (Math.abs( x ) + Math.abs( y ) + Math.abs( z )) % 2;
|
||||
renderer.uvRotateEast = renderer.uvRotateBottom = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
|
||||
if ( v == 0 )
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerInsideA.getIcon() );
|
||||
else
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerInsideB.getIcon() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( hasPower )
|
||||
{
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerPowered.getIcon() );
|
||||
if ( isConflict )
|
||||
lights = ExtraBlockTextures.BlockControllerConflict;
|
||||
else
|
||||
lights = ExtraBlockTextures.BlockControllerLights;
|
||||
}
|
||||
else
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
}
|
||||
|
||||
boolean out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
if ( lights != null )
|
||||
{
|
||||
Tessellator.instance.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
|
||||
Tessellator.instance.setBrightness( 14 << 20 | 14 << 4 );
|
||||
renderer.renderFaceXNeg( blk, x, y, z, lights.getIcon() );
|
||||
renderer.renderFaceXPos( blk, x, y, z, lights.getIcon() );
|
||||
renderer.renderFaceYNeg( blk, x, y, z, lights.getIcon() );
|
||||
renderer.renderFaceYPos( blk, x, y, z, lights.getIcon() );
|
||||
renderer.renderFaceZNeg( blk, x, y, z, lights.getIcon() );
|
||||
renderer.renderFaceZPos( blk, x, y, z, lights.getIcon() );
|
||||
}
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
renderer.uvRotateEast = renderer.uvRotateBottom = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
return out;
|
||||
}
|
||||
|
||||
private TileEntity getTileEntity(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if ( y >= 0 )
|
||||
return world.getTileEntity( x, y, z );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.crafting.BlockCraftingMonitor;
|
||||
import appeng.block.crafting.BlockCraftingUnit;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BusRenderHelper;
|
||||
import appeng.client.render.BusRenderer;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
|
||||
public class RenderBlockCraftingCPU extends BaseBlockRender
|
||||
{
|
||||
|
||||
protected RenderBlockCraftingCPU(boolean useTesr, int range) {
|
||||
super( useTesr, range );
|
||||
}
|
||||
|
||||
public RenderBlockCraftingCPU() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
super.renderInventory( blk, is, renderer, type, obj );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock blk, IBlockAccess w, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
IIcon theIcon = null;
|
||||
boolean formed = false;
|
||||
boolean emitsLight = false;
|
||||
|
||||
TileCraftingTile ct = blk.getTileEntity( w, x, y, z );
|
||||
if ( ct != null && ct.isFormed() )
|
||||
{
|
||||
formed = true;
|
||||
emitsLight = ct.isPowered();
|
||||
}
|
||||
int meta = w.getBlockMetadata( x, y, z ) & 3;
|
||||
|
||||
boolean isMonitor = blk.getClass() == BlockCraftingMonitor.class;
|
||||
theIcon = blk.getIcon( ForgeDirection.SOUTH.ordinal(), meta | (formed ? 8 : 0) );
|
||||
|
||||
IIcon nonForward = theIcon;
|
||||
if ( isMonitor )
|
||||
nonForward = AEApi.instance().blocks().blockCraftingUnit.block().getIcon( 0, meta | (formed ? 8 : 0) );
|
||||
|
||||
if ( formed && renderer.overrideBlockTexture == null )
|
||||
{
|
||||
renderer = BusRenderer.instance.renderer;
|
||||
BusRenderHelper i = BusRenderHelper.instance;
|
||||
BusRenderer.instance.renderer.isFacade = true;
|
||||
|
||||
renderer.blockAccess = w;
|
||||
i.setPass( 0 );
|
||||
i.setOrientation( ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH );
|
||||
|
||||
try
|
||||
{
|
||||
ct.lightCache = i.useSimplifiedRendering( x, y, z, null, ct.lightCache );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float highX = isConnected( w, x, y, z, ForgeDirection.EAST ) ? 16 : 13.01f;
|
||||
float lowX = isConnected( w, x, y, z, ForgeDirection.WEST ) ? 0 : 2.99f;
|
||||
|
||||
float highY = isConnected( w, x, y, z, ForgeDirection.UP ) ? 16 : 13.01f;
|
||||
float lowY = isConnected( w, x, y, z, ForgeDirection.DOWN ) ? 0 : 2.99f;
|
||||
|
||||
float highZ = isConnected( w, x, y, z, ForgeDirection.SOUTH ) ? 16 : 13.01f;
|
||||
float lowZ = isConnected( w, x, y, z, ForgeDirection.NORTH ) ? 0 : 2.99f;
|
||||
|
||||
renderCorner( i, renderer, w, x, y, z, ForgeDirection.UP, ForgeDirection.EAST, ForgeDirection.NORTH );
|
||||
renderCorner( i, renderer, w, x, y, z, ForgeDirection.UP, ForgeDirection.EAST, ForgeDirection.SOUTH );
|
||||
renderCorner( i, renderer, w, x, y, z, ForgeDirection.UP, ForgeDirection.WEST, ForgeDirection.NORTH );
|
||||
renderCorner( i, renderer, w, x, y, z, ForgeDirection.UP, ForgeDirection.WEST, ForgeDirection.SOUTH );
|
||||
renderCorner( i, renderer, w, x, y, z, ForgeDirection.DOWN, ForgeDirection.EAST, ForgeDirection.NORTH );
|
||||
renderCorner( i, renderer, w, x, y, z, ForgeDirection.DOWN, ForgeDirection.EAST, ForgeDirection.SOUTH );
|
||||
renderCorner( i, renderer, w, x, y, z, ForgeDirection.DOWN, ForgeDirection.WEST, ForgeDirection.NORTH );
|
||||
renderCorner( i, renderer, w, x, y, z, ForgeDirection.DOWN, ForgeDirection.WEST, ForgeDirection.SOUTH );
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
i.setBounds( fso( side, lowX, ForgeDirection.WEST ), fso( side, lowY, ForgeDirection.DOWN ), fso( side, lowZ, ForgeDirection.NORTH ),
|
||||
fso( side, highX, ForgeDirection.EAST ), fso( side, highY, ForgeDirection.UP ), fso( side, highZ, ForgeDirection.SOUTH ) );
|
||||
i.prepareBounds( renderer );
|
||||
|
||||
boolean LocalEmit = emitsLight;
|
||||
if ( blk instanceof BlockCraftingMonitor && !ct.getForward().equals( side ) )
|
||||
LocalEmit = false;
|
||||
|
||||
handleSide( blk, meta, x, y, z, i, renderer, ct.getForward().equals( side ) ? theIcon : nonForward, LocalEmit, isMonitor, side, w );
|
||||
}
|
||||
|
||||
BusRenderer.instance.renderer.isFacade = false;
|
||||
i.setFacesToRender( EnumSet.allOf( ForgeDirection.class ) );
|
||||
i.normalRendering();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
double a = 0.0 / 16.0;
|
||||
double o = 16.0 / 16.0;
|
||||
renderer.setRenderBounds( a, a, a, o, o, o );
|
||||
boolean out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
private void renderCorner(BusRenderHelper i, RenderBlocks renderer, IBlockAccess w, int x, int y, int z, ForgeDirection up, ForgeDirection east,
|
||||
ForgeDirection south)
|
||||
{
|
||||
if ( isConnected( w, x, y, z, up ) )
|
||||
return;
|
||||
if ( isConnected( w, x, y, z, east ) )
|
||||
return;
|
||||
if ( isConnected( w, x, y, z, south ) )
|
||||
return;
|
||||
|
||||
i.setBounds( gso( east, 3, ForgeDirection.WEST ), gso( up, 3, ForgeDirection.DOWN ), gso( south, 3, ForgeDirection.NORTH ),
|
||||
gso( east, 13, ForgeDirection.EAST ), gso( up, 13, ForgeDirection.UP ), gso( south, 13, ForgeDirection.SOUTH ) );
|
||||
i.prepareBounds( renderer );
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingUnitRing.getIcon() );
|
||||
i.renderBlockCurrentBounds( x, y, z, renderer );
|
||||
}
|
||||
|
||||
private float gso(ForgeDirection side, float def, ForgeDirection target)
|
||||
{
|
||||
if ( side != target )
|
||||
{
|
||||
if ( side.offsetX > 0 || side.offsetY > 0 || side.offsetZ > 0 )
|
||||
return 16;
|
||||
return 0;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
private float fso(ForgeDirection side, float def, ForgeDirection target)
|
||||
{
|
||||
if ( side == target )
|
||||
{
|
||||
if ( side.offsetX > 0 || side.offsetY > 0 || side.offsetZ > 0 )
|
||||
return 16;
|
||||
return 0;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
private void handleSide(AEBaseBlock blk, int meta, int x, int y, int z, BusRenderHelper i, RenderBlocks renderer, IIcon color, boolean emitsLight,
|
||||
boolean isMonitor, ForgeDirection side, IBlockAccess w)
|
||||
{
|
||||
if ( isConnected( w, x, y, z, side ) )
|
||||
return;
|
||||
|
||||
i.setFacesToRender( EnumSet.of( side ) );
|
||||
|
||||
if ( meta == 0 && blk.getClass() == BlockCraftingUnit.class )
|
||||
{
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingUnitFit.getIcon() );
|
||||
i.renderBlockCurrentBounds( x, y, z, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( color == ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon() )
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingMonitorOuter.getIcon() );
|
||||
else
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingFitSolid.getIcon() );
|
||||
|
||||
i.renderBlockCurrentBounds( x, y, z, renderer );
|
||||
|
||||
if ( color != null )
|
||||
{
|
||||
i.setTexture( color );
|
||||
|
||||
if ( !emitsLight )
|
||||
{
|
||||
if ( color == ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon() )
|
||||
{
|
||||
int b = w.getLightBrightnessForSkyBlocks( x + side.offsetX, y + side.offsetY, z + side.offsetZ, 0 );
|
||||
|
||||
TileCraftingMonitorTile sr = blk.getTileEntity( w, x, y, z );
|
||||
AEColor col = sr.getColor();
|
||||
|
||||
Tessellator.instance.setBrightness( b );
|
||||
Tessellator.instance.setColorOpaque_I( col.whiteVariant );
|
||||
i.renderFace( x, y, z, color, side, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( col.mediumVariant );
|
||||
i.renderFace( x, y, z, ExtraBlockTextures.BlockCraftingMonitorFit_Medium.getIcon(), side, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( col.blackVariant );
|
||||
i.renderFace( x, y, z, ExtraBlockTextures.BlockCraftingMonitorFit_Dark.getIcon(), side, renderer );
|
||||
}
|
||||
else
|
||||
i.renderBlockCurrentBounds( x, y, z, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isMonitor )
|
||||
{
|
||||
TileCraftingMonitorTile sr = blk.getTileEntity( w, x, y, z );
|
||||
AEColor col = sr.getColor();
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( col.whiteVariant );
|
||||
Tessellator.instance.setBrightness( 13 << 20 | 13 << 4 );
|
||||
i.renderFace( x, y, z, color, side, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( col.mediumVariant );
|
||||
Tessellator.instance.setBrightness( 13 << 20 | 13 << 4 );
|
||||
i.renderFace( x, y, z, ExtraBlockTextures.BlockCraftingMonitorFit_Medium.getIcon(), side, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( col.blackVariant );
|
||||
Tessellator.instance.setBrightness( 13 << 20 | 13 << 4 );
|
||||
i.renderFace( x, y, z, ExtraBlockTextures.BlockCraftingMonitorFit_Dark.getIcon(), side, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
Tessellator.instance.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
|
||||
Tessellator.instance.setBrightness( 13 << 20 | 13 << 4 );
|
||||
i.renderFace( x, y, z, color, side, renderer );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (ForgeDirection a : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if ( a == side || a == side.getOpposite() )
|
||||
continue;
|
||||
|
||||
if ( (side.offsetX != 0 || side.offsetZ != 0)
|
||||
&& (a == ForgeDirection.NORTH || a == ForgeDirection.EAST || a == ForgeDirection.WEST || a == ForgeDirection.SOUTH) )
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingUnitRingLongRotated.getIcon() );
|
||||
else if ( (side.offsetY != 0) && (a == ForgeDirection.EAST || a == ForgeDirection.WEST) )
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingUnitRingLongRotated.getIcon() );
|
||||
else
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingUnitRingLong.getIcon() );
|
||||
|
||||
double width = 3.0 / 16.0;
|
||||
|
||||
if ( !(i.getBound( a ) < 0.001 || i.getBound( a ) > 15.999) )
|
||||
{
|
||||
switch (a)
|
||||
{
|
||||
case DOWN:
|
||||
renderer.renderMinY = 0;
|
||||
renderer.renderMaxY = width;
|
||||
break;
|
||||
case EAST:
|
||||
renderer.renderMaxX = 1;
|
||||
renderer.renderMinX = 1.0 - width;
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateEast = 1;
|
||||
break;
|
||||
case NORTH:
|
||||
renderer.renderMinZ = 0;
|
||||
renderer.renderMaxZ = width;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateNorth = 1;
|
||||
renderer.uvRotateSouth = 1;
|
||||
break;
|
||||
case SOUTH:
|
||||
renderer.renderMaxZ = 1;
|
||||
renderer.renderMinZ = 1.0 - width;
|
||||
renderer.uvRotateNorth = 1;
|
||||
renderer.uvRotateSouth = 1;
|
||||
break;
|
||||
case UP:
|
||||
renderer.renderMaxY = 1;
|
||||
renderer.renderMinY = 1.0 - width;
|
||||
break;
|
||||
case WEST:
|
||||
renderer.renderMinX = 0;
|
||||
renderer.renderMaxX = width;
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateEast = 1;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
}
|
||||
|
||||
i.renderBlockCurrentBounds( x, y, z, renderer );
|
||||
i.prepareBounds( renderer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isConnected(IBlockAccess w, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return w.getTileEntity( x + side.offsetX, y + side.offsetY, z + side.offsetZ ) instanceof TileCraftingTile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.core.AELog;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class RenderBlockCraftingCPUMonitor extends RenderBlockCraftingCPU
|
||||
{
|
||||
|
||||
public RenderBlockCraftingCPUMonitor() {
|
||||
super( true, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTile(AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer)
|
||||
{
|
||||
if ( Platform.isDrawing( tess ) )
|
||||
return;
|
||||
|
||||
if ( tile instanceof TileCraftingMonitorTile )
|
||||
{
|
||||
TileCraftingMonitorTile cmt = (TileCraftingMonitorTile) tile;
|
||||
IAEItemStack ais = (IAEItemStack) cmt.getJobProgress();
|
||||
|
||||
if ( cmt.dspList == null )
|
||||
{
|
||||
cmt.updateList = true;
|
||||
cmt.dspList = GLAllocation.generateDisplayLists( 1 );
|
||||
}
|
||||
|
||||
if ( ais != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 );
|
||||
|
||||
if ( cmt.updateList )
|
||||
{
|
||||
cmt.updateList = false;
|
||||
GL11.glNewList( cmt.dspList, GL11.GL_COMPILE_AND_EXECUTE );
|
||||
tesrRenderScreen( tess, cmt, ais );
|
||||
GL11.glEndList();
|
||||
}
|
||||
else
|
||||
GL11.glCallList( cmt.dspList );
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tesrRenderScreen(Tessellator tess, TileCraftingMonitorTile cmt, IAEItemStack ais)
|
||||
{
|
||||
ForgeDirection side = cmt.getForward();
|
||||
|
||||
ForgeDirection walrus = side.offsetY != 0 ? ForgeDirection.SOUTH : ForgeDirection.UP;
|
||||
int spin = 0;
|
||||
|
||||
int max = 5;
|
||||
while (walrus != cmt.getUp() && max-- > 0)
|
||||
{
|
||||
spin++;
|
||||
walrus = Platform.rotateAround( walrus, side );
|
||||
}
|
||||
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
ForgeDirection d = side;
|
||||
GL11.glTranslated( d.offsetX * 0.69, d.offsetY * 0.69, d.offsetZ * 0.69 );
|
||||
|
||||
float scale = 0.7f;
|
||||
GL11.glScalef( scale, scale, scale );
|
||||
|
||||
if ( d == ForgeDirection.UP )
|
||||
{
|
||||
GL11.glScalef( 1.0f, -1.0f, 1.0f );
|
||||
GL11.glRotatef( 90.0f, 1.0f, 0.0f, 0.0f );
|
||||
GL11.glRotatef( (float) spin * 90.0F, 0, 0, 1 );
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.DOWN )
|
||||
{
|
||||
GL11.glScalef( 1.0f, -1.0f, 1.0f );
|
||||
GL11.glRotatef( -90.0f, 1.0f, 0.0f, 0.0f );
|
||||
GL11.glRotatef( (float) spin * -90.0F, 0, 0, 1 );
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.EAST )
|
||||
{
|
||||
GL11.glScalef( -1.0f, -1.0f, -1.0f );
|
||||
GL11.glRotatef( -90.0f, 0.0f, 1.0f, 0.0f );
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.WEST )
|
||||
{
|
||||
GL11.glScalef( -1.0f, -1.0f, -1.0f );
|
||||
GL11.glRotatef( 90.0f, 0.0f, 1.0f, 0.0f );
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.NORTH )
|
||||
{
|
||||
GL11.glScalef( -1.0f, -1.0f, -1.0f );
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.SOUTH )
|
||||
{
|
||||
GL11.glScalef( -1.0f, -1.0f, -1.0f );
|
||||
GL11.glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
try
|
||||
{
|
||||
ItemStack sis = ais.getItemStack();
|
||||
sis.stackSize = 1;
|
||||
|
||||
int br = 16 << 20 | 16 << 4;
|
||||
int var11 = br % 65536;
|
||||
int var12 = br / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11 * 0.8F, var12 * 0.8F );
|
||||
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
|
||||
// RenderHelper.enableGUIStandardItemLighting();
|
||||
tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
|
||||
|
||||
ClientHelper.proxy.doRenderItem( sis, cmt.getWorldObj() );
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glTranslatef( 0.0f, 0.14f, -0.24f );
|
||||
GL11.glScalef( 1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f );
|
||||
|
||||
long qty = ais.getStackSize();
|
||||
if ( qty > 999999999999L )
|
||||
qty = 999999999999L;
|
||||
|
||||
String msg = Long.toString( qty );
|
||||
if ( qty > 1000000000 )
|
||||
msg = Long.toString( qty / 1000000000 ) + "B";
|
||||
else if ( qty > 1000000 )
|
||||
msg = Long.toString( qty / 1000000 ) + "M";
|
||||
else if ( qty > 9999 )
|
||||
msg = Long.toString( qty / 1000 ) + "K";
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
int width = fr.getStringWidth( msg );
|
||||
GL11.glTranslatef( -0.5f * width, 0.0f, -1.0f );
|
||||
fr.drawString( msg, 0, 0, 0 );
|
||||
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.grindstone.TileCrank;
|
||||
|
||||
public class RenderBlockCrank extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderBlockCrank() {
|
||||
super( true, 60 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
renderer.setRenderBounds( 0.5D - 0.05, 0.5D - 0.5, 0.5D - 0.05, 0.5D + 0.05, 0.5D + 0.3, 0.5D + 0.05 );
|
||||
super.renderInventory( blk, is, renderer, type, obj );
|
||||
|
||||
renderer.setRenderBounds( 0.70D - 0.15, 0.75D - 0.05, 0.5D - 0.05, 0.70D + 0.28, 0.75D + 0.05, 0.5D + 0.05 );
|
||||
super.renderInventory( blk, is, renderer, type, obj );
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTile(AEBaseBlock blk, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks rbinstance)
|
||||
{
|
||||
TileCrank tc = (TileCrank) tile;
|
||||
if ( tc.getUp() == null || tc.getUp() == ForgeDirection.UNKNOWN )
|
||||
return;
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.locationBlocksTexture );
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
if ( Minecraft.isAmbientOcclusionEnabled() )
|
||||
GL11.glShadeModel( GL11.GL_SMOOTH );
|
||||
else
|
||||
GL11.glShadeModel( GL11.GL_FLAT );
|
||||
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
applyTESRRotation( x, y, z, tile.getForward(), tile.getUp() );
|
||||
|
||||
GL11.glTranslated( 0.5, 0, 0.5 );
|
||||
GL11.glRotatef( tc.visibleRotation, 0, 1, 0 );
|
||||
GL11.glTranslated( -0.5, 0, -0.5 );
|
||||
|
||||
tess.setTranslation( -tc.xCoord, -tc.yCoord, -tc.zCoord );
|
||||
tess.startDrawingQuads();
|
||||
rbinstance.renderAllFaces = true;
|
||||
rbinstance.blockAccess = tc.getWorldObj();
|
||||
|
||||
rbinstance.setRenderBounds( 0.5D - 0.05, 0.5D - 0.5, 0.5D - 0.05, 0.5D + 0.05, 0.5D + 0.1, 0.5D + 0.05 );
|
||||
|
||||
rbinstance.renderStandardBlock( blk, tc.xCoord, tc.yCoord, tc.zCoord );
|
||||
|
||||
rbinstance.setRenderBounds( 0.70D - 0.15, 0.55D - 0.05, 0.5D - 0.05, 0.70D + 0.15, 0.55D + 0.05, 0.5D + 0.05 );
|
||||
|
||||
rbinstance.renderStandardBlock( blk, tc.xCoord, tc.yCoord, tc.zCoord );
|
||||
|
||||
tess.draw();
|
||||
tess.setTranslation( 0, 0, 0 );
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
|
||||
public class RenderBlockEnergyCube extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderBlockEnergyCube() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
IAEItemPowerStorage myItem = (IAEItemPowerStorage) is.getItem();
|
||||
double internalCurrentPower = myItem.getAECurrentPower( is );
|
||||
double internalMaxPower = myItem.getAEMaxPower( is );
|
||||
|
||||
int meta = (int) (8.0 * (internalCurrentPower / internalMaxPower));
|
||||
|
||||
if ( meta > 7 )
|
||||
meta = 7;
|
||||
if ( meta < 0 )
|
||||
meta = 0;
|
||||
|
||||
renderer.setOverrideBlockTexture( blk.getIcon( 0, meta ) );
|
||||
super.renderInventory( blk, is, renderer, type, obj );
|
||||
renderer.setOverrideBlockTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock blk, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
int meta = world.getBlockMetadata( x, y, z );
|
||||
|
||||
renderer.overrideBlockTexture = blk.getIcon( 0, meta );
|
||||
boolean out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
renderer.overrideBlockTexture = null;
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.misc.BlockInscriber;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.AELog;
|
||||
import appeng.recipes.handlers.Inscribe.InscriberRecipe;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class RenderBlockInscriber extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderBlockInscriber() {
|
||||
super( true, 30 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
setInvRenderBounds( renderer, 6, 1, 0, 10, 15, 2 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
// sides...
|
||||
setInvRenderBounds( renderer, 3, 1, 0, 13, 15, 3 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 0, 1, 0, 3, 15, 16 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 13, 1, 0, 16, 15, 16 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 1, 0, 1, 15, 2, 15 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 1, 14, 1, 15, 16, 15 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockInscriberInside.getIcon() );
|
||||
|
||||
// press
|
||||
setInvRenderBounds( renderer, 3, 2, 3, 13, 3, 13 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
setInvRenderBounds( renderer, 3, 13, 3, 13, 15, 13 );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
// blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
preRenderInWorld( block, world, x, y, z, renderer );
|
||||
|
||||
BlockInscriber blk = (BlockInscriber) block;
|
||||
|
||||
IOrientable te = getOrientable( block, world, x, y, z );
|
||||
|
||||
ForgeDirection fdy = te.getUp();
|
||||
ForgeDirection fdz = te.getForward();
|
||||
ForgeDirection fdx = Platform.crossProduct( fdz, fdy ).getOpposite();
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
// sides...
|
||||
renderBlockBounds( renderer, 3, 1, 0, 13, 15, 3, fdx, fdy, fdz );
|
||||
boolean out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 0, 1, 0, 3, 15, 16, fdx, fdy, fdz );
|
||||
out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 13, 1, 0, 16, 15, 16, fdx, fdy, fdz );
|
||||
out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
// top bottom..
|
||||
renderBlockBounds( renderer, 1, 0, 1, 15, 4, 15, fdx, fdy, fdz );
|
||||
out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderBlockBounds( renderer, 1, 12, 1, 15, 16, 15, fdx, fdy, fdz );
|
||||
out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
postRenderInWorld( renderer );
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTile(AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer)
|
||||
{
|
||||
TileInscriber inv = (TileInscriber) tile;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
applyTESRRotation( x, y, z, tile.getForward(), tile.getUp() );
|
||||
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.renderEngine.bindTexture( TextureMap.locationBlocksTexture );
|
||||
|
||||
int light = tile.getWorldObj().getLightBrightnessForSkyBlocks( tile.xCoord, tile.yCoord, tile.zCoord, 0 );
|
||||
int br = light;// << 20 | light << 4;
|
||||
int var11 = br % 65536;
|
||||
int var12 = br / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11, var12 );
|
||||
|
||||
float TwoPx = 2.0f / 16.0f;
|
||||
float middle = 0.5f;
|
||||
|
||||
float press = 0.2f;
|
||||
float base = 0.4f;
|
||||
|
||||
long lprogress = 0;
|
||||
if ( inv.smash )
|
||||
{
|
||||
long currentTime = System.currentTimeMillis();
|
||||
lprogress = currentTime - inv.clientStart;
|
||||
if ( lprogress > 800 )
|
||||
inv.smash = false;
|
||||
}
|
||||
|
||||
float rprogress = (float) (lprogress % 800) / 400.0f;
|
||||
float progress = rprogress;
|
||||
|
||||
if ( progress > 1.0f )
|
||||
progress = 1.0f - (progress - 1.0f);
|
||||
press -= progress / 5.0f;
|
||||
|
||||
IIcon ic = ExtraBlockTextures.BlockInscriberInside.getIcon();
|
||||
tess.startDrawingQuads();
|
||||
|
||||
middle += 0.02f;
|
||||
tess.addVertexWithUV( TwoPx, middle + press, TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 2 ) );
|
||||
tess.addVertexWithUV( 1.0 - TwoPx, middle + press, TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 2 ) );
|
||||
tess.addVertexWithUV( 1.0 - TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 13 ) );
|
||||
tess.addVertexWithUV( TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 13 ) );
|
||||
|
||||
tess.addVertexWithUV( TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 3 ) );
|
||||
tess.addVertexWithUV( 1.0 - TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 3 ) );
|
||||
tess.addVertexWithUV( 1.0 - TwoPx, middle + base, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 3 - 16 * (press - base) ) );
|
||||
tess.addVertexWithUV( TwoPx, middle + base, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 3 - 16 * (press - base) ) );
|
||||
|
||||
middle -= 2.0f * 0.02f;
|
||||
tess.addVertexWithUV( 1.0 - TwoPx, middle - press, TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 2 ) );
|
||||
tess.addVertexWithUV( TwoPx, middle - press, TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 2 ) );
|
||||
tess.addVertexWithUV( TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 13 ) );
|
||||
tess.addVertexWithUV( 1.0 - TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 13 ) );
|
||||
|
||||
tess.addVertexWithUV( 1.0 - TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 3 ) );
|
||||
tess.addVertexWithUV( TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 3 ) );
|
||||
tess.addVertexWithUV( TwoPx, middle - base, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 3 - 16 * (press - base) ) );
|
||||
tess.addVertexWithUV( 1.0 - TwoPx, middle + -base, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 3 - 16 * (press - base) ) );
|
||||
|
||||
tess.draw();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
int items = 0;
|
||||
if ( inv.getStackInSlot( 0 ) != null )
|
||||
items++;
|
||||
if ( inv.getStackInSlot( 1 ) != null )
|
||||
items++;
|
||||
if ( inv.getStackInSlot( 2 ) != null )
|
||||
items++;
|
||||
|
||||
if ( rprogress > 1.0f || items == 0 )
|
||||
{
|
||||
ItemStack is = inv.getStackInSlot( 3 );
|
||||
|
||||
if ( is == null )
|
||||
{
|
||||
InscriberRecipe ir = inv.getTask();
|
||||
if ( ir != null )
|
||||
is = ir.output.copy();
|
||||
}
|
||||
|
||||
renderItem( is, 0.0f, block, tile, tess, x, y, z, f, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
renderItem( inv.getStackInSlot( 0 ), press, block, tile, tess, x, y, z, f, renderer );
|
||||
renderItem( inv.getStackInSlot( 1 ), -press, block, tile, tess, x, y, z, f, renderer );
|
||||
renderItem( inv.getStackInSlot( 2 ), 0.0f, block, tile, tess, x, y, z, f, renderer );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void renderItem(ItemStack sis, float o, AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f,
|
||||
RenderBlocks renderer)
|
||||
{
|
||||
if ( sis != null )
|
||||
{
|
||||
sis = sis.copy();
|
||||
GL11.glPushMatrix();
|
||||
applyTESRRotation( x, y, z, tile.getForward(), tile.getUp() );
|
||||
|
||||
try
|
||||
{
|
||||
GL11.glTranslatef( 0.5f, 0.5f + o, 0.5f );
|
||||
GL11.glScalef( 1.0f / 1.1f, 1.0f / 1.1f, 1.0f / 1.1f );
|
||||
GL11.glScalef( 1.0f, 1.0f, 1.0f );
|
||||
|
||||
Block blk = Block.getBlockFromItem( sis.getItem() );
|
||||
if ( sis.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d( blk.getRenderType() ) )
|
||||
{
|
||||
GL11.glRotatef( 25.0f, 1.0f, 0.0f, 0.0f );
|
||||
GL11.glRotatef( 15.0f, 0.0f, 1.0f, 0.0f );
|
||||
GL11.glRotatef( 30.0f, 0.0f, 1.0f, 0.0f );
|
||||
}
|
||||
|
||||
GL11.glRotatef( 90.0f, 1, 0, 0 );
|
||||
|
||||
int light = tile.getWorldObj().getLightBrightnessForSkyBlocks( tile.xCoord, tile.yCoord, tile.zCoord, 0 );
|
||||
int br = light;// << 20 | light << 4;
|
||||
int var11 = br % 65536;
|
||||
int var12 = br / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11, var12 );
|
||||
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
|
||||
tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
|
||||
|
||||
doRenderItem( sis, tile );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AELog.error( err );
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BlockRenderInfo;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
|
||||
public class RenderBlockInterface extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderBlockInterface() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
TileInterface ti = block.getTileEntity( world, x, y, z );
|
||||
|
||||
BlockRenderInfo info = block.getRendererInstance();
|
||||
|
||||
if ( ti.getForward() != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
IIcon side = ExtraBlockTextures.BlockInterfaceAlternateArrow.getIcon();
|
||||
info.setTemporaryRenderIcons( ExtraBlockTextures.BlockInterfaceAlternate.getIcon(), block.getIcon( 0, 0 ), side, side, side, side );
|
||||
}
|
||||
|
||||
boolean fz = super.renderInWorld( block, world, x, y, z, renderer );
|
||||
|
||||
info.setTemporaryRenderIcon( null );
|
||||
|
||||
return fz;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.helpers.Splot;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
|
||||
public class RenderBlockPaint extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderBlockPaint() {
|
||||
super( false, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
TilePaint tp = imb.getTileEntity( world, x, y, z );
|
||||
boolean out = false;
|
||||
if ( tp != null )
|
||||
{
|
||||
// super.renderInWorld( imb, world, x, y, z, renderer );
|
||||
|
||||
IIcon icoSet[] = new IIcon[] { imb.getIcon( 0, 0 ), ExtraBlockTextures.BlockPaint2.getIcon(), ExtraBlockTextures.BlockPaint3.getIcon() };
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
int lumen = 14 << 20 | 14 << 4;
|
||||
int worldb = imb.getMixedBrightnessForBlock( world, x, y, z );
|
||||
|
||||
double offoff = 0.001;
|
||||
|
||||
EnumSet<ForgeDirection> validSides = EnumSet.noneOf( ForgeDirection.class );
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if ( tp.isSideValid( side ) )
|
||||
validSides.add( side );
|
||||
}
|
||||
|
||||
for (Splot s : tp.getDots())
|
||||
{
|
||||
if ( !validSides.contains( s.side ) )
|
||||
continue;
|
||||
|
||||
if ( s.lumen )
|
||||
{
|
||||
tess.setColorOpaque_I( s.color.whiteVariant );
|
||||
tess.setBrightness( lumen );
|
||||
}
|
||||
else
|
||||
{
|
||||
tess.setColorOpaque_I( s.color.mediumVariant );
|
||||
tess.setBrightness( worldb );
|
||||
}
|
||||
|
||||
double offset = offoff;
|
||||
offoff += 0.001;
|
||||
|
||||
double H = 0.1;
|
||||
|
||||
double pos_x = s.x();
|
||||
double pos_y = s.y();
|
||||
|
||||
pos_x = Math.max( H, Math.min( 1.0 - H, pos_x ) );
|
||||
pos_y = Math.max( H, Math.min( 1.0 - H, pos_y ) );
|
||||
|
||||
if ( s.side == ForgeDirection.SOUTH || s.side == ForgeDirection.NORTH )
|
||||
{
|
||||
pos_x += x;
|
||||
pos_y += y;
|
||||
}
|
||||
|
||||
else if ( s.side == ForgeDirection.UP || s.side == ForgeDirection.DOWN )
|
||||
{
|
||||
pos_x += x;
|
||||
pos_y += z;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
pos_x += y;
|
||||
pos_y += z;
|
||||
}
|
||||
|
||||
IIcon ico = icoSet[s.getSeed() % icoSet.length];
|
||||
|
||||
switch (s.side)
|
||||
{
|
||||
case UP:
|
||||
offset = 1.0 - offset;
|
||||
tess.addVertexWithUV( pos_x - H, y + offset, pos_y - H, ico.getMinU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( pos_x + H, y + offset, pos_y - H, ico.getMaxU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( pos_x + H, y + offset, pos_y + H, ico.getMaxU(), ico.getMaxV() );
|
||||
tess.addVertexWithUV( pos_x - H, y + offset, pos_y + H, ico.getMinU(), ico.getMaxV() );
|
||||
break;
|
||||
|
||||
case DOWN:
|
||||
tess.addVertexWithUV( pos_x + H, y + offset, pos_y - H, ico.getMinU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( pos_x - H, y + offset, pos_y - H, ico.getMaxU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( pos_x - H, y + offset, pos_y + H, ico.getMaxU(), ico.getMaxV() );
|
||||
tess.addVertexWithUV( pos_x + H, y + offset, pos_y + H, ico.getMinU(), ico.getMaxV() );
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
offset = 1.0 - offset;
|
||||
tess.addVertexWithUV( x + offset, pos_x + H, pos_y - H, ico.getMinU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( x + offset, pos_x - H, pos_y - H, ico.getMaxU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( x + offset, pos_x - H, pos_y + H, ico.getMaxU(), ico.getMaxV() );
|
||||
tess.addVertexWithUV( x + offset, pos_x + H, pos_y + H, ico.getMinU(), ico.getMaxV() );
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
tess.addVertexWithUV( x + offset, pos_x - H, pos_y - H, ico.getMinU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( x + offset, pos_x + H, pos_y - H, ico.getMaxU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( x + offset, pos_x + H, pos_y + H, ico.getMaxU(), ico.getMaxV() );
|
||||
tess.addVertexWithUV( x + offset, pos_x - H, pos_y + H, ico.getMinU(), ico.getMaxV() );
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
offset = 1.0 - offset;
|
||||
tess.addVertexWithUV( pos_x + H, pos_y - H, z + offset, ico.getMinU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( pos_x - H, pos_y - H, z + offset, ico.getMaxU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( pos_x - H, pos_y + H, z + offset, ico.getMaxU(), ico.getMaxV() );
|
||||
tess.addVertexWithUV( pos_x + H, pos_y + H, z + offset, ico.getMinU(), ico.getMaxV() );
|
||||
break;
|
||||
|
||||
case NORTH:
|
||||
tess.addVertexWithUV( pos_x - H, pos_y - H, z + offset, ico.getMinU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( pos_x + H, pos_y - H, z + offset, ico.getMaxU(), ico.getMinV() );
|
||||
tess.addVertexWithUV( pos_x + H, pos_y + H, z + offset, ico.getMaxU(), ico.getMaxV() );
|
||||
tess.addVertexWithUV( pos_x - H, pos_y + H, z + offset, ico.getMinU(), ico.getMaxV() );
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
out = true;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.misc.TileQuartzGrowthAccelerator;
|
||||
|
||||
public class RenderBlockQuartzAccelerator extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderBlockQuartzAccelerator() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock blk, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
TileEntity te = world.getTileEntity( x, y, z );
|
||||
if ( te instanceof TileQuartzGrowthAccelerator )
|
||||
{
|
||||
if ( ((TileQuartzGrowthAccelerator) te).hasPower )
|
||||
{
|
||||
IIcon top_Bottom = ExtraBlockTextures.BlockQuartzGrowthAcceleratorOn.getIcon();
|
||||
IIcon side = ExtraBlockTextures.BlockQuartzGrowthAcceleratorSideOn.getIcon();
|
||||
blk.getRendererInstance().setTemporaryRenderIcons( top_Bottom, top_Bottom, side, side, side, side );
|
||||
}
|
||||
}
|
||||
|
||||
boolean out = super.renderInWorld( blk, world, x, y, z, renderer );
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.ModelChest;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
|
||||
public class RenderBlockSkyChest extends BaseBlockRender
|
||||
{
|
||||
|
||||
ModelChest model = new ModelChest();
|
||||
|
||||
public RenderBlockSkyChest() {
|
||||
super( true, 80 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
ResourceLocation loc;
|
||||
if ( is.getItemDamage() == 1 )
|
||||
loc = new ResourceLocation( "appliedenergistics2", "textures/models/skyblockchest.png" );
|
||||
else
|
||||
loc = new ResourceLocation( "appliedenergistics2", "textures/models/skychest.png" );
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( loc );
|
||||
|
||||
float lidangle = 0.0f;
|
||||
|
||||
GL11.glScalef( 1.0F, -1F, -1F );
|
||||
GL11.glTranslatef( -0.0F, -1.0F, -1.0F );
|
||||
|
||||
model.chestLid.offsetY = -(0.9f / 16.0f);
|
||||
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
||||
model.renderAll();
|
||||
|
||||
GL11.glDisable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock blk, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTile(AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float partialTick, RenderBlocks renderer)
|
||||
{
|
||||
if ( !(tile instanceof TileSkyChest) )
|
||||
return;
|
||||
|
||||
TileSkyChest skyChest = (TileSkyChest) tile;
|
||||
|
||||
if ( !skyChest.hasWorldObj() )
|
||||
return;
|
||||
|
||||
GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
ResourceLocation loc;
|
||||
|
||||
if ( tile.getWorldObj().getBlockMetadata( tile.xCoord, tile.yCoord, tile.zCoord ) == 1 )
|
||||
loc = new ResourceLocation( "appliedenergistics2", "textures/models/skyblockchest.png" );
|
||||
else
|
||||
loc = new ResourceLocation( "appliedenergistics2", "textures/models/skychest.png" );
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( loc );
|
||||
|
||||
this.applyTESRRotation( x, y, z, skyChest.getForward(), skyChest.getUp() );
|
||||
|
||||
GL11.glScalef( 1.0F, -1F, -1F );
|
||||
GL11.glTranslatef( -0.0F, -1.0F, -1.0F );
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
long distance = now - skyChest.lastEvent;
|
||||
|
||||
if ( skyChest.playerOpen > 0 )
|
||||
skyChest.lidAngle += distance * 0.0001;
|
||||
else
|
||||
skyChest.lidAngle -= distance * 0.0001;
|
||||
|
||||
if ( skyChest.lidAngle > 0.5f )
|
||||
skyChest.lidAngle = 0.5f;
|
||||
|
||||
if ( skyChest.lidAngle < 0.0f )
|
||||
skyChest.lidAngle = 0.0f;
|
||||
|
||||
float lidangle = skyChest.lidAngle;
|
||||
lidangle = 1.0F - lidangle;
|
||||
lidangle = 1.0F - lidangle * lidangle * lidangle;
|
||||
|
||||
model.chestLid.offsetY = -(1.01f / 16.0f);
|
||||
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
||||
model.renderAll();
|
||||
|
||||
GL11.glDisable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.model.ModelCompass;
|
||||
import appeng.hooks.CompassManager;
|
||||
import appeng.hooks.CompassResult;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileSkyCompass;
|
||||
|
||||
public class RenderBlockSkyCompass extends BaseBlockRender
|
||||
{
|
||||
|
||||
float r = 0;
|
||||
ModelCompass model = new ModelCompass();
|
||||
|
||||
public RenderBlockSkyCompass() {
|
||||
super( true, 80 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
if ( type == ItemRenderType.INVENTORY )
|
||||
{
|
||||
boolean isGood = false;
|
||||
|
||||
IInventory inv = Minecraft.getMinecraft().thePlayer.inventory;
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
if ( inv.getStackInSlot( x ) == is )
|
||||
isGood = true;
|
||||
|
||||
if ( !isGood )
|
||||
type = ItemRenderType.FIRST_PERSON_MAP;
|
||||
}
|
||||
|
||||
GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/models/compass.png" );
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( loc );
|
||||
|
||||
if ( type == ItemRenderType.ENTITY )
|
||||
{
|
||||
GL11.glRotatef( -90.0f, 0.0f, 0.0f, 1.0f );
|
||||
GL11.glScalef( 1.0F, -1F, -1F );
|
||||
GL11.glScalef( 2.5f, 2.5f, 2.5f );
|
||||
GL11.glTranslatef( -0.25F, -1.65F, -0.19F );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( type == ItemRenderType.EQUIPPED_FIRST_PERSON )
|
||||
GL11.glRotatef( 15.3f, 0.0f, 0.0f, 1.0f );
|
||||
|
||||
GL11.glScalef( 1.0F, -1F, -1F );
|
||||
GL11.glScalef( 2.5f, 2.5f, 2.5f );
|
||||
|
||||
if ( type == ItemRenderType.EQUIPPED_FIRST_PERSON )
|
||||
GL11.glTranslatef( 0.3F, -1.65F, -0.19F );
|
||||
else
|
||||
GL11.glTranslatef( 0.2F, -1.65F, -0.19F );
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
if ( type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.INVENTORY || type == ItemRenderType.EQUIPPED )
|
||||
{
|
||||
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
|
||||
float rYaw = p.rotationYaw;
|
||||
|
||||
if ( type == ItemRenderType.EQUIPPED )
|
||||
{
|
||||
p = (EntityPlayer) obj[1];
|
||||
rYaw = p.renderYawOffset;
|
||||
}
|
||||
|
||||
int x = (int) p.posX;
|
||||
int y = (int) p.posY;
|
||||
int z = (int) p.posZ;
|
||||
CompassResult cr = CompassManager.instance.getCompassDirection( 0, x, y, z );
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 3; j++)
|
||||
CompassManager.instance.getCompassDirection( 0, x + i - 1, y, z + j - 1 );
|
||||
|
||||
if ( cr.hasResult )
|
||||
{
|
||||
if ( cr.spin )
|
||||
{
|
||||
now = now % 100000;
|
||||
model.renderAll( ((float) now / 50000.0f) * (float) Math.PI * 500.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( type == ItemRenderType.EQUIPPED_FIRST_PERSON )
|
||||
{
|
||||
float offRads = rYaw / 180.0f * (float) Math.PI;
|
||||
float adjustment = (float) Math.PI * 0.74f;
|
||||
model.renderAll( (float) flipidiy( cr.rad + offRads + adjustment ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
float offRads = rYaw / 180.0f * (float) Math.PI;
|
||||
float adjustment = (float) Math.PI * -0.74f;
|
||||
model.renderAll( (float) flipidiy( cr.rad + offRads + adjustment ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
now = now % 1000000;
|
||||
model.renderAll( ((float) now / 500000.0f) * (float) Math.PI * 500.0f );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
now = now % 100000;
|
||||
model.renderAll( ((float) now / 50000.0f) * (float) Math.PI * 500.0f );
|
||||
}
|
||||
|
||||
GL11.glDisable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock blk, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTile(AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float partialTick, RenderBlocks renderer)
|
||||
{
|
||||
if ( !(tile instanceof TileSkyCompass) )
|
||||
return;
|
||||
|
||||
TileSkyCompass skyCompass = (TileSkyCompass) tile;
|
||||
|
||||
if ( !skyCompass.hasWorldObj() )
|
||||
return;
|
||||
|
||||
GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/models/compass.png" );
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( loc );
|
||||
|
||||
this.applyTESRRotation( x, y, z, skyCompass.getUp(), skyCompass.getForward() );
|
||||
|
||||
GL11.glScalef( 1.0F, -1F, -1F );
|
||||
GL11.glTranslatef( 0.5F, -1.5F, -0.5F );
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
CompassResult cr = null;
|
||||
if ( skyCompass.getForward() == ForgeDirection.UP || skyCompass.getForward() == ForgeDirection.DOWN )
|
||||
cr = CompassManager.instance.getCompassDirection( 0, tile.xCoord, tile.yCoord, tile.zCoord );
|
||||
else
|
||||
cr = new CompassResult( false, true, 0 );
|
||||
|
||||
if ( cr.hasResult )
|
||||
{
|
||||
if ( cr.spin )
|
||||
{
|
||||
now = now % 100000;
|
||||
model.renderAll( ((float) now / 50000.0f) * (float) Math.PI * 500.0f );
|
||||
}
|
||||
else
|
||||
model.renderAll( (float) (skyCompass.getForward() == ForgeDirection.DOWN ? flipidiy( cr.rad ) : cr.rad) );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
now = now % 1000000;
|
||||
model.renderAll( ((float) now / 500000.0f) * (float) Math.PI * 500.0f );
|
||||
}
|
||||
|
||||
GL11.glDisable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
}
|
||||
|
||||
private double flipidiy(double rad)
|
||||
{
|
||||
double x = Math.cos( rad );
|
||||
double y = Math.sin( rad );
|
||||
return Math.atan2( -y, x );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BlockRenderInfo;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.client.texture.OffsetIcon;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class RenderBlockWireless extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderBlockWireless() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
this.blk = blk;
|
||||
cenx = 0;
|
||||
ceny = 0;
|
||||
cenz = 0;
|
||||
hasChan = false;
|
||||
hasPower = false;
|
||||
BlockRenderInfo ri = blk.getRendererInstance();
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
IIcon r = CableBusTextures.PartMonitorSidesStatus.getIcon();
|
||||
ri.setTemporaryRenderIcons( r, r, CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), r, r );
|
||||
renderBlockBounds( renderer, 5, 5, 0, 11, 11, 1, ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
r = CableBusTextures.PartWirelessSides.getIcon();
|
||||
ri.setTemporaryRenderIcons( r, r, ExtraBlockTextures.BlockWirelessInside.getIcon(), ExtraBlockTextures.BlockWirelessInside.getIcon(), r, r );
|
||||
renderBlockBounds( renderer, 5, 5, 1, 11, 11, 2, ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
tess.startDrawingQuads();
|
||||
ri.setTemporaryRenderIcon( null );
|
||||
renderTorchAtAngle( renderer, ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH );
|
||||
super.postRenderInWorld( renderer );
|
||||
tess.draw();
|
||||
|
||||
ri.setTemporaryRenderIcons( r, r, ExtraBlockTextures.BlockWirelessInside.getIcon(), ExtraBlockTextures.BlockWirelessInside.getIcon(), r, r );
|
||||
|
||||
ForgeDirection sides[] = new ForgeDirection[] { ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.UP, ForgeDirection.DOWN };
|
||||
|
||||
int s = 1;
|
||||
|
||||
for (ForgeDirection side : sides)
|
||||
{
|
||||
renderBlockBounds( renderer, 8 + (side.offsetX != 0 ? side.offsetX * 2 : -2), 8 + (side.offsetY != 0 ? side.offsetY * 2 : -2), 2
|
||||
+ (side.offsetZ != 0 ? side.offsetZ * 2 : -1) + s, 8 + (side.offsetX != 0 ? side.offsetX * 4 : 2),
|
||||
8 + (side.offsetY != 0 ? side.offsetY * 4 : 2), 2 + (side.offsetZ != 0 ? side.offsetZ * 5 : 1) + s, ForgeDirection.EAST, ForgeDirection.UP,
|
||||
ForgeDirection.SOUTH );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
}
|
||||
|
||||
s = 3;
|
||||
for (ForgeDirection side : sides)
|
||||
{
|
||||
renderBlockBounds( renderer, 8 + (side.offsetX != 0 ? side.offsetX * 4 : -1), 8 + (side.offsetY != 0 ? side.offsetY * 4 : -1), 1
|
||||
+ (side.offsetZ != 0 ? side.offsetZ * 4 : -1) + s, 8 + (side.offsetX != 0 ? side.offsetX * 5 : 1),
|
||||
8 + (side.offsetY != 0 ? side.offsetY * 5 : 1), 2 + (side.offsetZ != 0 ? side.offsetZ * 5 : 1) + s, ForgeDirection.EAST, ForgeDirection.UP,
|
||||
ForgeDirection.SOUTH );
|
||||
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
}
|
||||
}
|
||||
|
||||
int cenx = 0;
|
||||
int ceny = 0;
|
||||
int cenz = 0;
|
||||
AEBaseBlock blk;
|
||||
boolean hasChan = false;
|
||||
boolean hasPower = false;
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock blk, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
TileWireless tw = blk.getTileEntity( world, x, y, z );
|
||||
this.blk = blk;
|
||||
if ( tw != null )
|
||||
{
|
||||
hasChan = (tw.clientFlags & (TileWireless.POWERED_FLAG | TileWireless.CHANNEL_FLAG)) == (TileWireless.POWERED_FLAG | TileWireless.CHANNEL_FLAG);
|
||||
hasPower = (tw.clientFlags & TileWireless.POWERED_FLAG) == TileWireless.POWERED_FLAG;
|
||||
|
||||
BlockRenderInfo ri = blk.getRendererInstance();
|
||||
|
||||
ForgeDirection fdy = tw.getUp();
|
||||
ForgeDirection fdz = tw.getForward();
|
||||
ForgeDirection fdx = Platform.crossProduct( fdz, fdy ).getOpposite();
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
IIcon r = CableBusTextures.PartMonitorSidesStatus.getIcon();
|
||||
ri.setTemporaryRenderIcons( r, r, CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), r, r );
|
||||
renderBlockBounds( renderer, 5, 5, 0, 11, 11, 1, fdx, fdy, fdz );
|
||||
super.renderInWorld( blk, world, x, y, z, renderer );
|
||||
|
||||
r = CableBusTextures.PartWirelessSides.getIcon();
|
||||
ri.setTemporaryRenderIcons( r, r, ExtraBlockTextures.BlockWirelessInside.getIcon(), ExtraBlockTextures.BlockWirelessInside.getIcon(), r, r );
|
||||
renderBlockBounds( renderer, 5, 5, 1, 11, 11, 2, fdx, fdy, fdz );
|
||||
super.renderInWorld( blk, world, x, y, z, renderer );
|
||||
|
||||
cenx = x;
|
||||
ceny = y;
|
||||
cenz = z;
|
||||
ri.setTemporaryRenderIcon( null );
|
||||
|
||||
renderTorchAtAngle( renderer, fdx, fdy, fdz );
|
||||
super.postRenderInWorld( renderer );
|
||||
|
||||
ri.setTemporaryRenderIcons( r, r, ExtraBlockTextures.BlockWirelessInside.getIcon(), ExtraBlockTextures.BlockWirelessInside.getIcon(), r, r );
|
||||
|
||||
ForgeDirection sides[] = new ForgeDirection[] { ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.UP, ForgeDirection.DOWN };
|
||||
|
||||
int s = 1;
|
||||
|
||||
for (ForgeDirection side : sides)
|
||||
{
|
||||
renderBlockBounds( renderer, 8 + (side.offsetX != 0 ? side.offsetX * 2 : -2), 8 + (side.offsetY != 0 ? side.offsetY * 2 : -2), 2
|
||||
+ (side.offsetZ != 0 ? side.offsetZ * 2 : -1) + s, 8 + (side.offsetX != 0 ? side.offsetX * 4 : 2),
|
||||
8 + (side.offsetY != 0 ? side.offsetY * 4 : 2), 2 + (side.offsetZ != 0 ? side.offsetZ * 5 : 1) + s, fdx, fdy, fdz );
|
||||
super.renderInWorld( blk, world, x, y, z, renderer );
|
||||
}
|
||||
|
||||
s = 3;
|
||||
for (ForgeDirection side : sides)
|
||||
{
|
||||
renderBlockBounds( renderer, 8 + (side.offsetX != 0 ? side.offsetX * 4 : -1), 8 + (side.offsetY != 0 ? side.offsetY * 4 : -1), 1
|
||||
+ (side.offsetZ != 0 ? side.offsetZ * 4 : -1) + s, 8 + (side.offsetX != 0 ? side.offsetX * 5 : 1),
|
||||
8 + (side.offsetY != 0 ? side.offsetY * 5 : 1), 2 + (side.offsetZ != 0 ? side.offsetZ * 5 : 1) + s, fdx, fdy, fdz );
|
||||
super.renderInWorld( blk, world, x, y, z, renderer );
|
||||
}
|
||||
|
||||
r = CableBusTextures.PartMonitorSidesStatusLights.getIcon();
|
||||
// ri.setTemporaryRenderIcons( r, r, ExtraTextures.BlockChargerInside.getIcon(),
|
||||
// ExtraTextures.BlockChargerInside.getIcon(), r, r );
|
||||
renderBlockBounds( renderer, 5, 5, 0, 11, 11, 1, fdx, fdy, fdz );
|
||||
|
||||
if ( hasChan )
|
||||
{
|
||||
int l = 14;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
Tessellator.instance.setColorOpaque_I( AEColor.Transparent.blackVariant );
|
||||
}
|
||||
else if ( hasPower )
|
||||
{
|
||||
int l = 9;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
Tessellator.instance.setColorOpaque_I( AEColor.Transparent.whiteVariant );
|
||||
}
|
||||
else
|
||||
{
|
||||
Tessellator.instance.setBrightness( 0 );
|
||||
Tessellator.instance.setColorOpaque_I( 0x000000 );
|
||||
}
|
||||
|
||||
if ( ForgeDirection.UP != fdz.getOpposite() )
|
||||
super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.UP );
|
||||
if ( ForgeDirection.DOWN != fdz.getOpposite() )
|
||||
super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.DOWN );
|
||||
if ( ForgeDirection.EAST != fdz.getOpposite() )
|
||||
super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.EAST );
|
||||
if ( ForgeDirection.WEST != fdz.getOpposite() )
|
||||
super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.WEST );
|
||||
if ( ForgeDirection.SOUTH != fdz.getOpposite() )
|
||||
super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.SOUTH );
|
||||
if ( ForgeDirection.NORTH != fdz.getOpposite() )
|
||||
super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.NORTH );
|
||||
|
||||
ri.setTemporaryRenderIcon( null );
|
||||
renderer.renderAllFaces = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void renderTorchAtAngle(RenderBlocks renderer, ForgeDirection x, ForgeDirection y, ForgeDirection z)
|
||||
{
|
||||
IIcon r = (hasChan ? CableBusTextures.BlockWirelessOn.getIcon() : blk.getIcon( 0, 0 ));
|
||||
IIcon sides = new OffsetIcon( r, 0.0f, -2.0f );
|
||||
|
||||
switch (z)
|
||||
{
|
||||
case DOWN:
|
||||
renderer.uvRotateNorth = 3;
|
||||
renderer.uvRotateSouth = 3;
|
||||
renderer.uvRotateEast = 3;
|
||||
renderer.uvRotateWest = 3;
|
||||
break;
|
||||
case EAST:
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 2;
|
||||
renderer.uvRotateEast = 2;
|
||||
renderer.uvRotateWest = 1;
|
||||
break;
|
||||
case NORTH:
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateNorth = 2;
|
||||
renderer.uvRotateSouth = 1;
|
||||
break;
|
||||
case SOUTH:
|
||||
renderer.uvRotateTop = 3;
|
||||
renderer.uvRotateBottom = 3;
|
||||
renderer.uvRotateNorth = 1;
|
||||
renderer.uvRotateSouth = 2;
|
||||
break;
|
||||
case WEST:
|
||||
renderer.uvRotateTop = 2;
|
||||
renderer.uvRotateBottom = 1;
|
||||
renderer.uvRotateEast = 1;
|
||||
renderer.uvRotateWest = 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( 0xffffff );
|
||||
renderBlockBounds( renderer, 0, 7, 1, 16, 9, 16, x, y, z );
|
||||
renderFace( cenx, ceny, cenz, blk, sides, renderer, y );
|
||||
renderFace( cenx, ceny, cenz, blk, sides, renderer, y.getOpposite() );
|
||||
|
||||
renderBlockBounds( renderer, 7, 0, 1, 9, 16, 16, x, y, z );
|
||||
renderFace( cenx, ceny, cenz, blk, sides, renderer, x );
|
||||
renderFace( cenx, ceny, cenz, blk, sides, renderer, x.getOpposite() );
|
||||
|
||||
renderBlockBounds( renderer, 7, 7, 1, 9, 9, 10.6, x, y, z );
|
||||
renderFace( cenx, ceny, cenz, blk, r, renderer, z );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class RenderDrive extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderDrive() {
|
||||
super( false, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
renderer.overrideBlockTexture = ExtraBlockTextures.getMissing();
|
||||
this.renderInvBlock( EnumSet.of( ForgeDirection.SOUTH ), block, is, Tessellator.instance, 0x000000, renderer );
|
||||
|
||||
renderer.overrideBlockTexture = null;
|
||||
super.renderInventory( block, is, renderer, type, obj );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
TileDrive sp = imb.getTileEntity( world, x, y, z );
|
||||
renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
ForgeDirection up = sp.getUp();
|
||||
ForgeDirection forward = sp.getForward();
|
||||
ForgeDirection west = Platform.crossProduct( forward, up );
|
||||
|
||||
boolean result = super.renderInWorld( imb, world, x, y, z, renderer );
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
IIcon ico = ExtraBlockTextures.MEStorageCellTextures.getIcon();
|
||||
|
||||
int b = world.getLightBrightnessForSkyBlocks( x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ, 0 );
|
||||
|
||||
for (int yy = 0; yy < 5; yy++)
|
||||
{
|
||||
for (int xx = 0; xx < 2; xx++)
|
||||
{
|
||||
int stat = sp.getCellStatus( yy * 2 + (1 - xx) );
|
||||
selectFace( renderer, west, up, forward, 2 + xx * 7, 7 + xx * 7, 1 + yy * 3, 3 + yy * 3 );
|
||||
|
||||
int spin = 0;
|
||||
|
||||
switch (forward.offsetX + forward.offsetY * 2 + forward.offsetZ * 3)
|
||||
{
|
||||
case 1:
|
||||
switch (up)
|
||||
{
|
||||
case UP:
|
||||
spin = 3;
|
||||
break;
|
||||
case DOWN:
|
||||
spin = 1;
|
||||
break;
|
||||
case NORTH:
|
||||
spin = 0;
|
||||
break;
|
||||
case SOUTH:
|
||||
spin = 2;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
break;
|
||||
case -1:
|
||||
switch (up)
|
||||
{
|
||||
case UP:
|
||||
spin = 1;
|
||||
break;
|
||||
case DOWN:
|
||||
spin = 3;
|
||||
break;
|
||||
case NORTH:
|
||||
spin = 0;
|
||||
break;
|
||||
case SOUTH:
|
||||
spin = 2;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
break;
|
||||
case -2:
|
||||
switch (up)
|
||||
{
|
||||
case EAST:
|
||||
spin = 1;
|
||||
break;
|
||||
case WEST:
|
||||
spin = 3;
|
||||
break;
|
||||
case NORTH:
|
||||
spin = 2;
|
||||
break;
|
||||
case SOUTH:
|
||||
spin = 0;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (up)
|
||||
{
|
||||
case EAST:
|
||||
spin = 1;
|
||||
break;
|
||||
case WEST:
|
||||
spin = 3;
|
||||
break;
|
||||
case NORTH:
|
||||
spin = 0;
|
||||
break;
|
||||
case SOUTH:
|
||||
spin = 0;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch (up)
|
||||
{
|
||||
case UP:
|
||||
spin = 2;
|
||||
break;
|
||||
case DOWN:
|
||||
spin = 0;
|
||||
break;
|
||||
case EAST:
|
||||
spin = 3;
|
||||
break;
|
||||
case WEST:
|
||||
spin = 1;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
break;
|
||||
case -3:
|
||||
switch (up)
|
||||
{
|
||||
case UP:
|
||||
spin = 2;
|
||||
break;
|
||||
case DOWN:
|
||||
spin = 0;
|
||||
break;
|
||||
case EAST:
|
||||
spin = 1;
|
||||
break;
|
||||
case WEST:
|
||||
spin = 3;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
double u1 = ico.getInterpolatedU( (spin % 4 < 2) ? 1 : 6 );
|
||||
double u2 = ico.getInterpolatedU( ((spin + 1) % 4 < 2) ? 1 : 6 );
|
||||
double u3 = ico.getInterpolatedU( ((spin + 2) % 4 < 2) ? 1 : 6 );
|
||||
double u4 = ico.getInterpolatedU( ((spin + 3) % 4 < 2) ? 1 : 6 );
|
||||
|
||||
int m = 1;
|
||||
int mx = 3;
|
||||
if ( stat == 0 )
|
||||
{
|
||||
m = 4;
|
||||
mx = 5;
|
||||
}
|
||||
|
||||
double v1 = ico.getInterpolatedV( ((spin + 1) % 4 < 2) ? m : mx );
|
||||
double v2 = ico.getInterpolatedV( ((spin + 2) % 4 < 2) ? m : mx );
|
||||
double v3 = ico.getInterpolatedV( ((spin + 3) % 4 < 2) ? m : mx );
|
||||
double v4 = ico.getInterpolatedV( ((spin + 0) % 4 < 2) ? m : mx );
|
||||
|
||||
tess.setBrightness( b );
|
||||
tess.setColorOpaque_I( 0xffffff );
|
||||
switch (forward.offsetX + forward.offsetY * 2 + forward.offsetZ * 3)
|
||||
{
|
||||
case 1:
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMinZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMinZ, u4, v4 );
|
||||
break;
|
||||
case -1:
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMinZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMinZ, u4, v4 );
|
||||
break;
|
||||
case -2:
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMinZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMinZ, u4, v4 );
|
||||
break;
|
||||
case 2:
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMinZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMinZ, u4, v4 );
|
||||
break;
|
||||
case 3:
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMaxZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMinY, z + renderer.renderMaxZ, u4, v4 );
|
||||
break;
|
||||
case -3:
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMinY, z + renderer.renderMaxZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMaxZ, u4, v4 );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( (forward == ForgeDirection.UP && up == ForgeDirection.SOUTH) || forward == ForgeDirection.DOWN )
|
||||
selectFace( renderer, west, up, forward, 3 + xx * 7, 4 + xx * 7, 1 + yy * 3, 2 + yy * 3 );
|
||||
else
|
||||
selectFace( renderer, west, up, forward, 5 + xx * 7, 6 + xx * 7, 2 + yy * 3, 3 + yy * 3 );
|
||||
|
||||
if ( stat != 0 )
|
||||
{
|
||||
IIcon wico = ExtraBlockTextures.White.getIcon();
|
||||
u1 = wico.getInterpolatedU( (spin % 4 < 2) ? 1 : 6 );
|
||||
u2 = wico.getInterpolatedU( ((spin + 1) % 4 < 2) ? 1 : 6 );
|
||||
u3 = wico.getInterpolatedU( ((spin + 2) % 4 < 2) ? 1 : 6 );
|
||||
u4 = wico.getInterpolatedU( ((spin + 3) % 4 < 2) ? 1 : 6 );
|
||||
|
||||
v1 = wico.getInterpolatedV( ((spin + 1) % 4 < 2) ? 1 : 3 );
|
||||
v2 = wico.getInterpolatedV( ((spin + 2) % 4 < 2) ? 1 : 3 );
|
||||
v3 = wico.getInterpolatedV( ((spin + 3) % 4 < 2) ? 1 : 3 );
|
||||
v4 = wico.getInterpolatedV( ((spin + 0) % 4 < 2) ? 1 : 3 );
|
||||
|
||||
if ( sp.isPowered() )
|
||||
tess.setBrightness( 15 << 20 | 15 << 4 );
|
||||
else
|
||||
tess.setBrightness( 0 );
|
||||
|
||||
if ( stat == 1 )
|
||||
Tessellator.instance.setColorOpaque_I( 0x00ff00 );
|
||||
if ( stat == 2 )
|
||||
Tessellator.instance.setColorOpaque_I( 0xffaa00 );
|
||||
if ( stat == 3 )
|
||||
Tessellator.instance.setColorOpaque_I( 0xff0000 );
|
||||
|
||||
switch (forward.offsetX + forward.offsetY * 2 + forward.offsetZ * 3)
|
||||
{
|
||||
case 1:
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMinZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMinZ, u4, v4 );
|
||||
break;
|
||||
case -1:
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMinZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMinZ, u4, v4 );
|
||||
break;
|
||||
case -2:
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMinZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMinZ, u4, v4 );
|
||||
break;
|
||||
case 2:
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMinZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMinZ, u4, v4 );
|
||||
break;
|
||||
case 3:
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMaxZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMinY, z + renderer.renderMaxZ, u4, v4 );
|
||||
break;
|
||||
case -3:
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMinY, z + renderer.renderMaxZ, u1, v1 );
|
||||
tess.addVertexWithUV( x + renderer.renderMinX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u2, v2 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMaxY, z + renderer.renderMaxZ, u3, v3 );
|
||||
tess.addVertexWithUV( x + renderer.renderMaxX, y + renderer.renderMinY, z + renderer.renderMaxZ, u4, v4 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderer.overrideBlockTexture = null;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.client.texture.FlippableIcon;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.client.texture.OffsetIcon;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class RenderMEChest extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderMEChest() {
|
||||
super( false, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
Tessellator.instance.setBrightness( 0 );
|
||||
renderer.overrideBlockTexture = ExtraBlockTextures.getMissing();
|
||||
this.renderInvBlock( EnumSet.of( ForgeDirection.SOUTH ), block, is, Tessellator.instance, 0x000000, renderer );
|
||||
|
||||
renderer.overrideBlockTexture = ExtraBlockTextures.MEChest.getIcon();
|
||||
this.renderInvBlock( EnumSet.of( ForgeDirection.UP ), block, is, Tessellator.instance, adjustBrightness( AEColor.Transparent.whiteVariant, 0.7 ),
|
||||
renderer );
|
||||
|
||||
renderer.overrideBlockTexture = null;
|
||||
super.renderInventory( block, is, renderer, type, obj );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
TileChest sp = imb.getTileEntity( world, x, y, z );
|
||||
renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
ForgeDirection up = sp.getUp();
|
||||
ForgeDirection forward = sp.getForward();
|
||||
ForgeDirection west = Platform.crossProduct( forward, up );
|
||||
|
||||
preRenderInWorld( imb, world, x, y, z, renderer );
|
||||
|
||||
int stat = sp.getCellStatus( 0 );
|
||||
boolean result = renderer.renderStandardBlock( imb, x, y, z );
|
||||
|
||||
selectFace( renderer, west, up, forward, 5, 16 - 5, 9, 12 );
|
||||
|
||||
int offsetU = -4;
|
||||
int offsetV = 8;
|
||||
if ( stat == 0 )
|
||||
offsetV = 3;
|
||||
|
||||
int b = world.getLightBrightnessForSkyBlocks( x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ, 0 );
|
||||
Tessellator.instance.setBrightness( b );
|
||||
Tessellator.instance.setColorOpaque_I( 0xffffff );
|
||||
|
||||
FlippableIcon fico = new FlippableIcon( new OffsetIcon( ExtraBlockTextures.MEStorageCellTextures.getIcon(), offsetU, offsetV ) );
|
||||
if ( forward == ForgeDirection.EAST && (up == ForgeDirection.NORTH || up == ForgeDirection.SOUTH) )
|
||||
fico.setFlip( true, false );
|
||||
else if ( forward == ForgeDirection.NORTH && up == ForgeDirection.EAST )
|
||||
fico.setFlip( false, true );
|
||||
else if ( forward == ForgeDirection.NORTH && up == ForgeDirection.WEST )
|
||||
fico.setFlip( true, false );
|
||||
else if ( forward == ForgeDirection.DOWN && up == ForgeDirection.EAST )
|
||||
fico.setFlip( false, true );
|
||||
else if ( forward == ForgeDirection.DOWN )
|
||||
fico.setFlip( true, false );
|
||||
|
||||
/*
|
||||
* 1.7.2
|
||||
*
|
||||
* else if ( forward == ForgeDirection.EAST && up == ForgeDirection.UP ) fico.setFlip( true, false ); else if (
|
||||
* forward == ForgeDirection.NORTH && up == ForgeDirection.UP ) fico.setFlip( true, false );
|
||||
*/
|
||||
|
||||
renderFace( x, y, z, imb, fico, renderer, forward );
|
||||
|
||||
if ( stat != 0 )
|
||||
{
|
||||
b = 0;
|
||||
if ( sp.isPowered() )
|
||||
{
|
||||
b = 15 << 20 | 15 << 4;
|
||||
}
|
||||
|
||||
Tessellator.instance.setBrightness( b );
|
||||
if ( stat == 1 )
|
||||
Tessellator.instance.setColorOpaque_I( 0x00ff00 );
|
||||
if ( stat == 2 )
|
||||
Tessellator.instance.setColorOpaque_I( 0xffaa00 );
|
||||
if ( stat == 3 )
|
||||
Tessellator.instance.setColorOpaque_I( 0xff0000 );
|
||||
selectFace( renderer, west, up, forward, 9, 10, 11, 12 );
|
||||
renderFace( x, y, z, imb, ExtraBlockTextures.White.getIcon(), renderer, forward );
|
||||
}
|
||||
|
||||
b = world.getLightBrightnessForSkyBlocks( x + up.offsetX, y + up.offsetY, z + up.offsetZ, 0 );
|
||||
if ( sp.isPowered() )
|
||||
{
|
||||
b = 15 << 20 | 15 << 4;
|
||||
}
|
||||
|
||||
Tessellator.instance.setBrightness( b );
|
||||
Tessellator.instance.setColorOpaque_I( 0xffffff );
|
||||
renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
ICellHandler ch = AEApi.instance().registries().cell().getHandler( sp.getStorageType() );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( sp.getColor().whiteVariant );
|
||||
IIcon ico = ch == null ? null : ch.getTopTexture_Light();
|
||||
renderFace( x, y, z, imb, ico == null ? ExtraBlockTextures.MEChest.getIcon() : ico, renderer, up );
|
||||
|
||||
if ( ico != null )
|
||||
{
|
||||
Tessellator.instance.setColorOpaque_I( sp.getColor().mediumVariant );
|
||||
ico = ch == null ? null : ch.getTopTexture_Medium();
|
||||
renderFace( x, y, z, imb, ico == null ? ExtraBlockTextures.MEChest.getIcon() : ico, renderer, up );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( sp.getColor().blackVariant );
|
||||
ico = ch == null ? null : ch.getTopTexture_Dark();
|
||||
renderFace( x, y, z, imb, ico == null ? ExtraBlockTextures.MEChest.getIcon() : ico, renderer, up );
|
||||
}
|
||||
|
||||
renderer.overrideBlockTexture = null;
|
||||
postRenderInWorld( renderer );
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
|
||||
public class RenderNull extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderNull() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
|
||||
public class RenderQNB extends BaseBlockRender
|
||||
{
|
||||
|
||||
public void renderCableAt(double Thickness, IBlockAccess world, int x, int y, int z, AEBaseBlock block, RenderBlocks renderer, IIcon texture, double pull,
|
||||
EnumSet<ForgeDirection> connections)
|
||||
{
|
||||
block.getRendererInstance().setTemporaryRenderIcon( texture );
|
||||
|
||||
if ( connections.contains( ForgeDirection.UNKNOWN ) )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D - Thickness, 0.5D - Thickness, 0.5D - Thickness, 0.5D + Thickness, 0.5D + Thickness, 0.5D + Thickness );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
if ( connections.contains( ForgeDirection.WEST ) )
|
||||
{
|
||||
renderer.setRenderBounds( 0.0D, 0.5D - Thickness, 0.5D - Thickness, 0.5D - Thickness - pull, 0.5D + Thickness, 0.5D + Thickness );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
if ( connections.contains( ForgeDirection.EAST ) )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D + Thickness + pull, 0.5D - Thickness, 0.5D - Thickness, 1.0D, 0.5D + Thickness, 0.5D + Thickness );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
if ( connections.contains( ForgeDirection.NORTH ) )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D - Thickness, 0.5D - Thickness, 0.0D, 0.5D + Thickness, 0.5D + Thickness, 0.5D - Thickness - pull );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
if ( connections.contains( ForgeDirection.SOUTH ) )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D - Thickness, 0.5D - Thickness, 0.5D + Thickness + pull, 0.5D + Thickness, 0.5D + Thickness, 1.0D );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
if ( connections.contains( ForgeDirection.DOWN ) )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D - Thickness, 0.0D, 0.5D - Thickness, 0.5D + Thickness, 0.5D - Thickness - pull, 0.5D + Thickness );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
if ( connections.contains( ForgeDirection.UP ) )
|
||||
{
|
||||
renderer.setRenderBounds( 0.5D - Thickness, 0.5D + Thickness + pull, 0.5D - Thickness, 0.5D + Thickness, 1.0D, 0.5D + Thickness );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
block.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
float px = 2.0f / 16.0f;
|
||||
float maxpx = 14.0f / 16.0f;
|
||||
renderer.setRenderBounds( px, px, px, maxpx, maxpx, maxpx );
|
||||
|
||||
super.renderInventory( block, item, renderer, type, obj );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
TileQuantumBridge tqb = block.getTileEntity( world, x, y, z );
|
||||
if ( tqb == null )
|
||||
return false;
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
if ( tqb.getBlockType() == AEApi.instance().blocks().blockQuantumLink.block() )
|
||||
{
|
||||
if ( tqb.isFormed() )
|
||||
{
|
||||
AEColoredItemDefinition cabldef = AEApi.instance().parts().partCableGlass;
|
||||
Item cable = cabldef.item( AEColor.Transparent );
|
||||
|
||||
AEColoredItemDefinition ccabldef = AEApi.instance().parts().partCableCovered;
|
||||
Item ccable = ccabldef.item( AEColor.Transparent );
|
||||
|
||||
EnumSet<ForgeDirection> sides = tqb.getConnections();
|
||||
renderCableAt( 0.11D, world, x, y, z, block, renderer, cable.getIconIndex( cabldef.stack( AEColor.Transparent, 1 ) ), 0.141D, sides );
|
||||
renderCableAt( 0.188D, world, x, y, z, block, renderer, ccable.getIconIndex( ccabldef.stack( AEColor.Transparent, 1 ) ), 0.1875D, sides );
|
||||
}
|
||||
|
||||
float px = 2.0f / 16.0f;
|
||||
float maxpx = 14.0f / 16.0f;
|
||||
renderer.setRenderBounds( px, px, px, maxpx, maxpx, maxpx );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
// super.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !tqb.isFormed() )
|
||||
{
|
||||
float px = 2.0f / 16.0f;
|
||||
float maxpx = 14.0f / 16.0f;
|
||||
renderer.setRenderBounds( px, px, px, maxpx, maxpx, maxpx );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
else if ( tqb.isCorner() )
|
||||
{
|
||||
// renderCableAt(0.11D, world, x, y, z, block, modelId,
|
||||
// renderer,
|
||||
// AppEngTextureRegistry.Blocks.MECable.get(), true, 0.0D);
|
||||
AEColoredItemDefinition ccabldef = AEApi.instance().parts().partCableCovered;
|
||||
Item ccable = ccabldef.item( AEColor.Transparent );
|
||||
|
||||
renderCableAt( 0.188D, world, x, y, z, block, renderer, ccable.getIconIndex( ccabldef.stack( AEColor.Transparent, 1 ) ), 0.05D,
|
||||
tqb.getConnections() );
|
||||
|
||||
float px = 4.0f / 16.0f;
|
||||
float maxpx = 12.0f / 16.0f;
|
||||
|
||||
renderer.setRenderBounds( px, px, px, maxpx, maxpx, maxpx );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
|
||||
if ( tqb.isPowered() )
|
||||
{
|
||||
|
||||
px = 3.9f / 16.0f;
|
||||
maxpx = 12.1f / 16.0f;
|
||||
renderer.setRenderBounds( px, px, px, maxpx, maxpx, maxpx );
|
||||
|
||||
int bn = 15;
|
||||
Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
||||
Tessellator.instance.setBrightness( bn << 20 | bn << 4 );
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingCornerLight.getIcon(), renderer, side );
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float px = 2.0f / 16.0f;
|
||||
float maxpx = 14.0f / 16.0f;
|
||||
renderer.setRenderBounds( 0, px, px, 1, maxpx, maxpx );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
|
||||
renderer.setRenderBounds( px, 0, px, maxpx, 1, maxpx );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
|
||||
renderer.setRenderBounds( px, px, 0, maxpx, maxpx, 1 );
|
||||
renderer.renderStandardBlock( block, x, y, z );
|
||||
|
||||
if ( tqb.isPowered() )
|
||||
{
|
||||
px = -0.01f / 16.0f;
|
||||
maxpx = 16.01f / 16.0f;
|
||||
renderer.setRenderBounds( px, px, px, maxpx, maxpx, maxpx );
|
||||
|
||||
int bn = 15;
|
||||
Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
||||
Tessellator.instance.setBrightness( bn << 20 | bn << 4 );
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingEdgeLight.getIcon(), renderer, side );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.client.texture.OffsetIcon;
|
||||
|
||||
public class RenderQuartzGlass extends BaseBlockRender
|
||||
{
|
||||
|
||||
static byte offsets[][][];
|
||||
|
||||
public RenderQuartzGlass() {
|
||||
super( false, 0 );
|
||||
if ( offsets == null )
|
||||
{
|
||||
Random r = new Random( 924 );
|
||||
offsets = new byte[10][10][10];
|
||||
for (int x = 0; x < 10; x++)
|
||||
for (int y = 0; y < 10; y++)
|
||||
r.nextBytes( offsets[x][y] );
|
||||
}
|
||||
}
|
||||
|
||||
boolean isFlush(AEBaseBlock imb, IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return isGlass( imb, world, x, y, z );
|
||||
}
|
||||
|
||||
boolean isGlass(AEBaseBlock imb, IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return world.getBlock( x, y, z ) == AEApi.instance().blocks().blockQuartzGlass.block()
|
||||
|| world.getBlock( x, y, z ) == AEApi.instance().blocks().blockQuartzVibrantGlass.block();
|
||||
}
|
||||
|
||||
void renderEdge(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer, ForgeDirection side, ForgeDirection direction)
|
||||
{
|
||||
if ( !isFlush( imb, world, x + side.offsetX, y + side.offsetY, z + side.offsetZ ) )
|
||||
{
|
||||
if ( !isFlush( imb, world, x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ ) )
|
||||
{
|
||||
float minX = 0.5f + (side.offsetX + direction.offsetX) / 2.0f;
|
||||
float minY = 0.5f + (side.offsetY + direction.offsetY) / 2.0f;
|
||||
float minZ = 0.5f + (side.offsetZ + direction.offsetZ) / 2.0f;
|
||||
float maxX = 0.5f + (side.offsetX + direction.offsetX) / 2.0f;
|
||||
float maxY = 0.5f + (side.offsetY + direction.offsetY) / 2.0f;
|
||||
float maxZ = 0.5f + (side.offsetZ + direction.offsetZ) / 2.0f;
|
||||
|
||||
if ( 0 == side.offsetX && 0 == direction.offsetX )
|
||||
{
|
||||
minX = 0.0f;
|
||||
maxX = 1.0f;
|
||||
}
|
||||
if ( 0 == side.offsetY && 0 == direction.offsetY )
|
||||
{
|
||||
minY = 0.0f;
|
||||
maxY = 1.0f;
|
||||
}
|
||||
if ( 0 == side.offsetZ && 0 == direction.offsetZ )
|
||||
{
|
||||
minZ = 0.0f;
|
||||
maxZ = 1.0f;
|
||||
}
|
||||
|
||||
if ( maxX <= 0.001f )
|
||||
maxX += 0.9f / 16.0f;
|
||||
if ( maxY <= 0.001f )
|
||||
maxY += 0.9f / 16.0f;
|
||||
if ( maxZ <= 0.001f )
|
||||
maxZ += 0.9f / 16.0f;
|
||||
|
||||
if ( minX >= 0.999f )
|
||||
minX -= 0.9f / 16.0f;
|
||||
if ( minY >= 0.999f )
|
||||
minY -= 0.9f / 16.0f;
|
||||
if ( minZ >= 0.999f )
|
||||
minZ -= 0.9f / 16.0f;
|
||||
|
||||
renderer.setRenderBounds( minX, minY, minZ, maxX, maxY, maxZ );
|
||||
|
||||
switch (side)
|
||||
{
|
||||
case WEST:
|
||||
renderer.renderFaceXNeg( imb, x, y, z, ExtraBlockTextures.GlassFrame.getIcon() );
|
||||
break;
|
||||
case EAST:
|
||||
renderer.renderFaceXPos( imb, x, y, z, ExtraBlockTextures.GlassFrame.getIcon() );
|
||||
break;
|
||||
case NORTH:
|
||||
renderer.renderFaceZNeg( imb, x, y, z, ExtraBlockTextures.GlassFrame.getIcon() );
|
||||
break;
|
||||
case SOUTH:
|
||||
renderer.renderFaceZPos( imb, x, y, z, ExtraBlockTextures.GlassFrame.getIcon() );
|
||||
break;
|
||||
case DOWN:
|
||||
renderer.renderFaceYNeg( imb, x, y, z, ExtraBlockTextures.GlassFrame.getIcon() );
|
||||
break;
|
||||
case UP:
|
||||
renderer.renderFaceYPos( imb, x, y, z, ExtraBlockTextures.GlassFrame.getIcon() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
renderer.overrideBlockTexture = ExtraBlockTextures.GlassFrame.getIcon();
|
||||
super.renderInventory( block, is, renderer, type, obj );
|
||||
renderer.overrideBlockTexture = null;
|
||||
super.renderInventory( block, is, renderer, type, obj );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
int cx = Math.abs( x % 10 );
|
||||
int cy = Math.abs( y % 10 );
|
||||
int cz = Math.abs( z % 10 );
|
||||
|
||||
int u = offsets[cx][cy][cz] % 4;
|
||||
int v = offsets[9 - cx][9 - cy][9 - cz] % 4;
|
||||
|
||||
switch (Math.abs( (offsets[cx][cy][cz] + (x + y + z)) % 4 ))
|
||||
{
|
||||
case 0:
|
||||
renderer.overrideBlockTexture = new OffsetIcon( imb.getIcon( 0, 0 ), u / 2, v / 2 );
|
||||
break;
|
||||
case 1:
|
||||
renderer.overrideBlockTexture = new OffsetIcon( ExtraBlockTextures.BlockQuartzGlassB.getIcon(), u / 2, v / 2 );
|
||||
break;
|
||||
case 2:
|
||||
renderer.overrideBlockTexture = new OffsetIcon( ExtraBlockTextures.BlockQuartzGlassC.getIcon(), u, v );
|
||||
break;
|
||||
case 3:
|
||||
renderer.overrideBlockTexture = new OffsetIcon( ExtraBlockTextures.BlockQuartzGlassD.getIcon(), u, v );
|
||||
break;
|
||||
}
|
||||
|
||||
boolean result = renderer.renderStandardBlock( imb, x, y, z );
|
||||
|
||||
renderer.overrideBlockTexture = null;
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.UP, ForgeDirection.EAST );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.UP, ForgeDirection.WEST );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.UP, ForgeDirection.NORTH );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.UP, ForgeDirection.SOUTH );
|
||||
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.DOWN, ForgeDirection.EAST );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.DOWN, ForgeDirection.WEST );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.DOWN, ForgeDirection.NORTH );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.DOWN, ForgeDirection.SOUTH );
|
||||
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.EAST, ForgeDirection.UP );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.EAST, ForgeDirection.DOWN );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.EAST, ForgeDirection.NORTH );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.EAST, ForgeDirection.SOUTH );
|
||||
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.WEST, ForgeDirection.UP );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.WEST, ForgeDirection.DOWN );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.WEST, ForgeDirection.NORTH );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.WEST, ForgeDirection.SOUTH );
|
||||
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.NORTH, ForgeDirection.EAST );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.NORTH, ForgeDirection.WEST );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.NORTH, ForgeDirection.UP );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.NORTH, ForgeDirection.DOWN );
|
||||
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.SOUTH, ForgeDirection.EAST );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.SOUTH, ForgeDirection.WEST );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.SOUTH, ForgeDirection.UP );
|
||||
renderEdge( imb, world, x, y, z, renderer, ForgeDirection.SOUTH, ForgeDirection.DOWN );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.solids.OreQuartz;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
|
||||
public class RenderQuartzOre extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderQuartzOre() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
super.renderInventory( blk, is, renderer, type, obj );
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.OreQuartzStone.getIcon() );
|
||||
super.renderInventory( blk, is, renderer, type, obj );
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
OreQuartz blk = (OreQuartz) block;
|
||||
blk.enhanceBrightness = true;
|
||||
super.renderInWorld( block, world, x, y, z, renderer );
|
||||
blk.enhanceBrightness = false;
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.OreQuartzStone.getIcon() );
|
||||
boolean out = super.renderInWorld( block, world, x, y, z, renderer );
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.misc.BlockQuartzTorch;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
|
||||
public class RenderQuartzTorch extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderQuartzTorch() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
float Point2 = 6.0f / 16.0f;
|
||||
float Point3 = 7.0f / 16.0f;
|
||||
float Point13 = 10.0f / 16.0f;
|
||||
float Point12 = 9.0f / 16.0f;
|
||||
|
||||
float Onepx = 1.0f / 16.0f;
|
||||
float rbottom = 5.0f / 16.0f;
|
||||
float rtop = 10.0f / 16.0f;
|
||||
|
||||
float bottom = 7.0f / 16.0f;
|
||||
float top = 8.0f / 16.0f;
|
||||
|
||||
float xOff = 0.0f;
|
||||
float yOff = 0.0f;
|
||||
float zOff = 0.0f;
|
||||
|
||||
renderer.setRenderBounds( Point3 + xOff, rbottom + yOff, Point3 + zOff, Point12 + xOff, rtop + yOff, Point12 + zOff );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
renderer.setRenderBounds( Point3 + xOff, rtop + yOff, Point3 + zOff, Point3 + Onepx + xOff, rtop + Onepx + yOff, Point3 + Onepx + zOff );
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
renderer.setRenderBounds( Point12 - Onepx + xOff, rbottom - Onepx + yOff, Point12 - Onepx + zOff, Point12 + xOff, rbottom + yOff, Point12 + zOff );
|
||||
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( Blocks.hopper.getIcon( 0, 0 ) );
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
renderer.setRenderBounds( Point2 + xOff, bottom + yOff, Point2 + zOff, Point13 + xOff, top + yOff, Point3 + zOff );
|
||||
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
renderer.setRenderBounds( Point2 + xOff, bottom + yOff, Point12 + zOff, Point13 + xOff, top + yOff, Point13 + zOff );
|
||||
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
renderer.setRenderBounds( Point2 + xOff, bottom + yOff, Point3 + zOff, Point3 + xOff, top + yOff, Point12 + zOff );
|
||||
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
renderer.setRenderBounds( Point12 + xOff, bottom + yOff, Point3 + zOff, Point13 + xOff, top + yOff, Point12 + zOff );
|
||||
|
||||
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
BlockQuartzTorch blk = (BlockQuartzTorch) block;
|
||||
|
||||
IOrientable te = ((IOrientableBlock) block).getOrientable( world, x, y, z );
|
||||
|
||||
float Point2 = 6.0f / 16.0f;
|
||||
float Point3 = 7.0f / 16.0f;
|
||||
float Point13 = 10.0f / 16.0f;
|
||||
float Point12 = 9.0f / 16.0f;
|
||||
|
||||
float Onepx = 1.0f / 16.0f;
|
||||
float rbottom = 5.0f / 16.0f;
|
||||
float rtop = 10.0f / 16.0f;
|
||||
|
||||
float bottom = 7.0f / 16.0f;
|
||||
float top = 8.0f / 16.0f;
|
||||
|
||||
float xOff = 0.0f;
|
||||
float yOff = 0.0f;
|
||||
float zOff = 0.0f;
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
if ( te != null )
|
||||
{
|
||||
ForgeDirection forward = te.getUp();
|
||||
xOff = forward.offsetX * -(4.0f / 16.0f);
|
||||
yOff = forward.offsetY * -(4.0f / 16.0f);
|
||||
zOff = forward.offsetZ * -(4.0f / 16.0f);
|
||||
}
|
||||
|
||||
renderer.setRenderBounds( Point3 + xOff, rbottom + yOff, Point3 + zOff, Point12 + xOff, rtop + yOff, Point12 + zOff );
|
||||
super.renderInWorld( block, world, x, y, z, renderer );
|
||||
|
||||
int r = (x + y + z) % 2;
|
||||
if ( r == 0 )
|
||||
{
|
||||
renderer.setRenderBounds( Point3 + xOff, rtop + yOff, Point3 + zOff, Point3 + Onepx + xOff, rtop + Onepx + yOff, Point3 + Onepx + zOff );
|
||||
super.renderInWorld( block, world, x, y, z, renderer );
|
||||
|
||||
renderer.setRenderBounds( Point12 - Onepx + xOff, rbottom - Onepx + yOff, Point12 - Onepx + zOff, Point12 + xOff, rbottom + yOff, Point12 + zOff );
|
||||
super.renderInWorld( block, world, x, y, z, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.setRenderBounds( Point3 + xOff, rbottom - Onepx + yOff, Point3 + zOff, Point3 + Onepx + xOff, rbottom + yOff, Point3 + Onepx + zOff );
|
||||
super.renderInWorld( block, world, x, y, z, renderer );
|
||||
|
||||
renderer.setRenderBounds( Point12 - Onepx + xOff, rtop + yOff, Point12 - Onepx + zOff, Point12 + xOff, rtop + Onepx + yOff, Point12 + zOff );
|
||||
super.renderInWorld( block, world, x, y, z, renderer );
|
||||
}
|
||||
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( Blocks.hopper.getIcon( 0, 0 ) );
|
||||
|
||||
renderer.setRenderBounds( Point2 + xOff, bottom + yOff, Point2 + zOff, Point13 + xOff, top + yOff, Point3 + zOff );
|
||||
boolean out = renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderer.setRenderBounds( Point2 + xOff, bottom + yOff, Point12 + zOff, Point13 + xOff, top + yOff, Point13 + zOff );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderer.setRenderBounds( Point2 + xOff, bottom + yOff, Point3 + zOff, Point3 + xOff, top + yOff, Point12 + zOff );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
renderer.setRenderBounds( Point12 + xOff, bottom + yOff, Point3 + zOff, Point13 + xOff, top + yOff, Point12 + zOff );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
|
||||
if ( te != null )
|
||||
{
|
||||
ForgeDirection forward = te.getUp();
|
||||
switch (forward)
|
||||
{
|
||||
case EAST:
|
||||
renderer.setRenderBounds( 0, bottom + yOff, bottom + zOff, Point2 + xOff, top + yOff, top + zOff );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
break;
|
||||
case WEST:
|
||||
renderer.setRenderBounds( Point13 + xOff, bottom + yOff, bottom + zOff, 1.0, top + yOff, top + zOff );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
break;
|
||||
case NORTH:
|
||||
renderer.setRenderBounds( bottom + xOff, bottom + yOff, Point13 + zOff, top + xOff, top + yOff, 1.0 );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
break;
|
||||
case SOUTH:
|
||||
renderer.setRenderBounds( bottom + xOff, bottom + yOff, 0, top + xOff, top + yOff, Point2 + zOff );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
break;
|
||||
case UP:
|
||||
renderer.setRenderBounds( Point2, 0, Point2, Point3, bottom + yOff, Point3 );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
renderer.setRenderBounds( Point2, 0, Point12, Point3, bottom + yOff, Point13 );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
renderer.setRenderBounds( Point12, 0, Point2, Point13, bottom + yOff, Point3 );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
renderer.setRenderBounds( Point12, 0, Point12, Point13, bottom + yOff, Point13 );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
break;
|
||||
case DOWN:
|
||||
renderer.setRenderBounds( Point2, top + yOff, Point2, Point3, 1.0, Point3 );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
renderer.setRenderBounds( Point2, top + yOff, Point12, Point3, 1.0, Point13 );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
renderer.setRenderBounds( Point12, top + yOff, Point2, Point13, 1.0, Point3 );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
renderer.setRenderBounds( Point12, top + yOff, Point12, Point13, 1.0, Point13 );
|
||||
renderer.renderStandardBlock( blk, x, y, z );
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BlockRenderInfo;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.spatial.TileSpatialPylon;
|
||||
|
||||
public class RenderSpatialPylon extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderSpatialPylon() {
|
||||
super( false, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
renderer.overrideBlockTexture = ExtraBlockTextures.BlockSpatialPylon_dim.getIcon();
|
||||
super.renderInventory( block, is, renderer, type, obj );
|
||||
renderer.overrideBlockTexture = null;
|
||||
super.renderInventory( block, is, renderer, type, obj );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
TileSpatialPylon sp = imb.getTileEntity( world, x, y, z );
|
||||
|
||||
int displayBits = sp.getDisplayBits();
|
||||
ForgeDirection ori = ForgeDirection.UNKNOWN;
|
||||
|
||||
if ( displayBits != 0 )
|
||||
{
|
||||
if ( (displayBits & sp.DISPLAY_Z) == sp.DISPLAY_X )
|
||||
{
|
||||
ori = ForgeDirection.EAST;
|
||||
if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_ENDMAX )
|
||||
{
|
||||
renderer.uvRotateEast = 1;
|
||||
renderer.uvRotateWest = 2;
|
||||
renderer.uvRotateTop = 2;
|
||||
renderer.uvRotateBottom = 1;
|
||||
}
|
||||
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_ENDMIN )
|
||||
{
|
||||
renderer.uvRotateEast = 2;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.uvRotateEast = 1;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
}
|
||||
}
|
||||
|
||||
else if ( (displayBits & sp.DISPLAY_Z) == sp.DISPLAY_Y )
|
||||
{
|
||||
ori = ForgeDirection.UP;
|
||||
if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_ENDMAX )
|
||||
{
|
||||
renderer.uvRotateNorth = 3;
|
||||
renderer.uvRotateSouth = 3;
|
||||
renderer.uvRotateEast = 3;
|
||||
renderer.uvRotateWest = 3;
|
||||
}
|
||||
}
|
||||
|
||||
else if ( (displayBits & sp.DISPLAY_Z) == sp.DISPLAY_Z )
|
||||
{
|
||||
ori = ForgeDirection.NORTH;
|
||||
if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_ENDMAX )
|
||||
{
|
||||
renderer.uvRotateSouth = 1;
|
||||
renderer.uvRotateNorth = 2;
|
||||
}
|
||||
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_ENDMIN )
|
||||
{
|
||||
renderer.uvRotateNorth = 1;
|
||||
renderer.uvRotateSouth = 2;
|
||||
renderer.uvRotateTop = 3;
|
||||
renderer.uvRotateBottom = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.uvRotateNorth = 1;
|
||||
renderer.uvRotateSouth = 2;
|
||||
}
|
||||
}
|
||||
|
||||
BlockRenderInfo bri = imb.getRendererInstance();
|
||||
bri.setTemporaryRenderIcon( null );
|
||||
bri.setTemporaryRenderIcons( getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.UP ),
|
||||
getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.DOWN ),
|
||||
getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.SOUTH ),
|
||||
getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.NORTH ),
|
||||
getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.EAST ),
|
||||
getBlockTextureFromSideOutside( imb, sp, displayBits, ori, ForgeDirection.WEST ) );
|
||||
|
||||
boolean r = renderer.renderStandardBlock( imb, x, y, z );
|
||||
|
||||
if ( (displayBits & sp.DISPLAY_POWEREDENABLED) == sp.DISPLAY_POWEREDENABLED )
|
||||
{
|
||||
int bn = 15;
|
||||
Tessellator.instance.setBrightness( bn << 20 | bn << 4 );
|
||||
Tessellator.instance.setColorOpaque_I( 0xffffff );
|
||||
|
||||
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
|
||||
renderFace( x, y, z, imb, getBlockTextureFromSideInside( imb, sp, displayBits, ori, d ), renderer, d );
|
||||
}
|
||||
else
|
||||
{
|
||||
bri.setTemporaryRenderIcon( null );
|
||||
bri.setTemporaryRenderIcons( getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.UP ),
|
||||
getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.DOWN ),
|
||||
getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.SOUTH ),
|
||||
getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.NORTH ),
|
||||
getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.EAST ),
|
||||
getBlockTextureFromSideInside( imb, sp, displayBits, ori, ForgeDirection.WEST ) );
|
||||
|
||||
renderer.renderStandardBlock( imb, x, y, z );
|
||||
}
|
||||
|
||||
bri.setTemporaryRenderIcon( null );
|
||||
renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateBottom = 0;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
renderer.overrideBlockTexture = imb.getIcon( 0, 0 );
|
||||
boolean result = renderer.renderStandardBlock( imb, x, y, z );
|
||||
|
||||
renderer.overrideBlockTexture = ExtraBlockTextures.BlockSpatialPylon_dim.getIcon();
|
||||
result = renderer.renderStandardBlock( imb, x, y, z );
|
||||
|
||||
renderer.overrideBlockTexture = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
private IIcon getBlockTextureFromSideOutside(AEBaseBlock blk, TileSpatialPylon sp, int displayBits, ForgeDirection ori, ForgeDirection dir)
|
||||
{
|
||||
|
||||
if ( ori.equals( dir ) || ori.getOpposite().equals( dir ) )
|
||||
return blk.getRendererInstance().getTexture( dir );
|
||||
|
||||
if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_MIDDLE )
|
||||
return ExtraBlockTextures.BlockSpatialPylonC.getIcon();
|
||||
|
||||
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_ENDMIN )
|
||||
return ExtraBlockTextures.BlockSpatialPylonE.getIcon();
|
||||
|
||||
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_ENDMAX )
|
||||
return ExtraBlockTextures.BlockSpatialPylonE.getIcon();
|
||||
|
||||
return blk.getIcon( 0, 0 );
|
||||
}
|
||||
|
||||
private IIcon getBlockTextureFromSideInside(AEBaseBlock blk, TileSpatialPylon sp, int displayBits, ForgeDirection ori, ForgeDirection dir)
|
||||
{
|
||||
boolean good = (displayBits & sp.DISPLAY_ENABLED) == sp.DISPLAY_ENABLED;
|
||||
|
||||
if ( ori.equals( dir ) || ori.getOpposite().equals( dir ) )
|
||||
return good ? ExtraBlockTextures.BlockSpatialPylon_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylon_red.getIcon();
|
||||
|
||||
if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_MIDDLE )
|
||||
return good ? ExtraBlockTextures.BlockSpatialPylonC_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonC_red.getIcon();
|
||||
|
||||
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_ENDMIN )
|
||||
return good ? ExtraBlockTextures.BlockSpatialPylonE_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonE_red.getIcon();
|
||||
|
||||
else if ( (displayBits & sp.DISPLAY_MIDDLE) == sp.DISPLAY_ENDMAX )
|
||||
return good ? ExtraBlockTextures.BlockSpatialPylonE_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonE_red.getIcon();
|
||||
|
||||
return blk.getIcon( 0, 0 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
|
||||
public class RenderTinyTNT extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderTinyTNT() {
|
||||
super( false, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
renderer.setRenderBounds( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f );
|
||||
super.renderInventory( block, is, renderer, type, obj );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
renderer.renderAllFaces = true;
|
||||
renderer.setRenderBounds( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f );
|
||||
boolean out = super.renderInWorld( imb, world, x, y, z, renderer );
|
||||
renderer.renderAllFaces = false;
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BusRenderHelper;
|
||||
import appeng.client.render.BusRenderer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
|
||||
public class RendererCableBus extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RendererCableBus() {
|
||||
super( true, 30 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
// nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
AEBaseTile t = block.getTileEntity( world, x, y, z );
|
||||
|
||||
if ( t instanceof TileCableBus )
|
||||
{
|
||||
BusRenderer.instance.renderer.renderAllFaces = true;
|
||||
BusRenderer.instance.renderer.blockAccess = renderer.blockAccess;
|
||||
BusRenderer.instance.renderer.overrideBlockTexture = renderer.overrideBlockTexture;
|
||||
((TileCableBus) t).cb.renderStatic( x, y, z );
|
||||
BusRenderer.instance.renderer.renderAllFaces = false;
|
||||
}
|
||||
|
||||
return BusRenderHelper.instance.getItemsRendered() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTile(AEBaseBlock block, AEBaseTile t, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer)
|
||||
{
|
||||
if ( t instanceof TileCableBus )
|
||||
{
|
||||
BusRenderer.instance.renderer.overrideBlockTexture = null;
|
||||
((TileCableBus) t).cb.renderDynamic( x, y, z );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.misc.TileSecurity;
|
||||
|
||||
public class RendererSecurity extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RendererSecurity() {
|
||||
super( false, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
renderer.overrideBlockTexture = ExtraBlockTextures.getMissing();
|
||||
this.renderInvBlock( EnumSet.of( ForgeDirection.SOUTH ), block, is, Tessellator.instance, 0x000000, renderer );
|
||||
|
||||
renderer.overrideBlockTexture = ExtraBlockTextures.MEChest.getIcon();
|
||||
this.renderInvBlock( EnumSet.of( ForgeDirection.UP ), block, is, Tessellator.instance, adjustBrightness( AEColor.Transparent.whiteVariant, 0.7 ),
|
||||
renderer );
|
||||
|
||||
renderer.overrideBlockTexture = null;
|
||||
super.renderInventory( block, is, renderer, type, obj );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
TileSecurity sp = imb.getTileEntity( world, x, y, z );
|
||||
renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
ForgeDirection up = sp.getUp();
|
||||
|
||||
preRenderInWorld( imb, world, x, y, z, renderer );
|
||||
|
||||
boolean result = renderer.renderStandardBlock( imb, x, y, z );
|
||||
|
||||
int b = world.getLightBrightnessForSkyBlocks( x + up.offsetX, y + up.offsetY, z + up.offsetZ, 0 );
|
||||
if ( sp.isActive() )
|
||||
{
|
||||
b = 15 << 20 | 15 << 4;
|
||||
}
|
||||
|
||||
Tessellator.instance.setBrightness( b );
|
||||
Tessellator.instance.setColorOpaque_I( 0xffffff );
|
||||
renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( sp.getColor().whiteVariant );
|
||||
IIcon ico = sp.isActive() ? ExtraBlockTextures.BlockMESecurityOn_Light.getIcon() : ExtraBlockTextures.MEChest.getIcon();
|
||||
renderFace( x, y, z, imb, ico, renderer, up );
|
||||
if ( sp.isActive() )
|
||||
{
|
||||
Tessellator.instance.setColorOpaque_I( sp.getColor().mediumVariant );
|
||||
ico = sp.isActive() ? ExtraBlockTextures.BlockMESecurityOn_Medium.getIcon() : ExtraBlockTextures.MEChest.getIcon();
|
||||
renderFace( x, y, z, imb, ico, renderer, up );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( sp.getColor().blackVariant );
|
||||
ico = sp.isActive() ? ExtraBlockTextures.BlockMESecurityOn_Dark.getIcon() : ExtraBlockTextures.MEChest.getIcon();
|
||||
renderFace( x, y, z, imb, ico, renderer, up );
|
||||
}
|
||||
|
||||
renderer.overrideBlockTexture = null;
|
||||
postRenderInWorld( renderer );
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.entity.EntityFloatingItem;
|
||||
|
||||
public class AssemblerFX extends EntityFX
|
||||
{
|
||||
|
||||
IAEItemStack item;
|
||||
EntityFloatingItem fi;
|
||||
float time = 0;
|
||||
float speed;
|
||||
|
||||
public AssemblerFX(World w, double x, double y, double z, double r, double g, double b, float speed, IAEItemStack is) {
|
||||
super( w, x, y, z, r, g, b );
|
||||
motionX = 0;
|
||||
motionY = 0;
|
||||
motionZ = 0;
|
||||
item = is;
|
||||
this.speed = speed;
|
||||
fi = new EntityFloatingItem( this, w, x, y, z, is.getItemStack() );
|
||||
w.spawnEntityInWorld( fi );
|
||||
particleMaxAge = (int) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightnessForRender(float par1)
|
||||
{
|
||||
int j1 = 13;
|
||||
return j1 << 20 | j1 << 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if ( isDead )
|
||||
fi.setDead();
|
||||
else
|
||||
{
|
||||
float lifeSpan = (float) this.particleAge / (float) this.particleMaxAge;
|
||||
fi.setProgress( lifeSpan );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tess, float l, float rX, float rY, float rZ, float rYZ, float rXY)
|
||||
{
|
||||
time += l;
|
||||
if ( time > 4.0 )
|
||||
{
|
||||
time -= 4.0;
|
||||
// if ( CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
for (int x = 0; x < (int) Math.ceil( speed / 5 ); x++)
|
||||
CommonHelper.proxy.spawnEffect( EffectType.Crafting, worldObj, posX, posY, posZ, null );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import net.minecraft.client.particle.EntityReddustFX;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ChargedOreFX extends EntityReddustFX
|
||||
{
|
||||
|
||||
public ChargedOreFX(World w, double x, double y, double z, float r, float g, float b) {
|
||||
super( w, x, y, z, 0.21f, 0.61f, 1.0f );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightnessForRender(float par1)
|
||||
{
|
||||
int j1 = super.getBrightnessForRender( par1 );
|
||||
j1 = Math.max( j1 >> 20, j1 >> 4 );
|
||||
j1 += 3;
|
||||
if ( j1 > 15 )
|
||||
j1 = 15;
|
||||
return j1 << 20 | j1 << 4;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import net.minecraft.client.particle.EntityBreakingFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CraftingFx extends EntityBreakingFX
|
||||
{
|
||||
|
||||
private IIcon particleTextureIndex;
|
||||
|
||||
private int startBlkX;
|
||||
private int startBlkY;
|
||||
private int startBlkZ;
|
||||
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public CraftingFx(World par1World, double par2, double par4, double par6, Item par8Item) {
|
||||
super( par1World, par2, par4, par6, par8Item );
|
||||
particleGravity = 0;
|
||||
this.particleBlue = 1;
|
||||
this.particleGreen = 0.9f;
|
||||
this.particleRed = 1;
|
||||
this.particleAlpha = 1.3f;
|
||||
this.particleScale = 1.5f;
|
||||
this.particleTextureIndex = ExtraBlockTextures.BlockEnergyParticle.getIcon();
|
||||
particleMaxAge /= 1.2;
|
||||
|
||||
startBlkX = MathHelper.floor_double( posX );
|
||||
startBlkY = MathHelper.floor_double( posY );
|
||||
startBlkZ = MathHelper.floor_double( posZ );
|
||||
}
|
||||
|
||||
public void fromItem(ForgeDirection d)
|
||||
{
|
||||
this.posX += 0.2 * d.offsetX;
|
||||
this.posY += 0.2 * d.offsetY;
|
||||
this.posZ += 0.2 * d.offsetZ;
|
||||
this.particleScale *= 0.8f;
|
||||
}
|
||||
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
this.particleScale *= 0.51f;
|
||||
this.particleAlpha *= 0.51f;
|
||||
}
|
||||
|
||||
public void renderParticle(Tessellator par1Tessellator, float partialTick, float x, float y, float z, float rx, float rz)
|
||||
{
|
||||
if ( partialTick < 0 || partialTick > 1 )
|
||||
return;
|
||||
|
||||
float f6 = this.particleTextureIndex.getMinU();
|
||||
float f7 = this.particleTextureIndex.getMaxU();
|
||||
float f8 = this.particleTextureIndex.getMinV();
|
||||
float f9 = this.particleTextureIndex.getMaxV();
|
||||
float scale = 0.1F * this.particleScale;
|
||||
|
||||
float offx = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick);
|
||||
float offy = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick);
|
||||
float offz = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick);
|
||||
float f14 = 1.0F;
|
||||
|
||||
int blkX = MathHelper.floor_double( offx );
|
||||
int blkY = MathHelper.floor_double( offy );
|
||||
int blkZ = MathHelper.floor_double( offz );
|
||||
if ( blkX == startBlkX && blkY == startBlkY && blkZ == startBlkZ )
|
||||
{
|
||||
offx -= interpPosX;
|
||||
offy -= interpPosY;
|
||||
offz -= interpPosZ;
|
||||
|
||||
// AELog.info( "" + partialTick );
|
||||
par1Tessellator.setColorRGBA_F( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha );
|
||||
par1Tessellator.addVertexWithUV( (double) (offx - x * scale - rx * scale), (double) (offy - y * scale), (double) (offz - z * scale - rz * scale),
|
||||
(double) f7, (double) f9 );
|
||||
par1Tessellator.addVertexWithUV( (double) (offx - x * scale + rx * scale), (double) (offy + y * scale), (double) (offz - z * scale + rz * scale),
|
||||
(double) f7, (double) f8 );
|
||||
par1Tessellator.addVertexWithUV( (double) (offx + x * scale + rx * scale), (double) (offy + y * scale), (double) (offz + z * scale + rz * scale),
|
||||
(double) f6, (double) f8 );
|
||||
par1Tessellator.addVertexWithUV( (double) (offx + x * scale - rx * scale), (double) (offy - y * scale), (double) (offz + z * scale - rz * scale),
|
||||
(double) f6, (double) f9 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import net.minecraft.client.particle.EntityBreakingFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class EnergyFx extends EntityBreakingFX
|
||||
{
|
||||
|
||||
private IIcon particleTextureIndex;
|
||||
|
||||
private int startBlkX;
|
||||
private int startBlkY;
|
||||
private int startBlkZ;
|
||||
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public EnergyFx(World par1World, double par2, double par4, double par6, Item par8Item) {
|
||||
super( par1World, par2, par4, par6, par8Item );
|
||||
particleGravity = 0;
|
||||
this.particleBlue = 255;
|
||||
this.particleGreen = 255;
|
||||
this.particleRed = 255;
|
||||
this.particleAlpha = 1.4f;
|
||||
this.particleScale = 3.5f;
|
||||
this.particleTextureIndex = ExtraBlockTextures.BlockEnergyParticle.getIcon();
|
||||
|
||||
startBlkX = MathHelper.floor_double( posX );
|
||||
startBlkY = MathHelper.floor_double( posY );
|
||||
startBlkZ = MathHelper.floor_double( posZ );
|
||||
}
|
||||
|
||||
public void fromItem(ForgeDirection d)
|
||||
{
|
||||
this.posX += 0.2 * d.offsetX;
|
||||
this.posY += 0.2 * d.offsetY;
|
||||
this.posZ += 0.2 * d.offsetZ;
|
||||
this.particleScale *= 0.8f;
|
||||
}
|
||||
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
this.particleScale *= 0.89f;
|
||||
this.particleAlpha *= 0.89f;
|
||||
}
|
||||
|
||||
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
|
||||
{
|
||||
float f6 = this.particleTextureIndex.getMinU();
|
||||
float f7 = this.particleTextureIndex.getMaxU();
|
||||
float f8 = this.particleTextureIndex.getMinV();
|
||||
float f9 = this.particleTextureIndex.getMaxV();
|
||||
float f10 = 0.1F * this.particleScale;
|
||||
|
||||
float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX);
|
||||
float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY);
|
||||
float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ);
|
||||
float f14 = 1.0F;
|
||||
|
||||
int blkX = MathHelper.floor_double( posX );
|
||||
int blkY = MathHelper.floor_double( posY );
|
||||
int blkZ = MathHelper.floor_double( posZ );
|
||||
|
||||
if ( blkX == startBlkX && blkY == startBlkY && blkZ == startBlkZ )
|
||||
{
|
||||
par1Tessellator.setColorRGBA_F( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha );
|
||||
par1Tessellator.addVertexWithUV( (double) (f11 - par3 * f10 - par6 * f10), (double) (f12 - par4 * f10), (double) (f13 - par5 * f10 - par7 * f10),
|
||||
(double) f7, (double) f9 );
|
||||
par1Tessellator.addVertexWithUV( (double) (f11 - par3 * f10 + par6 * f10), (double) (f12 + par4 * f10), (double) (f13 - par5 * f10 + par7 * f10),
|
||||
(double) f7, (double) f8 );
|
||||
par1Tessellator.addVertexWithUV( (double) (f11 + par3 * f10 + par6 * f10), (double) (f12 + par4 * f10), (double) (f13 + par5 * f10 + par7 * f10),
|
||||
(double) f6, (double) f8 );
|
||||
par1Tessellator.addVertexWithUV( (double) (f11 + par3 * f10 - par6 * f10), (double) (f12 - par4 * f10), (double) (f13 + par5 * f10 - par7 * f10),
|
||||
(double) f6, (double) f9 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LightningArcFX extends LightningFX
|
||||
{
|
||||
|
||||
double rx, ry, rz;
|
||||
|
||||
public LightningArcFX(World w, double x, double y, double z, double ex, double ey, double ez, double r, double g, double b) {
|
||||
super( w, x, y, z, r, g, b, 6 );
|
||||
|
||||
this.rx = ex - x;
|
||||
this.ry = ey - y;
|
||||
this.rz = ez - z;
|
||||
|
||||
regen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void regen()
|
||||
{
|
||||
double i = 1.0 / (steps - 1);
|
||||
double lastDirectionX = rx * i;
|
||||
double lastDirectionY = ry * i;
|
||||
double lastDirectionZ = rz * i;
|
||||
|
||||
double len = Math.sqrt( lastDirectionX * lastDirectionX + lastDirectionY * lastDirectionY + lastDirectionZ * lastDirectionZ );
|
||||
for (int s = 0; s < steps; s++)
|
||||
{
|
||||
Steps[s][0] = (lastDirectionX + (rng.nextDouble() - 0.5) * len * 1.2) / 2.0;
|
||||
Steps[s][1] = (lastDirectionY + (rng.nextDouble() - 0.5) * len * 1.2) / 2.0;
|
||||
Steps[s][2] = (lastDirectionZ + (rng.nextDouble() - 0.5) * len * 1.2) / 2.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LightningFX extends EntityFX
|
||||
{
|
||||
|
||||
final int steps = getSteps();
|
||||
static Random rng = new Random();
|
||||
double[][] Steps;
|
||||
|
||||
protected LightningFX(World w, double x, double y, double z, double r, double g, double b, int maxAge) {
|
||||
super( w, x, y, z, r, g, b );
|
||||
Steps = new double[steps][3];
|
||||
motionX = 0;
|
||||
motionY = 0;
|
||||
motionZ = 0;
|
||||
particleMaxAge = maxAge;
|
||||
}
|
||||
|
||||
private int getSteps()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public LightningFX(World w, double x, double y, double z, double r, double g, double b) {
|
||||
this( w, x, y, z, r, g, b, 6 );
|
||||
regen();
|
||||
}
|
||||
|
||||
float currentPoint = 0;
|
||||
|
||||
@Override
|
||||
public int getBrightnessForRender(float par1)
|
||||
{
|
||||
int j1 = 13;
|
||||
return j1 << 20 | j1 << 4;
|
||||
}
|
||||
|
||||
protected void regen()
|
||||
{
|
||||
double lastDirectionX = (rng.nextDouble() - 0.5) * 0.9;
|
||||
double lastDirectionY = (rng.nextDouble() - 0.5) * 0.9;
|
||||
double lastDirectionZ = (rng.nextDouble() - 0.5) * 0.9;
|
||||
for (int s = 0; s < steps; s++)
|
||||
{
|
||||
Steps[s][0] = lastDirectionX = (lastDirectionX + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
|
||||
Steps[s][1] = lastDirectionY = (lastDirectionY + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
|
||||
Steps[s][2] = lastDirectionZ = (lastDirectionZ + (rng.nextDouble() - 0.5) * 0.9) / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tess, float l, float rX, float rY, float rZ, float rYZ, float rXY)
|
||||
{
|
||||
float j = 1.0f;
|
||||
tess.setColorRGBA_F( this.particleRed * j * 0.9f, this.particleGreen * j * 0.95f, this.particleBlue * j, this.particleAlpha );
|
||||
if ( particleAge == 3 )
|
||||
{
|
||||
regen();
|
||||
}
|
||||
double f6 = this.particleTextureIndexX / 16.0;
|
||||
double f7 = f6 + 0.0324375F;
|
||||
double f8 = this.particleTextureIndexY / 16.0;
|
||||
double f9 = f8 + 0.0324375F;
|
||||
|
||||
f6 = f7;
|
||||
f8 = f9;
|
||||
|
||||
double scale = 0.02;// 0.02F * this.particleScale;
|
||||
|
||||
double a[] = new double[3];
|
||||
double b[] = new double[3];
|
||||
|
||||
double ox = 0;
|
||||
double oy = 0;
|
||||
double oz = 0;
|
||||
|
||||
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
|
||||
double offX = -rZ;
|
||||
double offY = MathHelper.cos( (float) (Math.PI / 2.0f + p.rotationPitch * 0.017453292F) );
|
||||
double offZ = rX;
|
||||
|
||||
for (int layer = 0; layer < 2; layer++)
|
||||
{
|
||||
if ( layer == 0 )
|
||||
{
|
||||
scale = 0.04;
|
||||
offX *= 0.001;
|
||||
offY *= 0.001;
|
||||
offZ *= 0.001;
|
||||
tess.setColorRGBA_F( this.particleRed * j * 0.4f, this.particleGreen * j * 0.25f, this.particleBlue * j * 0.45f, this.particleAlpha );
|
||||
}
|
||||
else
|
||||
{
|
||||
offX = 0;
|
||||
offY = 0;
|
||||
offZ = 0;
|
||||
scale = 0.02;
|
||||
tess.setColorRGBA_F( this.particleRed * j * 0.9f, this.particleGreen * j * 0.65f, this.particleBlue * j * 0.85f, this.particleAlpha );
|
||||
}
|
||||
|
||||
for (int cycle = 0; cycle < 3; cycle++)
|
||||
{
|
||||
clear();
|
||||
|
||||
double x = (this.prevPosX + (this.posX - this.prevPosX) * (double) l - interpPosX) - offX;
|
||||
double y = (this.prevPosY + (this.posY - this.prevPosY) * (double) l - interpPosY) - offY;
|
||||
double z = (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) l - interpPosZ) - offZ;
|
||||
|
||||
for (int s = 0; s < steps; s++)
|
||||
{
|
||||
double xN = x + Steps[s][0];
|
||||
double yN = y + Steps[s][1];
|
||||
double zN = z + Steps[s][2];
|
||||
|
||||
double xD = xN - x;
|
||||
double yD = yN - y;
|
||||
double zD = zN - z;
|
||||
|
||||
if ( cycle == 0 )
|
||||
{
|
||||
ox = (yD * 0) - (1 * zD);
|
||||
oy = (zD * 0) - (0 * xD);
|
||||
oz = (xD * 1) - (0 * yD);
|
||||
}
|
||||
if ( cycle == 1 )
|
||||
{
|
||||
ox = (yD * 1) - (0 * zD);
|
||||
oy = (zD * 0) - (1 * xD);
|
||||
oz = (xD * 0) - (0 * yD);
|
||||
}
|
||||
if ( cycle == 2 )
|
||||
{
|
||||
ox = (yD * 0) - (0 * zD);
|
||||
oy = (zD * 1) - (0 * xD);
|
||||
oz = (xD * 0) - (1 * yD);
|
||||
}
|
||||
|
||||
double ss = Math.sqrt( ox * ox + oy * oy + oz * oz ) / ((((double) steps - (double) s) / (double) steps) * scale);
|
||||
ox /= ss;
|
||||
oy /= ss;
|
||||
oz /= ss;
|
||||
|
||||
a[0] = x + ox;
|
||||
a[1] = y + oy;
|
||||
a[2] = z + oz;
|
||||
|
||||
b[0] = x;
|
||||
b[1] = y;
|
||||
b[2] = z;
|
||||
|
||||
draw( tess, a, b, f6, f8 );
|
||||
|
||||
x = xN;
|
||||
y = yN;
|
||||
z = zN;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); GL11.glDisable( GL11.GL_CULL_FACE ); tess.draw();
|
||||
* GL11.glPopAttrib(); tess.startDrawingQuads();
|
||||
*/
|
||||
}
|
||||
|
||||
boolean hasData = false;
|
||||
double[] I = new double[3];
|
||||
double[] K = new double[3];
|
||||
|
||||
private void draw(Tessellator tess, double[] a, double[] b, double f6, double f8)
|
||||
{
|
||||
if ( hasData )
|
||||
{
|
||||
tess.addVertexWithUV( a[0], a[1], a[2], f6, f8 );
|
||||
tess.addVertexWithUV( I[0], I[1], I[2], f6, f8 );
|
||||
tess.addVertexWithUV( K[0], K[1], K[2], f6, f8 );
|
||||
tess.addVertexWithUV( b[0], b[1], b[2], f6, f8 );
|
||||
}
|
||||
hasData = true;
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
I[x] = a[x];
|
||||
K[x] = b[x];
|
||||
}
|
||||
}
|
||||
|
||||
private void clear()
|
||||
{
|
||||
hasData = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import net.minecraft.client.particle.EntityBreakingFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
|
||||
public class MatterCannonFX extends EntityBreakingFX
|
||||
{
|
||||
|
||||
private IIcon particleTextureIndex;
|
||||
|
||||
public MatterCannonFX(World par1World, double par2, double par4, double par6, Item par8Item) {
|
||||
super( par1World, par2, par4, par6, par8Item );
|
||||
particleGravity = 0;
|
||||
this.particleBlue = 255;
|
||||
this.particleGreen = 255;
|
||||
this.particleRed = 255;
|
||||
this.particleAlpha = 1.4f;
|
||||
this.particleScale = 1.1f;
|
||||
this.motionX = 0.0f;
|
||||
this.motionY = 0.0f;
|
||||
this.motionZ = 0.0f;
|
||||
this.particleTextureIndex = ExtraBlockTextures.BlockMatterCannonParticle.getIcon();
|
||||
}
|
||||
|
||||
public void fromItem(ForgeDirection d)
|
||||
{
|
||||
this.particleScale *= 1.2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
this.particleScale *= 1.19f;
|
||||
this.particleAlpha *= 0.59f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
|
||||
{
|
||||
float f6 = this.particleTextureIndex.getMinU();
|
||||
float f7 = this.particleTextureIndex.getMaxU();
|
||||
float f8 = this.particleTextureIndex.getMinV();
|
||||
float f9 = this.particleTextureIndex.getMaxV();
|
||||
float f10 = 0.05F * this.particleScale;
|
||||
|
||||
float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX);
|
||||
float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY);
|
||||
float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ);
|
||||
float f14 = 1.0F;
|
||||
|
||||
par1Tessellator.setColorRGBA_F( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha );
|
||||
par1Tessellator.addVertexWithUV( (double) (f11 - par3 * f10 - par6 * f10), (double) (f12 - par4 * f10), (double) (f13 - par5 * f10 - par7 * f10),
|
||||
(double) f7, (double) f9 );
|
||||
par1Tessellator.addVertexWithUV( (double) (f11 - par3 * f10 + par6 * f10), (double) (f12 + par4 * f10), (double) (f13 - par5 * f10 + par7 * f10),
|
||||
(double) f7, (double) f8 );
|
||||
par1Tessellator.addVertexWithUV( (double) (f11 + par3 * f10 + par6 * f10), (double) (f12 + par4 * f10), (double) (f13 + par5 * f10 + par7 * f10),
|
||||
(double) f6, (double) f8 );
|
||||
par1Tessellator.addVertexWithUV( (double) (f11 + par3 * f10 - par6 * f10), (double) (f12 - par4 * f10), (double) (f13 + par5 * f10 - par7 * f10),
|
||||
(double) f6, (double) f9 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class VibrantFX extends EntityFX
|
||||
{
|
||||
|
||||
public VibrantFX(World par1World, double x, double y, double z, double par8, double par10, double par12) {
|
||||
super( par1World, x, y, z, par8, par10, par12 );
|
||||
float f = this.rand.nextFloat() * 0.1F + 0.8F;
|
||||
this.particleRed = f * 0.7f;
|
||||
this.particleGreen = f * 0.89f;
|
||||
this.particleBlue = f * 0.9f;
|
||||
this.setParticleTextureIndex( 0 );
|
||||
this.setSize( 0.04F, 0.04F );
|
||||
this.particleScale *= this.rand.nextFloat() * 0.6F + 1.9F;
|
||||
this.motionX = 0.0D;
|
||||
this.motionY = 0.0D;
|
||||
this.motionZ = 0.0D;
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
this.particleMaxAge = (int) (20.0D / (Math.random() * 0.8D + 0.1D));
|
||||
this.noClip = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBrightness(float par1)
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
// this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
||||
this.particleScale *= 0.95;
|
||||
|
||||
if ( this.particleMaxAge-- <= 0 || this.particleScale < 0.1 )
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package appeng.client.render.items;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
|
||||
public class ItemEncodedPatternRenderer implements IItemRenderer
|
||||
{
|
||||
|
||||
RenderItem ri = new RenderItem();
|
||||
boolean recursive;
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
||||
{
|
||||
boolean isShiftHeld = Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) || Keyboard.isKeyDown( Keyboard.KEY_RSHIFT );
|
||||
|
||||
if ( recursive == false && type == IItemRenderer.ItemRenderType.INVENTORY && isShiftHeld )
|
||||
{
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem();
|
||||
if ( iep.getOutput( item ) != null )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
recursive = true;
|
||||
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem();
|
||||
|
||||
ItemStack is = iep.getOutput( item );
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
ri.renderItemAndEffectIntoGUI( mc.fontRenderer, mc.getTextureManager(), is, 0, 0 );
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glPopAttrib();
|
||||
|
||||
recursive = false;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user