More compile things
This commit is contained in:
@@ -75,6 +75,7 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
//TODO, pass generic up here for Container
|
||||
public abstract class AEBaseGui extends ContainerScreen<AEBaseContainer>
|
||||
{
|
||||
private final List<InternalSlotME> meSlots = new ArrayList<>();
|
||||
|
||||
@@ -71,7 +71,7 @@ public class GuiUpgradeable extends AEBaseGui
|
||||
|
||||
protected boolean hasToolbox()
|
||||
{
|
||||
return ( (ContainerUpgradeable) this.inventorySlots ).hasToolbox();
|
||||
return ( (ContainerUpgradeable) this.container ).hasToolbox();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.client.gui.widgets;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -30,13 +31,13 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GuiTabButton extends Button implements ITooltip
|
||||
{
|
||||
private final RenderItem itemRenderer;
|
||||
private final ItemRenderer itemRenderer;
|
||||
private final String message;
|
||||
private int hideEdge = 0;
|
||||
private int myIcon = -1;
|
||||
private ItemStack myItem;
|
||||
|
||||
public GuiTabButton( final int x, final int y, final int ico, final String message, final RenderItem ir )
|
||||
public GuiTabButton( final int x, final int y, final int ico, final String message, final ItemRenderer ir )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
|
||||
@@ -58,7 +59,7 @@ public class GuiTabButton extends Button implements ITooltip
|
||||
* @param message mouse over message
|
||||
* @param ir renderer
|
||||
*/
|
||||
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final RenderItem ir )
|
||||
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
this.x = x;
|
||||
|
||||
@@ -21,15 +21,18 @@ package appeng.client.render;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
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.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
|
||||
import appeng.client.render.cablebus.FacadeBuilder;
|
||||
import appeng.core.AppEng;
|
||||
@@ -39,47 +42,29 @@ import appeng.core.AppEng;
|
||||
* The model class for facades. Since facades wrap existing models, they don't declare any dependencies here other
|
||||
* than the cable anchor.
|
||||
*/
|
||||
public class FacadeItemModel implements IModel
|
||||
public class FacadeItemModel implements IUnbakedModel
|
||||
{
|
||||
// We use this to get the default item transforms and make our lives easier
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/facade_base" );
|
||||
|
||||
private IModel getBaseModel()
|
||||
{
|
||||
try
|
||||
{
|
||||
return ModelLoaderRegistry.getModel( MODEL_BASE );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
return Collections.singleton( MODEL_BASE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
|
||||
{
|
||||
IBakedModel bakedBaseModel = this.getBaseModel().bake( state, format, bakedTextureGetter );
|
||||
IBakedModel bakedBaseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
|
||||
FacadeBuilder facadeBuilder = new FacadeBuilder();
|
||||
|
||||
return new FacadeDispatcherBakedModel( bakedBaseModel, facadeBuilder );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return this.getBaseModel().getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,34 +1,29 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
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.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
|
||||
import appeng.api.implementations.items.IBiometricCard;
|
||||
import appeng.api.util.AEColor;
|
||||
@@ -39,8 +34,6 @@ import appeng.core.AELog;
|
||||
class BiometricCardBakedModel implements IBakedModel
|
||||
{
|
||||
|
||||
private final VertexFormat format;
|
||||
|
||||
private final IBakedModel baseModel;
|
||||
|
||||
private final TextureAtlasSprite texture;
|
||||
@@ -51,14 +44,13 @@ class BiometricCardBakedModel implements IBakedModel
|
||||
|
||||
private final ImmutableList<BakedQuad> generalQuads;
|
||||
|
||||
BiometricCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture )
|
||||
BiometricCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture )
|
||||
{
|
||||
this( format, baseModel, texture, 0, createCache() );
|
||||
this( baseModel, texture, 0, createCache() );
|
||||
}
|
||||
|
||||
private BiometricCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture, int hash, Cache<Integer, BiometricCardBakedModel> modelCache )
|
||||
private BiometricCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture, int hash, Cache<Integer, BiometricCardBakedModel> modelCache )
|
||||
{
|
||||
this.format = format;
|
||||
this.baseModel = baseModel;
|
||||
this.texture = texture;
|
||||
this.hash = hash;
|
||||
@@ -68,16 +60,14 @@ class BiometricCardBakedModel implements IBakedModel
|
||||
|
||||
private static Cache<Integer, BiometricCardBakedModel> createCache()
|
||||
{
|
||||
return CacheBuilder.newBuilder()
|
||||
.maximumSize( 100 )
|
||||
.build();
|
||||
return CacheBuilder.newBuilder().maximumSize( 100 ).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand )
|
||||
{
|
||||
|
||||
List<BakedQuad> quads = this.baseModel.getQuads( state, side, rand );
|
||||
List<BakedQuad> quads = this.baseModel.getQuads( state, side, rand, EmptyModelData.INSTANCE );
|
||||
|
||||
if( side != null )
|
||||
{
|
||||
@@ -92,7 +82,7 @@ class BiometricCardBakedModel implements IBakedModel
|
||||
|
||||
private List<BakedQuad> buildGeneralQuads()
|
||||
{
|
||||
CubeBuilder builder = new CubeBuilder( this.format );
|
||||
CubeBuilder builder = new CubeBuilder();
|
||||
|
||||
builder.setTexture( this.texture );
|
||||
|
||||
@@ -125,8 +115,7 @@ class BiometricCardBakedModel implements IBakedModel
|
||||
else
|
||||
{
|
||||
final float scale = 0.3f / 255.0f;
|
||||
builder.setColorRGB( ( ( col.blackVariant >> 16 ) & 0xff ) * scale, ( ( col.blackVariant >> 8 ) & 0xff ) * scale,
|
||||
( col.blackVariant & 0xff ) * scale );
|
||||
builder.setColorRGB( ( ( col.blackVariant >> 16 ) & 0xff ) * scale, ( ( col.blackVariant >> 8 ) & 0xff ) * scale, ( col.blackVariant & 0xff ) * scale );
|
||||
}
|
||||
|
||||
builder.addCube( 4 + x, 6 + y, 7.5f, 4 + x + 1, 6 + y + 1, 8.5f );
|
||||
@@ -147,6 +136,12 @@ class BiometricCardBakedModel implements IBakedModel
|
||||
return this.baseModel.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230044_c_()
|
||||
{
|
||||
return false;//TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
@@ -168,10 +163,10 @@ class BiometricCardBakedModel implements IBakedModel
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return new ItemOverrideList( Collections.emptyList() )
|
||||
return new ItemOverrideList()
|
||||
{
|
||||
@Override
|
||||
public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity )
|
||||
public IBakedModel getModelWithOverrides( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity )
|
||||
{
|
||||
String username = "";
|
||||
if( stack.getItem() instanceof IBiometricCard )
|
||||
@@ -199,8 +194,7 @@ class BiometricCardBakedModel implements IBakedModel
|
||||
|
||||
try
|
||||
{
|
||||
return BiometricCardBakedModel.this.modelCache.get( hash,
|
||||
() -> new BiometricCardBakedModel( BiometricCardBakedModel.this.format, BiometricCardBakedModel.this.baseModel, BiometricCardBakedModel.this.texture, hash, BiometricCardBakedModel.this.modelCache ) );
|
||||
return BiometricCardBakedModel.this.modelCache.get( hash, () -> new BiometricCardBakedModel( BiometricCardBakedModel.this.baseModel, BiometricCardBakedModel.this.texture, hash, BiometricCardBakedModel.this.modelCache ) );
|
||||
}
|
||||
catch( ExecutionException e )
|
||||
{
|
||||
@@ -212,15 +206,15 @@ class BiometricCardBakedModel implements IBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type )
|
||||
public boolean doesHandlePerspectives()
|
||||
{
|
||||
// Delegate to the base model if possible
|
||||
if( this.baseModel instanceof IBakedModel )
|
||||
{
|
||||
IBakedModel pam = this.baseModel;
|
||||
Pair<? extends IBakedModel, Matrix4f> pair = pam.handlePerspective( type );
|
||||
return Pair.of( this, pair.getValue() );
|
||||
}
|
||||
return Pair.of( this, TRSRTransformation.identity().getMatrix() );
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat )
|
||||
{
|
||||
baseModel.handlePerspective( cameraTransformType, mat );
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
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.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@@ -22,11 +25,11 @@ import appeng.core.AppEng;
|
||||
* Model wrapper for the biometric card item model, which combines a base card layer with a "visual hash" of the player
|
||||
* name
|
||||
*/
|
||||
public class BiometricCardModel implements IModel
|
||||
public class BiometricCardModel implements IUnbakedModel
|
||||
{
|
||||
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/biometric_card" );
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation( AppEng.MOD_ID, "items/biometric_card_hash" );
|
||||
private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/biometric_card_hash" ) );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
@@ -35,37 +38,19 @@ public class BiometricCardModel implements IModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
{
|
||||
return Collections.singletonList( TEXTURE );
|
||||
return Collections.singleton( TEXTURE );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
|
||||
{
|
||||
TextureAtlasSprite texture = bakedTextureGetter.apply( TEXTURE );
|
||||
TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
|
||||
|
||||
IBakedModel baseModel = this.getBaseModel( state, format, bakedTextureGetter );
|
||||
IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
|
||||
|
||||
return new BiometricCardBakedModel( format, baseModel, texture );
|
||||
}
|
||||
|
||||
private IBakedModel getBaseModel( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
// Load the base model
|
||||
try
|
||||
{
|
||||
return ModelLoaderRegistry.getModel( MODEL_BASE ).bake( state, format, bakedTextureGetter );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
return new BiometricCardBakedModel( baseModel, texture );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
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.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
|
||||
|
||||
class ColorApplicatorBakedModel implements IBakedModel
|
||||
@@ -29,16 +26,16 @@ class ColorApplicatorBakedModel implements IBakedModel
|
||||
|
||||
private final IBakedModel baseModel;
|
||||
|
||||
private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms;
|
||||
private final IModelTransform transforms;
|
||||
|
||||
private final EnumMap<Direction, List<BakedQuad>> quadsBySide;
|
||||
|
||||
private final List<BakedQuad> generalQuads;
|
||||
|
||||
ColorApplicatorBakedModel( IBakedModel baseModel, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> map, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright )
|
||||
ColorApplicatorBakedModel( IBakedModel baseModel, IModelTransform transforms, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright )
|
||||
{
|
||||
this.baseModel = baseModel;
|
||||
this.transforms = map;
|
||||
this.transforms = transforms;
|
||||
|
||||
// Put the tint indices in... Since this is an item model, we are ignoring rand
|
||||
this.generalQuads = this.fixQuadTint( null, texDark, texMedium, texBright );
|
||||
@@ -51,21 +48,21 @@ class ColorApplicatorBakedModel implements IBakedModel
|
||||
|
||||
private List<BakedQuad> fixQuadTint( Direction facing, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright )
|
||||
{
|
||||
List<BakedQuad> quads = this.baseModel.getQuads( null, facing, 0 );
|
||||
List<BakedQuad> quads = this.baseModel.getQuads( null, facing, new Random( 0 ), EmptyModelData.INSTANCE );
|
||||
List<BakedQuad> result = new ArrayList<>( quads.size() );
|
||||
for( BakedQuad quad : quads )
|
||||
{
|
||||
int tint;
|
||||
|
||||
if( quad.getSprite() == texDark )
|
||||
if( quad.func_187508_a() == texDark )
|
||||
{
|
||||
tint = 1;
|
||||
}
|
||||
else if( quad.getSprite() == texMedium )
|
||||
else if( quad.func_187508_a() == texMedium )
|
||||
{
|
||||
tint = 2;
|
||||
}
|
||||
else if( quad.getSprite() == texBright )
|
||||
else if( quad.func_187508_a() == texBright )
|
||||
{
|
||||
tint = 3;
|
||||
}
|
||||
@@ -75,8 +72,7 @@ class ColorApplicatorBakedModel implements IBakedModel
|
||||
continue;
|
||||
}
|
||||
|
||||
BakedQuad newQuad = new BakedQuad( quad.getVertexData(), tint, quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad
|
||||
.getFormat() );
|
||||
BakedQuad newQuad = new BakedQuad( quad.getVertexData(), tint, quad.getFace(), quad.func_187508_a(), quad.shouldApplyDiffuseLighting() );
|
||||
result.add( newQuad );
|
||||
}
|
||||
|
||||
@@ -84,7 +80,7 @@ class ColorApplicatorBakedModel implements IBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand )
|
||||
{
|
||||
if( side == null )
|
||||
{
|
||||
@@ -105,6 +101,12 @@ class ColorApplicatorBakedModel implements IBakedModel
|
||||
return this.baseModel.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230044_c_()
|
||||
{
|
||||
return false;//TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
@@ -130,8 +132,8 @@ class ColorApplicatorBakedModel implements IBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type )
|
||||
public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat )
|
||||
{
|
||||
return PerspectiveMapWrapper.handlePerspective( this, this.transforms, type );
|
||||
return PerspectiveMapWrapper.handlePerspective( this, transforms, cameraTransformType, mat );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
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.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@@ -27,14 +27,14 @@ import appeng.core.AppEng;
|
||||
* A color applicator uses the base model, and extends it with additional layers that are colored according to the
|
||||
* selected color of the applicator.
|
||||
*/
|
||||
public class ColorApplicatorModel implements IModel
|
||||
public class ColorApplicatorModel implements IUnbakedModel
|
||||
{
|
||||
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/color_applicator_colored" );
|
||||
|
||||
private static final ResourceLocation TEXTURE_DARK = new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_dark" );
|
||||
private static final ResourceLocation TEXTURE_MEDIUM = new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_medium" );
|
||||
private static final ResourceLocation TEXTURE_BRIGHT = new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_bright" );
|
||||
private static final Material TEXTURE_DARK = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_dark" ) );
|
||||
private static final Material TEXTURE_MEDIUM = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_medium" ) );
|
||||
private static final Material TEXTURE_BRIGHT = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_bright" ) );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
@@ -43,44 +43,21 @@ public class ColorApplicatorModel implements IModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
{
|
||||
return ImmutableList.of(
|
||||
TEXTURE_DARK,
|
||||
TEXTURE_MEDIUM,
|
||||
TEXTURE_BRIGHT );
|
||||
return Arrays.asList( TEXTURE_DARK, TEXTURE_MEDIUM, TEXTURE_DARK );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
|
||||
{
|
||||
IBakedModel baseModel = this.getBaseModel( state, format, bakedTextureGetter );
|
||||
IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
|
||||
|
||||
TextureAtlasSprite texDark = bakedTextureGetter.apply( TEXTURE_DARK );
|
||||
TextureAtlasSprite texMedium = bakedTextureGetter.apply( TEXTURE_MEDIUM );
|
||||
TextureAtlasSprite texBright = bakedTextureGetter.apply( TEXTURE_BRIGHT );
|
||||
TextureAtlasSprite texDark = spriteGetterIn.apply( TEXTURE_DARK );
|
||||
TextureAtlasSprite texMedium = spriteGetterIn.apply( TEXTURE_MEDIUM );
|
||||
TextureAtlasSprite texBright = spriteGetterIn.apply( TEXTURE_BRIGHT );
|
||||
|
||||
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> map = PerspectiveMapWrapper.getTransforms( state );
|
||||
|
||||
return new ColorApplicatorBakedModel( baseModel, map, texDark, texMedium, texBright );
|
||||
}
|
||||
|
||||
private IBakedModel getBaseModel( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
// Load the base model
|
||||
try
|
||||
{
|
||||
return ModelLoaderRegistry.getModel( MODEL_BASE ).bake( state, format, bakedTextureGetter );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
return new ColorApplicatorBakedModel( baseModel, transformIn, texDark, texMedium, texBright );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
@@ -6,29 +5,29 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
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.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.util.AEColor;
|
||||
@@ -43,8 +42,6 @@ class MemoryCardBakedModel implements IBakedModel
|
||||
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
|
||||
};
|
||||
|
||||
private final VertexFormat format;
|
||||
|
||||
private final IBakedModel baseModel;
|
||||
|
||||
private final TextureAtlasSprite texture;
|
||||
@@ -55,14 +52,13 @@ class MemoryCardBakedModel implements IBakedModel
|
||||
|
||||
private final ImmutableList<BakedQuad> generalQuads;
|
||||
|
||||
MemoryCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture )
|
||||
MemoryCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture )
|
||||
{
|
||||
this( format, baseModel, texture, DEFAULT_COLOR_CODE, createCache() );
|
||||
this( baseModel, texture, DEFAULT_COLOR_CODE, createCache() );
|
||||
}
|
||||
|
||||
private MemoryCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture, AEColor[] hash, Cache<CacheKey, MemoryCardBakedModel> modelCache )
|
||||
private MemoryCardBakedModel( IBakedModel baseModel, TextureAtlasSprite texture, AEColor[] hash, Cache<CacheKey, MemoryCardBakedModel> modelCache )
|
||||
{
|
||||
this.format = format;
|
||||
this.baseModel = baseModel;
|
||||
this.texture = texture;
|
||||
this.colorCode = hash;
|
||||
@@ -72,16 +68,14 @@ class MemoryCardBakedModel implements IBakedModel
|
||||
|
||||
private static Cache<CacheKey, MemoryCardBakedModel> createCache()
|
||||
{
|
||||
return CacheBuilder.newBuilder()
|
||||
.maximumSize( 100 )
|
||||
.build();
|
||||
return CacheBuilder.newBuilder().maximumSize( 100 ).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand )
|
||||
{
|
||||
|
||||
List<BakedQuad> quads = this.baseModel.getQuads( state, side, rand );
|
||||
List<BakedQuad> quads = this.baseModel.getQuads( state, side, rand, EmptyModelData.INSTANCE );
|
||||
|
||||
if( side != null )
|
||||
{
|
||||
@@ -96,7 +90,7 @@ class MemoryCardBakedModel implements IBakedModel
|
||||
|
||||
private List<BakedQuad> buildGeneralQuads()
|
||||
{
|
||||
CubeBuilder builder = new CubeBuilder( this.format );
|
||||
CubeBuilder builder = new CubeBuilder();
|
||||
|
||||
builder.setTexture( this.texture );
|
||||
|
||||
@@ -126,6 +120,12 @@ class MemoryCardBakedModel implements IBakedModel
|
||||
return this.baseModel.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230044_c_()
|
||||
{
|
||||
return false;//TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
@@ -147,10 +147,10 @@ class MemoryCardBakedModel implements IBakedModel
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return new ItemOverrideList( Collections.emptyList() )
|
||||
return new ItemOverrideList()
|
||||
{
|
||||
@Override
|
||||
public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity )
|
||||
public IBakedModel getModelWithOverrides( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -160,7 +160,7 @@ class MemoryCardBakedModel implements IBakedModel
|
||||
final AEColor[] colors = memoryCard.getColorCode( stack );
|
||||
|
||||
return MemoryCardBakedModel.this.modelCache.get( new CacheKey( colors ),
|
||||
() -> new MemoryCardBakedModel( MemoryCardBakedModel.this.format, MemoryCardBakedModel.this.baseModel, MemoryCardBakedModel.this.texture, colors, MemoryCardBakedModel.this.modelCache ) );
|
||||
() -> new MemoryCardBakedModel( MemoryCardBakedModel.this.baseModel, MemoryCardBakedModel.this.texture, colors, MemoryCardBakedModel.this.modelCache ) );
|
||||
}
|
||||
}
|
||||
catch( ExecutionException e )
|
||||
@@ -171,20 +171,13 @@ class MemoryCardBakedModel implements IBakedModel
|
||||
return MemoryCardBakedModel.this;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type )
|
||||
public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat )
|
||||
{
|
||||
// Delegate to the base model if possible
|
||||
if( this.baseModel instanceof IBakedModel )
|
||||
{
|
||||
IBakedModel pam = this.baseModel;
|
||||
Pair<? extends IBakedModel, Matrix4f> pair = pam.handlePerspective( type );
|
||||
return Pair.of( this, pair.getValue() );
|
||||
}
|
||||
return Pair.of( this, TRSRTransformation.identity().getMatrix() );
|
||||
baseModel.handlePerspective( cameraTransformType, mat );
|
||||
return this;
|
||||
}
|
||||
|
||||
private static class CacheKey
|
||||
@@ -223,6 +216,5 @@ class MemoryCardBakedModel implements IBakedModel
|
||||
CacheKey other = (CacheKey) obj;
|
||||
return Arrays.equals( this.key, other.key );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
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.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@@ -21,11 +24,11 @@ import appeng.core.AppEng;
|
||||
/**
|
||||
* Model wrapper for the memory card item model, which combines a base card layer with a "visual hash" of the part/tile.
|
||||
*/
|
||||
public class MemoryCardModel implements IModel
|
||||
public class MemoryCardModel implements IUnbakedModel
|
||||
{
|
||||
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/memory_card" );
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation( AppEng.MOD_ID, "items/memory_card_hash" );
|
||||
private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/memory_card_hash" ) );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
@@ -34,37 +37,19 @@ public class MemoryCardModel implements IModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
{
|
||||
return Collections.singletonList( TEXTURE );
|
||||
return Collections.singleton( TEXTURE );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
|
||||
{
|
||||
TextureAtlasSprite texture = bakedTextureGetter.apply( TEXTURE );
|
||||
TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
|
||||
|
||||
IBakedModel baseModel = this.getBaseModel( state, format, bakedTextureGetter );
|
||||
IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
|
||||
|
||||
return new MemoryCardBakedModel( format, baseModel, texture );
|
||||
}
|
||||
|
||||
private IBakedModel getBaseModel( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
// Load the base model
|
||||
try
|
||||
{
|
||||
return ModelLoaderRegistry.getModel( MODEL_BASE ).bake( state, format, bakedTextureGetter );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity().toItemTransform();
|
||||
return new MemoryCardBakedModel( baseModel, texture );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user