More Rendering fixes

This commit is contained in:
Sebastian Hartte
2020-06-08 18:35:27 +02:00
parent 679ea1c332
commit b2afa0398c
44 changed files with 427 additions and 276 deletions
@@ -20,6 +20,7 @@ package appeng.client.render.crafting;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.tile.crafting.CraftingCubeModelData;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
import net.minecraft.block.BlockState;
@@ -249,13 +250,11 @@ abstract class CraftingCubeBakedModel implements IDynamicBakedModel
// If none is present, just assume there are no adjacent crafting cube blocks
private static EnumSet<Direction> getConnections( IModelData modelData )
{
CraftingCubeState cubeState = modelData.getData( TileCraftingTile.STATE );
if( cubeState == null )
{
return EnumSet.noneOf( Direction.class );
if (!(modelData instanceof CraftingCubeModelData)) {
return EnumSet.noneOf(Direction.class);
}
return cubeState.getConnections();
return ((CraftingCubeModelData) modelData).getConnections();
}
protected abstract void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2);
@@ -19,13 +19,10 @@
package appeng.client.render.crafting;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import appeng.core.AppEng;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -35,62 +32,12 @@ import net.minecraftforge.api.distmarker.OnlyIn;
*/
public class CraftingCubeRendering extends BlockRenderingCustomizer
{
private final String registryName;
private final AbstractCraftingUnitBlock.CraftingUnitType type;
public CraftingCubeRendering( String registryName, AbstractCraftingUnitBlock.CraftingUnitType type )
{
this.registryName = registryName;
this.type = type;
}
@Override
@OnlyIn( Dist.CLIENT )
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
if (type != AbstractCraftingUnitBlock.CraftingUnitType.MONITOR) {
rendering.renderType(RenderType.getCutout());
}
ResourceLocation baseName = new ResourceLocation( AppEng.MOD_ID, this.registryName );
rendering.renderType(RenderType.getCutout());
// Disable auto-rotation
if( this.type != AbstractCraftingUnitBlock.CraftingUnitType.MONITOR )
{
rendering.modelCustomizer( ( loc, model ) -> model );
}
// FIXME // This is the standard blockstate model
// FIXME ModelResourceLocation defaultModel = new ModelResourceLocation( baseName, "normal" );
// FIXME
// FIXME // This is the built-in model
// FIXME String builtInName = "models/block/crafting/" + this.registryName + "/builtin";
// FIXME ModelResourceLocation builtInModelName = new ModelResourceLocation( new ResourceLocation( AppEng.MOD_ID, builtInName ), "normal" );
// FIXME
// FIXME rendering.builtInModel( builtInName, new CraftingCubeModel( this.type ) );
// FIXME
// FIXME rendering.stateMapper( block -> this.mapState( block, defaultModel, builtInModelName ) );
rendering.modelCustomizer( ( loc, model ) -> model );
}
// FIXME private Map<BlockState, ModelResourceLocation> mapState( Block block, ModelResourceLocation defaultModel, ModelResourceLocation formedModel )
// FIXME {
// FIXME Map<BlockState, ModelResourceLocation> result = new HashMap<>();
// FIXME for( BlockState state : block.getBlockState().getValidStates() )
// FIXME {
// FIXME if( state.get( AbstractCraftingUnitBlock.FORMED ) )
// FIXME {
// FIXME // Always use the builtin model if the multiblock is formed
// FIXME result.put( state, formedModel );
// FIXME }
// FIXME else
// FIXME {
// FIXME // Use the default model
// FIXME result.put( state, defaultModel );
// FIXME }
// FIXME }
// FIXME return result;
// FIXME }
}
@@ -1,45 +0,0 @@
/*
* 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 java.util.EnumSet;
import net.minecraft.util.Direction;
/**
* Transports the rendering state for a block of a crafting cube.
*/
public final class CraftingCubeState
{
// Contains information on which sides of the block are connected to other parts of a formed crafting cube
private final EnumSet<Direction> connections;
public CraftingCubeState( EnumSet<Direction> connections )
{
this.connections = connections;
}
public EnumSet<Direction> getConnections()
{
return this.connections;
}
}
@@ -19,17 +19,23 @@
package appeng.client.render.crafting;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.core.Api;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.render.TesrRenderHelper;
import appeng.tile.crafting.TileCraftingMonitorTile;
import net.minecraftforge.registries.ForgeRegistries;
/**
@@ -49,14 +55,15 @@ public class CraftingMonitorTESR extends TileEntityRenderer<TileCraftingMonitorT
Direction facing = te.getForward();
IAEItemStack jobProgress = te.getJobProgress();
if( jobProgress != null )
{
matrixStack.push();
matrixStack.translate(0.5, 0.5, 0.5);
matrixStack.translate(0.5, 0.5, 0.5); // Move to the center of the block
TesrRenderHelper.moveToFace( matrixStack, facing );
TesrRenderHelper.rotateToFace( matrixStack, facing, (byte) 0 );
TesrRenderHelper.renderItem2dWithAmount(matrixStack, buffers, jobProgress, 0.7f, 0.1f );
matrixStack.translate(0, 0.08, 0.5);
TesrRenderHelper.renderItem2dWithAmount(matrixStack, buffers, jobProgress, 0.3f, -0.18f, 15728880, combinedOverlay);
matrixStack.pop();
}
@@ -22,7 +22,8 @@ package appeng.client.render.crafting;
import appeng.api.util.AEColor;
import appeng.block.crafting.BlockCraftingMonitor;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.tile.crafting.TileCraftingMonitorTile;
import appeng.client.render.model.AEModelData;
import appeng.tile.crafting.CraftingMonitorModelData;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Direction;
@@ -36,7 +37,7 @@ import net.minecraftforge.client.model.data.IModelData;
* color. The textures
* are full-bright if the cube is powered.
*/
class MonitorBakedModel extends CraftingCubeBakedModel
public class MonitorBakedModel extends CraftingCubeBakedModel
{
private final TextureAtlasSprite chassisTexture;
@@ -96,21 +97,16 @@ class MonitorBakedModel extends CraftingCubeBakedModel
}
private static AEColor getColor(IModelData modelData) {
AEColor color = modelData.getData(TileCraftingMonitorTile.COLOR);
if (color != null) {
return color;
if (modelData instanceof CraftingMonitorModelData) {
return ((CraftingMonitorModelData) modelData).getColor();
}
return AEColor.TRANSPARENT;
}
private static Direction getForward(IModelData modelData) {
Direction forward = modelData.getData(BlockCraftingMonitor.FORWARD);
if (forward != null) {
return forward;
if (modelData instanceof AEModelData) {
return ((AEModelData) modelData).getForward();
}
return Direction.NORTH;
}
}