Skip to content

Commit

Permalink
fix glowing mobs attempt #5
Browse files Browse the repository at this point in the history
  • Loading branch information
luxtracon committed May 28, 2024
1 parent 71a0dc7 commit 649d010
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ public CrystalSlugRaysLayer(RenderLayerParent<SlugEntity, CrystalSlugModel> 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();
}
}
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 649d010

Please sign in to comment.