Code style changes, entities fixes

This commit is contained in:
paulevsGitch 2021-07-08 00:21:47 +03:00
parent 9d604b2d25
commit 44962e18b6
377 changed files with 5038 additions and 4914 deletions

View file

@ -21,11 +21,6 @@
package shadow.fabric.api.client.rendering.v1;
import java.util.Arrays;
import shadow.fabric.impl.client.rendering.ArmorRenderingRegistryImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.model.HumanoidModel;
@ -34,6 +29,11 @@ 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 org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import shadow.fabric.impl.client.rendering.ArmorRenderingRegistryImpl;
import java.util.Arrays;
/**
* A class for registering custom armor models and textures for {@link Item}, to be provided by a {@link ModelProvider} or {@link TextureProvider}.
@ -49,120 +49,120 @@ import net.minecraft.world.item.ItemStack;
*/
@Environment(EnvType.CLIENT)
public final class ArmorRenderingRegistry {
private ArmorRenderingRegistry() {
}
private ArmorRenderingRegistry() {
}
/**
* Registers a provider for custom armor models for an item.
*
* @param provider the provider for the model
* @param items the items to be registered for
*/
public static void registerModel(@Nullable ModelProvider provider, Item... items) {
registerModel(provider, Arrays.asList(items));
}
/**
* Registers a provider for custom armor models for an item.
*
* @param provider the provider for the model
* @param items the items to be registered for
*/
public static void registerModel(@Nullable ModelProvider provider, Item... items) {
registerModel(provider, Arrays.asList(items));
}
/**
* Registers a provider for custom armor models for an item.
*
* @param provider the provider for the model
* @param items the items to be registered for
*/
public static void registerModel(@Nullable ModelProvider provider, Iterable<Item> items) {
ArmorRenderingRegistryImpl.registerModel(provider, items);
}
/**
* Registers a provider for custom armor models for an item.
*
* @param provider the provider for the model
* @param items the items to be registered for
*/
public static void registerModel(@Nullable ModelProvider provider, Iterable<Item> items) {
ArmorRenderingRegistryImpl.registerModel(provider, items);
}
/**
* Registers a provider for custom texture models for an item.
*
* @param provider the provider for the texture
* @param items the items to be registered for
*/
public static void registerTexture(@Nullable TextureProvider provider, Item... items) {
registerTexture(provider, Arrays.asList(items));
}
/**
* Registers a provider for custom texture models for an item.
*
* @param provider the provider for the texture
* @param items the items to be registered for
*/
public static void registerTexture(@Nullable TextureProvider provider, Item... items) {
registerTexture(provider, Arrays.asList(items));
}
/**
* Registers a provider for custom texture models for an item.
*
* @param provider the provider for the texture
* @param items the items to be registered for
*/
public static void registerTexture(@Nullable TextureProvider provider, Iterable<Item> items) {
ArmorRenderingRegistryImpl.registerTexture(provider, items);
}
/**
* Registers a provider for custom texture models for an item.
*
* @param provider the provider for the texture
* @param items the items to be registered for
*/
public static void registerTexture(@Nullable TextureProvider provider, Iterable<Item> items) {
ArmorRenderingRegistryImpl.registerTexture(provider, items);
}
/**
* Register simple armor items to use the vanilla armor file name under the mods namespace.
*
* @param identifier The namespace + path to use for the armor texture location.
* @param items the items to be registered
*/
public static void registerSimpleTexture(ResourceLocation identifier, Item... items) {
registerTexture((entity, stack, slot, secondLayer, suffix, defaultTexture) -> {
return new ResourceLocation(identifier.getNamespace(), "textures/models/armor/" + identifier.getPath() + "_layer_" + (secondLayer ? 2 : 1) + (suffix == null ? "" : "_" + suffix) + ".png");
}, items);
}
/**
* Register simple armor items to use the vanilla armor file name under the mods namespace.
*
* @param identifier The namespace + path to use for the armor texture location.
* @param items the items to be registered
*/
public static void registerSimpleTexture(ResourceLocation identifier, Item... items) {
registerTexture((entity, stack, slot, secondLayer, suffix, defaultTexture) -> {
return new ResourceLocation(identifier.getNamespace(), "textures/models/armor/" + identifier.getPath() + "_layer_" + (secondLayer ? 2 : 1) + (suffix == null ? "" : "_" + suffix) + ".png");
}, items);
}
/**
* Gets the model of the armor piece.
*
* @param entity The entity equipping the armor
* @param stack The item stack of the armor
* @param slot The slot which the armor is in
* @param defaultModel The default model that vanilla provides
* @return The model of the armor piece.
*/
@NotNull
public static HumanoidModel<LivingEntity> getArmorModel(LivingEntity entity, ItemStack stack, EquipmentSlot slot, HumanoidModel<LivingEntity> defaultModel) {
return ArmorRenderingRegistryImpl.getArmorModel(entity, stack, slot, defaultModel);
}
/**
* Gets the model of the armor piece.
*
* @param entity The entity equipping the armor
* @param stack The item stack of the armor
* @param slot The slot which the armor is in
* @param defaultModel The default model that vanilla provides
* @return The model of the armor piece.
*/
@NotNull
public static HumanoidModel<LivingEntity> getArmorModel(LivingEntity entity, ItemStack stack, EquipmentSlot slot, HumanoidModel<LivingEntity> defaultModel) {
return ArmorRenderingRegistryImpl.getArmorModel(entity, stack, slot, defaultModel);
}
/**
* Gets the armor texture {@link net.minecraft.resources.ResourceLocation}.
*
* @param entity The entity equipping the armor
* @param stack The item stack of the armor
* @param slot The slot which the armor is in
* @param secondLayer True if using the second texture layer
* @param suffix The texture suffix, used in vanilla by {@link net.minecraft.world.item.DyeableArmorItem}
* @param defaultTexture The default vanilla texture identifier
* @return the custom armor texture identifier, return null to use the vanilla ones. Defaulted to the item's registry id.
*/
@NotNull
public static ResourceLocation getArmorTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot, boolean secondLayer, @Nullable String suffix, ResourceLocation defaultTexture) {
return ArmorRenderingRegistryImpl.getArmorTexture(entity, stack, slot, secondLayer, suffix, defaultTexture);
}
/**
* Gets the armor texture {@link net.minecraft.resources.ResourceLocation}.
*
* @param entity The entity equipping the armor
* @param stack The item stack of the armor
* @param slot The slot which the armor is in
* @param secondLayer True if using the second texture layer
* @param suffix The texture suffix, used in vanilla by {@link net.minecraft.world.item.DyeableArmorItem}
* @param defaultTexture The default vanilla texture identifier
* @return the custom armor texture identifier, return null to use the vanilla ones. Defaulted to the item's registry id.
*/
@NotNull
public static ResourceLocation getArmorTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot, boolean secondLayer, @Nullable String suffix, ResourceLocation defaultTexture) {
return ArmorRenderingRegistryImpl.getArmorTexture(entity, stack, slot, secondLayer, suffix, defaultTexture);
}
@FunctionalInterface
@Environment(EnvType.CLIENT)
public interface ModelProvider {
/**
* Gets the model of the armor piece.
*
* @param entity The entity equipping the armor
* @param stack The item stack of the armor
* @param slot The slot which the armor is in
* @param defaultModel The default vanilla armor model
* @return The model of the armor piece. Should never be null.
*/
@NotNull
HumanoidModel<LivingEntity> getArmorModel(LivingEntity entity, ItemStack stack, EquipmentSlot slot, HumanoidModel<LivingEntity> defaultModel);
}
@FunctionalInterface
@Environment(EnvType.CLIENT)
public interface ModelProvider {
/**
* Gets the model of the armor piece.
*
* @param entity The entity equipping the armor
* @param stack The item stack of the armor
* @param slot The slot which the armor is in
* @param defaultModel The default vanilla armor model
* @return The model of the armor piece. Should never be null.
*/
@NotNull
HumanoidModel<LivingEntity> getArmorModel(LivingEntity entity, ItemStack stack, EquipmentSlot slot, HumanoidModel<LivingEntity> defaultModel);
}
@FunctionalInterface
@Environment(EnvType.CLIENT)
public interface TextureProvider {
/**
* Gets the armor texture {@link net.minecraft.resources.ResourceLocation}.
*
* @param entity The entity equipping the armor
* @param stack The item stack of the armor
* @param slot The slot which the armor is in
* @param defaultTexture The default vanilla texture identifier
* @return the custom armor texture identifier. Should never be null.
*/
@NotNull
ResourceLocation getArmorTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot, boolean secondLayer, @Nullable String suffix, ResourceLocation defaultTexture);
}
@FunctionalInterface
@Environment(EnvType.CLIENT)
public interface TextureProvider {
/**
* Gets the armor texture {@link net.minecraft.resources.ResourceLocation}.
*
* @param entity The entity equipping the armor
* @param stack The item stack of the armor
* @param slot The slot which the armor is in
* @param defaultTexture The default vanilla texture identifier
* @return the custom armor texture identifier. Should never be null.
*/
@NotNull
ResourceLocation getArmorTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot, boolean secondLayer, @Nullable String suffix, ResourceLocation defaultTexture);
}
}