2018-04-26 23:46:32 +02:00
|
|
|
package com.minelittlepony.render;
|
2015-11-17 06:09:04 +01:00
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
import net.minecraft.client.model.ModelBox;
|
2015-08-02 00:36:33 +02:00
|
|
|
import net.minecraft.client.model.PositionTextureVertex;
|
|
|
|
import net.minecraft.client.model.TexturedQuad;
|
2017-06-13 05:55:50 +02:00
|
|
|
import net.minecraft.client.renderer.BufferBuilder;
|
|
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2018-04-25 16:40:47 +02:00
|
|
|
public class HornGlow extends ModelBox {
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2018-04-25 12:59:18 +02:00
|
|
|
private final float alpha;
|
2018-04-26 23:46:32 +02:00
|
|
|
|
2018-04-25 12:59:18 +02:00
|
|
|
private final HornGlowRenderer parent;
|
2018-04-26 23:46:32 +02:00
|
|
|
|
2015-08-02 00:36:33 +02:00
|
|
|
private TexturedQuad[] quadList;
|
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
public HornGlow(HornGlowRenderer parent, int texU, int texV, float x, float y, float z, int w, int h, int d, float scale, float alpha) {
|
|
|
|
super(parent, texU, texV, x, y, z, w, h, d, scale);
|
2018-04-26 23:46:32 +02:00
|
|
|
|
2018-04-25 12:59:18 +02:00
|
|
|
this.parent = parent;
|
|
|
|
this.alpha = alpha;
|
2018-04-26 23:46:32 +02:00
|
|
|
|
2015-08-02 00:36:33 +02:00
|
|
|
this.quadList = new TexturedQuad[6];
|
2018-04-26 23:46:32 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
float x2 = x + w + scale;
|
|
|
|
float y2 = y + h + scale;
|
|
|
|
float z2 = z + d + scale;
|
2018-04-26 23:46:32 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
x -= scale;
|
|
|
|
y -= scale;
|
|
|
|
z -= scale;
|
2018-04-26 23:46:32 +02:00
|
|
|
|
2018-04-25 12:59:18 +02:00
|
|
|
if (parent.mirror) {
|
2018-04-26 23:46:32 +02:00
|
|
|
float tmp = x2;
|
2018-04-26 16:01:31 +02:00
|
|
|
x2 = x;
|
2018-04-26 23:46:32 +02:00
|
|
|
x = tmp;
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
float halfpar4 = x + w * 0.05F;
|
|
|
|
float halfpar6 = z + d * 0.05F;
|
|
|
|
float halfvar11 = x + w * 0.95F;
|
|
|
|
float halfvar13 = z + d * 0.95F;
|
2018-04-26 23:46:32 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
PositionTextureVertex p7 = new PositionTextureVertex(halfpar4, y, halfpar6, 0, 0);
|
|
|
|
PositionTextureVertex p0 = new PositionTextureVertex(halfvar11, y, halfpar6, 0, 8);
|
|
|
|
PositionTextureVertex p1 = new PositionTextureVertex(x2, y2, z, 8, 8);
|
|
|
|
PositionTextureVertex p2 = new PositionTextureVertex(x, y2, z, 8, 0);
|
|
|
|
PositionTextureVertex p3 = new PositionTextureVertex(halfpar4, y, halfvar13, 0, 0);
|
|
|
|
PositionTextureVertex p4 = new PositionTextureVertex(halfvar11, y, halfvar13, 0, 8);
|
|
|
|
PositionTextureVertex p5 = new PositionTextureVertex(x2, y2, z2, 8, 8);
|
|
|
|
PositionTextureVertex p6 = new PositionTextureVertex(x, y2, z2, 8, 0);
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
this.quadList[0] = new TexturedQuad(new PositionTextureVertex[]{p4, p0, p1, p5}, texU + d + w, texV + d, texU + d + w + d, texV + d + h, parent.textureWidth, parent.textureHeight);
|
|
|
|
this.quadList[1] = new TexturedQuad(new PositionTextureVertex[]{p7, p3, p6, p2}, texU, texV + d, texU + d, texV + d + h, parent.textureWidth, parent.textureHeight);
|
|
|
|
this.quadList[2] = new TexturedQuad(new PositionTextureVertex[]{p4, p3, p7, p0}, texU + d, texV, texU + d + w, texV + d, parent.textureWidth, parent.textureHeight);
|
|
|
|
this.quadList[3] = new TexturedQuad(new PositionTextureVertex[]{p1, p2, p6, p5}, texU + d + w, texV + d, texU + d + w + w, texV, parent.textureWidth, parent.textureHeight);
|
|
|
|
this.quadList[4] = new TexturedQuad(new PositionTextureVertex[]{p0, p7, p2, p1}, texU + d, texV + d, texU + d + w, texV + d + h, parent.textureWidth, parent.textureHeight);
|
|
|
|
this.quadList[5] = new TexturedQuad(new PositionTextureVertex[]{p3, p4, p5, p6}, texU + d + w + d, texV + d, texU + d + w + d + w, texV + d + h, parent.textureWidth, parent.textureHeight);
|
2018-04-26 23:46:32 +02:00
|
|
|
|
2018-04-25 12:59:18 +02:00
|
|
|
if (parent.mirror) {
|
2018-04-26 16:01:31 +02:00
|
|
|
for (TexturedQuad i : quadList) {
|
|
|
|
i.flipFace();
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
@Override
|
2018-04-26 16:01:31 +02:00
|
|
|
public void render(@Nonnull BufferBuilder buffer, float scale) {
|
2018-04-25 12:59:18 +02:00
|
|
|
parent.applyTint(alpha);
|
2018-04-26 23:46:32 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
for (TexturedQuad i : quadList) {
|
|
|
|
i.draw(buffer, scale);
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|