mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-03-14 15:40:06 +01:00
Compare commits
4 commits
4.12.1-bet
...
1.20.2
Author | SHA1 | Date | |
---|---|---|---|
|
57754d8dec | ||
|
ec8f92e151 | ||
|
e21ce62631 | ||
|
c78cf32bd4 |
123 changed files with 1049 additions and 1298 deletions
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
@ -1,38 +0,0 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[BUG]"
|
||||
labels: bug
|
||||
assignees: Sollace
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Steps to reproduce**
|
||||
Help us figure out what you did to get this issue
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Version Information:**
|
||||
- Minecraft Version: [e.g. 1.20.5]
|
||||
- Mine Little Pony Version:
|
||||
|
||||
**Mod Loader:**
|
||||
- [ ] Fabric
|
||||
- [ ] Quilt
|
||||
- [ ] Neoforge (with connector)
|
||||
|
||||
**Client/Server Logs**
|
||||
If applicable, add log files by uploading them as attachments or put them below.
|
||||
|
||||
<details>
|
||||
```
|
||||
**Paste logs here**
|
||||
```
|
||||
</details>
|
26
.github/ISSUE_TEMPLATE/feature_request.md
vendored
26
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
@ -1,26 +0,0 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: Sollace
|
||||
|
||||
---
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Version Information:**
|
||||
- Minecraft Version: [e.g. 1.20.5]
|
||||
- Mine Little Pony Version:
|
||||
|
||||
**Mod Loader:**
|
||||
- [ ] Fabric
|
||||
- [ ] Quilt
|
||||
- [ ] Neoforge (with connector)
|
2
.github/workflows/gradle-build.yml
vendored
2
.github/workflows/gradle-build.yml
vendored
|
@ -12,7 +12,7 @@ jobs:
|
|||
- name: Set up JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
- name: Build Gradle
|
||||
uses: eskatos/gradle-command-action@v1
|
||||
with:
|
||||
|
|
2
.github/workflows/gradle-check.yml
vendored
2
.github/workflows/gradle-check.yml
vendored
|
@ -12,7 +12,7 @@ jobs:
|
|||
- name: Set up JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
- name: Build Gradle
|
||||
uses: eskatos/gradle-command-action@v1
|
||||
with:
|
||||
|
|
2
.github/workflows/gradle-publish.yml
vendored
2
.github/workflows/gradle-publish.yml
vendored
|
@ -16,7 +16,7 @@ jobs:
|
|||
- name: Set up JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
- name: Publish Maven Jar
|
||||
env:
|
||||
ACCESS_KEY: ${{ secrets.ACCESS_KEY }}
|
||||
|
|
8
.gitmodules
vendored
8
.gitmodules
vendored
|
@ -2,11 +2,3 @@
|
|||
path = skins
|
||||
url = https://github.com/MineLittlePony/Community-Skin-Pack.git
|
||||
branch = master
|
||||
[submodule "plugins/ShowMeYourPonies"]
|
||||
path = plugins/ShowMeYourPonies
|
||||
url = https://github.com/MineLittlePony/ShowMeYourPonies.git
|
||||
branch = 1.20.5
|
||||
[submodule "plugins/Sockies"]
|
||||
path = plugins/Sockies
|
||||
url = https://github.com/MineLittlePony/Sockies.git
|
||||
branch = 1.21
|
||||
|
|
15
build.gradle
15
build.gradle
|
@ -4,7 +4,7 @@ buildscript {
|
|||
}
|
||||
}
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.6-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.5-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
id 'com.modrinth.minotaur' version '2.+'
|
||||
id 'org.ajoberstar.reckon' version '0.13.1'
|
||||
|
@ -13,13 +13,13 @@ apply plugin: 'io.github.dexman545.outlet'
|
|||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
outlet.allowSnapshotsForProject = false
|
||||
outlet.mcVersionRange = ">=${project.minecraft_version}"
|
||||
outlet.mcVersionRange = project.minecraft_version_range
|
||||
|
||||
group = project.group
|
||||
description = project.displayname
|
||||
|
@ -84,7 +84,7 @@ processResources {
|
|||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version.toString(),
|
||||
"minecraftVersion": ">=${project.minecraft_version}",
|
||||
"minecraftVersion": project.minecraft_version_range,
|
||||
"loaderVersion": ">=${project.loader_version}",
|
||||
"fabricVersion": ">=${project.fabric_version}",
|
||||
"kirinVersion": ">=${project.kirin_version}",
|
||||
|
@ -123,10 +123,9 @@ modrinth {
|
|||
gameVersions.add ver
|
||||
}
|
||||
dependencies {
|
||||
required.project 'P7dR8mSH' // Fabric API
|
||||
required.project '9aNz8Zqn' // Kirin
|
||||
optional.project 'FzE9gshV' // HD Skins
|
||||
optional.project 'h9pJxJR9' // Big Pony
|
||||
required.project 'P7dR8mSH'
|
||||
optional.project 'FzE9gshV'
|
||||
optional.project 'h9pJxJR9'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ org.gradle.daemon=false
|
|||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.21
|
||||
yarn_mappings=1.21+build.9
|
||||
loader_version=0.15.11
|
||||
fabric_version=0.100.7+1.21
|
||||
minecraft_version=1.20.2
|
||||
yarn_mappings=1.20.2+build.4
|
||||
loader_version=0.15.1
|
||||
fabric_version=0.91.1+1.20.2
|
||||
|
||||
# Mod Properties
|
||||
group=com.minelittlepony
|
||||
|
@ -15,11 +15,12 @@ org.gradle.daemon=false
|
|||
description=Mine Little Pony turns players and mobs into ponies. Press F9 ingame to access settings.
|
||||
|
||||
# Publishing
|
||||
minecraft_version_range=>=1.20.2
|
||||
modrinth_loader_type=fabric
|
||||
modrinth_project_id=JBjInUXM
|
||||
|
||||
# Dependencies
|
||||
modmenu_version=11.0.0-beta.1
|
||||
kirin_version=1.19.0+1.21
|
||||
hd_skins_version=6.13.0+1.21
|
||||
mson_version=1.10.0+1.21
|
||||
modmenu_version=8.0.0
|
||||
kirin_version=1.16.1+1.20.2
|
||||
hd_skins_version=6.12.4+1.20.2
|
||||
mson_version=1.9.3+1.20.2
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 055fd831ee57bb17c44042ef28f7f57a5fc0333a
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 9b57eec91c820844bd1fc7a0423f4049405b2290
|
|
@ -1,16 +1,13 @@
|
|||
package com.minelittlepony.api.config;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.minelittlepony.api.pony.meta.*;
|
||||
import com.minelittlepony.common.client.gui.VisibilityMode;
|
||||
import com.minelittlepony.common.util.GamePaths;
|
||||
import com.minelittlepony.common.util.settings.*;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Storage container for MineLP client settings.
|
||||
|
@ -88,13 +85,8 @@ public class PonyConfig extends Config {
|
|||
.addComment("ON - always show")
|
||||
.addComment("OFF - never show");
|
||||
|
||||
public final Setting<HashSet<Identifier>> forwardHoldingItems = value("customisation", "forwardHoldingItems", HashSet::new, Identifier.class)
|
||||
.addComment("Contains a list of item ids that should preserve orientation")
|
||||
.addComment("when held in a unicorn's magical aura in first person");
|
||||
|
||||
public PonyConfig(Path path) {
|
||||
super(new HeirarchicalJsonConfigAdapter(new GsonBuilder()
|
||||
.registerTypeAdapter(Identifier.class, new ToStringAdapter<>(Identifier::toString, Identifier::of))), path);
|
||||
super(HEIRARCHICAL_JSON_ADAPTER, path);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,10 @@ import net.fabricmc.api.EnvType;
|
|||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginConnectionEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.*;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
@ -18,6 +17,8 @@ import com.minelittlepony.api.pony.PonyData;
|
|||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class Channel {
|
||||
private static final Identifier CLIENT_PONY_DATA = new Identifier("minelittlepony", "pony_data");
|
||||
private static final Identifier REQUEST_PONY_DATA = new Identifier("minelittlepony", "request_pony_data");
|
||||
private static final Logger LOGGER = LogManager.getLogger("MineLittlePony:Networking");
|
||||
|
||||
private static boolean registered;
|
||||
|
@ -26,24 +27,20 @@ public class Channel {
|
|||
ClientLoginConnectionEvents.INIT.register((handler, client) -> {
|
||||
registered = false;
|
||||
});
|
||||
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||
LOGGER.info("Sending consent packet to " + handler.getPlayer().getName().getString());
|
||||
sender.sendPacket(PonyDataRequest.INSTANCE);
|
||||
|
||||
sender.sendPacket(REQUEST_PONY_DATA, PacketByteBufs.empty());
|
||||
});
|
||||
|
||||
PayloadTypeRegistry.playS2C().register(PonyDataRequest.ID, PonyDataRequest.CODEC);
|
||||
PayloadTypeRegistry.playS2C().register(PonyDataPayload.ID, PonyDataPayload.CODEC);
|
||||
PayloadTypeRegistry.playC2S().register(PonyDataPayload.ID, PonyDataPayload.CODEC);
|
||||
|
||||
ClientPlayNetworking.registerGlobalReceiver(PonyDataRequest.ID, (packet, context) -> {
|
||||
ClientPlayNetworking.registerGlobalReceiver(REQUEST_PONY_DATA, (client, handler, ignored, sender) -> {
|
||||
registered = true;
|
||||
LOGGER.info("Server has just consented");
|
||||
});
|
||||
|
||||
ServerPlayNetworking.registerGlobalReceiver(PonyDataPayload.ID, (packet, context) -> {
|
||||
context.player().server.execute(() -> {
|
||||
PonyDataCallback.EVENT.invoker().onPonyDataAvailable(context.player(), packet.data(), EnvType.SERVER);
|
||||
ServerPlayNetworking.registerGlobalReceiver(CLIENT_PONY_DATA, (server, player, ignore, buffer, ignore2) -> {
|
||||
PonyData packet = MsgPonyData.read(buffer);
|
||||
server.execute(() -> {
|
||||
PonyDataCallback.EVENT.invoker().onPonyDataAvailable(player, packet, EnvType.SERVER);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -60,31 +57,7 @@ public class Channel {
|
|||
throw new RuntimeException("Client packet send called by the server");
|
||||
}
|
||||
|
||||
ClientPlayNetworking.send(new PonyDataPayload(packet));
|
||||
ClientPlayNetworking.send(CLIENT_PONY_DATA, MsgPonyData.write(packet, PacketByteBufs.create()));
|
||||
return true;
|
||||
}
|
||||
|
||||
record PonyDataPayload(PonyData data) implements CustomPayload {
|
||||
public static final Id<PonyDataPayload> ID = new Id<>(Identifier.of("minelittlepony", "pony_data"));
|
||||
public static final PacketCodec<PacketByteBuf, PonyDataPayload> CODEC = CustomPayload.codecOf(
|
||||
(p, buffer) -> MsgPonyData.write(p.data(), buffer),
|
||||
buffer -> new PonyDataPayload(MsgPonyData.read(buffer))
|
||||
);
|
||||
|
||||
@Override
|
||||
public Id<PonyDataPayload> getId() {
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
|
||||
record PonyDataRequest() implements CustomPayload {
|
||||
public static final PonyDataRequest INSTANCE = new PonyDataRequest();
|
||||
private static final Id<PonyDataRequest> ID = new Id<>(Identifier.of("minelittlepony", "request_pony_data"));
|
||||
public static final PacketCodec<PacketByteBuf, PonyDataRequest> CODEC = PacketCodec.unit(INSTANCE);
|
||||
|
||||
@Override
|
||||
public Id<? extends CustomPayload> getId() {
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,13 +7,8 @@ import net.minecraft.entity.Entity;
|
|||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
|
||||
/**
|
||||
* Event triggered when a pony model's state is being evaluated.
|
||||
* <p>
|
||||
* Subscribers have the option to read the pony model's attributes or modify them if neccessary to
|
||||
* allow for custom animations.
|
||||
*/
|
||||
public interface PonyModelPrepareCallback {
|
||||
|
||||
Event<PonyModelPrepareCallback> EVENT = EventFactory.createArrayBacked(PonyModelPrepareCallback.class, listeners -> (entity, model, mode) -> {
|
||||
for (PonyModelPrepareCallback event : listeners) {
|
||||
event.onPonyModelPrepared(entity, model, mode);
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package com.minelittlepony.api.events;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
|
||||
/**
|
||||
* Event for mods that want to replace the skin being used by a pony.
|
||||
*/
|
||||
public interface PonySkinResolver {
|
||||
Event<PonySkinResolver> EVENT = EventFactory.createArrayBacked(PonySkinResolver.class, listeners -> (entity, pony, result) -> {
|
||||
for (PonySkinResolver event : listeners) {
|
||||
result = event.onPonySkinResolving(entity, pony, result);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
@Nullable
|
||||
Identifier onPonySkinResolving(Entity entity, PonyLookup ponyLookup, @Nullable Identifier previousResult);
|
||||
|
||||
interface PonyLookup {
|
||||
Pony getPony(Identifier skin);
|
||||
}
|
||||
}
|
|
@ -61,7 +61,7 @@ public class ModelAttributes {
|
|||
*/
|
||||
public boolean isLeftHanded;
|
||||
/**
|
||||
* True if the model is riding on the back of another pony.
|
||||
* True if the model is sitting as in boats.
|
||||
*/
|
||||
public boolean isRidingInteractive;
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.api.model;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public interface PreviewModel {
|
||||
Identifier getForm();
|
||||
boolean forceSeapony();
|
||||
|
||||
boolean forceNirik();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public interface SubModel {
|
|||
/**
|
||||
* Renders this model component.
|
||||
*/
|
||||
void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes);
|
||||
void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, float red, float green, float blue, float alpha, ModelAttributes attributes);
|
||||
|
||||
/**
|
||||
* Sets whether this part should be rendered.
|
||||
|
|
|
@ -27,14 +27,14 @@ public abstract class AbstractGearModel extends Model implements Gear {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, UUID interpolatorId) {
|
||||
render(stack, vertices, overlay, light, color);
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||
render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer renderContext, int overlay, int light, int color) {
|
||||
public void render(MatrixStack stack, VertexConsumer renderContext, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
parts.forEach(part -> {
|
||||
part.render(stack, renderContext, overlay, light, color);
|
||||
part.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ public interface Gear {
|
|||
/**
|
||||
* Renders this model component.
|
||||
*/
|
||||
void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, UUID interpolatorId);
|
||||
void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId);
|
||||
|
||||
/**
|
||||
* A render context for instance of IGear.
|
||||
|
|
|
@ -3,34 +3,30 @@ package com.minelittlepony.api.pony;
|
|||
import net.minecraft.client.util.DefaultSkinHelper;
|
||||
import net.minecraft.client.util.SkinTextures;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class DefaultPonySkinHelper {
|
||||
public static final Identifier STEVE = id("textures/entity/player/wide/steve_pony.png");
|
||||
public static final Identifier STEVE = new Identifier("minelittlepony", "textures/entity/player/wide/steve_pony.png");
|
||||
|
||||
public static final Identifier SEAPONY_SKIN_TYPE_ID = id("seapony");
|
||||
public static final Identifier NIRIK_SKIN_TYPE_ID = id("nirik");
|
||||
public static final Identifier SEAPONY_SKIN_TYPE_ID = new Identifier("minelp", "seapony");
|
||||
public static final Identifier NIRIK_SKIN_TYPE_ID = new Identifier("minelp", "nirik");
|
||||
|
||||
private static final Function<SkinTextures, SkinTextures> SKINS = Util.memoize(original -> new SkinTextures(
|
||||
id(original.texture().getPath().replace(".png", "_pony.png")),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
original.model(),
|
||||
false
|
||||
));
|
||||
|
||||
public static Identifier id(String name) {
|
||||
return Identifier.of("minelittlepony", name);
|
||||
}
|
||||
private static final Map<SkinTextures, SkinTextures> SKINS = new HashMap<>();
|
||||
|
||||
public static SkinTextures getTextures(SkinTextures original) {
|
||||
return SKINS.apply(original);
|
||||
return SKINS.computeIfAbsent(original, o -> {
|
||||
return new SkinTextures(
|
||||
new Identifier("minelittlepony", original.texture().getPath().replace(".png", "_pony.png")),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
original.model(),
|
||||
false
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public static String getModelType(UUID id) {
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
package com.minelittlepony.api.pony;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.client.render.entity.PlayerPonyRenderer;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* The different forms a pony can take.
|
||||
* <p>
|
||||
* The default is land, which is your typical pony with four legs.
|
||||
* Other options are water (seaponies that go shoop-de-doo)
|
||||
* And Niriks (the burning form of kirins)
|
||||
*/
|
||||
public record PonyForm(Identifier id, Predicate<PlayerEntity> shouldApply, RendererFactory<?> factory) {
|
||||
public static final Identifier DEFAULT = DefaultPonySkinHelper.id("land");
|
||||
public static final Identifier SEAPONY = DefaultPonySkinHelper.id("seapony");
|
||||
public static final Identifier NIRIK = DefaultPonySkinHelper.id("nirik");
|
||||
|
||||
public static final List<Identifier> VALUES = new ArrayList<>();
|
||||
public static final Map<Identifier, PonyForm> REGISTRY = new HashMap<>();
|
||||
|
||||
public static void register(Identifier id, Predicate<PlayerEntity> shouldApply, RendererFactory<?> factory) {
|
||||
VALUES.add(0, id);
|
||||
REGISTRY.put(id, new PonyForm(id, shouldApply, factory));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PonyForm of(PlayerEntity player) {
|
||||
for (Identifier id : VALUES) {
|
||||
PonyForm form = REGISTRY.get(id);
|
||||
if (form != null && form.shouldApply().test(player)) {
|
||||
return form;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface RendererFactory<T extends PlayerPonyRenderer> {
|
||||
T create(EntityRendererFactory.Context context, boolean slimArms);
|
||||
}
|
||||
}
|
|
@ -86,9 +86,16 @@ public final class PonyPosture {
|
|||
return isSitting(entity) && getMountPony(entity).map(Pony::race).orElse(Race.HUMAN) != Race.HUMAN;
|
||||
}
|
||||
|
||||
public static boolean isSeaponyModifier(LivingEntity entity) {
|
||||
if (entity instanceof PreviewModel preview) {
|
||||
return preview.forceSeapony();
|
||||
}
|
||||
return hasSeaponyForm(entity) && isPartiallySubmerged(entity);
|
||||
}
|
||||
|
||||
public static boolean hasSeaponyForm(LivingEntity entity) {
|
||||
if (entity instanceof PreviewModel preview) {
|
||||
return preview.getForm() == PonyForm.SEAPONY;
|
||||
return preview.forceSeapony();
|
||||
}
|
||||
return Pony.getManager().getPony(entity).filter(pony -> {
|
||||
return (pony.race() == Race.SEAPONY
|
||||
|
@ -97,9 +104,17 @@ public final class PonyPosture {
|
|||
}).isPresent();
|
||||
}
|
||||
|
||||
public static boolean isNirikModifier(LivingEntity entity) {
|
||||
if (entity instanceof PreviewModel preview) {
|
||||
return preview.forceNirik();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasNirikForm(LivingEntity entity) {
|
||||
if (entity instanceof PreviewModel preview) {
|
||||
return preview.getForm() == PonyForm.NIRIK;
|
||||
return preview.forceNirik();
|
||||
}
|
||||
return Pony.getManager().getPony(entity).filter(pony -> {
|
||||
return (pony.race() == Race.KIRIN
|
||||
|
|
|
@ -27,7 +27,7 @@ public record Flags<T extends Enum<T> & TValue<T>> (
|
|||
for (int i = 0; i < length; i++) {
|
||||
values.add(all[buffer.readInt()]);
|
||||
}
|
||||
return of(def, buffer.readInt(), values);
|
||||
return new Flags<>(def, values, buffer.readInt());
|
||||
}
|
||||
|
||||
public void write(PacketByteBuf buffer) {
|
||||
|
|
|
@ -3,22 +3,20 @@ package com.minelittlepony.api.pony.meta;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
|
||||
import com.minelittlepony.api.pony.DefaultPonySkinHelper;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public enum Wearable implements TValue<Wearable> {
|
||||
NONE (0x00, null),
|
||||
CROWN (0x16, DefaultPonySkinHelper.id("textures/models/crown.png")),
|
||||
MUFFIN (0x32, DefaultPonySkinHelper.id("textures/models/muffin.png")),
|
||||
HAT (0x64, Identifier.ofVanilla("textures/entity/witch.png")),
|
||||
ANTLERS (0x96, DefaultPonySkinHelper.id("textures/models/antlers.png")),
|
||||
SADDLE_BAGS_LEFT (0xC6, DefaultPonySkinHelper.id("textures/models/saddlebags.png")),
|
||||
SADDLE_BAGS_RIGHT (0xC7, DefaultPonySkinHelper.id("textures/models/saddlebags.png")),
|
||||
SADDLE_BAGS_BOTH (0xC8, DefaultPonySkinHelper.id("textures/models/saddlebags.png")),
|
||||
STETSON (0xFA, DefaultPonySkinHelper.id("textures/models/stetson.png"));
|
||||
CROWN (0x16, new Identifier("minelittlepony", "textures/models/crown.png")),
|
||||
MUFFIN (0x32, new Identifier("minelittlepony", "textures/models/muffin.png")),
|
||||
HAT (0x64, new Identifier("textures/entity/witch.png")),
|
||||
ANTLERS (0x96, new Identifier("minelittlepony", "textures/models/antlers.png")),
|
||||
SADDLE_BAGS_LEFT (0xC6, new Identifier("minelittlepony", "textures/models/saddlebags.png")),
|
||||
SADDLE_BAGS_RIGHT (0xC7, new Identifier("minelittlepony", "textures/models/saddlebags.png")),
|
||||
SADDLE_BAGS_BOTH (0xC8, new Identifier("minelittlepony", "textures/models/saddlebags.png")),
|
||||
STETSON (0xFA, new Identifier("minelittlepony", "textures/models/stetson.png"));
|
||||
|
||||
private int triggerValue;
|
||||
|
||||
|
@ -31,7 +29,7 @@ public enum Wearable implements TValue<Wearable> {
|
|||
|
||||
Wearable(int pixel, Identifier texture) {
|
||||
triggerValue = pixel;
|
||||
id = DefaultPonySkinHelper.id(name().toLowerCase(Locale.ROOT));
|
||||
id = new Identifier("minelittlepony", name().toLowerCase(Locale.ROOT));
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class HorseCam {
|
|||
public static float rescaleCameraPitch(double toHeight, float originalPitch) {
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
PlayerEntity player = client.player;
|
||||
client.gameRenderer.updateCrosshairTarget(client.getRenderTickCounter().getTickDelta(false));
|
||||
client.gameRenderer.updateTargetedEntity(client.getTickDelta());
|
||||
HitResult hit = client.crosshairTarget;
|
||||
|
||||
if (client.targetedEntity != null) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.minelittlepony.client.render.PonyRenderDispatcher;
|
|||
import com.minelittlepony.common.client.gui.VisibilityMode;
|
||||
import com.minelittlepony.common.client.gui.element.Button;
|
||||
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
|
||||
import com.minelittlepony.common.event.ClientReadyCallback;
|
||||
import com.minelittlepony.common.event.ScreenInitCallback;
|
||||
import com.minelittlepony.common.event.SkinFilterCallback;
|
||||
import com.minelittlepony.common.util.GamePaths;
|
||||
|
@ -47,7 +48,6 @@ public class MineLittlePony implements ClientModInitializer {
|
|||
private final KeyBinding keyBinding = new KeyBinding("key.minelittlepony.settings", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_F9, "key.categories.misc");
|
||||
|
||||
private final PonyRenderDispatcher renderDispatcher = new PonyRenderDispatcher();
|
||||
private boolean initialized;
|
||||
|
||||
private boolean hasHdSkins;
|
||||
private boolean hasModMenu;
|
||||
|
@ -63,10 +63,6 @@ public class MineLittlePony implements ClientModInitializer {
|
|||
return instance;
|
||||
}
|
||||
|
||||
public static Identifier id(String name) {
|
||||
return Identifier.of("minelittlepony", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
hasHdSkins = FabricLoader.getInstance().isModLoaded("hdskins");
|
||||
|
@ -80,13 +76,16 @@ public class MineLittlePony implements ClientModInitializer {
|
|||
|
||||
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ponyManager);
|
||||
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(variatedTextures);
|
||||
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ArmourTextureResolver.INSTANCE);
|
||||
|
||||
// convert legacy pony skins
|
||||
SkinFilterCallback.EVENT.register(new LegacySkinConverter());
|
||||
|
||||
// general events
|
||||
ClientReadyCallback.Handler.register();
|
||||
ClientTickEvents.END_CLIENT_TICK.register(this::onTick);
|
||||
ClientReadyCallback.EVENT.register(client -> {
|
||||
renderDispatcher.initialise(client.getEntityRenderDispatcher(), false);
|
||||
});
|
||||
ScreenInitCallback.EVENT.register(this::onScreenInit);
|
||||
|
||||
config.load();
|
||||
|
@ -98,10 +97,6 @@ public class MineLittlePony implements ClientModInitializer {
|
|||
}
|
||||
|
||||
private void onTick(MinecraftClient client) {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
renderDispatcher.initialise(client.getEntityRenderDispatcher(), false);
|
||||
}
|
||||
|
||||
boolean inGame = client.world != null && client.player != null && client.currentScreen == null;
|
||||
boolean mainMenu = client.currentScreen instanceof TitleScreen;
|
||||
|
@ -129,7 +124,7 @@ public class MineLittlePony implements ClientModInitializer {
|
|||
button.getStyle()
|
||||
.setIcon(new TextureSprite()
|
||||
.setPosition(2, 2)
|
||||
.setTexture(id("textures/gui/pony.png"))
|
||||
.setTexture(new Identifier("minelittlepony", "textures/gui/pony.png"))
|
||||
.setTextureSize(16, 16)
|
||||
.setSize(16, 16))
|
||||
.setTooltip("minelp.options.title", 0, 10);
|
||||
|
|
|
@ -1,28 +1,50 @@
|
|||
package com.minelittlepony.client;
|
||||
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.api.pony.PonyPosture;
|
||||
import com.minelittlepony.client.transform.PonyTransformation;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class PonyBounds {
|
||||
public static Vec3d getAbsoluteRidingOffset(LivingEntity entity) {
|
||||
return PonyPosture.getMountPony(entity).map(ridingPony -> {
|
||||
LivingEntity vehicle = (LivingEntity)entity.getVehicle();
|
||||
|
||||
Vec3d offset = PonyTransformation.forSize(ridingPony.size()).getRiderOffset();
|
||||
float scale = ridingPony.metadata().size().scaleFactor();
|
||||
|
||||
return getAbsoluteRidingOffset(vehicle).add(
|
||||
0,
|
||||
offset.y - vehicle.getHeight() * 1 / scale,
|
||||
0
|
||||
);
|
||||
}).orElseGet(() -> getBaseRidingOffset(entity));
|
||||
}
|
||||
|
||||
private static Vec3d getBaseRidingOffset(LivingEntity entity) {
|
||||
float delta = MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false);
|
||||
float delta = MinecraftClient.getInstance().getTickDelta();
|
||||
|
||||
Entity vehicle = entity.getVehicle();
|
||||
double vehicleOffset = vehicle == null ? 0 : vehicle.getHeight();
|
||||
|
||||
return new Vec3d(
|
||||
MathHelper.lerp(delta, entity.prevX, entity.getX()),
|
||||
MathHelper.lerp(delta, entity.prevY, entity.getY()),
|
||||
MathHelper.lerp(delta, entity.prevY, entity.getY()) + vehicleOffset,
|
||||
MathHelper.lerp(delta, entity.prevZ, entity.getZ())
|
||||
);
|
||||
}
|
||||
|
||||
public static Box getBoundingBox(Pony pony, LivingEntity entity) {
|
||||
final float scale = pony.size().scaleFactor();
|
||||
final float scale = pony.size().scaleFactor() + 0.1F;
|
||||
final float width = entity.getWidth() * scale;
|
||||
final float height = entity.getHeight() * scale;
|
||||
|
||||
return new Box(-width, 0, -width, width, height, width).offset(getBaseRidingOffset(entity));
|
||||
return new Box(-width, height, -width, width, 0, width).offset(getAbsoluteRidingOffset(entity));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ import java.util.function.Supplier;
|
|||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PonyDataLoader {
|
||||
public static final Supplier<Optional<PonyData>> NULL = loaded(PonyData.NULL);
|
||||
class PonyDataLoader {
|
||||
static final Supplier<Optional<PonyData>> NULL = loaded(PonyData.NULL);
|
||||
private static final ResourceMetadataReader<PonyData> SERIALIZER = new ResourceMetadataReader<PonyData>() {
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package com.minelittlepony.client;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.cache.*;
|
||||
import com.minelittlepony.api.config.PonyConfig;
|
||||
import com.minelittlepony.api.config.PonyLevel;
|
||||
import com.minelittlepony.api.events.PonySkinResolver;
|
||||
import com.minelittlepony.api.pony.*;
|
||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
|
||||
|
||||
|
@ -15,35 +13,36 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.util.DefaultSkinHelper;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceReloadListener {
|
||||
private static final Identifier ID = MineLittlePony.id("background_ponies");
|
||||
private static final Identifier ID = new Identifier("minelittlepony", "background_ponies");
|
||||
|
||||
private final PonyConfig config;
|
||||
|
||||
private final LoadingCache<Key, Pony> poniesCache = CacheBuilder.newBuilder()
|
||||
private final LoadingCache<Identifier, Pony> defaultedPoniesCache = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(30, TimeUnit.SECONDS)
|
||||
.build(CacheLoader.from(key -> new Pony(key.texture(), PonyDataLoader.parse(key.texture(), key.defaulted()))));
|
||||
private final WeakHashMap<UUID, Pony> playerPonies = new WeakHashMap<>();
|
||||
.build(CacheLoader.from(resource -> new Pony(resource, PonyDataLoader.parse(resource, true))));
|
||||
|
||||
record Key(Identifier texture, @Nullable UUID uuid, boolean defaulted) {}
|
||||
private final LoadingCache<Identifier, Pony> poniesCache = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(30, TimeUnit.SECONDS)
|
||||
.build(CacheLoader.from(resource -> new Pony(resource, PonyDataLoader.parse(resource, false))));
|
||||
|
||||
public PonyManagerImpl(PonyConfig config) {
|
||||
this.config = config;
|
||||
Instance.instance = this;
|
||||
}
|
||||
|
||||
private Pony loadPony(Identifier resource, @Nullable UUID uuid, boolean defaulted) {
|
||||
private Pony loadPony(Identifier resource, boolean defaulted) {
|
||||
try {
|
||||
return poniesCache.get(new Key(resource, uuid, defaulted));
|
||||
return (defaulted ? defaultedPoniesCache : poniesCache).get(resource);
|
||||
} catch (ExecutionException e) {
|
||||
return new Pony(resource, PonyDataLoader.NULL);
|
||||
}
|
||||
|
@ -51,26 +50,7 @@ public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceRe
|
|||
|
||||
@Override
|
||||
public Pony getPony(PlayerEntity player) {
|
||||
final UUID id = player instanceof ForcedPony ? null : player.getGameProfile() == null || player.getGameProfile().getId() == null ? player.getUuid() : player.getGameProfile().getId();
|
||||
|
||||
Pony pony;
|
||||
if (player instanceof ServerPlayerEntity && id != null) {
|
||||
pony = playerPonies.get(id);
|
||||
if (pony != null) {
|
||||
return pony;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Identifier skin = getSkin(player);
|
||||
if (skin != null) {
|
||||
skin = MoreObjects.firstNonNull(PonySkinResolver.EVENT.invoker().onPonySkinResolving(player, s -> getPony(s, id), skin), skin);
|
||||
}
|
||||
pony = getPony(skin, id);
|
||||
if (!(player instanceof ServerPlayerEntity) && id != null) {
|
||||
playerPonies.put(id, pony);
|
||||
}
|
||||
return pony;
|
||||
return getPony(getSkin(player), player instanceof ForcedPony ? null : player.getGameProfile() == null ? player.getUuid() : player.getGameProfile().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,21 +58,17 @@ public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceRe
|
|||
if (entity instanceof PlayerEntity player) {
|
||||
return Optional.of(getPony(player));
|
||||
}
|
||||
@Nullable
|
||||
Identifier skin = getSkin(entity);
|
||||
if (skin != null) {
|
||||
skin = MoreObjects.firstNonNull(PonySkinResolver.EVENT.invoker().onPonySkinResolving(entity, s -> getPony(s, null), skin), skin);
|
||||
}
|
||||
return skin == null ? Optional.empty() : Optional.of(getPony(skin, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pony getPony(@Nullable Identifier resource, @Nullable UUID uuid) {
|
||||
if (resource == null) {
|
||||
return uuid == null ? loadPony(DefaultSkinHelper.getTexture(), uuid, true) : getBackgroundPony(uuid);
|
||||
return uuid == null ? loadPony(DefaultSkinHelper.getTexture(), true) : getBackgroundPony(uuid);
|
||||
}
|
||||
|
||||
Pony pony = loadPony(resource, uuid, false);
|
||||
Pony pony = loadPony(resource, false);
|
||||
|
||||
if (uuid != null && PonyConfig.getInstance().ponyLevel.get() == PonyLevel.PONIES && pony.metadata().race().isHuman()) {
|
||||
return getBackgroundPony(uuid);
|
||||
|
@ -103,9 +79,9 @@ public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceRe
|
|||
@Override
|
||||
public Pony getBackgroundPony(@Nullable UUID uuid) {
|
||||
if (config.ponyLevel.get() == PonyLevel.PONIES) {
|
||||
return loadPony(MineLittlePony.getInstance().getVariatedTextures().get(VariatedTextureSupplier.BACKGROUND_PONIES_POOL, uuid).orElse(DefaultSkinHelper.getSkinTextures(uuid).texture()), uuid, true);
|
||||
return loadPony(MineLittlePony.getInstance().getVariatedTextures().get(VariatedTextureSupplier.BACKGROUND_PONIES_POOL, uuid).orElse(DefaultSkinHelper.getSkinTextures(uuid).texture()), true);
|
||||
}
|
||||
return loadPony(DefaultSkinHelper.getSkinTextures(uuid).texture(), uuid, true);
|
||||
return loadPony(DefaultSkinHelper.getSkinTextures(uuid).texture(), true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -125,17 +101,19 @@ public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceRe
|
|||
|
||||
public void removePony(Identifier resource) {
|
||||
poniesCache.invalidate(resource);
|
||||
defaultedPoniesCache.invalidate(resource);
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
MineLittlePony.logger.info("Turned {} cached ponies into cupcakes.", poniesCache.size());
|
||||
MineLittlePony.logger.info("Flushed {} cached ponies.", poniesCache.size());
|
||||
poniesCache.invalidateAll();
|
||||
defaultedPoniesCache.invalidateAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload(ResourceManager manager) {
|
||||
public void reload(ResourceManager var1) {
|
||||
clearCache();
|
||||
PonySkullRenderer.INSTANCE.reload();
|
||||
PonySkullRenderer.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -136,11 +136,10 @@ public class PonySettingsScreen extends GameGui {
|
|||
|
||||
if (hiddenOptions) {
|
||||
for (Setting<?> i : config.getCategory("customisation").entries()) {
|
||||
if (i.get() instanceof Boolean value) {
|
||||
content.addButton(new Toggle(LEFT, row += 20, value))
|
||||
.onChange((Setting<Boolean>)i)
|
||||
.getStyle().setText(OPTIONS_PREFIX + i.name().toLowerCase());
|
||||
}
|
||||
Button button = content
|
||||
.addButton(new Toggle(LEFT, row += 20, ((Setting<Boolean>)i).get()))
|
||||
.onChange((Setting<Boolean>)i);
|
||||
button.getStyle().setText(OPTIONS_PREFIX + i.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ import com.minelittlepony.util.MathUtil;
|
|||
import java.util.*;
|
||||
|
||||
public class VariatedTextureSupplier implements SimpleSynchronousResourceReloadListener {
|
||||
private static final Identifier ID = MineLittlePony.id("variated_textures");
|
||||
public static final Identifier BACKGROUND_PONIES_POOL = MineLittlePony.id("textures/entity/pony");
|
||||
public static final Identifier BACKGROUND_ZOMPONIES_POOL = MineLittlePony.id("textures/entity/zompony");
|
||||
private static final Identifier ID = new Identifier("minelittlepony", "variated_textures");
|
||||
public static final Identifier BACKGROUND_PONIES_POOL = new Identifier("minelittlepony", "textures/entity/pony");
|
||||
public static final Identifier BACKGROUND_ZOMPONIES_POOL = new Identifier("minelittlepony", "textures/entity/zompony");
|
||||
|
||||
private final Map<Identifier, SkinList> entries = new HashMap<>();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.client.compat.hdskins;
|
||||
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.api.model.PreviewModel;
|
||||
import com.minelittlepony.api.pony.*;
|
||||
|
@ -21,13 +20,12 @@ class DummyPony extends DummyPlayer implements PreviewModel, PonyManager.ForcedP
|
|||
}
|
||||
|
||||
@Override
|
||||
public Identifier getForm() {
|
||||
if (getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.seaponySkinType) {
|
||||
return PonyForm.SEAPONY;
|
||||
}
|
||||
if (getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.nirikSkinType) {
|
||||
return PonyForm.NIRIK;
|
||||
}
|
||||
return PonyForm.DEFAULT;
|
||||
public boolean forceSeapony() {
|
||||
return getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.seaponySkinType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean forceNirik() {
|
||||
return getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.nirikSkinType;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ import net.minecraft.util.Identifier;
|
|||
* Skin uploading GUI. Usually displayed over the main menu.
|
||||
*/
|
||||
class GuiSkinsMineLP extends GuiSkins {
|
||||
private static final Identifier[] PANORAMAS = new Identifier[] {
|
||||
MineLittlePony.id("textures/cubemap/sugarcubecorner"),
|
||||
MineLittlePony.id("textures/cubemap/quillsandsofas"),
|
||||
MineLittlePony.id("textures/cubemap/sweetappleacres")
|
||||
private static final String[] PANORAMAS = new String[] {
|
||||
"minelittlepony:textures/cubemap/sugarcubecorner",
|
||||
"minelittlepony:textures/cubemap/quillsandsofas",
|
||||
"minelittlepony:textures/cubemap/sweetappleacres"
|
||||
};
|
||||
|
||||
public GuiSkinsMineLP(Screen parent, SkinServerList servers) {
|
||||
|
@ -47,7 +47,7 @@ class GuiSkinsMineLP extends GuiSkins {
|
|||
.getStyle()
|
||||
.setIcon(new TextureSprite()
|
||||
.setPosition(2, 2)
|
||||
.setTexture(MineLittlePony.id("textures/gui/pony.png"))
|
||||
.setTexture(new Identifier("minelittlepony", "textures/gui/pony.png"))
|
||||
.setTextureSize(16, 16)
|
||||
.setSize(16, 16))
|
||||
.setTooltip("minelp.options.title", 0, 10);
|
||||
|
@ -64,6 +64,8 @@ class GuiSkinsMineLP extends GuiSkins {
|
|||
|
||||
@Override
|
||||
protected Identifier getBackground() {
|
||||
return PANORAMAS[(int)Math.floor(Math.random() * PANORAMAS.length)];
|
||||
int i = (int)Math.floor(Math.random() * PANORAMAS.length);
|
||||
|
||||
return new Identifier(PANORAMAS[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.minelittlepony.api.pony.*;
|
|||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.common.client.gui.ScrollContainer;
|
||||
import com.minelittlepony.common.client.gui.element.Button;
|
||||
import com.minelittlepony.hdskins.HDSkinsServer;
|
||||
import com.minelittlepony.common.event.ClientReadyCallback;
|
||||
import com.minelittlepony.hdskins.client.*;
|
||||
import com.minelittlepony.hdskins.client.gui.GuiSkins;
|
||||
import com.minelittlepony.hdskins.client.gui.player.DummyPlayer;
|
||||
|
@ -38,7 +38,7 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
|||
static SkinType seaponySkinType;
|
||||
static SkinType nirikSkinType;
|
||||
|
||||
static final Map<SkinType, Wearable> WEARABLE_TYPES = new HashMap<>();
|
||||
static final Map<SkinType, Wearable> wearableTypes = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
|
@ -49,17 +49,17 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
|||
nirikSkinType = SkinType.register(DefaultPonySkinHelper.NIRIK_SKIN_TYPE_ID, Items.LAVA_BUCKET.getDefaultStack());
|
||||
Wearable.REGISTRY.values().forEach(wearable -> {
|
||||
if (wearable != Wearable.NONE) {
|
||||
WEARABLE_TYPES.put(SkinType.register(wearable.getId(), Items.BUNDLE.getDefaultStack()), wearable);
|
||||
wearableTypes.put(SkinType.register(wearable.getId(), Items.BUNDLE.getDefaultStack()), wearable);
|
||||
}
|
||||
});
|
||||
|
||||
// Clear ponies when skins are cleared
|
||||
SkinCacheClearCallback.EVENT.register(() -> {
|
||||
MineLittlePony.getInstance().getManager().clearCache();
|
||||
});
|
||||
ClientReadyCallback.EVENT.register(client -> {
|
||||
// Clear ponies when skins are cleared
|
||||
SkinCacheClearCallback.EVENT.register(MineLittlePony.getInstance().getManager()::clearCache);
|
||||
|
||||
// Ponify the skins GUI.
|
||||
GuiSkins.setSkinsGui(GuiSkinsMineLP::new);
|
||||
// Ponify the skins GUI.
|
||||
GuiSkins.setSkinsGui(GuiSkinsMineLP::new);
|
||||
});
|
||||
|
||||
HDSkins.getInstance().getSkinPrioritySorter().addSelector((skinType, playerSkins) -> {
|
||||
if (skinType == SkinType.SKIN && PonyConfig.getInstance().mixedHumanSkins.get()) {
|
||||
|
@ -85,7 +85,7 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
|||
private void renderOption(Screen screen, @Nullable Screen parent, int row, int RIGHT, ScrollContainer content) {
|
||||
content.addButton(new Button(RIGHT, row += 20, 150, 20))
|
||||
.onClick(button -> MinecraftClient.getInstance().setScreen(
|
||||
parent instanceof GuiSkins ? parent : GuiSkins.create(screen, HDSkinsServer.getInstance().getServers())
|
||||
parent instanceof GuiSkins ? parent : GuiSkins.create(screen, HDSkins.getInstance().getSkinServerList())
|
||||
))
|
||||
.getStyle()
|
||||
.setText("minelp.options.skins.hdskins.open");
|
||||
|
@ -134,17 +134,16 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
|||
}
|
||||
}
|
||||
|
||||
return Optional.of(player)
|
||||
.flatMap(PlayerSkins::of)
|
||||
return Optional.of(player).flatMap(PlayerSkins::of)
|
||||
.map(PlayerSkins::layers)
|
||||
.map(PlayerSkinLayers::combined)
|
||||
.flatMap(skins -> skins.getSkin(type));
|
||||
.map(PlayerSkinLayers::combined).flatMap(skins -> skins.getSkin(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getSkinTexture(GameProfile profile) {
|
||||
return HDSkins.getInstance().getProfileRepository()
|
||||
.load(profile).getNow(ProvidedSkins.EMPTY)
|
||||
.load(profile)
|
||||
.getNow(ProvidedSkins.EMPTY)
|
||||
.getSkin(SkinType.SKIN)
|
||||
.orElseGet(() -> super.getSkinTexture(profile));
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class PonifiedDualCarouselWidget extends DualCarouselWidget {
|
|||
return super.getDefaultSkin(SkinType.SKIN, modelVariant);
|
||||
}
|
||||
|
||||
Wearable wearable = MineLPHDSkins.WEARABLE_TYPES.getOrDefault(type, Wearable.NONE);
|
||||
Wearable wearable = MineLPHDSkins.wearableTypes.getOrDefault(type, Wearable.NONE);
|
||||
|
||||
if (wearable != Wearable.NONE) {
|
||||
return NativeImageFilters.GREYSCALE.load(wearable.getDefaultTexture(), wearable.getDefaultTexture(), getExclusion());
|
||||
|
|
|
@ -12,11 +12,11 @@ import net.minecraft.client.render.Camera;
|
|||
|
||||
@Mixin(Camera.class)
|
||||
abstract class MixinCamera {
|
||||
@Inject(method = "clipToSpace(F)F",
|
||||
@Inject(method = "clipToSpace(D)D",
|
||||
at = @At("RETURN"),
|
||||
cancellable = true)
|
||||
private void redirectCameraDistance(float initial, CallbackInfoReturnable<Float> info) {
|
||||
float value = info.getReturnValueF();
|
||||
private void redirectCameraDistance(double initial, CallbackInfoReturnable<Double> info) {
|
||||
double value = info.getReturnValueD();
|
||||
|
||||
Pony pony = Pony.getManager().getPony(MinecraftClient.getInstance().player);
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package com.minelittlepony.client.mixin;
|
||||
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.client.render.EquineRenderManager;
|
||||
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.EntityPose;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity implements EquineRenderManager.RegistrationHandler {
|
||||
public MixinClientPlayerEntity() { super(null, null); }
|
||||
|
||||
private final EquineRenderManager.SyncedPony syncedPony = new EquineRenderManager.SyncedPony();
|
||||
|
||||
@Inject(method = "startRiding(Lnet/minecraft/entity/Entity;Z)Z", at = @At("RETURN"))
|
||||
private void onStartRiding(Entity entity, boolean bl, CallbackInfoReturnable<Boolean> info) {
|
||||
calculateDimensions();
|
||||
}
|
||||
|
||||
@Inject(method = "dismountVehicle()V", at = @At("RETURN"))
|
||||
private void onStopRiding(CallbackInfo info) {
|
||||
calculateDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EquineRenderManager.SyncedPony getSyncedPony() {
|
||||
return syncedPony;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getActiveEyeHeight(EntityPose pose, EntityDimensions dimensions) {
|
||||
float value = super.getActiveEyeHeight(pose, dimensions);
|
||||
|
||||
Pony pony = Pony.getManager().getPony(this);
|
||||
|
||||
if (!pony.race().isHuman()) {
|
||||
float factor = pony.size().eyeHeightFactor();
|
||||
if (factor != 1) {
|
||||
value *= factor;
|
||||
|
||||
if (hasVehicle()) {
|
||||
value += getVehicle().getHeight();
|
||||
}
|
||||
return Math.max(value, 0.1F);
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.minelittlepony.client.mixin;
|
||||
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -13,12 +14,12 @@ import com.minelittlepony.api.model.RenderPass;
|
|||
@Mixin(GameRenderer.class)
|
||||
abstract class MixinGameRenderer {
|
||||
@Inject(method = "renderWorld", at = @At("HEAD"))
|
||||
private void beforeRenderWorld(RenderTickCounter counter, CallbackInfo info) {
|
||||
private void beforeRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
||||
RenderPass.swap(RenderPass.WORLD);
|
||||
}
|
||||
|
||||
@Inject(method = "renderWorld", at = @At("RETURN"))
|
||||
private void afterRenderWorld(RenderTickCounter counter, CallbackInfo info) {
|
||||
private void afterRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
||||
RenderPass.swap(RenderPass.GUI);
|
||||
}
|
||||
}
|
||||
|
@ -30,14 +31,7 @@ abstract class MixinWorldRenderer {
|
|||
target = "net.minecraft.client.render.VertexConsumerProvider$Immediate.drawCurrentLayer()V",
|
||||
ordinal = 0
|
||||
))
|
||||
private void onRender(
|
||||
RenderTickCounter counter,
|
||||
boolean renderBlockOutline,
|
||||
Camera camera,
|
||||
GameRenderer gameRenderer,
|
||||
LightmapTextureManager lightmapTextureManager,
|
||||
Matrix4f matrix4f,
|
||||
Matrix4f matrix4f2, CallbackInfo info) {
|
||||
private void onRender(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo info) {
|
||||
RenderPass.swap(RenderPass.HUD);
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.minelittlepony.client.mixin;
|
||||
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.minelittlepony.client.render.EquineRenderManager.RegistrationHandler;
|
||||
import com.minelittlepony.client.render.EquineRenderManager.SyncedPony;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
abstract class MixinPlayerEntity extends LivingEntity implements RegistrationHandler {
|
||||
MixinPlayerEntity() { super(null, null); }
|
||||
|
||||
private final SyncedPony syncedPony = new SyncedPony();
|
||||
|
||||
@Override
|
||||
public SyncedPony getSyncedPony() {
|
||||
return syncedPony;
|
||||
}
|
||||
|
||||
@Inject(method = "getBaseDimensions", at = @At("RETURN"), cancellable = true)
|
||||
private void onGetBaseDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> info) {
|
||||
float factor = syncedPony.getCachedPonyData().size().eyeHeightFactor();
|
||||
|
||||
if (factor != 1) {
|
||||
EntityDimensions dimensions = info.getReturnValue();
|
||||
info.setReturnValue(dimensions.withEyeHeight(dimensions.eyeHeight() * factor));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick()V", at = @At("TAIL"))
|
||||
private void onTick(CallbackInfo info) {
|
||||
syncedPony.synchronize((PlayerEntity)(Object)this);
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
|||
import net.minecraft.client.render.block.entity.SkullBlockEntityModel;
|
||||
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.type.ProfileComponent;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -18,6 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -39,18 +39,18 @@ abstract class MixinSkullBlockEntityRenderer implements BlockEntityRenderer<Skul
|
|||
SkullBlockEntityModel model, RenderLayer layer,
|
||||
CallbackInfo info) {
|
||||
|
||||
if (!info.isCancelled() && PonySkullRenderer.INSTANCE.renderSkull(direction, angle, poweredTicks, stack, renderContext, layer, lightUv)) {
|
||||
if (!info.isCancelled() && PonySkullRenderer.renderSkull(direction, angle, poweredTicks, stack, renderContext, layer, lightUv)) {
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getRenderLayer("
|
||||
+ "Lnet/minecraft/block/SkullBlock$SkullType;"
|
||||
+ "Lnet/minecraft/component/type/ProfileComponent;"
|
||||
+ "Lcom/mojang/authlib/GameProfile;"
|
||||
+ ")Lnet/minecraft/client/render/RenderLayer;", at = @At("HEAD"), cancellable = true)
|
||||
private static void onGetRenderLayer(SkullBlock.SkullType skullType, @Nullable ProfileComponent profile, CallbackInfoReturnable<RenderLayer> info) {
|
||||
private static void onGetRenderLayer(SkullBlock.SkullType skullType, @Nullable GameProfile profile, CallbackInfoReturnable<RenderLayer> info) {
|
||||
if (!info.isCancelled()) {
|
||||
RenderLayer result = PonySkullRenderer.INSTANCE.getSkullRenderLayer(skullType, profile);
|
||||
RenderLayer result = PonySkullRenderer.getSkullRenderLayer(skullType, profile);
|
||||
if (result != null) {
|
||||
info.setReturnValue(result);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.minelittlepony.client.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.Arrays;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumers;
|
||||
|
||||
|
@ -25,12 +25,15 @@ abstract class MixinVertextConsumers {
|
|||
}
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "union([" + T + ")" + T, at = @At("HEAD"), argsOnly = true)
|
||||
private static VertexConsumer[] onUnion(VertexConsumer[] delegates) {
|
||||
Set<VertexConsumer> set = new ObjectArraySet<>(delegates.length);
|
||||
for (VertexConsumer delegate : delegates) {
|
||||
set.add(delegate);
|
||||
@Inject(method = "union([" + T + ")" + T, at = @At("HEAD"), cancellable = true)
|
||||
private static void onUnion(VertexConsumer[] delegates, CallbackInfoReturnable<VertexConsumer> info) {
|
||||
int oldLength = delegates.length;
|
||||
delegates = Arrays.stream(delegates).distinct().toArray(VertexConsumer[]::new);
|
||||
|
||||
if (delegates.length == 1) {
|
||||
info.setReturnValue(delegates[0]);
|
||||
} else if (delegates.length != oldLength) {
|
||||
info.setReturnValue(new VertexConsumers.Union(delegates));
|
||||
}
|
||||
return set.toArray(VertexConsumer[]::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.minelittlepony.api.model.*;
|
|||
import com.minelittlepony.api.events.PonyModelPrepareCallback;
|
||||
import com.minelittlepony.api.pony.meta.SizePreset;
|
||||
import com.minelittlepony.client.transform.PonyTransformation;
|
||||
import com.minelittlepony.mson.util.RenderList;
|
||||
import com.minelittlepony.client.util.render.RenderList;
|
||||
import com.minelittlepony.util.MathUtil;
|
||||
import com.minelittlepony.util.MathUtil.Angles;
|
||||
|
||||
|
@ -31,6 +31,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
|
||||
public static final Pivot ORIGIN = new Pivot(0, 0, 0);
|
||||
public static final Pivot HEAD_SNEAKING = new Pivot(0, 6, -2);
|
||||
public static final Pivot HEAD_SLEEPING = new Pivot(1, 2, 0);
|
||||
public static final Pivot BODY_SNEAKING = new Pivot(0, 7, -4);
|
||||
public static final Pivot BODY_RIDING = new Pivot(0, 1, 4);
|
||||
public static final Pivot FONT_LEGS_SLEEPING = new Pivot(0, 2, 6);
|
||||
|
@ -71,27 +72,27 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
}
|
||||
|
||||
protected RenderList forPart(Supplier<SubModel> part) {
|
||||
return (stack, vertices, overlay, light, color) -> {
|
||||
part.get().renderPart(stack, vertices, overlay, light, color, attributes);
|
||||
return (stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
||||
part.get().renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes);
|
||||
};
|
||||
}
|
||||
|
||||
protected RenderList forPart(SubModel part) {
|
||||
return (stack, vertices, overlay, light, color) -> {
|
||||
part.renderPart(stack, vertices, overlay, light, color, attributes);
|
||||
return (stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
||||
part.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color) {
|
||||
mainRenderList.accept(stack, vertices, overlay, light, color);
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
mainRenderList.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
protected RenderList withStage(BodyPart part, RenderList action) {
|
||||
return (stack, vertices, overlay, light, color) -> {
|
||||
return (stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
||||
stack.push();
|
||||
transform(part, stack);
|
||||
action.accept(stack, vertices, overlay, light, color);
|
||||
action.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
stack.pop();
|
||||
};
|
||||
}
|
||||
|
@ -194,6 +195,8 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
rightLeg.pitch = MathUtil.Angles._90_DEG;
|
||||
leftLeg.pitch = MathUtil.Angles._90_DEG;
|
||||
|
||||
HEAD_SLEEPING.set(head);
|
||||
|
||||
FONT_LEGS_SLEEPING.add(rightArm);
|
||||
FONT_LEGS_SLEEPING.add(leftArm);
|
||||
BACK_LEGS_SLEEPING.add(rightLeg);
|
||||
|
@ -201,9 +204,14 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
}
|
||||
|
||||
protected void ponySit() {
|
||||
adjustBodyComponents(BODY_RIDING_PITCH, BODY_RIDING);
|
||||
neck.setPivot(NECK_X, 0, 0);
|
||||
head.setPivot(0, 0, 0);
|
||||
adjustBodyComponents(BODY_RIDING_PITCH * (attributes.isRidingInteractive ? 2 : 1), BODY_RIDING);
|
||||
if (attributes.isRidingInteractive) {
|
||||
neck.setPivot(NECK_X, 0, -4);
|
||||
head.setPivot(0, -2, -5);
|
||||
} else {
|
||||
neck.setPivot(NECK_X, 0, 0);
|
||||
head.setPivot(0, 0, 0);
|
||||
}
|
||||
|
||||
leftLeg.pivotZ = 14;
|
||||
leftLeg.pivotY = 17;
|
||||
|
@ -223,6 +231,26 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
leftArm.pitch += body.pitch;
|
||||
rightArm.roll = MathHelper.PI * 0.06f;
|
||||
rightArm.pitch += body.pitch;
|
||||
|
||||
if (attributes.isRidingInteractive) {
|
||||
leftLeg.yaw = MathHelper.PI / 15;
|
||||
leftLeg.pitch = MathHelper.PI / 9;
|
||||
|
||||
leftLeg.pivotZ = 10;
|
||||
leftLeg.pivotY = 7;
|
||||
|
||||
rightLeg.yaw = -MathHelper.PI / 15;
|
||||
rightLeg.pitch = MathHelper.PI / 9;
|
||||
|
||||
rightLeg.pivotZ = 10;
|
||||
rightLeg.pivotY = 7;
|
||||
|
||||
leftArm.pitch = MathHelper.PI / 6;
|
||||
rightArm.pitch = MathHelper.PI / 6;
|
||||
|
||||
leftArm.roll *= 2;
|
||||
rightArm.roll *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -572,6 +600,10 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
}
|
||||
}
|
||||
|
||||
if (getAttributes().isRidingInteractive) {
|
||||
matrices.translate(left / 10, -0.2F, -0.5F);
|
||||
}
|
||||
|
||||
matrices.translate(-left * 0.1F, 0.45F, 0);
|
||||
|
||||
if (getAttributes().heldStack.getUseAction() == UseAction.BLOCK && getAttributes().itemUseTime == 0) {
|
||||
|
@ -591,8 +623,11 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180));
|
||||
}
|
||||
|
||||
boolean crouching = attributes.isCrouching;
|
||||
|
||||
if (attributes.isLyingDown && !attributes.isSleeping) {
|
||||
stack.translate(0, 1.35F, 0);
|
||||
attributes.isCrouching = sneaking;
|
||||
}
|
||||
|
||||
if (attributes.isHorsey) {
|
||||
|
@ -606,5 +641,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
|||
}
|
||||
|
||||
PonyTransformation.forSize(getSize()).transform(this, part, stack);
|
||||
|
||||
attributes.isCrouching = crouching;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@ import net.minecraft.client.render.entity.model.ArmorStandEntityModel;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.mob.VexEntity;
|
||||
import net.minecraft.entity.passive.*;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.api.model.gear.*;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.armour.PonyArmourModel;
|
||||
import com.minelittlepony.client.model.entity.*;
|
||||
import com.minelittlepony.client.model.entity.race.*;
|
||||
|
@ -56,7 +56,7 @@ public final class ModelType {
|
|||
public static final ModelKey<PonyArmourModel<?>> INNER_PONY_ARMOR = register("armor/inner_pony_armor", PonyArmourModel::new);
|
||||
public static final ModelKey<PonyArmourModel<?>> OUTER_PONY_ARMOR = register("armor/outer_pony_armor", PonyArmourModel::new);
|
||||
|
||||
public static final GearModelKey<AbstractGearModel> STETSON = registerGear("stetson", Wearable.STETSON, t -> new WearableGear(Wearable.STETSON, BodyPart.HEAD, 0.15F).addPart(t));
|
||||
public static final GearModelKey<AbstractGearModel> STETSON = registerGear("stetson", Wearable.STETSON, t -> new WearableGear(Wearable.STETSON, BodyPart.HEAD, 0.15F));
|
||||
public static final GearModelKey<SaddleBags> SADDLEBAGS_BOTH = registerGear("saddlebags", Wearable.SADDLE_BAGS_BOTH, t -> new SaddleBags(t, Wearable.SADDLE_BAGS_BOTH));
|
||||
public static final GearModelKey<SaddleBags> SADDLEBAGS_LEFT = registerGear(SADDLEBAGS_BOTH, Wearable.SADDLE_BAGS_LEFT, t -> new SaddleBags(t, Wearable.SADDLE_BAGS_LEFT));
|
||||
public static final GearModelKey<SaddleBags> SADDLEBAGS_RIGHT = registerGear(SADDLEBAGS_BOTH, Wearable.SADDLE_BAGS_RIGHT, t -> new SaddleBags(t, Wearable.SADDLE_BAGS_RIGHT));
|
||||
|
@ -93,7 +93,7 @@ public final class ModelType {
|
|||
@SuppressWarnings("unchecked")
|
||||
static <T extends AbstractGearModel> GearModelKey<T> registerGear(String name, Wearable wearable, MsonModel.Factory<T> constructor) {
|
||||
return (GearModelKey<T>)GEAR_MODELS.computeIfAbsent(wearable, w -> {
|
||||
return new GearModelKey<T>(Mson.getInstance().registerModel(MineLittlePony.id("gear/" + name), constructor), constructor);
|
||||
return new GearModelKey<T>(Mson.getInstance().registerModel(new Identifier("minelittlepony", "gear/" + name), constructor), constructor);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public final class ModelType {
|
|||
}
|
||||
|
||||
static <T extends Model> ModelKey<T> register(String name, MsonModel.Factory<T> constructor) {
|
||||
return new ModelKeyImpl<T>(MineLittlePony.id(name), constructor);
|
||||
return new ModelKeyImpl<T>(new Identifier("minelittlepony", name), constructor);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -3,12 +3,12 @@ package com.minelittlepony.client.model;
|
|||
import net.minecraft.client.model.Model;
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.api.model.Models;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.armour.PonyArmourModel;
|
||||
import com.minelittlepony.mson.api.*;
|
||||
|
||||
|
@ -21,8 +21,8 @@ public record PlayerModelKey<T extends LivingEntity, M extends Model & PonyModel
|
|||
) {
|
||||
PlayerModelKey(String name, BiFunction<ModelPart, Boolean, M> modelFactory, MsonModel.Factory<PonyArmourModel<T>> armorFactory) {
|
||||
this(
|
||||
new ModelKeyImpl<>(MineLittlePony.id("races/steve/" + name), tree -> modelFactory.apply(tree, false)),
|
||||
new ModelKeyImpl<>(MineLittlePony.id("races/alex/" + name), tree -> modelFactory.apply(tree, true)),
|
||||
new ModelKeyImpl<>(new Identifier("minelittlepony", "races/steve/" + name), tree -> modelFactory.apply(tree, false)),
|
||||
new ModelKeyImpl<>(new Identifier("minelittlepony", "races/alex/" + name), tree -> modelFactory.apply(tree, true)),
|
||||
armorFactory
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,129 +0,0 @@
|
|||
package com.minelittlepony.client.model.armour;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.model.Model;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.type.DyedColorComponent;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.trim.ArmorTrim;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface ArmourRendererPlugin {
|
||||
AtomicReference<ArmourRendererPlugin> INSTANCE = new AtomicReference<>(new ArmourRendererPlugin() {});
|
||||
|
||||
static void register(Function<ArmourRendererPlugin, ArmourRendererPlugin> constructor) {
|
||||
INSTANCE.set(constructor.apply(INSTANCE.get()));
|
||||
}
|
||||
|
||||
default ArmourTextureLookup getTextureLookup() {
|
||||
return ArmourTextureResolver.INSTANCE;
|
||||
}
|
||||
|
||||
default void onArmourRendered(LivingEntity entity, MatrixStack matrices, VertexConsumerProvider provider, EquipmentSlot armorSlot, ArmourLayer layer, ArmourType type) {
|
||||
|
||||
}
|
||||
|
||||
default ItemStack[] getArmorStacks(LivingEntity entity, EquipmentSlot armorSlot, ArmourLayer layer, ArmourType type) {
|
||||
return new ItemStack[] { entity.getEquippedStack(armorSlot) };
|
||||
}
|
||||
|
||||
default float getGlintAlpha(EquipmentSlot slot, ItemStack stack) {
|
||||
return stack.hasGlint() ? 1 : 0;
|
||||
}
|
||||
|
||||
default int getDyeColor(EquipmentSlot slot, ItemStack stack) {
|
||||
return stack.isIn(ItemTags.DYEABLE) ? DyedColorComponent.getColor(stack, -6265536) : Colors.WHITE;
|
||||
}
|
||||
|
||||
default float getArmourAlpha(EquipmentSlot slot, ArmourLayer layer) {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
default float getTrimAlpha(EquipmentSlot slot, RegistryEntry<ArmorMaterial> material, ArmorTrim trim, ArmourLayer layer) {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
default float getElytraAlpha(ItemStack stack, Model model, LivingEntity entity) {
|
||||
return stack.isOf(Items.ELYTRA) ? 1F : 0F;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default VertexConsumer getTrimConsumer(EquipmentSlot slot, VertexConsumerProvider provider, RegistryEntry<ArmorMaterial> material, ArmorTrim trim, ArmourLayer layer) {
|
||||
@Nullable VertexConsumer buffer = getOptionalBuffer(provider, getTrimLayer(slot, material, trim, layer));
|
||||
if (buffer == null) {
|
||||
return null;
|
||||
}
|
||||
SpriteAtlasTexture armorTrimsAtlas = MinecraftClient.getInstance().getBakedModelManager().getAtlas(TexturedRenderLayers.ARMOR_TRIMS_ATLAS_TEXTURE);
|
||||
Sprite sprite = armorTrimsAtlas.getSprite(layer == ArmourLayer.INNER ? trim.getLeggingsModelId(material) : trim.getGenericModelId(material));
|
||||
return sprite.getTextureSpecificVertexConsumer(buffer);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default RenderLayer getTrimLayer(EquipmentSlot slot, RegistryEntry<ArmorMaterial> material, ArmorTrim trim, ArmourLayer layer) {
|
||||
return TexturedRenderLayers.getArmorTrims(trim.getPattern().value().decal());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default VertexConsumer getArmourConsumer(EquipmentSlot slot, VertexConsumerProvider provider, Identifier texture, ArmourLayer layer) {
|
||||
return getOptionalBuffer(provider, getArmourLayer(slot, texture, layer));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default RenderLayer getArmourLayer(EquipmentSlot slot, Identifier texture, ArmourLayer layer) {
|
||||
return RenderLayer.getArmorCutoutNoCull(texture);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default VertexConsumer getGlintConsumer(EquipmentSlot slot, VertexConsumerProvider provider, ArmourLayer layer) {
|
||||
return getOptionalBuffer(provider, getGlintLayer(slot, layer));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default RenderLayer getGlintLayer(EquipmentSlot slot, ArmourLayer layer) {
|
||||
return RenderLayer.getArmorEntityGlint();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default VertexConsumer getCapeConsumer(LivingEntity entity, VertexConsumerProvider provider, Identifier texture) {
|
||||
if (entity.getEquippedStack(EquipmentSlot.CHEST).isOf(Items.ELYTRA)) {
|
||||
return null;
|
||||
}
|
||||
return getOptionalBuffer(provider, getCapeLayer(entity, texture));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default RenderLayer getCapeLayer(LivingEntity entity, Identifier texture) {
|
||||
return RenderLayer.getEntitySolid(texture);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default VertexConsumer getElytraConsumer(ItemStack stack, Model model, LivingEntity entity, VertexConsumerProvider provider, Identifier texture) {
|
||||
return ItemRenderer.getDirectItemGlintConsumer(provider, model.getLayer(texture), false, getGlintAlpha(EquipmentSlot.CHEST, stack) > 0F);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static VertexConsumer getOptionalBuffer(VertexConsumerProvider provider, @Nullable RenderLayer layer) {
|
||||
return layer == null ? null : provider.getBuffer(layer);
|
||||
}
|
||||
|
||||
public enum ArmourType {
|
||||
ARMOUR,
|
||||
CAPE,
|
||||
ELYTRA,
|
||||
SKULL
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package com.minelittlepony.client.model.armour;
|
||||
|
||||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.google.common.collect.Interner;
|
||||
import com.google.common.collect.Interners;
|
||||
import com.minelittlepony.api.config.PonyConfig;
|
||||
import com.minelittlepony.util.ResourceUtil;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public record ArmourTexture(Identifier texture, ArmourVariant variant) {
|
||||
private static final Interner<ArmourTexture> INTERNER = Interners.newWeakInterner();
|
||||
public static final ArmourTexture UNKNOWN = legacy(TextureManager.MISSING_IDENTIFIER);
|
||||
|
||||
public boolean validate() {
|
||||
return texture != TextureManager.MISSING_IDENTIFIER && ResourceUtil.textureExists(texture);
|
||||
}
|
||||
|
||||
public static ArmourTexture legacy(Identifier texture) {
|
||||
return INTERNER.intern(new ArmourTexture(texture, ArmourVariant.LEGACY));
|
||||
}
|
||||
|
||||
public static ArmourTexture modern(Identifier texture) {
|
||||
return INTERNER.intern(new ArmourTexture(texture, ArmourVariant.NORMAL));
|
||||
}
|
||||
|
||||
public Stream<ArmourTexture> named() {
|
||||
return Stream.of(legacy(texture().withPath(p -> p.replace("1", "inner").replace("2", "outer"))), this);
|
||||
}
|
||||
|
||||
public Stream<ArmourTexture> ponify() {
|
||||
if (!PonyConfig.getInstance().disablePonifiedArmour.get()) {
|
||||
return Stream.of(this, modern(ResourceUtil.ponify(texture())));
|
||||
}
|
||||
return Stream.of(this);
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.minelittlepony.client.model.armour;
|
||||
|
||||
import net.minecraft.item.ArmorMaterial;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ArmourTextureLookup {
|
||||
ArmourTexture getTexture(ItemStack stack, ArmourLayer layer, ArmorMaterial.Layer armorLayer);
|
||||
|
||||
List<ArmorMaterial.Layer> getArmorLayers(ItemStack stack, int dyeColor);
|
||||
}
|
|
@ -1,24 +1,24 @@
|
|||
package com.minelittlepony.client.model.armour;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.CustomModelDataComponent;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.item.ArmorItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.minelittlepony.api.config.PonyConfig;
|
||||
import com.minelittlepony.util.ResourceUtil;
|
||||
|
||||
import com.google.common.cache.*;
|
||||
import com.google.common.collect.Interner;
|
||||
import com.google.common.collect.Interners;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* The default texture resolver used by Mine Little Pony.
|
||||
|
@ -35,89 +35,100 @@ import java.util.stream.Stream;
|
|||
* - the "minecraft" namespace is always replaced with "minelittlepony"
|
||||
* <p>
|
||||
*/
|
||||
public class ArmourTextureResolver implements ArmourTextureLookup, IdentifiableResourceReloadListener {
|
||||
public static final Identifier ID = MineLittlePony.id("armor_textures");
|
||||
public class ArmourTextureResolver {
|
||||
public static final ArmourTextureResolver INSTANCE = new ArmourTextureResolver();
|
||||
|
||||
private static final Interner<ArmorMaterial.Layer> LAYER_INTERNER = Interners.newWeakInterner();
|
||||
|
||||
private final LoadingCache<ArmourParameters, ArmourTexture> layerCache = CacheBuilder.newBuilder()
|
||||
private final Cache<String, Identifier> cache = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(30, TimeUnit.SECONDS)
|
||||
.build(CacheLoader.from(parameters -> {
|
||||
return Stream.of(ArmourTexture.legacy(parameters.material().getTexture(parameters.layer() == ArmourLayer.OUTER))).flatMap(i -> {
|
||||
if (parameters.layer() == ArmourLayer.OUTER) {
|
||||
return Stream.of(i, ArmourTexture.legacy(parameters.material().getTexture(false)));
|
||||
}
|
||||
return Stream.of(i);
|
||||
}).flatMap(i -> {
|
||||
if (parameters.customModelId() != 0) {
|
||||
return Stream.of(ArmourTexture.legacy(i.texture().withPath(p -> p.replace(".png", parameters.customModelId() + ".png"))), i);
|
||||
}
|
||||
return Stream.of(i);
|
||||
}).flatMap(this::performLookup).findFirst().orElse(ArmourTexture.UNKNOWN);
|
||||
}));
|
||||
private final LoadingCache<Identifier, List<ArmorMaterial.Layer>> nonDyedLayers = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(30, TimeUnit.SECONDS)
|
||||
.build(CacheLoader.from(material -> List.of(LAYER_INTERNER.intern(new ArmorMaterial.Layer(material, "", false)))));
|
||||
private final LoadingCache<Identifier, List<ArmorMaterial.Layer>> dyedLayers = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(30, TimeUnit.SECONDS)
|
||||
.build(CacheLoader.from(material -> List.of(
|
||||
LAYER_INTERNER.intern(new ArmorMaterial.Layer(material, "", false)),
|
||||
LAYER_INTERNER.intern(new ArmorMaterial.Layer(material, "overlay", true))
|
||||
)));
|
||||
|
||||
private Stream<ArmourTexture> performLookup(ArmourTexture id) {
|
||||
List<ArmourTexture> options = Stream.of(id)
|
||||
.flatMap(ArmourTexture::named)
|
||||
.flatMap(ArmourTexture::ponify)
|
||||
.toList();
|
||||
return options.stream().distinct()
|
||||
.filter(ArmourTexture::validate)
|
||||
.findFirst()
|
||||
.or(() -> {
|
||||
MineLittlePony.logger.warn("Could not identify correct texture to use for {}. Was none of: [" + System.lineSeparator() + "{}" + System.lineSeparator() + "]", id, options.stream()
|
||||
.map(ArmourTexture::texture)
|
||||
.map(Identifier::toString)
|
||||
.collect(Collectors.joining("," + System.lineSeparator())));
|
||||
return Optional.empty();
|
||||
}).stream();
|
||||
}
|
||||
.<String, Identifier>build();
|
||||
|
||||
public void invalidate() {
|
||||
layerCache.invalidateAll();
|
||||
nonDyedLayers.invalidateAll();
|
||||
dyedLayers.invalidateAll();
|
||||
cache.invalidateAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> reload(Synchronizer synchronizer, ResourceManager manager, Profiler prepareProfiler, Profiler applyProfiler, Executor prepareExecutor, Executor applyExecutor) {
|
||||
return CompletableFuture.runAsync(this::invalidate, prepareExecutor).thenCompose(synchronizer::whenPrepared);
|
||||
public Identifier getTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot, ArmourLayer layer, @Nullable String type) {
|
||||
Identifier material = stack.getItem() instanceof ArmorItem armor
|
||||
? new Identifier(armor.getMaterial().getName())
|
||||
: Registries.ITEM.getId(stack.getItem());
|
||||
String custom = getCustom(stack);
|
||||
|
||||
try {
|
||||
return cache.get(String.format("%s#%s#%s#%s", material, layer, type, custom), () -> {
|
||||
String typed = Strings.nullToEmpty(type);
|
||||
String extra = typed.isEmpty() ? "" : "_" + typed;
|
||||
|
||||
Identifier texture;
|
||||
|
||||
if (!"none".equals(custom)) {
|
||||
texture = resolveNewOrOld(material, layer, custom + extra, typed);
|
||||
if (texture != null) {
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
|
||||
texture = resolveNewOrOld(material, layer, extra, typed);
|
||||
if (texture != null) {
|
||||
return texture;
|
||||
}
|
||||
|
||||
return TextureManager.MISSING_IDENTIFIER;
|
||||
});
|
||||
} catch (ExecutionException ignored) {
|
||||
return TextureManager.MISSING_IDENTIFIER;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getFabricId() {
|
||||
return ID;
|
||||
private String getCustom(ItemStack stack) {
|
||||
if (stack.hasNbt() && stack.getNbt().contains("CustomModelData", NbtElement.NUMBER_TYPE)) {
|
||||
return "custom_" + stack.getNbt().getInt("CustomModelData");
|
||||
}
|
||||
return "none";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmourTexture getTexture(ItemStack stack, ArmourLayer layer, ArmorMaterial.Layer armorLayer) {
|
||||
return layerCache.getUnchecked(new ArmourParameters(layer, armorLayer, getCustom(stack)));
|
||||
}
|
||||
@Nullable
|
||||
private Identifier resolveNewOrOld(Identifier material, ArmourLayer layer, String extra, String type) {
|
||||
Identifier texture = resolveHumanOrPony(ResourceUtil.format("%s:textures/models/armor/%s_layer_%s%s.png", material.getNamespace(), material.getPath(), layer, extra), type);
|
||||
|
||||
@Override
|
||||
public List<ArmorMaterial.Layer> getArmorLayers(ItemStack stack, int dyeColor) {
|
||||
if (stack.getItem() instanceof ArmorItem armor) {
|
||||
return armor.getMaterial().value().layers();
|
||||
if (texture != null) {
|
||||
return texture;
|
||||
}
|
||||
|
||||
return (dyeColor == Colors.WHITE ? nonDyedLayers : dyedLayers).getUnchecked(Registries.ITEM.getId(stack.getItem()));
|
||||
return resolveHumanOrPony(ResourceUtil.format("%s:textures/models/armor/%s_layer_%d%s.png", material.getNamespace(), material.getPath(), layer.getLegacyId(), extra), type);
|
||||
}
|
||||
|
||||
private int getCustom(ItemStack stack) {
|
||||
return stack.getOrDefault(DataComponentTypes.CUSTOM_MODEL_DATA, CustomModelDataComponent.DEFAULT).value();
|
||||
@Nullable
|
||||
private Identifier resolveHumanOrPony(String res, String type) {
|
||||
Identifier human = new Identifier(res);
|
||||
|
||||
String domain = human.getNamespace();
|
||||
if ("minecraft".equals(domain)) {
|
||||
domain = "minelittlepony"; // it's a vanilla armor. I provide these.
|
||||
}
|
||||
|
||||
if (!PonyConfig.getInstance().disablePonifiedArmour.get()) {
|
||||
|
||||
Identifier pony = new Identifier(domain, human.getPath().replace(".png", "_pony.png"));
|
||||
|
||||
if (isValid(pony)) {
|
||||
return pony;
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid(human)) {
|
||||
return human;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private record ArmourParameters(ArmourLayer layer, ArmorMaterial.Layer material, int customModelId) {
|
||||
private final boolean isValid(Identifier texture) {
|
||||
return MinecraftClient.getInstance().getResourceManager().getResource(texture).isPresent();
|
||||
}
|
||||
|
||||
public ArmourVariant getVariant(ArmourLayer layer, Identifier resolvedTexture) {
|
||||
if (resolvedTexture.getPath().endsWith("_pony.png")) {
|
||||
return ArmourVariant.NORMAL;
|
||||
}
|
||||
return ArmourVariant.LEGACY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,10 +48,10 @@ public class EnderStallionModel extends SkeleponyModel<EndermanEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color) {
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
stack.push();
|
||||
stack.translate(0, -1.15F, 0);
|
||||
super.render(stack, vertices, overlay, light, color);
|
||||
super.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ public class GuardianPonyModel extends GuardianEntityModel implements PonyModelM
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color) {
|
||||
mixin().render(matrices, vertices, light, overlay, color);
|
||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
|
||||
mixin().render(matrices, vertices, light, overlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,8 +38,8 @@ public class ParaspriteModel<T extends LivingEntity> extends EntityModel<T> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color) {
|
||||
root.render(matrices, vertices, light, overlay, color);
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,13 +53,6 @@ public class PiglinPonyModel extends ZomponyModel<HostileEntity> {
|
|||
leftFlap.roll = 0.5235988F + MathHelper.cos(progress) * range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeadRotation(float animationProgress, float yaw, float pitch) {
|
||||
super.setHeadRotation(animationProgress, yaw, pitch);
|
||||
leftFlap.roll = -(float)(-(Math.cos((double)(animationProgress * (float) Math.PI * 0.2F * 1.2F)) + 2.5)) * 0.2F;
|
||||
rightFlap.roll = -(float)(Math.cos((double)(animationProgress * (float) Math.PI * 0.2F)) + 2.5) * 0.2F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotateLegs(float move, float swing, float ticks, HostileEntity entity) {
|
||||
super.rotateLegs(move, swing, ticks, entity);
|
||||
|
|
|
@ -21,7 +21,7 @@ public class SaddleModel<T extends LivingEntity> extends EntityModel<T> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color) {
|
||||
root.render(matrices, vertices, light, overlay, color);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraft.util.Arm;
|
|||
import net.minecraft.util.Hand;
|
||||
|
||||
import com.minelittlepony.api.model.MobPosingHelper;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.client.model.entity.race.AlicornModel;
|
||||
|
||||
public class SkeleponyModel<T extends HostileEntity> extends AlicornModel<T> {
|
||||
|
@ -59,11 +58,11 @@ public class SkeleponyModel<T extends HostileEntity> extends AlicornModel<T> {
|
|||
@Override
|
||||
protected void rotateLegs(float move, float swing, float ticks, T entity) {
|
||||
super.rotateLegs(move, swing, ticks, entity);
|
||||
if (rightArmPose != ArmPose.EMPTY && entity.isAttacking()) {
|
||||
if (rightArmPose != ArmPose.EMPTY) {
|
||||
rotateArmHolding(getArm(Arm.RIGHT), -1, getSwingAmount(), ticks);
|
||||
}
|
||||
|
||||
if (leftArmPose != ArmPose.EMPTY && entity.isAttacking()) {
|
||||
if (leftArmPose != ArmPose.EMPTY) {
|
||||
rotateArmHolding(getArm(Arm.LEFT), -1, getSwingAmount(), ticks);
|
||||
}
|
||||
}
|
||||
|
@ -73,8 +72,8 @@ public class SkeleponyModel<T extends HostileEntity> extends AlicornModel<T> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Race getRace() {
|
||||
return isUnicorn ? super.getRace() : Race.EARTH;
|
||||
public boolean hasMagic() {
|
||||
return isUnicorn;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,13 +5,12 @@ import com.minelittlepony.api.model.*;
|
|||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.SizePreset;
|
||||
import com.minelittlepony.client.model.part.UnicornHorn;
|
||||
import com.minelittlepony.client.util.render.RenderList;
|
||||
import com.minelittlepony.mson.api.ModelView;
|
||||
import com.minelittlepony.mson.util.RenderList;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +34,7 @@ public class UnicornModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
|||
super.init(context);
|
||||
horn = addPart(context.findByName("horn"));
|
||||
headRenderList.add(RenderList.of().add(head::rotate).add(forPart(horn)).checked(() -> getRace().hasHorn()));
|
||||
this.mainRenderList.add(withStage(BodyPart.HEAD, RenderList.of().add(head::rotate).add((stack, vertices, overlay, light, color) -> {
|
||||
this.mainRenderList.add(withStage(BodyPart.HEAD, RenderList.of().add(head::rotate).add((stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
||||
horn.renderMagic(stack, vertices, getAttributes().metadata.glowColor());
|
||||
})).checked(() -> hasMagic() && isCasting()));
|
||||
}
|
||||
|
@ -90,11 +89,8 @@ public class UnicornModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
|||
matrices.translate(0.4F - (0.3F * left), -0.675F, -0.3F);
|
||||
|
||||
UseAction action = getAttributes().heldStack.getUseAction();
|
||||
boolean shouldAimItem =
|
||||
(action == UseAction.SPYGLASS || action == UseAction.BOW) && getAttributes().itemUseTime > 0
|
||||
|| PonyConfig.getInstance().forwardHoldingItems.get().contains(Registries.ITEM.getId(getAttributes().heldStack.getItem()));
|
||||
|
||||
if (shouldAimItem) {
|
||||
if ((action == UseAction.SPYGLASS || action == UseAction.BOW) && getAttributes().itemUseTime > 0) {
|
||||
Arm main = getAttributes().mainArm;
|
||||
if (getAttributes().activeHand == Hand.OFF_HAND) {
|
||||
main = main.getOpposite();
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.minelittlepony.api.model.BodyPart;
|
|||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.api.model.gear.WearableGear;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.common.util.Color;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.UUID;
|
||||
|
@ -22,10 +23,9 @@ public class DeerAntlers extends WearableGear {
|
|||
dayChecked = true;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
dayResult = cal.get(Calendar.MONTH) == Calendar.DECEMBER
|
||||
&& cal.get(Calendar.DAY_OF_MONTH) == 25;
|
||||
&& Math.abs(cal.get(Calendar.DAY_OF_MONTH) - 25) < 2;
|
||||
}
|
||||
|
||||
|
||||
return dayResult;
|
||||
}
|
||||
|
||||
|
@ -62,12 +62,14 @@ public class DeerAntlers extends WearableGear {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, UUID interpolatorId) {
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||
if (tint != 0) {
|
||||
color = tint;
|
||||
red = Color.r(tint);
|
||||
green = Color.g(tint);
|
||||
blue = Color.b(tint);
|
||||
}
|
||||
|
||||
left.render(stack, vertices, overlay, light, color);
|
||||
right.render(stack, vertices, overlay, light, color);
|
||||
left.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
right.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class SaddleBags extends WearableGear {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer renderContext, int overlay, int light, int color, UUID interpolatorId) {
|
||||
public void render(MatrixStack stack, VertexConsumer renderContext, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
||||
|
||||
stack.push();
|
||||
if (wearable == Wearable.SADDLE_BAGS_BOTH) {
|
||||
|
@ -77,11 +77,11 @@ public class SaddleBags extends WearableGear {
|
|||
stack.translate(0, 0.3F, -0.3F);
|
||||
}
|
||||
|
||||
leftBag.render(stack, renderContext, overlay, light, color);
|
||||
rightBag.render(stack, renderContext, overlay, light, color);
|
||||
leftBag.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
||||
rightBag.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
||||
|
||||
stack.pop();
|
||||
strap.render(stack, renderContext, overlay, light, color);
|
||||
strap.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
||||
|
||||
stack.pop();
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class LionTail implements SubModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||
tail.render(stack, vertices, overlay, light, color);
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
tail.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PonyEars implements SubModel, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,7 @@ public class PonySnout implements SubModel, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -86,12 +86,12 @@ public class PonyTail implements SubModel, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
stack.push();
|
||||
tail.rotate(stack);
|
||||
|
||||
for (int i = 0; i < segments.size(); i++) {
|
||||
segments.get(i).render(this, stack, vertices, i, overlay, light, color, attributes);
|
||||
segments.get(i).render(this, stack, vertices, i, overlayUv, lightUv, red, green, blue, alpha, attributes);
|
||||
}
|
||||
|
||||
stack.pop();
|
||||
|
@ -104,7 +104,7 @@ public class PonyTail implements SubModel, MsonModel {
|
|||
this.tree = tree;
|
||||
}
|
||||
|
||||
public void render(PonyTail tail, MatrixStack stack, VertexConsumer renderContext, int index, int overlay, int light, int color, ModelAttributes attributes) {
|
||||
public void render(PonyTail tail, MatrixStack stack, VertexConsumer renderContext, int index, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
if (index >= tail.tailStop) {
|
||||
return;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ public class PonyTail implements SubModel, MsonModel {
|
|||
|
||||
if (attributes.isHorsey || tail.shape == TailShape.STRAIGHT) {
|
||||
tree.yaw = 0;
|
||||
tree.render(stack, renderContext, overlay, light, color);
|
||||
tree.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ public class PonyTail implements SubModel, MsonModel {
|
|||
tree.yaw = 0.2F * (index % 2 - 1);
|
||||
tree.pivotZ = 9;
|
||||
}
|
||||
tree.render(stack, renderContext, overlay, light, color);
|
||||
tree.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,9 +96,9 @@ public class PonyWings<T extends Model & WingedPonyModel<?>> implements SubModel
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||
getLeft().render(stack, vertices, overlay, light, color);
|
||||
getRight().render(stack, vertices, overlay, light, color);
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
getLeft().render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
getRight().render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public static class Wing implements MsonModel {
|
||||
|
@ -135,19 +135,19 @@ public class PonyWings<T extends Model & WingedPonyModel<?>> implements SubModel
|
|||
}
|
||||
}
|
||||
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color) {
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
||||
stack.push();
|
||||
stack.scale(wingScale, wingScale, wingScale);
|
||||
|
||||
if (pegasus.wingsAreOpen()) {
|
||||
extended.render(stack, vertices, overlay, light, color);
|
||||
extended.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
} else {
|
||||
boolean bags = pegasus.isWearing(Wearable.SADDLE_BAGS_BOTH);
|
||||
if (bags) {
|
||||
stack.push();
|
||||
stack.translate(0, 0, 0.198F);
|
||||
}
|
||||
folded.render(stack, vertices, overlay, light, color);
|
||||
folded.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
if (bags) {
|
||||
stack.pop();
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ public class SeaponyTail implements SubModel, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||
tailBase.render(stack, vertices, overlay, light, color);
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
tailBase.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import com.minelittlepony.api.model.SubModel;
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.client.render.MagicGlow;
|
||||
import com.minelittlepony.common.util.Color;
|
||||
|
||||
public class UnicornHorn implements SubModel {
|
||||
|
||||
|
@ -24,8 +25,8 @@ public class UnicornHorn implements SubModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||
horn.render(stack, vertices, overlay, light, color);
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
||||
horn.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void renderMagic(MatrixStack stack, VertexConsumer verts, int tint) {
|
||||
|
@ -33,7 +34,8 @@ public class UnicornHorn implements SubModel {
|
|||
Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
|
||||
|
||||
VertexConsumer vertices = immediate.getBuffer(MagicGlow.getRenderLayer());
|
||||
glow.render(stack, vertices, OverlayTexture.DEFAULT_UV, 0x0F00F0, (tint & 0xFFFFFF) | (102 << 24));
|
||||
|
||||
glow.render(stack, vertices, OverlayTexture.DEFAULT_UV, 0x0F00F0, Color.r(tint), Color.g(tint), Color.b(tint), 0.4F);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,22 +5,21 @@ import com.minelittlepony.api.events.Channel;
|
|||
import com.minelittlepony.api.events.PonyDataCallback;
|
||||
import com.minelittlepony.api.model.*;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.api.pony.PonyData;
|
||||
import com.minelittlepony.client.PonyDataLoader;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.transform.PonyPosture;
|
||||
import com.minelittlepony.mson.api.ModelKey;
|
||||
import com.minelittlepony.util.MathUtil;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.Frustum;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
|
@ -81,29 +80,61 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
|||
}
|
||||
models.applyMetadata(pony.metadata());
|
||||
models.body().updateLivingState(entity, pony, mode);
|
||||
|
||||
if (entity instanceof PlayerEntity player && entity instanceof RegistrationHandler handler) {
|
||||
handler.getSyncedPony().synchronize(player, pony);
|
||||
}
|
||||
}
|
||||
|
||||
public void setupTransforms(T entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||
public void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float tickDelta) {
|
||||
float s = getScaleFactor();
|
||||
stack.scale(s, s, s);
|
||||
|
||||
if (entity.hasVehicle() && entity.getVehicle() instanceof LivingEntity livingVehicles) {
|
||||
PonyRenderContext<LivingEntity, ?> renderer = MineLittlePony.getInstance().getRenderDispatcher().getPonyRenderer(livingVehicles);
|
||||
|
||||
if (renderer != null) {
|
||||
// negate vanilla translations so the rider begins at the ridees feet.
|
||||
stack.translate(0, -livingVehicles.getHeight(), 0);
|
||||
Pony pony = context.getEntityPony(entity);
|
||||
if (!pony.race().isHuman()) {
|
||||
renderer.getInternalRenderer().translateRider(livingVehicles, renderer.getEntityPony(livingVehicles), entity, pony, stack, tickDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof PlayerEntity) {
|
||||
if (getModels().body().getAttributes().isSitting) {
|
||||
stack.translate(0, 0.125D, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bodyYaw = getMountedYaw(entity, bodyYaw, tickDelta);
|
||||
transformer.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
|
||||
rotationYaw = getMountedYaw(entity, rotationYaw, tickDelta);
|
||||
transformer.setupTransforms(entity, stack, ageInTicks, rotationYaw, tickDelta);
|
||||
|
||||
PonyPosture.of(getModels().body().getAttributes()).apply(entity, getModels().body(), stack, bodyYaw, tickDelta, 1);
|
||||
PonyPosture.of(getModels().body().getAttributes()).apply(entity, getModels().body(), stack, rotationYaw, tickDelta, 1);
|
||||
}
|
||||
|
||||
private float getMountedYaw(T entity, float bodyYaw, float tickDelta) {
|
||||
if (entity.hasVehicle() && entity.getVehicle() instanceof LivingEntity mount) {
|
||||
return bodyYaw + MathUtil.interpolateDegress(mount.prevBodyYaw, mount.bodyYaw, tickDelta);
|
||||
private void translateRider(T entity, Pony pony, LivingEntity passenger, Pony passengerPony, MatrixStack stack, float tickDelta) {
|
||||
if (!passengerPony.race().isHuman()) {
|
||||
float yaw = MathUtil.interpolateDegress((float)entity.prevY, (float)entity.getY(), tickDelta);
|
||||
|
||||
models.applyMetadata(pony.metadata());
|
||||
models.body().transform(BodyPart.BACK, stack);
|
||||
|
||||
PonyPosture.of(models.body().getAttributes()).apply(entity, getModels().body(), stack, yaw, tickDelta, -1);
|
||||
}
|
||||
return bodyYaw;
|
||||
}
|
||||
|
||||
private float getMountedYaw(T entity, float rotationYaw, float partialTicks) {
|
||||
if (entity.hasVehicle()) {
|
||||
Entity mount = entity.getVehicle();
|
||||
if (mount instanceof LivingEntity) {
|
||||
return MathUtil.interpolateDegress(((LivingEntity) mount).prevBodyYaw, ((LivingEntity) mount).bodyYaw, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
return rotationYaw;
|
||||
}
|
||||
|
||||
public float getScaleFactor() {
|
||||
|
@ -137,7 +168,7 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
|||
}
|
||||
|
||||
public interface Transformer<T extends LivingEntity> {
|
||||
void setupTransforms(T entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale);
|
||||
void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks);
|
||||
}
|
||||
|
||||
public interface RegistrationHandler {
|
||||
|
@ -151,25 +182,14 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
|||
public static class SyncedPony {
|
||||
@Nullable
|
||||
private Pony lastRenderedPony;
|
||||
private Supplier<Optional<PonyData>> lastPonyData = PonyDataLoader.NULL;
|
||||
@Nullable
|
||||
private Pony lastTransmittedPony;
|
||||
|
||||
public Pony getCachedPony() {
|
||||
return lastRenderedPony;
|
||||
}
|
||||
|
||||
public PonyData getCachedPonyData() {
|
||||
return lastPonyData.get().orElse(PonyData.NULL);
|
||||
}
|
||||
|
||||
public void synchronize(PlayerEntity player) {
|
||||
Pony pony = Pony.getManager().getPony(player);
|
||||
public void synchronize(PlayerEntity player, Pony pony) {
|
||||
boolean changed = pony.compareTo(lastRenderedPony) != 0;
|
||||
|
||||
if (changed) {
|
||||
lastRenderedPony = pony;
|
||||
lastPonyData = pony.metadataGetter();
|
||||
player.calculateDimensions();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,36 +1,31 @@
|
|||
package com.minelittlepony.client.render;
|
||||
|
||||
import com.minelittlepony.api.config.PonyConfig;
|
||||
import com.minelittlepony.api.model.HornedPonyModel;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.common.util.render.RenderLayerUtil;
|
||||
import com.minelittlepony.client.util.render.RenderLayerUtil;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.item.CrossbowItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.PlayerScreenHandler;
|
||||
import net.minecraft.util.UseAction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LevitatingItemRenderer {
|
||||
private VertexConsumerProvider getProvider(Pony pony, VertexConsumerProvider provider) {
|
||||
private VertexConsumerProvider getProvider(Pony pony, VertexConsumerProvider renderContext) {
|
||||
final int color = pony.metadata().glowColor();
|
||||
return layer -> {
|
||||
if (layer.getVertexFormat() != VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL) {
|
||||
return provider.getBuffer(layer);
|
||||
return renderContext.getBuffer(layer);
|
||||
}
|
||||
return provider.getBuffer(MagicGlow.getColoured(RenderLayerUtil.getTexture(layer).orElse(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE), color));
|
||||
return renderContext.getBuffer(MagicGlow.getColoured(RenderLayerUtil.getTexture(layer).orElse(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE), color));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -39,55 +34,39 @@ public class LevitatingItemRenderer {
|
|||
*/
|
||||
public void renderItem(ItemRenderer itemRenderer, @Nullable LivingEntity entity, ItemStack stack, ModelTransformationMode mode, boolean left, MatrixStack matrix, VertexConsumerProvider renderContext, @Nullable World world, int lightUv, int posLong) {
|
||||
|
||||
if (entity != null && (mode.isFirstPerson()
|
||||
if (mode.isFirstPerson()
|
||||
|| mode == ModelTransformationMode.THIRD_PERSON_LEFT_HAND
|
||||
|| mode == ModelTransformationMode.THIRD_PERSON_RIGHT_HAND)
|
||||
|| mode == ModelTransformationMode.THIRD_PERSON_RIGHT_HAND
|
||||
) {
|
||||
if (MineLittlePony.getInstance().getRenderDispatcher().getPonyRenderer(entity) instanceof PonyRenderContext<LivingEntity, ?> context) {
|
||||
Pony pony = context.getEntityPony(entity);
|
||||
if (context.getInternalRenderer().getModels().body() instanceof HornedPonyModel model) {
|
||||
matrix.push();
|
||||
Pony.getManager().getPony(entity).ifPresentOrElse(pony -> {
|
||||
matrix.push();
|
||||
|
||||
boolean doMagic = (mode.isFirstPerson() ? PonyConfig.getInstance().fpsmagic : PonyConfig.getInstance().tpsmagic).get() && model.hasMagic();
|
||||
boolean doMagic = PonyConfig.getInstance().fpsmagic.get() && pony.hasMagic();
|
||||
|
||||
if (doMagic && mode.isFirstPerson()) {
|
||||
setupPerspective(itemRenderer, entity, stack, left, matrix);
|
||||
}
|
||||
|
||||
itemRenderer.renderItem(entity, stack, mode, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||
|
||||
if (doMagic) {
|
||||
VertexConsumerProvider interceptedContext = getProvider(pony, renderContext);
|
||||
|
||||
if (stack.hasGlint()) {
|
||||
stack = stack.copy();
|
||||
stack.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, false);
|
||||
}
|
||||
|
||||
float tickDelta = MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false) + entity.age;
|
||||
|
||||
|
||||
float driftStrength = 0.002F;
|
||||
float xDrift = MathHelper.sin(tickDelta / 20F) * driftStrength;
|
||||
float zDrift = MathHelper.cos((tickDelta + 20) / 20F) * driftStrength;
|
||||
|
||||
float scale = 1.1F + (MathHelper.sin(tickDelta / 20F) + 1) * driftStrength;
|
||||
matrix.scale(scale, scale, scale);
|
||||
matrix.translate(0.015F + xDrift, 0.01F, 0.01F + zDrift);
|
||||
|
||||
itemRenderer.renderItem(entity, stack, mode, left, matrix, interceptedContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||
matrix.scale(scale, scale, scale);
|
||||
matrix.translate(-0.03F - xDrift, -0.02F, -0.02F - zDrift);
|
||||
itemRenderer.renderItem(entity, stack, mode, left, matrix, interceptedContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||
}
|
||||
|
||||
matrix.pop();
|
||||
return;
|
||||
if (doMagic && mode.isFirstPerson()) {
|
||||
setupPerspective(itemRenderer, entity, stack, left, matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
itemRenderer.renderItem(entity, stack, mode, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||
itemRenderer.renderItem(entity, stack, mode, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||
|
||||
if (doMagic) {
|
||||
VertexConsumerProvider interceptedContext = getProvider(pony, renderContext);
|
||||
|
||||
matrix.scale(1.1F, 1.1F, 1.1F);
|
||||
matrix.translate(0.015F, 0.01F, 0.01F);
|
||||
|
||||
itemRenderer.renderItem(entity, stack, mode, left, matrix, interceptedContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||
matrix.translate(-0.03F, -0.02F, -0.02F);
|
||||
itemRenderer.renderItem(entity, stack, mode, left, matrix, interceptedContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||
}
|
||||
|
||||
matrix.pop();
|
||||
}, () -> {
|
||||
itemRenderer.renderItem(entity, stack, mode, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||
});
|
||||
} else {
|
||||
itemRenderer.renderItem(entity, stack, mode, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,10 +87,7 @@ public class LevitatingItemRenderer {
|
|||
boolean handHeldTool =
|
||||
action == UseAction.BOW
|
||||
|| action == UseAction.CROSSBOW
|
||||
|| action == UseAction.BLOCK
|
||||
|| item.getItem() instanceof ToolItem
|
||||
|| item.getItem() instanceof RangedWeaponItem
|
||||
|| PonyConfig.getInstance().forwardHoldingItems.get().contains(Registries.ITEM.getId(item.getItem()));
|
||||
|| action == UseAction.BLOCK;
|
||||
|
||||
float distanceChange = handHeldTool ? -0.3F : -0.6F;
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ public abstract class MagicGlow extends RenderPhase {
|
|||
.transparency(LIGHTNING_TRANSPARENCY)
|
||||
.lightmap(DISABLE_LIGHTMAP)
|
||||
.cull(DISABLE_CULLING)
|
||||
.layering(VIEW_OFFSET_Z_LAYERING)
|
||||
.build(false));
|
||||
});
|
||||
|
||||
|
@ -43,7 +42,6 @@ public abstract class MagicGlow extends RenderPhase {
|
|||
.transparency(LIGHTNING_TRANSPARENCY)
|
||||
.lightmap(DISABLE_LIGHTMAP)
|
||||
.cull(DISABLE_CULLING)
|
||||
.layering(VIEW_OFFSET_Z_LAYERING)
|
||||
.build(true));
|
||||
});
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.entity.EntityType;
|
|||
/**
|
||||
* Central location where new entity renderers are registered and applied.
|
||||
*/
|
||||
public class MobRenderers {
|
||||
public final class MobRenderers {
|
||||
public static final Map<String, MobRenderers> REGISTRY = new HashMap<>();
|
||||
|
||||
public static final MobRenderers VILLAGER = register("villagers", (state, pony) -> {
|
||||
|
|
|
@ -2,9 +2,7 @@ package com.minelittlepony.client.render;
|
|||
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.api.model.PreviewModel;
|
||||
import com.minelittlepony.api.pony.*;
|
||||
import com.minelittlepony.client.mixin.MixinEntityRenderers;
|
||||
import com.minelittlepony.client.render.entity.*;
|
||||
|
@ -20,6 +18,7 @@ import net.minecraft.client.util.SkinTextures;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
* Render manager responsible for replacing and restoring entity renderers when the client settings change.
|
||||
|
@ -27,17 +26,6 @@ import net.minecraft.entity.LivingEntity;
|
|||
public class PonyRenderDispatcher {
|
||||
private LevitatingItemRenderer magicRenderer = new LevitatingItemRenderer();
|
||||
|
||||
public PonyRenderDispatcher() {
|
||||
PonyForm.register(PonyForm.DEFAULT, Predicates.alwaysTrue(), PlayerPonyRenderer::new);
|
||||
PonyForm.register(PonyForm.SEAPONY, PonyPosture::hasSeaponyForm, (context, slimArms) -> new AquaticPlayerPonyRenderer(context, slimArms, DefaultPonySkinHelper.SEAPONY_SKIN_TYPE_ID, entity -> {
|
||||
if (entity instanceof PreviewModel preview) {
|
||||
return preview.getForm() == PonyForm.SEAPONY;
|
||||
}
|
||||
return PonyPosture.hasSeaponyForm(entity) && PonyPosture.isPartiallySubmerged(entity);
|
||||
}));
|
||||
PonyForm.register(PonyForm.NIRIK, PonyPosture::hasNirikForm, (context, slimArms) -> new FormChangingPlayerPonyRenderer(context, slimArms, DefaultPonySkinHelper.NIRIK_SKIN_TYPE_ID, PonyPosture::hasNirikForm));
|
||||
}
|
||||
|
||||
public LevitatingItemRenderer getMagicRenderer() {
|
||||
return magicRenderer;
|
||||
}
|
||||
|
@ -46,20 +34,42 @@ public class PonyRenderDispatcher {
|
|||
* Registers all new player skin types. (currently only pony and slimpony).
|
||||
*/
|
||||
public void initialise(EntityRenderDispatcher manager, boolean force) {
|
||||
PonyForm.REGISTRY.values().forEach(form -> {
|
||||
for (SkinTextures.Model armShape : SkinTextures.Model.values()) {
|
||||
Mson.getInstance().getEntityRendererRegistry().registerPlayerRenderer(
|
||||
form.id().withSuffixedPath("/" + armShape.getName()),
|
||||
player -> !Pony.getManager().getPony(player).race().isHuman()
|
||||
&& player.getSkinTextures().model() == armShape
|
||||
&& form.shouldApply().test(player) && PonyForm.of(player) == form,
|
||||
context -> form.factory().create(context, armShape == SkinTextures.Model.SLIM)
|
||||
);
|
||||
}
|
||||
});
|
||||
for (SkinTextures.Model armShape : SkinTextures.Model.values()) {
|
||||
addPlayerRenderer(armShape);
|
||||
}
|
||||
MobRenderers.REGISTRY.values().forEach(i -> i.apply(this, force));
|
||||
}
|
||||
|
||||
private void addPlayerRenderer(SkinTextures.Model armShape) {
|
||||
Mson.getInstance().getEntityRendererRegistry().registerPlayerRenderer(
|
||||
new Identifier("minelittlepony", "sea/" + armShape.getName()),
|
||||
player -> {
|
||||
return !Pony.getManager().getPony(player).race().isHuman()
|
||||
&& PonyPosture.hasSeaponyForm(player)
|
||||
&& player.getSkinTextures().model() == armShape;
|
||||
},
|
||||
context -> new AquaticPlayerPonyRenderer(context, armShape == SkinTextures.Model.SLIM)
|
||||
);
|
||||
Mson.getInstance().getEntityRendererRegistry().registerPlayerRenderer(
|
||||
new Identifier("minelittlepony", "nirik/" + armShape.getName()),
|
||||
player -> {
|
||||
return !Pony.getManager().getPony(player).race().isHuman()
|
||||
&& PonyPosture.hasNirikForm(player)
|
||||
&& player.getSkinTextures().model() == armShape;
|
||||
},
|
||||
context -> new FormChangingPlayerPonyRenderer(context, armShape == SkinTextures.Model.SLIM, DefaultPonySkinHelper.NIRIK_SKIN_TYPE_ID, PonyPosture::isNirikModifier)
|
||||
);
|
||||
Mson.getInstance().getEntityRendererRegistry().registerPlayerRenderer(
|
||||
new Identifier("minelittlepony", "land/" + armShape.getName()),
|
||||
player -> {
|
||||
return !Pony.getManager().getPony(player).race().isHuman()
|
||||
&& !PonyPosture.hasSeaponyForm(player) && !PonyPosture.hasNirikForm(player)
|
||||
&& player.getSkinTextures().model() == armShape;
|
||||
},
|
||||
context -> new PlayerPonyRenderer(context, armShape == SkinTextures.Model.SLIM)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Replaces an entity renderer depending on whether we want ponies or not.
|
||||
|
@ -70,17 +80,25 @@ public class PonyRenderDispatcher {
|
|||
* @param <T> The entity type
|
||||
*/
|
||||
<T extends Entity, V extends T> void switchRenderer(MobRenderers state, EntityType<V> type, Function<EntityRendererFactory.Context, EntityRenderer<T>> factory) {
|
||||
Mson.getInstance().getEntityRendererRegistry().registerEntityRenderer(type, ctx -> state.get()
|
||||
? factory.apply(ctx)
|
||||
: MixinEntityRenderers.getRendererFactories().get(type).create(ctx)
|
||||
);
|
||||
Mson.getInstance().getEntityRendererRegistry().registerEntityRenderer(type, ctx -> {
|
||||
if (!state.get()) {
|
||||
return MixinEntityRenderers.getRendererFactories().get(type).create(ctx);
|
||||
}
|
||||
return factory.apply(ctx);
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public <T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> PonyRenderContext<T, M> getPonyRenderer(@Nullable T entity) {
|
||||
if (entity != null && MinecraftClient.getInstance().getEntityRenderDispatcher().getRenderer(entity) instanceof PonyRenderContext c) {
|
||||
return c;
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
EntityRenderer<?> renderer = MinecraftClient.getInstance().getEntityRenderDispatcher().getRenderer(entity);
|
||||
|
||||
if (renderer instanceof PonyRenderContext) {
|
||||
return (PonyRenderContext<T, M>) renderer;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -7,13 +7,13 @@ import com.minelittlepony.client.model.AbstractPonyModel;
|
|||
import com.minelittlepony.client.render.MobRenderers;
|
||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer.ISkull;
|
||||
import com.minelittlepony.mson.api.ModelKey;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.type.ProfileComponent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class MobSkull implements ISkull {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Identifier getSkinResource(@Nullable ProfileComponent profile) {
|
||||
public Identifier getSkinResource(@Nullable GameProfile profile) {
|
||||
return texture;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class MobSkull implements ISkull {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int light, int overlay, int color) {
|
||||
ponyHead.get().headRenderList.accept(stack, vertices, light, overlay, color);
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int lightUv, int overlayUv, float red, float green, float blue, float alpha) {
|
||||
ponyHead.get().headRenderList.accept(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.minelittlepony.api.pony.SkinsProxy;
|
|||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.client.model.*;
|
||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer.ISkull;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -14,7 +15,6 @@ import java.util.Map;
|
|||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.DefaultSkinHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.type.ProfileComponent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
|
@ -35,17 +35,17 @@ public class PlayerPonySkull implements ISkull {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Identifier getSkinResource(@Nullable ProfileComponent profile) {
|
||||
renderingEars = profile != null && "deadmau5".equals(profile.gameProfile().getName());
|
||||
public Identifier getSkinResource(@Nullable GameProfile profile) {
|
||||
renderingEars = profile != null && "deadmau5".equals(profile.getName());
|
||||
|
||||
if (profile != null) {
|
||||
Identifier skin = SkinsProxy.instance.getSkinTexture(profile.gameProfile());
|
||||
Identifier skin = SkinsProxy.instance.getSkinTexture(profile);
|
||||
|
||||
if (skin != null) {
|
||||
return skin;
|
||||
}
|
||||
|
||||
return DefaultSkinHelper.getSkinTextures(profile.gameProfile()).texture();
|
||||
return DefaultSkinHelper.getSkinTextures(profile).texture();
|
||||
}
|
||||
|
||||
return DefaultSkinHelper.getTexture();
|
||||
|
@ -80,18 +80,18 @@ public class PlayerPonySkull implements ISkull {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int light, int overlay, int color) {
|
||||
public void render(MatrixStack stack, VertexConsumer vertices, int lightUv, int overlayUv, float red, float green, float blue, float alpha) {
|
||||
stack.push();
|
||||
ponyHead.headRenderList.accept(stack, vertices, light, overlay, color);
|
||||
ponyHead.headRenderList.accept(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
stack.pop();
|
||||
stack.push();
|
||||
ponyHead.helmetRenderList.accept(stack, vertices, light, overlay, color);
|
||||
ponyHead.helmetRenderList.accept(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
stack.pop();
|
||||
if (renderingEars) {
|
||||
stack.push();
|
||||
stack.scale(1.3333334f, 1.3333334f, 1.3333334f);
|
||||
stack.translate(0, 0.05F, 0);
|
||||
deadMau5.render(stack, vertices, light, overlay, color);
|
||||
deadMau5.render(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,23 @@
|
|||
package com.minelittlepony.client.render.blockentity.skull;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.api.config.PonyConfig;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
import com.minelittlepony.client.render.MobRenderers;
|
||||
import com.minelittlepony.client.render.entity.*;
|
||||
import com.minelittlepony.common.util.Color;
|
||||
import com.minelittlepony.client.render.entity.SkeleponyRenderer;
|
||||
import com.minelittlepony.client.render.entity.ZomponyRenderer;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.block.AbstractSkullBlock;
|
||||
import net.minecraft.block.SkullBlock;
|
||||
import net.minecraft.block.SkullBlock.SkullType;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.entity.SkullBlockEntityModel;
|
||||
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.ProfileComponent;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -38,44 +25,29 @@ import org.jetbrains.annotations.Nullable;
|
|||
* PonySkullRenderer! It renders ponies as skulls, or something...
|
||||
*/
|
||||
public class PonySkullRenderer {
|
||||
public static final PonySkullRenderer INSTANCE = new PonySkullRenderer();
|
||||
|
||||
private Map<SkullBlock.SkullType, ISkull> skulls = Map.of();
|
||||
private Map<SkullBlock.SkullType, SkullBlockEntityModel> headModels = Map.of();
|
||||
private static final Map<SkullBlock.SkullType, ISkull> SKULLS = Maps.newHashMap();
|
||||
|
||||
private ISkull selectedSkull;
|
||||
private Identifier selectedSkin;
|
||||
private static ISkull selectedSkull;
|
||||
private static Identifier selectedSkin;
|
||||
|
||||
boolean isBeingWorn;
|
||||
boolean isPony;
|
||||
|
||||
public void reload() {
|
||||
skulls = Util.make(new HashMap<>(), skullMap -> {
|
||||
skullMap.put(SkullBlock.Type.SKELETON, new MobSkull(SkeleponyRenderer.SKELETON, MobRenderers.SKELETON, ModelType.SKELETON));
|
||||
skullMap.put(SkullBlock.Type.WITHER_SKELETON, new MobSkull(SkeleponyRenderer.WITHER, MobRenderers.SKELETON, ModelType.SKELETON));
|
||||
skullMap.put(SkullBlock.Type.ZOMBIE, new MobSkull(ZomponyRenderer.ZOMBIE, MobRenderers.ZOMBIE, ModelType.ZOMBIE));
|
||||
skullMap.put(SkullBlock.Type.PIGLIN, new MobSkull(PonyPiglinRenderer.PIGLIN, MobRenderers.PIGLIN, ModelType.PIGLIN));
|
||||
skullMap.put(SkullBlock.Type.PLAYER, new PlayerPonySkull());
|
||||
});
|
||||
headModels = SkullBlockEntityRenderer.getModels(MinecraftClient.getInstance().getEntityModelLoader());
|
||||
public static void reload() {
|
||||
SKULLS.clear();
|
||||
loadSkulls(SKULLS);
|
||||
}
|
||||
|
||||
public void renderSkull(MatrixStack matrices, VertexConsumerProvider provider, ItemStack stack, LivingEntity entity, float tickDelta, int light, boolean isPony) {
|
||||
isBeingWorn = true;
|
||||
this.isPony = isPony;
|
||||
SkullType type = ((AbstractSkullBlock) ((BlockItem) stack.getItem()).getBlock()).getSkullType();
|
||||
SkullBlockEntityModel skullBlockEntityModel = headModels.get(type);
|
||||
RenderLayer renderLayer = SkullBlockEntityRenderer.getRenderLayer(type, stack.get(DataComponentTypes.PROFILE));
|
||||
SkullBlockEntityRenderer.renderSkull(null, 180, (entity.getVehicle() instanceof LivingEntity l ? l : entity).limbAnimator.getPos(tickDelta), matrices, provider, light, skullBlockEntityModel, renderLayer);
|
||||
isBeingWorn = false;
|
||||
this.isPony = false;
|
||||
private static void loadSkulls(Map<SkullBlock.SkullType, ISkull> skullMap) {
|
||||
skullMap.put(SkullBlock.Type.SKELETON, new MobSkull(SkeleponyRenderer.SKELETON, MobRenderers.SKELETON, ModelType.SKELETON));
|
||||
skullMap.put(SkullBlock.Type.WITHER_SKELETON, new MobSkull(SkeleponyRenderer.WITHER, MobRenderers.SKELETON, ModelType.SKELETON));
|
||||
skullMap.put(SkullBlock.Type.ZOMBIE, new MobSkull(ZomponyRenderer.ZOMBIE, MobRenderers.ZOMBIE, ModelType.ZOMBIE));
|
||||
skullMap.put(SkullBlock.Type.PLAYER, new PlayerPonySkull());
|
||||
}
|
||||
|
||||
public RenderLayer getSkullRenderLayer(SkullBlock.SkullType skullType, @Nullable ProfileComponent profile) {
|
||||
public static RenderLayer getSkullRenderLayer(SkullBlock.SkullType skullType, @Nullable GameProfile profile) {
|
||||
selectedSkull = null;
|
||||
selectedSkin = null;
|
||||
|
||||
ISkull skull = skulls.get(skullType);
|
||||
ISkull skull = SKULLS.get(skullType);
|
||||
|
||||
if (skull == null || !skull.canRender(PonyConfig.getInstance())) {
|
||||
return null;
|
||||
|
@ -86,12 +58,16 @@ public class PonySkullRenderer {
|
|||
return RenderLayer.getEntityTranslucent(selectedSkin);
|
||||
}
|
||||
|
||||
public boolean renderSkull(@Nullable Direction direction,
|
||||
public static boolean renderSkull(@Nullable Direction direction,
|
||||
float yaw, float animationProgress,
|
||||
MatrixStack stack, VertexConsumerProvider renderContext, RenderLayer layer,
|
||||
int light) {
|
||||
int lightUv) {
|
||||
|
||||
if (selectedSkull == null || !selectedSkull.canRender(PonyConfig.getInstance()) || !selectedSkull.bindPony(Pony.getManager().getPony(selectedSkin))) {
|
||||
if (selectedSkull == null || !selectedSkull.canRender(PonyConfig.getInstance())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!selectedSkull.bindPony(Pony.getManager().getPony(selectedSkin))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -100,6 +76,7 @@ public class PonySkullRenderer {
|
|||
if (direction == null) {
|
||||
stack.translate(0.5, 0, 0.5);
|
||||
} else {
|
||||
|
||||
final float offset = 0.25F;
|
||||
stack.translate(
|
||||
0.5F - direction.getOffsetX() * offset,
|
||||
|
@ -112,7 +89,7 @@ public class PonySkullRenderer {
|
|||
VertexConsumer vertices = renderContext.getBuffer(layer);
|
||||
|
||||
selectedSkull.setAngles(yaw, animationProgress);
|
||||
selectedSkull.render(stack, vertices, light, OverlayTexture.DEFAULT_UV, Color.argbToHex(ArmourRendererPlugin.INSTANCE.get().getArmourAlpha(EquipmentSlot.HEAD, ArmourLayer.OUTER), 1, 1, 1));
|
||||
selectedSkull.render(stack, vertices, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
||||
|
||||
stack.pop();
|
||||
|
||||
|
@ -125,18 +102,15 @@ public class PonySkullRenderer {
|
|||
* Implement this interface if you want to extend our behaviour, modders.
|
||||
*/
|
||||
public interface ISkull {
|
||||
|
||||
void setAngles(float angle, float poweredTicks);
|
||||
|
||||
void render(MatrixStack stack, VertexConsumer vertices, int light, int overlay, int color);
|
||||
void render(MatrixStack stack, VertexConsumer vertices, int lightUv, int overlayUv, float red, float green, float blue, float alpha);
|
||||
|
||||
boolean canRender(PonyConfig config);
|
||||
|
||||
Identifier getSkinResource(@Nullable ProfileComponent profile);
|
||||
Identifier getSkinResource(@Nullable GameProfile profile);
|
||||
|
||||
boolean bindPony(Pony pony);
|
||||
}
|
||||
|
||||
public interface SkullRenderer {
|
||||
Map<SkullBlock.SkullType, SkullBlockEntityModel> getModels();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
|
|||
protected void addFeatures(EntityRendererFactory.Context context) {
|
||||
addFeature(new ArmourFeature<>(this, context.getModelManager()));
|
||||
addFeature(createHeldItemFeature(context));
|
||||
addFeature(new SkullFeature<>(this, context.getModelLoader(), context.getItemRenderer()));
|
||||
addFeature(new SkullFeature<>(this, context.getModelLoader()));
|
||||
addFeature(new ElytraFeature<>(this));
|
||||
addFeature(new GearFeature<>(this));
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void setupTransforms(T entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||
manager.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
|
||||
protected void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
||||
manager.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,20 +94,18 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
|
|||
if (!entity.hasVehicle()) {
|
||||
stack.translate(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
|
||||
} else {
|
||||
if (manager.getModels().body().getAttributes().isSitting && entity.hasVehicle()) {
|
||||
stack.translate(0, 0.25F, 0);
|
||||
}
|
||||
stack.translate(0, entity.getRidingOffset(entity.getVehicle()), 0);
|
||||
}
|
||||
|
||||
stack.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabelIfPresent(T entity, Text name, MatrixStack matrices, VertexConsumerProvider vertices, int light, float tickDelta) {
|
||||
matrices.push();
|
||||
matrices.translate(0, manager.getNamePlateYOffset(entity), 0);
|
||||
super.renderLabelIfPresent(entity, name, matrices, vertices, light, tickDelta);
|
||||
matrices.pop();
|
||||
protected void renderLabelIfPresent(T entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) {
|
||||
stack.push();
|
||||
stack.translate(0, manager.getNamePlateYOffset(entity), 0);
|
||||
super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance);
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.minelittlepony.client.model.entity.BreezieModel;
|
|||
* AKA a breezie :D
|
||||
*/
|
||||
public class AllayRenderer extends MobEntityRenderer<AllayEntity, BreezieModel<AllayEntity>> {
|
||||
public static final Identifier BREEZIE_PONIES = MineLittlePony.id("textures/entity/allay/pony");
|
||||
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);
|
||||
|
|
|
@ -5,19 +5,16 @@ import com.minelittlepony.api.pony.*;
|
|||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.util.MathUtil;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class AquaticPlayerPonyRenderer extends FormChangingPlayerPonyRenderer {
|
||||
|
||||
public AquaticPlayerPonyRenderer(EntityRendererFactory.Context context, boolean slim, Identifier alternateFormSkinId, Predicate<AbstractClientPlayerEntity> formModifierPredicate) {
|
||||
super(context, slim, alternateFormSkinId, formModifierPredicate);
|
||||
public AquaticPlayerPonyRenderer(EntityRendererFactory.Context context, boolean slim) {
|
||||
super(context, slim, DefaultPonySkinHelper.SEAPONY_SKIN_TYPE_ID, PonyPosture::isSeaponyModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,18 +32,18 @@ public class AquaticPlayerPonyRenderer extends FormChangingPlayerPonyRenderer {
|
|||
@Override
|
||||
protected Race getPlayerRace(AbstractClientPlayerEntity entity, Pony pony) {
|
||||
Race race = super.getPlayerRace(entity, pony);
|
||||
return transformed ? Race.SEAPONY : race == Race.SEAPONY ? Race.UNICORN : race;
|
||||
return PonyPosture.isSeaponyModifier(entity) ? Race.SEAPONY : race == Race.SEAPONY ? Race.UNICORN : race;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupTransforms(AbstractClientPlayerEntity player, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||
if (transformed) {
|
||||
matrices.translate(0, 0.6 * scale, 0);
|
||||
protected void setupTransforms(AbstractClientPlayerEntity player, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
||||
if (PonyPosture.isSeaponyModifier(player)) {
|
||||
stack.translate(0, 0.6, 0);
|
||||
if (player.isInSneakingPose()) {
|
||||
matrices.translate(0, 0.125 * scale, 0);
|
||||
stack.translate(0, 0.125, 0);
|
||||
}
|
||||
}
|
||||
super.setupTransforms(player, matrices, animationProgress, bodyYaw, tickDelta, scale);
|
||||
super.setupTransforms(player, stack, ageInTicks, rotationYaw, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.client.render.entity;
|
||||
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.EnderStallionModel;
|
||||
import com.minelittlepony.client.render.entity.feature.GlowingEyesFeature;
|
||||
|
@ -20,8 +19,9 @@ import net.minecraft.util.Identifier;
|
|||
import java.util.Random;
|
||||
|
||||
public class EnderStallionRenderer extends PonyRenderer<EndermanEntity, EnderStallionModel> implements IGlowingRenderer {
|
||||
public static final Identifier ENDERMAN = MineLittlePony.id("textures/entity/enderman/enderman_pony.png");
|
||||
private static final Identifier EYES = MineLittlePony.id("textures/entity/enderman/enderman_pony_eyes.png");
|
||||
|
||||
public static final Identifier ENDERMAN = new Identifier("minelittlepony", "textures/entity/enderman/enderman_pony.png");
|
||||
private static final Identifier EYES = new Identifier("minelittlepony", "textures/entity/enderman/enderman_pony_eyes.png");
|
||||
|
||||
private final Random rnd = new Random();
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package com.minelittlepony.client.render.entity;
|
||||
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.api.pony.*;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class FormChangingPlayerPonyRenderer extends PlayerPonyRenderer {
|
||||
|
@ -31,8 +33,14 @@ public class FormChangingPlayerPonyRenderer extends PlayerPonyRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected final void preRender(AbstractClientPlayerEntity player, ModelAttributes.Mode mode) {
|
||||
super.preRender(player, mode);
|
||||
public void render(AbstractClientPlayerEntity player, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int light) {
|
||||
super.render(player, entityYaw, tickDelta, stack, renderContext, light);
|
||||
updateForm(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderArm(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, Arm side) {
|
||||
super.renderArm(stack, renderContext, lightUv, player, side);
|
||||
updateForm(player);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.minelittlepony.client.model.*;
|
|||
import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
import com.minelittlepony.client.render.entity.feature.*;
|
||||
import com.minelittlepony.common.util.render.RenderLayerUtil;
|
||||
import com.minelittlepony.client.util.render.RenderLayerUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
@ -56,7 +56,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
|||
addLayer(new HeldItemFeature(this, context.getHeldItemRenderer()));
|
||||
addLayer(new DJPon3Feature<>(this));
|
||||
addLayer(new CapeFeature<>(this));
|
||||
addLayer(new SkullFeature<>(this, context.getModelLoader(), context.getItemRenderer()));
|
||||
addLayer(new SkullFeature<>(this, context.getModelLoader()));
|
||||
addLayer(new ElytraFeature<>(this));
|
||||
addLayer(new PassengerFeature<>(this, context));
|
||||
addLayer(new GearFeature<>(this));
|
||||
|
@ -70,19 +70,14 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
|||
@Override
|
||||
protected void scale(AbstractClientPlayerEntity entity, MatrixStack stack, float tickDelta) {
|
||||
if (manager.getModels().body().getAttributes().isSitting && entity.hasVehicle()) {
|
||||
stack.translate(0, -0.25F * manager.getScaleFactor(), 0);
|
||||
stack.translate(0, entity.getRidingOffset(entity.getVehicle()), 0);
|
||||
}
|
||||
super.scale(entity, stack, tickDelta);
|
||||
}
|
||||
|
||||
protected void preRender(AbstractClientPlayerEntity player, ModelAttributes.Mode mode) {
|
||||
manager.preRender(player, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(AbstractClientPlayerEntity entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
|
||||
// EntityModelFeatures: We have to force it to use our models otherwise EMF overrides it and breaks pony rendering
|
||||
preRender(entity, ModelAttributes.Mode.THIRD_PERSON);
|
||||
manager.preRender(entity, ModelAttributes.Mode.THIRD_PERSON);
|
||||
shadowRadius = manager.getShadowSize();
|
||||
super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv);
|
||||
DebugBoundingBoxRenderer.render(getEntityPony(entity), this, entity, stack, renderContext, tickDelta);
|
||||
|
@ -107,8 +102,8 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void setupTransforms(AbstractClientPlayerEntity entity, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||
manager.setupTransforms(entity, matrices, animationProgress, bodyYaw, tickDelta, scale);
|
||||
protected void setupTransforms(AbstractClientPlayerEntity entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
||||
manager.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,7 +116,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabelIfPresent(AbstractClientPlayerEntity entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int light, float tickDelta) {
|
||||
protected void renderLabelIfPresent(AbstractClientPlayerEntity entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) {
|
||||
stack.push();
|
||||
|
||||
if (entity.isSleeping()) {
|
||||
|
@ -132,7 +127,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
|||
}
|
||||
}
|
||||
stack.translate(0, manager.getNamePlateYOffset(entity), 0);
|
||||
super.renderLabelIfPresent(entity, name, stack, renderContext, light, tickDelta);
|
||||
super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance);
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
|
@ -147,7 +142,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
|||
}
|
||||
|
||||
protected void renderArm(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, Arm side) {
|
||||
preRender(player, ModelAttributes.Mode.FIRST_PERSON);
|
||||
manager.preRender(player, ModelAttributes.Mode.FIRST_PERSON);
|
||||
|
||||
stack.push();
|
||||
float reflect = side == Arm.LEFT ? 1 : -1;
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PonyPigRenderer extends PigEntityRenderer {
|
|||
model.animateModel(entity, limbAngle, limbDistance, tickDelta);
|
||||
model.setAngles(entity, limbAngle, limbDistance, animationProgress, headYaw, headPitch);
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCull(Wearable.CROWN.getDefaultTexture()));
|
||||
model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 0xFFFFFFFF);
|
||||
model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,15 +5,14 @@ import net.minecraft.entity.mob.AbstractPiglinEntity;
|
|||
import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.PiglinPonyModel;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
|
||||
public class PonyPiglinRenderer extends PonyRenderer<HostileEntity, PiglinPonyModel> {
|
||||
public static final Identifier PIGLIN = MineLittlePony.id("textures/entity/piglin/piglin_pony.png");
|
||||
public static final Identifier PIGLIN_BRUTE = MineLittlePony.id("textures/entity/piglin/piglin_brute_pony.png");
|
||||
public static final Identifier ZOMBIFIED_PIGLIN = MineLittlePony.id("textures/entity/piglin/zombified_piglin_pony.png");
|
||||
private static final Identifier PIGLIN = new Identifier("minelittlepony", "textures/entity/piglin/piglin_pony.png");
|
||||
private static final Identifier PIGLIN_BRUTE = new Identifier("minelittlepony", "textures/entity/piglin/piglin_brute_pony.png");
|
||||
private static final Identifier ZOMBIFIED_PIGLIN = new Identifier("minelittlepony", "textures/entity/piglin/zombified_piglin_pony.png");
|
||||
|
||||
public PonyPiglinRenderer(EntityRendererFactory.Context context, Identifier texture, float scale) {
|
||||
super(context, ModelType.PIGLIN, TextureSupplier.of(texture), scale);
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.client.render.entity.feature.*;
|
|||
import net.minecraft.client.render.entity.model.ArmorStandArmorEntityModel;
|
||||
import net.minecraft.client.render.entity.model.EntityModelLayers;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
|
@ -14,6 +15,7 @@ import com.minelittlepony.api.model.Models;
|
|||
import com.minelittlepony.api.pony.PonyData;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.entity.PonyArmourStandModel;
|
||||
import com.minelittlepony.client.model.entity.race.EarthPonyModel;
|
||||
import com.minelittlepony.client.render.entity.feature.ArmourFeature;
|
||||
|
@ -50,10 +52,10 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void setupTransforms(ArmorStandEntity entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||
super.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
|
||||
protected void setupTransforms(ArmorStandEntity entity, MatrixStack stack, float f, float g, float h) {
|
||||
super.setupTransforms(entity, stack, f, g, h);
|
||||
if (isPonita(entity)) {
|
||||
stack.translate(0, 0, scale * -4/16F);
|
||||
stack.translate(0, 0, -4/16F);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +82,13 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
|||
pony.body().animateModel(entity, limbDistance, limbAngle, tickDelta);
|
||||
pony.body().setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
||||
PonyStandRenderer.this.pony.applyAnglesTo(pony.body());
|
||||
ArmourFeature.renderArmor(pony, stack, renderContext, lightUv, entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
||||
|
||||
for (EquipmentSlot i : EquipmentSlot.values()) {
|
||||
if (i.getType() == EquipmentSlot.Type.ARMOR) {
|
||||
ArmourFeature.renderArmor(pony, stack, renderContext, lightUv, entity, limbDistance, limbAngle, age, headYaw, headPitch, i, ArmourLayer.INNER);
|
||||
ArmourFeature.renderArmor(pony, stack, renderContext, lightUv, entity, limbDistance, limbAngle, age, headYaw, headPitch, i, ArmourLayer.OUTER);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.render(stack, renderContext, lightUv, entity, limbDistance, limbAngle, tickDelta, age, headYaw, headPitch);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.minelittlepony.client.render.entity;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.mixin.IResizeable;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.GuardianPonyModel;
|
||||
|
@ -18,10 +17,10 @@ import net.minecraft.entity.mob.GuardianEntity;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class SeaponyRenderer extends GuardianEntityRenderer {
|
||||
public static final Identifier SEAPONY = MineLittlePony.id("textures/entity/guardian/blueball.png");
|
||||
private static final Identifier SEAPONY_TEXTURES = MineLittlePony.id("textures/entity/guardian");
|
||||
public static final Identifier ELDER_SEAPONY = MineLittlePony.id("textures/entity/elder_guardian/blueball.png");
|
||||
private static final Identifier ELDER_SEAPONY_TEXTURES = MineLittlePony.id("textures/entity/elder_guardian");
|
||||
public static final Identifier SEAPONY = new Identifier("minelittlepony", "textures/entity/guardian/blueball.png");
|
||||
private static final Identifier SEAPONY_TEXTURES = new Identifier("minelittlepony", "textures/entity/guardian");
|
||||
public static final Identifier ELDER_SEAPONY = new Identifier("minelittlepony", "textures/entity/elder_guardian/blueball.png");
|
||||
private static final Identifier ELDER_SEAPONY_TEXTURES = new Identifier("minelittlepony", "textures/entity/elder_guardian");
|
||||
|
||||
private final AbstractPonyRenderer<GuardianEntity, GuardianPonyModel> ponyRenderer;
|
||||
|
||||
|
@ -65,7 +64,7 @@ public class SeaponyRenderer extends GuardianEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void setupTransforms(GuardianEntity entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||
ponyRenderer.manager.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
|
||||
protected void setupTransforms(GuardianEntity entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
||||
ponyRenderer.manager.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.client.render.entity;
|
||||
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.SkeleponyModel;
|
||||
import com.minelittlepony.client.render.entity.feature.StrayClothingFeature;
|
||||
|
@ -11,9 +10,10 @@ import net.minecraft.entity.mob.*;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class SkeleponyRenderer<Skeleton extends AbstractSkeletonEntity> extends PonyRenderer<Skeleton, SkeleponyModel<Skeleton>> {
|
||||
public static final Identifier SKELETON = MineLittlePony.id("textures/entity/skeleton/skeleton_pony.png");
|
||||
public static final Identifier WITHER = MineLittlePony.id("textures/entity/skeleton/skeleton_wither_pony.png");
|
||||
public static final Identifier STRAY = MineLittlePony.id("textures/entity/skeleton/stray_pony.png");
|
||||
|
||||
public static final Identifier SKELETON = new Identifier("minelittlepony", "textures/entity/skeleton/skeleton_pony.png");
|
||||
public static final Identifier WITHER = new Identifier("minelittlepony", "textures/entity/skeleton/skeleton_wither_pony.png");
|
||||
public static final Identifier STRAY = new Identifier("minelittlepony", "textures/entity/skeleton/stray_pony.png");
|
||||
|
||||
public SkeleponyRenderer(EntityRendererFactory.Context context, Identifier texture, float scale) {
|
||||
super(context, ModelType.SKELETON, TextureSupplier.of(texture), scale);
|
||||
|
|
|
@ -13,10 +13,10 @@ import com.minelittlepony.client.MineLittlePony;
|
|||
import com.minelittlepony.client.model.ModelType;
|
||||
|
||||
public class StriderRenderer extends MobEntityRenderer<StriderEntity, EntityModel<StriderEntity>> {
|
||||
public static final Identifier DRAGON_PONIES = MineLittlePony.id("textures/entity/strider/pony");
|
||||
public static final Identifier COLD_DRAGON_PONIES = MineLittlePony.id("textures/entity/strider/cold_pony");
|
||||
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 = MineLittlePony.id("textures/entity/strider/strider_saddle_pony.png");
|
||||
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);
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.minelittlepony.client.model.ModelType;
|
|||
import com.minelittlepony.client.model.entity.ParaspriteModel;
|
||||
|
||||
public class VexRenderer extends MobEntityRenderer<VexEntity, ParaspriteModel<VexEntity>> {
|
||||
public static final Identifier PARASPRITE_PONIES = MineLittlePony.id("textures/entity/illager/vex_pony");
|
||||
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);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.client.render.entity;
|
||||
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.WitchPonyModel;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
|
@ -10,7 +9,8 @@ import net.minecraft.entity.mob.WitchEntity;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class WitchRenderer extends PonyRenderer<WitchEntity, WitchPonyModel> {
|
||||
private static final Identifier WITCH_TEXTURES = MineLittlePony.id("textures/entity/witch_pony.png");
|
||||
|
||||
private static final Identifier WITCH_TEXTURES = new Identifier("minelittlepony", "textures/entity/witch_pony.png");
|
||||
|
||||
public WitchRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.WITCH, TextureSupplier.of(WITCH_TEXTURES), BASE_MODEL_SCALE);
|
||||
|
|
|
@ -4,17 +4,17 @@ import net.minecraft.client.render.entity.EntityRendererFactory;
|
|||
import net.minecraft.entity.mob.*;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.ZomponyModel;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
|
||||
public class ZomponyRenderer<Zombie extends HostileEntity> extends PonyRenderer<Zombie, ZomponyModel<Zombie>> {
|
||||
public static final Identifier ZOMBIE = MineLittlePony.id("textures/entity/zombie/zombie_pony.png");
|
||||
public static final Identifier HUSK = MineLittlePony.id("textures/entity/zombie/husk_pony.png");
|
||||
public static final Identifier DROWNED = MineLittlePony.id("textures/entity/zombie/drowned_pony.png");
|
||||
|
||||
public static final Identifier DEMON_CHILD = MineLittlePony.id("textures/entity/zombie/demon_child.png");
|
||||
public static final Identifier ZOMBIE = new Identifier("minelittlepony", "textures/entity/zombie/zombie_pony.png");
|
||||
public static final Identifier HUSK = new Identifier("minelittlepony", "textures/entity/zombie/husk_pony.png");
|
||||
public static final Identifier DROWNED = new Identifier("minelittlepony", "textures/entity/zombie/drowned_pony.png");
|
||||
|
||||
public static final Identifier DEMON_CHILD = new Identifier("minelittlepony", "textures/entity/zombie/demon_child.png");
|
||||
|
||||
public ZomponyRenderer(EntityRendererFactory.Context context, TextureSupplier<Zombie> texture, float scale) {
|
||||
super(context, ModelType.ZOMBIE, texture, scale);
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
|||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
|
@ -32,7 +31,7 @@ public abstract class AbstractClothingFeature<T extends LivingEntity, M extends
|
|||
overlayModel.setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
||||
|
||||
VertexConsumer vertexConsumer = renderContext.getBuffer(overlayModel.getLayer(getOverlayTexture()));
|
||||
overlayModel.render(stack, vertexConsumer, lightUv, OverlayTexture.DEFAULT_UV, Colors.WHITE);
|
||||
overlayModel.render(stack, vertexConsumer, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
||||
}
|
||||
|
||||
protected abstract M getOverlayModel();
|
||||
|
|
|
@ -3,119 +3,109 @@ package com.minelittlepony.client.render.entity.feature;
|
|||
import com.minelittlepony.api.model.Models;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.client.model.armour.*;
|
||||
import com.minelittlepony.client.render.ArmorRenderLayers;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
import com.minelittlepony.common.util.Color;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.entity.model.*;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.render.model.BakedModelManager;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.trim.ArmorTrim;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> extends AbstractPonyFeature<T, M> {
|
||||
|
||||
public ArmourFeature(PonyRenderContext<T, M> context, BakedModelManager bakery) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider provider, int light, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
renderArmor(getModelWrapper(), matrices, provider, light, entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
Models<T, M> pony = getModelWrapper();
|
||||
|
||||
for (EquipmentSlot i : EquipmentSlot.values()) {
|
||||
if (i.getType() == EquipmentSlot.Type.ARMOR) {
|
||||
renderArmor(pony, stack, renderContext, lightUv, entity, limbDistance, limbAngle, age, headYaw, headPitch, i, ArmourLayer.INNER);
|
||||
renderArmor(pony, stack, renderContext, lightUv, entity, limbDistance, limbAngle, age, headYaw, headPitch, i, ArmourLayer.OUTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends LivingEntity, V extends PonyArmourModel<T>> void renderArmor(
|
||||
Models<T, ? extends PonyModel<T>> pony, MatrixStack matrices,
|
||||
VertexConsumerProvider provider, int light, T entity,
|
||||
float limbDistance, float limbAngle,
|
||||
float age, float headYaw, float headPitch) {
|
||||
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||
|
||||
for (EquipmentSlot i : EquipmentSlot.values()) {
|
||||
if (i.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
|
||||
renderArmor(pony, matrices, provider, light, entity, limbDistance, limbAngle, age, headYaw, headPitch, i, ArmourLayer.INNER, plugin);
|
||||
renderArmor(pony, matrices, provider, light, entity, limbDistance, limbAngle, age, headYaw, headPitch, i, ArmourLayer.OUTER, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static <T extends LivingEntity, V extends PonyArmourModel<T>> void renderArmor(
|
||||
Models<T, ? extends PonyModel<T>> pony, MatrixStack matrices,
|
||||
VertexConsumerProvider provider, int light, T entity,
|
||||
VertexConsumerProvider renderContext, int light, T entity,
|
||||
float limbDistance, float limbAngle,
|
||||
float age, float headYaw, float headPitch,
|
||||
EquipmentSlot armorSlot, ArmourLayer layer, ArmourRendererPlugin plugin) {
|
||||
EquipmentSlot armorSlot, ArmourLayer layer) {
|
||||
|
||||
for (ItemStack stack : plugin.getArmorStacks(entity, armorSlot, layer, ArmourRendererPlugin.ArmourType.ARMOUR)) {
|
||||
if (stack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack stack = entity.getEquippedStack(armorSlot);
|
||||
|
||||
float glintAlpha = plugin.getGlintAlpha(armorSlot, stack);
|
||||
boolean glint = glintAlpha > 0;
|
||||
int color = plugin.getDyeColor(armorSlot, stack);
|
||||
|
||||
Set<PonyArmourModel<?>> models = glint ? new HashSet<>() : null;
|
||||
|
||||
ArmourTextureLookup textureLookup = plugin.getTextureLookup();
|
||||
|
||||
float alpha = plugin.getArmourAlpha(armorSlot, layer);
|
||||
|
||||
if (alpha > 0) {
|
||||
for (ArmorMaterial.Layer armorLayer : textureLookup.getArmorLayers(stack, color)) {
|
||||
ArmourTexture layerTexture = textureLookup.getTexture(stack, layer, armorLayer);
|
||||
|
||||
if (layerTexture == ArmourTexture.UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var m = pony.getArmourModel(stack, layer, layerTexture.variant()).orElse(null);
|
||||
if (m != null && m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body())) {
|
||||
VertexConsumer armorConsumer = plugin.getArmourConsumer(armorSlot, provider, layerTexture.texture(), layer);
|
||||
if (armorConsumer != null) {
|
||||
int armorTint = Colors.WHITE;
|
||||
if (armorLayer.isDyeable() && color != Colors.WHITE) {
|
||||
armorTint = color;
|
||||
}
|
||||
m.render(matrices, armorConsumer, light, OverlayTexture.DEFAULT_UV, (armorTint & 0xFFFFFF) | ((int)(alpha * 255) << 24));
|
||||
}
|
||||
if (glint) {
|
||||
models.add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArmorTrim trim = stack.get(DataComponentTypes.TRIM);
|
||||
|
||||
if (trim != null && stack.getItem() instanceof ArmorItem armor) {
|
||||
float trimAlpha = plugin.getTrimAlpha(armorSlot, armor.getMaterial(), trim, layer);
|
||||
if (trimAlpha > 0) {
|
||||
var m = pony.getArmourModel(stack, layer, ArmourVariant.TRIM).orElse(null);
|
||||
if (m != null && m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body())) {
|
||||
VertexConsumer trimConsumer = plugin.getTrimConsumer(armorSlot, provider, armor.getMaterial(), trim, layer);
|
||||
if (trimConsumer != null) {
|
||||
m.render(matrices, trimConsumer, light, OverlayTexture.DEFAULT_UV, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (glint) {
|
||||
VertexConsumer glintConsumer = plugin.getGlintConsumer(armorSlot, provider, layer);
|
||||
if (glintConsumer != null) {
|
||||
for (var m : models) {
|
||||
m.render(matrices, glintConsumer, light, OverlayTexture.DEFAULT_UV, Color.argbToHex(glintAlpha, 1, 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.onArmourRendered(entity, matrices, provider, armorSlot, layer, ArmourRendererPlugin.ArmourType.ARMOUR);
|
||||
Identifier texture = ArmourTextureResolver.INSTANCE.getTexture(entity, stack, armorSlot, layer, null);
|
||||
ArmourVariant variant = ArmourTextureResolver.INSTANCE.getVariant(layer, texture);
|
||||
|
||||
boolean glint = stack.hasGlint();
|
||||
Item item = stack.getItem();
|
||||
|
||||
pony.getArmourModel(stack, layer, variant)
|
||||
.filter(m -> m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body()))
|
||||
.ifPresent(model -> {
|
||||
float red = 1;
|
||||
float green = 1;
|
||||
float blue = 1;
|
||||
|
||||
if (item instanceof DyeableArmorItem dyeable) {
|
||||
int color = dyeable.getColor(stack);
|
||||
red = Color.r(color);
|
||||
green = Color.g(color);
|
||||
blue = Color.b(color);
|
||||
}
|
||||
|
||||
model.render(matrices, getArmorConsumer(renderContext, texture, glint), light, OverlayTexture.DEFAULT_UV, red, green, blue, 1);
|
||||
|
||||
if (item instanceof DyeableArmorItem) {
|
||||
Identifier tex = ArmourTextureResolver.INSTANCE.getTexture(entity, stack, armorSlot, layer, "overlay");
|
||||
pony.getArmourModel(stack, layer, ArmourTextureResolver.INSTANCE.getVariant(layer, tex))
|
||||
.filter(m -> m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body()))
|
||||
.ifPresent(m -> {
|
||||
m.render(matrices, getArmorConsumer(renderContext, tex, false), light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
||||
});
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof ArmorItem armor) {
|
||||
ArmorTrim.getTrim(entity.getWorld().getRegistryManager(), stack, true).ifPresent(trim -> {
|
||||
pony.getArmourModel(stack, layer, ArmourVariant.TRIM)
|
||||
.filter(m -> m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body()))
|
||||
.ifPresent(m -> {
|
||||
m.render(matrices, getTrimConsumer(renderContext, armor.getMaterial(), trim, layer, glint), light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static VertexConsumer getArmorConsumer(VertexConsumerProvider provider, Identifier texture, boolean glint) {
|
||||
return ItemRenderer.getArmorGlintConsumer(provider, ArmorRenderLayers.getArmorTranslucentNoCull(texture, false), false, glint);
|
||||
}
|
||||
|
||||
private static VertexConsumer getTrimConsumer(VertexConsumerProvider provider, ArmorMaterial material, ArmorTrim trim, ArmourLayer layer, boolean glint) {
|
||||
SpriteAtlasTexture armorTrimsAtlas = MinecraftClient.getInstance().getBakedModelManager().getAtlas(TexturedRenderLayers.ARMOR_TRIMS_ATLAS_TEXTURE);
|
||||
Sprite sprite = armorTrimsAtlas.getSprite(
|
||||
layer == ArmourLayer.INNER ? trim.getLeggingsModelId(material) : trim.getGenericModelId(material)
|
||||
);
|
||||
RenderLayer renderLayer = ArmorRenderLayers.getArmorTranslucentNoCull(TexturedRenderLayers.ARMOR_TRIMS_ATLAS_TEXTURE, trim.getPattern().value().decal());
|
||||
|
||||
return sprite.getTextureSpecificVertexConsumer(ItemRenderer.getDirectItemGlintConsumer(provider, renderLayer, true, glint));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,18 +2,18 @@ package com.minelittlepony.client.render.entity.feature;
|
|||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.PlayerModelPart;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.player.PlayerModelPart;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
|
||||
public class CapeFeature<M extends ClientPonyModel<AbstractClientPlayerEntity>> extends AbstractPonyFeature<AbstractClientPlayerEntity, M> {
|
||||
|
||||
|
@ -22,28 +22,21 @@ public class CapeFeature<M extends ClientPonyModel<AbstractClientPlayerEntity>>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider provider, int light, AbstractClientPlayerEntity player, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
M model = getModelWrapper().body();
|
||||
|
||||
if (!player.isInvisible()
|
||||
&& player.isPartVisible(PlayerModelPart.CAPE)
|
||||
&& player.getSkinTextures().capeTexture() != null) {
|
||||
&& player.isPartVisible(PlayerModelPart.CAPE) && player.getSkinTextures().capeTexture() != null
|
||||
&& player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) {
|
||||
|
||||
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||
stack.push();
|
||||
|
||||
VertexConsumer vertices = plugin.getCapeConsumer(player, provider, player.getSkinTextures().capeTexture());
|
||||
if (vertices == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
matrices.push();
|
||||
|
||||
matrices.translate(0, 0.24F, 0);
|
||||
stack.translate(0, 0.24F, 0);
|
||||
if (model.getAttributes().isLyingDown) {
|
||||
matrices.translate(0, -0.05F, 0);
|
||||
stack.translate(0, -0.05F, 0);
|
||||
}
|
||||
model.transform(BodyPart.BODY, matrices);
|
||||
model.getBodyPart(BodyPart.BODY).rotate(matrices);
|
||||
model.transform(BodyPart.BODY, stack);
|
||||
model.getBodyPart(BodyPart.BODY).rotate(stack);
|
||||
|
||||
double capeX = MathHelper.lerp(tickDelta, player.capeX, player.prevCapeX) - MathHelper.lerp(tickDelta, player.prevX, player.getX());
|
||||
double capeY = MathHelper.lerp(tickDelta, player.capeY, player.prevCapeY) - MathHelper.lerp(tickDelta, player.prevY, player.getY());
|
||||
|
@ -68,16 +61,15 @@ public class CapeFeature<M extends ClientPonyModel<AbstractClientPlayerEntity>>
|
|||
float camera = MathHelper.lerp(tickDelta, player.prevStrideDistance, player.strideDistance);
|
||||
capeMotionY += MathHelper.sin(MathHelper.lerp(tickDelta, player.prevHorizontalSpeed, player.horizontalSpeed) * 6) * 32 * camera;
|
||||
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(2 + capeMotionX / 12 + capeMotionY));
|
||||
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees( diagMotion / 2));
|
||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-diagMotion / 2));
|
||||
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180));
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(90));
|
||||
stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(2 + capeMotionX / 12 + capeMotionY));
|
||||
stack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees( diagMotion / 2));
|
||||
stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-diagMotion / 2));
|
||||
stack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180));
|
||||
stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(90));
|
||||
|
||||
model.renderCape(matrices, vertices, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.pop();
|
||||
|
||||
plugin.onArmourRendered(player, matrices, provider, EquipmentSlot.BODY, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.CAPE);
|
||||
VertexConsumer vertices = renderContext.getBuffer(RenderLayer.getEntitySolid(player.getSkinTextures().capeTexture()));
|
||||
model.renderCape(stack, vertices, lightUv, OverlayTexture.DEFAULT_UV);
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.minecraft.client.render.VertexConsumer;
|
|||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.Colors;
|
||||
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
|
@ -23,7 +22,7 @@ public class DJPon3Feature<T extends AbstractClientPlayerEntity, M extends Entit
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int light, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
if ("deadmau5".equals(entity.getName().getString())) {
|
||||
stack.push();
|
||||
|
||||
|
@ -39,7 +38,7 @@ public class DJPon3Feature<T extends AbstractClientPlayerEntity, M extends Entit
|
|||
|
||||
VertexConsumer vertices = renderContext.getBuffer(deadMau5.getLayer(entity.getSkinTextures().texture()));
|
||||
|
||||
deadMau5.render(stack, vertices, OverlayTexture.DEFAULT_UV, light, Colors.WHITE);
|
||||
deadMau5.render(stack, vertices, OverlayTexture.DEFAULT_UV, lightUv, limbDistance, limbAngle, tickDelta, 1);
|
||||
|
||||
stack.pop();
|
||||
}
|
||||
|
|
|
@ -5,60 +5,55 @@ import com.minelittlepony.api.model.PonyModel;
|
|||
import com.minelittlepony.api.pony.PonyPosture;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.PonyElytra;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.PlayerModelPart;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.util.SkinTextures;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerModelPart;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ElytraFeature<T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> extends AbstractPonyFeature<T, M> {
|
||||
private static final Identifier TEXTURE = Identifier.ofVanilla("textures/entity/elytra.png");
|
||||
|
||||
private final PonyElytra<T> model = ModelType.ELYTRA.createModel();
|
||||
private static final Identifier TEXTURE_ELYTRA = new Identifier("textures/entity/elytra.png");
|
||||
|
||||
public ElytraFeature(PonyRenderContext<T, M> context) {
|
||||
super(context);
|
||||
@SuppressWarnings("unchecked")
|
||||
private final PonyElytra<T> modelElytra = (PonyElytra<T>)ModelType.ELYTRA.createModel();
|
||||
|
||||
public ElytraFeature(PonyRenderContext<T, M> rp) {
|
||||
super(rp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider provider, int light, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
ItemStack itemstack = entity.getEquippedStack(EquipmentSlot.CHEST);
|
||||
|
||||
for (ItemStack stack : plugin.getArmorStacks(entity, EquipmentSlot.CHEST, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.ELYTRA)) {
|
||||
float alpha = plugin.getElytraAlpha(stack, model, entity);
|
||||
if (alpha <= 0) {
|
||||
return;
|
||||
if (itemstack.getItem() == Items.ELYTRA) {
|
||||
stack.push();
|
||||
preRenderCallback(stack);
|
||||
|
||||
EntityModel<T> elytra = getElytraModel();
|
||||
|
||||
getContextModel().copyStateTo(elytra);
|
||||
if (elytra instanceof PonyElytra) {
|
||||
((PonyElytra<T>)elytra).isSneaking = PonyPosture.isCrouching(getContext().getEntityPony(entity), entity);
|
||||
}
|
||||
|
||||
VertexConsumer vertexConsumer = plugin.getElytraConsumer(stack, model, entity, provider, getElytraTexture(entity));
|
||||
if (vertexConsumer == null) {
|
||||
return;
|
||||
}
|
||||
elytra.setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
||||
VertexConsumer vertexConsumer = ItemRenderer.getDirectItemGlintConsumer(renderContext, modelElytra.getLayer(getElytraTexture(entity)), false, itemstack.hasGlint());
|
||||
modelElytra.render(stack, vertexConsumer, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
||||
|
||||
matrices.push();
|
||||
preRenderCallback(matrices);
|
||||
|
||||
getContextModel().copyStateTo(model);
|
||||
model.isSneaking = PonyPosture.isCrouching(getContext().getEntityPony(entity), entity);
|
||||
model.setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
||||
model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, (Colors.WHITE & 0xFFFFFF) | (int)(alpha * 255) << 24);
|
||||
|
||||
matrices.pop();
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
plugin.onArmourRendered(entity, matrices, provider, EquipmentSlot.BODY, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.ELYTRA);
|
||||
}
|
||||
|
||||
protected void preRenderCallback(MatrixStack stack) {
|
||||
|
@ -67,6 +62,10 @@ public class ElytraFeature<T extends LivingEntity, M extends EntityModel<T> & Po
|
|||
body.transform(BodyPart.BODY, stack);
|
||||
}
|
||||
|
||||
protected EntityModel<T> getElytraModel() {
|
||||
return modelElytra;
|
||||
}
|
||||
|
||||
protected Identifier getElytraTexture(T entity) {
|
||||
if (entity instanceof AbstractClientPlayerEntity player) {
|
||||
SkinTextures textures = player.getSkinTextures();
|
||||
|
@ -80,6 +79,6 @@ public class ElytraFeature<T extends LivingEntity, M extends EntityModel<T> & Po
|
|||
}
|
||||
}
|
||||
|
||||
return TEXTURE;
|
||||
return TEXTURE_ELYTRA;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,11 @@ package com.minelittlepony.client.render.entity.feature;
|
|||
|
||||
import it.unimi.dsi.fastutil.objects.Object2FloatLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
|
||||
import net.minecraft.block.SkullBlock;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.world.EmptyBlockView;
|
||||
|
||||
import com.google.common.cache.*;
|
||||
import com.google.common.collect.Streams;
|
||||
|
@ -21,8 +15,6 @@ import com.minelittlepony.api.model.PonyModel;
|
|||
import com.minelittlepony.api.model.gear.Gear;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -60,14 +52,6 @@ public class GearFeature<T extends LivingEntity, M extends EntityModel<T> & Pony
|
|||
return;
|
||||
}
|
||||
|
||||
boolean hasSkull = false;
|
||||
for (ItemStack skull : ArmourRendererPlugin.INSTANCE.get().getArmorStacks(entity, EquipmentSlot.HEAD, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.SKULL)) {
|
||||
if (skull.getItem() instanceof BlockItem b && (b.getBlock() instanceof SkullBlock || b.getBlock().getDefaultState().isSolidBlock(EmptyBlockView.INSTANCE, BlockPos.ORIGIN))) {
|
||||
hasSkull = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final M model = getModelWrapper().body();
|
||||
final Object2FloatMap<BodyPart> renderStackingOffsets = new Object2FloatLinkedOpenHashMap<>();
|
||||
|
||||
|
@ -76,12 +60,9 @@ public class GearFeature<T extends LivingEntity, M extends EntityModel<T> & Pony
|
|||
stack.push();
|
||||
Gear gear = entry.gear();
|
||||
gear.transform(model, stack);
|
||||
BodyPart part = gear.getGearLocation();
|
||||
if (hasSkull && part== BodyPart.HEAD && renderStackingOffsets.getFloat(part) == 0) {
|
||||
renderStackingOffsets.put(part, 0.25F);
|
||||
}
|
||||
|
||||
if (gear.isStackable()) {
|
||||
BodyPart part = gear.getGearLocation();
|
||||
float v = renderStackingOffsets.getFloat(part);
|
||||
if (v != 0) {
|
||||
stack.translate(0, -v, 0);
|
||||
|
@ -97,7 +78,7 @@ public class GearFeature<T extends LivingEntity, M extends EntityModel<T> & Pony
|
|||
|
||||
private void renderGear(M model, T entity, Gear gear, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, float limbDistance, float limbAngle, float tickDelta) {
|
||||
gear.pose(model, entity, model.getAttributes().isGoingFast, entity.getUuid(), limbDistance, limbAngle, model.getWobbleAmount(), tickDelta);
|
||||
gear.render(stack, renderContext.getBuffer(gear.getLayer(entity, getContext())), lightUv, OverlayTexture.DEFAULT_UV, Colors.WHITE, entity.getUuid());
|
||||
gear.render(stack, renderContext.getBuffer(gear.getLayer(entity, getContext())), lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1, entity.getUuid());
|
||||
}
|
||||
|
||||
static record Entry(Gear gear, Wearable wearable) { }
|
||||
|
|
|
@ -2,79 +2,106 @@ package com.minelittlepony.client.render.entity.feature;
|
|||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.AbstractSkullBlock;
|
||||
import net.minecraft.block.SkullBlock;
|
||||
import net.minecraft.block.SkullBlock.SkullType;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.entity.feature.HeadFeatureRenderer;
|
||||
import net.minecraft.client.render.block.entity.SkullBlockEntityModel;
|
||||
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.render.entity.model.EntityModelLoader;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.mob.ZombieVillagerEntity;
|
||||
import net.minecraft.entity.passive.VillagerEntity;
|
||||
import net.minecraft.item.ArmorItem;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.village.VillagerDataContainer;
|
||||
|
||||
public class SkullFeature<T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> extends AbstractPonyFeature<T, M> {
|
||||
private final ItemRenderer itemRenderer;
|
||||
|
||||
public SkullFeature(PonyRenderContext<T, M> renderPony, EntityModelLoader entityModelLoader, ItemRenderer itemRenderer) {
|
||||
private final Map<SkullBlock.SkullType, SkullBlockEntityModel> headModels;
|
||||
|
||||
public SkullFeature(PonyRenderContext<T, M> renderPony, EntityModelLoader entityModelLoader) {
|
||||
super(renderPony);
|
||||
this.itemRenderer = itemRenderer;
|
||||
headModels = SkullBlockEntityRenderer.getModels(entityModelLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider provider, int light, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||
|
||||
for (ItemStack stack : plugin.getArmorStacks(entity, EquipmentSlot.HEAD, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.SKULL)) {
|
||||
if (stack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||
ItemStack itemstack = entity.getEquippedStack(EquipmentSlot.HEAD);
|
||||
if (!itemstack.isEmpty()) {
|
||||
M model = getModelWrapper().body();
|
||||
Item item = stack.getItem();
|
||||
Item item = itemstack.getItem();
|
||||
|
||||
matrices.push();
|
||||
stack.push();
|
||||
|
||||
if (entity.isBaby() && !(entity instanceof VillagerEntity)) {
|
||||
matrices.translate(0, 0.03125F, 0);
|
||||
matrices.scale(0.7F, 0.7F, 0.7F);
|
||||
matrices.translate(0, 1, 0);
|
||||
model.transform(BodyPart.HEAD, stack);
|
||||
model.getHead().rotate(stack);
|
||||
|
||||
if (model instanceof AbstractPonyModel) {
|
||||
stack.translate(0, 0.225F, 0);
|
||||
} else {
|
||||
stack.translate(0, 0, 0.15F);
|
||||
}
|
||||
|
||||
model.transform(BodyPart.HEAD, matrices);
|
||||
model.getHead().rotate(matrices);
|
||||
if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof AbstractSkullBlock) {
|
||||
boolean isVillager = entity instanceof VillagerDataContainer;
|
||||
|
||||
boolean isVillager = entity instanceof VillagerEntity || entity instanceof ZombieVillagerEntity;
|
||||
|
||||
float f = 1.1F;
|
||||
matrices.scale(f, f, f);
|
||||
|
||||
if (item instanceof BlockItem b && b.getBlock() instanceof AbstractSkullBlock) {
|
||||
float n = 1.1875F;
|
||||
matrices.scale(n, -n, -n);
|
||||
matrices.translate(0, -0.1F, 0.1F);
|
||||
matrices.translate(-0.5, 0, -0.5);
|
||||
PonySkullRenderer.INSTANCE.renderSkull(matrices, provider, stack, entity, tickDelta, light, true);
|
||||
} else if (!(item instanceof ArmorItem a) || a.getSlotType() != EquipmentSlot.HEAD) {
|
||||
matrices.translate(0, 0.1F, -0.1F);
|
||||
HeadFeatureRenderer.translate(matrices, isVillager);
|
||||
itemRenderer.renderItem(entity, stack, ModelTransformationMode.HEAD, false, matrices, provider, entity.getWorld(), light, OverlayTexture.DEFAULT_UV, entity.getId() + ModelTransformationMode.HEAD.ordinal());
|
||||
renderSkull(stack, renderContext, itemstack, isVillager, limbDistance, lightUv);
|
||||
} else if (!(item instanceof ArmorItem) || ((ArmorItem)item).getSlotType() != EquipmentSlot.HEAD) {
|
||||
renderBlock(stack, renderContext, entity, itemstack, lightUv);
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
plugin.onArmourRendered(entity, matrices, provider, EquipmentSlot.BODY, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.SKULL);
|
||||
}
|
||||
|
||||
private void renderBlock(MatrixStack stack, VertexConsumerProvider renderContext, T entity, ItemStack itemstack, int lightUv) {
|
||||
stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180));
|
||||
stack.scale(0.625F, -0.625F, -0.625F);
|
||||
stack.translate(0, 0.6F, -0.21F);
|
||||
|
||||
MinecraftClient.getInstance().getItemRenderer()
|
||||
.renderItem(entity, itemstack, ModelTransformationMode.HEAD, false, stack, renderContext, entity.getWorld(), lightUv, OverlayTexture.DEFAULT_UV, entity.getId() + ModelTransformationMode.HEAD.ordinal());
|
||||
}
|
||||
|
||||
private void renderSkull(MatrixStack stack, VertexConsumerProvider renderContext, ItemStack itemstack, boolean isVillager, float limbDistance, int lightUv) {
|
||||
stack.translate(0, 0, -0.14F);
|
||||
float f = 1.1875f;
|
||||
stack.scale(f, -f, -f);
|
||||
if (isVillager) {
|
||||
stack.translate(0, 0.0625F, 0);
|
||||
}
|
||||
|
||||
GameProfile profile = null;
|
||||
|
||||
if (itemstack.hasNbt()) {
|
||||
NbtCompound nbt = itemstack.getNbt();
|
||||
|
||||
if (nbt.contains("SkullOwner", 10)) {
|
||||
profile = NbtHelper.toGameProfile(nbt.getCompound("SkullOwner"));
|
||||
}
|
||||
}
|
||||
|
||||
stack.translate(-0.5, 0, -0.5);
|
||||
SkullType type = ((AbstractSkullBlock) ((BlockItem) itemstack.getItem()).getBlock()).getSkullType();
|
||||
SkullBlockEntityModel skullBlockEntityModel = (SkullBlockEntityModel)this.headModels.get(type);
|
||||
RenderLayer renderLayer = SkullBlockEntityRenderer.getRenderLayer(type, profile);
|
||||
|
||||
SkullBlockEntityRenderer.renderSkull(null, 180, f, stack, renderContext, lightUv, skullBlockEntityModel, renderLayer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@ import net.minecraft.client.render.entity.LivingEntityRenderer;
|
|||
import net.minecraft.entity.mob.AbstractSkeletonEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.SkeleponyModel;
|
||||
|
||||
public class StrayClothingFeature<Skeleton extends AbstractSkeletonEntity> extends AbstractClothingFeature<Skeleton, SkeleponyModel<Skeleton>> {
|
||||
public static final Identifier STRAY_SKELETON_OVERLAY = MineLittlePony.id("textures/entity/skeleton/stray_pony_overlay.png");
|
||||
|
||||
public static final Identifier STRAY_SKELETON_OVERLAY = new Identifier("minelittlepony", "textures/entity/skeleton/stray_pony_overlay.png");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private final SkeleponyModel<Skeleton> overlayModel = (SkeleponyModel<Skeleton>)ModelType.SKELETON_CLOTHES.createModel();
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.minelittlepony.api.pony.meta.Race;
|
|||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.client.model.*;
|
||||
import com.minelittlepony.client.render.entity.PonyRenderer;
|
||||
import com.minelittlepony.client.render.entity.feature.*;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.*;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
@ -33,6 +34,12 @@ abstract class AbstractNpcRenderer<T extends MobEntity & VillagerDataContainer>
|
|||
addFeature(clothing);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addFeatures(EntityRendererFactory.Context context) {
|
||||
addFeature(createHeldItemFeature(context));
|
||||
addFeature(new GearFeature<>(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(ClientPonyModel<T> model, T entity, Wearable wearable, Gear gear) {
|
||||
if (wearable == Wearable.SADDLE_BAGS_BOTH) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.client.render.entity.npc;
|
||||
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.IllagerPonyModel;
|
||||
import com.minelittlepony.client.render.entity.feature.IllagerHeldItemFeature;
|
||||
|
@ -20,9 +19,9 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class IllagerPonyRenderer<T extends IllagerEntity> extends PonyRenderer<T, IllagerPonyModel<T>> {
|
||||
public static final Identifier ILLUSIONIST = MineLittlePony.id("textures/entity/illager/illusionist_pony.png");
|
||||
public static final Identifier EVOKER = MineLittlePony.id("textures/entity/illager/evoker_pony.png");
|
||||
public static final Identifier VINDICATOR = MineLittlePony.id("textures/entity/illager/vindicator_pony.png");
|
||||
public static final Identifier ILLUSIONIST = new Identifier("minelittlepony", "textures/entity/illager/illusionist_pony.png");
|
||||
public static final Identifier EVOKER = new Identifier("minelittlepony", "textures/entity/illager/evoker_pony.png");
|
||||
public static final Identifier VINDICATOR = new Identifier("minelittlepony", "textures/entity/illager/vindicator_pony.png");
|
||||
|
||||
public IllagerPonyRenderer(EntityRendererFactory.Context context, Identifier texture) {
|
||||
super(context, ModelType.ILLAGER, TextureSupplier.of(texture), BASE_MODEL_SCALE);
|
||||
|
|
|
@ -8,7 +8,8 @@ import net.minecraft.client.render.entity.model.EntityModel;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.village.VillagerData;
|
||||
import net.minecraft.village.VillagerDataContainer;
|
||||
|
@ -16,7 +17,6 @@ import net.minecraft.village.VillagerProfession;
|
|||
import net.minecraft.village.VillagerType;
|
||||
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
import com.minelittlepony.client.render.entity.feature.AbstractPonyFeature;
|
||||
import com.minelittlepony.client.util.render.TextureFlattener;
|
||||
|
@ -30,11 +30,11 @@ class NpcClothingFeature<
|
|||
C extends FeatureRendererContext<T, M> & PonyRenderContext<T, M>> extends AbstractPonyFeature<T, M> {
|
||||
|
||||
private static final Int2ObjectMap<Identifier> LEVEL_TO_ID = Util.make(new Int2ObjectOpenHashMap<>(), a -> {
|
||||
a.put(1, Identifier.ofVanilla("stone"));
|
||||
a.put(2, Identifier.ofVanilla("iron"));
|
||||
a.put(3, Identifier.ofVanilla("gold"));
|
||||
a.put(4, Identifier.ofVanilla("emerald"));
|
||||
a.put(5, Identifier.ofVanilla("diamond"));
|
||||
a.put(1, new Identifier("stone"));
|
||||
a.put(2, new Identifier("iron"));
|
||||
a.put(3, new Identifier("gold"));
|
||||
a.put(4, new Identifier("emerald"));
|
||||
a.put(5, new Identifier("diamond"));
|
||||
});
|
||||
private final Set<Identifier> loadedTextures = new HashSet<>();
|
||||
|
||||
|
@ -59,9 +59,9 @@ class NpcClothingFeature<
|
|||
if (!ResourceUtil.textureExists(typeSkin)) {
|
||||
typeSkin = createTexture("type", Registries.VILLAGER_TYPE.getId(VillagerType.PLAINS));
|
||||
}
|
||||
renderModel(entityModel, typeSkin, matrixStack, provider, i, entity, Colors.WHITE);
|
||||
renderModel(entityModel, typeSkin, matrixStack, provider, i, entity, 1, 1, 1);
|
||||
} else {
|
||||
renderModel(entityModel, getMergedTexture(data), matrixStack, provider, i, entity, Colors.WHITE);
|
||||
renderModel(entityModel, getMergedTexture(data), matrixStack, provider, i, entity, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ class NpcClothingFeature<
|
|||
Identifier typeId = Registries.VILLAGER_TYPE.getId(type);
|
||||
Identifier profId = Registries.VILLAGER_PROFESSION.getId(profession);
|
||||
|
||||
Identifier key = MineLittlePony.id((typeId + "/" + profId + "/" + level).replace(':', '_'));
|
||||
Identifier key = new Identifier("minelittlepony", (typeId + "/" + profId + "/" + level).replace(':', '_'));
|
||||
|
||||
if (loadedTextures.add(key) && !ResourceUtil.textureExists(key)) {
|
||||
TextureFlattener.flatten(computeTextures(typeId, profId, profession == VillagerProfession.NITWIT ? -1 : level), key);
|
||||
|
@ -91,7 +91,7 @@ class NpcClothingFeature<
|
|||
}
|
||||
|
||||
Identifier profTexture = createTexture("profession", profId);
|
||||
skins.add(ResourceUtil.textureExists(profTexture) ? profTexture : createTexture("profession", Identifier.of(VillagerProfession.NITWIT.id())));
|
||||
skins.add(ResourceUtil.textureExists(profTexture) ? profTexture : createTexture("profession", new Identifier(VillagerProfession.NITWIT.id())));
|
||||
|
||||
if (level != -1) {
|
||||
skins.add(createTexture("profession_level", LEVEL_TO_ID.get(level)));
|
||||
|
@ -105,6 +105,6 @@ class NpcClothingFeature<
|
|||
}
|
||||
|
||||
private Identifier createTexture(String category, Identifier identifier) {
|
||||
return MineLittlePony.id(String.format("textures/entity/%s/%s/%s.png", entityType, category, identifier.getPath()));
|
||||
return new Identifier("minelittlepony", String.format("textures/entity/%s/%s/%s.png", entityType, category, identifier.getPath()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.client.render.entity.EntityRendererFactory;
|
|||
import net.minecraft.entity.mob.PillagerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.PillagerPonyModel;
|
||||
import com.minelittlepony.client.render.entity.feature.IllagerHeldItemFeature;
|
||||
|
@ -13,7 +12,8 @@ import com.minelittlepony.client.render.entity.PonyRenderer;
|
|||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||
|
||||
public class PillagerRenderer extends PonyRenderer<PillagerEntity, PillagerPonyModel<PillagerEntity>> {
|
||||
private static final Identifier TEXTURE = MineLittlePony.id("textures/entity/illager/pillager_pony.png");
|
||||
|
||||
private static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/entity/illager/pillager_pony.png");
|
||||
|
||||
public PillagerRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.PILLAGER, TextureSupplier.of(TEXTURE));
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue