From 734d1fc66da7bc8478cdfe632673cb4617f3b940 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 1 Jan 2022 19:30:52 +0100 Subject: [PATCH] the large boys --- .../com/hbm/blocks/network/PylonLarge.java | 7 +- src/main/java/com/hbm/main/ClientProxy.java | 13 +--- .../render/tileentity/RenderPylonBase.java | 72 +++++++++++++----- .../render/tileentity/RenderPylonLarge.java | 38 +++++++++ .../network/TileEntityPylonBase.java | 2 +- .../network/TileEntityPylonLarge.java | 9 ++- .../hbm/textures/blocks/charge_dynamite.png | Bin 0 -> 348 bytes .../textures/models/network/pylon_large.png | Bin 556 -> 1244 bytes src/main/resources/mcmod.info | 2 +- 9 files changed, 107 insertions(+), 36 deletions(-) create mode 100644 src/main/java/com/hbm/render/tileentity/RenderPylonLarge.java create mode 100644 src/main/resources/assets/hbm/textures/blocks/charge_dynamite.png diff --git a/src/main/java/com/hbm/blocks/network/PylonLarge.java b/src/main/java/com/hbm/blocks/network/PylonLarge.java index 140a4ff1b..e0457f924 100644 --- a/src/main/java/com/hbm/blocks/network/PylonLarge.java +++ b/src/main/java/com/hbm/blocks/network/PylonLarge.java @@ -21,7 +21,10 @@ public class PylonLarge extends BlockDummyable implements ITooltipProvider { @Override public TileEntity createNewTileEntity(World world, int meta) { - return new TileEntityPylonLarge(); + + if(meta >= 12) + return new TileEntityPylonLarge(); + return null; } @Override @@ -33,7 +36,7 @@ public class PylonLarge extends BlockDummyable implements ITooltipProvider { @Override public int[] getDimensions() { - return new int[] {9, 0, 1, 1, 1, 1}; + return new int[] {0, 0, 1, 1, 1, 1}; } @Override diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index e7ab91d8b..ca6cc9532 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -77,17 +77,9 @@ import com.hbm.tileentity.bomb.*; import com.hbm.tileentity.conductor.*; import com.hbm.tileentity.deco.*; import com.hbm.tileentity.machine.*; -import com.hbm.tileentity.machine.oil.TileEntityMachineCatalyticCracker; -import com.hbm.tileentity.machine.oil.TileEntityMachineFrackingTower; -import com.hbm.tileentity.machine.oil.TileEntityMachineFractionTower; -import com.hbm.tileentity.machine.oil.TileEntityMachineGasFlare; -import com.hbm.tileentity.machine.oil.TileEntityMachineOilWell; -import com.hbm.tileentity.machine.oil.TileEntityMachinePumpjack; -import com.hbm.tileentity.machine.oil.TileEntityMachineRefinery; -import com.hbm.tileentity.machine.oil.TileEntitySpacer; +import com.hbm.tileentity.machine.oil.*; import com.hbm.tileentity.machine.rbmk.*; -import com.hbm.tileentity.network.TileEntityConnector; -import com.hbm.tileentity.network.TileEntityPylon; +import com.hbm.tileentity.network.*; import com.hbm.tileentity.turret.*; import cpw.mods.fml.client.registry.ClientRegistry; @@ -238,6 +230,7 @@ public class ClientProxy extends ServerProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRFDuct.class, new RenderRFCable()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPylon.class, new RenderPylon()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConnector.class, new RenderConnector()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPylonLarge.class, new RenderPylonLarge()); //multiblocks ClientRegistry.bindTileEntitySpecialRenderer(TileEntityStructureMarker.class, new RenderStructureMaker()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMultiblock.class, new RenderMultiblock()); diff --git a/src/main/java/com/hbm/render/tileentity/RenderPylonBase.java b/src/main/java/com/hbm/render/tileentity/RenderPylonBase.java index 2824bdad8..8d3916a5a 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderPylonBase.java +++ b/src/main/java/com/hbm/render/tileentity/RenderPylonBase.java @@ -3,6 +3,7 @@ package com.hbm.render.tileentity; import org.lwjgl.opengl.GL11; import com.hbm.tileentity.network.TileEntityPylonBase; +import com.hbm.tileentity.network.TileEntityPylonBase.ConnectionType; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; @@ -59,7 +60,7 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer { int lY = brightness / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)lX / 1.0F, (float)lY / 1.0F); - drawPowerLine( + drawLineSegment( x + myOffset.xCoord + (wX * j / count), y + myOffset.yCoord + (wY * j / count) - Math.sin(j / count * Math.PI * 0.5) * hang, z + myOffset.zCoord + (wZ * j / count), @@ -73,10 +74,42 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer { public void renderLinesGeneric(TileEntityPylonBase pyl, double x, double y, double z) { + for(int i = 0; i < pyl.connected.size(); i++) { + + int[] wire = pyl.connected.get(i); + TileEntity tile = pyl.getWorldObj().getTileEntity(wire[0], wire[1], wire[2]); + + if(tile instanceof TileEntityPylonBase) { + TileEntityPylonBase pylon = (TileEntityPylonBase) tile; + + Vec3[] m1 = pyl.getMountPos(); + Vec3[] m2 = pylon.getMountPos(); + + int lineCount = Math.max(pyl.getConnectionType() == ConnectionType.QUAD ? 4 : 1, pylon.getConnectionType() == ConnectionType.QUAD ? 4 : 1); + + for(int line = 0; line < lineCount; line++) { + + Vec3 first = m1[line % m1.length]; + Vec3 second = m2[line % m2.length]; + double sX = second.xCoord + pylon.xCoord - pyl.xCoord; + double sY = second.yCoord + pylon.yCoord - pyl.yCoord; + double sZ = second.zCoord + pylon.zCoord - pyl.zCoord; + + renderLine(pyl.getWorldObj(), pyl, x, y, z, + first.xCoord, + first.yCoord, + first.zCoord, + first.xCoord + (sX - first.xCoord) * 0.5, + first.yCoord + (sY - first.yCoord) * 0.5, + first.zCoord + (sZ - first.zCoord) * 0.5); + } + } + } } public void renderLine(World world, TileEntityPylonBase pyl, double x, double y, double z, double x0, double y0, double z0, double x1, double y1, double z1) { + GL11.glPushMatrix(); GL11.glTranslated(x, y, z); float count = 10; @@ -98,7 +131,7 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer { int lY = brightness / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)lX / 1.0F, (float)lY / 1.0F); - drawPowerLine( + drawLineSegment( x0 + (deltaX * j / count), y0 + (deltaY * j / count) - Math.sin(j / count * Math.PI * 0.5), z0 + (deltaZ * j / count), @@ -106,9 +139,12 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer { y0 + (deltaY * k / count) - Math.sin(k / count * Math.PI * 0.5), z0 + (deltaZ * k / count)); } + GL11.glPopMatrix(); } - public void drawPowerLine(double x, double y, double z, double a, double b, double c) { + public void drawLineSegment(double x, double y, double z, double a, double b, double c) { + + double girth = 0.03125D; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); @@ -116,24 +152,18 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer { Tessellator tessellator = Tessellator.instance; tessellator.startDrawing(5); tessellator.setColorOpaque_I(0xBB3311); - tessellator.addVertex(x, y + 0.05F, z); - tessellator.addVertex(x, y - 0.05F, z); - tessellator.addVertex(a, b + 0.05F, c); - tessellator.addVertex(a, b - 0.05F, c); - tessellator.draw(); - tessellator.startDrawing(5); - tessellator.setColorOpaque_I(0xBB3311); - tessellator.addVertex(x + 0.05F, y, z); - tessellator.addVertex(x - 0.05F, y, z); - tessellator.addVertex(a + 0.05F, b, c); - tessellator.addVertex(a - 0.05F, b, c); - tessellator.draw(); - tessellator.startDrawing(5); - tessellator.setColorOpaque_I(0xBB3311); - tessellator.addVertex(x, y, z + 0.05F); - tessellator.addVertex(x, y, z - 0.05F); - tessellator.addVertex(a, b, c + 0.05F); - tessellator.addVertex(a, b, c - 0.05F); + tessellator.addVertex(x, y + girth, z); + tessellator.addVertex(x, y - girth, z); + tessellator.addVertex(a, b + girth, c); + tessellator.addVertex(a, b - girth, c); + tessellator.addVertex(x + girth, y, z); + tessellator.addVertex(x - girth, y, z); + tessellator.addVertex(a + girth, b, c); + tessellator.addVertex(a - girth, b, c); + tessellator.addVertex(x, y, z + girth); + tessellator.addVertex(x, y, z - girth); + tessellator.addVertex(a, b, c + girth); + tessellator.addVertex(a, b, c - girth); tessellator.draw(); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_TEXTURE_2D); diff --git a/src/main/java/com/hbm/render/tileentity/RenderPylonLarge.java b/src/main/java/com/hbm/render/tileentity/RenderPylonLarge.java new file mode 100644 index 000000000..d5ad3f7ce --- /dev/null +++ b/src/main/java/com/hbm/render/tileentity/RenderPylonLarge.java @@ -0,0 +1,38 @@ +package com.hbm.render.tileentity; + +import org.lwjgl.opengl.GL11; + +import com.hbm.blocks.BlockDummyable; +import com.hbm.main.ResourceManager; +import com.hbm.tileentity.network.TileEntityPylonLarge; + +import net.minecraft.tileentity.TileEntity; + +public class RenderPylonLarge extends RenderPylonBase { + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y, z + 0.5); + + switch(tile.getBlockMetadata() - BlockDummyable.offset) { + case 2: GL11.glRotatef(90, 0F, 1F, 0F); break; + case 4: GL11.glRotatef(180, 0F, 1F, 0F); break; + case 3: GL11.glRotatef(270, 0F, 1F, 0F); break; + case 5: GL11.glRotatef(0, 0F, 1F, 0F); break; + } + + GL11.glDisable(GL11.GL_CULL_FACE); + bindTexture(ResourceManager.pylon_large_tex); + ResourceManager.pylon_large.renderAll(); + GL11.glEnable(GL11.GL_CULL_FACE); + + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + TileEntityPylonLarge pyl = (TileEntityPylonLarge)tile; + this.renderLinesGeneric(pyl, x, y, z); + GL11.glPopMatrix(); + } + +} diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityPylonBase.java b/src/main/java/com/hbm/tileentity/network/TileEntityPylonBase.java index bd908f869..a4824bd2f 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityPylonBase.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityPylonBase.java @@ -116,7 +116,7 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT { if(mounts == null || mounts.length == 0) return Vec3.createVectorHelper(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - return mounts[0]; + return mounts[0].addVector(xCoord, yCoord, zCoord); } @Override diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityPylonLarge.java b/src/main/java/com/hbm/tileentity/network/TileEntityPylonLarge.java index beb4088a1..8cbe4638c 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityPylonLarge.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityPylonLarge.java @@ -11,7 +11,14 @@ public class TileEntityPylonLarge extends TileEntityPylonBase { @Override public Vec3[] getMountPos() { - return null; + double topOff = 0.75 + 0.0625; + double sideOff = 3.375; + return new Vec3[] { + Vec3.createVectorHelper(0.5 + sideOff, 11.5 + topOff, 0.5), + Vec3.createVectorHelper(0.5 + sideOff, 11.5 - topOff, 0.5), + Vec3.createVectorHelper(0.5 - sideOff, 11.5 + topOff, 0.5), + Vec3.createVectorHelper(0.5 - sideOff, 11.5 - topOff, 0.5), + }; } @Override diff --git a/src/main/resources/assets/hbm/textures/blocks/charge_dynamite.png b/src/main/resources/assets/hbm/textures/blocks/charge_dynamite.png new file mode 100644 index 0000000000000000000000000000000000000000..49c5cb40d4ee0dc9942491d6b551592e124756cf GIT binary patch literal 348 zcmV-i0i*tjP){}o) zWZ(`Rn3ADUiKtWwp(L#n23ly+CZ%HFP1gJUzxV9lhX01qB!VEQ0OB~V@viFvpp>fh z$X%*Rshw^?5NvT<0&8dA_rJL?3~RN$37U;v=>4U+Q{cCdcbBJ?-4_f^fny489k+G! zdJ;7OyDxY+z5rm9je)P*ZX070y`d=pNYj)g(}y3yF$JS+Omd`|=7$Ry&sTP3uTr$( z<$b~6{t*D{<{E(Wr-=a|XN!`3zOQ-70I)2JNv1J3W+!Jw$%n2w1=2zjMG>Cokz|?^ u`STs*d|5JIb|-i%O3qg6X|Aa@p3f%?=v()pje^bq0000Eakt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