diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/client/ClientProxy.java | 3 | ||||
-rw-r--r-- | src/main/java/client/GTTexture.java | 6 | ||||
-rw-r--r-- | src/main/java/client/renderer/TESR_BeamTransmitter.java | 65 | ||||
-rw-r--r-- | src/main/java/common/Blocks.java | 2 | ||||
-rw-r--r-- | src/main/java/common/TileEntities.java | 1 | ||||
-rw-r--r-- | src/main/java/common/blocks/Block_BeamTransmitter.java | 55 | ||||
-rw-r--r-- | src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java | 68 | ||||
-rw-r--r-- | src/main/java/common/tileentities/TE_BeamTransmitter.java | 47 | ||||
-rw-r--r-- | src/main/resources/assets/kekztech/lang/en_US.lang | 5 |
9 files changed, 195 insertions, 57 deletions
diff --git a/src/main/java/client/ClientProxy.java b/src/main/java/client/ClientProxy.java index f608861c0d..5ed713f827 100644 --- a/src/main/java/client/ClientProxy.java +++ b/src/main/java/client/ClientProxy.java @@ -1,8 +1,10 @@ package client; +import client.renderer.TESR_BeamTransmitter; import client.renderer.TESR_SECapacitor; import client.renderer.TESR_SETether; import common.CommonProxy; +import common.tileentities.TE_BeamTransmitter; import common.tileentities.TE_SpaceElevatorCapacitor; import common.tileentities.TE_SpaceElevatorTether; import cpw.mods.fml.client.registry.ClientRegistry; @@ -18,6 +20,7 @@ public class ClientProxy extends CommonProxy { // Register TESR ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorTether.class, new TESR_SETether()); ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorCapacitor.class, new TESR_SECapacitor()); + ClientRegistry.bindTileEntitySpecialRenderer(TE_BeamTransmitter.class, new TESR_BeamTransmitter()); } @Override diff --git a/src/main/java/client/GTTexture.java b/src/main/java/client/GTTexture.java index a449dc257b..2ede4976fb 100644 --- a/src/main/java/client/GTTexture.java +++ b/src/main/java/client/GTTexture.java @@ -12,9 +12,9 @@ import java.util.HashMap; public class GTTexture implements IIconContainer, Runnable { - public static final GTTexture TFFT_CASING = new GTTexture("textures/blocks/TFFTCasing"); - public static final GTTexture MULTI_HATCH_OFF = new GTTexture("textures/blocks/multi_hatch_off"); - public static final GTTexture MULTI_HATCH_ON = new GTTexture("textures/blocks/multi_hatch_on"); + public static final GTTexture TFFT_CASING = new GTTexture("blocks/TFFTCasing"); + public static final GTTexture MULTI_HATCH_OFF = new GTTexture("blocks/multi_hatch_off"); + public static final GTTexture MULTI_HATCH_ON = new GTTexture("blocks/multi_hatch_on"); private IIcon icon; private final String iconName; diff --git a/src/main/java/client/renderer/TESR_BeamTransmitter.java b/src/main/java/client/renderer/TESR_BeamTransmitter.java new file mode 100644 index 0000000000..3c48dab264 --- /dev/null +++ b/src/main/java/client/renderer/TESR_BeamTransmitter.java @@ -0,0 +1,65 @@ +package client.renderer; + +import common.tileentities.TE_BeamTransmitter; +import kekztech.KekzCore; +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.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class TESR_BeamTransmitter extends TileEntitySpecialRenderer { + + private static final ResourceLocation beamTexture = new ResourceLocation(KekzCore.MODID, "textures/effects/Tether_beam.png"); + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) { + final TE_BeamTransmitter beamTransmitter = (TE_BeamTransmitter) te; + + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + // Get Tessellator instance + final Tessellator tessellator = Tessellator.instance; + // Bind beam texture and set texture params + super.bindTexture(beamTexture); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + // Set render flags for inner beam + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + // Prepare Tessellator + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(255, 255, 255, 32); + // Variables stuff II + final float exactTime = (float)beamTransmitter.getWorldObj().getTotalWorldTime() + partialTick; + final float streamTextureOffset = -exactTime * 0.2F - (float) MathHelper.floor_float(-exactTime * 0.1F); + + final double halfBeamWidth = 0.1D; + final double height = beamTransmitter.getDistanceFromTarget(); + final double uv_x1 = 0.0D; + final double uv_x2 = 1.0D; + final double uv_y1 = -1.0D - streamTextureOffset; // This makes the beam stream upwards if you add a time sensitive number to it + final double uv_y2 = (double)beamTransmitter.getDistanceFromTarget() * (0.5D / (halfBeamWidth * 2)) + uv_y1; + // Construct mesh with texture + tessellator.addVertexWithUV(x + 0.5 + halfBeamWidth, y + 0.5, z + 0.5, uv_x2, uv_y2); + tessellator.addVertexWithUV(x + 0.5 + halfBeamWidth, y + height, z + 0.5, uv_x2, uv_y1); + tessellator.addVertexWithUV(x + 0.5 - halfBeamWidth, y + height, z + 0.5, uv_x1, uv_y1); + tessellator.addVertexWithUV(x + 0.5 - halfBeamWidth, y + 0.5, z + 0.5, uv_x1, uv_y2); + + tessellator.addVertexWithUV(x + 0.5, y + 0.5, z + 0.5 + halfBeamWidth, uv_x2, uv_y2); + tessellator.addVertexWithUV(x + 0.5, y + height, z + 0.5 + halfBeamWidth, uv_x2, uv_y1); + tessellator.addVertexWithUV(x + 0.5, y + height, z + 0.5 - halfBeamWidth, uv_x1, uv_y1); + tessellator.addVertexWithUV(x + 0.5, y + 0.5, z + 0.5 - halfBeamWidth, uv_x1, uv_y2); + // Draw! + tessellator.draw(); + + // Reset render flags + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + } +} diff --git a/src/main/java/common/Blocks.java b/src/main/java/common/Blocks.java index efb5146137..304af71460 100644 --- a/src/main/java/common/Blocks.java +++ b/src/main/java/common/Blocks.java @@ -33,6 +33,7 @@ public class Blocks { public static Block jarIchor; public static Block lscLapotronicEnergyUnit; + public static Block beamTransmitter; public static Block spaceElevatorStructure; public static Block spaceElevatorCapacitor; @@ -89,6 +90,7 @@ public class Blocks { private static void registerBlocks_LSC() { lscLapotronicEnergyUnit = Block_LapotronicEnergyUnit.registerBlock(); + beamTransmitter = Block_BeamTransmitter.registerBlock(); } private static void registerBlocks_SpaceElevator() { diff --git a/src/main/java/common/TileEntities.java b/src/main/java/common/TileEntities.java index 963dd81e9f..9bb839feda 100644 --- a/src/main/java/common/TileEntities.java +++ b/src/main/java/common/TileEntities.java @@ -25,6 +25,7 @@ public class TileEntities { GameRegistry.registerTileEntity(TE_ThaumiumReinforcedJar.class, "kekztech_thaumiumreinforcedjar"); GameRegistry.registerTileEntity(TE_IchorJar.class, "kekztech_ichorjar"); //GameRegistry.registerTileEntity(TE_SpaceElevatorCapacitor.class, "kekztech_secapacitor"); + GameRegistry.registerTileEntity(TE_BeamTransmitter.class, "kekztech_beamtransmitter"); } public static void init() { diff --git a/src/main/java/common/blocks/Block_BeamTransmitter.java b/src/main/java/common/blocks/Block_BeamTransmitter.java new file mode 100644 index 0000000000..af7a837fdd --- /dev/null +++ b/src/main/java/common/blocks/Block_BeamTransmitter.java @@ -0,0 +1,55 @@ +package common.blocks; + +import common.tileentities.TE_BeamTransmitter; +import common.tileentities.TE_SpaceElevatorTether; +import cpw.mods.fml.common.registry.GameRegistry; +import kekztech.KekzCore; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class Block_BeamTransmitter extends Block { + + private static final Block_BeamTransmitter INSTANCE = new Block_BeamTransmitter(); + + private Block_BeamTransmitter() { + super(Material.glass); + } + + public static Block registerBlock() { + final String blockName = "kekztech_beamtransmitter_block"; + INSTANCE.setBlockName(blockName); + INSTANCE.setCreativeTab(CreativeTabs.tabMisc); + INSTANCE.setHardness(5.0f); + INSTANCE.setResistance(5.0f); + INSTANCE.setBlockTextureName(KekzCore.MODID + ":" + "Tether_top"); + GameRegistry.registerBlock(INSTANCE, blockName); + + return INSTANCE; + } + + @Override + public TileEntity createTileEntity(World world, int meta) { + return new TE_BeamTransmitter(); + } + + @Override + public boolean hasTileEntity(int meta) { + return true; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + +} diff --git a/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java index ba523ab090..c8c987d7dc 100644 --- a/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java +++ b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java @@ -66,12 +66,14 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.MULTI_HATCH_ON)}; + //return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.MULTI_HATCH_ON)}; + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_PIPE_STEEL)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.MULTI_HATCH_OFF)}; + //return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.MULTI_HATCH_OFF)}; + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE)}; } @Override @@ -91,16 +93,6 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { } @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - - @Override public int getCapacity() { return (mfh != null) ? mfh.getCapacity() : 0; } @@ -108,8 +100,6 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide() && mfh != null) { - emptyContainers(aBaseMetaTileEntity); - fillContainers(aBaseMetaTileEntity); if(outputting && (aTick % 20 == 0)) { doAutoOutputPerSecond(aBaseMetaTileEntity); } @@ -117,43 +107,6 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { } /** - * Empty containers (cells, buckets, etc) from the GUI into the T.F.F.T - * @param aBaseMetaTileEntity - * this MetaTileEntity - */ - private void emptyContainers(IGregTechTileEntity aBaseMetaTileEntity) { - final FluidStack fluidFromCell = GT_Utility.getFluidForFilledItem(super.mInventory[super.getInputSlot()], true); - // Check if fluid is not null, could be inserted, and if there is space for the empty container - if (fluidFromCell != null && mfh.couldPush(fluidFromCell) - && aBaseMetaTileEntity.addStackToSlot(super.getOutputSlot(), GT_Utility.getContainerItem(super.mInventory[super.getInputSlot()], true), 1)) { - // Consume one filled container if it was emptied successfully - if(mfh.pushFluid(fluidFromCell, true) == fluidFromCell.amount) { - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - } - } - } - - /** - * Fill containers (cells, buckets, etc) in the GUI. The fluid used to fill containers will be the one that is - * selected through an Integrated Circuit in the T.F.F.T's controller GUI. - * @param aBaseMetaTileEntity - * this MetaTileEntity - */ - private void fillContainers(IGregTechTileEntity aBaseMetaTileEntity) { - final ItemStack cellFromFluid = GT_Utility.fillFluidContainer( - mfh.getFluidCopy(mfh.getSelectedFluid()), super.mInventory[super.getInputSlot()], false, true); - // Check if cell is not null and if there is space for the filled container - if (cellFromFluid != null && aBaseMetaTileEntity.addStackToSlot(super.getOutputSlot(), cellFromFluid, 1)) { - // Convert back to FluidStack to learn the container capacity... - final FluidStack fluidCapacityStack = GT_Utility.getFluidForFilledItem(cellFromFluid, true); - // Consume one empty container if it was filled successfully - if(mfh.pullFluid(fluidCapacityStack, true) == fluidCapacityStack.amount) { - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - } - } - } - - /** * Handle the Multi Hatch's auto-output feature. Should be called once per second only. * @param aBaseMetaTileEntity * this MetaTileEntity @@ -229,12 +182,21 @@ public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == super.getOutputSlot(); + return false; } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == super.getInputSlot(); + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; } + @Override + public boolean canTankBeEmptied() { + return true; + } } diff --git a/src/main/java/common/tileentities/TE_BeamTransmitter.java b/src/main/java/common/tileentities/TE_BeamTransmitter.java new file mode 100644 index 0000000000..74cb845fc4 --- /dev/null +++ b/src/main/java/common/tileentities/TE_BeamTransmitter.java @@ -0,0 +1,47 @@ +package common.tileentities; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import org.joml.Vector3i; +import org.joml.Vector3ic; + +public class TE_BeamTransmitter extends TileEntity { + + private final Vector3ic position; + + private Vector3ic target = new Vector3i(10, 20, 10); + private double distanceCache; + private boolean distanceCacheValid = false; + + public TE_BeamTransmitter() { + position = new Vector3i(super.xCoord, super.yCoord, super.zCoord); + } + + public Vector3ic getTargetPosition() { + return target; + } + + public double getDistanceFromTarget() { + if (!distanceCacheValid) { + distanceCache = position.distance(target); + distanceCacheValid = true; + } + return distanceCache; + } + + @SideOnly(Side.CLIENT) + @Override + public double getMaxRenderDistanceSquared() { + // 4k is standard, 65k is what the vanilla beacon uses + return 65536.0D; + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + // Make it so the beam is still rendered even when the source block is out of sight + return INFINITE_EXTENT_AABB; + } +} diff --git a/src/main/resources/assets/kekztech/lang/en_US.lang b/src/main/resources/assets/kekztech/lang/en_US.lang index f4a97bd101..3c8ec42ce8 100644 --- a/src/main/resources/assets/kekztech/lang/en_US.lang +++ b/src/main/resources/assets/kekztech/lang/en_US.lang @@ -173,4 +173,7 @@ tile.kekztech_spaceelevatorcapacitor_block.desc=The see-through is good for your tile.kekztech_spaceelevatortether_block.name=Space Elevator Tether # -------- Cosmetic Blocks -tile.kekztech_largehextile_block=Large Hex Tile
\ No newline at end of file +tile.kekztech_largehextile_block=Large Hex Tile + +# -------- Beam Transmitter +tile.kekztech_beamtransmitter_block=Beam Transmitter
\ No newline at end of file |