WIP: eternal crystal render
This commit is contained in:
parent
d9a60fc7f2
commit
0dcc003333
4 changed files with 138 additions and 94 deletions
|
@ -23,7 +23,10 @@ import ru.betterend.blocks.EternalPedestal;
|
|||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.client.render.BeamRenderer;
|
||||
import ru.betterend.client.render.EndCrystalRenderer;
|
||||
import ru.betterend.client.render.EternalCrystalRenderer;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class PedestalItemRenderer<T extends PedestalBlockEntity> extends BlockEntityRenderer<T> {
|
||||
|
@ -63,6 +66,8 @@ public class PedestalItemRenderer<T extends PedestalBlockEntity> extends BlockEn
|
|||
}
|
||||
if (activeItem.getItem() == Items.END_CRYSTAL) {
|
||||
EndCrystalRenderer.render(blockEntity.getAge(), blockEntity.getMaxAge(), tickDelta, matrices, vertexConsumers, light);
|
||||
} else if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
EternalCrystalRenderer.render(blockEntity.getAge(), tickDelta, matrices, vertexConsumers, light);
|
||||
} else {
|
||||
float rotation = (blockEntity.getAge() + tickDelta) / 25.0F + 6.0F;
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(rotation));
|
||||
|
|
|
@ -1,94 +1,94 @@
|
|||
package ru.betterend.blocks.entities.render;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Matrix3f;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
|
||||
public class EndCrystalRenderer {
|
||||
private static final Identifier CRYSTAL_TEXTURE = new Identifier("textures/entity/end_crystal/end_crystal.png");
|
||||
private static final Identifier CRYSTAL_BEAM_TEXTURE = new Identifier("textures/entity/end_crystal/end_crystal_beam.png");
|
||||
private static final RenderLayer CRYSTAL_BEAM_LAYER;
|
||||
private static final RenderLayer END_CRYSTAL;
|
||||
private static final ModelPart CORE;
|
||||
private static final ModelPart FRAME;
|
||||
private static final int AGE_CYCLE = 240;
|
||||
private static final float SINE_45_DEGREES;
|
||||
|
||||
public static void render(int age, int maxAge, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light) {
|
||||
float k = (float) AGE_CYCLE / maxAge;
|
||||
float rotation = (age * k + tickDelta) * 3.0F;
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(END_CRYSTAL);
|
||||
matrices.push();
|
||||
matrices.scale(0.8F, 0.8F, 0.8F);
|
||||
matrices.translate(0.0D, -0.5D, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
matrices.translate(0.0D, 0.8F, 0.0D);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.scale(0.875F, 0.875F, 0.875F);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.scale(0.875F, 0.875F, 0.875F);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
CORE.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
public static void renderBeam(BlockPos start, BlockPos end, float tickDelta, int age, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
|
||||
float dx = start.getX() - end.getX() + 1.0F;
|
||||
float dy = start.getY() - end.getY() + 1.0F;
|
||||
float dz = start.getZ() - end.getZ() + 1.0F;
|
||||
float f = MathHelper.sqrt(dx * dx + dz * dz);
|
||||
float g = MathHelper.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
matrices.push();
|
||||
matrices.translate(0.0D, 2.0D, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion((float)(-Math.atan2((double)dz, (double)dx)) - 1.5707964F));
|
||||
matrices.multiply(Vector3f.POSITIVE_X.getRadialQuaternion((float)(-Math.atan2((double)f, (double)dy)) - 1.5707964F));
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(CRYSTAL_BEAM_LAYER);
|
||||
float h = 0.0F - ((float)age + tickDelta) * 0.01F;
|
||||
float i = MathHelper.sqrt(dx * dx + dy * dy + dz * dz) / 32.0F - ((float)age + tickDelta) * 0.01F;
|
||||
float k = 0.0F;
|
||||
float l = 0.75F;
|
||||
float m = 0.0F;
|
||||
MatrixStack.Entry entry = matrices.peek();
|
||||
Matrix4f matrix4f = entry.getModel();
|
||||
Matrix3f matrix3f = entry.getNormal();
|
||||
|
||||
for(int n = 1; n <= 8; ++n) {
|
||||
float o = MathHelper.sin((float)n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float p = MathHelper.cos((float)n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float q = (float)n / 8.0F;
|
||||
vertexConsumer.vertex(matrix4f, k * 0.2F, l * 0.2F, 0.0F).color(0, 0, 0, 255).texture(m, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).texture(m, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).texture(q, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).texture(q, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
k = o;
|
||||
l = p;
|
||||
m = q;
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
static {
|
||||
END_CRYSTAL = RenderLayer.getEntityCutoutNoCull(CRYSTAL_TEXTURE);
|
||||
CRYSTAL_BEAM_LAYER = RenderLayer.getEntitySmoothCutout(CRYSTAL_BEAM_TEXTURE);
|
||||
SINE_45_DEGREES = (float) Math.sin(0.7853981633974483D);
|
||||
FRAME = new ModelPart(64, 32, 0, 0);
|
||||
FRAME.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
CORE = new ModelPart(64, 32, 32, 0);
|
||||
CORE.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
}
|
||||
}
|
||||
package ru.betterend.client.render;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Matrix3f;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
|
||||
public class EndCrystalRenderer {
|
||||
private static final Identifier CRYSTAL_TEXTURE = new Identifier("textures/entity/end_crystal/end_crystal.png");
|
||||
private static final Identifier CRYSTAL_BEAM_TEXTURE = new Identifier("textures/entity/end_crystal/end_crystal_beam.png");
|
||||
private static final RenderLayer CRYSTAL_BEAM_LAYER;
|
||||
private static final RenderLayer END_CRYSTAL;
|
||||
private static final ModelPart CORE;
|
||||
private static final ModelPart FRAME;
|
||||
private static final int AGE_CYCLE = 240;
|
||||
private static final float SINE_45_DEGREES;
|
||||
|
||||
public static void render(int age, int maxAge, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light) {
|
||||
float k = (float) AGE_CYCLE / maxAge;
|
||||
float rotation = (age * k + tickDelta) * 3.0F;
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(END_CRYSTAL);
|
||||
matrices.push();
|
||||
matrices.scale(0.8F, 0.8F, 0.8F);
|
||||
matrices.translate(0.0D, -0.5D, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
matrices.translate(0.0D, 0.8F, 0.0D);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.scale(0.875F, 0.875F, 0.875F);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.scale(0.875F, 0.875F, 0.875F);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
CORE.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
public static void renderBeam(BlockPos start, BlockPos end, float tickDelta, int age, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
|
||||
float dx = start.getX() - end.getX() + 1.0F;
|
||||
float dy = start.getY() - end.getY() + 1.0F;
|
||||
float dz = start.getZ() - end.getZ() + 1.0F;
|
||||
float f = MathHelper.sqrt(dx * dx + dz * dz);
|
||||
float g = MathHelper.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
matrices.push();
|
||||
matrices.translate(0.0D, 2.0D, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion((float)(-Math.atan2((double) dz, (double) dx)) - 1.5707964F));
|
||||
matrices.multiply(Vector3f.POSITIVE_X.getRadialQuaternion((float)(-Math.atan2((double) f, (double) dy)) - 1.5707964F));
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(CRYSTAL_BEAM_LAYER);
|
||||
float h = 0.0F - ((float) age + tickDelta) * 0.01F;
|
||||
float i = MathHelper.sqrt(dx * dx + dy * dy + dz * dz) / 32.0F - ((float) age + tickDelta) * 0.01F;
|
||||
float k = 0.0F;
|
||||
float l = 0.75F;
|
||||
float m = 0.0F;
|
||||
MatrixStack.Entry entry = matrices.peek();
|
||||
Matrix4f matrix4f = entry.getModel();
|
||||
Matrix3f matrix3f = entry.getNormal();
|
||||
|
||||
for(int n = 1; n <= 8; ++n) {
|
||||
float o = MathHelper.sin((float) n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float p = MathHelper.cos((float) n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float q = (float) n / 8.0F;
|
||||
vertexConsumer.vertex(matrix4f, k * 0.2F, l * 0.2F, 0.0F).color(0, 0, 0, 255).texture(m, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).texture(m, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).texture(q, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).texture(q, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
k = o;
|
||||
l = p;
|
||||
m = q;
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
static {
|
||||
END_CRYSTAL = RenderLayer.getEntityCutoutNoCull(CRYSTAL_TEXTURE);
|
||||
CRYSTAL_BEAM_LAYER = RenderLayer.getEntitySmoothCutout(CRYSTAL_BEAM_TEXTURE);
|
||||
SINE_45_DEGREES = (float) Math.sin(0.7853981633974483D);
|
||||
FRAME = new ModelPart(64, 32, 0, 0);
|
||||
FRAME.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
CORE = new ModelPart(64, 32, 32, 0);
|
||||
CORE.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package ru.betterend.client.render;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
public class EternalCrystalRenderer {
|
||||
private static final Identifier CRYSTAL_TEXTURE = BetterEnd.makeID("textures/entity/eternal_crystal.png");
|
||||
private static final RenderLayer RENDER_LAYER;
|
||||
private static final ModelPart CORE;
|
||||
|
||||
public static void render(int age, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light) {
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RENDER_LAYER);
|
||||
float rotation = (age + tickDelta) / 25.0F + 6.0F;
|
||||
float altitude = MathHelper.sin((age + tickDelta) / 10.0F) * 0.1F + 0.1F;
|
||||
matrices.push();
|
||||
matrices.scale(0.6F, 0.6F, 0.6F);
|
||||
matrices.translate(0.0D, altitude / 2.0D, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(rotation));
|
||||
matrices.push();
|
||||
matrices.translate(-0.125D, -0.1D, -0.125D);
|
||||
CORE.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.pop();
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
static {
|
||||
RENDER_LAYER = RenderLayer.getEntityTranslucent(CRYSTAL_TEXTURE);
|
||||
CORE = new ModelPart(16, 16, 0, 0);
|
||||
CORE.addCuboid(0.0F, 0.0F, 0.0F, 4.0F, 12.0F, 4.0F);
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 338 B |
Loading…
Add table
Add a link
Reference in a new issue