Code style changes, entities fixes
This commit is contained in:
parent
9d604b2d25
commit
44962e18b6
377 changed files with 5038 additions and 4914 deletions
|
@ -2,7 +2,6 @@ package ru.betterend.client.render;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.client.model.geom.EntityModelSet;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
|
@ -37,7 +36,8 @@ public class ArmoredElytraLayer<T extends LivingEntity, M extends EntityModel<T>
|
|||
AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) livingEntity;
|
||||
if (abstractClientPlayer.isElytraLoaded() && abstractClientPlayer.getElytraTextureLocation() != null) {
|
||||
wingsTexture = abstractClientPlayer.getElytraTextureLocation();
|
||||
} else if (abstractClientPlayer.isCapeLoaded() && abstractClientPlayer.getCloakTextureLocation() != null && abstractClientPlayer.isModelPartShown(PlayerModelPart.CAPE)) {
|
||||
}
|
||||
else if (abstractClientPlayer.isCapeLoaded() && abstractClientPlayer.getCloakTextureLocation() != null && abstractClientPlayer.isModelPartShown(PlayerModelPart.CAPE)) {
|
||||
wingsTexture = abstractClientPlayer.getCloakTextureLocation();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ 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;
|
||||
|
@ -14,26 +13,26 @@ import net.minecraft.util.Mth;
|
|||
|
||||
public class BeamRenderer {
|
||||
private static final ResourceLocation BEAM_TEXTURE = new ResourceLocation("textures/entity/end_gateway_beam.png");
|
||||
|
||||
|
||||
public static void renderLightBeam(PoseStack matrices, MultiBufferSource vertexConsumers, int age, float tick, int minY, int maxY, float[] colors, float alpha, float beamIn, float beamOut) {
|
||||
float red = colors[0];
|
||||
float green = colors[1];
|
||||
float blue = colors[2];
|
||||
|
||||
|
||||
int maxBY = minY + maxY;
|
||||
float delta = maxY < 0 ? tick : -tick;
|
||||
float fractDelta = Mth.frac(delta * 0.2F - (float) Mth.floor(delta * 0.1F));
|
||||
float fractDelta = Mth.frac(delta * 0.2F - (float) Mth.floor(delta * 0.1F));
|
||||
float xIn = -beamIn;
|
||||
float minV = Mth.clamp(fractDelta - 1.0F, 0.0F, 1.0F);
|
||||
float maxV = (float) maxY * (0.5F / beamIn) + minV;
|
||||
float rotation = (age + tick) / 25.0F + 6.0F;
|
||||
|
||||
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderType.beaconBeam(BEAM_TEXTURE, true));
|
||||
|
||||
|
||||
matrices.pushPose();
|
||||
matrices.mulPose(Vector3f.YP.rotation(-rotation));
|
||||
renderBeam(matrices, vertexConsumer, red, green, blue, alpha, minY, maxBY, beamIn, 0.0F, 0.0F, beamIn, 0.0F, xIn, xIn, 0.0F, 0.0F, 1.0F, minV, maxV);
|
||||
|
||||
|
||||
float xOut = -beamOut;
|
||||
maxV = (float) maxY + minV;
|
||||
renderBeam(matrices, vertexConsumer, red, green, blue, alpha, minY, maxBY, xOut, xOut, beamOut, xOut, xOut, beamOut, beamOut, beamOut, 0.0F, 1.0F, minV, maxV);
|
||||
|
@ -43,7 +42,7 @@ public class BeamRenderer {
|
|||
private static void renderBeam(PoseStack matrices, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, int minY, int maxY, float x1, float d1, float x2, float d2, float x3, float d3, float x4, float d4, float minU, float maxU, float minV, float maxV) {
|
||||
PoseStack.Pose entry = matrices.last();
|
||||
Matrix4f matrix4f = entry.pose();
|
||||
Matrix3f matrix3f = entry.normal();
|
||||
Matrix3f matrix3f = entry.normal();
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x1, d1, x2, d2, minU, maxU, minV, maxV);
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x4, d4, x3, d3, minU, maxU, minV, maxV);
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x2, d2, x4, d4, minU, maxU, minV, maxV);
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.model.geom.PartPose;
|
||||
import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
||||
|
@ -24,7 +23,7 @@ public class EndCrystalRenderer {
|
|||
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;
|
||||
|
@ -51,18 +50,18 @@ public class EndCrystalRenderer {
|
|||
MeshDefinition modelData = new MeshDefinition();
|
||||
PartDefinition modelPartData = modelData.getRoot();
|
||||
modelPartData.addOrReplaceChild("FRAME", CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.addBox(-4.0f, -4.0f, -4.0f, 8.0f, 8.0f, 8.0f),
|
||||
.texOffs(0, 0)
|
||||
.addBox(-4.0f, -4.0f, -4.0f, 8.0f, 8.0f, 8.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
modelPartData.addOrReplaceChild("CORE", CubeListBuilder.create()
|
||||
.texOffs(32, 0)
|
||||
.texOffs(32, 0)
|
||||
.addBox(-4.0f, -4.0f, -4.0f, 8.0f, 8.0f, 8.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
return LayerDefinition.create(modelData, 64, 32);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
END_CRYSTAL = RenderType.entityCutoutNoCull(CRYSTAL_TEXTURE);
|
||||
RenderType.entitySmoothCutout(CRYSTAL_BEAM_TEXTURE);
|
||||
|
|
|
@ -3,7 +3,6 @@ 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.model.geom.PartPose;
|
||||
import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
||||
|
@ -24,7 +23,7 @@ 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);
|
||||
|
@ -33,7 +32,7 @@ public class EternalCrystalRenderer {
|
|||
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;
|
||||
|
@ -41,24 +40,24 @@ public class EternalCrystalRenderer {
|
|||
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(ColorUtil.color(r, g, b));
|
||||
}
|
||||
|
||||
|
@ -66,33 +65,33 @@ public class EternalCrystalRenderer {
|
|||
MeshDefinition modelData = new MeshDefinition();
|
||||
PartDefinition modelPartData = modelData.getRoot();
|
||||
modelPartData.addOrReplaceChild("SHARDS_0", CubeListBuilder.create()
|
||||
.texOffs(2, 4)
|
||||
.texOffs(2, 4)
|
||||
.addBox(-5.0f, 1.0f, -3.0f, 2.0f, 8.0f, 2.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
modelPartData.addOrReplaceChild("SHARDS_1", CubeListBuilder.create()
|
||||
.texOffs(2, 4)
|
||||
.texOffs(2, 4)
|
||||
.addBox(3.0f, -1.0f, -1.0f, 2.0f, 8.0f, 2.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
modelPartData.addOrReplaceChild("SHARDS_2", CubeListBuilder.create()
|
||||
.texOffs(2, 4)
|
||||
.texOffs(2, 4)
|
||||
.addBox(-1.0f, 0.0f, -5.0f, 2.0f, 4.0f, 2.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
modelPartData.addOrReplaceChild("SHARDS_3", CubeListBuilder.create()
|
||||
.texOffs(2, 4)
|
||||
.texOffs(2, 4)
|
||||
.addBox(0.0f, 3.0f, 4.0f, 2.0f, 6.0f, 2.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
modelPartData.addOrReplaceChild("CORE", CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.texOffs(0, 0)
|
||||
.addBox(-2.0f, -2.0f, -2.0f, 4.0f, 12.0f, 4.0f),
|
||||
PartPose.ZERO);
|
||||
|
||||
return LayerDefinition.create(modelData, 16, 16);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
RENDER_LAYER = RenderType.beaconBeam(BetterEnd.makeID("textures/entity/eternal_crystal.png"), true);
|
||||
SHARDS = new ModelPart[4];
|
||||
|
|
|
@ -2,16 +2,13 @@ package ru.betterend.client.render;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
|
@ -27,21 +24,21 @@ import ru.betterend.registry.EndItems;
|
|||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class PedestalItemRenderer<T extends PedestalBlockEntity> implements BlockEntityRenderer<T> {
|
||||
|
||||
|
||||
public PedestalItemRenderer(BlockEntityRendererProvider.Context ctx) {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(T blockEntity, float tickDelta, PoseStack matrices,
|
||||
MultiBufferSource vertexConsumers, int light, int overlay) {
|
||||
MultiBufferSource vertexConsumers, int light, int overlay) {
|
||||
|
||||
Level world = blockEntity.getLevel();
|
||||
if (world == null || blockEntity.isEmpty()) return;
|
||||
|
||||
BlockState state = world.getBlockState(blockEntity.getBlockPos());
|
||||
if (!(state.getBlock() instanceof PedestalBlock)) return;
|
||||
|
||||
|
||||
ItemStack activeItem = blockEntity.getItem(0);
|
||||
|
||||
matrices.pushPose();
|
||||
|
@ -54,23 +51,26 @@ public class PedestalItemRenderer<T extends PedestalBlockEntity> implements Bloc
|
|||
matrices.translate(0.5, pedestal.getHeight(state), 0.5);
|
||||
if (activeItem.getItem() instanceof BlockItem) {
|
||||
matrices.scale(1.5F, 1.5F, 1.5F);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
matrices.scale(1.25F, 1.25F, 1.25F);
|
||||
}
|
||||
int age = blockEntity.getAge();
|
||||
if (state.is(EndBlocks.ETERNAL_PEDESTAL) && state.getValue(EternalPedestal.ACTIVATED)) {
|
||||
float[] colors = EternalCrystalRenderer.colors(age);
|
||||
int y = blockEntity.getBlockPos().getY();
|
||||
|
||||
|
||||
BeamRenderer.renderLightBeam(matrices, vertexConsumers, age, tickDelta, -y, 1024 - y, colors, 0.25F, 0.13F, 0.16F);
|
||||
float altitude = Mth.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F + 0.1F;
|
||||
matrices.translate(0.0D, altitude, 0.0D);
|
||||
}
|
||||
if (activeItem.getItem() == Items.END_CRYSTAL) {
|
||||
EndCrystalRenderer.render(age, blockEntity.getMaxAge(), tickDelta, matrices, vertexConsumers, light);
|
||||
} else if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
}
|
||||
else if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
EternalCrystalRenderer.render(age, tickDelta, matrices, vertexConsumers, light);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
float rotation = (age + tickDelta) / 25.0F + 6.0F;
|
||||
matrices.mulPose(Vector3f.YP.rotation(rotation));
|
||||
minecraft.getItemRenderer().render(activeItem, ItemTransforms.TransformType.GROUND, false, matrices, vertexConsumers, light, overlay, model);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue