Skip to content

Commit

Permalink
feat: hold item above head if wearing barrel
Browse files Browse the repository at this point in the history
  • Loading branch information
Tenzin Pelletier committed Jul 1, 2024
1 parent 7374bf5 commit 15dcfe8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ public void render(PoseStack matrixStackIn, MultiBufferSource bufferIn, int pack

private void renderItem(PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn, StrawGolem golem) {
HeldItem heldItem = golem.getHeldItem();
boolean holdAboveHead = golem.shouldHoldAboveHead();
boolean isBlock = golem.isHoldingBlock();
matrixStackIn.pushPose();
matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(isBlock ? -180.0F : -90.0F));
matrixStackIn.translate(0, isBlock ? -0.3F : -0.45F, isBlock ? 0.0F : -0.15F);
matrixStackIn.translate(0, holdAboveHead ? isBlock ? -0.3F : 0.0F : -0.45F, holdAboveHead ? isBlock ? 0.0F : 0.1F : -0.15F);
matrixStackIn.scale(0.5F, 0.5F, 0.5F);
this.itemInHandRenderer.renderItem(golem, heldItem.get(), ItemTransforms.TransformType.NONE, false, matrixStackIn, bufferIn, packedLightIn);
matrixStackIn.popPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ protected SoundEvent getDeathSound() {

/* Helpers */

public boolean shouldHoldAboveHead() {
if (hasBarrel() && !getMainHandItem().isEmpty()) return true;
return isHoldingBlock();
}

public boolean isHoldingBlock() {
Item item = heldItem.get().getItem();
return item instanceof BlockItem blockItem && blockItem.getBlock() instanceof StemGrownBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class StrawgolemArmsController extends StrawgolemAnimationController {

AnimationController<StrawGolem> controller = event.getController();
if (golem.isScared()) controller.setAnimation(SCARED_ANIM);
else if (golem.isHoldingBlock()) controller.setAnimation(HOLDING_BLOCK_ANIM);
else if (golem.shouldHoldAboveHead()) controller.setAnimation(HOLDING_BLOCK_ANIM);
else if (golem.getHeldItem().has()) controller.setAnimation(HOLDING_ITEM_ANIM);
else if (golem.isRunning()) controller.setAnimation(RUN_ARMS_ANIM);
else if (golem.isMoving()) controller.setAnimation(WALK_ARMS_ANIM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private static PlayState predicate(AnimationEvent<StrawGolem> event) {
}
} else if (event.getAnimatable().isPickingUpItem()) {
if (StrawgolemConfig.Visual.showHarvestItemAnimation.get()) {
event.getController().setAnimation(HARVEST_ITEM_ANIM);
event.getController().setAnimation(event.getAnimatable().hasBarrel() ? HARVEST_BLOCK_ANIM : HARVEST_ITEM_ANIM);
return PlayState.CONTINUE;
}
}
Expand Down

0 comments on commit 15dcfe8

Please sign in to comment.