diff --git a/src/main/java/com/minelittlepony/client/model/ModelType.java b/src/main/java/com/minelittlepony/client/model/ModelType.java index 1974d0d9..6fe17d94 100644 --- a/src/main/java/com/minelittlepony/client/model/ModelType.java +++ b/src/main/java/com/minelittlepony/client/model/ModelType.java @@ -13,19 +13,7 @@ import com.minelittlepony.api.model.gear.IGear; import com.minelittlepony.api.pony.meta.Race; import com.minelittlepony.api.pony.meta.Wearable; import com.minelittlepony.client.model.armour.PonyArmourModel; -import com.minelittlepony.client.model.entity.BreezieModel; -import com.minelittlepony.client.model.entity.EnderStallionModel; -import com.minelittlepony.client.model.entity.GuardianPonyModel; -import com.minelittlepony.client.model.entity.IllagerPonyModel; -import com.minelittlepony.client.model.entity.ParaspriteModel; -import com.minelittlepony.client.model.entity.PiglinPonyModel; -import com.minelittlepony.client.model.entity.PillagerPonyModel; -import com.minelittlepony.client.model.entity.PonyArmourStandModel; -import com.minelittlepony.client.model.entity.SkeleponyModel; -import com.minelittlepony.client.model.entity.VillagerPonyModel; -import com.minelittlepony.client.model.entity.WitchPonyModel; -import com.minelittlepony.client.model.entity.ZomponyModel; -import com.minelittlepony.client.model.entity.ZomponyVillagerModel; +import com.minelittlepony.client.model.entity.*; import com.minelittlepony.client.model.entity.race.AlicornModel; import com.minelittlepony.client.model.entity.race.ChangelingModel; import com.minelittlepony.client.model.entity.race.EarthPonyModel; @@ -71,7 +59,8 @@ public final class ModelType { public static final ModelKey GUARDIAN = register("guardian", GuardianPonyModel::new); public static final ModelKey ENDERMAN = register("enderman", EnderStallionModel::new); public static final ModelKey> VEX = register("vex", ParaspriteModel::new); - public static final ModelKey> STRIDER = register("strider", ParaspriteModel::new); + public static final ModelKey> STRIDER = register("strider", SpikeModel::new); + public static final ModelKey> STRIDER_SADDLE = register("strider_saddle", SaddleModel::new); public static final ModelKey> ALLAY = register("allay", BreezieModel::new); public static final ModelKey> ELYTRA = register("elytra", PonyElytra::new); diff --git a/src/main/java/com/minelittlepony/client/model/entity/SaddleModel.java b/src/main/java/com/minelittlepony/client/model/entity/SaddleModel.java new file mode 100644 index 00000000..7afa3238 --- /dev/null +++ b/src/main/java/com/minelittlepony/client/model/entity/SaddleModel.java @@ -0,0 +1,27 @@ +package com.minelittlepony.client.model.entity; + +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.MathHelper; + +public class SaddleModel extends EntityModel { + + private ModelPart root; + + public SaddleModel(ModelPart tree) { + root = tree; + } + + @Override + public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) { + root.pivotY = -MathHelper.cos(move * 1.5f) * 2.0f * swing; + } + + @Override + public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) { + root.render(matrices, vertices, light, overlay, red, green, blue, alpha); + } +} diff --git a/src/main/java/com/minelittlepony/client/model/entity/SpikeModel.java b/src/main/java/com/minelittlepony/client/model/entity/SpikeModel.java new file mode 100644 index 00000000..78671604 --- /dev/null +++ b/src/main/java/com/minelittlepony/client/model/entity/SpikeModel.java @@ -0,0 +1,103 @@ +package com.minelittlepony.client.model.entity; + +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.passive.StriderEntity; +import net.minecraft.util.math.MathHelper; + +public class SpikeModel extends BipedEntityModel { + + private final ModelPart tail; + private final ModelPart tail2; + private final ModelPart tail3; + + public SpikeModel(ModelPart tree) { + super(tree); + tail = body.getChild("tail"); + tail2 = tail.getChild("tail2"); + tail3 = tail2.getChild("tail3"); + } + + @Override + public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) { + swing *= 2; + move *= 1.5F; + child = false; + + head.pivotX = 0; + head.pivotZ = 0; + head.pivotY = 0; + + super.setAngles(entity, move, swing, ticks, headYaw, headPitch); + + leftArm.pivotY++; + rightArm.pivotY++; + body.pitch += 0.15F; + + if ((entity instanceof StriderEntity strider && strider.isSaddled())) { + leftArm.pitch = 3.15F; + leftArm.yaw = 1; + rightArm.pitch = 3.15F; + rightArm.yaw = -1; + + head.pivotY += 4; + head.pivotZ = -3; + hat.pivotY += 4; + hat.pivotZ = -3; + + leftLeg.pitch += 0.4F; + rightLeg.pitch += 0.4F; + } else { + float flailAmount = 1 + (float)MathHelper.clamp(entity.getVelocity().y * 10, 0, 7); + + leftArm.roll -= 0.2F * flailAmount; + rightArm.roll += 0.2F * flailAmount; + + leftArm.pivotZ += 2; + leftArm.pitch -= 0.3F; + + rightArm.pivotZ += 2; + rightArm.pitch -= 0.3F; + + if (entity instanceof StriderEntity strider && strider.isCold()) { + float armMotion = (float)Math.sin(ticks / 10F) / 10F; + + leftArm.pitch = -1 - armMotion; + rightArm.pitch = -1 + armMotion; + + leftArm.yaw = 0.8F; + rightArm.yaw = -0.8F; + + leftArm.pivotZ -= 3; + rightArm.pivotZ -= 3; + } + } + + tail.pitch = (float)Math.sin(move) / 3F - 0.5F; + tail2.pitch = -tail.pitch / 2; + tail3.pitch = tail2.pitch / 2; + + tail.yaw = (float)Math.sin(ticks / 20F) / 40 + (float)Math.sin(move / 20F) / 4; + tail2.yaw = tail.yaw / 2; + tail3.yaw = tail2.yaw / 2; + + for (var part : this.getHeadParts()) { + part.pivotY += 7; + } + + for (var part : this.getBodyParts()) { + part.pivotY += 7; + } + } +} + + + + + + + + + + diff --git a/src/main/java/com/minelittlepony/client/pony/BackgroundPonyList.java b/src/main/java/com/minelittlepony/client/pony/BackgroundPonyList.java index 39e71121..93d7ec35 100644 --- a/src/main/java/com/minelittlepony/client/pony/BackgroundPonyList.java +++ b/src/main/java/com/minelittlepony/client/pony/BackgroundPonyList.java @@ -15,7 +15,7 @@ import java.util.UUID; /** * All currently loaded background ponies. */ -class BackgroundPonyList implements VariatedTextureSupplier.VariatedTexture { +class BackgroundPonyList { /** * All currently loaded background ponies. */ @@ -25,6 +25,7 @@ class BackgroundPonyList implements VariatedTextureSupplier.VariatedTexture { public BackgroundPonyList(Identifier id) { this.id = id; + reloadAll(MinecraftClient.getInstance().getResourceManager()); } public Identifier getId(UUID uuid) { @@ -47,9 +48,4 @@ class BackgroundPonyList implements VariatedTextureSupplier.VariatedTexture { return MinecraftClient.getInstance().player != null && MinecraftClient.getInstance().player.getUuid().equals(uuid); } - - @Override - public Identifier get(UUID uuid) { - return getId(uuid); - } } diff --git a/src/main/java/com/minelittlepony/client/pony/PonyManager.java b/src/main/java/com/minelittlepony/client/pony/PonyManager.java index 992d96e9..97d17532 100644 --- a/src/main/java/com/minelittlepony/client/pony/PonyManager.java +++ b/src/main/java/com/minelittlepony/client/pony/PonyManager.java @@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit; public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloadListener { private static final Identifier ID = new Identifier("minelittlepony", "background_ponies"); + public static final Identifier BACKGROUND_PONIES = new Identifier("minelittlepony", "textures/entity/pony"); private final PonyConfig config; @@ -100,7 +101,7 @@ public class PonyManager implements IPonyManager, SimpleSynchronousResourceReloa @Override public IPony getBackgroundPony(UUID uuid) { - return ((Pony)getPony(MineLittlePony.getInstance().getVariatedTextures().get(VariatedTextureSupplier.BACKGROUND_PONIES).get(uuid))).defaulted(); + return ((Pony)getPony(MineLittlePony.getInstance().getVariatedTextures().get(BACKGROUND_PONIES, uuid))).defaulted(); } @Override diff --git a/src/main/java/com/minelittlepony/client/pony/VariatedTextureSupplier.java b/src/main/java/com/minelittlepony/client/pony/VariatedTextureSupplier.java index d1058bc0..620ccc2e 100644 --- a/src/main/java/com/minelittlepony/client/pony/VariatedTextureSupplier.java +++ b/src/main/java/com/minelittlepony/client/pony/VariatedTextureSupplier.java @@ -12,21 +12,11 @@ import java.util.UUID; public class VariatedTextureSupplier implements SimpleSynchronousResourceReloadListener { private static final Identifier ID = new Identifier("minelittlepony", "variated_textures"); - public static final Identifier BACKGROUND_PONIES = new Identifier("minelittlepony", "textures/entity/pony"); - public static final Identifier BREEZIE_PONIES = new Identifier("minelittlepony", "textures/entity/allay/pony"); - public static final Identifier PARASPRITE_PONIES = new Identifier("minelittlepony", "textures/entity/illager/vex_pony"); - private final Map entries = new HashMap<>(); - public VariatedTextureSupplier() { - get(BACKGROUND_PONIES); - get(BREEZIE_PONIES); - get(PARASPRITE_PONIES); - } - @Override public void reload(ResourceManager manager) { - entries.forEach((key, value) -> value.reloadAll(manager)); + entries.clear(); } @Override @@ -34,15 +24,15 @@ public class VariatedTextureSupplier implements SimpleSynchronousResourceReloadL return ID; } - public VariatedTexture get(Identifier id) { + private BackgroundPonyList get(Identifier id) { return entries.computeIfAbsent(id, BackgroundPonyList::new); } - public interface VariatedTexture { - Identifier get(UUID uuid); + public Identifier get(Identifier poolId, UUID seed) { + return get(poolId).getId(seed); + } - default Identifier get(Entity entity) { - return get(entity.getUuid()); - } + public Identifier get(Identifier poolId, Entity entity) { + return get(poolId, entity.getUuid()); } } diff --git a/src/main/java/com/minelittlepony/client/render/entity/AllayRenderer.java b/src/main/java/com/minelittlepony/client/render/entity/AllayRenderer.java index 4a6cf75a..6150065c 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/AllayRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entity/AllayRenderer.java @@ -10,12 +10,13 @@ import net.minecraft.util.math.BlockPos; import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.client.model.ModelType; import com.minelittlepony.client.model.entity.BreezieModel; -import com.minelittlepony.client.pony.VariatedTextureSupplier; /** * AKA a breezie :D */ public class AllayRenderer extends MobEntityRenderer> { + public static final Identifier BREEZIE_PONIES = new Identifier("minelittlepony", "textures/entity/allay/pony"); + public AllayRenderer(EntityRendererFactory.Context context) { super(context, ModelType.ALLAY.createModel(), 0.4f); addFeature(new HeldItemFeatureRenderer>(this, context.getHeldItemRenderer())); @@ -23,7 +24,7 @@ public class AllayRenderer extends MobEntityRenderer> { - private static final Identifier NORMAL = new Identifier("minelittlepony", "textures/entity/strider/strider_pony.png"); - private static final Identifier CONFUSED = new Identifier("minelittlepony", "textures/entity/strider/strider_confused_pony.png"); +public class StriderRenderer extends MobEntityRenderer> { + public static final Identifier DRAGON_PONIES = new Identifier("minelittlepony", "textures/entity/strider/pony"); + public static final Identifier COLD_DRAGON_PONIES = new Identifier("minelittlepony", "textures/entity/strider/cold_pony"); private static final Identifier SADDLE = new Identifier("minelittlepony", "textures/entity/strider/strider_saddle_pony.png"); public StriderRenderer(EntityRendererFactory.Context context) { super(context, ModelType.STRIDER.createModel(), 0.5F); - addFeature(new SaddleFeatureRenderer<>(this, ModelType.STRIDER.createModel(), SADDLE)); + addFeature(new SaddleFeatureRenderer<>(this, ModelType.STRIDER_SADDLE.createModel(), SADDLE)); } @Override public Identifier getTexture(StriderEntity entity) { - return entity.isCold() ? CONFUSED : NORMAL; + return MineLittlePony.getInstance().getVariatedTextures().get(entity.isCold() ? COLD_DRAGON_PONIES : DRAGON_PONIES, entity); } @Override diff --git a/src/main/java/com/minelittlepony/client/render/entity/VexRenderer.java b/src/main/java/com/minelittlepony/client/render/entity/VexRenderer.java index 91806be9..fce2f6ba 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/VexRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entity/VexRenderer.java @@ -8,9 +8,10 @@ import net.minecraft.util.Identifier; import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.client.model.ModelType; import com.minelittlepony.client.model.entity.ParaspriteModel; -import com.minelittlepony.client.pony.VariatedTextureSupplier; public class VexRenderer extends MobEntityRenderer> { + public static final Identifier PARASPRITE_PONIES = new Identifier("minelittlepony", "textures/entity/illager/vex_pony"); + public VexRenderer(EntityRendererFactory.Context context) { super(context, ModelType.VEX.createModel(), 0.3F); } @@ -22,7 +23,7 @@ public class VexRenderer extends MobEntityRenderer