Skip to content

Commit

Permalink
add more werewolf skins
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed May 22, 2024
1 parent ae26603 commit 5ec9db2
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class WerewolfForm {
public static final Codec<WerewolfForm> CODEC = Codec.STRING.xmap(WerewolfForm::getForm, WerewolfForm::getName);
public static final WerewolfForm NONE = new WerewolfForm("none", null, true, false, 0, 0F, true);
public static final WerewolfForm HUMAN = new WerewolfForm("human", null, true, true, 3, 0.05F, true);
public static final WerewolfForm BEAST = new WerewolfForm("beast", WerewolfSize.BEAST, false, true, 9, 0.2F, true);
public static final WerewolfForm BEAST4L = new WerewolfForm("beast4l", WerewolfSize.BEAST, false, true, 9, 0.3F, false);
public static final WerewolfForm SURVIVALIST = new WerewolfForm("survivalist", WerewolfSize.SURVIVAL, false, true, 9, 0.4F, false);
public static final WerewolfForm BEAST = new WerewolfForm("beast", WerewolfSize.BEAST, false, true, 11, 0.2F, true);
public static final WerewolfForm BEAST4L = new WerewolfForm("beast4l", WerewolfSize.BEAST, false, true, 11, 0.3F, false);
public static final WerewolfForm SURVIVALIST = new WerewolfForm("survivalist", WerewolfSize.SURVIVAL, false, true, 11, 0.4F, false);

@Nonnull
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import de.teamlapen.werewolves.util.REFERENCE;
import de.teamlapen.werewolves.util.AlphanumericComparator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.model.geom.ModelPart;
Expand Down Expand Up @@ -92,7 +93,7 @@ public void translateToHand(@Nonnull HumanoidArm arm, @Nonnull PoseStack stack)
}

protected static List<ResourceLocation> getTextures(String texturePath) {
return Minecraft.getInstance().getResourceManager().listResources(texturePath, s -> s.getPath().endsWith(".png")).keySet().stream().filter(r -> REFERENCE.MODID.equals(r.getNamespace())).collect(Collectors.toList());
return Minecraft.getInstance().getResourceManager().listResources(texturePath, s -> s.getPath().endsWith(".png")).keySet().stream().sorted(new AlphanumericComparator()).filter(r -> REFERENCE.MODID.equals(r.getNamespace())).collect(Collectors.toList());
}

protected HumanoidArm getAttackArm(T pEntity) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package de.teamlapen.werewolves.util;

import net.minecraft.resources.ResourceLocation;

import java.util.Comparator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class AlphanumericComparator implements Comparator<ResourceLocation> {

private final Pattern p = Pattern.compile("(\\D*)(\\d*)");

@Override
public int compare(ResourceLocation s, ResourceLocation t1) {
String first = s.toString();
String second = t1.toString();
Matcher m1 = p.matcher(first);
Matcher m2 = p.matcher(second);

// The loop is required because the string can contain multiple numeric parts,
// e.g., beast2part10
while (m1.find() && m2.find()) {
// Non-numeric part (could be empty)
int nonNumericCompare = m1.group(1).compareTo(m2.group(1));
if (nonNumericCompare != 0) {
return nonNumericCompare;
}

// Numeric part (could be empty)
if (!m1.group(2).isEmpty() && !m2.group(2).isEmpty()) {
int numericCompare = Integer.compare(Integer.parseInt(m1.group(2)), Integer.parseInt(m2.group(2)));
if (numericCompare != 0) {
return numericCompare;
}
}
}

// Handle if one string is a prefix of the other.
// E.g., beast2 and beast2part10
if (m1.hitEnd() && m2.hitEnd()) {
return 0;
} else {
return m1.hitEnd() ? -1 : 1;
}

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5ec9db2

Please sign in to comment.