-Colors for the Laser

This commit is contained in:
canitzp 2015-10-25 23:01:14 +01:00
parent 7859db2f74
commit 13faae85d4
3 changed files with 42 additions and 15 deletions

View file

@ -194,7 +194,7 @@ public class ModelLaserRelay extends ModelBaseAA{
for(LaserRelayConnectionHandler.ConnectionPair aPair : network){ for(LaserRelayConnectionHandler.ConnectionPair aPair : network){
TileEntityLaserRelay firstRelay = (TileEntityLaserRelay) aPair.firstRelay.getTileEntity(); TileEntityLaserRelay firstRelay = (TileEntityLaserRelay) aPair.firstRelay.getTileEntity();
if(aPair.contains(firstWP) && aPair.firstRelay.isEqual(firstWP)){ if(aPair.contains(firstWP) && aPair.firstRelay.isEqual(firstWP)){
firstRelay.firstDraw(aPair.firstRelay, aPair.secondRelay); firstRelay.drawLine(aPair.firstRelay, aPair.secondRelay);
} }
} }
} }

View file

@ -54,10 +54,9 @@ public class RenderLaserRelay extends RenderTileEntity{
} }
theModel.render(0.0625F); theModel.render(0.0625F);
//A Random texture, so it is a smooth Laser!
bindTexture(new ResourceLocation("actuallyadditions:textures/blocks/blockBreaker.png")); bindTexture(new ResourceLocation("actuallyadditions:textures/blocks/blockBreaker.png"));
theModel.renderExtra(0.0625F, tile); theModel.renderExtra(0.0625F, tile);
bindTexture(resLoc);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }

View file

@ -18,7 +18,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -26,6 +25,7 @@ import java.util.ArrayList;
public class TileEntityLaserRelay extends TileEntityBase implements IEnergyReceiver{ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyReceiver{
private GLColor laserColor = GLColor.RED_PURE;
@Override @Override
public void invalidate(){ public void invalidate(){
@ -101,25 +101,23 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
return true; return true;
} }
public void firstDraw(WorldPos firstPos, WorldPos secondPos){ public void drawLine(WorldPos firstPos, WorldPos secondPos){
double x = firstPos.getX() - secondPos.getX(); double x = firstPos.getX() - secondPos.getX();
double y = firstPos.getY() - secondPos.getY() + 1; double y = firstPos.getY() - secondPos.getY() + 1;
double z = -(firstPos.getZ() - secondPos.getZ()); double z = -(firstPos.getZ() - secondPos.getZ());
double player = Minecraft.getMinecraft().thePlayer.posY-firstPos.getY(); double relativePlayerBlockLocation = Minecraft.getMinecraft().thePlayer.posY - firstPos.getY();
float f = 5; float f;
System.out.println(player); if(relativePlayerBlockLocation < 10) f=5;
if(player < 10) f=5; else if(relativePlayerBlockLocation < 20 && relativePlayerBlockLocation > 10) f = 4;
else if(player < 20 && player > 10) f = 4; else if(relativePlayerBlockLocation < 30 && relativePlayerBlockLocation > 20) f = 3;
else if(player < 30 && player > 20) f = 3; else if(relativePlayerBlockLocation < 40 && relativePlayerBlockLocation > 30) f = 2;
else if(player < 40 && player > 30) f = 2; else if(relativePlayerBlockLocation < 50 && relativePlayerBlockLocation > 40) f = 1;
else if(player < 50 && player > 40) f = 1;
else f=1; else f=1;
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glLineWidth(f); GL11.glLineWidth(f);
GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glBegin(GL11.GL_LINE_STRIP);
{ {
GL11.glColor3f(1.0F, 0, 0); GL11.glColor3f(this.laserColor.getRed(), this.laserColor.getGreen(), this.laserColor.getBlue());
GL11.glVertex3d(x, y, z); GL11.glVertex3d(x, y, z);
GL11.glVertex3d(0, 1, 0); GL11.glVertex3d(0, 1, 0);
} }
@ -128,4 +126,34 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
GL11.glPopMatrix(); 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;
}
}
} }