mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
Simplify usage of IItemRenderProperties::getArmorModel (#8349)
This commit is contained in:
1 parent
5f0d4abf23
commit
fd522d38b0
5 files changed
+204
-15
No files matched your search
@@ -22,12 +22,16 @@ package net.minecraftforge.client;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.model.Model;
|
||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface IItemRenderProperties
|
||||
{
|
||||
IItemRenderProperties DUMMY = new IItemRenderProperties()
|
||||
@@ -53,13 +57,40 @@ public interface IItemRenderProperties
|
||||
* @param itemStack The itemStack to render the model of
|
||||
* @param armorSlot The slot the armor is in
|
||||
* @param _default Original armor model. Will have attributes set.
|
||||
* @return A ModelBiped to render instead of the default
|
||||
* @return A HumanoidModel to render instead of the default, will have the relevant properties copied in {@link #getBaseArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel).
|
||||
* Returning null will cause the default to render.
|
||||
* @see #getBaseArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)
|
||||
*/
|
||||
default <A extends HumanoidModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, A _default)
|
||||
@Nullable
|
||||
default HumanoidModel<?> getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> _default)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method to return a generic model rather than a {@link HumanoidModel}. More ideal for wrapping the original model or returning non-standard models like elytra wings.
|
||||
* By default, this hook copies in the model properties from the default into the model returned by {@link #getArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)},
|
||||
* so if you override this method you are responsible for copying properties you care about
|
||||
*
|
||||
* @param entityLiving The entity wearing the armor
|
||||
* @param itemStack The itemStack to render the model of
|
||||
* @param armorSlot The slot the armor is in
|
||||
* @param _default Original armor model. Will have attributes set.
|
||||
* @return A Model to render instead of the default
|
||||
* @see #getArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)
|
||||
*/
|
||||
@Nonnull
|
||||
default Model getBaseArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> _default)
|
||||
{
|
||||
HumanoidModel<?> replacement = getArmorModel(entityLiving, itemStack, armorSlot, _default);
|
||||
if (replacement != null && replacement != _default)
|
||||
{
|
||||
ForgeHooksClient.copyModelProperties(_default, replacement);
|
||||
return replacement;
|
||||
}
|
||||
return _default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the client starts rendering the HUD, for whatever item the player
|
||||
* currently has as a helmet. This is where pumpkins would render there overlay.
|
||||
|
||||
Reference in new issue
Block a user