Skip to content

Commit

Permalink
Improve trinkets rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
OroArmor committed Feb 9, 2021
1 parent 3ecb6eb commit 2994715
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
package com.oroarmor.netherite_plus.compatibility;

import com.oroarmor.netherite_plus.client.render.NetheriteElytraFeatureRenderer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.model.ElytraEntityModel;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

@Environment(EnvType.CLIENT)
public class NetheritePlusTrinketsRenderer {
@Environment(EnvType.CLIENT)
@SuppressWarnings({"unchecked", "rawtypes"})
public final static ElytraEntityModel<AbstractClientPlayerEntity> elytra = new ElytraEntityModel();

@Environment(EnvType.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public final static ElytraEntityModel<AbstractClientPlayerEntity> elytra = new ElytraEntityModel();

public static void renderTrinketsElytra(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, AbstractClientPlayerEntity livingEntity, Item item) {
matrixStack.push();
matrixStack.scale(1.5f, 1.5f, 1.5f);
matrixStack.translate(0.0D, -0.775D, 0.125D);
elytra.setAngles(livingEntity, 0f, 0f, 0f, 0f, 0f);
VertexConsumer vertexConsumer = ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, elytra.getLayer(NetheriteElytraFeatureRenderer.NETHERITE_ELYTRA_SKIN), false, item.getDefaultStack().hasGlint());
elytra.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrixStack.pop();
}

public static void renderTrinketsElytra(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, AbstractClientPlayerEntity livingEntity, ItemStack item) {
matrixStack.push();
matrixStack.scale(2f, 2f, 2f);
matrixStack.translate(0.0D, -0.775D, 0.125D / 2D);
elytra.setAngles(livingEntity, 0f, 0f, 0f, 0f, 0f);
VertexConsumer vertexConsumer = ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, elytra.getLayer(NetheriteElytraFeatureRenderer.NETHERITE_ELYTRA_SKIN), false, item.hasGlint());
elytra.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrixStack.pop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import java.util.List;
import com.oroarmor.netherite_plus.compatibility.NetheritePlusTrinketsRenderer;
import com.oroarmor.netherite_plus.config.NetheritePlusConfig;
import dev.emi.trinkets.api.Slots;
import dev.emi.trinkets.api.Trinket;
import dev.emi.trinkets.api.TrinketItem;
import dev.emi.trinkets.api.*;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.DispenserBlock;
Expand Down Expand Up @@ -54,13 +53,11 @@ public void onUnequip(PlayerEntity player, ItemStack stack) {
@Environment(EnvType.CLIENT)
@Override
public void render(String slot, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, PlayerEntityModel<AbstractClientPlayerEntity> model, AbstractClientPlayerEntity livingEntity, float headYaw, float headPitch) {

NetheritePlusTrinketsRenderer.renderTrinketsElytra(matrixStack, vertexConsumerProvider, light, livingEntity, this);
NetheritePlusTrinketsRenderer.renderTrinketsElytra(matrixStack, vertexConsumerProvider, light, livingEntity, TrinketsApi.getTrinketComponent(livingEntity).getStack(slot));
}

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
return Trinket.equipTrinket(player, hand);
}

}

0 comments on commit 2994715

Please sign in to comment.