[Change] Use Fabric ArmorRenderer for Crystalite Armor
This commit is contained in:
parent
634be67361
commit
c36a68d158
10 changed files with 76 additions and 660 deletions
|
@ -1,97 +0,0 @@
|
|||
package org.betterx.betterend.item.model;
|
||||
|
||||
import org.betterx.betterend.item.CrystaliteArmor;
|
||||
import org.betterx.betterend.registry.EndItems;
|
||||
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import shadow.fabric.api.client.rendering.v1.ArmorRenderingRegistry;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class CrystaliteArmorProvider implements ArmorRenderingRegistry.ModelProvider, ArmorRenderingRegistry.TextureProvider {
|
||||
//TODO: find new registry
|
||||
private final static ResourceLocation FIRST_LAYER = new ResourceLocation(
|
||||
"textures/models/armor/crystalite_layer_1.png");
|
||||
private final static ResourceLocation SECOND_LAYER = new ResourceLocation(
|
||||
"textures/models/armor/crystalite_layer_2.png");
|
||||
private final static CrystaliteHelmetModel HELMET_MODEL = CrystaliteHelmetModel.createModel(null);
|
||||
private final static CrystaliteChestplateModel CHEST_MODEL = CrystaliteChestplateModel.createRegularModel(null);
|
||||
private final static CrystaliteChestplateModel CHEST_MODEL_SLIM = CrystaliteChestplateModel.createThinModel(null);
|
||||
private final static CrystaliteLeggingsModel LEGGINGS_MODEL = CrystaliteLeggingsModel.createModel(null);
|
||||
private final static CrystaliteBootsModel BOOTS_MODEL = CrystaliteBootsModel.createModel(null);
|
||||
|
||||
//@Override
|
||||
public @NotNull ResourceLocation getArmorTexture(
|
||||
LivingEntity entity,
|
||||
ItemStack stack,
|
||||
EquipmentSlot slot,
|
||||
boolean secondLayer,
|
||||
@Nullable String suffix,
|
||||
ResourceLocation defaultTexture
|
||||
) {
|
||||
if (!isStackValid(stack)) return defaultTexture;
|
||||
if (secondLayer) return SECOND_LAYER;
|
||||
return FIRST_LAYER;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public @NotNull HumanoidModel<LivingEntity> getArmorModel(
|
||||
LivingEntity entity,
|
||||
ItemStack stack,
|
||||
EquipmentSlot slot,
|
||||
HumanoidModel<LivingEntity> defaultModel
|
||||
) {
|
||||
if (!isStackValid(stack)) return defaultModel;
|
||||
switch (slot) {
|
||||
case HEAD: {
|
||||
return HELMET_MODEL;
|
||||
}
|
||||
case CHEST: {
|
||||
if (entity instanceof AbstractClientPlayer && ((AbstractClientPlayer) entity).getModelName()
|
||||
.equals("slim")) {
|
||||
CHEST_MODEL_SLIM.copyPropertiesTo(defaultModel);
|
||||
return CHEST_MODEL_SLIM;
|
||||
}
|
||||
CHEST_MODEL.copyPropertiesTo(defaultModel);
|
||||
return CHEST_MODEL;
|
||||
}
|
||||
case LEGS: {
|
||||
return LEGGINGS_MODEL;
|
||||
}
|
||||
case FEET: {
|
||||
BOOTS_MODEL.copyPropertiesTo(defaultModel);
|
||||
return BOOTS_MODEL;
|
||||
}
|
||||
default: {
|
||||
return defaultModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Iterable<Item> getRenderedItems() {
|
||||
return Lists.newArrayList(
|
||||
EndItems.CRYSTALITE_HELMET,
|
||||
EndItems.CRYSTALITE_CHESTPLATE,
|
||||
EndItems.CRYSTALITE_ELYTRA,
|
||||
EndItems.CRYSTALITE_LEGGINGS,
|
||||
EndItems.CRYSTALITE_BOOTS
|
||||
);
|
||||
}
|
||||
|
||||
private boolean isStackValid(ItemStack stack) {
|
||||
return stack.getItem() instanceof CrystaliteArmor;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.betterx.betterend.item.model;
|
||||
|
||||
import org.betterx.bclib.client.render.HumanoidArmorRenderer;
|
||||
import org.betterx.betterend.registry.EndItems;
|
||||
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderer;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class CrystaliteArmorRenderer extends HumanoidArmorRenderer {
|
||||
private final static ResourceLocation FIRST_LAYER = new ResourceLocation(
|
||||
"textures/models/armor/crystalite_layer_1.png");
|
||||
private final static ResourceLocation SECOND_LAYER = new ResourceLocation(
|
||||
"textures/models/armor/crystalite_layer_2.png");
|
||||
private final static CrystaliteHelmetModel HELMET_MODEL = CrystaliteHelmetModel.createModel(null);
|
||||
private final static CrystaliteChestplateModel CHEST_MODEL = CrystaliteChestplateModel.createRegularModel(null);
|
||||
private final static CrystaliteChestplateModel CHEST_MODEL_SLIM = CrystaliteChestplateModel.createThinModel(null);
|
||||
private final static CrystaliteLeggingsModel LEGGINGS_MODEL = CrystaliteLeggingsModel.createModel(null);
|
||||
private final static CrystaliteBootsModel BOOTS_MODEL = CrystaliteBootsModel.createModel(null);
|
||||
private static CrystaliteArmorRenderer INSTANCE = null;
|
||||
|
||||
public static void register() {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new CrystaliteArmorRenderer();
|
||||
ArmorRenderer.register(
|
||||
INSTANCE,
|
||||
EndItems.CRYSTALITE_HELMET,
|
||||
EndItems.CRYSTALITE_CHESTPLATE,
|
||||
EndItems.CRYSTALITE_ELYTRA,
|
||||
EndItems.CRYSTALITE_LEGGINGS,
|
||||
EndItems.CRYSTALITE_BOOTS
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected ResourceLocation getTextureForSlot(EquipmentSlot slot, boolean innerLayer) {
|
||||
return innerLayer ? SECOND_LAYER : FIRST_LAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HumanoidModel<LivingEntity> getModelForSlot(LivingEntity entity, EquipmentSlot slot) {
|
||||
if (slot == EquipmentSlot.HEAD) return HELMET_MODEL;
|
||||
if (slot == EquipmentSlot.LEGS) return LEGGINGS_MODEL;
|
||||
if (slot == EquipmentSlot.FEET) return BOOTS_MODEL;
|
||||
if (slot == EquipmentSlot.CHEST) {
|
||||
if (entity instanceof AbstractClientPlayer acp && acp.getModelName().equals("slim")) {
|
||||
return CHEST_MODEL_SLIM;
|
||||
} else {
|
||||
return CHEST_MODEL;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package org.betterx.betterend.item.model;
|
||||
|
||||
import org.betterx.bclib.client.render.HumanoidArmorRenderer;
|
||||
import org.betterx.betterend.registry.EndEntitiesRenders;
|
||||
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
|
@ -14,7 +15,7 @@ import com.google.common.collect.Lists;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
public class CrystaliteBootsModel extends HumanoidModel<LivingEntity> {
|
||||
public class CrystaliteBootsModel extends HumanoidModel<LivingEntity> implements HumanoidArmorRenderer.CopyExtraState {
|
||||
|
||||
public ModelPart leftBoot;
|
||||
public ModelPart rightBoot;
|
||||
|
@ -66,8 +67,7 @@ public class CrystaliteBootsModel extends HumanoidModel<LivingEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void copyPropertiesTo(HumanoidModel<LivingEntity> bipedEntityModel) {
|
||||
super.copyPropertiesTo(bipedEntityModel);
|
||||
public void copyPropertiesFrom(HumanoidModel<LivingEntity> bipedEntityModel) {
|
||||
this.leftBoot.copyFrom(leftLeg);
|
||||
this.rightBoot.copyFrom(rightLeg);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.betterx.betterend.item.model;
|
||||
|
||||
import org.betterx.bclib.client.render.HumanoidArmorRenderer;
|
||||
import org.betterx.betterend.registry.EndEntitiesRenders;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
@ -17,7 +18,7 @@ import com.google.common.collect.Lists;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
public class CrystaliteChestplateModel extends HumanoidModel<LivingEntity> {
|
||||
public class CrystaliteChestplateModel extends HumanoidModel<LivingEntity> implements HumanoidArmorRenderer.CopyExtraState {
|
||||
|
||||
public ModelPart leftShoulder;
|
||||
public ModelPart rightShoulder;
|
||||
|
@ -119,13 +120,13 @@ public class CrystaliteChestplateModel extends HumanoidModel<LivingEntity> {
|
|||
super(modelPart, RenderType::entityTranslucent);
|
||||
this.thinArms = thinArms;
|
||||
localBody = modelPart.getChild(PartNames.BODY);
|
||||
leftShoulder = modelPart.getChild("leftShoulder");
|
||||
rightShoulder = modelPart.getChild("rightShoulder");
|
||||
this.leftShoulder = modelPart.getChild("leftShoulder");
|
||||
this.rightShoulder = modelPart.getChild("rightShoulder");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void copyPropertiesTo(HumanoidModel<LivingEntity> bipedEntityModel) {
|
||||
super.copyPropertiesTo(bipedEntityModel);
|
||||
public void copyPropertiesFrom(HumanoidModel<LivingEntity> parentModel) {
|
||||
this.leftShoulder.copyFrom(leftArm);
|
||||
this.rightShoulder.copyFrom(rightArm);
|
||||
}
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
package org.betterx.betterend.registry;
|
||||
|
||||
import org.betterx.betterend.item.model.CrystaliteArmorProvider;
|
||||
import org.betterx.betterend.item.model.CrystaliteArmorRenderer;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import shadow.fabric.api.client.rendering.v1.ArmorRenderingRegistry;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class EndModelProviders {
|
||||
|
||||
public final static CrystaliteArmorProvider CRYSTALITE_PROVIDER = new CrystaliteArmorProvider();
|
||||
|
||||
public final static void register() {
|
||||
ArmorRenderingRegistry.registerModel(CRYSTALITE_PROVIDER, CRYSTALITE_PROVIDER.getRenderedItems());
|
||||
ArmorRenderingRegistry.registerTexture(CRYSTALITE_PROVIDER, CRYSTALITE_PROVIDER.getRenderedItems());
|
||||
CrystaliteArmorRenderer.register();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue