mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
commit
0b3288d002
3 changed files with 70 additions and 5 deletions
|
@ -188,12 +188,13 @@ public class ModelLaserRelay extends ModelBaseAA{
|
|||
@Override
|
||||
public void renderExtra(float f, TileEntity tile){
|
||||
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||
WorldPos thisPos = new WorldPos(relay.getWorldObj(), relay.xCoord, relay.yCoord, relay.zCoord);
|
||||
ArrayList<LaserRelayConnectionHandler.ConnectionPair> network = LaserRelayConnectionHandler.getInstance().getNetworkFor(thisPos);
|
||||
WorldPos firstWP = new WorldPos(relay.getWorldObj(), relay.xCoord, relay.yCoord, relay.zCoord);
|
||||
ArrayList<LaserRelayConnectionHandler.ConnectionPair> network = LaserRelayConnectionHandler.getInstance().getNetworkFor(firstWP);
|
||||
if(network != null){
|
||||
for(LaserRelayConnectionHandler.ConnectionPair aPair : network){
|
||||
if(aPair.contains(thisPos) && aPair.firstRelay.isEqual(thisPos)){
|
||||
//TODO Make this work
|
||||
TileEntityLaserRelay firstRelay = (TileEntityLaserRelay) aPair.firstRelay.getTileEntity();
|
||||
if(aPair.contains(firstWP) && aPair.firstRelay.isEqual(firstWP)){
|
||||
firstRelay.drawLine(aPair.firstRelay, aPair.secondRelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,10 @@
|
|||
package ellpeck.actuallyadditions.blocks.render;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
||||
public class RenderLaserRelay extends RenderTileEntity{
|
||||
|
||||
public RenderLaserRelay(ModelBaseAA model){
|
||||
|
@ -52,9 +54,11 @@ public class RenderLaserRelay extends RenderTileEntity{
|
|||
}
|
||||
|
||||
theModel.render(0.0625F);
|
||||
//A Random texture, so it is a smooth Laser!
|
||||
bindTexture(new ResourceLocation("actuallyadditions:textures/blocks/blockBreaker.png"));
|
||||
theModel.renderExtra(0.0625F, tile);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,16 +13,20 @@ package ellpeck.actuallyadditions.tile;
|
|||
import cofh.api.energy.IEnergyReceiver;
|
||||
import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileEntityLaserRelay extends TileEntityBase implements IEnergyReceiver{
|
||||
|
||||
private GLColor laserColor = GLColor.RED_PURE;
|
||||
|
||||
@Override
|
||||
public void invalidate(){
|
||||
super.invalidate();
|
||||
|
@ -96,4 +100,60 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
|||
public boolean canConnectEnergy(ForgeDirection from){
|
||||
return true;
|
||||
}
|
||||
|
||||
public void drawLine(WorldPos firstPos, WorldPos secondPos){
|
||||
double x = firstPos.getX() - secondPos.getX();
|
||||
double y = firstPos.getY() - secondPos.getY() + 1;
|
||||
double z = -(firstPos.getZ() - secondPos.getZ());
|
||||
double relativePlayerBlockLocation = Minecraft.getMinecraft().thePlayer.posY - firstPos.getY();
|
||||
float f;
|
||||
if(relativePlayerBlockLocation < 10) f=5;
|
||||
else if(relativePlayerBlockLocation < 20 && relativePlayerBlockLocation > 10) f = 4;
|
||||
else if(relativePlayerBlockLocation < 30 && relativePlayerBlockLocation > 20) f = 3;
|
||||
else if(relativePlayerBlockLocation < 40 && relativePlayerBlockLocation > 30) f = 2;
|
||||
else if(relativePlayerBlockLocation < 50 && relativePlayerBlockLocation > 40) f = 1;
|
||||
else f=1;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glLineWidth(f);
|
||||
GL11.glBegin(GL11.GL_LINE_STRIP);
|
||||
{
|
||||
GL11.glColor3f(this.laserColor.getRed(), this.laserColor.getGreen(), this.laserColor.getBlue());
|
||||
GL11.glVertex3d(x, y, z);
|
||||
GL11.glVertex3d(0, 1, 0);
|
||||
}
|
||||
GL11.glEnd();
|
||||
GL11.glLineWidth(1);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void changeLineColor(GLColor color){this.laserColor = color;}
|
||||
|
||||
|
||||
//Colors for the Laser:
|
||||
public enum GLColor{
|
||||
|
||||
RED_PURE(1.0F, 0, 0),
|
||||
GREEN_PURE(0, 1.0F, 0),
|
||||
BLUE_PURE(0, 0, 1.0F),
|
||||
DARK_YELLOW(1, 1, 0);
|
||||
|
||||
private float red, green, blue;
|
||||
GLColor(float red, float green, float blue){
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
public float getRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
public float getGreen() {
|
||||
return green;
|
||||
}
|
||||
|
||||
public float getBlue() {
|
||||
return blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue