diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index b2745e6d0..f10989622 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -690,6 +690,7 @@ public class ModBlocks { public static Block red_wire_coated; public static Block red_cable; + public static Block red_connector; public static Block red_pylon; public static Block cable_switch; public static Block machine_detector; @@ -1790,6 +1791,7 @@ public class ModBlocks { red_wire_coated = new WireCoated(Material.iron).setBlockName("red_wire_coated").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":red_wire_coated"); red_cable = new BlockCable(Material.iron).setBlockName("red_cable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":cable_neo"); rf_cable = new BlockRFCable(Material.iron).setBlockName("rf_cable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":rf_cable_icon"); + red_connector = new ConnectorRedWire(Material.iron).setBlockName("red_connector").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":red_connector"); red_pylon = new PylonRedWire(Material.iron).setBlockName("red_pylon").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":red_pylon"); cable_switch = new CableSwitch(Material.iron).setBlockName("cable_switch").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":cable_switch_off"); machine_detector = new PowerDetector(Material.iron).setBlockName("machine_detector").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_detector_off"); @@ -2869,6 +2871,7 @@ public class ModBlocks { GameRegistry.registerBlock(red_cable, red_cable.getUnlocalizedName()); GameRegistry.registerBlock(red_wire_coated, red_wire_coated.getUnlocalizedName()); + GameRegistry.registerBlock(red_connector, red_connector.getUnlocalizedName()); GameRegistry.registerBlock(red_pylon, red_pylon.getUnlocalizedName()); GameRegistry.registerBlock(cable_switch, cable_switch.getUnlocalizedName()); GameRegistry.registerBlock(machine_detector, machine_detector.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/blocks/network/ConnectorRedWire.java b/src/main/java/com/hbm/blocks/network/ConnectorRedWire.java new file mode 100644 index 000000000..1eaf9f06c --- /dev/null +++ b/src/main/java/com/hbm/blocks/network/ConnectorRedWire.java @@ -0,0 +1,20 @@ +package com.hbm.blocks.network; + +import com.hbm.tileentity.network.TileEntityConnector; + +import net.minecraft.block.material.Material; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class ConnectorRedWire extends PylonBase { + + public ConnectorRedWire(Material mat) { + super(mat); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityConnector(); + } + +} diff --git a/src/main/java/com/hbm/blocks/network/PylonRedWire.java b/src/main/java/com/hbm/blocks/network/PylonRedWire.java index 6cebf526b..552781fd9 100644 --- a/src/main/java/com/hbm/blocks/network/PylonRedWire.java +++ b/src/main/java/com/hbm/blocks/network/PylonRedWire.java @@ -9,12 +9,12 @@ import net.minecraft.world.World; public class PylonRedWire extends PylonBase { - public PylonRedWire(Material p_i45386_1_) { - super(p_i45386_1_); + public PylonRedWire(Material material) { + super(material); } @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityPylon(); } } diff --git a/src/main/java/com/hbm/entity/missile/EntityMissileDrill.java b/src/main/java/com/hbm/entity/missile/EntityMissileDrill.java index 7ee90dc9a..bc860e2e6 100644 --- a/src/main/java/com/hbm/entity/missile/EntityMissileDrill.java +++ b/src/main/java/com/hbm/entity/missile/EntityMissileDrill.java @@ -26,7 +26,7 @@ public class EntityMissileDrill extends EntityMissileBaseAdvanced { public void onImpact() { for(int i = 0; i < 30; i++) { - ExplosionNT explosion = new ExplosionNT(worldObj, this, this.posX, this.posY - 1, this.posZ, 10F); + ExplosionNT explosion = new ExplosionNT(worldObj, this, this.posX, this.posY - i, this.posZ, 10F); explosion.addAllAttrib(ExAttrib.ERRODE); explosion.explode(); //an explosion exploded! } diff --git a/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java b/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java index 50f8fb6c3..5662bcc4e 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java +++ b/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java @@ -202,8 +202,7 @@ public class EntityBulletBase extends Entity implements IProjectile { return; } - if(this.config.blackPowder) { - this.setDead(); + if(this.config.blackPowder && this.ticksExisted == 1) { for(int i = 0; i < 15; i++) { double mod = rand.nextDouble(); @@ -215,7 +214,6 @@ public class EntityBulletBase extends Entity implements IProjectile { double mod = 0.5; this.worldObj.spawnParticle("flame", this.posX + this.motionX * mod, this.posY + this.motionY * mod, this.posZ + this.motionZ * mod, 0, 0, 0); - return; } if(config.maxAge == 0) { diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index a725ce863..71b27a8ef 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -86,6 +86,7 @@ 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.rbmk.*; +import com.hbm.tileentity.network.TileEntityConnector; import com.hbm.tileentity.network.TileEntityPylon; import com.hbm.tileentity.turret.*; @@ -236,6 +237,7 @@ public class ClientProxy extends ServerProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFluidDuct.class, new RenderFluidDuct()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRFDuct.class, new RenderRFCable()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPylon.class, new RenderPylon()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConnector.class, new RenderConnector()); //multiblocks ClientRegistry.bindTileEntitySpecialRenderer(TileEntityStructureMarker.class, new RenderStructureMaker()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMultiblock.class, new RenderMultiblock()); diff --git a/src/main/java/com/hbm/render/tileentity/RenderConnector.java b/src/main/java/com/hbm/render/tileentity/RenderConnector.java new file mode 100644 index 000000000..1182553fe --- /dev/null +++ b/src/main/java/com/hbm/render/tileentity/RenderConnector.java @@ -0,0 +1,28 @@ +package com.hbm.render.tileentity; + +import org.lwjgl.opengl.GL11; + +import com.hbm.main.ResourceManager; +import com.hbm.tileentity.network.TileEntityConnector; + +import net.minecraft.tileentity.TileEntity; + +public class RenderConnector extends RenderPylonBase { + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float interp) { + TileEntityConnector con = (TileEntityConnector) te; + + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y, z + 0.5); + double s = 0.5; + GL11.glScaled(s, s, s); + bindTexture(ResourceManager.universal); + ResourceManager.barrel.renderAll(); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + this.renderSingleLine(con, x, y, z); + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/com/hbm/render/tileentity/RenderPylon.java b/src/main/java/com/hbm/render/tileentity/RenderPylon.java index 5fb6ef3af..f700bd3ed 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderPylon.java +++ b/src/main/java/com/hbm/render/tileentity/RenderPylon.java @@ -16,7 +16,7 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; -public class RenderPylon extends TileEntitySpecialRenderer { +public class RenderPylon extends RenderPylonBase { private static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":" + "textures/models/ModelPylon.png"); @@ -29,83 +29,16 @@ public class RenderPylon extends TileEntitySpecialRenderer { @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) { TileEntityPylon pyl = (TileEntityPylon)te; + GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F - ((1F / 16F) * 14F), (float) z + 0.5F); GL11.glRotatef(180, 0F, 0F, 1F); bindTexture(texture); this.pylon.renderAll(0.0625F); GL11.glPopMatrix(); - GL11.glPushMatrix(); - for(int i = 0; i < pyl.connected.size(); i++) { - - int[] wire = pyl.connected.get(i); - - float wX = (wire[0] - pyl.xCoord) / 2F; - float wY = (wire[1] - pyl.yCoord) / 2F; - float wZ = (wire[2] - pyl.zCoord) / 2F; - - float count = 10; - Vec3 delta = Vec3.createVectorHelper((wire[0] - te.xCoord), (wire[1] - te.yCoord), (wire[2] - te.zCoord)); - - for(float j = 0; j < count; j++) { - - float k = j + 1; - - double ja = j + 0.5D; - double ix = te.xCoord + 0.5 + delta.xCoord / (double)(count * 2) * ja; - double iy = te.yCoord + 0.5 + delta.yCoord / (double)(count * 2) * ja + 5 - Math.sin(j / count * Math.PI * 0.5); - double iz = te.zCoord + 0.5 + delta.zCoord / (double)(count * 2) * ja; - - //te.getWorldObj().spawnParticle("reddust", ix, iy, iz, 0.01 + j * 0.1, 0, 0); - - int brightness = te.getWorldObj().getLightBrightnessForSkyBlocks(MathHelper.floor_double(ix), MathHelper.floor_double(iy), MathHelper.floor_double(iz), 0); - int lX = brightness % 65536; - int lY = brightness / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)lX / 1.0F, (float)lY / 1.0F); - - drawPowerLine( - x + 0.5 + (wX * j / count), - y + 5.4 + (wY * j / count) - Math.sin(j / count * Math.PI * 0.5), - z + 0.5 + (wZ * j / count), - x + 0.5 + (wX * k / count), - y + 5.4 + (wY * k / count) - Math.sin(k / count * Math.PI * 0.5), - z + 0.5 + (wZ * k / count)); - } - } + GL11.glPushMatrix(); + this.renderSingleLine(pyl, x, y, z); GL11.glPopMatrix(); } - - public void drawPowerLine(double x, double y, double z, double a, double b, double c) { - - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - 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.draw(); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_CULL_FACE); - } - } diff --git a/src/main/java/com/hbm/render/tileentity/RenderPylonBase.java b/src/main/java/com/hbm/render/tileentity/RenderPylonBase.java new file mode 100644 index 000000000..ef4e3111d --- /dev/null +++ b/src/main/java/com/hbm/render/tileentity/RenderPylonBase.java @@ -0,0 +1,136 @@ +package com.hbm.render.tileentity; + +import org.lwjgl.opengl.GL11; + +import com.hbm.tileentity.network.TileEntityPylonBase; + +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public abstract class RenderPylonBase extends TileEntitySpecialRenderer { + + //TODO: adapt this into a more generic form for multi wire pylons + public void renderSingleLine(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 myOffset = pyl.getMountPos(); + Vec3 theirOffset = pylon.getMountPos(); + + double conX0 = pyl.xCoord + myOffset.xCoord; + double conY0 = pyl.yCoord + myOffset.yCoord; + double conZ0 = pyl.zCoord + myOffset.zCoord; + double conX1 = pylon.xCoord + theirOffset.xCoord; + double conY1 = pylon.yCoord + theirOffset.yCoord; + double conZ1 = pylon.zCoord + theirOffset.zCoord; + + double wX = (conX1 - conX0) / 2D; + double wY = (conY1 - conY0) / 2D; + double wZ = (conZ1 - conZ0) / 2D; + + float count = 10; + Vec3 delta = Vec3.createVectorHelper(conX1 - conX0, conY1 - conY0, conZ1 - conZ0); + + for(float j = 0; j < count; j++) { + + float k = j + 1; + + double ja = j + 0.5D; + double ix = conX0 + delta.xCoord / (double)(count * 2) * ja; + double iy = conY0 + delta.yCoord / (double)(count * 2) * ja - Math.sin(j / count * Math.PI * 0.5); + double iz = conZ0 + delta.zCoord / (double)(count * 2) * ja; + + //pylon.getWorldObj().spawnParticle("reddust", ix, iy, iz, 0.01 + j * 0.1, 0, 0); + + int brightness = pyl.getWorldObj().getLightBrightnessForSkyBlocks(MathHelper.floor_double(ix), MathHelper.floor_double(iy), MathHelper.floor_double(iz), 0); + int lX = brightness % 65536; + int lY = brightness / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)lX / 1.0F, (float)lY / 1.0F); + + drawPowerLine( + x + myOffset.xCoord + (wX * j / count), + y + myOffset.yCoord + (wY * j / count) - Math.sin(j / count * Math.PI * 0.5), + z + myOffset.zCoord + (wZ * j / count), + x + myOffset.xCoord + (wX * k / count), + y + myOffset.yCoord + (wY * k / count) - Math.sin(k / count * Math.PI * 0.5), + z + myOffset.zCoord + (wZ * k / count)); + } + } + } + } + + 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.glTranslated(x, y, z); + float count = 10; + + for(float j = 0; j < count; j++) { + + float k = j + 1; + + double deltaX = x1 - x0; + double deltaY = y1 - y0; + double deltaZ = z1 - z0; + + double ja = j + 0.5D; + double ix = pyl.xCoord + x0 + deltaX / (double)(count * 2) * ja; + double iy = pyl.yCoord + y0 + deltaY / (double)(count * 2) * ja - Math.sin(j / count * Math.PI * 0.5); + double iz = pyl.zCoord + z0 + deltaZ / (double)(count * 2) * ja; + + int brightness = world.getLightBrightnessForSkyBlocks(MathHelper.floor_double(ix), MathHelper.floor_double(iy), MathHelper.floor_double(iz), 0); + int lX = brightness % 65536; + int lY = brightness / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)lX / 1.0F, (float)lY / 1.0F); + + drawPowerLine( + x0 + (deltaX * j / count), + y0 + (deltaY * j / count) - Math.sin(j / count * Math.PI * 0.5), + z0 + (deltaZ * j / count), + x0 + (deltaX * k / count), + y0 + (deltaY * k / count) - Math.sin(k / count * Math.PI * 0.5), + z0 + (deltaZ * k / count)); + } + } + + public void drawPowerLine(double x, double y, double z, double a, double b, double c) { + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + 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.draw(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_CULL_FACE); + } +} diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index 5001d7ef2..00b8cd714 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -73,6 +73,7 @@ public class TileMappings { put(TileEntityGasDuct.class, "tileentity_gas_duct"); put(TileEntityGasDuctSolid.class, "tileentity_gas_duct_solid"); put(TileEntityMachineRTG.class, "tileentity_machine_rtg"); + put(TileEntityConnector.class, "tileentity_connector_redwire"); put(TileEntityPylon.class, "tileentity_pylon_redwire"); put(TileEntityStructureMarker.class, "tileentity_structure_marker"); put(TileEntityMachineMiningDrill.class, "tileentity_mining_drill"); diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityConnector.java b/src/main/java/com/hbm/tileentity/network/TileEntityConnector.java new file mode 100644 index 000000000..e51fd5f40 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/network/TileEntityConnector.java @@ -0,0 +1,22 @@ +package com.hbm.tileentity.network; + +import net.minecraft.util.Vec3; + +public class TileEntityConnector extends TileEntityPylonBase { + + @Override + public ConnectionType getConnectionType() { + return ConnectionType.SINGLE; + } + + @Override + public Vec3 getMountPos() { + return Vec3.createVectorHelper(0.5, 0.5, 0.5); + } + + @Override + public double getMaxWireLength() { + return 10; + } + +} diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityPylon.java b/src/main/java/com/hbm/tileentity/network/TileEntityPylon.java index b986a5632..50ee6d7bc 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityPylon.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityPylon.java @@ -14,7 +14,7 @@ public class TileEntityPylon extends TileEntityPylonBase { @Override public Vec3 getMountPos() { - return Vec3.createVectorHelper(xCoord + 0.5, yCoord + 5.4, zCoord + 0.5); + return Vec3.createVectorHelper(0.5, 5.4, 0.5); } @Override diff --git a/src/main/resources/assets/hbm/textures/blocks/stone_gneiss_dark.png b/src/main/resources/assets/hbm/textures/blocks/stone_gneiss_dark.png new file mode 100644 index 000000000..096e26573 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/stone_gneiss_dark.png differ