Skip to content

Commit

Permalink
fix lycanthrope slim body model
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Jan 12, 2024
1 parent 5ba5996 commit 6784a7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.teamlapen.werewolves.client.render;

import de.teamlapen.vampirism.client.renderer.entity.DualBipedRenderer;
import de.teamlapen.werewolves.entities.werewolf.HumanWerewolfEntity;
import de.teamlapen.werewolves.util.REFERENCE;
import net.minecraft.client.Minecraft;
Expand All @@ -10,26 +11,34 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;

@OnlyIn(Dist.CLIENT)
public class HumanWerewolfRenderer extends MobRenderer<HumanWerewolfEntity, PlayerModel<HumanWerewolfEntity>> {
public class HumanWerewolfRenderer extends DualBipedRenderer<HumanWerewolfEntity, PlayerModel<HumanWerewolfEntity>> {

private final ResourceLocation[] textures;
private final Pair<ResourceLocation, Boolean>[] textures;

public HumanWerewolfRenderer(EntityRendererProvider.Context context) {
super(context, new PlayerModel<>(context.bakeLayer(ModelLayers.PLAYER), false), 0.5f);
this.textures = Minecraft.getInstance().getResourceManager().listResources("textures/entity/human", s -> s.getPath().endsWith(".png")).keySet().stream().filter(r -> REFERENCE.MODID.equals(r.getNamespace())).toArray(ResourceLocation[]::new);
super(context, new PlayerModel<>(context.bakeLayer(ModelLayers.PLAYER), false), new PlayerModel<>(context.bakeLayer(ModelLayers.PLAYER_SLIM), true),0.5f);
this.textures = gatherTextures("textures/entity/human", true);
}

public ResourceLocation getHumanTexture(int entityId) {
return this.textures[entityId % textures.length];
@Override
protected Pair<ResourceLocation, Boolean> determineTextureAndModel(HumanWerewolfEntity entity) {
return textures[entity.getSkinType() % textures.length];
}

@Nonnull
@Override
public ResourceLocation getTextureLocation(@Nonnull HumanWerewolfEntity entity) {
return this.getHumanTexture(entity.getSkinType());
protected Pair<ResourceLocation, Boolean> @NotNull [] gatherTextures(@NotNull String dirPath, boolean required) {
Collection<ResourceLocation> hunterTextures = new ArrayList<>(Minecraft.getInstance().getResourceManager().listResources(dirPath, s -> s.getPath().endsWith(".png")).keySet());
Pair<ResourceLocation, Boolean>[] textures = separateSlimTextures(hunterTextures.stream().filter(r -> REFERENCE.MODID.equals(r.getNamespace())));
if (textures.length == 0 && required) {
throw new IllegalStateException("Must have at least one hunter texture: " + REFERENCE.MODID + ":" + dirPath + "/texture.png");
}
return textures;
}
}

0 comments on commit 6784a7a

Please sign in to comment.