Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
TheidenHD committed Jan 6, 2025
1 parent 1ac1ea9 commit 6c920e7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Thumbs.db

## ForgeGradle
/run
/runs

## eclipse
/.settings
Expand Down
38 changes: 3 additions & 35 deletions src/main/java/vazkii/psi/client/model/ArmorModels.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,11 @@
*/
package vazkii.psi.client.model;

import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.Minecraft;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

import vazkii.psi.common.item.armor.ItemPsimetalArmor;

import javax.annotation.Nullable;

import java.util.Collections;
import java.util.EnumMap;
import java.util.Map;

public class ArmorModels {
private static Map<EquipmentSlot, ModelArmor> exosuit = Collections.emptyMap();

private static Map<EquipmentSlot, ModelArmor> make(EntityRendererProvider.Context ctx, ModelLayerLocation inner, ModelLayerLocation outer) {
Map<EquipmentSlot, ModelArmor> ret = new EnumMap<>(EquipmentSlot.class);
for(var slot : EquipmentSlot.values()) {
var mesh = ctx.bakeLayer(slot == EquipmentSlot.LEGS ? inner : outer);
ret.put(slot, new ModelArmor(mesh, slot));
}
return ret;
}

public static void init(EntityRendererProvider.Context ctx) {
exosuit = make(ctx, ModModelLayers.PSIMETAL_EXOSUIT_INNER_ARMOR, ModModelLayers.PSIMETAL_EXOSUIT_OUTER_ARMOR);
}

@Nullable
public static ModelArmor get(ItemStack stack) {
Item item = stack.getItem();
if(item instanceof ItemPsimetalArmor armor) {
return exosuit.get(armor.getEquipmentSlot());
}

return null;
public static ModelArmor get(EquipmentSlot equipmentSlot) {
return new ModelArmor(Minecraft.getInstance().getEntityModels().bakeLayer(equipmentSlot == EquipmentSlot.LEGS ? ModModelLayers.PSIMETAL_EXOSUIT_INNER_ARMOR : ModModelLayers.PSIMETAL_EXOSUIT_OUTER_ARMOR), equipmentSlot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public class RenderSpellCircle extends EntityRenderer<EntitySpellCircle> {

public RenderSpellCircle(EntityRendererProvider.Context ctx) {
super(ctx);
// Ugly hack to get context
ArmorModels.init(ctx);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void initializeClient(Consumer<IClientItemExtensions> consumer) {
consumer.accept(new IClientItemExtensions() {
@Override
public @NotNull HumanoidModel<?> getHumanoidArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel<?> original) {
return ArmorModels.get(itemStack);
return ArmorModels.get(equipmentSlot);
}
});
}
Expand Down

0 comments on commit 6c920e7

Please sign in to comment.