mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-23 07:38:34 +01:00
-LaserRelay renderer
This commit is contained in:
parent
d021f502ea
commit
6b58039721
3 changed files with 42 additions and 4 deletions
|
@ -188,12 +188,13 @@ public class ModelLaserRelay extends ModelBaseAA{
|
||||||
@Override
|
@Override
|
||||||
public void renderExtra(float f, TileEntity tile){
|
public void renderExtra(float f, TileEntity tile){
|
||||||
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||||
WorldPos thisPos = new WorldPos(relay.getWorldObj(), relay.xCoord, relay.yCoord, relay.zCoord);
|
WorldPos firstWP = new WorldPos(relay.getWorldObj(), relay.xCoord, relay.yCoord, relay.zCoord);
|
||||||
ArrayList<LaserRelayConnectionHandler.ConnectionPair> network = LaserRelayConnectionHandler.getInstance().getNetworkFor(thisPos);
|
ArrayList<LaserRelayConnectionHandler.ConnectionPair> network = LaserRelayConnectionHandler.getInstance().getNetworkFor(firstWP);
|
||||||
if(network != null){
|
if(network != null){
|
||||||
for(LaserRelayConnectionHandler.ConnectionPair aPair : network){
|
for(LaserRelayConnectionHandler.ConnectionPair aPair : network){
|
||||||
if(aPair.contains(thisPos) && aPair.firstRelay.isEqual(thisPos)){
|
TileEntityLaserRelay firstRelay = (TileEntityLaserRelay) aPair.firstRelay.getTileEntity();
|
||||||
//TODO Make this work
|
if(aPair.contains(firstWP) && aPair.firstRelay.isEqual(firstWP)){
|
||||||
|
firstRelay.firstDraw(aPair.firstRelay, aPair.secondRelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,10 @@
|
||||||
package ellpeck.actuallyadditions.blocks.render;
|
package ellpeck.actuallyadditions.blocks.render;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
|
||||||
public class RenderLaserRelay extends RenderTileEntity{
|
public class RenderLaserRelay extends RenderTileEntity{
|
||||||
|
|
||||||
public RenderLaserRelay(ModelBaseAA model){
|
public RenderLaserRelay(ModelBaseAA model){
|
||||||
|
@ -52,9 +54,12 @@ public class RenderLaserRelay extends RenderTileEntity{
|
||||||
}
|
}
|
||||||
|
|
||||||
theModel.render(0.0625F);
|
theModel.render(0.0625F);
|
||||||
|
bindTexture(new ResourceLocation("actuallyadditions:textures/blocks/blockBreaker.png"));
|
||||||
theModel.renderExtra(0.0625F, tile);
|
theModel.renderExtra(0.0625F, tile);
|
||||||
|
bindTexture(resLoc);
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,16 +13,20 @@ package ellpeck.actuallyadditions.tile;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler;
|
import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler;
|
||||||
import ellpeck.actuallyadditions.util.WorldPos;
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
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 java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TileEntityLaserRelay extends TileEntityBase implements IEnergyReceiver{
|
public class TileEntityLaserRelay extends TileEntityBase implements IEnergyReceiver{
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate(){
|
public void invalidate(){
|
||||||
super.invalidate();
|
super.invalidate();
|
||||||
|
@ -96,4 +100,32 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
||||||
public boolean canConnectEnergy(ForgeDirection from){
|
public boolean canConnectEnergy(ForgeDirection from){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void firstDraw(WorldPos firstPos, WorldPos secondPos){
|
||||||
|
double x = firstPos.getX() - secondPos.getX();
|
||||||
|
double y = firstPos.getY() - secondPos.getY() + 1;
|
||||||
|
double z = -(firstPos.getZ() - secondPos.getZ());
|
||||||
|
double player = Minecraft.getMinecraft().thePlayer.posY-firstPos.getY();
|
||||||
|
float f = 5;
|
||||||
|
System.out.println(player);
|
||||||
|
if(player < 10) f=5;
|
||||||
|
else if(player < 20 && player > 10) f = 4;
|
||||||
|
else if(player < 30 && player > 20) f = 3;
|
||||||
|
else if(player < 40 && player > 30) f = 2;
|
||||||
|
else if(player < 50 && player > 40) f = 1;
|
||||||
|
else f=1;
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glLineWidth(f);
|
||||||
|
GL11.glBegin(GL11.GL_LINE_STRIP);
|
||||||
|
{
|
||||||
|
GL11.glColor3f(1.0F, 0, 0);
|
||||||
|
GL11.glVertex3d(x, y, z);
|
||||||
|
GL11.glVertex3d(0, 1, 0);
|
||||||
|
}
|
||||||
|
GL11.glEnd();
|
||||||
|
GL11.glLineWidth(1);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue