Removed Inscriber Recipe Registry
Fixed Inscriber TESR rendering and added a small easing function
This commit is contained in:
@@ -2,25 +2,31 @@
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.vertex.MatrixApplyingVertexBuilder;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.model.pipeline.TransformerConsumer;
|
||||
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;
|
||||
|
||||
|
||||
@@ -32,14 +38,20 @@ public final class InscriberTESR extends TileEntityRenderer<TileInscriber>
|
||||
|
||||
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
|
||||
|
||||
private static final ResourceLocation TEXTURE_INSIDE = new ResourceLocation( AppEng.MOD_ID, "block/inscriber_inside" );
|
||||
|
||||
private static TextureAtlasSprite textureInside;
|
||||
private static final Material TEXTURE_INSIDE = new Material(PlayerContainer.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "block/inscriber_inside" ));
|
||||
|
||||
public InscriberTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
// See https://easings.net/#easeOutBack
|
||||
private static float ease(float x) {
|
||||
float c1 = 1.70158f;
|
||||
float c3 = c1 + 1;
|
||||
|
||||
return (float) (1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileInscriber tile, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) {
|
||||
|
||||
@@ -50,22 +62,8 @@ public final class InscriberTESR extends TileEntityRenderer<TileInscriber>
|
||||
FacingToRotation.get( tile.getForward(), tile.getUp() ).push(ms);
|
||||
ms.translate( -0.5F, -0.5F, -0.5F );
|
||||
|
||||
// FIXME RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
// FIXME RenderSystem.disableLighting();
|
||||
// FIXME RenderSystem.disableRescaleNormal();
|
||||
|
||||
// render sides of stamps
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
// FIXME RenderingEngine.getInstance().bindTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE );
|
||||
|
||||
// << 20 | light << 4;
|
||||
// FIXME final int br = combinedLight;
|
||||
// FIXME final int var11 = br % 65536;
|
||||
// FIXME final int var12 = br / 65536;
|
||||
|
||||
// FIXME OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11, var12 );
|
||||
|
||||
long absoluteProgress = 0;
|
||||
|
||||
if( tile.isSmash() )
|
||||
@@ -84,51 +82,49 @@ public final class InscriberTESR extends TileEntityRenderer<TileInscriber>
|
||||
if( progress > 1.0f )
|
||||
{
|
||||
progress = 1.0f - ( progress - 1.0f );
|
||||
} else {
|
||||
// Only apply the easing function on the way down
|
||||
progress = ease(progress);
|
||||
}
|
||||
|
||||
float press = 0.2f;
|
||||
press -= progress / 5.0f;
|
||||
|
||||
IVertexBuilder buffer = buffers.getBuffer(RenderType.getSolid());
|
||||
|
||||
// final BufferBuilder buffer = Tessellator.getInstance().getBuffer();
|
||||
// FIXME 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;
|
||||
|
||||
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 = TEXTURE_INSIDE.getSprite();
|
||||
|
||||
// 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();
|
||||
IVertexBuilder buffer = buffers.getBuffer(RenderType.getSolid());
|
||||
|
||||
// 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();
|
||||
// Bottom of Top Stamp
|
||||
addVertex( buffer, ms, TwoPx, middle + press, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 13 ), combinedOverlay, combinedLight, 0, -1, 0);
|
||||
addVertex( buffer, ms, 1.0f - TwoPx, middle + press, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 13 ), combinedOverlay, combinedLight, 0, -1, 0);
|
||||
addVertex( buffer, ms, 1.0f - TwoPx, middle + press, 1.0f - TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 2 ), combinedOverlay, combinedLight, 0, -1, 0);
|
||||
addVertex( buffer, ms, TwoPx, middle + press, 1.0f - TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 2 ), combinedOverlay, combinedLight, 0, -1, 0);
|
||||
|
||||
// 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 Top Stamp
|
||||
addVertex( buffer, ms, TwoPx, middle + base, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 3 - 16 * ( press - base ) ), combinedOverlay, combinedLight, 0, 0, -1);
|
||||
addVertex( buffer, ms, 1.0f - TwoPx, middle + base, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 3 - 16 * ( press - base ) ), combinedOverlay, combinedLight, 0, 0, -1);
|
||||
addVertex( buffer, ms, 1.0f - TwoPx, middle + press, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 3 ), combinedOverlay, combinedLight, 0, 0, -1);
|
||||
addVertex( buffer, ms, TwoPx, middle + press, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 3 ), combinedOverlay, combinedLight, 0, 0, -1);
|
||||
|
||||
// Top of Bottom Stamp
|
||||
middle -= 2.0f * 0.02f;
|
||||
addVertex( buffer, ms, 1.0f - TwoPx, middle - press, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 13 ), combinedOverlay, combinedLight, 0, 1, 0);
|
||||
addVertex( buffer, ms, TwoPx, middle - press, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 13 ), combinedOverlay, combinedLight, 0, 1, 0);
|
||||
addVertex( buffer, ms, TwoPx, middle - press, 1.0f - TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 2 ), combinedOverlay, combinedLight, 0, 1, 0);
|
||||
addVertex( buffer, ms, 1.0f - TwoPx, middle - press, 1.0f - TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 2 ), combinedOverlay, combinedLight, 0, 1, 0);
|
||||
|
||||
// Front of Bottom Stamp
|
||||
addVertex( buffer, ms, 1.0f - TwoPx, middle + -base, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 3 - 16 * ( press - base ) ), combinedOverlay, combinedLight, 0, 0, -1);
|
||||
addVertex( buffer, ms, TwoPx, middle - base, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 3 - 16 * ( press - base ) ), combinedOverlay, combinedLight, 0, 0, -1);
|
||||
addVertex( buffer, ms, TwoPx, middle - press, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 14 ), tas.getInterpolatedV( 3 ), combinedOverlay, combinedLight, 0, 0, -1);
|
||||
addVertex( buffer, ms, 1.0f - TwoPx, middle - press, TwoPx, 1, 1, 1, 1, tas.getInterpolatedU( 2 ), tas.getInterpolatedV( 3 ), combinedOverlay, combinedLight, 0, 0, -1);
|
||||
|
||||
// render items.
|
||||
// FIXME RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
IItemHandler tileInv = tile.getInternalInventory();
|
||||
|
||||
@@ -152,7 +148,7 @@ public final class InscriberTESR extends TileEntityRenderer<TileInscriber>
|
||||
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
final IInscriberRecipe ir = tile.getTask();
|
||||
final InscriberRecipe ir = tile.getTask();
|
||||
if( ir != null )
|
||||
{
|
||||
is = ir.getOutput().copy();
|
||||
@@ -169,8 +165,16 @@ public final class InscriberTESR extends TileEntityRenderer<TileInscriber>
|
||||
}
|
||||
|
||||
ms.pop();
|
||||
// FIXME RenderSystem.enableLighting();
|
||||
// FIXME GlStateManager.enableRescaleNormal();
|
||||
}
|
||||
|
||||
private static void addVertex(IVertexBuilder vb, MatrixStack ms, float x, float y, float z, float red, float green, float blue, float alpha, float texU, float texV, int overlayUV, int lightmapUV, float normalX, float normalY, float normalZ) {
|
||||
vb.pos(ms.getLast().getMatrix(), x, y, z);
|
||||
vb.color(red, green, blue, alpha);
|
||||
vb.tex(texU, texV);
|
||||
vb.overlay(overlayUV);
|
||||
vb.lightmap(lightmapUV);
|
||||
vb.normal(ms.getLast().getNormal(), normalX, normalY, normalZ);
|
||||
vb.endVertex();
|
||||
}
|
||||
|
||||
private void renderItem( MatrixStack ms, final ItemStack stack, final float o, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay )
|
||||
@@ -197,8 +201,10 @@ public final class InscriberTESR extends TileEntityRenderer<TileInscriber>
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerTexture( TextureStitchEvent.Pre event )
|
||||
public static void registerTexture( TextureStitchEvent.Pre evt )
|
||||
{
|
||||
// FIXME textureInside = event.getMap().registerSprite( TEXTURE_INSIDE );
|
||||
if (evt.getMap().getTextureLocation().equals(TEXTURE_INSIDE.getAtlasLocation())) {
|
||||
evt.addSprite(TEXTURE_INSIDE.getTextureLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user