diff --git a/src/main/java/com/axanthic/icaria/client/helper/IcariaClientHelper.java b/src/main/java/com/axanthic/icaria/client/helper/IcariaClientHelper.java index 97af64266..1b1239e2d 100644 --- a/src/main/java/com/axanthic/icaria/client/helper/IcariaClientHelper.java +++ b/src/main/java/com/axanthic/icaria/client/helper/IcariaClientHelper.java @@ -51,9 +51,18 @@ public static float getLightBasedAlpha(LivingEntity pLivingEntity) { public static float getLightBasedAlpha2(LivingEntity pLivingEntity, float pPartialTick) { System.out.println(pLivingEntity.level().getSunAngle(pPartialTick)); - return pLivingEntity.level().getSunAngle(pPartialTick) >= Math.PI ? 1.0F : 0.0F; + if (pLivingEntity.level().getSunAngle(pPartialTick) >= IcariaValues.DUSK_INIT && pLivingEntity.level().getSunAngle(pPartialTick) < IcariaValues.DUSK_EXIT) { + return (pLivingEntity.level().getSunAngle(pPartialTick) - IcariaValues.DUSK_INIT) / (IcariaValues.DUSK_EXIT - IcariaValues.DUSK_INIT); + } else if (pLivingEntity.level().getSunAngle(pPartialTick) >= IcariaValues.DUSK_INIT && pLivingEntity.level().getSunAngle(pPartialTick) < IcariaValues.DAWN_INIT) { + return 1.0F; + } else if (pLivingEntity.level().getSunAngle(pPartialTick) >= IcariaValues.DAWN_INIT && pLivingEntity.level().getSunAngle(pPartialTick) < IcariaValues.DAWN_EXIT) { + return (IcariaValues.DAWN_EXIT - pLivingEntity.level().getSunAngle(pPartialTick)) / (IcariaValues.DAWN_EXIT - IcariaValues.DAWN_INIT); + } else { + return 0.0F; + } } + public static float getRed(BlockEntity pBlockEntity) { return IcariaClientHelper.getImageBasedColor(pBlockEntity).getRed() / 255.0F; } @@ -106,6 +115,34 @@ public static void renderRays(PoseStack pPoseStack, MultiBufferSource pBuffer, L } } + public static void renderRays2(PoseStack pPoseStack, MultiBufferSource pBuffer, LivingEntity pLivingEntity, float pRed, float pGreen, float pBlue, float pPartialTick) { + if (IcariaConfig.RENDER_CRYSTAL_RAYS.get()) { + var matrix4f = pPoseStack.last().pose(); + var randomSource = RandomSource.create(432L); + var vertexConsumer = pBuffer.getBuffer(IcariaRenderTypes.ADDITIVE_TRANSPARENT); + + float alpha = (0.1F - Math.min(0.0F, 0.1F)) * (!pLivingEntity.isInvisible() ? IcariaClientHelper.getLightBasedAlpha2(pLivingEntity, pPartialTick) : 0.0F); + float length = randomSource.nextFloat() * 2.0F + 1.25F; + float width = randomSource.nextFloat() * 0.5F + 0.25F; + + for (int i = 0; i < 96; ++i) { + pPoseStack.mulPose(Axis.XP.rotationDegrees(randomSource.nextFloat() * 360.0F)); + pPoseStack.mulPose(Axis.YP.rotationDegrees(randomSource.nextFloat() * 360.0F)); + pPoseStack.mulPose(Axis.ZP.rotationDegrees(randomSource.nextFloat() * 360.0F)); + + IcariaClientHelper.vertexA(vertexConsumer, matrix4f, pRed, pGreen, pBlue, alpha); + IcariaClientHelper.vertexB(vertexConsumer, matrix4f, length, width); + IcariaClientHelper.vertexC(vertexConsumer, matrix4f, length, width); + IcariaClientHelper.vertexA(vertexConsumer, matrix4f, pRed, pGreen, pBlue, alpha); + IcariaClientHelper.vertexC(vertexConsumer, matrix4f, length, width); + IcariaClientHelper.vertexD(vertexConsumer, matrix4f, length, width); + IcariaClientHelper.vertexA(vertexConsumer, matrix4f, pRed, pGreen, pBlue, alpha); + IcariaClientHelper.vertexD(vertexConsumer, matrix4f, length, width); + IcariaClientHelper.vertexB(vertexConsumer, matrix4f, length, width); + } + } + } + public static void renderRays(PoseStack pPoseStack, MultiBufferSource pBuffer, float pRed, float pGreen, float pBlue) { diff --git a/src/main/java/com/axanthic/icaria/client/layer/CrystalSlugRaysLayer.java b/src/main/java/com/axanthic/icaria/client/layer/CrystalSlugRaysLayer.java index 7c2d7fcc9..04ab6ee77 100644 --- a/src/main/java/com/axanthic/icaria/client/layer/CrystalSlugRaysLayer.java +++ b/src/main/java/com/axanthic/icaria/client/layer/CrystalSlugRaysLayer.java @@ -21,32 +21,32 @@ public CrystalSlugRaysLayer(RenderLayerParent pRen @Override public void render(PoseStack pPoseStack, MultiBufferSource pBuffer, int pPackedLight, SlugEntity pLivingEntity, float pLimbSwing, float pLimbSwingAmount, float pPartialTick, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) { - this.neck(pPoseStack, pBuffer, pLivingEntity); - this.center(pPoseStack, pBuffer, pLivingEntity); - this.rear(pPoseStack, pBuffer, pLivingEntity); + this.neck(pPoseStack, pBuffer, pLivingEntity, pPartialTick); + this.center(pPoseStack, pBuffer, pLivingEntity, pPartialTick); + this.rear(pPoseStack, pBuffer, pLivingEntity, pPartialTick); } - public void neck(PoseStack pPoseStack, MultiBufferSource pBuffer, SlugEntity pLivingEntity) { + public void neck(PoseStack pPoseStack, MultiBufferSource pBuffer, SlugEntity pLivingEntity, float pPartialTick) { pPoseStack.pushPose(); this.getParentModel().translateToNeck(pPoseStack); IcariaClientHelper.setPositionAndSize(pPoseStack, 0.125F, -0.060F, -0.095F, 0.375F); - IcariaClientHelper.renderRays(pPoseStack, pBuffer, pLivingEntity, pLivingEntity.red, pLivingEntity.green, pLivingEntity.blue); + IcariaClientHelper.renderRays2(pPoseStack, pBuffer, pLivingEntity, pLivingEntity.red, pLivingEntity.green, pLivingEntity.blue, pPartialTick); pPoseStack.popPose(); } - public void center(PoseStack pPoseStack, MultiBufferSource pBuffer, SlugEntity pLivingEntity) { + public void center(PoseStack pPoseStack, MultiBufferSource pBuffer, SlugEntity pLivingEntity, float pPartialTick) { pPoseStack.pushPose(); this.getParentModel().translateToCenter(pPoseStack); IcariaClientHelper.setPositionAndSize(pPoseStack, -0.060F, -0.055F, -0.310F, 0.375F); - IcariaClientHelper.renderRays(pPoseStack, pBuffer, pLivingEntity, pLivingEntity.red, pLivingEntity.green, pLivingEntity.blue); + IcariaClientHelper.renderRays2(pPoseStack, pBuffer, pLivingEntity, pLivingEntity.red, pLivingEntity.green, pLivingEntity.blue, pPartialTick); pPoseStack.popPose(); } - public void rear(PoseStack pPoseStack, MultiBufferSource pBuffer, SlugEntity pLivingEntity) { + public void rear(PoseStack pPoseStack, MultiBufferSource pBuffer, SlugEntity pLivingEntity, float pPartialTick) { pPoseStack.pushPose(); this.getParentModel().translateToRear(pPoseStack); IcariaClientHelper.setPositionAndSize(pPoseStack, 0.090F, -0.060F, 0.165F, 0.375F); - IcariaClientHelper.renderRays(pPoseStack, pBuffer, pLivingEntity, pLivingEntity.red, pLivingEntity.green, pLivingEntity.blue); + IcariaClientHelper.renderRays2(pPoseStack, pBuffer, pLivingEntity, pLivingEntity.red, pLivingEntity.green, pLivingEntity.blue, pPartialTick); pPoseStack.popPose(); } } diff --git a/src/main/java/com/axanthic/icaria/common/util/IcariaValues.java b/src/main/java/com/axanthic/icaria/common/util/IcariaValues.java index 3a5afaff0..97f455b34 100644 --- a/src/main/java/com/axanthic/icaria/common/util/IcariaValues.java +++ b/src/main/java/com/axanthic/icaria/common/util/IcariaValues.java @@ -1,8 +1,8 @@ package com.axanthic.icaria.common.util; public class IcariaValues { - public static final float DUSK_INIT = 12000.0F; - public static final float DUSK_EXIT = 13000.0F; - public static final float DAWN_INIT = 23000.0F; - public static final float DAWN_EXIT = 24000.0F; + public static final float DUSK_INIT = 1.3539146F; // 1.3539146 + public static final float DUSK_EXIT = 1.6314344F; // 1.6314344 + public static final float DAWN_INIT = 4.6517510F; // 4.6517510 + public static final float DAWN_EXIT = 4.9292707F; // 4.9292707 } \ No newline at end of file