Small improvements to cable rendering
This commit is contained in:
parent
5ca379667d
commit
25280e9e7e
2 changed files with 64 additions and 13 deletions
|
@ -6,6 +6,7 @@ import net.minecraft.client.renderer.block.model.*;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||||
|
import org.lwjgl.util.vector.Vector3f;
|
||||||
import reborncore.client.models.BakedModelUtils;
|
import reborncore.client.models.BakedModelUtils;
|
||||||
import reborncore.common.misc.vecmath.Vecs3dCube;
|
import reborncore.common.misc.vecmath.Vecs3dCube;
|
||||||
import techreborn.parts.fluidPipes.EnumFluidPipeTypes;
|
import techreborn.parts.fluidPipes.EnumFluidPipeTypes;
|
||||||
|
@ -30,45 +31,95 @@ public class RenderFluidPipePart implements IBakedModel {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face,
|
||||||
|
ModelRotation modelRotation, TextureAtlasSprite cubeTexture, EnumFacing dir, FaceBakery faceBakery)
|
||||||
|
{
|
||||||
|
BlockFaceUV uv = new BlockFaceUV(new float[] { (float) cube.getMinX(), (float) cube.getMinY(),
|
||||||
|
(float) cube.getMaxX(), (float) cube.getMaxY() }, 0);
|
||||||
|
face = new BlockPartFace(null, 0, "", uv);
|
||||||
|
list.add(faceBakery.makeBakedQuad(
|
||||||
|
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||||
|
new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||||
|
EnumFacing.DOWN, modelRotation, null, true, true));// down
|
||||||
|
list.add(faceBakery.makeBakedQuad(
|
||||||
|
new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMinZ()),
|
||||||
|
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||||
|
EnumFacing.UP, modelRotation, null, true, true));// up
|
||||||
|
list.add(faceBakery.makeBakedQuad(
|
||||||
|
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||||
|
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||||
|
EnumFacing.NORTH, modelRotation, null, true, true));// north
|
||||||
|
list.add(faceBakery.makeBakedQuad(
|
||||||
|
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMaxZ()),
|
||||||
|
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||||
|
EnumFacing.SOUTH, modelRotation, null, true, true));// south
|
||||||
|
list.add(faceBakery.makeBakedQuad(
|
||||||
|
new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||||
|
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||||
|
EnumFacing.EAST, modelRotation, null, true, true));// east
|
||||||
|
list.add(faceBakery.makeBakedQuad(
|
||||||
|
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||||
|
new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||||
|
EnumFacing.WEST, modelRotation, null, true, true));// west
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand) {
|
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand) {
|
||||||
ArrayList<BakedQuad> list = new ArrayList<>();
|
ArrayList<BakedQuad> list = new ArrayList<>();
|
||||||
BlockFaceUV uv = new BlockFaceUV(new float[]{0.0F, 0.0F, 16.0F, 16.0F}, 0);
|
BlockFaceUV uv = new BlockFaceUV(new float[] { 0.0F, 0.0F, 16.0F, 16.0F }, 0);
|
||||||
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
|
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
|
||||||
double thickness = MultipartFluidPipe.thickness;
|
double thickness = MultipartFluidPipe.thickness;
|
||||||
double lastThickness = 16 - thickness;
|
double lastThickness = 16 - thickness;
|
||||||
IExtendedBlockState state = (IExtendedBlockState) blockState;
|
IExtendedBlockState state = (IExtendedBlockState) blockState;
|
||||||
if (side != null) {
|
if (side != null)
|
||||||
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
boolean renderedConnection = false;
|
||||||
list, face, ModelRotation.X0_Y0, texture, null, faceBakery);
|
if (state != null)
|
||||||
if (state != null) {
|
{
|
||||||
if (state.getValue(MultipartFluidPipe.UP)) {
|
if (state.getValue(MultipartFluidPipe.UP))
|
||||||
|
{
|
||||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
||||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP, faceBakery);
|
list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP, faceBakery);
|
||||||
|
renderedConnection = true;
|
||||||
}
|
}
|
||||||
if (state.getValue(MultipartFluidPipe.DOWN)) {
|
if (state.getValue(MultipartFluidPipe.DOWN))
|
||||||
|
{
|
||||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list,
|
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list,
|
||||||
face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN, faceBakery);
|
face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN, faceBakery);
|
||||||
|
renderedConnection = true;
|
||||||
}
|
}
|
||||||
if (state.getValue(MultipartFluidPipe.NORTH)) {
|
if (state.getValue(MultipartFluidPipe.NORTH))
|
||||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, thickness), list,
|
{
|
||||||
|
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, lastThickness), list,
|
||||||
face, ModelRotation.X0_Y0, texture, EnumFacing.NORTH, faceBakery);
|
face, ModelRotation.X0_Y0, texture, EnumFacing.NORTH, faceBakery);
|
||||||
|
renderedConnection = true;
|
||||||
}
|
}
|
||||||
if (state.getValue(MultipartFluidPipe.SOUTH)) {
|
if (state.getValue(MultipartFluidPipe.SOUTH))
|
||||||
|
{
|
||||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, lastThickness, lastThickness, lastThickness, 16.0),
|
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, lastThickness, lastThickness, lastThickness, 16.0),
|
||||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.SOUTH, faceBakery);
|
list, face, ModelRotation.X0_Y0, texture, EnumFacing.SOUTH, faceBakery);
|
||||||
|
renderedConnection = true;
|
||||||
}
|
}
|
||||||
if (state.getValue(MultipartFluidPipe.EAST)) {
|
if (state.getValue(MultipartFluidPipe.EAST))
|
||||||
|
{
|
||||||
BakedModelUtils.addCubeToList(new Vecs3dCube(lastThickness, thickness, thickness, 16.0, lastThickness, lastThickness),
|
BakedModelUtils.addCubeToList(new Vecs3dCube(lastThickness, thickness, thickness, 16.0, lastThickness, lastThickness),
|
||||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST, faceBakery);
|
list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST, faceBakery);
|
||||||
|
renderedConnection = true;
|
||||||
}
|
}
|
||||||
if (state.getValue(MultipartFluidPipe.WEST)) {
|
if (state.getValue(MultipartFluidPipe.WEST))
|
||||||
|
{
|
||||||
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list,
|
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list,
|
||||||
face, ModelRotation.X0_Y0, texture, EnumFacing.WEST, faceBakery);
|
face, ModelRotation.X0_Y0, texture, EnumFacing.WEST, faceBakery);
|
||||||
|
renderedConnection = true;
|
||||||
|
}
|
||||||
|
if(!renderedConnection){
|
||||||
|
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
||||||
|
list, face, ModelRotation.X0_Y0, texture, null, faceBakery);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class MultipartFluidPipe extends Multipart implements INormallyOccludingP
|
||||||
public static final IUnlistedProperty<Boolean> SOUTH = Properties.toUnlisted(PropertyBool.create("south"));
|
public static final IUnlistedProperty<Boolean> SOUTH = Properties.toUnlisted(PropertyBool.create("south"));
|
||||||
public static final IUnlistedProperty<Boolean> WEST = Properties.toUnlisted(PropertyBool.create("west"));
|
public static final IUnlistedProperty<Boolean> WEST = Properties.toUnlisted(PropertyBool.create("west"));
|
||||||
public static final IProperty<EnumFluidPipeTypes> TYPE = PropertyEnum.create("type", EnumFluidPipeTypes.class);
|
public static final IProperty<EnumFluidPipeTypes> TYPE = PropertyEnum.create("type", EnumFluidPipeTypes.class);
|
||||||
public static final int thickness = 11;
|
public static final double thickness = 11;
|
||||||
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
|
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
|
||||||
public float center = 0.6F;
|
public float center = 0.6F;
|
||||||
public float offset = 0.10F;
|
public float offset = 0.10F;
|
||||||
|
|
Loading…
Reference in a new issue