Working in part placement
This commit is contained in:
@@ -24,7 +24,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.color.block.BlockColorProvider;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.util.AEColor;
|
||||
@@ -37,7 +37,7 @@ public class ColorableTileBlockColor implements BlockColorProvider {
|
||||
public static final ColorableTileBlockColor INSTANCE = new ColorableTileBlockColor();
|
||||
|
||||
@Override
|
||||
public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int tintIndex) {
|
||||
public int getColor(BlockState state, @Nullable BlockRenderView worldIn, @Nullable BlockPos pos, int tintIndex) {
|
||||
AEColor color = AEColor.TRANSPARENT; // Default to a neutral color
|
||||
|
||||
if (worldIn != null && pos != null) {
|
||||
|
||||
@@ -22,9 +22,13 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
|
||||
import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel;
|
||||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
@@ -42,36 +46,27 @@ import appeng.client.render.cablebus.FacadeBuilder;
|
||||
*
|
||||
* @author covers1624
|
||||
*/
|
||||
public class FacadeBakedItemModel extends DelegateBakedModel {
|
||||
public class FacadeBakedItemModel extends ForwardingBakedModel implements FabricBakedModel {
|
||||
|
||||
private final ItemStack textureStack;
|
||||
private final FacadeBuilder facadeBuilder;
|
||||
private List<BakedQuad> quads = null;
|
||||
|
||||
protected FacadeBakedItemModel(BakedModel base, ItemStack textureStack, FacadeBuilder facadeBuilder) {
|
||||
super(base);
|
||||
this.wrapped = base;
|
||||
this.textureStack = textureStack;
|
||||
this.facadeBuilder = facadeBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
return getQuads(state, side, rand, EmptyModelData.INSTANCE);
|
||||
}
|
||||
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
|
||||
super.emitItemQuads(stack, randomSupplier, context);
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand,
|
||||
IModelData data) {
|
||||
if (side != null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (quads == null) {
|
||||
quads = new ArrayList<>();
|
||||
quads.addAll(this.facadeBuilder.buildFacadeItemQuads(this.textureStack, Direction.NORTH));
|
||||
quads.addAll(this.getBaseModel().getQuads(state, side, rand, data));
|
||||
quads = Collections.unmodifiableList(quads);
|
||||
}
|
||||
return quads;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ package appeng.client.render;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
@@ -30,7 +31,6 @@ import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraftforge.client.IRenderHandler;
|
||||
import net.minecraftforge.client.SkyRenderHandler;
|
||||
@@ -85,7 +85,7 @@ public class SpatialSkyRender implements SkyRenderHandler {
|
||||
matrixStack.multiply(rotation);
|
||||
|
||||
RenderSystem.disableTexture();
|
||||
VertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
|
||||
VertexBuffer.begin(GL11.GL_QUADS, VertexFormats.POSITION);
|
||||
VertexBuffer.pos(-100.0D, -100.0D, -100.0D).endVertex();
|
||||
VertexBuffer.pos(-100.0D, -100.0D, 100.0D).endVertex();
|
||||
VertexBuffer.pos(100.0D, -100.0D, 100.0D).endVertex();
|
||||
@@ -123,7 +123,7 @@ public class SpatialSkyRender implements SkyRenderHandler {
|
||||
private void renderTwinkles() {
|
||||
final Tessellator tessellator = Tessellator.getInstance();
|
||||
final BufferBuilder vb = tessellator.getBuffer();
|
||||
vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
|
||||
vb.begin(GL11.GL_QUADS, VertexFormats.POSITION);
|
||||
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
double iX = this.random.nextFloat() * 2.0F - 1.0F;
|
||||
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.color.block.BlockColorProvider;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class StaticBlockColor implements BlockColorProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int tintIndex) {
|
||||
public int getColor(BlockState state, @Nullable BlockRenderView worldIn, @Nullable BlockPos pos, int tintIndex) {
|
||||
return this.color.getVariantByTintIndex(tintIndex);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +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;
|
||||
|
||||
import net.minecraft.client.color.item.ItemColorProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
/**
|
||||
* Returns the shades of a single AE color for tint indices 0, 1, and 2.
|
||||
*/
|
||||
public class StaticItemColor implements ItemColorProvider {
|
||||
|
||||
private final AEColor color;
|
||||
|
||||
public StaticItemColor(AEColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(ItemStack stack, int tintIndex) {
|
||||
return this.color.getVariantByTintIndex(tintIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,727 +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.cablebus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
/**
|
||||
* A helper class that builds quads for cable connections.
|
||||
*/
|
||||
class CableBuilder {
|
||||
|
||||
// Textures for the cable core types, one per type/color pair
|
||||
private final EnumMap<CableCoreType, EnumMap<AEColor, Sprite>> coreTextures;
|
||||
|
||||
// Textures for rendering the actual connection cubes, one per type/color pair
|
||||
private final EnumMap<AECableType, EnumMap<AEColor, Sprite>> connectionTextures;
|
||||
|
||||
private final SmartCableTextures smartCableTextures;
|
||||
|
||||
CableBuilder(Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
|
||||
this.coreTextures = new EnumMap<>(CableCoreType.class);
|
||||
|
||||
for (CableCoreType type : CableCoreType.values()) {
|
||||
EnumMap<AEColor, Sprite> colorTextures = new EnumMap<>(AEColor.class);
|
||||
|
||||
for (AEColor color : AEColor.values()) {
|
||||
colorTextures.put(color, bakedTextureGetter.apply(type.getTexture(color)));
|
||||
}
|
||||
|
||||
this.coreTextures.put(type, colorTextures);
|
||||
}
|
||||
|
||||
this.connectionTextures = new EnumMap<>(AECableType.class);
|
||||
|
||||
for (AECableType type : AECableType.VALIDCABLES) {
|
||||
EnumMap<AEColor, Sprite> colorTextures = new EnumMap<>(AEColor.class);
|
||||
|
||||
for (AEColor color : AEColor.values()) {
|
||||
colorTextures.put(color, bakedTextureGetter.apply(getConnectionTexture(type, color)));
|
||||
}
|
||||
|
||||
this.connectionTextures.put(type, colorTextures);
|
||||
}
|
||||
|
||||
this.smartCableTextures = new SmartCableTextures(bakedTextureGetter);
|
||||
}
|
||||
|
||||
static SpriteIdentifier getConnectionTexture(AECableType cableType, AEColor color) {
|
||||
String textureFolder;
|
||||
switch (cableType) {
|
||||
case GLASS:
|
||||
textureFolder = "parts/cable/glass/";
|
||||
break;
|
||||
case COVERED:
|
||||
textureFolder = "parts/cable/covered/";
|
||||
break;
|
||||
case SMART:
|
||||
textureFolder = "parts/cable/smart/";
|
||||
break;
|
||||
case DENSE_COVERED:
|
||||
textureFolder = "parts/cable/dense_covered/";
|
||||
break;
|
||||
case DENSE_SMART:
|
||||
textureFolder = "parts/cable/dense_smart/";
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Cable type " + cableType + " does not support connections.");
|
||||
}
|
||||
|
||||
return new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, textureFolder + color.name().toLowerCase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the core of a cable to the given list of quads.
|
||||
*
|
||||
* The type of cable core is automatically deduced from the given cable type.
|
||||
*/
|
||||
public void addCableCore(AECableType cableType, AEColor color, List<BakedQuad> quadsOut) {
|
||||
switch (cableType) {
|
||||
case GLASS:
|
||||
this.addCableCore(CableCoreType.GLASS, color, quadsOut);
|
||||
break;
|
||||
case COVERED:
|
||||
case SMART:
|
||||
this.addCableCore(CableCoreType.COVERED, color, quadsOut);
|
||||
break;
|
||||
case DENSE_COVERED:
|
||||
case DENSE_SMART:
|
||||
this.addCableCore(CableCoreType.DENSE, color, quadsOut);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public void addCableCore(CableCoreType coreType, AEColor color, List<BakedQuad> quadsOut) {
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
Sprite texture = this.coreTextures.get(coreType).get(color);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
switch (coreType) {
|
||||
case GLASS:
|
||||
cubeBuilder.addCube(6, 6, 6, 10, 10, 10);
|
||||
break;
|
||||
case COVERED:
|
||||
cubeBuilder.addCube(5, 5, 5, 11, 11, 11);
|
||||
break;
|
||||
case DENSE:
|
||||
cubeBuilder.addCube(3, 3, 3, 13, 13, 13);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void addGlassConnection(Direction facing, AEColor cableColor, AECableType connectionType,
|
||||
boolean cableBusAdjacent, List<BakedQuad> quadsOut) {
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
// We render all faces except the one on the connection side
|
||||
cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing)));
|
||||
|
||||
// For to-machine connections, use a thicker end-cap for the connection
|
||||
if (connectionType != AECableType.GLASS && !cableBusAdjacent) {
|
||||
Sprite texture = this.connectionTextures.get(AECableType.COVERED).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
this.addBigCoveredCableSizedCube(facing, cubeBuilder);
|
||||
}
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.GLASS).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
cubeBuilder.addCube(6, 0, 6, 10, 6, 10);
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube(10, 6, 6, 16, 10, 10);
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube(6, 6, 0, 10, 10, 6);
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube(6, 6, 10, 10, 10, 16);
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube(6, 10, 6, 10, 16, 10);
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube(0, 6, 6, 6, 10, 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void addStraightGlassConnection(Direction facing, AEColor cableColor, List<BakedQuad> quadsOut) {
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
// We render all faces except the connection caps. We can do this because the
|
||||
// glass cable is the smallest one
|
||||
// and its ends will always be covered by something
|
||||
cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing, facing.getOpposite())));
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.GLASS).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
case UP:
|
||||
cubeBuilder.addCube(6, 0, 6, 10, 16, 10);
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube(6, 6, 0, 10, 10, 16);
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
cubeBuilder.addCube(0, 6, 6, 16, 10, 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void addConstrainedGlassConnection(Direction facing, AEColor cableColor, int distanceFromEdge,
|
||||
List<BakedQuad> quadsOut) {
|
||||
|
||||
// Glass connections reach only 6 voxels from the edge
|
||||
if (distanceFromEdge >= 6) {
|
||||
return;
|
||||
}
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.GLASS).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
cubeBuilder.addCube(6, distanceFromEdge, 6, 10, 6, 10);
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube(10, 6, 6, 16 - distanceFromEdge, 10, 10);
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube(6, 6, distanceFromEdge, 10, 10, 6);
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube(6, 6, 10, 10, 10, 16 - distanceFromEdge);
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube(6, 10, 6, 10, 16 - distanceFromEdge, 10);
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube(distanceFromEdge, 6, 6, 6, 10, 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void addCoveredConnection(Direction facing, AEColor cableColor, AECableType connectionType,
|
||||
boolean cableBusAdjacent, List<BakedQuad> quadsOut) {
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
// We render all faces except the one on the connection side
|
||||
cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing)));
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.COVERED).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
// Draw a covered connection, if anything but glass is requested
|
||||
if (connectionType != AECableType.GLASS && !cableBusAdjacent) {
|
||||
this.addBigCoveredCableSizedCube(facing, cubeBuilder);
|
||||
}
|
||||
|
||||
addCoveredCableSizedCube(facing, cubeBuilder);
|
||||
}
|
||||
|
||||
public void addStraightCoveredConnection(Direction facing, AEColor cableColor, List<BakedQuad> quadsOut) {
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.COVERED).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
setStraightCableUVs(cubeBuilder, facing, 5, 11);
|
||||
|
||||
addStraightCoveredCableSizedCube(facing, cubeBuilder);
|
||||
}
|
||||
|
||||
private static void setStraightCableUVs(CubeBuilder cubeBuilder, Direction facing, int x, int y) {
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
case UP:
|
||||
cubeBuilder.setCustomUv(Direction.NORTH, x, 0, y, x);
|
||||
cubeBuilder.setCustomUv(Direction.EAST, x, 0, y, x);
|
||||
cubeBuilder.setCustomUv(Direction.SOUTH, x, 0, y, x);
|
||||
cubeBuilder.setCustomUv(Direction.WEST, x, 0, y, x);
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
cubeBuilder.setCustomUv(Direction.UP, 0, x, x, y);
|
||||
cubeBuilder.setCustomUv(Direction.DOWN, 0, x, x, y);
|
||||
cubeBuilder.setCustomUv(Direction.NORTH, 0, x, x, y);
|
||||
cubeBuilder.setCustomUv(Direction.SOUTH, 0, x, x, y);
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
cubeBuilder.setCustomUv(Direction.UP, x, 0, y, x);
|
||||
cubeBuilder.setCustomUv(Direction.DOWN, x, 0, y, x);
|
||||
cubeBuilder.setCustomUv(Direction.EAST, 0, x, x, y);
|
||||
cubeBuilder.setCustomUv(Direction.WEST, 0, x, x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void addConstrainedCoveredConnection(Direction facing, AEColor cableColor, int distanceFromEdge,
|
||||
List<BakedQuad> quadsOut) {
|
||||
// The core of a covered cable reaches up to 5 voxels from the block edge, so
|
||||
// drawing a connection can only occur from there onwards
|
||||
if (distanceFromEdge >= 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.COVERED).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
addCoveredCableSizedCube(facing, distanceFromEdge, cubeBuilder);
|
||||
}
|
||||
|
||||
public void addSmartConnection(Direction facing, AEColor cableColor, AECableType connectionType,
|
||||
boolean cableBusAdjacent, int channels, List<BakedQuad> quadsOut) {
|
||||
if (connectionType == AECableType.COVERED || connectionType == AECableType.GLASS) {
|
||||
this.addCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent, quadsOut);
|
||||
return;
|
||||
}
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
// We render all faces except the one on the connection side
|
||||
cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing)));
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.SMART).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
Sprite oddChannel = this.smartCableTextures.getOddTextureForChannels(channels);
|
||||
Sprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
||||
|
||||
// For to-machine connections, use a thicker end-cap for the connection
|
||||
if (connectionType != AECableType.GLASS && !cableBusAdjacent) {
|
||||
this.addBigCoveredCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright(true);
|
||||
|
||||
cubeBuilder.setTexture(oddChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||
this.addBigCoveredCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
cubeBuilder.setTexture(evenChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
||||
this.addBigCoveredCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
// Reset back to normal rendering for the rest
|
||||
cubeBuilder.setRenderFullBright(false);
|
||||
cubeBuilder.setTexture(texture);
|
||||
}
|
||||
|
||||
addCoveredCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright(true);
|
||||
|
||||
cubeBuilder.setTexture(oddChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||
addCoveredCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
cubeBuilder.setTexture(evenChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
||||
addCoveredCableSizedCube(facing, cubeBuilder);
|
||||
}
|
||||
|
||||
public void addStraightSmartConnection(Direction facing, AEColor cableColor, int channels,
|
||||
List<BakedQuad> quadsOut) {
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.SMART).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
setStraightCableUVs(cubeBuilder, facing, 5, 11);
|
||||
|
||||
addStraightCoveredCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
Sprite oddChannel = this.smartCableTextures.getOddTextureForChannels(channels);
|
||||
Sprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright(true);
|
||||
|
||||
cubeBuilder.setTexture(oddChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||
addStraightCoveredCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
cubeBuilder.setTexture(evenChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
||||
addStraightCoveredCableSizedCube(facing, cubeBuilder);
|
||||
}
|
||||
|
||||
public void addConstrainedSmartConnection(Direction facing, AEColor cableColor, int distanceFromEdge, int channels,
|
||||
List<BakedQuad> quadsOut) {
|
||||
// Same as with covered cables, the smart cable's core extends up to 5 voxels
|
||||
// away from the edge.
|
||||
// Drawing a connection to any point before that point is fruitless
|
||||
if (distanceFromEdge >= 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.SMART).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
addCoveredCableSizedCube(facing, distanceFromEdge, cubeBuilder);
|
||||
|
||||
Sprite oddChannel = this.smartCableTextures.getOddTextureForChannels(channels);
|
||||
Sprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright(true);
|
||||
|
||||
cubeBuilder.setTexture(oddChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||
addCoveredCableSizedCube(facing, distanceFromEdge, cubeBuilder);
|
||||
|
||||
cubeBuilder.setTexture(evenChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
||||
addCoveredCableSizedCube(facing, distanceFromEdge, cubeBuilder);
|
||||
}
|
||||
|
||||
public void addDenseCoveredConnection(Direction facing, AEColor cableColor, AECableType connectionType,
|
||||
boolean cableBusAdjacent, List<BakedQuad> quadsOut) {
|
||||
// Dense cables only render their connections as dense if the adjacent blocks
|
||||
// actually wants that
|
||||
if (connectionType == AECableType.COVERED || connectionType == AECableType.SMART
|
||||
|| connectionType == AECableType.GLASS) {
|
||||
this.addCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent, quadsOut);
|
||||
return;
|
||||
}
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
// We render all faces except the one on the connection side
|
||||
cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing)));
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.DENSE_COVERED).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
addDenseCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
// Reset back to normal rendering for the rest
|
||||
cubeBuilder.setRenderFullBright(false);
|
||||
cubeBuilder.setTexture(texture);
|
||||
}
|
||||
|
||||
public void addDenseSmartConnection(Direction facing, AEColor cableColor, AECableType connectionType,
|
||||
boolean cableBusAdjacent, int channels, List<BakedQuad> quadsOut) {
|
||||
// Dense cables only render their connections as dense if the adjacent blocks
|
||||
// actually wants that
|
||||
if (connectionType == AECableType.SMART) {
|
||||
this.addSmartConnection(facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut);
|
||||
return;
|
||||
} else if (connectionType == AECableType.COVERED || connectionType == AECableType.GLASS) {
|
||||
this.addCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent, quadsOut);
|
||||
return;
|
||||
} else if (connectionType == AECableType.DENSE_COVERED) {
|
||||
this.addDenseCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent, quadsOut);
|
||||
return;
|
||||
}
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
// We render all faces except the one on the connection side
|
||||
cubeBuilder.setDrawFaces(EnumSet.complementOf(EnumSet.of(facing)));
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.DENSE_SMART).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
addDenseCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
// Dense cables show used channels in groups of 4, rounded up
|
||||
channels = (channels + 3) / 4;
|
||||
|
||||
Sprite oddChannel = this.smartCableTextures.getOddTextureForChannels(channels);
|
||||
Sprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright(true);
|
||||
|
||||
cubeBuilder.setTexture(oddChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||
addDenseCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
cubeBuilder.setTexture(evenChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
||||
addDenseCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
// Reset back to normal rendering for the rest
|
||||
cubeBuilder.setRenderFullBright(false);
|
||||
cubeBuilder.setTexture(texture);
|
||||
}
|
||||
|
||||
public void addStraightDenseCoveredConnection(Direction facing, AEColor cableColor, List<BakedQuad> quadsOut) {
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.DENSE_COVERED).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
setStraightCableUVs(cubeBuilder, facing, 5, 11);
|
||||
|
||||
addStraightDenseCableSizedCube(facing, cubeBuilder);
|
||||
}
|
||||
|
||||
public void addStraightDenseSmartConnection(Direction facing, AEColor cableColor, int channels,
|
||||
List<BakedQuad> quadsOut) {
|
||||
CubeBuilder cubeBuilder = new CubeBuilder(quadsOut);
|
||||
|
||||
Sprite texture = this.connectionTextures.get(AECableType.DENSE_SMART).get(cableColor);
|
||||
cubeBuilder.setTexture(texture);
|
||||
|
||||
setStraightCableUVs(cubeBuilder, facing, 5, 11);
|
||||
|
||||
addStraightDenseCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
// Dense cables show used channels in groups of 4, rounded up
|
||||
channels = (channels + 3) / 4;
|
||||
|
||||
Sprite oddChannel = this.smartCableTextures.getOddTextureForChannels(channels);
|
||||
Sprite evenChannel = this.smartCableTextures.getEvenTextureForChannels(channels);
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright(true);
|
||||
|
||||
cubeBuilder.setTexture(oddChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.blackVariant);
|
||||
addStraightDenseCableSizedCube(facing, cubeBuilder);
|
||||
|
||||
cubeBuilder.setTexture(evenChannel);
|
||||
cubeBuilder.setColorRGB(cableColor.whiteVariant);
|
||||
addStraightDenseCableSizedCube(facing, cubeBuilder);
|
||||
}
|
||||
|
||||
private static void addDenseCableSizedCube(Direction facing, CubeBuilder cubeBuilder) {
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
cubeBuilder.addCube(4, 0, 4, 12, 5, 12);
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube(11, 4, 4, 16, 12, 12);
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube(4, 4, 0, 12, 12, 5);
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube(4, 4, 11, 12, 12, 16);
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube(4, 11, 4, 12, 16, 12);
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube(0, 4, 4, 5, 12, 12);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a cube to the given cube builder that has the size of a dense cable
|
||||
// connection and spans the entire block
|
||||
// for the given direction
|
||||
private static void addStraightDenseCableSizedCube(Direction facing, CubeBuilder cubeBuilder) {
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
case UP:
|
||||
cubeBuilder.setUvRotation(Direction.EAST, 3);
|
||||
cubeBuilder.addCube(3, 0, 3, 13, 16, 13);
|
||||
cubeBuilder.setUvRotation(Direction.EAST, 0);
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
cubeBuilder.setUvRotation(Direction.SOUTH, 3);
|
||||
cubeBuilder.setUvRotation(Direction.NORTH, 3);
|
||||
cubeBuilder.addCube(0, 3, 3, 16, 13, 13);
|
||||
cubeBuilder.setUvRotation(Direction.SOUTH, 0);
|
||||
cubeBuilder.setUvRotation(Direction.NORTH, 0);
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
cubeBuilder.setUvRotation(Direction.EAST, 3);
|
||||
cubeBuilder.setUvRotation(Direction.WEST, 3);
|
||||
cubeBuilder.addCube(3, 3, 0, 13, 13, 16);
|
||||
cubeBuilder.setUvRotation(Direction.EAST, 0);
|
||||
cubeBuilder.setUvRotation(Direction.WEST, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a cube to the given cube builder that has the size of a covered cable
|
||||
// connection from the core of the cable
|
||||
// to the given face
|
||||
private static void addCoveredCableSizedCube(Direction facing, CubeBuilder cubeBuilder) {
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
cubeBuilder.addCube(6, 0, 6, 10, 5, 10);
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube(11, 6, 6, 16, 10, 10);
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube(6, 6, 0, 10, 10, 5);
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube(6, 6, 11, 10, 10, 16);
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube(6, 11, 6, 10, 16, 10);
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube(0, 6, 6, 5, 10, 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a cube to the given cube builder that has the size of a covered cable
|
||||
// connection and spans the entire block
|
||||
// for the given direction
|
||||
private static void addStraightCoveredCableSizedCube(Direction facing, CubeBuilder cubeBuilder) {
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
case UP:
|
||||
cubeBuilder.setUvRotation(Direction.EAST, 3);
|
||||
cubeBuilder.addCube(5, 0, 5, 11, 16, 11);
|
||||
cubeBuilder.setUvRotation(Direction.EAST, 0);
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
cubeBuilder.setUvRotation(Direction.SOUTH, 3);
|
||||
cubeBuilder.setUvRotation(Direction.NORTH, 3);
|
||||
cubeBuilder.addCube(0, 5, 5, 16, 11, 11);
|
||||
cubeBuilder.setUvRotation(Direction.SOUTH, 0);
|
||||
cubeBuilder.setUvRotation(Direction.NORTH, 0);
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
cubeBuilder.setUvRotation(Direction.EAST, 3);
|
||||
cubeBuilder.setUvRotation(Direction.WEST, 3);
|
||||
cubeBuilder.addCube(5, 5, 0, 11, 11, 16);
|
||||
cubeBuilder.setUvRotation(Direction.EAST, 0);
|
||||
cubeBuilder.setUvRotation(Direction.WEST, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void addCoveredCableSizedCube(Direction facing, int distanceFromEdge, CubeBuilder cubeBuilder) {
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
cubeBuilder.addCube(6, distanceFromEdge, 6, 10, 5, 10);
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube(11, 6, 6, 16 - distanceFromEdge, 10, 10);
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube(6, 6, distanceFromEdge, 10, 10, 5);
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube(6, 6, 11, 10, 10, 16 - distanceFromEdge);
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube(6, 11, 6, 10, 16 - distanceFromEdge, 10);
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube(distanceFromEdge, 6, 6, 5, 10, 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This renders a slightly bigger covered cable connection to the specified
|
||||
* side. This is used to connect cable cores with adjacent machines that do not
|
||||
* want to be connected to using a glass cable connection. This applies to most
|
||||
* machines (interfaces, etc.)
|
||||
*/
|
||||
private void addBigCoveredCableSizedCube(Direction facing, CubeBuilder cubeBuilder) {
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
cubeBuilder.addCube(5, 0, 5, 11, 4, 11);
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube(12, 5, 5, 16, 11, 11);
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube(5, 5, 0, 11, 11, 4);
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube(5, 5, 12, 11, 11, 16);
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube(5, 12, 5, 11, 16, 11);
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube(0, 5, 5, 4, 11, 11);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get all textures needed for building the actual cable quads
|
||||
public static List<SpriteIdentifier> getTextures() {
|
||||
List<SpriteIdentifier> locations = new ArrayList<>();
|
||||
|
||||
for (CableCoreType coreType : CableCoreType.values()) {
|
||||
for (AEColor color : AEColor.values()) {
|
||||
locations.add(coreType.getTexture(color));
|
||||
}
|
||||
}
|
||||
|
||||
for (AECableType cableType : AECableType.VALIDCABLES) {
|
||||
for (AEColor color : AEColor.values()) {
|
||||
locations.add(getConnectionTexture(cableType, color));
|
||||
}
|
||||
}
|
||||
|
||||
Collections.addAll(locations, SmartCableTextures.SMART_CHANNELS_TEXTURES);
|
||||
|
||||
return locations;
|
||||
}
|
||||
|
||||
public Sprite getCoreTexture(CableCoreType coreType, AEColor color) {
|
||||
return this.coreTextures.get(coreType).get(color);
|
||||
}
|
||||
}
|
||||
@@ -1,348 +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.cablebus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
|
||||
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
public class CableBusBakedModel implements BakedModel {
|
||||
|
||||
private static final Map<CableBusRenderState, List<BakedQuad>> CABLE_MODEL_CACHE = new HashMap<>();
|
||||
|
||||
private final CableBuilder cableBuilder;
|
||||
|
||||
private final FacadeBuilder facadeBuilder;
|
||||
|
||||
private final Map<Identifier, BakedModel> partModels;
|
||||
|
||||
private final Sprite particleTexture;
|
||||
|
||||
CableBusBakedModel(CableBuilder cableBuilder, FacadeBuilder facadeBuilder,
|
||||
Map<Identifier, BakedModel> partModels, Sprite particleTexture) {
|
||||
this.cableBuilder = cableBuilder;
|
||||
this.facadeBuilder = facadeBuilder;
|
||||
this.partModels = partModels;
|
||||
this.particleTexture = particleTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
return getQuads(state, side, rand, EmptyModelData.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand,
|
||||
IModelData data) {
|
||||
CableBusRenderState renderState = data.getData(CableBusRenderState.PROPERTY);
|
||||
|
||||
if (renderState == null || side != null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
RenderLayer layer = MinecraftForgeClient.getRenderLayer();
|
||||
|
||||
List<BakedQuad> quads = new ArrayList<>();
|
||||
|
||||
// The core parts of the cable will only be rendered in the CUTOUT layer.
|
||||
// Facades will add them selves to what ever the block would be rendered with,
|
||||
// except when transparent facades are enabled, they are forced to TRANSPARENT.
|
||||
if (layer == RenderLayer.getCutout()) {
|
||||
|
||||
// First, handle the cable at the center of the cable bus
|
||||
final List<BakedQuad> cableModel = CABLE_MODEL_CACHE.computeIfAbsent(renderState, k -> {
|
||||
final List<BakedQuad> model = new ArrayList<>();
|
||||
this.addCableQuads(renderState, model);
|
||||
return model;
|
||||
});
|
||||
quads.addAll(cableModel);
|
||||
|
||||
// Then handle attachments
|
||||
for (Direction facing : Direction.values()) {
|
||||
final IPartModel partModel = renderState.getAttachments().get(facing);
|
||||
if (partModel == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IModelData partModelData = renderState.getPartModelData().get(facing);
|
||||
if (partModelData == null) {
|
||||
partModelData = EmptyModelData.INSTANCE;
|
||||
}
|
||||
|
||||
for (Identifier model : partModel.getModels()) {
|
||||
BakedModel bakedModel = this.partModels.get(model);
|
||||
|
||||
if (bakedModel == null) {
|
||||
throw new IllegalStateException("Trying to use an unregistered part model: " + model);
|
||||
}
|
||||
|
||||
List<BakedQuad> partQuads = bakedModel.getQuads(state, null, rand, partModelData);
|
||||
|
||||
// Rotate quads accordingly
|
||||
QuadRotator rotator = new QuadRotator();
|
||||
partQuads = rotator.rotateQuads(partQuads, facing, Direction.UP);
|
||||
|
||||
quads.addAll(partQuads);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.facadeBuilder.buildFacadeQuads(layer, renderState, rand, quads, this.partModels::get);
|
||||
|
||||
return quads;
|
||||
}
|
||||
|
||||
// Determines whether a cable is connected to exactly two sides that are
|
||||
// opposite each other
|
||||
private static boolean isStraightLine(AECableType cableType, EnumMap<Direction, AECableType> sides) {
|
||||
final Iterator<Entry<Direction, AECableType>> it = sides.entrySet().iterator();
|
||||
if (!it.hasNext()) {
|
||||
return false; // No connections
|
||||
}
|
||||
|
||||
final Entry<Direction, AECableType> nextConnection = it.next();
|
||||
final Direction firstSide = nextConnection.getKey();
|
||||
final AECableType firstType = nextConnection.getValue();
|
||||
|
||||
if (!it.hasNext()) {
|
||||
return false; // Only a single connection
|
||||
}
|
||||
if (firstSide.getOpposite() != it.next().getKey()) {
|
||||
return false; // Connected to two sides that are not opposite each other
|
||||
}
|
||||
if (it.hasNext()) {
|
||||
return false; // Must not have any other connection points
|
||||
}
|
||||
|
||||
final AECableType secondType = sides.get(firstSide.getOpposite());
|
||||
|
||||
return firstType == secondType && cableType == firstType && cableType == secondType;
|
||||
}
|
||||
|
||||
private void addCableQuads(CableBusRenderState renderState, List<BakedQuad> quadsOut) {
|
||||
AECableType cableType = renderState.getCableType();
|
||||
if (cableType == AECableType.NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
AEColor cableColor = renderState.getCableColor();
|
||||
EnumMap<Direction, AECableType> connectionTypes = renderState.getConnectionTypes();
|
||||
|
||||
// If the connection is straight, no busses are attached, and no covered core
|
||||
// has been forced (in case of glass
|
||||
// cables), then render the cable as a simplified straight line.
|
||||
boolean noAttachments = !renderState.getAttachments().values().stream()
|
||||
.anyMatch(IPartModel::requireCableConnection);
|
||||
if (noAttachments && isStraightLine(cableType, connectionTypes)) {
|
||||
Direction facing = connectionTypes.keySet().iterator().next();
|
||||
|
||||
switch (cableType) {
|
||||
case GLASS:
|
||||
this.cableBuilder.addStraightGlassConnection(facing, cableColor, quadsOut);
|
||||
break;
|
||||
case COVERED:
|
||||
this.cableBuilder.addStraightCoveredConnection(facing, cableColor, quadsOut);
|
||||
break;
|
||||
case SMART:
|
||||
this.cableBuilder.addStraightSmartConnection(facing, cableColor,
|
||||
renderState.getChannelsOnSide().get(facing), quadsOut);
|
||||
break;
|
||||
case DENSE_COVERED:
|
||||
this.cableBuilder.addStraightDenseCoveredConnection(facing, cableColor, quadsOut);
|
||||
break;
|
||||
case DENSE_SMART:
|
||||
this.cableBuilder.addStraightDenseSmartConnection(facing, cableColor,
|
||||
renderState.getChannelsOnSide().get(facing), quadsOut);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return; // Don't render the other form of connection
|
||||
}
|
||||
|
||||
this.cableBuilder.addCableCore(renderState.getCoreType(), cableColor, quadsOut);
|
||||
|
||||
// Render all internal connections to attachments
|
||||
EnumMap<Direction, Integer> attachmentConnections = renderState.getAttachmentConnections();
|
||||
for (Direction facing : attachmentConnections.keySet()) {
|
||||
int distance = attachmentConnections.get(facing);
|
||||
int channels = renderState.getChannelsOnSide().get(facing);
|
||||
|
||||
switch (cableType) {
|
||||
case GLASS:
|
||||
this.cableBuilder.addConstrainedGlassConnection(facing, cableColor, distance, quadsOut);
|
||||
break;
|
||||
case COVERED:
|
||||
this.cableBuilder.addConstrainedCoveredConnection(facing, cableColor, distance, quadsOut);
|
||||
break;
|
||||
case SMART:
|
||||
this.cableBuilder.addConstrainedSmartConnection(facing, cableColor, distance, channels, quadsOut);
|
||||
break;
|
||||
case DENSE_COVERED:
|
||||
case DENSE_SMART:
|
||||
// Dense cables do not render connections to parts since none can be attached
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Render all outgoing connections using the appropriate type
|
||||
for (final Entry<Direction, AECableType> connection : connectionTypes.entrySet()) {
|
||||
final Direction facing = connection.getKey();
|
||||
final AECableType connectionType = connection.getValue();
|
||||
final boolean cableBusAdjacent = renderState.getCableBusAdjacent().contains(facing);
|
||||
final int channels = renderState.getChannelsOnSide().get(facing);
|
||||
|
||||
switch (cableType) {
|
||||
case GLASS:
|
||||
this.cableBuilder.addGlassConnection(facing, cableColor, connectionType, cableBusAdjacent,
|
||||
quadsOut);
|
||||
break;
|
||||
case COVERED:
|
||||
this.cableBuilder.addCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent,
|
||||
quadsOut);
|
||||
break;
|
||||
case SMART:
|
||||
this.cableBuilder.addSmartConnection(facing, cableColor, connectionType, cableBusAdjacent, channels,
|
||||
quadsOut);
|
||||
break;
|
||||
case DENSE_COVERED:
|
||||
this.cableBuilder.addDenseCoveredConnection(facing, cableColor, connectionType, cableBusAdjacent,
|
||||
quadsOut);
|
||||
break;
|
||||
case DENSE_SMART:
|
||||
this.cableBuilder.addDenseSmartConnection(facing, cableColor, connectionType, cableBusAdjacent,
|
||||
channels, quadsOut);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of texture sprites appropriate for particles (digging, etc.)
|
||||
* given the render state for a cable bus.
|
||||
*/
|
||||
public List<Sprite> getParticleTextures(CableBusRenderState renderState) {
|
||||
CableCoreType coreType = CableCoreType.fromCableType(renderState.getCableType());
|
||||
AEColor cableColor = renderState.getCableColor();
|
||||
|
||||
List<Sprite> result = new ArrayList<>();
|
||||
|
||||
if (coreType != null) {
|
||||
result.add(this.cableBuilder.getCoreTexture(coreType, cableColor));
|
||||
}
|
||||
|
||||
// If no core is present, just use the first part that comes into play
|
||||
for (Direction side : renderState.getAttachments().keySet()) {
|
||||
IPartModel partModel = renderState.getAttachments().get(side);
|
||||
|
||||
for (Identifier model : partModel.getModels()) {
|
||||
BakedModel bakedModel = this.partModels.get(model);
|
||||
|
||||
if (bakedModel == null) {
|
||||
throw new IllegalStateException("Trying to use an unregistered part model: " + model);
|
||||
}
|
||||
|
||||
Sprite particleTexture = bakedModel.getSprite();
|
||||
|
||||
// If a part sub-model has no particle texture (indicated by it being the
|
||||
// missing texture),
|
||||
// don't add it, so we don't get ugly missing texture break particles.
|
||||
if (!isMissingTexture(particleTexture)) {
|
||||
result.add(particleTexture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isMissingTexture(Sprite particleTexture) {
|
||||
return particleTexture instanceof MissingTextureSprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAmbientOcclusion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDepth() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideLit() {
|
||||
return false;// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sprite getSprite() {
|
||||
return this.particleTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelTransformation getTransformation() {
|
||||
return ModelTransformation.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelOverrideList getOverrides() {
|
||||
return ModelOverrideList.EMPTY;
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
CABLE_MODEL_CACHE.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
import net.minecraft.client.particle.ParticleTextureSheet;
|
||||
import net.minecraft.client.particle.SpriteBillboardParticle;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.world.World;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
// Derived from Vanilla's BreakingParticle, but allows
|
||||
// a texture to be specified directly rather than via an itemstack
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class CableBusBreakingParticle extends SpriteBillboardParticle {
|
||||
|
||||
private final float field_217571_C;
|
||||
private final float field_217572_F;
|
||||
|
||||
public CableBusBreakingParticle(World world, double x, double y, double z, double speedX, double speedY,
|
||||
double speedZ, Sprite sprite) {
|
||||
super(world, x, y, z, speedX, speedY, speedZ);
|
||||
this.setSprite(sprite);
|
||||
this.gravityStrength = 1.0F;
|
||||
this.particleScale /= 2.0F;
|
||||
this.field_217571_C = this.rand.nextFloat() * 3.0F;
|
||||
this.field_217572_F = this.rand.nextFloat() * 3.0F;
|
||||
}
|
||||
|
||||
public CableBusBreakingParticle(World world, double x, double y, double z, Sprite sprite) {
|
||||
this(world, x, y, z, 0, 0, 0, sprite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleTextureSheet getRenderType() {
|
||||
return ParticleTextureSheet.TERRAIN_SHEET;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getMinU() {
|
||||
return this.sprite.getInterpolatedU((this.field_217571_C + 1.0F) / 4.0F * 16.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getMaxU() {
|
||||
return this.sprite.getInterpolatedU(this.field_217571_C / 4.0F * 16.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getMinV() {
|
||||
return this.sprite.getInterpolatedV(this.field_217572_F / 4.0F * 16.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getMaxV() {
|
||||
return this.sprite.getInterpolatedV((this.field_217572_F + 1.0F) / 4.0F * 16.0F);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,94 +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.cablebus;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.IModelTransform;
|
||||
import net.minecraft.client.render.model.IUnbakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.render.model.ModelLoader;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
|
||||
/**
|
||||
* The built-in model for the cable bus block.
|
||||
*/
|
||||
public class CableBusModel implements IModelGeometry<CableBusModel> {
|
||||
|
||||
private final PartModels partModels;
|
||||
|
||||
public CableBusModel(PartModels partModels) {
|
||||
this.partModels = partModels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelLoader bakery,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetter, IModelTransform modelTransform,
|
||||
ModelOverrideList overrides, Identifier modelLocation) {
|
||||
Map<Identifier, BakedModel> partModels = this.loadPartModels(bakery, spriteGetter, modelTransform);
|
||||
|
||||
CableBuilder cableBuilder = new CableBuilder(spriteGetter);
|
||||
FacadeBuilder facadeBuilder = new FacadeBuilder();
|
||||
|
||||
// This should normally not be used, but we *have* to provide a particle texture
|
||||
// or otherwise damage models will
|
||||
// crash
|
||||
Sprite particleTexture = cableBuilder.getCoreTexture(CableCoreType.GLASS, AEColor.TRANSPARENT);
|
||||
|
||||
return new CableBusBakedModel(cableBuilder, facadeBuilder, partModels, particleTexture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SpriteIdentifier> getTextures(IModelConfiguration owner,
|
||||
Function<Identifier, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.unmodifiableList(CableBuilder.getTextures());
|
||||
}
|
||||
|
||||
private Map<Identifier, BakedModel> loadPartModels(ModelLoader bakery,
|
||||
Function<SpriteIdentifier, Sprite> spriteGetterIn, IModelTransform transformIn) {
|
||||
ImmutableMap.Builder<Identifier, BakedModel> result = ImmutableMap.builder();
|
||||
|
||||
for (Identifier location : this.partModels.getModels()) {
|
||||
BakedModel bakedModel = bakery.getBakedModel(location, transformIn, spriteGetterIn);
|
||||
if (bakedModel == null) {
|
||||
AELog.warn("Failed to bake part model {}", location);
|
||||
} else {
|
||||
result.put(location, bakedModel);
|
||||
}
|
||||
}
|
||||
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
|
||||
import appeng.core.features.registries.PartModels;
|
||||
|
||||
public class CableBusModelLoader implements IModelLoader<CableBusModel> {
|
||||
|
||||
private final PartModels partModels;
|
||||
|
||||
public CableBusModelLoader(PartModels partModels) {
|
||||
this.partModels = partModels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
CableBusBakedModel.clearCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableBusModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
|
||||
return new CableBusModel(partModels);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,216 +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.cablebus;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ILightReader;
|
||||
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
/**
|
||||
* This class captures the entire rendering state needed for a cable bus and
|
||||
* transports it to the rendering thread for processing.
|
||||
*/
|
||||
public class CableBusRenderState {
|
||||
|
||||
public static final ModelProperty<CableBusRenderState> PROPERTY = new ModelProperty<>();
|
||||
|
||||
// The cable type used for rendering the outgoing connections to other blocks
|
||||
// and attached parts
|
||||
private AECableType cableType = AECableType.NONE;
|
||||
|
||||
// The type to use for rendering the core of the cable.
|
||||
private CableCoreType coreType;
|
||||
|
||||
private AEColor cableColor = AEColor.TRANSPARENT;
|
||||
|
||||
// Describes the outgoing connections of this cable bus to other blocks, and how
|
||||
// they should be rendered
|
||||
private EnumMap<Direction, AECableType> connectionTypes = new EnumMap<>(Direction.class);
|
||||
|
||||
// Indicate on which sides signified by connectionTypes above, there is another
|
||||
// cable bus. If a side is connected,
|
||||
// but it is absent from this
|
||||
// set, then it means that there is a Grid host, but not a cable bus on that
|
||||
// side (i.e. an interface, a controller,
|
||||
// etc.)
|
||||
private EnumSet<Direction> cableBusAdjacent = EnumSet.noneOf(Direction.class);
|
||||
|
||||
// Specifies the number of channels used for the connection to a given side.
|
||||
// Only contains entries if
|
||||
// connections contains a corresponding entry.
|
||||
private EnumMap<Direction, Integer> channelsOnSide = new EnumMap<>(Direction.class);
|
||||
|
||||
private EnumMap<Direction, IPartModel> attachments = new EnumMap<>(Direction.class);
|
||||
|
||||
// For each attachment, this contains the distance from the edge until which a
|
||||
// cable connection should be drawn
|
||||
private EnumMap<Direction, Integer> attachmentConnections = new EnumMap<>(Direction.class);
|
||||
|
||||
// Contains the facade to use for each side that has a facade attached
|
||||
private EnumMap<Direction, FacadeRenderState> facades = new EnumMap<>(Direction.class);
|
||||
|
||||
// Used for Facades.
|
||||
private WeakReference<ILightReader> world;
|
||||
private BlockPos pos;
|
||||
|
||||
// Contains the bounding boxes of all parts on the cable bus to allow facades to
|
||||
// cut out holes for the parts. This
|
||||
// list is only populated if there are
|
||||
// facades on this cable bus
|
||||
private List<Box> boundingBoxes = new ArrayList<>();
|
||||
|
||||
// Additional model data passed to the part models
|
||||
private EnumMap<Direction, IModelData> partModelData = new EnumMap<>(Direction.class);
|
||||
|
||||
public CableCoreType getCoreType() {
|
||||
return this.coreType;
|
||||
}
|
||||
|
||||
public void setCoreType(CableCoreType coreType) {
|
||||
this.coreType = coreType;
|
||||
}
|
||||
|
||||
public AECableType getCableType() {
|
||||
return this.cableType;
|
||||
}
|
||||
|
||||
public void setCableType(AECableType cableType) {
|
||||
this.cableType = cableType;
|
||||
}
|
||||
|
||||
public AEColor getCableColor() {
|
||||
return this.cableColor;
|
||||
}
|
||||
|
||||
public void setCableColor(AEColor cableColor) {
|
||||
this.cableColor = cableColor;
|
||||
}
|
||||
|
||||
public EnumMap<Direction, Integer> getChannelsOnSide() {
|
||||
return this.channelsOnSide;
|
||||
}
|
||||
|
||||
public EnumMap<Direction, AECableType> getConnectionTypes() {
|
||||
return this.connectionTypes;
|
||||
}
|
||||
|
||||
public void setConnectionTypes(EnumMap<Direction, AECableType> connectionTypes) {
|
||||
this.connectionTypes = connectionTypes;
|
||||
}
|
||||
|
||||
public void setChannelsOnSide(EnumMap<Direction, Integer> channelsOnSide) {
|
||||
this.channelsOnSide = channelsOnSide;
|
||||
}
|
||||
|
||||
public EnumSet<Direction> getCableBusAdjacent() {
|
||||
return this.cableBusAdjacent;
|
||||
}
|
||||
|
||||
public void setCableBusAdjacent(EnumSet<Direction> cableBusAdjacent) {
|
||||
this.cableBusAdjacent = cableBusAdjacent;
|
||||
}
|
||||
|
||||
public EnumMap<Direction, IPartModel> getAttachments() {
|
||||
return this.attachments;
|
||||
}
|
||||
|
||||
public EnumMap<Direction, Integer> getAttachmentConnections() {
|
||||
return this.attachmentConnections;
|
||||
}
|
||||
|
||||
public EnumMap<Direction, FacadeRenderState> getFacades() {
|
||||
return this.facades;
|
||||
}
|
||||
|
||||
public ILightReader getWorld() {
|
||||
return this.world.get();
|
||||
}
|
||||
|
||||
public void setWorld(ILightReader world) {
|
||||
this.world = new WeakReference<>(world);
|
||||
}
|
||||
|
||||
public BlockPos getPos() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
public void setPos(BlockPos pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public List<Box> getBoundingBoxes() {
|
||||
return this.boundingBoxes;
|
||||
}
|
||||
|
||||
public EnumMap<Direction, IModelData> getPartModelData() {
|
||||
return this.partModelData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((this.attachmentConnections == null) ? 0 : this.attachmentConnections.hashCode());
|
||||
result = prime * result + ((this.cableBusAdjacent == null) ? 0 : this.cableBusAdjacent.hashCode());
|
||||
result = prime * result + ((this.cableColor == null) ? 0 : this.cableColor.hashCode());
|
||||
result = prime * result + ((this.cableType == null) ? 0 : this.cableType.hashCode());
|
||||
result = prime * result + ((this.channelsOnSide == null) ? 0 : this.channelsOnSide.hashCode());
|
||||
result = prime * result + ((this.connectionTypes == null) ? 0 : this.connectionTypes.hashCode());
|
||||
result = prime * result + ((this.coreType == null) ? 0 : this.coreType.hashCode());
|
||||
result = prime * result + ((this.partModelData == null) ? 0 : this.partModelData.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final CableBusRenderState other = (CableBusRenderState) obj;
|
||||
|
||||
return this.cableColor == other.cableColor && this.cableType == other.cableType
|
||||
&& this.coreType == other.coreType
|
||||
&& Objects.equals(this.attachmentConnections, other.attachmentConnections)
|
||||
&& Objects.equals(this.cableBusAdjacent, other.cableBusAdjacent)
|
||||
&& Objects.equals(this.channelsOnSide, other.channelsOnSide)
|
||||
&& Objects.equals(this.connectionTypes, other.connectionTypes)
|
||||
&& Objects.equals(this.partModelData, other.partModelData);
|
||||
}
|
||||
}
|
||||
@@ -1,80 +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.cablebus;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
/**
|
||||
* AE can render the core of a cable (the core that connections are made to, in
|
||||
* case the cable is not a straight line) in three different ways: - Glass -
|
||||
* Covered (also used by the Smart Cable) - Dense
|
||||
*/
|
||||
public enum CableCoreType {
|
||||
GLASS("parts/cable/core/glass"), COVERED("parts/cable/core/covered"), DENSE("parts/cable/core/dense_smart");
|
||||
|
||||
private static final Map<AECableType, CableCoreType> cableMapping = generateCableMapping();
|
||||
|
||||
/**
|
||||
* Creates the mapping that assigns a cable core type to an AE cable type.
|
||||
*/
|
||||
private static Map<AECableType, CableCoreType> generateCableMapping() {
|
||||
|
||||
Map<AECableType, CableCoreType> result = new EnumMap<>(AECableType.class);
|
||||
|
||||
result.put(AECableType.GLASS, CableCoreType.GLASS);
|
||||
result.put(AECableType.COVERED, CableCoreType.COVERED);
|
||||
result.put(AECableType.SMART, CableCoreType.COVERED);
|
||||
result.put(AECableType.DENSE_COVERED, CableCoreType.DENSE);
|
||||
result.put(AECableType.DENSE_SMART, CableCoreType.DENSE);
|
||||
|
||||
return ImmutableMap.copyOf(result);
|
||||
}
|
||||
|
||||
private final String textureFolder;
|
||||
|
||||
CableCoreType(String textureFolder) {
|
||||
this.textureFolder = textureFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The type of core that should be rendered when the given cable isn't
|
||||
* straight and needs to have a core to attach connections to. Is null
|
||||
* for the NULL cable.
|
||||
*/
|
||||
public static CableCoreType fromCableType(AECableType cableType) {
|
||||
return cableMapping.get(cableType);
|
||||
}
|
||||
|
||||
public SpriteIdentifier getTexture(AEColor color) {
|
||||
return new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX,
|
||||
new Identifier(AppEng.MOD_ID, this.textureFolder + "/" + color.name().toLowerCase()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,466 +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.cablebus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.client.util.math.Vector4f;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
|
||||
/**
|
||||
* Builds the quads for a cube.
|
||||
*/
|
||||
public class CubeBuilder {
|
||||
|
||||
private final List<BakedQuad> output;
|
||||
|
||||
private final EnumMap<Direction, Sprite> textures = new EnumMap<>(Direction.class);
|
||||
|
||||
private EnumSet<Direction> drawFaces = EnumSet.allOf(Direction.class);
|
||||
|
||||
private final EnumMap<Direction, Vector4f> customUv = new EnumMap<>(Direction.class);
|
||||
|
||||
private byte[] uvRotations = new byte[Direction.values().length];
|
||||
|
||||
private int color = 0xFFFFFFFF;
|
||||
|
||||
private boolean useStandardUV = false;
|
||||
|
||||
private boolean renderFullBright;
|
||||
|
||||
public CubeBuilder(List<BakedQuad> output) {
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public CubeBuilder() {
|
||||
this(new ArrayList<>(6));
|
||||
}
|
||||
|
||||
public void addCube(float x1, float y1, float z1, float x2, float y2, float z2) {
|
||||
x1 /= 16.0f;
|
||||
y1 /= 16.0f;
|
||||
z1 /= 16.0f;
|
||||
x2 /= 16.0f;
|
||||
y2 /= 16.0f;
|
||||
z2 /= 16.0f;
|
||||
|
||||
for (Direction face : this.drawFaces) {
|
||||
this.putFace(face, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
}
|
||||
|
||||
public void addQuad(Direction face, float x1, float y1, float z1, float x2, float y2, float z2) {
|
||||
this.putFace(face, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
private static final class UvVector {
|
||||
float u1;
|
||||
float u2;
|
||||
float v1;
|
||||
float v2;
|
||||
}
|
||||
|
||||
private void putFace(Direction face, float x1, float y1, float z1, float x2, float y2, float z2) {
|
||||
|
||||
Sprite texture = this.textures.get(face);
|
||||
|
||||
BakedQuadBuilder builder = new BakedQuadBuilder(texture);
|
||||
builder.setQuadOrientation(face);
|
||||
builder.setQuadTint(-1);
|
||||
builder.setApplyDiffuseLighting(true);
|
||||
|
||||
UvVector uv = new UvVector();
|
||||
|
||||
// The user might have set specific UV coordinates for this face
|
||||
Vector4f customUv = this.customUv.get(face);
|
||||
if (customUv != null) {
|
||||
uv.u1 = texture.getInterpolatedU(customUv.getX());
|
||||
uv.v1 = texture.getInterpolatedV(customUv.getY());
|
||||
uv.u2 = texture.getInterpolatedU(customUv.getZ());
|
||||
uv.v2 = texture.getInterpolatedV(customUv.getW());
|
||||
} else if (this.useStandardUV) {
|
||||
uv = this.getStandardUv(face, texture, x1, y1, z1, x2, y2, z2);
|
||||
} else {
|
||||
uv = this.getDefaultUv(face, texture, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
this.putVertexTR(builder, face, x2, y1, z1, uv);
|
||||
this.putVertexBR(builder, face, x2, y1, z2, uv);
|
||||
this.putVertexBL(builder, face, x1, y1, z2, uv);
|
||||
this.putVertexTL(builder, face, x1, y1, z1, uv);
|
||||
break;
|
||||
case UP:
|
||||
this.putVertexTL(builder, face, x1, y2, z1, uv);
|
||||
this.putVertexBL(builder, face, x1, y2, z2, uv);
|
||||
this.putVertexBR(builder, face, x2, y2, z2, uv);
|
||||
this.putVertexTR(builder, face, x2, y2, z1, uv);
|
||||
break;
|
||||
case NORTH:
|
||||
this.putVertexBR(builder, face, x2, y2, z1, uv);
|
||||
this.putVertexTR(builder, face, x2, y1, z1, uv);
|
||||
this.putVertexTL(builder, face, x1, y1, z1, uv);
|
||||
this.putVertexBL(builder, face, x1, y2, z1, uv);
|
||||
break;
|
||||
case SOUTH:
|
||||
this.putVertexBL(builder, face, x1, y2, z2, uv);
|
||||
this.putVertexTL(builder, face, x1, y1, z2, uv);
|
||||
this.putVertexTR(builder, face, x2, y1, z2, uv);
|
||||
this.putVertexBR(builder, face, x2, y2, z2, uv);
|
||||
break;
|
||||
case WEST:
|
||||
this.putVertexTL(builder, face, x1, y1, z1, uv);
|
||||
this.putVertexTR(builder, face, x1, y1, z2, uv);
|
||||
this.putVertexBR(builder, face, x1, y2, z2, uv);
|
||||
this.putVertexBL(builder, face, x1, y2, z1, uv);
|
||||
break;
|
||||
case EAST:
|
||||
this.putVertexBR(builder, face, x2, y2, z1, uv);
|
||||
this.putVertexBL(builder, face, x2, y2, z2, uv);
|
||||
this.putVertexTL(builder, face, x2, y1, z2, uv);
|
||||
this.putVertexTR(builder, face, x2, y1, z1, uv);
|
||||
break;
|
||||
}
|
||||
|
||||
this.output.add(builder.build());
|
||||
}
|
||||
|
||||
private UvVector getDefaultUv(Direction face, Sprite texture, float x1, float y1, float z1, float x2,
|
||||
float y2, float z2) {
|
||||
|
||||
UvVector uv = new UvVector();
|
||||
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
uv.u1 = texture.getInterpolatedU(x1 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(z1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(x2 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(z2 * 16);
|
||||
break;
|
||||
case UP:
|
||||
uv.u1 = texture.getInterpolatedU(x1 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(z1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(x2 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(z2 * 16);
|
||||
break;
|
||||
case NORTH:
|
||||
uv.u1 = texture.getInterpolatedU(x1 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(16 - y1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(x2 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(16 - y2 * 16);
|
||||
break;
|
||||
case SOUTH:
|
||||
uv.u1 = texture.getInterpolatedU(x1 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(16 - y1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(x2 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(16 - y2 * 16);
|
||||
break;
|
||||
case WEST:
|
||||
uv.u1 = texture.getInterpolatedU(z1 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(16 - y1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(z2 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(16 - y2 * 16);
|
||||
break;
|
||||
case EAST:
|
||||
uv.u1 = texture.getInterpolatedU(z2 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(16 - y1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(z1 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(16 - y2 * 16);
|
||||
break;
|
||||
}
|
||||
|
||||
return uv;
|
||||
}
|
||||
|
||||
private UvVector getStandardUv(Direction face, Sprite texture, float x1, float y1, float z1, float x2,
|
||||
float y2, float z2) {
|
||||
UvVector uv = new UvVector();
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
uv.u1 = texture.getInterpolatedU(x1 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(16 - z1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(x2 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(16 - z2 * 16);
|
||||
break;
|
||||
case UP:
|
||||
uv.u1 = texture.getInterpolatedU(x1 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(z1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(x2 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(z2 * 16);
|
||||
break;
|
||||
case NORTH:
|
||||
uv.u1 = texture.getInterpolatedU(16 - x1 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(16 - y1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(16 - x2 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(16 - y2 * 16);
|
||||
break;
|
||||
case SOUTH:
|
||||
uv.u1 = texture.getInterpolatedU(x1 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(16 - y1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(x2 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(16 - y2 * 16);
|
||||
break;
|
||||
case WEST:
|
||||
uv.u1 = texture.getInterpolatedU(z1 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(16 - y1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(z2 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(16 - y2 * 16);
|
||||
break;
|
||||
case EAST:
|
||||
uv.u1 = texture.getInterpolatedU(16 - z2 * 16);
|
||||
uv.v1 = texture.getInterpolatedV(16 - y1 * 16);
|
||||
uv.u2 = texture.getInterpolatedU(16 - z1 * 16);
|
||||
uv.v2 = texture.getInterpolatedV(16 - y2 * 16);
|
||||
break;
|
||||
}
|
||||
return uv;
|
||||
}
|
||||
|
||||
// uv.u1, uv.v1
|
||||
private void putVertexTL(BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv) {
|
||||
float u, v;
|
||||
|
||||
switch (this.uvRotations[face.ordinal()]) {
|
||||
default:
|
||||
case 0:
|
||||
u = uv.u1;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 1: // 90° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 2: // 180° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 3: // 270° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v1;
|
||||
break;
|
||||
}
|
||||
|
||||
this.putVertex(builder, face, x, y, z, u, v);
|
||||
}
|
||||
|
||||
// uv.u2, uv.v1
|
||||
private void putVertexTR(BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv) {
|
||||
float u, v;
|
||||
|
||||
switch (this.uvRotations[face.ordinal()]) {
|
||||
default:
|
||||
case 0:
|
||||
u = uv.u2;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 1: // 90° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 2: // 180° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 3: // 270° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v2;
|
||||
break;
|
||||
}
|
||||
this.putVertex(builder, face, x, y, z, u, v);
|
||||
}
|
||||
|
||||
// uv.u2, uv.v2
|
||||
private void putVertexBR(BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv) {
|
||||
|
||||
float u;
|
||||
float v;
|
||||
|
||||
switch (this.uvRotations[face.ordinal()]) {
|
||||
default:
|
||||
case 0:
|
||||
u = uv.u2;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 1: // 90° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 2: // 180° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 3: // 270° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v2;
|
||||
break;
|
||||
}
|
||||
|
||||
this.putVertex(builder, face, x, y, z, u, v);
|
||||
}
|
||||
|
||||
// uv.u1, uv.v2
|
||||
private void putVertexBL(BakedQuadBuilder builder, Direction face, float x, float y, float z, UvVector uv) {
|
||||
|
||||
float u;
|
||||
float v;
|
||||
|
||||
switch (this.uvRotations[face.ordinal()]) {
|
||||
default:
|
||||
case 0:
|
||||
u = uv.u1;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 1: // 90° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v2;
|
||||
break;
|
||||
case 2: // 180° clockwise
|
||||
u = uv.u2;
|
||||
v = uv.v1;
|
||||
break;
|
||||
case 3: // 270° clockwise
|
||||
u = uv.u1;
|
||||
v = uv.v1;
|
||||
break;
|
||||
}
|
||||
|
||||
this.putVertex(builder, face, x, y, z, u, v);
|
||||
}
|
||||
|
||||
private void putVertex(BakedQuadBuilder builder, Direction face, float x, float y, float z, float u, float v) {
|
||||
VertexFormat format = builder.getVertexFormat();
|
||||
|
||||
List<VertexFormatElement> elements = format.getElements();
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
VertexFormatElement e = elements.get(i);
|
||||
switch (e.getUsage()) {
|
||||
case POSITION:
|
||||
builder.put(i, x, y, z);
|
||||
break;
|
||||
case NORMAL:
|
||||
builder.put(i, face.getOffsetX(), face.getOffsetY(), face.getOffsetZ());
|
||||
break;
|
||||
case COLOR:
|
||||
// Color format is RGBA
|
||||
float r = (this.color >> 16 & 0xFF) / 255f;
|
||||
float g = (this.color >> 8 & 0xFF) / 255f;
|
||||
float b = (this.color & 0xFF) / 255f;
|
||||
float a = (this.color >> 24 & 0xFF) / 255f;
|
||||
builder.put(i, r, g, b, a);
|
||||
break;
|
||||
case UV:
|
||||
if (e.getIndex() == 0) {
|
||||
builder.put(i, u, v);
|
||||
break;
|
||||
} else if (e.getIndex() == 2 && renderFullBright) {
|
||||
// Force Brightness to 15, this is for full bright mode
|
||||
// this vertex element will only be present in that case
|
||||
final float lightMapU = (float) (15 * 0x20) / 0xFFFF;
|
||||
final float lightMapV = (float) (15 * 0x20) / 0xFFFF;
|
||||
builder.put(i, lightMapU, lightMapV);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
builder.put(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTexture(Sprite texture) {
|
||||
for (Direction face : Direction.values()) {
|
||||
this.textures.put(face, texture);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextures(Sprite up, Sprite down, Sprite north,
|
||||
Sprite south, Sprite east, Sprite west) {
|
||||
this.textures.put(Direction.UP, up);
|
||||
this.textures.put(Direction.DOWN, down);
|
||||
this.textures.put(Direction.NORTH, north);
|
||||
this.textures.put(Direction.SOUTH, south);
|
||||
this.textures.put(Direction.EAST, east);
|
||||
this.textures.put(Direction.WEST, west);
|
||||
}
|
||||
|
||||
public void setTexture(Direction facing, Sprite sprite) {
|
||||
this.textures.put(facing, sprite);
|
||||
}
|
||||
|
||||
public void setDrawFaces(EnumSet<Direction> drawFaces) {
|
||||
this.drawFaces = drawFaces;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vertex color for future vertices to the given RGB value, and forces
|
||||
* the alpha component to 255.
|
||||
*/
|
||||
public void setColorRGB(int color) {
|
||||
this.setColor(color | 0xFF000000);
|
||||
}
|
||||
|
||||
public void setColorRGB(float r, float g, float b) {
|
||||
this.setColorRGB((int) (r * 255) << 16 | (int) (g * 255) << 8 | (int) (b * 255));
|
||||
}
|
||||
|
||||
public void setRenderFullBright(boolean renderFullBright) {
|
||||
this.renderFullBright = renderFullBright;
|
||||
}
|
||||
|
||||
public void setCustomUv(Direction facing, float u1, float v1, float u2, float v2) {
|
||||
this.customUv.put(facing, new Vector4f(u1, v1, u2, v2));
|
||||
}
|
||||
|
||||
public void setUvRotation(Direction facing, int rotation) {
|
||||
if (rotation == 2) {
|
||||
rotation = 3;
|
||||
} else if (rotation == 3) {
|
||||
rotation = 2;
|
||||
}
|
||||
Preconditions.checkArgument(rotation >= 0 && rotation <= 3, "rotation");
|
||||
this.uvRotations[facing.ordinal()] = (byte) rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* CubeBuilder uses UV optimized for cables by default. This switches to
|
||||
* standard UV coordinates.
|
||||
*/
|
||||
public void useStandardUV() {
|
||||
this.useStandardUV = true;
|
||||
}
|
||||
|
||||
public List<BakedQuad> getOutput() {
|
||||
return this.output;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
import net.minecraft.world.level.ColorResolver;
|
||||
import net.minecraft.world.lighting.WorldLightManager;
|
||||
|
||||
@@ -35,14 +35,14 @@ import net.minecraft.world.lighting.WorldLightManager;
|
||||
*
|
||||
* @author covers1624
|
||||
*/
|
||||
public class FacadeBlockAccess implements ILightReader {
|
||||
public class FacadeBlockAccess implements BlockRenderView {
|
||||
|
||||
private final ILightReader world;
|
||||
private final BlockRenderView world;
|
||||
private final BlockPos pos;
|
||||
private final Direction side;
|
||||
private final BlockState state;
|
||||
|
||||
public FacadeBlockAccess(ILightReader world, BlockPos pos, Direction side, BlockState state) {
|
||||
public FacadeBlockAccess(BlockRenderView world, BlockPos pos, Direction side, BlockState state) {
|
||||
this.world = world;
|
||||
this.pos = pos;
|
||||
this.side = side;
|
||||
@@ -69,8 +69,8 @@ public class FacadeBlockAccess implements ILightReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldLightManager getLightManager() {
|
||||
return world.getLightManager();
|
||||
public WorldLightManager getLightingProvider() {
|
||||
return world.getLightingProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,435 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, 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.cablebus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.block.BlockRenderManager;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEAxisAlignedBB;
|
||||
import appeng.parts.misc.CableAnchorPart;
|
||||
import appeng.thirdparty.codechicken.lib.model.CachedFormat;
|
||||
import appeng.thirdparty.codechicken.lib.model.Quad;
|
||||
import appeng.thirdparty.codechicken.lib.model.pipeline.BakedPipeline;
|
||||
import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadAlphaOverride;
|
||||
import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadClamper;
|
||||
import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadCornerKicker;
|
||||
import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadFaceStripper;
|
||||
import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadReInterpolator;
|
||||
import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadTinter;
|
||||
|
||||
/**
|
||||
* The FacadeBuilder builds for facades..
|
||||
*
|
||||
* @author covers1624
|
||||
*/
|
||||
public class FacadeBuilder {
|
||||
|
||||
public static final double THICK_THICKNESS = 2D / 16D;
|
||||
public static final double THIN_THICKNESS = 1D / 16D;
|
||||
|
||||
public static final Box[] THICK_FACADE_BOXES = new Box[] {
|
||||
new Box(0.0, 0.0, 0.0, 1.0, THICK_THICKNESS, 1.0),
|
||||
new Box(0.0, 1.0 - THICK_THICKNESS, 0.0, 1.0, 1.0, 1.0),
|
||||
new Box(0.0, 0.0, 0.0, 1.0, 1.0, THICK_THICKNESS),
|
||||
new Box(0.0, 0.0, 1.0 - THICK_THICKNESS, 1.0, 1.0, 1.0),
|
||||
new Box(0.0, 0.0, 0.0, THICK_THICKNESS, 1.0, 1.0),
|
||||
new Box(1.0 - THICK_THICKNESS, 0.0, 0.0, 1.0, 1.0, 1.0) };
|
||||
|
||||
public static final Box[] THIN_FACADE_BOXES = new Box[] {
|
||||
new Box(0.0, 0.0, 0.0, 1.0, THIN_THICKNESS, 1.0),
|
||||
new Box(0.0, 1.0 - THIN_THICKNESS, 0.0, 1.0, 1.0, 1.0),
|
||||
new Box(0.0, 0.0, 0.0, 1.0, 1.0, THIN_THICKNESS),
|
||||
new Box(0.0, 0.0, 1.0 - THIN_THICKNESS, 1.0, 1.0, 1.0),
|
||||
new Box(0.0, 0.0, 0.0, THIN_THICKNESS, 1.0, 1.0),
|
||||
new Box(1.0 - THIN_THICKNESS, 0.0, 0.0, 1.0, 1.0, 1.0) };
|
||||
|
||||
private final ThreadLocal<BakedPipeline> pipelines = ThreadLocal.withInitial(() -> BakedPipeline.builder()
|
||||
// Clamper is responsible for clamping the vertex to the bounds specified.
|
||||
.addElement("clamper", QuadClamper.FACTORY)
|
||||
// Strips faces if they match a mask.
|
||||
.addElement("face_stripper", QuadFaceStripper.FACTORY)
|
||||
// Kicks the edge inner corners in, solves Z fighting
|
||||
.addElement("corner_kicker", QuadCornerKicker.FACTORY)
|
||||
// Re-Interpolates the UV's for the quad.
|
||||
.addElement("interp", QuadReInterpolator.FACTORY)
|
||||
// Tints the quad if we need it to. Disabled by default.
|
||||
.addElement("tinter", QuadTinter.FACTORY, false)
|
||||
// Overrides the quad's alpha if we are forcing transparent facades.
|
||||
.addElement("transparent", QuadAlphaOverride.FACTORY, false, e -> e.setAlphaOverride(0x4C / 255F)).build()//
|
||||
);
|
||||
private final ThreadLocal<Quad> collectors = ThreadLocal.withInitial(Quad::new);
|
||||
|
||||
public void buildFacadeQuads(RenderLayer layer, CableBusRenderState renderState, Random rand, List<BakedQuad> quads,
|
||||
Function<Identifier, BakedModel> modelLookup) {
|
||||
BakedPipeline pipeline = this.pipelines.get();
|
||||
Quad collectorQuad = this.collectors.get();
|
||||
boolean transparent = AEApi.instance().partHelper().getCableRenderMode().transparentFacades;
|
||||
Map<Direction, FacadeRenderState> facadeStates = renderState.getFacades();
|
||||
List<Box> partBoxes = renderState.getBoundingBoxes();
|
||||
Set<Direction> sidesWithParts = renderState.getAttachments().keySet();
|
||||
ILightReader parentWorld = renderState.getWorld();
|
||||
BlockPos pos = renderState.getPos();
|
||||
BlockColors blockColors = MinecraftClient.getInstance().getBlockColors();
|
||||
boolean thinFacades = isUseThinFacades(partBoxes);
|
||||
|
||||
for (Entry<Direction, FacadeRenderState> entry : facadeStates.entrySet()) {
|
||||
Direction side = entry.getKey();
|
||||
int sideIndex = side.ordinal();
|
||||
FacadeRenderState facadeRenderState = entry.getValue();
|
||||
boolean renderStilt = !sidesWithParts.contains(side);
|
||||
if (layer == RenderLayer.getCutout() && renderStilt) {
|
||||
for (Identifier part : CableAnchorPart.FACADE_MODELS.getModels()) {
|
||||
BakedModel partModel = modelLookup.apply(part);
|
||||
QuadRotator rotator = new QuadRotator();
|
||||
quads.addAll(rotator.rotateQuads(gatherQuads(partModel, null, rand, EmptyModelData.INSTANCE), side,
|
||||
Direction.UP));
|
||||
}
|
||||
}
|
||||
// If we are forcing transparency and this isn't the Translucent layer.
|
||||
if (transparent && layer != RenderLayer.getTranslucent()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockState blockState = facadeRenderState.getSourceBlock();
|
||||
// If we aren't forcing transparency let the block decide if it should render.
|
||||
if (!transparent && layer != null) {
|
||||
if (!RenderTypeLookup.canRenderInLayer(blockState, layer)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Box fullBounds = thinFacades ? THIN_FACADE_BOXES[sideIndex] : THICK_FACADE_BOXES[sideIndex];
|
||||
Box facadeBox = fullBounds;
|
||||
// If we are a transparent facade, we need to modify out BB.
|
||||
if (facadeRenderState.isTransparent()) {
|
||||
double offset = thinFacades ? THIN_THICKNESS : THICK_THICKNESS;
|
||||
AEAxisAlignedBB tmpBB = null;
|
||||
for (Direction face : Direction.values()) {
|
||||
// Only faces that aren't on our axis
|
||||
if (face.getAxis() != side.getAxis()) {
|
||||
FacadeRenderState otherState = facadeStates.get(face);
|
||||
if (otherState != null && !otherState.isTransparent()) {
|
||||
if (tmpBB == null) {
|
||||
tmpBB = AEAxisAlignedBB.fromBounds(facadeBox);
|
||||
}
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
tmpBB.minY += offset;
|
||||
break;
|
||||
case UP:
|
||||
tmpBB.maxY -= offset;
|
||||
break;
|
||||
case NORTH:
|
||||
tmpBB.minZ += offset;
|
||||
break;
|
||||
case SOUTH:
|
||||
tmpBB.maxZ -= offset;
|
||||
break;
|
||||
case WEST:
|
||||
tmpBB.minX += offset;
|
||||
break;
|
||||
case EAST:
|
||||
tmpBB.maxX -= offset;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Switch falloff. " + String.valueOf(face));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tmpBB != null) {
|
||||
facadeBox = tmpBB.getBoundingBox();
|
||||
}
|
||||
}
|
||||
|
||||
AEAxisAlignedBB cutOutBox = getCutOutBox(facadeBox, partBoxes);
|
||||
List<Box> holeStrips = getBoxes(facadeBox, cutOutBox, side.getAxis());
|
||||
ILightReader facadeAccess = new FacadeBlockAccess(parentWorld, pos, side, blockState);
|
||||
|
||||
BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager();
|
||||
BakedModel model = dispatcher.getModelForState(blockState);
|
||||
IModelData modelData = model.getModelData(facadeAccess, pos, blockState, EmptyModelData.INSTANCE);
|
||||
|
||||
List<BakedQuad> modelQuads = new ArrayList<>();
|
||||
// If we are forcing transparent facades, fake the render layer, and grab all
|
||||
// quads.
|
||||
if (transparent || layer == null) {
|
||||
for (RenderLayer forcedLayer : RenderLayer.getBlockRenderTypes()) {
|
||||
// Check if the block renders on the layer we want to force.
|
||||
if (RenderTypeLookup.canRenderInLayer(blockState, forcedLayer)) {
|
||||
// Force the layer and gather quads.
|
||||
ForgeHooksClient.setRenderLayer(forcedLayer);
|
||||
modelQuads.addAll(gatherQuads(model, blockState, rand, modelData));
|
||||
}
|
||||
}
|
||||
|
||||
// Reset.
|
||||
ForgeHooksClient.setRenderLayer(layer);
|
||||
} else {
|
||||
modelQuads.addAll(gatherQuads(model, blockState, rand, modelData));
|
||||
}
|
||||
|
||||
// No quads.. Cool, next!
|
||||
if (modelQuads.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Grab out pipeline elements.
|
||||
QuadClamper clamper = pipeline.getElement("clamper", QuadClamper.class);
|
||||
QuadFaceStripper edgeStripper = pipeline.getElement("face_stripper", QuadFaceStripper.class);
|
||||
QuadTinter tinter = pipeline.getElement("tinter", QuadTinter.class);
|
||||
QuadCornerKicker kicker = pipeline.getElement("corner_kicker", QuadCornerKicker.class);
|
||||
|
||||
// Set global element states.
|
||||
|
||||
// calculate the side mask.
|
||||
int facadeMask = 0;
|
||||
for (Entry<Direction, FacadeRenderState> ent : facadeStates.entrySet()) {
|
||||
Direction s = ent.getKey();
|
||||
if (s.getAxis() != side.getAxis()) {
|
||||
FacadeRenderState otherState = ent.getValue();
|
||||
if (!otherState.isTransparent()) {
|
||||
facadeMask |= 1 << s.ordinal();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Setup the edge stripper.
|
||||
edgeStripper.setBounds(fullBounds);
|
||||
edgeStripper.setMask(facadeMask);
|
||||
|
||||
// Setup the kicker.
|
||||
kicker.setSide(sideIndex);
|
||||
kicker.setFacadeMask(facadeMask);
|
||||
kicker.setBox(fullBounds);
|
||||
kicker.setThickness(thinFacades ? THIN_THICKNESS : THICK_THICKNESS);
|
||||
|
||||
for (BakedQuad quad : modelQuads) {
|
||||
// lookup the format in CachedFormat.
|
||||
CachedFormat format = CachedFormat.lookup(DefaultVertexFormats.BLOCK);
|
||||
// If this quad has a tint index, setup the tinter.
|
||||
if (quad.hasTintIndex()) {
|
||||
tinter.setTint(blockColors.getColor(blockState, facadeAccess, pos, quad.getColorIndex()));
|
||||
}
|
||||
for (Box box : holeStrips) {
|
||||
// setup the clamper for this box
|
||||
clamper.setClampBounds(box);
|
||||
// Reset the pipeline, clears all enabled/disabled states.
|
||||
pipeline.reset(format);
|
||||
// Reset out collector.
|
||||
collectorQuad.reset(format);
|
||||
// Enable / disable the optional elements
|
||||
pipeline.setElementState("tinter", quad.hasTintIndex());
|
||||
pipeline.setElementState("transparent", transparent);
|
||||
// Prepare the pipeline for a quad.
|
||||
pipeline.prepare(collectorQuad);
|
||||
|
||||
// Pipe our quad into the pipeline.
|
||||
quad.pipe(pipeline);
|
||||
// Check if the collector got any data.
|
||||
if (collectorQuad.full) {
|
||||
// Add the result.
|
||||
quads.add(collectorQuad.bake());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is slow, so should be cached.
|
||||
*
|
||||
* @return The model.
|
||||
*/
|
||||
public List<BakedQuad> buildFacadeItemQuads(ItemStack textureItem, Direction side) {
|
||||
List<BakedQuad> facadeQuads = new ArrayList<>();
|
||||
BakedModel model = MinecraftClient.getInstance().getItemRenderer().getItemModelWithOverrides(textureItem, null,
|
||||
null);
|
||||
List<BakedQuad> modelQuads = gatherQuads(model, null, new Random(), EmptyModelData.INSTANCE);
|
||||
|
||||
BakedPipeline pipeline = this.pipelines.get();
|
||||
Quad collectorQuad = this.collectors.get();
|
||||
|
||||
// Grab pipeline elements.
|
||||
QuadClamper clamper = pipeline.getElement("clamper", QuadClamper.class);
|
||||
QuadTinter tinter = pipeline.getElement("tinter", QuadTinter.class);
|
||||
|
||||
for (BakedQuad quad : modelQuads) {
|
||||
// Lookup the CachedFormat for this quads format.
|
||||
CachedFormat format = CachedFormat.lookup(DefaultVertexFormats.BLOCK);
|
||||
// Reset the pipeline.
|
||||
pipeline.reset(format);
|
||||
// Reset the collector.
|
||||
collectorQuad.reset(format);
|
||||
// If we have a tint index, setup the tinter and enable it.
|
||||
if (quad.hasTintIndex()) {
|
||||
tinter.setTint(MinecraftClient.getInstance().getItemColors().getColor(textureItem, quad.getColorIndex()));
|
||||
pipeline.enableElement("tinter");
|
||||
}
|
||||
// Disable elements we don't need for items.
|
||||
pipeline.disableElement("face_stripper");
|
||||
pipeline.disableElement("corner_kicker");
|
||||
// Setup the clamper
|
||||
clamper.setClampBounds(THICK_FACADE_BOXES[side.ordinal()]);
|
||||
// Prepare the pipeline.
|
||||
pipeline.prepare(collectorQuad);
|
||||
// Pipe our quad into the pipeline.
|
||||
quad.pipe(pipeline);
|
||||
// Check the collector for data and add the quad if there was.
|
||||
if (collectorQuad.full) {
|
||||
facadeQuads.add(collectorQuad.bake());
|
||||
}
|
||||
}
|
||||
return facadeQuads;
|
||||
}
|
||||
|
||||
// Helper to gather all quads from a model into a list.
|
||||
private static List<BakedQuad> gatherQuads(BakedModel model, BlockState state, Random rand, IModelData data) {
|
||||
List<BakedQuad> modelQuads = new ArrayList<>();
|
||||
for (Direction face : Direction.values()) {
|
||||
modelQuads.addAll(model.getQuads(state, face, rand, data));
|
||||
}
|
||||
modelQuads.addAll(model.getQuads(state, null, rand, data));
|
||||
return modelQuads;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the actual facade bounding box, and the bounding boxes of all parts,
|
||||
* determine the biggest union of AABB that intersect with the facade's bounding
|
||||
* box. This AABB will need to be "cut out" when the facade is rendered.
|
||||
*/
|
||||
@Nullable
|
||||
private static AEAxisAlignedBB getCutOutBox(Box facadeBox, List<Box> partBoxes) {
|
||||
AEAxisAlignedBB b = null;
|
||||
for (Box bb : partBoxes) {
|
||||
if (bb.intersects(facadeBox)) {
|
||||
if (b == null) {
|
||||
b = AEAxisAlignedBB.fromBounds(bb);
|
||||
} else {
|
||||
b.maxX = Math.max(b.maxX, bb.maxX);
|
||||
b.maxY = Math.max(b.maxY, bb.maxY);
|
||||
b.maxZ = Math.max(b.maxZ, bb.maxZ);
|
||||
b.minX = Math.min(b.minX, bb.minX);
|
||||
b.minY = Math.min(b.minY, bb.minY);
|
||||
b.minZ = Math.min(b.minZ, bb.minZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the box segments around the specified hole. If the specified hole
|
||||
* is null, a Singleton of the Facade box is returned.
|
||||
*
|
||||
* @param fb The Facade's box.
|
||||
* @param hole The hole to 'cut'.
|
||||
* @param axis The axis the facade is on.
|
||||
*
|
||||
* @return The box segments.
|
||||
*/
|
||||
private static List<Box> getBoxes(Box fb, AEAxisAlignedBB hole, Axis axis) {
|
||||
if (hole == null) {
|
||||
return Collections.singletonList(fb);
|
||||
}
|
||||
List<Box> boxes = new ArrayList<>();
|
||||
switch (axis) {
|
||||
case Y:
|
||||
boxes.add(new Box(fb.minX, fb.minY, fb.minZ, hole.minX, fb.maxY, fb.maxZ));
|
||||
boxes.add(new Box(hole.maxX, fb.minY, fb.minZ, fb.maxX, fb.maxY, fb.maxZ));
|
||||
|
||||
boxes.add(new Box(hole.minX, fb.minY, fb.minZ, hole.maxX, fb.maxY, hole.minZ));
|
||||
boxes.add(new Box(hole.minX, fb.minY, hole.maxZ, hole.maxX, fb.maxY, fb.maxZ));
|
||||
|
||||
break;
|
||||
case Z:
|
||||
boxes.add(new Box(fb.minX, fb.minY, fb.minZ, fb.maxX, hole.minY, fb.maxZ));
|
||||
boxes.add(new Box(fb.minX, hole.maxY, fb.minZ, fb.maxX, fb.maxY, fb.maxZ));
|
||||
|
||||
boxes.add(new Box(fb.minX, hole.minY, fb.minZ, hole.minX, hole.maxY, fb.maxZ));
|
||||
boxes.add(new Box(hole.maxX, hole.minY, fb.minZ, fb.maxX, hole.maxY, fb.maxZ));
|
||||
|
||||
break;
|
||||
case X:
|
||||
boxes.add(new Box(fb.minX, fb.minY, fb.minZ, fb.maxX, hole.minY, fb.maxZ));
|
||||
boxes.add(new Box(fb.minX, hole.maxY, fb.minZ, fb.maxX, fb.maxY, fb.maxZ));
|
||||
|
||||
boxes.add(new Box(fb.minX, hole.minY, fb.minZ, fb.maxX, hole.maxY, hole.minZ));
|
||||
boxes.add(new Box(fb.minX, hole.minY, hole.maxZ, fb.maxX, hole.maxY, fb.maxZ));
|
||||
break;
|
||||
default:
|
||||
// should never happen.
|
||||
throw new RuntimeException("switch falloff. " + String.valueOf(axis));
|
||||
}
|
||||
|
||||
return boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if any of the part's bounding boxes intersects with the outside 2
|
||||
* voxel wide layer. If so, we should use thinner facades (1 voxel deep).
|
||||
*/
|
||||
private static boolean isUseThinFacades(List<Box> partBoxes) {
|
||||
final double min = 2.0 / 16.0;
|
||||
final double max = 14.0 / 16.0;
|
||||
|
||||
for (Box bb : partBoxes) {
|
||||
int o = 0;
|
||||
o += bb.maxX > max ? 1 : 0;
|
||||
o += bb.maxY > max ? 1 : 0;
|
||||
o += bb.maxZ > max ? 1 : 0;
|
||||
o += bb.minX < min ? 1 : 0;
|
||||
o += bb.minY < min ? 1 : 0;
|
||||
o += bb.minZ < min ? 1 : 0;
|
||||
|
||||
if (o >= 2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
/**
|
||||
* Captures the state required to render a facade properly.
|
||||
*/
|
||||
public class FacadeRenderState {
|
||||
|
||||
// The block state to use for rendering this facade
|
||||
private final BlockState sourceBlock;
|
||||
|
||||
private final boolean transparent;
|
||||
|
||||
public FacadeRenderState(BlockState sourceBlock, boolean transparent) {
|
||||
this.sourceBlock = sourceBlock;
|
||||
this.transparent = transparent;
|
||||
}
|
||||
|
||||
public BlockState getSourceBlock() {
|
||||
return this.sourceBlock;
|
||||
}
|
||||
|
||||
public boolean isTransparent() {
|
||||
return this.transparent;
|
||||
}
|
||||
}
|
||||
@@ -9,18 +9,17 @@ import java.util.concurrent.ExecutionException;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class P2PTunnelFrequencyBakedModel implements IDynamicBakedModel {
|
||||
public class P2PTunnelFrequencyBakedModel implements FabricBakedModel {
|
||||
|
||||
private final Sprite texture;
|
||||
|
||||
|
||||
@@ -1,94 +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.cablebus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.thirdparty.codechicken.lib.model.CachedFormat;
|
||||
import appeng.thirdparty.codechicken.lib.model.Quad;
|
||||
import appeng.thirdparty.codechicken.lib.model.pipeline.BakedPipeline;
|
||||
import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadMatrixTransformer;
|
||||
|
||||
/**
|
||||
* Assuming a default-orientation of forward=NORTH and up=UP, this class rotates
|
||||
* a given list of quads to the desired facing
|
||||
*/
|
||||
public class QuadRotator {
|
||||
private static final ThreadLocal<BakedPipeline> pipelines = ThreadLocal.withInitial(() -> //
|
||||
BakedPipeline.builder()//
|
||||
.addElement("transformer", QuadMatrixTransformer.FACTORY)//
|
||||
.build());
|
||||
private static final ThreadLocal<Quad> collectors = ThreadLocal.withInitial(Quad::new);
|
||||
|
||||
public List<BakedQuad> rotateQuads(List<BakedQuad> quads, Direction newForward, Direction newUp) {
|
||||
if (newForward == Direction.NORTH && newUp == Direction.UP) {
|
||||
return quads; // This is the default orientation
|
||||
}
|
||||
FacingToRotation rotation = getRotation(newForward, newUp);
|
||||
if (rotation.isRedundant()) {
|
||||
return quads;
|
||||
}
|
||||
|
||||
List<BakedQuad> result = new ArrayList<>(quads.size());
|
||||
|
||||
CachedFormat format = CachedFormat.lookup(DefaultVertexFormats.BLOCK);
|
||||
BakedPipeline pipeline = pipelines.get();
|
||||
Quad collector = collectors.get();
|
||||
QuadMatrixTransformer transformer = pipeline.getElement("transformer", QuadMatrixTransformer.class);
|
||||
|
||||
// FIXME: Temporary rotation fix
|
||||
Matrix4f mat = new Matrix4f();
|
||||
mat.setTranslation(-0.5f, -0.5f, -0.5f);
|
||||
mat.multiplyBackward(rotation.getMat());
|
||||
mat.translate(new Vector3f(0.5f, 0.5f, 0.5f));
|
||||
|
||||
for (BakedQuad quad : quads) {
|
||||
pipeline.reset(format);
|
||||
collector.reset(format);
|
||||
|
||||
transformer.setMatrix(mat);
|
||||
pipeline.prepare(collector);
|
||||
quad.pipe(pipeline);
|
||||
result.add(collector.bake());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private FacingToRotation getRotation(Direction forward, Direction up) {
|
||||
// Sanitize forward/up
|
||||
if (forward.getAxis() == up.getAxis()) {
|
||||
if (up.getAxis() == Direction.Axis.Y) {
|
||||
up = Direction.NORTH;
|
||||
} else {
|
||||
up = Direction.UP;
|
||||
}
|
||||
}
|
||||
|
||||
return FacingToRotation.get(forward, up);
|
||||
}
|
||||
}
|
||||
@@ -1,85 +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.cablebus;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
/**
|
||||
* Manages the channel textures for smart cables.
|
||||
*/
|
||||
public class SmartCableTextures {
|
||||
|
||||
public static final SpriteIdentifier[] SMART_CHANNELS_TEXTURES = Arrays
|
||||
.stream(new Identifier[] { new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_00"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_01"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_02"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_03"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_04"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_10"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_11"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_12"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_13"), //
|
||||
new Identifier(AppEng.MOD_ID, "parts/cable/smart/channels_14")//
|
||||
}).map(e -> new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, e)).toArray(SpriteIdentifier[]::new);
|
||||
|
||||
// Textures used to display channels on smart cables. There's two sets of 5
|
||||
// textures each, and
|
||||
// one of each set are composed together to get even/odd colored channels
|
||||
private final Sprite[] textures;
|
||||
|
||||
public SmartCableTextures(Function<SpriteIdentifier, Sprite> bakedTextureGetter) {
|
||||
this.textures = Arrays.stream(SMART_CHANNELS_TEXTURES)//
|
||||
.map(bakedTextureGetter)//
|
||||
.toArray(Sprite[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* The odd variant is used for displaying channels 1-4 as in use.
|
||||
*/
|
||||
public Sprite getOddTextureForChannels(int channels) {
|
||||
if (channels < 0) {
|
||||
return this.textures[0];
|
||||
} else if (channels <= 4) {
|
||||
return this.textures[channels];
|
||||
} else {
|
||||
return this.textures[4];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The odd variant is used for displaying channels 5-8 as in use.
|
||||
*/
|
||||
public Sprite getEvenTextureForChannels(int channels) {
|
||||
if (channels < 5) {
|
||||
return this.textures[5];
|
||||
} else if (channels <= 8) {
|
||||
return this.textures[1 + channels];
|
||||
} else {
|
||||
return this.textures[9];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,18 +32,18 @@ import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.VertexFormat;
|
||||
import net.minecraft.client.render.VertexFormatElement;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.client.util.math.Vector4f;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
@@ -174,8 +174,8 @@ public class AutoRotatingBakedModel implements BakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state,
|
||||
@Nonnull IModelData tileData) {
|
||||
public IModelData getModelData(@Nonnull BlockRenderView world, @Nonnull BlockPos pos, @Nonnull BlockState state,
|
||||
@Nonnull IModelData tileData) {
|
||||
return this.parent.getModelData(world, pos, state, tileData);
|
||||
}
|
||||
|
||||
@@ -205,9 +205,9 @@ public class AutoRotatingBakedModel implements BakedModel {
|
||||
for (int v = 0; v < 4; v++) {
|
||||
for (int e = 0; e < elements.size(); e++) {
|
||||
VertexFormatElement element = elements.get(e);
|
||||
if (element.getUsage() == VertexFormatElement.Usage.POSITION) {
|
||||
if (element.getType() == VertexFormatElement.Usage.POSITION) {
|
||||
this.parent.put(e, this.transform(this.quadData[e][v]));
|
||||
} else if (element.getUsage() == VertexFormatElement.Usage.NORMAL) {
|
||||
} else if (element.getType() == VertexFormatElement.Usage.NORMAL) {
|
||||
this.parent.put(e, this.transformNormal(this.quadData[e][v]));
|
||||
} else {
|
||||
this.parent.put(e, this.quadData[e][v]);
|
||||
|
||||
@@ -28,6 +28,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -73,7 +74,7 @@ public class DriveBakedModel extends DelegateBakedModel {
|
||||
// cell-model being in slot 0,0 at the top left of the drive.
|
||||
float xOffset = -col * 8 / 16.0f;
|
||||
float yOffset = -row * 3 / 16.0f;
|
||||
transform.setTranslation(xOffset, yOffset, 0);
|
||||
transform.addToLastColumn(new Vector3f(xOffset, yOffset, 0));
|
||||
|
||||
int slot = row * 2 + col;
|
||||
|
||||
|
||||
@@ -32,20 +32,20 @@ import javax.annotation.Nullable;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.VertexFormat;
|
||||
import net.minecraft.client.render.VertexFormatElement;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.json.ModelOverrideList;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
@@ -240,7 +240,7 @@ class GlassBakedModel implements IDynamicBakedModel {
|
||||
VertexFormat vertexFormat = builder.getVertexFormat();
|
||||
for (int e = 0; e < vertexFormat.getElements().size(); e++) {
|
||||
VertexFormatElement el = vertexFormat.getElements().get(e);
|
||||
switch (el.getUsage()) {
|
||||
switch (el.getType()) {
|
||||
case POSITION:
|
||||
builder.put(e, (float) x, (float) y, (float) z, 1.0f);
|
||||
break;
|
||||
@@ -252,8 +252,8 @@ class GlassBakedModel implements IDynamicBakedModel {
|
||||
break;
|
||||
case UV:
|
||||
if (el.getIndex() == 0) {
|
||||
u = sprite.getInterpolatedU(u);
|
||||
v = sprite.getInterpolatedV(v);
|
||||
u = sprite.getFrameU(u);
|
||||
v = sprite.getFrameV(v);
|
||||
builder.put(e, u, v, 0f, 1f);
|
||||
break;
|
||||
}
|
||||
@@ -305,8 +305,8 @@ class GlassBakedModel implements IDynamicBakedModel {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state,
|
||||
@Nonnull IModelData tileData) {
|
||||
public IModelData getModelData(@Nonnull BlockRenderView world, @Nonnull BlockPos pos, @Nonnull BlockState state,
|
||||
@Nonnull IModelData tileData) {
|
||||
|
||||
EnumSet<Direction> flushWith = EnumSet.noneOf(Direction.class);
|
||||
// Test every direction for another glass block
|
||||
|
||||
@@ -20,11 +20,11 @@ package appeng.client.render.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.render.VertexFormatElement;
|
||||
import net.minecraft.client.util.math.Vector4f;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.client.render.VertexFormat;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraftforge.client.model.pipeline.QuadGatheringTransformer;
|
||||
|
||||
@@ -48,9 +48,9 @@ final class MatrixVertexTransformer extends QuadGatheringTransformer {
|
||||
for (int v = 0; v < 4; v++) {
|
||||
for (int e = 0; e < count; e++) {
|
||||
VertexFormatElement element = elements.get(e);
|
||||
if (element.getUsage() == VertexFormatElement.Usage.POSITION) {
|
||||
if (element.getType() == VertexFormatElement.Usage.POSITION) {
|
||||
this.parent.put(e, this.transform(this.quadData[e][v], element.getElementCount()));
|
||||
} else if (element.getUsage() == VertexFormatElement.Usage.NORMAL) {
|
||||
} else if (element.getType() == VertexFormatElement.Usage.NORMAL) {
|
||||
this.parent.put(e, this.transformNormal(this.quadData[e][v]));
|
||||
} else {
|
||||
this.parent.put(e, this.quadData[e][v]);
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CrankTESR extends BlockEntityRenderer<CrankBlockEntity> {
|
||||
|
||||
BlockState blockState = te.getCachedState();
|
||||
BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager();
|
||||
BakedModel model = dispatcher.getModelForState(blockState);
|
||||
BakedModel model = dispatcher.getModel(blockState);
|
||||
VertexConsumer buffer = buffers.getBuffer(TexturedRenderLayers.getEntityTranslucentCull());
|
||||
dispatcher.getModelRenderer().renderModelBrightnessColor(ms.peek(), buffer, null, model, 1, 1, 1,
|
||||
combinedLightIn, combinedOverlayIn);
|
||||
|
||||
@@ -4,17 +4,16 @@ import java.util.EnumMap;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.renderer.RenderState;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
@@ -70,7 +69,7 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
|
||||
// Bottom Face
|
||||
R, B, FR, L, B, FR, L, B, BA, R, B, BA, };
|
||||
|
||||
private static final RenderLayer STATE = RenderLayer.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7,
|
||||
private static final RenderLayer STATE = RenderLayer.makeType("ae_drive_leds", VertexFormats.POSITION_COLOR, 7,
|
||||
32565, false, true, RenderLayer.State.getBuilder().build(false));
|
||||
|
||||
public DriveLedTileEntityRenderer(BlockEntityRenderDispatcher rendererDispatcherIn) {
|
||||
@@ -90,9 +89,9 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
|
||||
FacingToRotation.get(drive.getForward(), drive.getUp()).push(ms);
|
||||
ms.translate(-0.5, -0.5, -0.5);
|
||||
|
||||
RenderType rt = RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true,
|
||||
RenderType rt = RenderType.makeType("ae_drive_leds", VertexFormats.POSITION_COLOR, 7, 32565, false, true,
|
||||
RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).build(false));
|
||||
IVertexBuilder buffer = buffers.getBuffer(STATE);
|
||||
VertexConsumer buffer = buffers.getBuffer(STATE);
|
||||
|
||||
for (int row = 0; row < 5; row++) {
|
||||
for (int col = 0; col < 2; col++) {
|
||||
|
||||
@@ -175,7 +175,7 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
|
||||
float z, double texU, double texV, int overlayUV, int lightmapUV, Direction front) {
|
||||
vb.pos(ms.peek().getMatrix(), x, y, z);
|
||||
vb.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
vb.tex(sprite.getInterpolatedU(texU), sprite.getInterpolatedV(texV));
|
||||
vb.tex(sprite.getFrameU(texU), sprite.getFrameV(texV));
|
||||
vb.overlay(overlayUV);
|
||||
vb.lightmap(lightmapUV);
|
||||
vb.normal(ms.peek().getNormal(), front.getOffsetX(), front.getOffsetY(), front.getOffsetZ());
|
||||
|
||||
Reference in New Issue
Block a user