pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
@@ -18,11 +18,11 @@
package appeng.client.render.crafting;
import java.util.*;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
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;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.ItemOverrideList;
@@ -31,266 +31,255 @@ import net.minecraft.util.Direction;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.tile.crafting.CraftingCubeModelData;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
/**
* The base model for baked models used by components of the crafting cube multi-block in it's formed state.
* 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.
* The base model for baked models used by components of the crafting cube
* multi-block in it's formed state. 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 IDynamicBakedModel
{
abstract class CraftingCubeBakedModel implements IDynamicBakedModel {
private final TextureAtlasSprite ringCorner;
private final TextureAtlasSprite ringCorner;
private final TextureAtlasSprite ringHor;
private final TextureAtlasSprite ringHor;
private final TextureAtlasSprite ringVer;
private final TextureAtlasSprite ringVer;
CraftingCubeBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer )
{
this.ringCorner = ringCorner;
this.ringHor = ringHor;
this.ringVer = ringVer;
}
CraftingCubeBakedModel(TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer) {
this.ringCorner = ringCorner;
this.ringHor = ringHor;
this.ringVer = ringVer;
}
@Nonnull
@Override
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
}
@Nonnull
@Override
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( extraData );
EnumSet<Direction> connections = getConnections(extraData);
List<BakedQuad> quads = new ArrayList<>();
CubeBuilder builder = new CubeBuilder( quads );
List<BakedQuad> quads = new ArrayList<>();
CubeBuilder builder = new CubeBuilder(quads);
builder.setDrawFaces( EnumSet.of( side ) );
builder.setDrawFaces(EnumSet.of(side));
// Add the quads for the ring that frames the entire multi-block structure
this.addRing( builder, side, connections );
// Add the quads for the ring that frames the entire multi-block structure
this.addRing(builder, side, connections);
// Calculate the bounds of the "inner" block that is framed by the border drawn above
float x2 = connections.contains( Direction.EAST ) ? 16 : 13.01f;
float x1 = connections.contains( Direction.WEST ) ? 0 : 2.99f;
// Calculate the bounds of the "inner" block that is framed by the border drawn
// above
float x2 = connections.contains(Direction.EAST) ? 16 : 13.01f;
float x1 = connections.contains(Direction.WEST) ? 0 : 2.99f;
float y2 = connections.contains( Direction.UP ) ? 16 : 13.01f;
float y1 = connections.contains( Direction.DOWN ) ? 0 : 2.99f;
float y2 = connections.contains(Direction.UP) ? 16 : 13.01f;
float y1 = connections.contains(Direction.DOWN) ? 0 : 2.99f;
float z2 = connections.contains( Direction.SOUTH ) ? 16 : 13.01f;
float z1 = connections.contains( Direction.NORTH ) ? 0 : 2.99f;
float z2 = connections.contains(Direction.SOUTH) ? 16 : 13.01f;
float z1 = connections.contains(Direction.NORTH) ? 0 : 2.99f;
// On the axis of the side that we're currently drawing, extend the dimensions
// out to the outer face of the block
switch( side )
{
case DOWN:
case UP:
y1 = 0;
y2 = 16;
break;
case NORTH:
case SOUTH:
z1 = 0;
z2 = 16;
break;
case WEST:
case EAST:
x1 = 0;
x2 = 16;
break;
}
// On the axis of the side that we're currently drawing, extend the dimensions
// out to the outer face of the block
switch (side) {
case DOWN:
case UP:
y1 = 0;
y2 = 16;
break;
case NORTH:
case SOUTH:
z1 = 0;
z2 = 16;
break;
case WEST:
case EAST:
x1 = 0;
x2 = 16;
break;
}
this.addInnerCube( side, state, extraData, builder, x1, y1, z1, x2, y2, z2 );
this.addInnerCube(side, state, extraData, builder, x1, y1, z1, x2, y2, z2);
return quads;
}
return quads;
}
private void addRing( CubeBuilder builder, @Nullable Direction side, EnumSet<Direction> connections )
{
// Fill in the corners
builder.setTexture( this.ringCorner );
this.addCornerCap( builder, connections, side, Direction.UP, Direction.EAST, Direction.NORTH );
this.addCornerCap( builder, connections, side, Direction.UP, Direction.EAST, Direction.SOUTH );
this.addCornerCap( builder, connections, side, Direction.UP, Direction.WEST, Direction.NORTH );
this.addCornerCap( builder, connections, side, Direction.UP, Direction.WEST, Direction.SOUTH );
this.addCornerCap( builder, connections, side, Direction.DOWN, Direction.EAST, Direction.NORTH );
this.addCornerCap( builder, connections, side, Direction.DOWN, Direction.EAST, Direction.SOUTH );
this.addCornerCap( builder, connections, side, Direction.DOWN, Direction.WEST, Direction.NORTH );
this.addCornerCap( builder, connections, side, Direction.DOWN, Direction.WEST, Direction.SOUTH );
private void addRing(CubeBuilder builder, @Nullable Direction side, EnumSet<Direction> connections) {
// Fill in the corners
builder.setTexture(this.ringCorner);
this.addCornerCap(builder, connections, side, Direction.UP, Direction.EAST, Direction.NORTH);
this.addCornerCap(builder, connections, side, Direction.UP, Direction.EAST, Direction.SOUTH);
this.addCornerCap(builder, connections, side, Direction.UP, Direction.WEST, Direction.NORTH);
this.addCornerCap(builder, connections, side, Direction.UP, Direction.WEST, Direction.SOUTH);
this.addCornerCap(builder, connections, side, Direction.DOWN, Direction.EAST, Direction.NORTH);
this.addCornerCap(builder, connections, side, Direction.DOWN, Direction.EAST, Direction.SOUTH);
this.addCornerCap(builder, connections, side, Direction.DOWN, Direction.WEST, Direction.NORTH);
this.addCornerCap(builder, connections, side, Direction.DOWN, Direction.WEST, Direction.SOUTH);
// Fill in the remaining stripes of the face
for( Direction a : Direction.values() )
{
if( a == side || a == side.getOpposite() )
{
continue;
}
// Fill in the remaining stripes of the face
for (Direction a : Direction.values()) {
if (a == side || a == side.getOpposite()) {
continue;
}
// Select the horizontal or vertical ring texture depending on which side we're filling in
if( ( side.getAxis() != Direction.Axis.Y ) && ( a == Direction.NORTH || a == Direction.EAST || a == Direction.WEST || a == Direction.SOUTH ) )
{
builder.setTexture( this.ringVer );
}
else if( side.getAxis() == Direction.Axis.Y && ( a == Direction.EAST || a == Direction.WEST ) )
{
builder.setTexture( this.ringVer );
}
else
{
builder.setTexture( this.ringHor );
}
// Select the horizontal or vertical ring texture depending on which side we're
// filling in
if ((side.getAxis() != Direction.Axis.Y)
&& (a == Direction.NORTH || a == Direction.EAST || a == Direction.WEST || a == Direction.SOUTH)) {
builder.setTexture(this.ringVer);
} else if (side.getAxis() == Direction.Axis.Y && (a == Direction.EAST || a == Direction.WEST)) {
builder.setTexture(this.ringVer);
} else {
builder.setTexture(this.ringHor);
}
// If there's an adjacent crafting cube block on side a, then the core of the block already extends
// fully to this side. So only bother drawing the stripe, if there's no connection.
if( !connections.contains( a ) )
{
// Note that since we're drawing something that "looks" 2-dimensional,
// two of the following will always be 0 and 16.
float x1 = 0, y1 = 0, z1 = 0, x2 = 16, y2 = 16, z2 = 16;
// If there's an adjacent crafting cube block on side a, then the core of the
// block already extends
// fully to this side. So only bother drawing the stripe, if there's no
// connection.
if (!connections.contains(a)) {
// Note that since we're drawing something that "looks" 2-dimensional,
// two of the following will always be 0 and 16.
float x1 = 0, y1 = 0, z1 = 0, x2 = 16, y2 = 16, z2 = 16;
switch( a )
{
case DOWN:
y1 = 0;
y2 = 3;
break;
case UP:
y1 = 13.0f;
y2 = 16;
break;
case WEST:
x1 = 0;
x2 = 3;
break;
case EAST:
x1 = 13;
x2 = 16;
break;
case NORTH:
z1 = 0;
z2 = 3;
break;
case SOUTH:
z1 = 13;
z2 = 16;
break;
}
switch (a) {
case DOWN:
y1 = 0;
y2 = 3;
break;
case UP:
y1 = 13.0f;
y2 = 16;
break;
case WEST:
x1 = 0;
x2 = 3;
break;
case EAST:
x1 = 13;
x2 = 16;
break;
case NORTH:
z1 = 0;
z2 = 3;
break;
case SOUTH:
z1 = 13;
z2 = 16;
break;
}
// Constraint the stripe in the two directions perpendicular to a in case there has been a corner
// 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 = Platform.rotateAround( a, side );
for( Direction cornerCandidate : EnumSet.of( perpendicular, perpendicular.getOpposite() ) )
{
if( !connections.contains( cornerCandidate ) )
{
// There's a cap in this direction
switch( cornerCandidate )
{
case DOWN:
y1 = 3;
break;
case UP:
y2 = 13;
break;
case NORTH:
z1 = 3;
break;
case SOUTH:
z2 = 13;
break;
case WEST:
x1 = 3;
break;
case EAST:
x2 = 13;
break;
}
}
}
// Constraint the stripe in the two directions perpendicular to a in case there
// has been a corner
// 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 = Platform.rotateAround(a, side);
for (Direction cornerCandidate : EnumSet.of(perpendicular, perpendicular.getOpposite())) {
if (!connections.contains(cornerCandidate)) {
// There's a cap in this direction
switch (cornerCandidate) {
case DOWN:
y1 = 3;
break;
case UP:
y2 = 13;
break;
case NORTH:
z1 = 3;
break;
case SOUTH:
z2 = 13;
break;
case WEST:
x1 = 3;
break;
case EAST:
x2 = 13;
break;
}
}
}
builder.addCube( x1, y1, z1, x2, y2, z2 );
}
}
}
builder.addCube(x1, y1, z1, x2, y2, z2);
}
}
}
/**
* Adds a 3x3x3 corner cap to the cube builder if there are no adjacent crafting cubes on that corner.
*/
private void addCornerCap( CubeBuilder builder, EnumSet<Direction> connections, Direction side, Direction down, Direction west, Direction north )
{
if( connections.contains( down ) || connections.contains( west ) || connections.contains( north ) )
{
return;
}
/**
* Adds a 3x3x3 corner cap to the cube builder if there are no adjacent crafting
* cubes on that corner.
*/
private void addCornerCap(CubeBuilder builder, EnumSet<Direction> connections, Direction side, Direction down,
Direction west, Direction north) {
if (connections.contains(down) || connections.contains(west) || connections.contains(north)) {
return;
}
// Only add faces for sides that can actually be seen (the outside of the cube)
if( side != down && side != west && side != north )
{
return;
}
// Only add faces for sides that can actually be seen (the outside of the cube)
if (side != down && side != west && side != north) {
return;
}
float x1 = ( west == Direction.WEST ? 0 : 13 );
float y1 = ( down == Direction.DOWN ? 0 : 13 );
float z1 = ( north == Direction.NORTH ? 0 : 13 );
float x2 = ( west == Direction.WEST ? 3 : 16 );
float y2 = ( down == Direction.DOWN ? 3 : 16 );
float z2 = ( north == Direction.NORTH ? 3 : 16 );
builder.addCube( x1, y1, z1, x2, y2, z2 );
}
float x1 = (west == Direction.WEST ? 0 : 13);
float y1 = (down == Direction.DOWN ? 0 : 13);
float z1 = (north == Direction.NORTH ? 0 : 13);
float x2 = (west == Direction.WEST ? 3 : 16);
float y2 = (down == Direction.DOWN ? 3 : 16);
float z2 = (north == Direction.NORTH ? 3 : 16);
builder.addCube(x1, y1, z1, x2, y2, z2);
}
// 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( IModelData modelData )
{
if (!(modelData instanceof CraftingCubeModelData)) {
return EnumSet.noneOf(Direction.class);
}
// 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(IModelData modelData) {
if (!(modelData instanceof CraftingCubeModelData)) {
return EnumSet.noneOf(Direction.class);
}
return ((CraftingCubeModelData) modelData).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);
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()
{
return false;
}
@Override
public boolean isAmbientOcclusion() {
return false;
}
@Override
public boolean isGui3d()
{
return false;
}
@Override
public boolean isGui3d() {
return false;
}
@Override
public boolean isBuiltInRenderer()
{
return false;
}
@Override
public boolean isBuiltInRenderer() {
return false;
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.ringCorner;
}
@Override
public TextureAtlasSprite getParticleTexture() {
return this.ringCorner;
}
@Override
public boolean func_230044_c_() {
return false;
}
@Override
public boolean func_230044_c_() {
return false;
}
@Override
public ItemOverrideList getOverrides() {
return ItemOverrideList.EMPTY;
}
@Override
public ItemOverrideList getOverrides() {
return ItemOverrideList.EMPTY;
}
}
@@ -18,11 +18,13 @@
package appeng.client.render.crafting;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
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;
@@ -30,93 +32,91 @@ 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;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.core.AppEng;
/**
* The built-in model for the connected texture crafting cube.
*/
class CraftingCubeModel implements IModelGeometry<CraftingCubeModel>
{
class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
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( "1k_storage_light" );
private final static Material STORAGE_4K_LIGHT = texture( "4k_storage_light" );
private final static Material STORAGE_16K_LIGHT = texture( "16k_storage_light" );
private final static Material STORAGE_64K_LIGHT = texture( "64k_storage_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 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("1k_storage_light");
private final static Material STORAGE_4K_LIGHT = texture("4k_storage_light");
private final static Material STORAGE_16K_LIGHT = texture("16k_storage_light");
private final static Material STORAGE_64K_LIGHT = texture("64k_storage_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;
private final AbstractCraftingUnitBlock.CraftingUnitType type;
CraftingCubeModel( AbstractCraftingUnitBlock.CraftingUnitType type )
{
this.type = type;
}
CraftingCubeModel(AbstractCraftingUnitBlock.CraftingUnitType type) {
this.type = type;
}
@Override
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 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(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 = spriteGetter.apply( RING_CORNER );
TextureAtlasSprite ringSideHor = spriteGetter.apply( RING_SIDE_HOR );
TextureAtlasSprite ringSideVer = spriteGetter.apply( RING_SIDE_VER );
@Override
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 = 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( ringCorner, ringSideHor, ringSideVer, spriteGetter.apply( UNIT_BASE ) );
case ACCELERATOR:
case STORAGE_1K:
case STORAGE_4K:
case STORAGE_16K:
case STORAGE_64K:
return new LightBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter
.apply( LIGHT_BASE ), getLightTexture( spriteGetter, this.type ) );
case MONITOR:
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 );
}
}
switch (this.type) {
case UNIT:
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(ringCorner, ringSideHor, ringSideVer, spriteGetter.apply(LIGHT_BASE),
getLightTexture(spriteGetter, this.type));
case MONITOR:
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<Material, TextureAtlasSprite> textureGetter, AbstractCraftingUnitBlock.CraftingUnitType type )
{
switch( type )
{
case ACCELERATOR:
return textureGetter.apply( ACCELERATOR_LIGHT );
case STORAGE_1K:
return textureGetter.apply( STORAGE_1K_LIGHT );
case STORAGE_4K:
return textureGetter.apply( STORAGE_4K_LIGHT );
case STORAGE_16K:
return textureGetter.apply( STORAGE_16K_LIGHT );
case STORAGE_64K:
return textureGetter.apply( STORAGE_64K_LIGHT );
default:
throw new IllegalArgumentException( "Crafting unit type " + type + " does not use a light texture." );
}
}
private static TextureAtlasSprite getLightTexture(Function<Material, TextureAtlasSprite> textureGetter,
AbstractCraftingUnitBlock.CraftingUnitType type) {
switch (type) {
case ACCELERATOR:
return textureGetter.apply(ACCELERATOR_LIGHT);
case STORAGE_1K:
return textureGetter.apply(STORAGE_1K_LIGHT);
case STORAGE_4K:
return textureGetter.apply(STORAGE_4K_LIGHT);
case STORAGE_16K:
return textureGetter.apply(STORAGE_16K_LIGHT);
case STORAGE_64K:
return textureGetter.apply(STORAGE_64K_LIGHT);
default:
throw new IllegalArgumentException("Crafting unit type " + type + " does not use a light texture.");
}
}
private static Material texture( String name )
{
return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "block/crafting/" + name));
}
private static Material texture(String name) {
return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/crafting/" + name));
}
}
@@ -18,44 +18,44 @@
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;
import appeng.block.crafting.AbstractCraftingUnitBlock;
/**
* Loader that allows access to the built-in crafting cube model from block-model JSONs.
* Loader that allows access to the built-in crafting cube model from
* block-model JSONs.
*/
public class CraftingCubeModelLoader implements IModelLoader<CraftingCubeModel>
{
public class CraftingCubeModelLoader implements IModelLoader<CraftingCubeModel> {
public static final CraftingCubeModelLoader INSTANCE = new CraftingCubeModelLoader();
public static final CraftingCubeModelLoader INSTANCE = new CraftingCubeModelLoader();
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
}
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
}
@Override
public CraftingCubeModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
AbstractCraftingUnitBlock.CraftingUnitType unitType = null;
@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");
}
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);
}
return new CraftingCubeModel(unitType);
}
}
@@ -18,26 +18,23 @@
package appeng.client.render.crafting;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
/**
* Rendering customization for the crafting cube.
*/
public class CraftingCubeRendering extends BlockRenderingCustomizer
{
@Override
@OnlyIn( Dist.CLIENT )
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
rendering.renderType(RenderType.getCutout());
// Disable auto-rotation
rendering.modelCustomizer( ( loc, model ) -> model );
}
public class CraftingCubeRendering extends BlockRenderingCustomizer {
@Override
@OnlyIn(Dist.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
// Disable auto-rotation
rendering.modelCustomizer((loc, model) -> model);
}
}
@@ -18,10 +18,8 @@
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;
@@ -31,41 +29,42 @@ 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;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.render.TesrRenderHelper;
import appeng.core.Api;
import appeng.tile.crafting.TileCraftingMonitorTile;
/**
* Renders the item currently being crafted
*/
@OnlyIn( Dist.CLIENT )
public class CraftingMonitorTESR extends TileEntityRenderer<TileCraftingMonitorTile>
{
@OnlyIn(Dist.CLIENT)
public class CraftingMonitorTESR extends TileEntityRenderer<TileCraftingMonitorTile> {
public CraftingMonitorTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
}
public CraftingMonitorTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
}
@Override
public void render(TileCraftingMonitorTile te, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) {
@Override
public void render(TileCraftingMonitorTile te, float partialTicks, MatrixStack matrixStack,
IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) {
Direction facing = te.getForward();
Direction facing = te.getForward();
IAEItemStack jobProgress = te.getJobProgress();
IAEItemStack jobProgress = te.getJobProgress();
if( jobProgress != null )
{
matrixStack.push();
matrixStack.translate(0.5, 0.5, 0.5); // Move to the center of the block
if (jobProgress != null) {
matrixStack.push();
matrixStack.translate(0.5, 0.5, 0.5); // Move to the center of the block
TesrRenderHelper.rotateToFace( matrixStack, facing, (byte) 0 );
matrixStack.translate(0, 0.08, 0.5);
TesrRenderHelper.renderItem2dWithAmount(matrixStack, buffers, jobProgress, 0.3f, -0.18f, 15728880, combinedOverlay);
TesrRenderHelper.rotateToFace(matrixStack, facing, (byte) 0);
matrixStack.translate(0, 0.08, 0.5);
TesrRenderHelper.renderItem2dWithAmount(matrixStack, buffers, jobProgress, 0.3f, -0.18f, 15728880,
combinedOverlay);
matrixStack.pop();
}
}
matrixStack.pop();
}
}
}
@@ -1,9 +1,14 @@
package appeng.client.render.crafting;
import appeng.client.render.DelegateBakedModel;
import appeng.items.misc.ItemEncodedPattern;
import java.util.List;
import java.util.Random;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableMap;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
@@ -21,57 +26,51 @@ import net.minecraftforge.client.model.PerspectiveMapWrapper;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Random;
import appeng.client.render.DelegateBakedModel;
import appeng.items.misc.ItemEncodedPattern;
/**
* This model is used to substitute the crafting result's item model for our encoded pattern model if these
* two conditions are met:
* - The player is holding shift
* - The itemstack is being rendered in the UI (not on the ground, etc.)
* This model is used to substitute the crafting result's item model for our
* encoded pattern model if these two conditions are met: - The player is
* holding shift - The itemstack is being rendered in the UI (not on the ground,
* etc.)
*
* We do this by abusing a custom {@link ItemOverrideList} since it will be called each frame with the itemstack
* that is about to be rendered. We return a custom IBakedModel ({@link ShiftHoldingModelWrapper} if the player
* is holding down shift from the override list.
* This custom baked model implements {@link #doesHandlePerspectives()} and returns the crafting result model
* if the model for {@link ItemCameraTransforms.TransformType#GUI} is requested.
* We do this by abusing a custom {@link ItemOverrideList} since it will be
* called each frame with the itemstack that is about to be rendered. We return
* a custom IBakedModel ({@link ShiftHoldingModelWrapper} if the player is
* holding down shift from the override list. This custom baked model implements
* {@link #doesHandlePerspectives()} and returns the crafting result model if
* the model for {@link ItemCameraTransforms.TransformType#GUI} is requested.
*/
public class EncodedPatternBakedModel extends DelegateBakedModel {
private final CustomOverrideList overrides;
EncodedPatternBakedModel(IBakedModel baseModel)
{
EncodedPatternBakedModel(IBakedModel baseModel) {
super(baseModel);
this.overrides = new CustomOverrideList();
}
@Override
public ItemOverrideList getOverrides()
{
public ItemOverrideList getOverrides() {
return this.overrides;
}
/**
* 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,
* 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 static class ShiftHoldingModelWrapper extends DelegateBakedModel
{
private static class ShiftHoldingModelWrapper extends DelegateBakedModel {
private final IBakedModel outputModel;
private ShiftHoldingModelWrapper( IBakedModel patternModel, IBakedModel outputModel )
{
private ShiftHoldingModelWrapper(IBakedModel patternModel, IBakedModel outputModel) {
super(patternModel);
this.outputModel = outputModel;
}
@@ -82,16 +81,14 @@ public class EncodedPatternBakedModel extends DelegateBakedModel {
}
@Override
public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat )
{
// No need to re-check for shift being held since this model is only handed out in that case
if( cameraTransformType == ItemCameraTransforms.TransformType.GUI )
{
ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> transforms = PerspectiveMapWrapper.getTransforms(outputModel.getItemCameraTransforms());
return PerspectiveMapWrapper.handlePerspective( this.outputModel, transforms, cameraTransformType, mat );
}
else
{
public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) {
// No need to re-check for shift being held since this model is only handed out
// in that case
if (cameraTransformType == ItemCameraTransforms.TransformType.GUI) {
ImmutableMap<ItemCameraTransforms.TransformType, TransformationMatrix> transforms = PerspectiveMapWrapper
.getTransforms(outputModel.getItemCameraTransforms());
return PerspectiveMapWrapper.handlePerspective(this.outputModel, transforms, cameraTransformType, mat);
} else {
return getBaseModel().handlePerspective(cameraTransformType, mat);
}
}
@@ -111,38 +108,36 @@ public class EncodedPatternBakedModel extends DelegateBakedModel {
}
@Override
public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat )
{
public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat) {
return getBaseModel().handlePerspective(cameraTransformType, mat);
}
/**
* 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.
* 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
{
private class CustomOverrideList extends ItemOverrideList {
@Nullable
@Override
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable LivingEntity entity) {
public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, @Nullable World world,
@Nullable LivingEntity entity) {
boolean shiftHeld = Screen.hasShiftDown();
if( shiftHeld )
{
if (shiftHeld) {
ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
ItemStack output = iep.getOutput( stack );
if( !output.isEmpty() )
{
IBakedModel realModel = Minecraft.getInstance().getItemRenderer().getItemModelMesher().getItemModel( output );
ItemStack output = iep.getOutput(stack);
if (!output.isEmpty()) {
IBakedModel realModel = Minecraft.getInstance().getItemRenderer().getItemModelMesher()
.getItemModel(output);
// Give the item model a chance to handle the overrides as well
realModel = realModel.getOverrides().getModelWithOverrides( realModel, output, world, entity );
realModel = realModel.getOverrides().getModelWithOverrides(realModel, output, world, entity);
return new ShiftHoldingModelWrapper(getBaseModel(), realModel);
}
}
return getBaseModel().getOverrides().getModelWithOverrides( originalModel, stack, world, entity );
return getBaseModel().getOverrides().getModelWithOverrides(originalModel, stack, world, entity);
}
}
@@ -1,16 +1,17 @@
package appeng.client.render.crafting;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.model.*;
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;
/**
* This model is used to provide the {@link EncodedPatternBakedModel}.
*/
@@ -23,14 +24,17 @@ public class EncodedPatternModel implements IModelGeometry<EncodedPatternModel>
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
public Collection<Material> getTextures(IModelConfiguration owner,
Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return modelGetter.apply(baseModel).getTextures(modelGetter, missingTextureErrors);
}
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, ResourceLocation modelLocation) {
IBakedModel baseModel = bakery.getBakedModel(this.baseModel, modelTransform, spriteGetter);
return new EncodedPatternBakedModel( baseModel);
return new EncodedPatternBakedModel(baseModel);
}
}
@@ -2,13 +2,15 @@ package appeng.client.render.crafting;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import net.minecraft.resources.IResourceManager;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModelLoader;
/**
* Provides our custom {@link EncodedPatternBakedModel encoded pattern item model}.
* Provides our custom {@link EncodedPatternBakedModel encoded pattern item
* model}.
*/
public class EncodedPatternModelLoader implements IModelLoader<EncodedPatternModel> {
@@ -18,44 +18,42 @@
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.client.model.data.IModelData;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.client.render.cablebus.CubeBuilder;
import net.minecraftforge.client.model.data.IModelData;
/**
* Crafting cube baked model that adds a full-bright light texture on top of a normal base texture onto the inner cube.
* The light texture is only drawn fullbright if the multiblock is currently powered.
* Crafting cube baked model that adds a full-bright light texture on top of a
* normal base texture onto the inner cube. The light texture is only drawn
* fullbright if the multiblock is currently powered.
*/
class LightBakedModel extends CraftingCubeBakedModel
{
class LightBakedModel extends CraftingCubeBakedModel {
private final TextureAtlasSprite baseTexture;
private final TextureAtlasSprite baseTexture;
private final TextureAtlasSprite lightTexture;
private final TextureAtlasSprite lightTexture;
LightBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite baseTexture, TextureAtlasSprite lightTexture )
{
super( ringCorner, ringHor, ringVer );
this.baseTexture = baseTexture;
this.lightTexture = lightTexture;
}
LightBakedModel(TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer,
TextureAtlasSprite baseTexture, TextureAtlasSprite lightTexture) {
super(ringCorner, ringHor, ringVer);
this.baseTexture = baseTexture;
this.lightTexture = lightTexture;
}
@Override
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 );
@Override
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);
boolean powered = state.get( AbstractCraftingUnitBlock.POWERED );
builder.setRenderFullBright( powered );
builder.setTexture( this.lightTexture );
builder.addCube( x1, y1, z1, x2, y2, z2 );
}
boolean powered = state.get(AbstractCraftingUnitBlock.POWERED);
builder.setRenderFullBright(powered);
builder.setTexture(this.lightTexture);
builder.addCube(x1, y1, z1, x2, y2, z2);
}
}
@@ -18,95 +18,93 @@
package appeng.client.render.crafting;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Direction;
import net.minecraftforge.client.model.data.IModelData;
import appeng.api.util.AEColor;
import appeng.block.crafting.BlockCraftingMonitor;
import appeng.client.render.cablebus.CubeBuilder;
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;
import net.minecraftforge.client.model.data.IModelData;
/**
* The baked model for the crafting monitor. Please note that this model doesn't handle the item being displayed. That
* is handled by a TESR.
* Instead, this model adds 3 layered light textures using the [dark|medium|bright] color variants of the attached bus
* color. The textures
* are full-bright if the cube is powered.
* The baked model for the crafting monitor. Please note that this model doesn't
* handle the item being displayed. That is handled by a TESR. Instead, this
* model adds 3 layered light textures using the [dark|medium|bright] color
* variants of the attached bus color. The textures are full-bright if the cube
* is powered.
*/
public class MonitorBakedModel extends CraftingCubeBakedModel
{
public class MonitorBakedModel extends CraftingCubeBakedModel {
private final TextureAtlasSprite chassisTexture;
private final TextureAtlasSprite chassisTexture;
private final TextureAtlasSprite baseTexture;
private final TextureAtlasSprite baseTexture;
private final TextureAtlasSprite lightDarkTexture;
private final TextureAtlasSprite lightDarkTexture;
private final TextureAtlasSprite lightMediumTexture;
private final TextureAtlasSprite lightMediumTexture;
private final TextureAtlasSprite lightBrightTexture;
private final TextureAtlasSprite lightBrightTexture;
MonitorBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite chassisTexture, TextureAtlasSprite baseTexture, TextureAtlasSprite lightDarkTexture, TextureAtlasSprite lightMediumTexture, TextureAtlasSprite lightBrightTexture )
{
super( ringCorner, ringHor, ringVer );
this.chassisTexture = chassisTexture;
this.baseTexture = baseTexture;
this.lightDarkTexture = lightDarkTexture;
this.lightMediumTexture = lightMediumTexture;
this.lightBrightTexture = lightBrightTexture;
}
MonitorBakedModel(TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer,
TextureAtlasSprite chassisTexture, TextureAtlasSprite baseTexture, TextureAtlasSprite lightDarkTexture,
TextureAtlasSprite lightMediumTexture, TextureAtlasSprite lightBrightTexture) {
super(ringCorner, ringHor, ringVer);
this.chassisTexture = chassisTexture;
this.baseTexture = baseTexture;
this.lightDarkTexture = lightDarkTexture;
this.lightMediumTexture = lightMediumTexture;
this.lightBrightTexture = lightBrightTexture;
}
@Override
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( modelData );
@Override
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(modelData);
// For sides other than the front, use the chassis texture
if( side != forward )
{
builder.setTexture( this.chassisTexture );
builder.addCube( x1, y1, z1, x2, y2, z2 );
return;
}
// For sides other than the front, use the chassis texture
if (side != forward) {
builder.setTexture(this.chassisTexture);
builder.addCube(x1, y1, z1, x2, y2, z2);
return;
}
builder.setTexture( this.baseTexture );
builder.addCube( x1, y1, z1, x2, y2, z2 );
builder.setTexture(this.baseTexture);
builder.addCube(x1, y1, z1, x2, y2, z2);
// Now add the three layered light textures
AEColor color = getColor( modelData );
boolean powered = state.get( BlockCraftingMonitor.POWERED );
// Now add the three layered light textures
AEColor color = getColor(modelData);
boolean powered = state.get(BlockCraftingMonitor.POWERED);
builder.setRenderFullBright( powered );
builder.setRenderFullBright(powered);
builder.setColorRGB( color.whiteVariant );
builder.setTexture( this.lightBrightTexture );
builder.addCube( x1, y1, z1, x2, y2, z2 );
builder.setColorRGB(color.whiteVariant);
builder.setTexture(this.lightBrightTexture);
builder.addCube(x1, y1, z1, x2, y2, z2);
builder.setColorRGB( color.mediumVariant );
builder.setTexture( this.lightMediumTexture );
builder.addCube( x1, y1, z1, x2, y2, z2 );
builder.setColorRGB(color.mediumVariant);
builder.setTexture(this.lightMediumTexture);
builder.addCube(x1, y1, z1, x2, y2, z2);
builder.setColorRGB( color.blackVariant );
builder.setTexture( this.lightDarkTexture );
builder.addCube( x1, y1, z1, x2, y2, z2 );
builder.setColorRGB(color.blackVariant);
builder.setTexture(this.lightDarkTexture);
builder.addCube(x1, y1, z1, x2, y2, z2);
}
}
private static AEColor getColor(IModelData modelData) {
if (modelData instanceof CraftingMonitorModelData) {
return ((CraftingMonitorModelData) modelData).getColor();
}
return AEColor.TRANSPARENT;
}
private static AEColor getColor(IModelData modelData) {
if (modelData instanceof CraftingMonitorModelData) {
return ((CraftingMonitorModelData) modelData).getColor();
}
return AEColor.TRANSPARENT;
}
private static Direction getForward(IModelData modelData) {
if (modelData instanceof AEModelData) {
return ((AEModelData) modelData).getForward();
}
return Direction.NORTH;
}
private static Direction getForward(IModelData modelData) {
if (modelData instanceof AEModelData) {
return ((AEModelData) modelData).getForward();
}
return Direction.NORTH;
}
}
@@ -18,33 +18,30 @@
package appeng.client.render.crafting;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Direction;
import appeng.client.render.cablebus.CubeBuilder;
import net.minecraftforge.client.model.data.IModelData;
import appeng.client.render.cablebus.CubeBuilder;
/**
* A simple crafting unit model that uses an un-lit texture for the inner block.
*/
class UnitBakedModel extends CraftingCubeBakedModel
{
class UnitBakedModel extends CraftingCubeBakedModel {
private final TextureAtlasSprite unitTexture;
private final TextureAtlasSprite unitTexture;
UnitBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite unitTexture )
{
super( ringCorner, ringHor, ringVer );
this.unitTexture = unitTexture;
}
UnitBakedModel(TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer,
TextureAtlasSprite unitTexture) {
super(ringCorner, ringHor, ringVer);
this.unitTexture = unitTexture;
}
@Override
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 );
}
@Override
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);
}
}