reformatted all src files (#141)
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
@@ -19,186 +21,163 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
||||
/**
|
||||
* Renders the dynamic parts of an inscriber (the presses, the animation and the item being smashed)
|
||||
*/
|
||||
public final class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
{
|
||||
public final class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber> {
|
||||
|
||||
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
|
||||
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
|
||||
|
||||
private static final ResourceLocation TEXTURE_INSIDE = new ResourceLocation( AppEng.MOD_ID, "blocks/inscriber_inside" );
|
||||
private static final ResourceLocation TEXTURE_INSIDE = new ResourceLocation(AppEng.MOD_ID, "blocks/inscriber_inside");
|
||||
|
||||
private static TextureAtlasSprite textureInside;
|
||||
private static TextureAtlasSprite textureInside;
|
||||
|
||||
@Override
|
||||
public void render( final TileInscriber tile, final double x, final double y, final double z, final float partialTicks, final int destroyStage, final float p_render_10_ )
|
||||
{
|
||||
// render inscriber
|
||||
@Override
|
||||
public void render(final TileInscriber tile, final double x, final double y, final double z, final float partialTicks, final int destroyStage, final float p_render_10_) {
|
||||
// render inscriber
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate( x, y, z );
|
||||
GlStateManager.translate( 0.5F, 0.5F, 0.5F );
|
||||
FacingToRotation.get( tile.getForward(), tile.getUp() ).glRotateCurrentMat();
|
||||
GlStateManager.translate( -0.5F, -0.5F, -0.5F );
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x, y, z);
|
||||
GlStateManager.translate(0.5F, 0.5F, 0.5F);
|
||||
FacingToRotation.get(tile.getForward(), tile.getUp()).glRotateCurrentMat();
|
||||
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
|
||||
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableRescaleNormal();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableRescaleNormal();
|
||||
|
||||
// render sides of stamps
|
||||
// render sides of stamps
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.renderEngine.bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
|
||||
// << 20 | light << 4;
|
||||
final int br = tile.getWorld().getCombinedLight( tile.getPos(), 0 );
|
||||
final int var11 = br % 65536;
|
||||
final int var12 = br / 65536;
|
||||
// << 20 | light << 4;
|
||||
final int br = tile.getWorld().getCombinedLight(tile.getPos(), 0);
|
||||
final int var11 = br % 65536;
|
||||
final int var12 = br / 65536;
|
||||
|
||||
OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11, var12 );
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11, var12);
|
||||
|
||||
long absoluteProgress = 0;
|
||||
long absoluteProgress = 0;
|
||||
|
||||
if( tile.isSmash() )
|
||||
{
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
absoluteProgress = currentTime - tile.getClientStart();
|
||||
if( absoluteProgress > 800 )
|
||||
{
|
||||
tile.setSmash( false );
|
||||
}
|
||||
}
|
||||
if (tile.isSmash()) {
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
absoluteProgress = currentTime - tile.getClientStart();
|
||||
if (absoluteProgress > 800) {
|
||||
tile.setSmash(false);
|
||||
}
|
||||
}
|
||||
|
||||
final float relativeProgress = absoluteProgress % 800 / 400.0f;
|
||||
float progress = relativeProgress;
|
||||
final float relativeProgress = absoluteProgress % 800 / 400.0f;
|
||||
float progress = relativeProgress;
|
||||
|
||||
if( progress > 1.0f )
|
||||
{
|
||||
progress = 1.0f - ( progress - 1.0f );
|
||||
}
|
||||
float press = 0.2f;
|
||||
press -= progress / 5.0f;
|
||||
if (progress > 1.0f) {
|
||||
progress = 1.0f - (progress - 1.0f);
|
||||
}
|
||||
float press = 0.2f;
|
||||
press -= progress / 5.0f;
|
||||
|
||||
final BufferBuilder buffer = Tessellator.getInstance().getBuffer();
|
||||
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX );
|
||||
final BufferBuilder buffer = Tessellator.getInstance().getBuffer();
|
||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
|
||||
float middle = 0.5f;
|
||||
middle += 0.02f;
|
||||
final float TwoPx = 2.0f / 16.0f;
|
||||
final float base = 0.4f;
|
||||
float middle = 0.5f;
|
||||
middle += 0.02f;
|
||||
final float TwoPx = 2.0f / 16.0f;
|
||||
final float base = 0.4f;
|
||||
|
||||
final TextureAtlasSprite tas = textureInside;
|
||||
if( tas != null )
|
||||
{
|
||||
// Bottom of Top Stamp
|
||||
buffer.pos( TwoPx, middle + press, TwoPx ).tex( tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 13 ) ).endVertex();
|
||||
buffer.pos( 1.0 - TwoPx, middle + press, TwoPx ).tex( tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 13 ) ).endVertex();
|
||||
buffer.pos( 1.0 - TwoPx, middle + press, 1.0 - TwoPx ).tex( tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 2 ) ).endVertex();
|
||||
buffer.pos( TwoPx, middle + press, 1.0 - TwoPx ).tex( tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 2 ) ).endVertex();
|
||||
final TextureAtlasSprite tas = textureInside;
|
||||
if (tas != null) {
|
||||
// Bottom of Top Stamp
|
||||
buffer.pos(TwoPx, middle + press, TwoPx).tex(tas.getInterpolatedU(2), tas.getInterpolatedV(13)).endVertex();
|
||||
buffer.pos(1.0 - TwoPx, middle + press, TwoPx).tex(tas.getInterpolatedU(14), tas.getInterpolatedV(13)).endVertex();
|
||||
buffer.pos(1.0 - TwoPx, middle + press, 1.0 - TwoPx).tex(tas.getInterpolatedU(14), tas.getInterpolatedV(2)).endVertex();
|
||||
buffer.pos(TwoPx, middle + press, 1.0 - TwoPx).tex(tas.getInterpolatedU(2), tas.getInterpolatedV(2)).endVertex();
|
||||
|
||||
// Front of Top Stamp
|
||||
buffer.pos( TwoPx, middle + base, TwoPx ).tex( tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 3 - 16 * ( press - base ) ) ).endVertex();
|
||||
buffer.pos( 1.0 - TwoPx, middle + base, TwoPx ).tex( tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 3 - 16 * ( press - base ) ) ).endVertex();
|
||||
buffer.pos( 1.0 - TwoPx, middle + press, TwoPx ).tex( tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 3 ) ).endVertex();
|
||||
buffer.pos( TwoPx, middle + press, TwoPx ).tex( tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 3 ) ).endVertex();
|
||||
// Front of Top Stamp
|
||||
buffer.pos(TwoPx, middle + base, TwoPx).tex(tas.getInterpolatedU(2), tas.getInterpolatedV(3 - 16 * (press - base))).endVertex();
|
||||
buffer.pos(1.0 - TwoPx, middle + base, TwoPx).tex(tas.getInterpolatedU(14), tas.getInterpolatedV(3 - 16 * (press - base))).endVertex();
|
||||
buffer.pos(1.0 - TwoPx, middle + press, TwoPx).tex(tas.getInterpolatedU(14), tas.getInterpolatedV(3)).endVertex();
|
||||
buffer.pos(TwoPx, middle + press, TwoPx).tex(tas.getInterpolatedU(2), tas.getInterpolatedV(3)).endVertex();
|
||||
|
||||
// Top of Bottom Stamp
|
||||
middle -= 2.0f * 0.02f;
|
||||
buffer.pos( 1.0 - TwoPx, middle - press, TwoPx ).tex( tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 13 ) ).endVertex();
|
||||
buffer.pos( TwoPx, middle - press, TwoPx ).tex( tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 13 ) ).endVertex();
|
||||
buffer.pos( TwoPx, middle - press, 1.0 - TwoPx ).tex( tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 2 ) ).endVertex();
|
||||
buffer.pos( 1.0 - TwoPx, middle - press, 1.0 - TwoPx ).tex( tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 2 ) ).endVertex();
|
||||
// Top of Bottom Stamp
|
||||
middle -= 2.0f * 0.02f;
|
||||
buffer.pos(1.0 - TwoPx, middle - press, TwoPx).tex(tas.getInterpolatedU(2), tas.getInterpolatedV(13)).endVertex();
|
||||
buffer.pos(TwoPx, middle - press, TwoPx).tex(tas.getInterpolatedU(14), tas.getInterpolatedV(13)).endVertex();
|
||||
buffer.pos(TwoPx, middle - press, 1.0 - TwoPx).tex(tas.getInterpolatedU(14), tas.getInterpolatedV(2)).endVertex();
|
||||
buffer.pos(1.0 - TwoPx, middle - press, 1.0 - TwoPx).tex(tas.getInterpolatedU(2), tas.getInterpolatedV(2)).endVertex();
|
||||
|
||||
// Front of Bottom Stamp
|
||||
buffer.pos( 1.0 - TwoPx, middle + -base, TwoPx ).tex( tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 3 - 16 * ( press - base ) ) ).endVertex();
|
||||
buffer.pos( TwoPx, middle - base, TwoPx ).tex( tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 3 - 16 * ( press - base ) ) ).endVertex();
|
||||
buffer.pos( TwoPx, middle - press, TwoPx ).tex( tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 3 ) ).endVertex();
|
||||
buffer.pos( 1.0 - TwoPx, middle - press, TwoPx ).tex( tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 3 ) ).endVertex();
|
||||
}
|
||||
// Front of Bottom Stamp
|
||||
buffer.pos(1.0 - TwoPx, middle + -base, TwoPx).tex(tas.getInterpolatedU(2), tas.getInterpolatedV(3 - 16 * (press - base))).endVertex();
|
||||
buffer.pos(TwoPx, middle - base, TwoPx).tex(tas.getInterpolatedU(14), tas.getInterpolatedV(3 - 16 * (press - base))).endVertex();
|
||||
buffer.pos(TwoPx, middle - press, TwoPx).tex(tas.getInterpolatedU(14), tas.getInterpolatedV(3)).endVertex();
|
||||
buffer.pos(1.0 - TwoPx, middle - press, TwoPx).tex(tas.getInterpolatedU(2), tas.getInterpolatedV(3)).endVertex();
|
||||
}
|
||||
|
||||
Tessellator.getInstance().draw();
|
||||
Tessellator.getInstance().draw();
|
||||
|
||||
// render items.
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
// render items.
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
IItemHandler tileInv = tile.getInternalInventory();
|
||||
IItemHandler tileInv = tile.getInternalInventory();
|
||||
|
||||
int items = 0;
|
||||
if( !tileInv.getStackInSlot( 0 ).isEmpty() )
|
||||
{
|
||||
items++;
|
||||
}
|
||||
if( !tileInv.getStackInSlot( 1 ).isEmpty() )
|
||||
{
|
||||
items++;
|
||||
}
|
||||
if( !tileInv.getStackInSlot( 2 ).isEmpty() )
|
||||
{
|
||||
items++;
|
||||
}
|
||||
int items = 0;
|
||||
if (!tileInv.getStackInSlot(0).isEmpty()) {
|
||||
items++;
|
||||
}
|
||||
if (!tileInv.getStackInSlot(1).isEmpty()) {
|
||||
items++;
|
||||
}
|
||||
if (!tileInv.getStackInSlot(2).isEmpty()) {
|
||||
items++;
|
||||
}
|
||||
|
||||
if( relativeProgress > 1.0f || items == 0 )
|
||||
{
|
||||
ItemStack is = tileInv.getStackInSlot( 3 );
|
||||
if (relativeProgress > 1.0f || items == 0) {
|
||||
ItemStack is = tileInv.getStackInSlot(3);
|
||||
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
final IInscriberRecipe ir = tile.getTask();
|
||||
if( ir != null )
|
||||
{
|
||||
is = ir.getOutput().copy();
|
||||
}
|
||||
}
|
||||
if (is.isEmpty()) {
|
||||
final IInscriberRecipe ir = tile.getTask();
|
||||
if (ir != null) {
|
||||
is = ir.getOutput().copy();
|
||||
}
|
||||
}
|
||||
|
||||
this.renderItem( is, 0.0f, tile, x, y, z );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.renderItem( tileInv.getStackInSlot( 0 ), press, tile, x, y, z );
|
||||
this.renderItem( tileInv.getStackInSlot( 1 ), -press, tile, x, y, z );
|
||||
this.renderItem( tileInv.getStackInSlot( 2 ), 0.0f, tile, x, y, z );
|
||||
}
|
||||
this.renderItem(is, 0.0f, tile, x, y, z);
|
||||
} else {
|
||||
this.renderItem(tileInv.getStackInSlot(0), press, tile, x, y, z);
|
||||
this.renderItem(tileInv.getStackInSlot(1), -press, tile, x, y, z);
|
||||
this.renderItem(tileInv.getStackInSlot(2), 0.0f, tile, x, y, z);
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.enableRescaleNormal();
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.enableRescaleNormal();
|
||||
}
|
||||
|
||||
private void renderItem( final ItemStack stack, final float o, final AEBaseTile tile, final double x, final double y, final double z )
|
||||
{
|
||||
if( !stack.isEmpty() )
|
||||
{
|
||||
final ItemStack sis = stack.copy();
|
||||
private void renderItem(final ItemStack stack, final float o, final AEBaseTile tile, final double x, final double y, final double z) {
|
||||
if (!stack.isEmpty()) {
|
||||
final ItemStack sis = stack.copy();
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
// move to center
|
||||
GlStateManager.translate( 0.5f, 0.5f + o, 0.5f );
|
||||
GlStateManager.rotate( 90, 1, 0, 0 );
|
||||
// set scale
|
||||
GlStateManager.scale( ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE );
|
||||
GlStateManager.pushMatrix();
|
||||
// move to center
|
||||
GlStateManager.translate(0.5f, 0.5f + o, 0.5f);
|
||||
GlStateManager.rotate(90, 1, 0, 0);
|
||||
// set scale
|
||||
GlStateManager.scale(ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE);
|
||||
|
||||
// heuristic to scale items down much further than blocks
|
||||
if( !( sis.getItem() instanceof ItemBlock ) )
|
||||
{
|
||||
GlStateManager.scale( 0.5, 0.5, 0.5 );
|
||||
}
|
||||
// heuristic to scale items down much further than blocks
|
||||
if (!(sis.getItem() instanceof ItemBlock)) {
|
||||
GlStateManager.scale(0.5, 0.5, 0.5);
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem( sis, ItemCameraTransforms.TransformType.FIXED );
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(sis, ItemCameraTransforms.TransformType.FIXED);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerTexture( TextureStitchEvent.Pre event )
|
||||
{
|
||||
textureInside = event.getMap().registerSprite( TEXTURE_INSIDE );
|
||||
}
|
||||
public static void registerTexture(TextureStitchEvent.Pre event) {
|
||||
textureInside = event.getMap().registerSprite(TEXTURE_INSIDE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user