Skip to content

Commit

Permalink
First shot at armor trims
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Aug 1, 2023
1 parent 3034621 commit bdaaf33
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.armortrim.ArmorTrim;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -38,6 +40,23 @@ private void changeId(PoseStack pHumanoidArmorLayer0, MultiBufferSource pMultiBu
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(BlockRenderingSettings.INSTANCE.getItemIds().applyAsInt(new NamespacedId(location.getNamespace(), location.getPath())));
}

private int backupValue = 0;

@Inject(method = "renderTrim", at = @At(value = "HEAD"), locals = LocalCapture.CAPTURE_FAILHARD)
private void changeTrimTemp(ArmorMaterial pHumanoidArmorLayer0, PoseStack pPoseStack1, MultiBufferSource pMultiBufferSource2, int pInt3, ArmorTrim pArmorTrim4, A pHumanoidModel5, boolean pBoolean6, CallbackInfo ci) {
if (BlockRenderingSettings.INSTANCE.getItemIds() == null) return;

backupValue = CapturedRenderingState.INSTANCE.getCurrentRenderedItem();
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(BlockRenderingSettings.INSTANCE.getItemIds().applyAsInt(new NamespacedId("minecraft", "trim_" + pArmorTrim4.material().value().assetName())));
}

@Inject(method = "renderTrim", at = @At(value = "TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
private void changeTrimTemp2(ArmorMaterial pHumanoidArmorLayer0, PoseStack pPoseStack1, MultiBufferSource pMultiBufferSource2, int pInt3, ArmorTrim pArmorTrim4, A pHumanoidModel5, boolean pBoolean6, CallbackInfo ci) {
if (BlockRenderingSettings.INSTANCE.getItemIds() == null) return;
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(backupValue);
backupValue = 0;
}

@Inject(method = "renderArmorPiece", at = @At(value = "TAIL"))
private void changeId2(CallbackInfo ci) {
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ private void fillExtendedData(int vertexAmount) {
for (int vertex = 0; vertex < vertexAmount; vertex++) {
buffer.putFloat(nextElementByte - midUOffset - stride * vertex, midU);
buffer.putFloat(nextElementByte - midVOffset - stride * vertex, midV);
buffer.putInt(nextElementByte - normalOffset - stride * vertex, packedNormal);
if (vertexAmount != 3) {
buffer.putInt(nextElementByte - normalOffset - stride * vertex, packedNormal);
}
buffer.putInt(nextElementByte - tangentOffset - stride * vertex, tangent);
}
}
Expand Down

0 comments on commit bdaaf33

Please sign in to comment.