More compile things
This commit is contained in:
@@ -29,13 +29,10 @@ import com.google.common.base.Preconditions;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
|
||||
import appeng.client.render.VertexFormats;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
|
||||
|
||||
/**
|
||||
@@ -44,8 +41,6 @@ import appeng.client.render.VertexFormats;
|
||||
public class CubeBuilder
|
||||
{
|
||||
|
||||
private VertexFormat format;
|
||||
|
||||
private final List<BakedQuad> output;
|
||||
|
||||
private final EnumMap<Direction, TextureAtlasSprite> textures = new EnumMap<>( Direction.class );
|
||||
@@ -62,15 +57,14 @@ public class CubeBuilder
|
||||
|
||||
private boolean renderFullBright;
|
||||
|
||||
public CubeBuilder( VertexFormat format, List<BakedQuad> output )
|
||||
public CubeBuilder( List<BakedQuad> output )
|
||||
{
|
||||
this.output = output;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public CubeBuilder( VertexFormat format )
|
||||
public CubeBuilder()
|
||||
{
|
||||
this( format, new ArrayList<>( 6 ) );
|
||||
this( new ArrayList<>( 6 ) );
|
||||
}
|
||||
|
||||
public void addCube( float x1, float y1, float z1, float x2, float y2, float z2 )
|
||||
@@ -82,49 +76,15 @@ public class CubeBuilder
|
||||
y2 /= 16.0f;
|
||||
z2 /= 16.0f;
|
||||
|
||||
// If brightness is forced to specific values, extend the vertex format to contain the multi-texturing lightmap
|
||||
// offset
|
||||
VertexFormat savedFormat = null;
|
||||
if( this.renderFullBright )
|
||||
{
|
||||
savedFormat = this.format;
|
||||
this.format = VertexFormats.getFormatWithLightMap( this.format );
|
||||
}
|
||||
|
||||
for( Direction face : this.drawFaces )
|
||||
{
|
||||
this.putFace( face, x1, y1, z1, x2, y2, z2 );
|
||||
}
|
||||
|
||||
// Restore old format
|
||||
if( savedFormat != null )
|
||||
{
|
||||
this.format = savedFormat;
|
||||
}
|
||||
}
|
||||
|
||||
public void addQuad( Direction face, float x1, float y1, float z1, float x2, float y2, float z2 )
|
||||
{
|
||||
// If brightness is forced to specific values, extend the vertex format to contain the multi-texturing lightmap
|
||||
// offset
|
||||
VertexFormat savedFormat = null;
|
||||
if( this.renderFullBright )
|
||||
{
|
||||
savedFormat = this.format;
|
||||
this.format = new VertexFormat( savedFormat );
|
||||
if( !this.format.getElements().contains( DefaultVertexFormats.TEX_2S ) )
|
||||
{
|
||||
this.format.addElement( DefaultVertexFormats.TEX_2S );
|
||||
}
|
||||
}
|
||||
|
||||
this.putFace( face, x1, y1, z1, x2, y2, z2 );
|
||||
|
||||
// Restore old format
|
||||
if( savedFormat != null )
|
||||
{
|
||||
this.format = savedFormat;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class UvVector
|
||||
@@ -140,8 +100,7 @@ public class CubeBuilder
|
||||
|
||||
TextureAtlasSprite texture = this.textures.get( face );
|
||||
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder( this.format );
|
||||
builder.setTexture( texture );
|
||||
BakedQuadBuilder builder = new BakedQuadBuilder( texture );
|
||||
builder.setQuadOrientation( face );
|
||||
builder.setQuadTint( -1 );
|
||||
builder.setApplyDiffuseLighting( true );
|
||||
@@ -152,10 +111,10 @@ public class CubeBuilder
|
||||
Vector4f customUv = this.customUv.get( face );
|
||||
if( customUv != null )
|
||||
{
|
||||
uv.u1 = texture.getInterpolatedU( customUv.x );
|
||||
uv.v1 = texture.getInterpolatedV( customUv.y );
|
||||
uv.u2 = texture.getInterpolatedU( customUv.z );
|
||||
uv.v2 = texture.getInterpolatedV( customUv.w );
|
||||
uv.u1 = texture.getInterpolatedU( customUv.getX() );
|
||||
uv.v1 = texture.getInterpolatedV( customUv.getY() );
|
||||
uv.u2 = texture.getInterpolatedU( customUv.getZ() );
|
||||
uv.v2 = texture.getInterpolatedV( customUv.getW() );
|
||||
}
|
||||
else if( this.useStandardUV )
|
||||
{
|
||||
@@ -303,7 +262,7 @@ public class CubeBuilder
|
||||
}
|
||||
|
||||
// uv.u1, uv.v1
|
||||
private void putVertexTL( UnpackedBakedQuad.Builder builder, Direction face, float x, float y, float z, UvVector uv )
|
||||
private void putVertexTL( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv )
|
||||
{
|
||||
float u, v;
|
||||
|
||||
@@ -332,7 +291,7 @@ public class CubeBuilder
|
||||
}
|
||||
|
||||
// uv.u2, uv.v1
|
||||
private void putVertexTR( UnpackedBakedQuad.Builder builder, Direction face, float x, float y, float z, UvVector uv )
|
||||
private void putVertexTR( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv )
|
||||
{
|
||||
float u, v;
|
||||
|
||||
@@ -360,7 +319,7 @@ public class CubeBuilder
|
||||
}
|
||||
|
||||
// uv.u2, uv.v2
|
||||
private void putVertexBR( UnpackedBakedQuad.Builder builder, Direction face, float x, float y, float z, UvVector uv )
|
||||
private void putVertexBR( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv )
|
||||
{
|
||||
|
||||
float u;
|
||||
@@ -391,7 +350,7 @@ public class CubeBuilder
|
||||
}
|
||||
|
||||
// uv.u1, uv.v2
|
||||
private void putVertexBL( UnpackedBakedQuad.Builder builder, Direction face, float x, float y, float z, UvVector uv )
|
||||
private void putVertexBL( BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv )
|
||||
{
|
||||
|
||||
float u;
|
||||
@@ -421,13 +380,14 @@ public class CubeBuilder
|
||||
this.putVertex( builder, face, x, y, z, u, v );
|
||||
}
|
||||
|
||||
private void putVertex( UnpackedBakedQuad.Builder builder, Direction face, float x, float y, float z, float u, float v )
|
||||
private void putVertex( BakedQuadBuilder builder, Direction face, float x, float y, float z, float u, float v )
|
||||
{
|
||||
VertexFormat format = builder.getVertexFormat();
|
||||
|
||||
for( int i = 0; i < format.getElementCount(); i++ )
|
||||
List<VertexFormatElement> elements = format.getElements();
|
||||
for( int i = 0; i < elements.size(); i++ )
|
||||
{
|
||||
VertexFormatElement e = format.getElement( i );
|
||||
VertexFormatElement e = elements.get( i );
|
||||
switch( e.getUsage() )
|
||||
{
|
||||
case POSITION:
|
||||
@@ -449,7 +409,7 @@ public class CubeBuilder
|
||||
{
|
||||
builder.put( i, u, v );
|
||||
}
|
||||
else
|
||||
else if( e.getIndex() == 2 && renderFullBright )
|
||||
{
|
||||
// Force Brightness to 15, this is for full bright mode
|
||||
// this vertex element will only be present in that case
|
||||
|
||||
@@ -4,6 +4,7 @@ package appeng.client.render.cablebus;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
@@ -11,10 +12,9 @@ import com.google.common.cache.CacheBuilder;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import appeng.api.parts.IPartBakedModel;
|
||||
@@ -24,7 +24,6 @@ import appeng.util.Platform;
|
||||
|
||||
public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedModel
|
||||
{
|
||||
private final VertexFormat format;
|
||||
private final TextureAtlasSprite texture;
|
||||
|
||||
private final static Cache<Long, List<BakedQuad>> modelCache = CacheBuilder.newBuilder().maximumSize( 100 ).build();
|
||||
@@ -36,14 +35,13 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
|
||||
{ 10, 4, 2 }
|
||||
};
|
||||
|
||||
public P2PTunnelFrequencyBakedModel( final VertexFormat format, final TextureAtlasSprite texture )
|
||||
public P2PTunnelFrequencyBakedModel( final TextureAtlasSprite texture )
|
||||
{
|
||||
this.format = format;
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getPartQuads( Long partFlags, long rand )
|
||||
public List<BakedQuad> getPartQuads( Long partFlags, Random rand )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -66,7 +64,7 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( BlockState state, Direction side, long rand )
|
||||
public List<BakedQuad> getQuads( BlockState state, Direction side, Random rand )
|
||||
{
|
||||
if( side != null )
|
||||
{
|
||||
@@ -78,7 +76,7 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
|
||||
private List<BakedQuad> getQuadsForFrequency( final short frequency, final boolean active )
|
||||
{
|
||||
final AEColor[] colors = Platform.p2p().toColors( frequency );
|
||||
final CubeBuilder cb = new CubeBuilder( this.format );
|
||||
final CubeBuilder cb = new CubeBuilder();
|
||||
|
||||
cb.setTexture( this.texture );
|
||||
cb.useStandardUV();
|
||||
@@ -122,6 +120,12 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230044_c_()
|
||||
{
|
||||
return false;//TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
|
||||
@@ -1,43 +1,54 @@
|
||||
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
public class P2PTunnelFrequencyModel implements IModel
|
||||
public class P2PTunnelFrequencyModel implements IUnbakedModel
|
||||
{
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation( AppEng.MOD_ID, "parts/p2p_tunnel_frequency" );
|
||||
private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "parts/p2p_tunnel_frequency" ) );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.singletonList( TEXTURE );
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
{
|
||||
return Collections.singleton( TEXTURE );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
|
||||
{
|
||||
try
|
||||
{
|
||||
final TextureAtlasSprite texture = bakedTextureGetter.apply( TEXTURE );
|
||||
return new P2PTunnelFrequencyBakedModel( format, texture );
|
||||
final TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
|
||||
return new P2PTunnelFrequencyBakedModel( texture );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user