Buckets & entity enhancements, cleanup

This commit is contained in:
paulevsGitch 2021-04-19 21:22:11 +03:00
parent 00fd2b6199
commit 3ec2edd6d5
234 changed files with 1988 additions and 1643 deletions

View file

@ -12,6 +12,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix4f;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.Util;

View file

@ -6,6 +6,7 @@ import java.util.Set;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.GuiComponent;

View file

@ -2,6 +2,7 @@ package ru.betterend.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.components.ImageButton;

View file

@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import com.mojang.math.Vector3f;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.OverlayTexture;

View file

@ -1,94 +1,95 @@
package ru.betterend.client.render;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
public class EndCrystalRenderer {
private static final ResourceLocation CRYSTAL_TEXTURE = new ResourceLocation("textures/entity/end_crystal/end_crystal.png");
private static final ResourceLocation CRYSTAL_BEAM_TEXTURE = new ResourceLocation("textures/entity/end_crystal/end_crystal_beam.png");
private static final RenderType CRYSTAL_BEAM_LAYER;
private static final RenderType 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, PoseStack matrices, MultiBufferSource vertexConsumerProvider, int light) {
float k = (float) AGE_CYCLE / maxAge;
float rotation = (age * k + tickDelta) * 3.0F;
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(END_CRYSTAL);
matrices.pushPose();
matrices.scale(0.8F, 0.8F, 0.8F);
matrices.translate(0.0D, -0.5D, 0.0D);
matrices.mulPose(Vector3f.YP.rotationDegrees(rotation));
matrices.translate(0.0D, 0.8F, 0.0D);
matrices.mulPose(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY);
matrices.scale(0.875F, 0.875F, 0.875F);
matrices.mulPose(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
matrices.mulPose(Vector3f.YP.rotationDegrees(rotation));
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY);
matrices.scale(0.875F, 0.875F, 0.875F);
matrices.mulPose(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
matrices.mulPose(Vector3f.YP.rotationDegrees(rotation));
CORE.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY);
matrices.popPose();
}
public static void renderBeam(BlockPos start, BlockPos end, float tickDelta, int age, PoseStack matrices, MultiBufferSource 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 = Mth.sqrt(dx * dx + dz * dz);
float g = Mth.sqrt(dx * dx + dy * dy + dz * dz);
matrices.pushPose();
matrices.translate(0.0D, 2.0D, 0.0D);
matrices.mulPose(Vector3f.YP.rotation((float)(-Math.atan2((double) dz, (double) dx)) - 1.5707964F));
matrices.mulPose(Vector3f.XP.rotation((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 = Mth.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;
PoseStack.Pose entry = matrices.last();
Matrix4f matrix4f = entry.pose();
Matrix3f matrix3f = entry.normal();
for(int n = 1; n <= 8; ++n) {
float o = Mth.sin((float) n * 6.2831855F / 8.0F) * 0.75F;
float p = Mth.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).uv(m, h).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).uv(m, i).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).uv(q, i).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).uv(q, h).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
k = o;
l = p;
m = q;
}
matrices.popPose();
}
static {
END_CRYSTAL = RenderType.entityCutoutNoCull(CRYSTAL_TEXTURE);
CRYSTAL_BEAM_LAYER = RenderType.entitySmoothCutout(CRYSTAL_BEAM_TEXTURE);
SINE_45_DEGREES = (float) Math.sin(0.7853981633974483D);
FRAME = new ModelPart(64, 32, 0, 0);
FRAME.addBox(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
CORE = new ModelPart(64, 32, 32, 0);
CORE.addBox(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
}
}
package ru.betterend.client.render;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
public class EndCrystalRenderer {
private static final ResourceLocation CRYSTAL_TEXTURE = new ResourceLocation("textures/entity/end_crystal/end_crystal.png");
private static final ResourceLocation CRYSTAL_BEAM_TEXTURE = new ResourceLocation("textures/entity/end_crystal/end_crystal_beam.png");
private static final RenderType CRYSTAL_BEAM_LAYER;
private static final RenderType 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, PoseStack matrices, MultiBufferSource vertexConsumerProvider, int light) {
float k = (float) AGE_CYCLE / maxAge;
float rotation = (age * k + tickDelta) * 3.0F;
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(END_CRYSTAL);
matrices.pushPose();
matrices.scale(0.8F, 0.8F, 0.8F);
matrices.translate(0.0D, -0.5D, 0.0D);
matrices.mulPose(Vector3f.YP.rotationDegrees(rotation));
matrices.translate(0.0D, 0.8F, 0.0D);
matrices.mulPose(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY);
matrices.scale(0.875F, 0.875F, 0.875F);
matrices.mulPose(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
matrices.mulPose(Vector3f.YP.rotationDegrees(rotation));
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY);
matrices.scale(0.875F, 0.875F, 0.875F);
matrices.mulPose(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
matrices.mulPose(Vector3f.YP.rotationDegrees(rotation));
CORE.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY);
matrices.popPose();
}
public static void renderBeam(BlockPos start, BlockPos end, float tickDelta, int age, PoseStack matrices, MultiBufferSource 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 = Mth.sqrt(dx * dx + dz * dz);
float g = Mth.sqrt(dx * dx + dy * dy + dz * dz);
matrices.pushPose();
matrices.translate(0.0D, 2.0D, 0.0D);
matrices.mulPose(Vector3f.YP.rotation((float)(-Math.atan2((double) dz, (double) dx)) - 1.5707964F));
matrices.mulPose(Vector3f.XP.rotation((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 = Mth.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;
PoseStack.Pose entry = matrices.last();
Matrix4f matrix4f = entry.pose();
Matrix3f matrix3f = entry.normal();
for(int n = 1; n <= 8; ++n) {
float o = Mth.sin((float) n * 6.2831855F / 8.0F) * 0.75F;
float p = Mth.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).uv(m, h).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).uv(m, i).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).uv(q, i).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).uv(q, h).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
k = o;
l = p;
m = q;
}
matrices.popPose();
}
static {
END_CRYSTAL = RenderType.entityCutoutNoCull(CRYSTAL_TEXTURE);
CRYSTAL_BEAM_LAYER = RenderType.entitySmoothCutout(CRYSTAL_BEAM_TEXTURE);
SINE_45_DEGREES = (float) Math.sin(0.7853981633974483D);
FRAME = new ModelPart(64, 32, 0, 0);
FRAME.addBox(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
CORE = new ModelPart(64, 32, 32, 0);
CORE.addBox(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
}
}

View file

@ -1,69 +1,70 @@
package ru.betterend.client.render;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.Vec3i;
import net.minecraft.util.Mth;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.AuroraCrystalBlock;
import ru.betterend.util.ColorUtil;
import ru.betterend.util.MHelper;
public class EternalCrystalRenderer {
private static final RenderType RENDER_LAYER;
private static final ModelPart[] SHARDS;
private static final ModelPart CORE;
public static void render(int age, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumerProvider, int light) {
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RENDER_LAYER);
float[] colors = colors(age);
float rotation = (age + tickDelta) / 25.0F + 6.0F;
matrices.pushPose();
matrices.scale(0.6F, 0.6F, 0.6F);
matrices.mulPose(Vector3f.YP.rotation(rotation));
CORE.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, colors[0], colors[1], colors[2], colors[3]);
for (int i = 0; i < 4; i++) {
matrices.pushPose();
float offset = Mth.sin(rotation * 2 + i) * 0.15F;
matrices.translate(0, offset, 0);
SHARDS[i].render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, colors[0], colors[1], colors[2], colors[3]);
matrices.popPose();
}
matrices.popPose();
}
public static float[] colors(int age) {
double delta = age * 0.01;
int index = MHelper.floor(delta);
int index2 = (index + 1) & 3;
delta -= index;
index &= 3;
Vec3i color1 = AuroraCrystalBlock.COLORS[index];
Vec3i color2 = AuroraCrystalBlock.COLORS[index2];
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
return ColorUtil.toFloatArray(MHelper.color(r, g, b));
}
static {
RENDER_LAYER = RenderType.beaconBeam(BetterEnd.makeID("textures/entity/eternal_crystal.png"), true);
SHARDS = new ModelPart[4];
SHARDS[0] = new ModelPart(16, 16, 2, 4).addBox(-5.0F, 1.0F, -3.0F, 2.0F, 8.0F, 2.0F);
SHARDS[1] = new ModelPart(16, 16, 2, 4).addBox(3.0F, -1.0F, -1.0F, 2.0F, 8.0F, 2.0F);
SHARDS[2] = new ModelPart(16, 16, 2, 4).addBox(-1.0F, 0.0F, -5.0F, 2.0F, 4.0F, 2.0F);
SHARDS[3] = new ModelPart(16, 16, 2, 4).addBox(0.0F, 3.0F, 4.0F, 2.0F, 6.0F, 2.0F);
CORE = new ModelPart(16, 16, 0, 0);
CORE.addBox(-2.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F);
}
}
package ru.betterend.client.render;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.Vec3i;
import net.minecraft.util.Mth;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.AuroraCrystalBlock;
import ru.betterend.util.ColorUtil;
import ru.betterend.util.MHelper;
public class EternalCrystalRenderer {
private static final RenderType RENDER_LAYER;
private static final ModelPart[] SHARDS;
private static final ModelPart CORE;
public static void render(int age, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumerProvider, int light) {
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RENDER_LAYER);
float[] colors = colors(age);
float rotation = (age + tickDelta) / 25.0F + 6.0F;
matrices.pushPose();
matrices.scale(0.6F, 0.6F, 0.6F);
matrices.mulPose(Vector3f.YP.rotation(rotation));
CORE.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, colors[0], colors[1], colors[2], colors[3]);
for (int i = 0; i < 4; i++) {
matrices.pushPose();
float offset = Mth.sin(rotation * 2 + i) * 0.15F;
matrices.translate(0, offset, 0);
SHARDS[i].render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, colors[0], colors[1], colors[2], colors[3]);
matrices.popPose();
}
matrices.popPose();
}
public static float[] colors(int age) {
double delta = age * 0.01;
int index = MHelper.floor(delta);
int index2 = (index + 1) & 3;
delta -= index;
index &= 3;
Vec3i color1 = AuroraCrystalBlock.COLORS[index];
Vec3i color2 = AuroraCrystalBlock.COLORS[index2];
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
return ColorUtil.toFloatArray(MHelper.color(r, g, b));
}
static {
RENDER_LAYER = RenderType.beaconBeam(BetterEnd.makeID("textures/entity/eternal_crystal.png"), true);
SHARDS = new ModelPart[4];
SHARDS[0] = new ModelPart(16, 16, 2, 4).addBox(-5.0F, 1.0F, -3.0F, 2.0F, 8.0F, 2.0F);
SHARDS[1] = new ModelPart(16, 16, 2, 4).addBox(3.0F, -1.0F, -1.0F, 2.0F, 8.0F, 2.0F);
SHARDS[2] = new ModelPart(16, 16, 2, 4).addBox(-1.0F, 0.0F, -5.0F, 2.0F, 4.0F, 2.0F);
SHARDS[3] = new ModelPart(16, 16, 2, 4).addBox(0.0F, 3.0F, 4.0F, 2.0F, 6.0F, 2.0F);
CORE = new ModelPart(16, 16, 0, 0);
CORE.addBox(-2.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F);
}
}