Some more work on fluid pipe rendering, I may recode it
This commit is contained in:
parent
9fa77d31d8
commit
fd95cf7141
4 changed files with 138 additions and 30 deletions
|
@ -27,7 +27,7 @@ public class ClientPartModelBakery
|
||||||
new RenderCablePart(type));
|
new RenderCablePart(type));
|
||||||
}
|
}
|
||||||
event.getModelRegistry().putObject(
|
event.getModelRegistry().putObject(
|
||||||
new ModelResourceLocation("techreborn:fluidpipe"),
|
new ModelResourceLocation("techreborn:fluidpipe#multipart"),
|
||||||
new RenderFluidPipePart());
|
new RenderFluidPipePart());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.lwjgl.util.vector.Vector3f;
|
||||||
import reborncore.common.misc.vecmath.Vecs3dCube;
|
import reborncore.common.misc.vecmath.Vecs3dCube;
|
||||||
import techreborn.parts.fluidPipes.MultipartFluidPipe;
|
import techreborn.parts.fluidPipes.MultipartFluidPipe;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -36,6 +37,7 @@ public class RenderFluidPipePart implements IBakedModel {
|
||||||
(float) cube.getMaxZ(), (float) cube.getMaxY()}, 0);
|
(float) cube.getMaxZ(), (float) cube.getMaxY()}, 0);
|
||||||
face = new BlockPartFace(null, 0, "", uv);
|
face = new BlockPartFace(null, 0, "", uv);
|
||||||
}
|
}
|
||||||
|
if (dir == null) {
|
||||||
list.add(faceBakery.makeBakedQuad(
|
list.add(faceBakery.makeBakedQuad(
|
||||||
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMaxZ()), face, cubeTexture,
|
new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||||
|
@ -60,6 +62,91 @@ public class RenderFluidPipePart implements IBakedModel {
|
||||||
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||||
new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||||
EnumFacing.WEST, modelRotation, null, true, true));// west
|
EnumFacing.WEST, modelRotation, null, true, true));// west
|
||||||
|
} else {
|
||||||
|
if (dir != EnumFacing.DOWN) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if (dir != EnumFacing.UP) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if (dir != EnumFacing.NORTH) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if (dir != EnumFacing.SOUTH) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if (dir != EnumFacing.EAST) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if (dir != EnumFacing.WEST) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCulledCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face,
|
||||||
|
ModelRotation modelRotation, TextureAtlasSprite cubeTexture, List<EnumFacing> dirs) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (dirs.contains(EnumFacing.DOWN)) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if (dirs.contains(EnumFacing.UP)) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if (dirs.contains(EnumFacing.NORTH)) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if (dirs.contains(EnumFacing.SOUTH)) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if (dirs.contains(EnumFacing.EAST)) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
if (dirs.contains(EnumFacing.WEST)) {
|
||||||
|
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
|
||||||
|
@ -73,8 +160,29 @@ public class RenderFluidPipePart implements IBakedModel {
|
||||||
if (side != null) {
|
if (side != null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
//TODO recode the fuck out of this
|
||||||
list, face, ModelRotation.X0_Y0, texture, null);
|
ArrayList<EnumFacing> dirs = new ArrayList<>();
|
||||||
|
if(!state.getValue(MultipartFluidPipe.DOWN)){
|
||||||
|
dirs.add(EnumFacing.DOWN);
|
||||||
|
}
|
||||||
|
if(!state.getValue(MultipartFluidPipe.UP)){
|
||||||
|
dirs.add(EnumFacing.UP);
|
||||||
|
}
|
||||||
|
if(!state.getValue(MultipartFluidPipe.NORTH)){
|
||||||
|
dirs.add(EnumFacing.NORTH);
|
||||||
|
}
|
||||||
|
if(!state.getValue(MultipartFluidPipe.SOUTH)){
|
||||||
|
dirs.add(EnumFacing.SOUTH);
|
||||||
|
}
|
||||||
|
if(!state.getValue(MultipartFluidPipe.EAST)){
|
||||||
|
dirs.add(EnumFacing.EAST);
|
||||||
|
}
|
||||||
|
if(!state.getValue(MultipartFluidPipe.WEST)){
|
||||||
|
dirs.add(EnumFacing.WEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
addCulledCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
||||||
|
list, face, ModelRotation.X0_Y0, texture, dirs);
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
if (state.getValue(MultipartFluidPipe.UP)) {
|
if (state.getValue(MultipartFluidPipe.UP)) {
|
||||||
addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
||||||
|
|
|
@ -54,8 +54,8 @@ public class RecipeCompact implements IRecipeCompact
|
||||||
recipes.put("solarPanel", new ItemStack(ModBlocks.solarPanel));
|
recipes.put("solarPanel", new ItemStack(ModBlocks.solarPanel));
|
||||||
recipes.put("waterCell", ItemCells.getCellByName("water"));
|
recipes.put("waterCell", ItemCells.getCellByName("water"));
|
||||||
recipes.put("lavaCell", ItemCells.getCellByName("lava"));
|
recipes.put("lavaCell", ItemCells.getCellByName("lava"));
|
||||||
recipes.put("pump", new ItemStack(ModItems.missingRecipe));
|
recipes.put("pump", new ItemStack(ModBlocks.pump));
|
||||||
recipes.put("teleporter", new ItemStack(ModItems.missingRecipe));
|
// recipes.put("teleporter", new ItemStack(ModItems.missingRecipe));
|
||||||
recipes.put("advancedAlloy", ItemIngots.getIngotByName("advancedAlloy"));
|
recipes.put("advancedAlloy", ItemIngots.getIngotByName("advancedAlloy"));
|
||||||
recipes.put("lvTransformer", new ItemStack(ModBlocks.lvt));
|
recipes.put("lvTransformer", new ItemStack(ModBlocks.lvt));
|
||||||
recipes.put("mvTransformer", new ItemStack(ModBlocks.mvt));
|
recipes.put("mvTransformer", new ItemStack(ModBlocks.mvt));
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class MultipartFluidPipe extends Multipart implements INormallyOccludingP
|
||||||
public float center = 0.6F;
|
public float center = 0.6F;
|
||||||
public float offset = 0.10F;
|
public float offset = 0.10F;
|
||||||
public Map<EnumFacing, BlockPos> connectedSides;
|
public Map<EnumFacing, BlockPos> connectedSides;
|
||||||
public static final int thickness = 12;
|
public static final int thickness = 11;
|
||||||
|
|
||||||
public MultipartFluidPipe() {
|
public MultipartFluidPipe() {
|
||||||
connectedSides = new HashMap<>();
|
connectedSides = new HashMap<>();
|
||||||
|
|
Loading…
Add table
Reference in a new issue