91 lines
4.3 KiB
Java
91 lines
4.3 KiB
Java
package net.minecraft.client.renderer.entity.layers;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import net.fabricmc.api.EnvType;
|
|
import net.fabricmc.api.Environment;
|
|
import net.minecraft.client.model.ColorableHierarchicalModel;
|
|
import net.minecraft.client.model.EntityModel;
|
|
import net.minecraft.client.model.TropicalFishModelA;
|
|
import net.minecraft.client.model.TropicalFishModelB;
|
|
import net.minecraft.client.model.geom.EntityModelSet;
|
|
import net.minecraft.client.model.geom.ModelLayers;
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
|
import net.minecraft.client.renderer.entity.RenderLayerParent;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.world.entity.animal.TropicalFish;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class TropicalFishPatternLayer extends RenderLayer<TropicalFish, ColorableHierarchicalModel<TropicalFish>> {
|
|
private static final ResourceLocation KOB_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_a_pattern_1.png");
|
|
private static final ResourceLocation SUNSTREAK_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_a_pattern_2.png");
|
|
private static final ResourceLocation SNOOPER_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_a_pattern_3.png");
|
|
private static final ResourceLocation DASHER_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_a_pattern_4.png");
|
|
private static final ResourceLocation BRINELY_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_a_pattern_5.png");
|
|
private static final ResourceLocation SPOTTY_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_a_pattern_6.png");
|
|
private static final ResourceLocation FLOPPER_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_b_pattern_1.png");
|
|
private static final ResourceLocation STRIPEY_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_b_pattern_2.png");
|
|
private static final ResourceLocation GLITTER_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_b_pattern_3.png");
|
|
private static final ResourceLocation BLOCKFISH_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_b_pattern_4.png");
|
|
private static final ResourceLocation BETTY_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_b_pattern_5.png");
|
|
private static final ResourceLocation CLAYFISH_TEXTURE = ResourceLocation.withDefaultNamespace("textures/entity/fish/tropical_b_pattern_6.png");
|
|
private final TropicalFishModelA<TropicalFish> modelA;
|
|
private final TropicalFishModelB<TropicalFish> modelB;
|
|
|
|
public TropicalFishPatternLayer(RenderLayerParent<TropicalFish, ColorableHierarchicalModel<TropicalFish>> renderer, EntityModelSet modelSet) {
|
|
super(renderer);
|
|
this.modelA = new TropicalFishModelA<>(modelSet.bakeLayer(ModelLayers.TROPICAL_FISH_SMALL_PATTERN));
|
|
this.modelB = new TropicalFishModelB<>(modelSet.bakeLayer(ModelLayers.TROPICAL_FISH_LARGE_PATTERN));
|
|
}
|
|
|
|
public void render(
|
|
PoseStack poseStack,
|
|
MultiBufferSource buffer,
|
|
int packedLight,
|
|
TropicalFish livingEntity,
|
|
float limbSwing,
|
|
float limbSwingAmount,
|
|
float partialTicks,
|
|
float ageInTicks,
|
|
float netHeadYaw,
|
|
float headPitch
|
|
) {
|
|
TropicalFish.Pattern pattern = livingEntity.getVariant();
|
|
|
|
EntityModel<TropicalFish> entityModel = (EntityModel<TropicalFish>)(switch (pattern.base()) {
|
|
case SMALL -> this.modelA;
|
|
case LARGE -> this.modelB;
|
|
});
|
|
|
|
ResourceLocation resourceLocation = switch (pattern) {
|
|
case KOB -> KOB_TEXTURE;
|
|
case SUNSTREAK -> SUNSTREAK_TEXTURE;
|
|
case SNOOPER -> SNOOPER_TEXTURE;
|
|
case DASHER -> DASHER_TEXTURE;
|
|
case BRINELY -> BRINELY_TEXTURE;
|
|
case SPOTTY -> SPOTTY_TEXTURE;
|
|
case FLOPPER -> FLOPPER_TEXTURE;
|
|
case STRIPEY -> STRIPEY_TEXTURE;
|
|
case GLITTER -> GLITTER_TEXTURE;
|
|
case BLOCKFISH -> BLOCKFISH_TEXTURE;
|
|
case BETTY -> BETTY_TEXTURE;
|
|
case CLAYFISH -> CLAYFISH_TEXTURE;
|
|
};
|
|
int i = livingEntity.getPatternColor().getTextureDiffuseColor();
|
|
coloredCutoutModelCopyLayerRender(
|
|
this.getParentModel(),
|
|
entityModel,
|
|
resourceLocation,
|
|
poseStack,
|
|
buffer,
|
|
packedLight,
|
|
livingEntity,
|
|
limbSwing,
|
|
limbSwingAmount,
|
|
ageInTicks,
|
|
netHeadYaw,
|
|
headPitch,
|
|
partialTicks,
|
|
i
|
|
);
|
|
}
|
|
}
|