All GUI compile errors fixed, switched to excludes over includes in gradle build and lots, LOTS of more fixes.

This commit is contained in:
Sebastian Hartte
2020-06-06 21:16:05 +02:00
parent bb453b0d35
commit ff042a394b
209 changed files with 4527 additions and 4479 deletions
@@ -19,25 +19,20 @@
package appeng.client.render.crafting;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import javax.annotation.Nullable;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
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.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.Direction;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.client.render.cablebus.CubeBuilder;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
/**
@@ -45,38 +40,34 @@ import appeng.client.render.cablebus.CubeBuilder;
* Primarily this base class handles adding the "ring" that frames the multi-block structure and delegates
* rendering of the "inner" part of each block to the subclasses of this class.
*/
abstract class CraftingCubeBakedModel implements IBakedModel
abstract class CraftingCubeBakedModel implements IDynamicBakedModel
{
private final VertexFormat format;
private final TextureAtlasSprite ringCorner;
private final TextureAtlasSprite ringHor;
private final TextureAtlasSprite ringVer;
CraftingCubeBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer )
CraftingCubeBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer )
{
this.format = format;
this.ringCorner = ringCorner;
this.ringHor = ringHor;
this.ringVer = ringVer;
}
@Nonnull
@Override
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
{
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
if( side == null )
{
return Collections.emptyList(); // No generic quads for this model
}
EnumSet<Direction> connections = getConnections( state );
EnumSet<Direction> connections = getConnections( extraData );
List<BakedQuad> quads = new ArrayList<>();
CubeBuilder builder = new CubeBuilder( this.format, quads );
CubeBuilder builder = new CubeBuilder( quads );
builder.setDrawFaces( EnumSet.of( side ) );
@@ -114,7 +105,7 @@ abstract class CraftingCubeBakedModel implements IBakedModel
break;
}
this.addInnerCube( side, state, builder, x1, y1, z1, x2, y2, z2 );
this.addInnerCube( side, state, extraData, builder, x1, y1, z1, x2, y2, z2 );
return quads;
}
@@ -194,7 +185,7 @@ abstract class CraftingCubeBakedModel implements IBakedModel
// drawn in those directions. Since a corner is drawn if the three touching faces dont have adjacent
// crafting cube blocks, we'd have to check for a, side, and the perpendicular direction. But in this
// block, we've already checked for side (due to face culling) and a (see above).
Direction perpendicular = a.rotateAround( side.getAxis() );
Direction perpendicular = Platform.rotateAround( a, side );
for( Direction cornerCandidate : EnumSet.of( perpendicular, perpendicular.getOpposite() ) )
{
if( !connections.contains( cornerCandidate ) )
@@ -256,15 +247,9 @@ abstract class CraftingCubeBakedModel implements IBakedModel
// Retrieve the cube connection state from the block state
// If none is present, just assume there are no adjacent crafting cube blocks
private static EnumSet<Direction> getConnections( @Nullable BlockState state )
private static EnumSet<Direction> getConnections( IModelData modelData )
{
if( !( state instanceof IExtendedBlockState ) )
{
return EnumSet.noneOf( Direction.class );
}
IExtendedBlockState extState = (IExtendedBlockState) state;
CraftingCubeState cubeState = extState.getValue( AbstractCraftingUnitBlock.STATE );
CraftingCubeState cubeState = modelData.getData( TileCraftingTile.STATE );
if( cubeState == null )
{
return EnumSet.noneOf( Direction.class );
@@ -273,7 +258,7 @@ abstract class CraftingCubeBakedModel implements IBakedModel
return cubeState.getConnections();
}
protected abstract void addInnerCube( Direction facing, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 );
protected abstract void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2);
@Override
public boolean isAmbientOcclusion()
@@ -300,14 +285,13 @@ abstract class CraftingCubeBakedModel implements IBakedModel
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
return ItemCameraTransforms.DEFAULT;
public boolean func_230044_c_() {
return false;
}
@Override
public ItemOverrideList getOverrides()
{
public ItemOverrideList getOverrides() {
return ItemOverrideList.EMPTY;
}
}
@@ -19,44 +19,42 @@
package appeng.client.render.crafting;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.renderer.block.model.IBakedModel;
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 net.minecraftforge.common.model.TRSRTransformation;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.core.AppEng;
import com.google.common.collect.ImmutableList;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.model.*;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModelConfiguration;
import net.minecraftforge.client.model.geometry.IModelGeometry;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
/**
* The built-in model for the connected texture crafting cube.
*/
class CraftingCubeModel implements IModel
class CraftingCubeModel implements IModelGeometry<CraftingCubeModel>
{
private final static ResourceLocation RING_CORNER = texture( "ring_corner" );
private final static ResourceLocation RING_SIDE_HOR = texture( "ring_side_hor" );
private final static ResourceLocation RING_SIDE_VER = texture( "ring_side_ver" );
private final static ResourceLocation UNIT_BASE = texture( "unit_base" );
private final static ResourceLocation LIGHT_BASE = texture( "light_base" );
private final static ResourceLocation ACCELERATOR_LIGHT = texture( "accelerator_light" );
private final static ResourceLocation STORAGE_1K_LIGHT = texture( "storage_1k_light" );
private final static ResourceLocation STORAGE_4K_LIGHT = texture( "storage_4k_light" );
private final static ResourceLocation STORAGE_16K_LIGHT = texture( "storage_16k_light" );
private final static ResourceLocation STORAGE_64K_LIGHT = texture( "storage_64k_light" );
private final static ResourceLocation MONITOR_BASE = texture( "monitor_base" );
private final static ResourceLocation MONITOR_LIGHT_DARK = texture( "monitor_light_dark" );
private final static ResourceLocation MONITOR_LIGHT_MEDIUM = texture( "monitor_light_medium" );
private final static ResourceLocation MONITOR_LIGHT_BRIGHT = texture( "monitor_light_bright" );
private final static Material RING_CORNER = texture( "ring_corner" );
private final static Material RING_SIDE_HOR = texture( "ring_side_hor" );
private final static Material RING_SIDE_VER = texture( "ring_side_ver" );
private final static Material UNIT_BASE = texture( "unit_base" );
private final static Material LIGHT_BASE = texture( "light_base" );
private final static Material ACCELERATOR_LIGHT = texture( "accelerator_light" );
private final static Material STORAGE_1K_LIGHT = texture( "storage_1k_light" );
private final static Material STORAGE_4K_LIGHT = texture( "storage_4k_light" );
private final static Material STORAGE_16K_LIGHT = texture( "storage_16k_light" );
private final static Material STORAGE_64K_LIGHT = texture( "storage_64k_light" );
private final static Material MONITOR_BASE = texture( "monitor_base" );
private final static Material MONITOR_LIGHT_DARK = texture( "monitor_light_dark" );
private final static Material MONITOR_LIGHT_MEDIUM = texture( "monitor_light_medium" );
private final static Material MONITOR_LIGHT_BRIGHT = texture( "monitor_light_bright" );
private final AbstractCraftingUnitBlock.CraftingUnitType type;
@@ -66,47 +64,39 @@ class CraftingCubeModel implements IModel
}
@Override
public Collection<ResourceLocation> getDependencies()
{
return Collections.emptyList();
}
@Override
public Collection<ResourceLocation> getTextures()
{
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return ImmutableList.of( RING_CORNER, RING_SIDE_HOR, RING_SIDE_VER, UNIT_BASE, LIGHT_BASE, ACCELERATOR_LIGHT, STORAGE_1K_LIGHT, STORAGE_4K_LIGHT,
STORAGE_16K_LIGHT, STORAGE_64K_LIGHT, MONITOR_BASE, MONITOR_LIGHT_DARK, MONITOR_LIGHT_MEDIUM, MONITOR_LIGHT_BRIGHT );
}
@Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
// Retrieve our textures and pass them on to the baked model
TextureAtlasSprite ringCorner = bakedTextureGetter.apply( RING_CORNER );
TextureAtlasSprite ringSideHor = bakedTextureGetter.apply( RING_SIDE_HOR );
TextureAtlasSprite ringSideVer = bakedTextureGetter.apply( RING_SIDE_VER );
TextureAtlasSprite ringCorner = spriteGetter.apply( RING_CORNER );
TextureAtlasSprite ringSideHor = spriteGetter.apply( RING_SIDE_HOR );
TextureAtlasSprite ringSideVer = spriteGetter.apply( RING_SIDE_VER );
switch( this.type )
{
case UNIT:
return new UnitBakedModel( format, ringCorner, ringSideHor, ringSideVer, bakedTextureGetter.apply( UNIT_BASE ) );
return new UnitBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter.apply( UNIT_BASE ) );
case ACCELERATOR:
case STORAGE_1K:
case STORAGE_4K:
case STORAGE_16K:
case STORAGE_64K:
return new LightBakedModel( format, ringCorner, ringSideHor, ringSideVer, bakedTextureGetter
.apply( LIGHT_BASE ), getLightTexture( bakedTextureGetter, this.type ) );
return new LightBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter
.apply( LIGHT_BASE ), getLightTexture( spriteGetter, this.type ) );
case MONITOR:
return new MonitorBakedModel( format, ringCorner, ringSideHor, ringSideVer, bakedTextureGetter.apply( UNIT_BASE ), bakedTextureGetter
.apply( MONITOR_BASE ), bakedTextureGetter.apply(
MONITOR_LIGHT_DARK ), bakedTextureGetter.apply( MONITOR_LIGHT_MEDIUM ), bakedTextureGetter.apply( MONITOR_LIGHT_BRIGHT ) );
return new MonitorBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter.apply( UNIT_BASE ), spriteGetter
.apply( MONITOR_BASE ), spriteGetter.apply(
MONITOR_LIGHT_DARK ), spriteGetter.apply( MONITOR_LIGHT_MEDIUM ), spriteGetter.apply( MONITOR_LIGHT_BRIGHT ) );
default:
throw new IllegalArgumentException( "Unsupported crafting unit type: " + this.type );
}
}
private static TextureAtlasSprite getLightTexture( Function<ResourceLocation, TextureAtlasSprite> textureGetter, AbstractCraftingUnitBlock.CraftingUnitType type )
private static TextureAtlasSprite getLightTexture( Function<Material, TextureAtlasSprite> textureGetter, AbstractCraftingUnitBlock.CraftingUnitType type )
{
switch( type )
{
@@ -125,14 +115,8 @@ class CraftingCubeModel implements IModel
}
}
@Override
public IModelState getDefaultState()
private static Material texture( String name )
{
return TRSRTransformation.identity();
}
private static ResourceLocation texture( String name )
{
return new ResourceLocation( AppEng.MOD_ID, "blocks/crafting/" + name );
return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "blocks/crafting/" + name));
}
}
@@ -0,0 +1,61 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.crafting;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import net.minecraft.resources.IResourceManager;
import net.minecraftforge.client.model.IModelLoader;
/**
* Loader that allows access to the built-in crafting cube model from block-model JSONs.
*/
public class CraftingCubeModelLoader implements IModelLoader<CraftingCubeModel>
{
public static final CraftingCubeModelLoader INSTANCE = new CraftingCubeModelLoader();
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
}
@Override
public CraftingCubeModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
AbstractCraftingUnitBlock.CraftingUnitType unitType = null;
JsonElement typeEl = modelContents.get("type");
if (typeEl != null) {
String typeName = deserializationContext.deserialize(typeEl, String.class);
if (typeName != null) {
unitType = AbstractCraftingUnitBlock.CraftingUnitType.valueOf(typeName.toUpperCase());
}
}
if (unitType == null) {
throw new JsonParseException("type property is missing");
}
return new CraftingCubeModel(unitType);
}
}
@@ -0,0 +1,25 @@
package appeng.client.render.crafting;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
* This special model handles switching between rendering the crafting output of an encoded pattern (when shift is being
* held), and showing the encoded pattern itself. Matters are further complicated by only wanting to show the crafting output when
* the pattern is being rendered in the GUI, and not anywhere else.
*/
@OnlyIn(Dist.CLIENT)
public class EncodedPatternRenderer extends ItemStackTileEntityRenderer {
@Override
public void render(ItemStack is, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) {
}
}
@@ -1,242 +0,0 @@
package appeng.client.render.crafting;
import java.util.List;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.input.Keyboard;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
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.texture.TextureAtlasSprite;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.world.World;
import net.minecraftforge.client.model.PerspectiveMapWrapper;
import net.minecraftforge.common.model.TRSRTransformation;
import appeng.items.misc.ItemEncodedPattern;
/**
* This special model handles switching between rendering the crafting output of an encoded pattern (when shift is being
* held), and
* showing the encoded pattern itself. Matters are further complicated by only wanting to show the crafting output when
* the pattern is being
* rendered in the GUI, and not anywhere else.
*/
class ItemEncodedPatternBakedModel implements IBakedModel
{
private final IBakedModel baseModel;
private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms;
private final CustomOverrideList overrides;
ItemEncodedPatternBakedModel( IBakedModel baseModel, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms )
{
this.baseModel = baseModel;
this.transforms = transforms;
this.overrides = new CustomOverrideList();
}
@Override
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
{
return this.baseModel.getQuads( state, side, rand );
}
@Override
public boolean isAmbientOcclusion()
{
return this.baseModel.isAmbientOcclusion();
}
@Override
public boolean isGui3d()
{
return this.baseModel.isGui3d();
}
@Override
public boolean isBuiltInRenderer()
{
return this.baseModel.isBuiltInRenderer();
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.baseModel.getParticleTexture();
}
@Override
@Deprecated
public ItemCameraTransforms getItemCameraTransforms()
{
return this.baseModel.getItemCameraTransforms();
}
@Override
public ItemOverrideList getOverrides()
{
return this.overrides;
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType cameraTransformType )
{
if( this.baseModel instanceof IBakedModel )
{
return this.baseModel.handlePerspective( cameraTransformType );
}
return PerspectiveMapWrapper.handlePerspective( this, this.transforms, cameraTransformType );
}
/**
* Since the ItemOverrideList handling comes before handling the perspective awareness (which is the first place
* where we
* know how we are being rendered) we need to remember the model of the crafting output, and make the decision on
* which to render later on.
* Sadly, Forge is pretty inconsistent when it will call the handlePerspective method, so some methods are called
* even on this interim-model.
* Usually those methods only matter for rendering on the ground and other cases, where we wouldn't render the
* crafting output model anyway,
* so in those cases we delegate to the model of the encoded pattern.
*/
private class ShiftHoldingModelWrapper implements IBakedModel
{
private final IBakedModel outputModel;
private ShiftHoldingModelWrapper( IBakedModel outputModel )
{
this.outputModel = outputModel;
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType cameraTransformType )
{
final IBakedModel selectedModel;
// No need to re-check for shift being held since this model is only handed out in that case
if( cameraTransformType == ItemCameraTransforms.TransformType.GUI )
{
selectedModel = this.outputModel;
}
else
{
selectedModel = ItemEncodedPatternBakedModel.this.baseModel;
}
// Now retroactively handle the isGui3d call, for which we always return false below
if( selectedModel.isGui3d() != ItemEncodedPatternBakedModel.this.baseModel.isGui3d() )
{
RenderSystem.enableLighting();
}
if( selectedModel instanceof IBakedModel )
{
return selectedModel.handlePerspective( cameraTransformType );
}
return PerspectiveMapWrapper.handlePerspective( this, ItemEncodedPatternBakedModel.this.transforms, cameraTransformType );
}
@Override
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
{
// This may be called for items on the ground, in which case we will always fall back to the pattern
return ItemEncodedPatternBakedModel.this.baseModel.getQuads( state, side, rand );
}
@Override
public boolean isAmbientOcclusion()
{
return ItemEncodedPatternBakedModel.this.baseModel.isAmbientOcclusion();
}
@Override
public boolean isGui3d()
{
// NOTE: Sadly, Forge will let Minecraft call this method before handling the perspective awareness
return ItemEncodedPatternBakedModel.this.baseModel.isGui3d();
}
@Override
public boolean isBuiltInRenderer()
{
// This may be called for items on the ground, in which case we will always fall back to the pattern
return ItemEncodedPatternBakedModel.this.baseModel.isBuiltInRenderer();
}
@Override
public TextureAtlasSprite getParticleTexture()
{
// This may be called for items on the ground, in which case we will always fall back to the pattern
return ItemEncodedPatternBakedModel.this.baseModel.getParticleTexture();
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
// This may be called for items on the ground, in which case we will always fall back to the pattern
return ItemEncodedPatternBakedModel.this.baseModel.getItemCameraTransforms();
}
@Override
public ItemOverrideList getOverrides()
{
// This may be called for items on the ground, in which case we will always fall back to the pattern
return ItemEncodedPatternBakedModel.this.baseModel.getOverrides();
}
}
/**
* Item Override Lists are the only point during item rendering where we can access the item stack that is being
* rendered.
* So this is the point where we actually check if shift is being held, and if so, determine the crafting output
* model.
*/
private class CustomOverrideList extends ItemOverrideList
{
CustomOverrideList()
{
super( ItemEncodedPatternBakedModel.this.baseModel.getOverrides().getOverrides() );
}
@Override
public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity )
{
boolean shiftHeld = Keyboard.isKeyDown( GLFW.GLFW_KEY_LSHIFT ) || Keyboard.isKeyDown( GLFW.GLFW_KEY_RSHIFT );
if( shiftHeld )
{
ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
ItemStack output = iep.getOutput( stack );
if( !output.isEmpty() )
{
IBakedModel realModel = Minecraft.getInstance().getRenderItem().getItemModelMesher().getItemModel( output );
// Give the item model a chance to handle the overrides as well
realModel = realModel.getOverrides().handleItemState( realModel, output, world, entity );
return new ShiftHoldingModelWrapper( realModel );
}
}
return ItemEncodedPatternBakedModel.this.baseModel.getOverrides().handleItemState( originalModel, stack, world, entity );
}
}
}
@@ -1,68 +0,0 @@
package appeng.client.render.crafting;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
import com.google.common.collect.ImmutableMap;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
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;
/**
* Simple model for the encoded pattern built-in baked model.
*/
class ItemEncodedPatternModel implements IModel
{
private static final ResourceLocation BASE_MODEL = new ResourceLocation( AppEng.MOD_ID, "item/encoded_pattern" );
@Override
public Collection<ResourceLocation> getDependencies()
{
return Collections.singletonList( BASE_MODEL );
}
@Override
public Collection<ResourceLocation> getTextures()
{
return Collections.emptyList();
}
@Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
IBakedModel baseModel;
try
{
baseModel = ModelLoaderRegistry.getModel( BASE_MODEL ).bake( state, format, bakedTextureGetter );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms = PerspectiveMapWrapper.getTransforms( state );
return new ItemEncodedPatternBakedModel( baseModel, transforms );
}
@Override
public IModelState getDefaultState()
{
return TRSRTransformation.identity();
}
}
@@ -26,6 +26,7 @@ import net.minecraft.util.Direction;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.client.render.cablebus.CubeBuilder;
import net.minecraftforge.client.model.data.IModelData;
/**
@@ -39,15 +40,15 @@ class LightBakedModel extends CraftingCubeBakedModel
private final TextureAtlasSprite lightTexture;
LightBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite baseTexture, TextureAtlasSprite lightTexture )
LightBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite baseTexture, TextureAtlasSprite lightTexture )
{
super( format, ringCorner, ringHor, ringVer );
super( ringCorner, ringHor, ringVer );
this.baseTexture = baseTexture;
this.lightTexture = lightTexture;
}
@Override
protected void addInnerCube( Direction facing, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 )
protected void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2)
{
builder.setTexture( this.baseTexture );
builder.addCube( x1, y1, z1, x2, y2, z2 );
@@ -19,15 +19,14 @@
package appeng.client.render.crafting;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.Direction;
import net.minecraftforge.common.property.IExtendedBlockState;
import appeng.api.util.AEColor;
import appeng.block.crafting.BlockCraftingMonitor;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.tile.crafting.TileCraftingMonitorTile;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Direction;
import net.minecraftforge.client.model.data.IModelData;
/**
@@ -50,9 +49,9 @@ class MonitorBakedModel extends CraftingCubeBakedModel
private final TextureAtlasSprite lightBrightTexture;
MonitorBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite chassisTexture, TextureAtlasSprite baseTexture, TextureAtlasSprite lightDarkTexture, TextureAtlasSprite lightMediumTexture, TextureAtlasSprite lightBrightTexture )
MonitorBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite chassisTexture, TextureAtlasSprite baseTexture, TextureAtlasSprite lightDarkTexture, TextureAtlasSprite lightMediumTexture, TextureAtlasSprite lightBrightTexture )
{
super( format, ringCorner, ringHor, ringVer );
super( ringCorner, ringHor, ringVer );
this.chassisTexture = chassisTexture;
this.baseTexture = baseTexture;
this.lightDarkTexture = lightDarkTexture;
@@ -61,9 +60,9 @@ class MonitorBakedModel extends CraftingCubeBakedModel
}
@Override
protected void addInnerCube( Direction side, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 )
protected void addInnerCube(Direction side, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2)
{
Direction forward = getForward( state );
Direction forward = getForward( modelData );
// For sides other than the front, use the chassis texture
if( side != forward )
@@ -77,7 +76,7 @@ class MonitorBakedModel extends CraftingCubeBakedModel
builder.addCube( x1, y1, z1, x2, y2, z2 );
// Now add the three layered light textures
AEColor color = getColor( state );
AEColor color = getColor( modelData );
boolean powered = state.get( BlockCraftingMonitor.POWERED );
builder.setRenderFullBright( powered );
@@ -96,31 +95,20 @@ class MonitorBakedModel extends CraftingCubeBakedModel
}
private static AEColor getColor( BlockState state )
{
if( state instanceof IExtendedBlockState )
{
IExtendedBlockState extState = (IExtendedBlockState) state;
AEColor color = extState.getValue( BlockCraftingMonitor.COLOR );
if( color != null )
{
return color;
}
private static AEColor getColor(IModelData modelData) {
AEColor color = modelData.getData(TileCraftingMonitorTile.COLOR);
if (color != null) {
return color;
}
return AEColor.TRANSPARENT;
}
private static Direction getForward( BlockState state )
{
if( state instanceof IExtendedBlockState )
{
IExtendedBlockState extState = (IExtendedBlockState) state;
Direction forward = extState.getValue( BlockCraftingMonitor.FORWARD );
if( forward != null )
{
return forward;
}
private static Direction getForward(IModelData modelData) {
Direction forward = modelData.getData(BlockCraftingMonitor.FORWARD);
if (forward != null) {
return forward;
}
return Direction.NORTH;
@@ -21,10 +21,10 @@ package appeng.client.render.crafting;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.Direction;
import appeng.client.render.cablebus.CubeBuilder;
import net.minecraftforge.client.model.data.IModelData;
/**
@@ -35,14 +35,14 @@ class UnitBakedModel extends CraftingCubeBakedModel
private final TextureAtlasSprite unitTexture;
UnitBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite unitTexture )
UnitBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite unitTexture )
{
super( format, ringCorner, ringHor, ringVer );
super( ringCorner, ringHor, ringVer );
this.unitTexture = unitTexture;
}
@Override
protected void addInnerCube( Direction facing, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 )
protected void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2)
{
builder.setTexture( this.unitTexture );
builder.addCube( x1, y1, z1, x2, y2, z2 );