mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-28 15:56:07 +00:00
#32 Connected Photovoltaic Cells
- Have connected textures similar to cap banks - Form a cohesive unit that gains and emites power as a whole
This commit is contained in:
1 parent
18837b8050
commit
ff4ef4ffd3
22 files changed
+431
-49
No files matched your search
@@ -3,6 +3,7 @@ package crazypants.render;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.util.BlockCoord;
|
||||
@@ -56,6 +57,10 @@ public final class BoundingBox {
|
||||
this(bc.x, bc.y, bc.z, bc.x + 1, bc.y + 1, bc.z + 1);
|
||||
}
|
||||
|
||||
public BoundingBox(Block block) {
|
||||
this(block.getBlockBoundsMinX(), block.getBlockBoundsMinY(), block.getBlockBoundsMinZ(), block.getBlockBoundsMaxX(), block.getBlockBoundsMaxY(), block.getBlockBoundsMaxZ());
|
||||
}
|
||||
|
||||
public BoundingBox expandBy(BoundingBox other) {
|
||||
return new BoundingBox(
|
||||
Math.min(minX, other.minX), Math.min(minY, other.minY), Math.min(minZ, other.minZ),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package crazypants.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -58,6 +59,8 @@ public class ConnectedTextureRenderer implements IRenderFace, IConnectedTextureR
|
||||
private TextureCallback edgeTexureCallback;
|
||||
|
||||
private boolean matchMetaData;
|
||||
|
||||
private EnumSet<ForgeDirection> sidesToRender = EnumSet.allOf(ForgeDirection.class);
|
||||
|
||||
public boolean isForceAllEdges() {
|
||||
return forceAllEdges;
|
||||
@@ -87,6 +90,10 @@ public class ConnectedTextureRenderer implements IRenderFace, IConnectedTextureR
|
||||
this.matchMetaData = matchMetaData;
|
||||
}
|
||||
|
||||
public void setSidesToRender(EnumSet<ForgeDirection> sides) {
|
||||
sidesToRender = sides.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesMetadata(int meta1, int meta2) {
|
||||
return !this.matchMetaData || meta1 == meta2;
|
||||
@@ -95,6 +102,10 @@ public class ConnectedTextureRenderer implements IRenderFace, IConnectedTextureR
|
||||
@Override
|
||||
public void renderFace(CustomRenderBlocks rb, ForgeDirection face, Block par1Block, double x, double y, double z, IIcon texture, List<Vertex> refVertices,
|
||||
boolean translateToXYZ) {
|
||||
|
||||
if (!sidesToRender.contains(face)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Vertex> finalVerts = new ArrayList<Vertex>();
|
||||
finalVerts.addAll(refVertices);
|
||||
@@ -126,6 +137,10 @@ public class ConnectedTextureRenderer implements IRenderFace, IConnectedTextureR
|
||||
float xLen = 1 - Math.abs(edge.offsetX) * scaleFactor;
|
||||
float yLen = 1 - Math.abs(edge.offsetY) * scaleFactor;
|
||||
float zLen = 1 - Math.abs(edge.offsetZ) * scaleFactor;
|
||||
|
||||
xLen -= 2* (1 - par1Block.getBlockBoundsMaxX()) - par1Block.getBlockBoundsMinX();
|
||||
yLen -= 2* (1 - par1Block.getBlockBoundsMaxY()) - par1Block.getBlockBoundsMinY();
|
||||
zLen -= 2* (1 - par1Block.getBlockBoundsMaxZ()) - par1Block.getBlockBoundsMinZ();
|
||||
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(xLen, yLen, zLen);
|
||||
|
||||
@@ -172,7 +187,11 @@ public class ConnectedTextureRenderer implements IRenderFace, IConnectedTextureR
|
||||
v.xyz.x = Math.max(-0.001, v.xyz.x);
|
||||
v.xyz.y = Math.max(-0.001, v.xyz.y);
|
||||
v.xyz.z = Math.max(-0.001, v.xyz.z);
|
||||
|
||||
|
||||
v.xyz.x -= (1 - par1Block.getBlockBoundsMaxX()) - par1Block.getBlockBoundsMinX();
|
||||
v.xyz.y -= (1 - par1Block.getBlockBoundsMaxY()) - par1Block.getBlockBoundsMinY();
|
||||
v.xyz.z -= (1 - par1Block.getBlockBoundsMaxZ()) - par1Block.getBlockBoundsMinZ();
|
||||
|
||||
if(ForgeDirectionOffsets.isPositiveOffset(face)) {
|
||||
v.xyz.add(ForgeDirectionOffsets.forDir(face));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import crazypants.vecmath.Vertex;
|
||||
public class CustomRenderBlocks extends RenderBlocks {
|
||||
|
||||
boolean translateToXYZ = true;
|
||||
boolean shouldRenderBaseTexture = true;
|
||||
|
||||
private final List<IRenderFace> renderFaceCallbacks = new ArrayList<IRenderFace>();
|
||||
private IIcon overrideTexture;
|
||||
@@ -54,6 +55,10 @@ public class CustomRenderBlocks extends RenderBlocks {
|
||||
public void setOverrideTexture(IIcon overrideTexture) {
|
||||
this.overrideTexture = overrideTexture;
|
||||
}
|
||||
|
||||
public void setShouldRenderBaseTexture(boolean val) {
|
||||
shouldRenderBaseTexture = val;
|
||||
}
|
||||
|
||||
private void renderFace(ForgeDirection face, Block par1Block, double x, double y, double z, IIcon texture) {
|
||||
if(renderFaceCallbacks.isEmpty()) {
|
||||
|
||||
@@ -321,11 +321,11 @@ public class RenderUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderConnectedTextureFace(IBlockAccess blockAccess, int x, int y, int z, ForgeDirection face, IIcon texture, boolean forceAllEdges) {
|
||||
renderConnectedTextureFace(blockAccess, x, y, z, face, texture, forceAllEdges, true, true);
|
||||
public static void renderConnectedTextureFace(IBlockAccess blockAccess, Block block, int x, int y, int z, ForgeDirection face, IIcon texture, boolean forceAllEdges) {
|
||||
renderConnectedTextureFace(blockAccess, block, x, y, z, face, texture, forceAllEdges, true, true);
|
||||
}
|
||||
|
||||
public static void renderConnectedTextureFace(IBlockAccess blockAccess, int x, int y, int z, ForgeDirection face, IIcon texture, boolean forceAllEdges,
|
||||
public static void renderConnectedTextureFace(IBlockAccess blockAccess, Block block, int x, int y, int z, ForgeDirection face, IIcon texture, boolean forceAllEdges,
|
||||
boolean translateToXYZ, boolean applyFaceShading) {
|
||||
|
||||
if((blockAccess == null && !forceAllEdges) || face == null || texture == null) {
|
||||
@@ -333,11 +333,11 @@ public class RenderUtil {
|
||||
}
|
||||
|
||||
if(!forceAllEdges) {
|
||||
Block block = blockAccess.getBlock(x, y, z);
|
||||
if(block == null) {
|
||||
Block check = blockAccess.getBlock(x, y, z);
|
||||
if(check == null) {
|
||||
return;
|
||||
}
|
||||
if(!block.shouldSideBeRendered(blockAccess, x + face.offsetX, y + face.offsetY, z + face.offsetZ, face.ordinal())) {
|
||||
if(!check.shouldSideBeRendered(blockAccess, x + face.offsetX, y + face.offsetY, z + face.offsetZ, face.ordinal())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -365,6 +365,11 @@ public class RenderUtil {
|
||||
float xLen = 1 - Math.abs(edge.offsetX) * scaleFactor;
|
||||
float yLen = 1 - Math.abs(edge.offsetY) * scaleFactor;
|
||||
float zLen = 1 - Math.abs(edge.offsetZ) * scaleFactor;
|
||||
|
||||
xLen -= 2* (1 - block.getBlockBoundsMaxX()) - block.getBlockBoundsMinX();
|
||||
yLen -= 2* (1 - block.getBlockBoundsMaxY()) - block.getBlockBoundsMinY();
|
||||
zLen -= 2* (1 - block.getBlockBoundsMaxZ()) - block.getBlockBoundsMinZ();
|
||||
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(xLen, yLen, zLen);
|
||||
|
||||
List<Vector3f> corners = bb.getCornersForFace(face);
|
||||
|
||||
Reference in new issue
Block a user