Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
awakaxis committed Nov 26, 2024
1 parent 618fb47 commit d735382
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public void decrementCardCount() {
this.cardCount--;
this.setChanged();
}
// UNO.LOGGER.info("set cardCount to{}", cardCount);
}

public void resetCardCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ public class CardDeckRenderer implements BlockEntityRenderer<CardDeckBlockEntity
public static final ResourceLocation CARD_DECK_TEXTURE = UNO.id("textures/entity/card_deck.png");
public static final ResourceLocation CARD_DECK_TEXTURE_SIDE = UNO.id("textures/entity/card_deck_side.png");
private static final float CARD_THICKNESS = 0.007f;
private static final float CARD_FACTOR = 5.0f;

public CardDeckRenderer(BlockEntityRendererProvider.Context context) {}

@Override
public void render(CardDeckBlockEntity blockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j) {
if (blockEntity.getCardCount() <= 0) return;

float height = CARD_THICKNESS * Math.round(blockEntity.getCardCount() / 10.0f) / 2.0f;
float height = CARD_THICKNESS * Math.round(blockEntity.getCardCount() / CARD_FACTOR) / 2.0f;

VertexConsumer vertexConsumer = multiBufferSource.getBuffer(RenderType.entityCutout(CARD_DECK_TEXTURE));
poseStack.pushPose();
Expand All @@ -35,6 +36,8 @@ public void render(CardDeckBlockEntity blockEntity, float f, PoseStack poseStack
Matrix4f affine = poseStack.last().pose();
Matrix3f normal = poseStack.last().normal();

//TODO: replace hardcoded vertex coordinates with variables so that implementing blockstates is easier

// top face
this.vertex(affine, normal, vertexConsumer, 0.375f, height, 0.312f, 0, 0, 0, 1, 0, i);
this.vertex(affine, normal, vertexConsumer, 0.375f, height, 0.687f, 0, 1, 0, 1, 0, i);
Expand All @@ -45,7 +48,7 @@ public void render(CardDeckBlockEntity blockEntity, float f, PoseStack poseStack

// round to x, x + 0.5, or x + 1 because the card side texture is actually two cards on top of each other, so the value needs to be in terms of 0.5
// hawk tuah
final float VALUE = Math.round(blockEntity.getCardCount() / 10.0f) / 2.0f;
final float VALUE = Math.round(blockEntity.getCardCount() / CARD_FACTOR) / 2.0f;
final float UV_NY = (int) VALUE < VALUE ? 0.5f : 0.0F;
final float UV_PY = (int) VALUE < VALUE ? VALUE + 0.5f : VALUE;

Expand Down Expand Up @@ -86,9 +89,4 @@ public void vertex(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexCo
.normal(matrix3f, (float)l, (float)m, (float)n)
.endVertex();
}

// @Override
// public boolean shouldRender(CardDeckBlockEntity blockEntity, Vec3 vec3) {
// return true;
// }
}

0 comments on commit d735382

Please sign in to comment.