More compile things

This commit is contained in:
covers1624
2020-06-02 15:12:30 +09:30
parent 404ef5624b
commit 3f5c299d09
111 changed files with 838 additions and 873 deletions
@@ -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 );
}
}