2016-12-12 01:28:47 +00:00
|
|
|
package WayofTime.bloodmagic.client.render.block;
|
2016-01-15 20:06:03 +00:00
|
|
|
|
2017-08-15 03:53:42 +00:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
2016-03-01 07:20:57 +00:00
|
|
|
import WayofTime.bloodmagic.ConfigHandler;
|
|
|
|
import WayofTime.bloodmagic.api.iface.INodeRenderer;
|
2016-03-17 20:00:44 +00:00
|
|
|
import WayofTime.bloodmagic.client.helper.ShaderHelper;
|
|
|
|
import WayofTime.bloodmagic.tile.routing.TileRoutingNode;
|
2016-03-01 07:20:57 +00:00
|
|
|
import net.minecraft.client.Minecraft;
|
2017-08-16 03:21:54 +00:00
|
|
|
import net.minecraft.client.renderer.BufferBuilder;
|
2016-01-15 20:44:20 +00:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2016-01-15 20:06:03 +00:00
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
|
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-03-17 20:00:44 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.MathHelper;
|
2016-01-15 20:06:03 +00:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2016-03-17 20:00:44 +00:00
|
|
|
import java.util.List;
|
2016-01-15 20:06:03 +00:00
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public class RenderItemRoutingNode extends TileEntitySpecialRenderer<TileRoutingNode> {
|
2017-08-15 03:53:42 +00:00
|
|
|
private static final ResourceLocation beamTexture = new ResourceLocation(BloodMagic.MODID, "textures/entities/nodeBeam.png");
|
2016-03-01 07:20:57 +00:00
|
|
|
private static final Minecraft mc = Minecraft.getMinecraft();
|
2016-01-15 20:06:03 +00:00
|
|
|
|
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public void render(TileRoutingNode tileNode, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
|
2017-08-20 01:56:50 +00:00
|
|
|
if (mc.player.getHeldItemMainhand().getItem() instanceof INodeRenderer || ConfigHandler.client.alwaysRenderRoutingLines) {
|
2016-03-01 07:20:57 +00:00
|
|
|
List<BlockPos> connectionList = tileNode.getConnected();
|
2017-08-16 04:30:48 +00:00
|
|
|
for (BlockPos wantedPos : connectionList) {
|
2016-03-01 07:20:57 +00:00
|
|
|
BlockPos offsetPos = wantedPos.subtract(tileNode.getPos());
|
|
|
|
|
|
|
|
//The beam renders towards the east by default.
|
|
|
|
|
|
|
|
int xd = offsetPos.getX();
|
|
|
|
int yd = offsetPos.getY();
|
|
|
|
int zd = offsetPos.getZ();
|
|
|
|
double distance = Math.sqrt(xd * xd + yd * yd + zd * zd);
|
2017-01-02 08:10:28 +00:00
|
|
|
double subLength = MathHelper.sqrt(xd * xd + zd * zd);
|
2016-03-01 07:20:57 +00:00
|
|
|
float rotYaw = -((float) (Math.atan2(zd, xd) * 180.0D / Math.PI));
|
|
|
|
float rotPitch = ((float) (Math.atan2(yd, subLength) * 180.0D / Math.PI));
|
|
|
|
|
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
float f1 = 1.0f;
|
|
|
|
Tessellator tessellator = Tessellator.getInstance();
|
2017-08-16 03:21:54 +00:00
|
|
|
BufferBuilder wr = tessellator.getBuffer();
|
2016-03-01 07:20:57 +00:00
|
|
|
this.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);
|
|
|
|
GlStateManager.disableLighting();
|
|
|
|
GlStateManager.disableCull();
|
|
|
|
float f2 = 0;
|
2017-01-02 08:10:28 +00:00
|
|
|
float f3 = -f2 * 0.2F - (float) MathHelper.floor(-f2 * 0.1F);
|
2016-03-01 07:20:57 +00:00
|
|
|
GlStateManager.enableBlend();
|
|
|
|
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
|
|
double width = 0.06;
|
|
|
|
|
|
|
|
float test = (tileNode.getWorld().getTotalWorldTime() + partialTicks) / 5f;
|
|
|
|
|
|
|
|
double d18 = -width / 2;
|
|
|
|
double d19 = -width / 2;
|
|
|
|
double d20 = width / 2;
|
|
|
|
double d21 = -width / 2;
|
|
|
|
double d22 = -width / 2;
|
|
|
|
double d23 = width / 2;
|
|
|
|
double d24 = width / 2;
|
|
|
|
double d25 = width / 2;
|
2017-08-15 03:53:42 +00:00
|
|
|
double d26 = distance * f1;
|
2016-03-01 07:20:57 +00:00
|
|
|
double d27 = 0.0D;
|
|
|
|
double d28 = 1.0D;
|
|
|
|
double d29 = (double) (f3) + test;
|
2017-08-15 03:53:42 +00:00
|
|
|
double d30 = distance * f1 + d29;
|
2016-03-01 07:20:57 +00:00
|
|
|
|
|
|
|
GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5);
|
|
|
|
|
|
|
|
GlStateManager.rotate(rotYaw, 0, 1, 0);
|
|
|
|
GlStateManager.rotate(rotPitch, 0, 0, 1);
|
2016-01-15 20:06:03 +00:00
|
|
|
|
|
|
|
// tessellator.setBrightness(240);
|
|
|
|
// float s = 1F / 16F;
|
2016-03-01 07:20:57 +00:00
|
|
|
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
2016-01-15 20:06:03 +00:00
|
|
|
// tessellator.setColorRGBA(255, 255, 255, 100);
|
2016-03-01 07:20:57 +00:00
|
|
|
wr.pos(d26, d18, d19).tex(d28, d30).endVertex();
|
|
|
|
wr.pos(0, d18, d19).tex(d28, d29).endVertex();
|
|
|
|
wr.pos(0, d20, d21).tex(d27, d29).endVertex();
|
|
|
|
wr.pos(d26, d20, d21).tex(d27, d30).endVertex();
|
|
|
|
wr.pos(d26, d24, d25).tex(d28, d30).endVertex();
|
|
|
|
wr.pos(0, d24, d25).tex(d28, d29).endVertex();
|
|
|
|
wr.pos(0, d22, d23).tex(d27, d29).endVertex();
|
|
|
|
wr.pos(d26, d22, d23).tex(d27, d30).endVertex();
|
|
|
|
wr.pos(d26, d20, d21).tex(d28, d30).endVertex();
|
|
|
|
wr.pos(0, d20, d21).tex(d28, d29).endVertex();
|
|
|
|
wr.pos(0, d24, d25).tex(d27, d29).endVertex();
|
|
|
|
wr.pos(d26, d24, d25).tex(d27, d30).endVertex();
|
|
|
|
wr.pos(d26, d22, d23).tex(d28, d30).endVertex();
|
|
|
|
wr.pos(0, d22, d23).tex(d28, d29).endVertex();
|
|
|
|
wr.pos(0, d18, d19).tex(d27, d29).endVertex();
|
|
|
|
wr.pos(d26, d18, d19).tex(d27, d30).endVertex();
|
|
|
|
|
|
|
|
ShaderHelper.useShader(ShaderHelper.psiBar, (int) tileNode.getWorld().getTotalWorldTime());
|
|
|
|
tessellator.draw();
|
|
|
|
ShaderHelper.releaseShader();
|
|
|
|
|
|
|
|
GlStateManager.enableLighting();
|
|
|
|
GlStateManager.enableTexture2D();
|
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
2016-01-15 20:06:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|