Skip to content

Commit

Permalink
Fix weird flashy colours
Browse files Browse the repository at this point in the history
  • Loading branch information
Rushmead committed Aug 11, 2024
1 parent 87d1035 commit f2229d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ public int calculatePartialColour(float partialTicks){
return (r << 16) | (g << 8) | b;
}

public int getColour(){
return (getRed() << 16) | (getGreen() << 8) | getBlue();
}

public static final Vec3 calculateViewVector(float xRot, float yRot) {
float f = xRot * 0.017453292F;
float g = -yRot * 0.017453292F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ public void render(MultiBufferSource.BufferSource bufferSource, PoseStack poseSt
VertexConsumer beamConsumer = bufferSource.getBuffer(TheatricalRenderTypes.BEAM);
poseStack.translate(blockEntity.getFixture().getBeamStartPosition()[0], blockEntity.getFixture().getBeamStartPosition()[1], blockEntity.getFixture().getBeamStartPosition()[2]);
float intensity = (blockEntity.getPrevIntensity() + ((blockEntity.getIntensity()) - blockEntity.getPrevIntensity()) * partialTick);
int color = blockEntity.calculatePartialColour(partialTick);
renderLightBeam(beamConsumer, poseStack, blockEntity, partialTick, (float) ((intensity * beamOpacity) / 255f), blockEntity.getFixture().getBeamWidth(), (float) blockEntity.getDistance(), color);
int color = blockEntity.getColour();
if(color != 0) {
renderLightBeam(beamConsumer, poseStack, blockEntity, partialTick, (float) ((intensity * beamOpacity) / 255f), blockEntity.getFixture().getBeamWidth(), (float) blockEntity.getDistance(), color);
}
poseStack.popPose();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void render(MultiBufferSource.BufferSource bufferSource, PoseStack poseSt
VertexConsumer beamConsumer = multiBufferSource.getBuffer(TheatricalRenderTypes.BEAM);
// poseStack.translate(blockEntity.getFixture().getBeamStartPosition()[0], blockEntity.getFixture().getBeamStartPosition()[1], blockEntity.getFixture().getBeamStartPosition()[2]);
float intensity = (blockEntity.getPrevIntensity() + ((blockEntity.getIntensity()) - blockEntity.getPrevIntensity()) * partialTicks);
int color = blockEntity.calculatePartialColour(partialTicks);
int color = blockEntity.getColour();
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
Expand Down

0 comments on commit f2229d7

Please sign in to comment.