Skip to content

Commit

Permalink
Make Lanternfish glow with shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Nov 6, 2023
1 parent 75c0d5a commit 32727af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.uraneptus.sullysmod.client.renderer.entities.layer.LanternfishGlowLayer;
import com.uraneptus.sullysmod.common.entities.Lanternfish;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.ResourceLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public LanternfishGlowLayer(RenderLayerParent<E, LanternfishModel<E>> entityRend

@Override
public void render(PoseStack pMatrixStack, MultiBufferSource pBuffer, int pPackedLight, E pLivingEntity, float pLimbSwing, float pLimbSwingAmount, float pPartialTicks, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) {
int i = (int) Mth.clampedLerp(0.0F, 15.0F, 1.0F - (float) pLivingEntity.getDarkTicksRemaining() / 10.0F);
int packedLight = i == 15 ? 240 : pPackedLight;
RenderType renderType = i == 15 ? BlueprintRenderTypes.getUnshadedCutoutEntity(GLOW_LAYER, true) : RenderType.entityCutoutNoCull(GLOW_LAYER);
VertexConsumer vertexconsumer = pBuffer.getBuffer(renderType);
this.getParentModel().renderToBuffer(pMatrixStack, vertexconsumer, packedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
if (pLivingEntity.renderGlow()) {
RenderType renderType = RenderType.eyes(GLOW_LAYER);
VertexConsumer vertexconsumer = pBuffer.getBuffer(renderType);
this.getParentModel().renderToBuffer(pMatrixStack, vertexconsumer, pPackedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -84,6 +85,11 @@ public int getDarkTicksRemaining() {
return this.entityData.get(DATA_DARK_TICKS_REMAINING);
}

public boolean renderGlow() {
int i = (int) Mth.clampedLerp(0.0F, 15.0F, 1.0F - (float) this.getDarkTicksRemaining() / 10.0F);
return i == 15;
}

@Override
protected SoundEvent getFlopSound() {
return SMSounds.LANTERNFISH_FLOP.get();
Expand Down

0 comments on commit 32727af

Please sign in to comment.