Fixed formation planes.
This commit is contained in:
@@ -19,63 +19,70 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
|
||||
/**
|
||||
* Built-in model for annihilation planes that supports connected textures.
|
||||
*/
|
||||
public class PlaneBakedModel implements IBakedModel
|
||||
public class PlaneBakedModel implements IDynamicBakedModel
|
||||
{
|
||||
|
||||
private static final PlaneConnections DEFAULT_PERMUTATION = PlaneConnections.of(false, false, false, false);
|
||||
|
||||
private final TextureAtlasSprite frontTexture;
|
||||
|
||||
private final List<BakedQuad> quads;
|
||||
private final Map<PlaneConnections, List<BakedQuad>> quads;
|
||||
|
||||
PlaneBakedModel( TextureAtlasSprite frontTexture, TextureAtlasSprite sidesTexture, TextureAtlasSprite backTexture, PlaneConnections connections )
|
||||
PlaneBakedModel( TextureAtlasSprite frontTexture, TextureAtlasSprite sidesTexture, TextureAtlasSprite backTexture )
|
||||
{
|
||||
this.frontTexture = frontTexture;
|
||||
|
||||
List<BakedQuad> quads = new ArrayList<>( 4 * 6 );
|
||||
quads = new HashMap<>(PlaneConnections.PERMUTATIONS.size());
|
||||
// Create all possible permutations (16)
|
||||
for (PlaneConnections permutation : PlaneConnections.PERMUTATIONS) {
|
||||
List<BakedQuad> quads = new ArrayList<>(4 * 6);
|
||||
|
||||
CubeBuilder builder = new CubeBuilder( quads );
|
||||
CubeBuilder builder = new CubeBuilder(quads);
|
||||
|
||||
builder.setTextures( sidesTexture, sidesTexture, frontTexture, backTexture, sidesTexture, sidesTexture );
|
||||
builder.setTextures(sidesTexture, sidesTexture, frontTexture, backTexture, sidesTexture, sidesTexture);
|
||||
|
||||
// Keep the orientation of the X axis in mind here. When looking at a quad facing north from the front,
|
||||
// The X-axis points left
|
||||
int minX = connections.isRight() ? 0 : 1;
|
||||
int maxX = connections.isLeft() ? 16 : 15;
|
||||
int minY = connections.isDown() ? 0 : 1;
|
||||
int maxY = connections.isUp() ? 16 : 15;
|
||||
// Keep the orientation of the X axis in mind here. When looking at a quad facing north from the front,
|
||||
// The X-axis points left
|
||||
int minX = permutation.isRight() ? 0 : 1;
|
||||
int maxX = permutation.isLeft() ? 16 : 15;
|
||||
int minY = permutation.isDown() ? 0 : 1;
|
||||
int maxY = permutation.isUp() ? 16 : 15;
|
||||
|
||||
builder.addCube( minX, minY, 0, maxX, maxY, 1 );
|
||||
builder.addCube(minX, minY, 0, maxX, maxY, 1);
|
||||
|
||||
this.quads = ImmutableList.copyOf( quads );
|
||||
this.quads.put(permutation, ImmutableList.copyOf(quads));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand )
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData)
|
||||
{
|
||||
if( side == null )
|
||||
{
|
||||
return this.quads;
|
||||
PlaneConnections connections = DEFAULT_PERMUTATION;
|
||||
if (modelData instanceof PlaneModelData) {
|
||||
connections = ((PlaneModelData) modelData).getConnections();
|
||||
}
|
||||
return this.quads.get(connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user