mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-03-14 15:40:06 +01:00
Compare commits
62 commits
1.20.2
...
4.12.0-bet
Author | SHA1 | Date | |
---|---|---|---|
|
86101e0807 | ||
|
1d0001c702 | ||
|
ca2d21d77e | ||
|
fa13d3263d | ||
|
8db3536250 | ||
|
d11fbf63f2 | ||
|
7f89ef646e | ||
|
1ff9489a61 | ||
|
91976a1020 | ||
|
8afa58f014 | ||
|
20dda1d517 | ||
|
49ae1f1f01 | ||
|
a9ede9405f | ||
|
6bf9906795 | ||
|
ed581e6dcc | ||
|
70e8e23996 | ||
|
2d2dc3b8d6 | ||
|
5524f8c7f1 | ||
|
ff6b3d182d | ||
|
ec193657af | ||
|
4963796c84 | ||
|
f0ee97bce0 | ||
|
1a22b290a6 | ||
|
0c0d77090f | ||
|
411118d036 | ||
|
c6560513bc | ||
|
405d9e2bbf | ||
|
a1e35bedb6 | ||
|
9c103dbddd | ||
|
aac343cd46 | ||
|
c4968aed4c | ||
|
4b6fdd4752 | ||
|
bf4a0139fb | ||
|
53b8921c50 | ||
|
0da671b699 | ||
|
93a895e90e | ||
|
53c9a85877 | ||
|
ced4a2d980 | ||
|
85726e8c8d | ||
|
eeea8ee184 | ||
|
3c44b00c1d | ||
|
8d385a3202 | ||
|
a9051293b7 | ||
|
62d606ada4 | ||
|
cc463bb293 | ||
|
807fb3213a | ||
|
36702e1fec | ||
|
1fc533babd | ||
|
4a3b6bb54b | ||
|
30e899a7e0 | ||
|
1bab1fe79c | ||
|
fce1db2cc7 | ||
|
e8035e97f5 | ||
|
8aa189f928 | ||
|
50e83bb930 | ||
|
58076df09a | ||
|
7ad3ab236a | ||
|
8687ec443b | ||
|
709879fe61 | ||
|
9f33f4c06a | ||
|
daa40cc143 | ||
|
63ec053bc2 |
119 changed files with 1239 additions and 1000 deletions
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
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
Normal file
26
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
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
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 17
|
java-version: 21
|
||||||
- name: Build Gradle
|
- name: Build Gradle
|
||||||
uses: eskatos/gradle-command-action@v1
|
uses: eskatos/gradle-command-action@v1
|
||||||
with:
|
with:
|
||||||
|
|
2
.github/workflows/gradle-check.yml
vendored
2
.github/workflows/gradle-check.yml
vendored
|
@ -12,7 +12,7 @@ jobs:
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 17
|
java-version: 21
|
||||||
- name: Build Gradle
|
- name: Build Gradle
|
||||||
uses: eskatos/gradle-command-action@v1
|
uses: eskatos/gradle-command-action@v1
|
||||||
with:
|
with:
|
||||||
|
|
2
.github/workflows/gradle-publish.yml
vendored
2
.github/workflows/gradle-publish.yml
vendored
|
@ -16,7 +16,7 @@ jobs:
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 17
|
java-version: 21
|
||||||
- name: Publish Maven Jar
|
- name: Publish Maven Jar
|
||||||
env:
|
env:
|
||||||
ACCESS_KEY: ${{ secrets.ACCESS_KEY }}
|
ACCESS_KEY: ${{ secrets.ACCESS_KEY }}
|
||||||
|
|
8
.gitmodules
vendored
8
.gitmodules
vendored
|
@ -2,3 +2,11 @@
|
||||||
path = skins
|
path = skins
|
||||||
url = https://github.com/MineLittlePony/Community-Skin-Pack.git
|
url = https://github.com/MineLittlePony/Community-Skin-Pack.git
|
||||||
branch = master
|
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 {
|
plugins {
|
||||||
id 'fabric-loom' version '1.5-SNAPSHOT'
|
id 'fabric-loom' version '1.6-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'com.modrinth.minotaur' version '2.+'
|
id 'com.modrinth.minotaur' version '2.+'
|
||||||
id 'org.ajoberstar.reckon' version '0.13.0'
|
id 'org.ajoberstar.reckon' version '0.13.0'
|
||||||
|
@ -13,13 +13,13 @@ apply plugin: 'dex.plugins.outlet'
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion = JavaLanguageVersion.of(17)
|
languageVersion = JavaLanguageVersion.of(21)
|
||||||
}
|
}
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
outlet.allowSnapshotsForProject = false
|
outlet.allowSnapshotsForProject = false
|
||||||
outlet.mcVersionRange = project.minecraft_version_range
|
outlet.mcVersionRange = ">=${project.minecraft_version}"
|
||||||
|
|
||||||
group = project.group
|
group = project.group
|
||||||
description = project.displayname
|
description = project.displayname
|
||||||
|
@ -84,7 +84,7 @@ processResources {
|
||||||
|
|
||||||
filesMatching("fabric.mod.json") {
|
filesMatching("fabric.mod.json") {
|
||||||
expand "version": project.version.toString(),
|
expand "version": project.version.toString(),
|
||||||
"minecraftVersion": project.minecraft_version_range,
|
"minecraftVersion": ">=${project.minecraft_version}",
|
||||||
"loaderVersion": ">=${project.loader_version}",
|
"loaderVersion": ">=${project.loader_version}",
|
||||||
"fabricVersion": ">=${project.fabric_version}",
|
"fabricVersion": ">=${project.fabric_version}",
|
||||||
"kirinVersion": ">=${project.kirin_version}",
|
"kirinVersion": ">=${project.kirin_version}",
|
||||||
|
@ -123,9 +123,10 @@ modrinth {
|
||||||
gameVersions.add ver
|
gameVersions.add ver
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
required.project 'P7dR8mSH'
|
required.project 'P7dR8mSH' // Fabric API
|
||||||
optional.project 'FzE9gshV'
|
required.project '9aNz8Zqn' // Kirin
|
||||||
optional.project 'h9pJxJR9'
|
optional.project 'FzE9gshV' // HD Skins
|
||||||
|
optional.project 'h9pJxJR9' // Big Pony
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@ org.gradle.daemon=false
|
||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=1.20.2
|
minecraft_version=1.21-pre2
|
||||||
yarn_mappings=1.20.2+build.4
|
yarn_mappings=1.21-pre2+build.2
|
||||||
loader_version=0.15.1
|
loader_version=0.15.11
|
||||||
fabric_version=0.91.1+1.20.2
|
fabric_version=0.99.4+1.21
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
group=com.minelittlepony
|
group=com.minelittlepony
|
||||||
|
@ -15,12 +15,11 @@ org.gradle.daemon=false
|
||||||
description=Mine Little Pony turns players and mobs into ponies. Press F9 ingame to access settings.
|
description=Mine Little Pony turns players and mobs into ponies. Press F9 ingame to access settings.
|
||||||
|
|
||||||
# Publishing
|
# Publishing
|
||||||
minecraft_version_range=>=1.20.2
|
|
||||||
modrinth_loader_type=fabric
|
modrinth_loader_type=fabric
|
||||||
modrinth_project_id=JBjInUXM
|
modrinth_project_id=JBjInUXM
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
modmenu_version=8.0.0
|
modmenu_version=11.0.0-beta.1
|
||||||
kirin_version=1.16.1+1.20.2
|
kirin_version=1.19.0-beta.5+1.21
|
||||||
hd_skins_version=6.11.2+1.20.2
|
hd_skins_version=6.13.0-beta.2+1.21
|
||||||
mson_version=1.9.3+1.20.2
|
mson_version=1.10.0-beta.2+1.21
|
||||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
1
plugins/ShowMeYourPonies
Submodule
1
plugins/ShowMeYourPonies
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 055fd831ee57bb17c44042ef28f7f57a5fc0333a
|
1
plugins/Sockies
Submodule
1
plugins/Sockies
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 9b57eec91c820844bd1fc7a0423f4049405b2290
|
|
@ -1,13 +1,16 @@
|
||||||
package com.minelittlepony.api.config;
|
package com.minelittlepony.api.config;
|
||||||
|
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
import com.minelittlepony.api.pony.meta.*;
|
import com.minelittlepony.api.pony.meta.*;
|
||||||
import com.minelittlepony.common.client.gui.VisibilityMode;
|
import com.minelittlepony.common.client.gui.VisibilityMode;
|
||||||
import com.minelittlepony.common.util.GamePaths;
|
import com.minelittlepony.common.util.GamePaths;
|
||||||
import com.minelittlepony.common.util.settings.*;
|
import com.minelittlepony.common.util.settings.*;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Storage container for MineLP client settings.
|
* Storage container for MineLP client settings.
|
||||||
|
@ -85,8 +88,13 @@ public class PonyConfig extends Config {
|
||||||
.addComment("ON - always show")
|
.addComment("ON - always show")
|
||||||
.addComment("OFF - never 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) {
|
public PonyConfig(Path path) {
|
||||||
super(HEIRARCHICAL_JSON_ADAPTER, path);
|
super(new HeirarchicalJsonConfigAdapter(new GsonBuilder()
|
||||||
|
.registerTypeAdapter(Identifier.class, new ToStringAdapter<>(Identifier::toString, Identifier::of))), path);
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,11 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginConnectionEvents;
|
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginConnectionEvents;
|
||||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
import net.fabricmc.fabric.api.networking.v1.*;
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
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 net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
@ -17,8 +18,6 @@ import com.minelittlepony.api.pony.PonyData;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class Channel {
|
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 final Logger LOGGER = LogManager.getLogger("MineLittlePony:Networking");
|
||||||
|
|
||||||
private static boolean registered;
|
private static boolean registered;
|
||||||
|
@ -27,20 +26,24 @@ public class Channel {
|
||||||
ClientLoginConnectionEvents.INIT.register((handler, client) -> {
|
ClientLoginConnectionEvents.INIT.register((handler, client) -> {
|
||||||
registered = false;
|
registered = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
LOGGER.info("Sending consent packet to " + handler.getPlayer().getName().getString());
|
LOGGER.info("Sending consent packet to " + handler.getPlayer().getName().getString());
|
||||||
|
sender.sendPacket(PonyDataRequest.INSTANCE);
|
||||||
sender.sendPacket(REQUEST_PONY_DATA, PacketByteBufs.empty());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ClientPlayNetworking.registerGlobalReceiver(REQUEST_PONY_DATA, (client, handler, ignored, sender) -> {
|
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) -> {
|
||||||
registered = true;
|
registered = true;
|
||||||
LOGGER.info("Server has just consented");
|
LOGGER.info("Server has just consented");
|
||||||
});
|
});
|
||||||
ServerPlayNetworking.registerGlobalReceiver(CLIENT_PONY_DATA, (server, player, ignore, buffer, ignore2) -> {
|
|
||||||
PonyData packet = MsgPonyData.read(buffer);
|
ServerPlayNetworking.registerGlobalReceiver(PonyDataPayload.ID, (packet, context) -> {
|
||||||
server.execute(() -> {
|
context.player().server.execute(() -> {
|
||||||
PonyDataCallback.EVENT.invoker().onPonyDataAvailable(player, packet, EnvType.SERVER);
|
PonyDataCallback.EVENT.invoker().onPonyDataAvailable(context.player(), packet.data(), EnvType.SERVER);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -57,7 +60,31 @@ public class Channel {
|
||||||
throw new RuntimeException("Client packet send called by the server");
|
throw new RuntimeException("Client packet send called by the server");
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientPlayNetworking.send(CLIENT_PONY_DATA, MsgPonyData.write(packet, PacketByteBufs.create()));
|
ClientPlayNetworking.send(new PonyDataPayload(packet));
|
||||||
return true;
|
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,8 +7,13 @@ import net.minecraft.entity.Entity;
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
import com.minelittlepony.api.model.PonyModel;
|
||||||
import com.minelittlepony.api.model.ModelAttributes;
|
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 {
|
public interface PonyModelPrepareCallback {
|
||||||
|
|
||||||
Event<PonyModelPrepareCallback> EVENT = EventFactory.createArrayBacked(PonyModelPrepareCallback.class, listeners -> (entity, model, mode) -> {
|
Event<PonyModelPrepareCallback> EVENT = EventFactory.createArrayBacked(PonyModelPrepareCallback.class, listeners -> (entity, model, mode) -> {
|
||||||
for (PonyModelPrepareCallback event : listeners) {
|
for (PonyModelPrepareCallback event : listeners) {
|
||||||
event.onPonyModelPrepared(entity, model, mode);
|
event.onPonyModelPrepared(entity, model, mode);
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
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;
|
public boolean isLeftHanded;
|
||||||
/**
|
/**
|
||||||
* True if the model is sitting as in boats.
|
* True if the model is riding on the back of another pony.
|
||||||
*/
|
*/
|
||||||
public boolean isRidingInteractive;
|
public boolean isRidingInteractive;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.api.model;
|
package com.minelittlepony.api.model;
|
||||||
|
|
||||||
public interface PreviewModel {
|
import net.minecraft.util.Identifier;
|
||||||
boolean forceSeapony();
|
|
||||||
|
|
||||||
boolean forceNirik();
|
public interface PreviewModel {
|
||||||
|
Identifier getForm();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public interface SubModel {
|
||||||
/**
|
/**
|
||||||
* Renders this model component.
|
* Renders this model component.
|
||||||
*/
|
*/
|
||||||
void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, float red, float green, float blue, float alpha, ModelAttributes attributes);
|
void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether this part should be rendered.
|
* Sets whether this part should be rendered.
|
||||||
|
|
|
@ -27,14 +27,14 @@ public abstract class AbstractGearModel extends Model implements Gear {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
public void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, UUID interpolatorId) {
|
||||||
render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
render(stack, vertices, overlay, light, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumer renderContext, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack stack, VertexConsumer renderContext, int overlay, int light, int color) {
|
||||||
parts.forEach(part -> {
|
parts.forEach(part -> {
|
||||||
part.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
part.render(stack, renderContext, overlay, light, color);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ public interface Gear {
|
||||||
/**
|
/**
|
||||||
* Renders this model component.
|
* Renders this model component.
|
||||||
*/
|
*/
|
||||||
void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId);
|
void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, UUID interpolatorId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A render context for instance of IGear.
|
* A render context for instance of IGear.
|
||||||
|
|
|
@ -3,30 +3,34 @@ package com.minelittlepony.api.pony;
|
||||||
import net.minecraft.client.util.DefaultSkinHelper;
|
import net.minecraft.client.util.DefaultSkinHelper;
|
||||||
import net.minecraft.client.util.SkinTextures;
|
import net.minecraft.client.util.SkinTextures;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
|
|
||||||
import com.minelittlepony.api.pony.meta.Race;
|
import com.minelittlepony.api.pony.meta.Race;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public final class DefaultPonySkinHelper {
|
public final class DefaultPonySkinHelper {
|
||||||
public static final Identifier STEVE = new Identifier("minelittlepony", "textures/entity/player/wide/steve_pony.png");
|
public static final Identifier STEVE = id("textures/entity/player/wide/steve_pony.png");
|
||||||
|
|
||||||
public static final Identifier SEAPONY_SKIN_TYPE_ID = new Identifier("minelp", "seapony");
|
public static final Identifier SEAPONY_SKIN_TYPE_ID = id("seapony");
|
||||||
public static final Identifier NIRIK_SKIN_TYPE_ID = new Identifier("minelp", "nirik");
|
public static final Identifier NIRIK_SKIN_TYPE_ID = id("nirik");
|
||||||
|
|
||||||
private static final Map<SkinTextures, SkinTextures> SKINS = new HashMap<>();
|
private static final Function<SkinTextures, SkinTextures> SKINS = Util.memoize(original -> new SkinTextures(
|
||||||
|
id(original.texture().getPath().replace(".png", "_pony.png")),
|
||||||
public static SkinTextures getTextures(SkinTextures original) {
|
|
||||||
return SKINS.computeIfAbsent(original, o -> {
|
|
||||||
return new SkinTextures(
|
|
||||||
new Identifier("minelittlepony", original.texture().getPath().replace(".png", "_pony.png")),
|
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
original.model(),
|
original.model(),
|
||||||
false
|
false
|
||||||
);
|
));
|
||||||
});
|
|
||||||
|
public static Identifier id(String name) {
|
||||||
|
return Identifier.of("minelittlepony", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkinTextures getTextures(SkinTextures original) {
|
||||||
|
return SKINS.apply(original);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getModelType(UUID id) {
|
public static String getModelType(UUID id) {
|
||||||
|
|
49
src/main/java/com/minelittlepony/api/pony/PonyForm.java
Normal file
49
src/main/java/com/minelittlepony/api/pony/PonyForm.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
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,16 +86,9 @@ public final class PonyPosture {
|
||||||
return isSitting(entity) && getMountPony(entity).map(Pony::race).orElse(Race.HUMAN) != Race.HUMAN;
|
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) {
|
public static boolean hasSeaponyForm(LivingEntity entity) {
|
||||||
if (entity instanceof PreviewModel preview) {
|
if (entity instanceof PreviewModel preview) {
|
||||||
return preview.forceSeapony();
|
return preview.getForm() == PonyForm.SEAPONY;
|
||||||
}
|
}
|
||||||
return Pony.getManager().getPony(entity).filter(pony -> {
|
return Pony.getManager().getPony(entity).filter(pony -> {
|
||||||
return (pony.race() == Race.SEAPONY
|
return (pony.race() == Race.SEAPONY
|
||||||
|
@ -104,17 +97,9 @@ public final class PonyPosture {
|
||||||
}).isPresent();
|
}).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNirikModifier(LivingEntity entity) {
|
|
||||||
if (entity instanceof PreviewModel preview) {
|
|
||||||
return preview.forceNirik();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean hasNirikForm(LivingEntity entity) {
|
public static boolean hasNirikForm(LivingEntity entity) {
|
||||||
if (entity instanceof PreviewModel preview) {
|
if (entity instanceof PreviewModel preview) {
|
||||||
return preview.forceNirik();
|
return preview.getForm() == PonyForm.NIRIK;
|
||||||
}
|
}
|
||||||
return Pony.getManager().getPony(entity).filter(pony -> {
|
return Pony.getManager().getPony(entity).filter(pony -> {
|
||||||
return (pony.race() == Race.KIRIN
|
return (pony.race() == Race.KIRIN
|
||||||
|
|
|
@ -3,20 +3,22 @@ package com.minelittlepony.api.pony.meta;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.ColorHelper;
|
import net.minecraft.util.math.ColorHelper;
|
||||||
|
|
||||||
|
import com.minelittlepony.api.pony.DefaultPonySkinHelper;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public enum Wearable implements TValue<Wearable> {
|
public enum Wearable implements TValue<Wearable> {
|
||||||
NONE (0x00, null),
|
NONE (0x00, null),
|
||||||
CROWN (0x16, new Identifier("minelittlepony", "textures/models/crown.png")),
|
CROWN (0x16, DefaultPonySkinHelper.id("textures/models/crown.png")),
|
||||||
MUFFIN (0x32, new Identifier("minelittlepony", "textures/models/muffin.png")),
|
MUFFIN (0x32, DefaultPonySkinHelper.id("textures/models/muffin.png")),
|
||||||
HAT (0x64, new Identifier("textures/entity/witch.png")),
|
HAT (0x64, Identifier.ofVanilla("textures/entity/witch.png")),
|
||||||
ANTLERS (0x96, new Identifier("minelittlepony", "textures/models/antlers.png")),
|
ANTLERS (0x96, DefaultPonySkinHelper.id("textures/models/antlers.png")),
|
||||||
SADDLE_BAGS_LEFT (0xC6, new Identifier("minelittlepony", "textures/models/saddlebags.png")),
|
SADDLE_BAGS_LEFT (0xC6, DefaultPonySkinHelper.id("textures/models/saddlebags.png")),
|
||||||
SADDLE_BAGS_RIGHT (0xC7, new Identifier("minelittlepony", "textures/models/saddlebags.png")),
|
SADDLE_BAGS_RIGHT (0xC7, DefaultPonySkinHelper.id("textures/models/saddlebags.png")),
|
||||||
SADDLE_BAGS_BOTH (0xC8, new Identifier("minelittlepony", "textures/models/saddlebags.png")),
|
SADDLE_BAGS_BOTH (0xC8, DefaultPonySkinHelper.id("textures/models/saddlebags.png")),
|
||||||
STETSON (0xFA, new Identifier("minelittlepony", "textures/models/stetson.png"));
|
STETSON (0xFA, DefaultPonySkinHelper.id("textures/models/stetson.png"));
|
||||||
|
|
||||||
private int triggerValue;
|
private int triggerValue;
|
||||||
|
|
||||||
|
@ -29,7 +31,7 @@ public enum Wearable implements TValue<Wearable> {
|
||||||
|
|
||||||
Wearable(int pixel, Identifier texture) {
|
Wearable(int pixel, Identifier texture) {
|
||||||
triggerValue = pixel;
|
triggerValue = pixel;
|
||||||
id = new Identifier("minelittlepony", name().toLowerCase(Locale.ROOT));
|
id = DefaultPonySkinHelper.id(name().toLowerCase(Locale.ROOT));
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class HorseCam {
|
||||||
public static float rescaleCameraPitch(double toHeight, float originalPitch) {
|
public static float rescaleCameraPitch(double toHeight, float originalPitch) {
|
||||||
MinecraftClient client = MinecraftClient.getInstance();
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
PlayerEntity player = client.player;
|
PlayerEntity player = client.player;
|
||||||
client.gameRenderer.updateTargetedEntity(client.getTickDelta());
|
client.gameRenderer.updateCrosshairTarget(client.getRenderTickCounter().getTickDelta(false));
|
||||||
HitResult hit = client.crosshairTarget;
|
HitResult hit = client.crosshairTarget;
|
||||||
|
|
||||||
if (client.targetedEntity != null) {
|
if (client.targetedEntity != null) {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.minelittlepony.client.render.PonyRenderDispatcher;
|
||||||
import com.minelittlepony.common.client.gui.VisibilityMode;
|
import com.minelittlepony.common.client.gui.VisibilityMode;
|
||||||
import com.minelittlepony.common.client.gui.element.Button;
|
import com.minelittlepony.common.client.gui.element.Button;
|
||||||
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
|
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.ScreenInitCallback;
|
||||||
import com.minelittlepony.common.event.SkinFilterCallback;
|
import com.minelittlepony.common.event.SkinFilterCallback;
|
||||||
import com.minelittlepony.common.util.GamePaths;
|
import com.minelittlepony.common.util.GamePaths;
|
||||||
|
@ -48,6 +47,7 @@ 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 KeyBinding keyBinding = new KeyBinding("key.minelittlepony.settings", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_F9, "key.categories.misc");
|
||||||
|
|
||||||
private final PonyRenderDispatcher renderDispatcher = new PonyRenderDispatcher();
|
private final PonyRenderDispatcher renderDispatcher = new PonyRenderDispatcher();
|
||||||
|
private boolean initialized;
|
||||||
|
|
||||||
private boolean hasHdSkins;
|
private boolean hasHdSkins;
|
||||||
private boolean hasModMenu;
|
private boolean hasModMenu;
|
||||||
|
@ -63,6 +63,10 @@ public class MineLittlePony implements ClientModInitializer {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Identifier id(String name) {
|
||||||
|
return Identifier.of("minelittlepony", name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
hasHdSkins = FabricLoader.getInstance().isModLoaded("hdskins");
|
hasHdSkins = FabricLoader.getInstance().isModLoaded("hdskins");
|
||||||
|
@ -76,16 +80,13 @@ public class MineLittlePony implements ClientModInitializer {
|
||||||
|
|
||||||
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ponyManager);
|
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ponyManager);
|
||||||
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(variatedTextures);
|
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(variatedTextures);
|
||||||
|
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ArmourTextureResolver.INSTANCE);
|
||||||
|
|
||||||
// convert legacy pony skins
|
// convert legacy pony skins
|
||||||
SkinFilterCallback.EVENT.register(new LegacySkinConverter());
|
SkinFilterCallback.EVENT.register(new LegacySkinConverter());
|
||||||
|
|
||||||
// general events
|
// general events
|
||||||
ClientReadyCallback.Handler.register();
|
|
||||||
ClientTickEvents.END_CLIENT_TICK.register(this::onTick);
|
ClientTickEvents.END_CLIENT_TICK.register(this::onTick);
|
||||||
ClientReadyCallback.EVENT.register(client -> {
|
|
||||||
renderDispatcher.initialise(client.getEntityRenderDispatcher(), false);
|
|
||||||
});
|
|
||||||
ScreenInitCallback.EVENT.register(this::onScreenInit);
|
ScreenInitCallback.EVENT.register(this::onScreenInit);
|
||||||
|
|
||||||
config.load();
|
config.load();
|
||||||
|
@ -97,6 +98,10 @@ public class MineLittlePony implements ClientModInitializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTick(MinecraftClient client) {
|
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 inGame = client.world != null && client.player != null && client.currentScreen == null;
|
||||||
boolean mainMenu = client.currentScreen instanceof TitleScreen;
|
boolean mainMenu = client.currentScreen instanceof TitleScreen;
|
||||||
|
@ -124,7 +129,7 @@ public class MineLittlePony implements ClientModInitializer {
|
||||||
button.getStyle()
|
button.getStyle()
|
||||||
.setIcon(new TextureSprite()
|
.setIcon(new TextureSprite()
|
||||||
.setPosition(2, 2)
|
.setPosition(2, 2)
|
||||||
.setTexture(new Identifier("minelittlepony", "textures/gui/pony.png"))
|
.setTexture(id("textures/gui/pony.png"))
|
||||||
.setTextureSize(16, 16)
|
.setTextureSize(16, 16)
|
||||||
.setSize(16, 16))
|
.setSize(16, 16))
|
||||||
.setTooltip("minelp.options.title", 0, 10);
|
.setTooltip("minelp.options.title", 0, 10);
|
||||||
|
|
|
@ -1,50 +1,28 @@
|
||||||
package com.minelittlepony.client;
|
package com.minelittlepony.client;
|
||||||
|
|
||||||
import com.minelittlepony.api.pony.Pony;
|
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.client.MinecraftClient;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.util.math.Box;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public class PonyBounds {
|
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) {
|
private static Vec3d getBaseRidingOffset(LivingEntity entity) {
|
||||||
float delta = MinecraftClient.getInstance().getTickDelta();
|
float delta = MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false);
|
||||||
|
|
||||||
Entity vehicle = entity.getVehicle();
|
|
||||||
double vehicleOffset = vehicle == null ? 0 : vehicle.getHeight();
|
|
||||||
|
|
||||||
return new Vec3d(
|
return new Vec3d(
|
||||||
MathHelper.lerp(delta, entity.prevX, entity.getX()),
|
MathHelper.lerp(delta, entity.prevX, entity.getX()),
|
||||||
MathHelper.lerp(delta, entity.prevY, entity.getY()) + vehicleOffset,
|
MathHelper.lerp(delta, entity.prevY, entity.getY()),
|
||||||
MathHelper.lerp(delta, entity.prevZ, entity.getZ())
|
MathHelper.lerp(delta, entity.prevZ, entity.getZ())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Box getBoundingBox(Pony pony, LivingEntity entity) {
|
public static Box getBoundingBox(Pony pony, LivingEntity entity) {
|
||||||
final float scale = pony.size().scaleFactor() + 0.1F;
|
final float scale = pony.size().scaleFactor();
|
||||||
final float width = entity.getWidth() * scale;
|
final float width = entity.getWidth() * scale;
|
||||||
final float height = entity.getHeight() * scale;
|
final float height = entity.getHeight() * scale;
|
||||||
|
|
||||||
return new Box(-width, height, -width, width, 0, width).offset(getAbsoluteRidingOffset(entity));
|
return new Box(-width, 0, -width, width, height, width).offset(getBaseRidingOffset(entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.minelittlepony.client;
|
package com.minelittlepony.client;
|
||||||
|
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.cache.*;
|
import com.google.common.cache.*;
|
||||||
import com.minelittlepony.api.config.PonyConfig;
|
import com.minelittlepony.api.config.PonyConfig;
|
||||||
import com.minelittlepony.api.config.PonyLevel;
|
import com.minelittlepony.api.config.PonyLevel;
|
||||||
|
import com.minelittlepony.api.events.PonySkinResolver;
|
||||||
import com.minelittlepony.api.pony.*;
|
import com.minelittlepony.api.pony.*;
|
||||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
|
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
|
||||||
|
|
||||||
|
@ -23,7 +25,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceReloadListener {
|
public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceReloadListener {
|
||||||
private static final Identifier ID = new Identifier("minelittlepony", "background_ponies");
|
private static final Identifier ID = MineLittlePony.id("background_ponies");
|
||||||
|
|
||||||
private final PonyConfig config;
|
private final PonyConfig config;
|
||||||
|
|
||||||
|
@ -50,7 +52,13 @@ public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceRe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pony getPony(PlayerEntity player) {
|
public Pony getPony(PlayerEntity player) {
|
||||||
return getPony(getSkin(player), player instanceof ForcedPony ? null : player.getGameProfile() == null ? player.getUuid() : player.getGameProfile().getId());
|
final UUID id = player instanceof ForcedPony ? null : player.getGameProfile() == null ? player.getUuid() : player.getGameProfile().getId();
|
||||||
|
@Nullable
|
||||||
|
Identifier skin = getSkin(player);
|
||||||
|
if (skin != null) {
|
||||||
|
skin = MoreObjects.firstNonNull(PonySkinResolver.EVENT.invoker().onPonySkinResolving(player, s -> getPony(s, id), skin), skin);
|
||||||
|
}
|
||||||
|
return getPony(skin, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,7 +66,11 @@ public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceRe
|
||||||
if (entity instanceof PlayerEntity player) {
|
if (entity instanceof PlayerEntity player) {
|
||||||
return Optional.of(getPony(player));
|
return Optional.of(getPony(player));
|
||||||
}
|
}
|
||||||
|
@Nullable
|
||||||
Identifier skin = getSkin(entity);
|
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));
|
return skin == null ? Optional.empty() : Optional.of(getPony(skin, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,9 +123,9 @@ public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceRe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(ResourceManager var1) {
|
public void reload(ResourceManager manager) {
|
||||||
clearCache();
|
clearCache();
|
||||||
PonySkullRenderer.reload();
|
PonySkullRenderer.INSTANCE.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,9 +11,9 @@ import com.minelittlepony.util.MathUtil;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class VariatedTextureSupplier implements SimpleSynchronousResourceReloadListener {
|
public class VariatedTextureSupplier implements SimpleSynchronousResourceReloadListener {
|
||||||
private static final Identifier ID = new Identifier("minelittlepony", "variated_textures");
|
private static final Identifier ID = MineLittlePony.id("variated_textures");
|
||||||
public static final Identifier BACKGROUND_PONIES_POOL = new Identifier("minelittlepony", "textures/entity/pony");
|
public static final Identifier BACKGROUND_PONIES_POOL = MineLittlePony.id("textures/entity/pony");
|
||||||
public static final Identifier BACKGROUND_ZOMPONIES_POOL = new Identifier("minelittlepony", "textures/entity/zompony");
|
public static final Identifier BACKGROUND_ZOMPONIES_POOL = MineLittlePony.id("textures/entity/zompony");
|
||||||
|
|
||||||
private final Map<Identifier, SkinList> entries = new HashMap<>();
|
private final Map<Identifier, SkinList> entries = new HashMap<>();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.minelittlepony.client.compat.hdskins;
|
package com.minelittlepony.client.compat.hdskins;
|
||||||
|
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.PreviewModel;
|
import com.minelittlepony.api.model.PreviewModel;
|
||||||
import com.minelittlepony.api.pony.*;
|
import com.minelittlepony.api.pony.*;
|
||||||
|
@ -20,12 +21,13 @@ class DummyPony extends DummyPlayer implements PreviewModel, PonyManager.ForcedP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean forceSeapony() {
|
public Identifier getForm() {
|
||||||
return getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.seaponySkinType;
|
if (getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.seaponySkinType) {
|
||||||
|
return PonyForm.SEAPONY;
|
||||||
}
|
}
|
||||||
|
if (getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.nirikSkinType) {
|
||||||
@Override
|
return PonyForm.NIRIK;
|
||||||
public boolean forceNirik() {
|
}
|
||||||
return getTextures().getPosture().getActiveSkinType() == MineLPHDSkins.nirikSkinType;
|
return PonyForm.DEFAULT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,10 @@ import net.minecraft.util.Identifier;
|
||||||
* Skin uploading GUI. Usually displayed over the main menu.
|
* Skin uploading GUI. Usually displayed over the main menu.
|
||||||
*/
|
*/
|
||||||
class GuiSkinsMineLP extends GuiSkins {
|
class GuiSkinsMineLP extends GuiSkins {
|
||||||
private static final String[] PANORAMAS = new String[] {
|
private static final Identifier[] PANORAMAS = new Identifier[] {
|
||||||
"minelittlepony:textures/cubemap/sugarcubecorner",
|
MineLittlePony.id("textures/cubemap/sugarcubecorner"),
|
||||||
"minelittlepony:textures/cubemap/quillsandsofas",
|
MineLittlePony.id("textures/cubemap/quillsandsofas"),
|
||||||
"minelittlepony:textures/cubemap/sweetappleacres"
|
MineLittlePony.id("textures/cubemap/sweetappleacres")
|
||||||
};
|
};
|
||||||
|
|
||||||
public GuiSkinsMineLP(Screen parent, SkinServerList servers) {
|
public GuiSkinsMineLP(Screen parent, SkinServerList servers) {
|
||||||
|
@ -47,7 +47,7 @@ class GuiSkinsMineLP extends GuiSkins {
|
||||||
.getStyle()
|
.getStyle()
|
||||||
.setIcon(new TextureSprite()
|
.setIcon(new TextureSprite()
|
||||||
.setPosition(2, 2)
|
.setPosition(2, 2)
|
||||||
.setTexture(new Identifier("minelittlepony", "textures/gui/pony.png"))
|
.setTexture(MineLittlePony.id("textures/gui/pony.png"))
|
||||||
.setTextureSize(16, 16)
|
.setTextureSize(16, 16)
|
||||||
.setSize(16, 16))
|
.setSize(16, 16))
|
||||||
.setTooltip("minelp.options.title", 0, 10);
|
.setTooltip("minelp.options.title", 0, 10);
|
||||||
|
@ -64,8 +64,6 @@ class GuiSkinsMineLP extends GuiSkins {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Identifier getBackground() {
|
protected Identifier getBackground() {
|
||||||
int i = (int)Math.floor(Math.random() * PANORAMAS.length);
|
return PANORAMAS[(int)Math.floor(Math.random() * PANORAMAS.length)];
|
||||||
|
|
||||||
return new Identifier(PANORAMAS[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,12 @@ import com.minelittlepony.api.pony.*;
|
||||||
import com.minelittlepony.api.pony.meta.Wearable;
|
import com.minelittlepony.api.pony.meta.Wearable;
|
||||||
import com.minelittlepony.common.client.gui.ScrollContainer;
|
import com.minelittlepony.common.client.gui.ScrollContainer;
|
||||||
import com.minelittlepony.common.client.gui.element.Button;
|
import com.minelittlepony.common.client.gui.element.Button;
|
||||||
import com.minelittlepony.common.event.ClientReadyCallback;
|
import com.minelittlepony.hdskins.HDSkinsServer;
|
||||||
import com.minelittlepony.hdskins.client.*;
|
import com.minelittlepony.hdskins.client.*;
|
||||||
import com.minelittlepony.hdskins.client.gui.GuiSkins;
|
import com.minelittlepony.hdskins.client.gui.GuiSkins;
|
||||||
import com.minelittlepony.hdskins.client.gui.player.DummyPlayer;
|
import com.minelittlepony.hdskins.client.gui.player.DummyPlayer;
|
||||||
import com.minelittlepony.hdskins.client.gui.player.skins.PlayerSkins.PlayerSkin;
|
import com.minelittlepony.hdskins.client.gui.player.skins.PlayerSkins.PlayerSkin;
|
||||||
|
import com.minelittlepony.hdskins.client.profile.SkinLoader.ProvidedSkins;
|
||||||
import com.minelittlepony.hdskins.profile.SkinType;
|
import com.minelittlepony.hdskins.profile.SkinType;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
@ -37,7 +38,7 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
||||||
static SkinType seaponySkinType;
|
static SkinType seaponySkinType;
|
||||||
static SkinType nirikSkinType;
|
static SkinType nirikSkinType;
|
||||||
|
|
||||||
static final Map<SkinType, Wearable> wearableTypes = new HashMap<>();
|
static final Map<SkinType, Wearable> WEARABLE_TYPES = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
|
@ -48,17 +49,17 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
||||||
nirikSkinType = SkinType.register(DefaultPonySkinHelper.NIRIK_SKIN_TYPE_ID, Items.LAVA_BUCKET.getDefaultStack());
|
nirikSkinType = SkinType.register(DefaultPonySkinHelper.NIRIK_SKIN_TYPE_ID, Items.LAVA_BUCKET.getDefaultStack());
|
||||||
Wearable.REGISTRY.values().forEach(wearable -> {
|
Wearable.REGISTRY.values().forEach(wearable -> {
|
||||||
if (wearable != Wearable.NONE) {
|
if (wearable != Wearable.NONE) {
|
||||||
wearableTypes.put(SkinType.register(wearable.getId(), Items.BUNDLE.getDefaultStack()), wearable);
|
WEARABLE_TYPES.put(SkinType.register(wearable.getId(), Items.BUNDLE.getDefaultStack()), wearable);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ClientReadyCallback.EVENT.register(client -> {
|
|
||||||
// Clear ponies when skins are cleared
|
// Clear ponies when skins are cleared
|
||||||
SkinCacheClearCallback.EVENT.register(MineLittlePony.getInstance().getManager()::clearCache);
|
SkinCacheClearCallback.EVENT.register(() -> {
|
||||||
|
MineLittlePony.getInstance().getManager().clearCache();
|
||||||
|
});
|
||||||
|
|
||||||
// Ponify the skins GUI.
|
// Ponify the skins GUI.
|
||||||
GuiSkins.setSkinsGui(GuiSkinsMineLP::new);
|
GuiSkins.setSkinsGui(GuiSkinsMineLP::new);
|
||||||
});
|
|
||||||
|
|
||||||
HDSkins.getInstance().getSkinPrioritySorter().addSelector((skinType, playerSkins) -> {
|
HDSkins.getInstance().getSkinPrioritySorter().addSelector((skinType, playerSkins) -> {
|
||||||
if (skinType == SkinType.SKIN && PonyConfig.getInstance().mixedHumanSkins.get()) {
|
if (skinType == SkinType.SKIN && PonyConfig.getInstance().mixedHumanSkins.get()) {
|
||||||
|
@ -75,7 +76,7 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static Optional<Pony> getPony(PlayerSkins.Layer layer) {
|
static Optional<Pony> getPony(PlayerSkinLayers.Layer layer) {
|
||||||
return layer
|
return layer
|
||||||
.getSkin(SkinType.SKIN)
|
.getSkin(SkinType.SKIN)
|
||||||
.map(Pony.getManager()::getPony);
|
.map(Pony.getManager()::getPony);
|
||||||
|
@ -84,7 +85,7 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
||||||
private void renderOption(Screen screen, @Nullable Screen parent, int row, int RIGHT, ScrollContainer content) {
|
private void renderOption(Screen screen, @Nullable Screen parent, int row, int RIGHT, ScrollContainer content) {
|
||||||
content.addButton(new Button(RIGHT, row += 20, 150, 20))
|
content.addButton(new Button(RIGHT, row += 20, 150, 20))
|
||||||
.onClick(button -> MinecraftClient.getInstance().setScreen(
|
.onClick(button -> MinecraftClient.getInstance().setScreen(
|
||||||
parent instanceof GuiSkins ? parent : GuiSkins.create(screen, HDSkins.getInstance().getSkinServerList())
|
parent instanceof GuiSkins ? parent : GuiSkins.create(screen, HDSkinsServer.getInstance().getServers())
|
||||||
))
|
))
|
||||||
.getStyle()
|
.getStyle()
|
||||||
.setText("minelp.options.skins.hdskins.open");
|
.setText("minelp.options.skins.hdskins.open");
|
||||||
|
@ -103,8 +104,9 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
||||||
|
|
||||||
if (entity instanceof AbstractClientPlayerEntity player) {
|
if (entity instanceof AbstractClientPlayerEntity player) {
|
||||||
return PlayerSkins.of(player)
|
return PlayerSkins.of(player)
|
||||||
.map(PlayerSkins::combined)
|
.map(PlayerSkins::layers)
|
||||||
.map(PlayerSkins.Layer::getProvidedSkinTypes)
|
.map(PlayerSkinLayers::combined)
|
||||||
|
.map(PlayerSkinLayers.Layer::getProvidedSkinTypes)
|
||||||
.orElseGet(Set::of);
|
.orElseGet(Set::of);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,13 +134,17 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.of(player).flatMap(PlayerSkins::of).map(PlayerSkins::combined).flatMap(skins -> skins.getSkin(type));
|
return Optional.of(player)
|
||||||
|
.flatMap(PlayerSkins::of)
|
||||||
|
.map(PlayerSkins::layers)
|
||||||
|
.map(PlayerSkinLayers::combined)
|
||||||
|
.flatMap(skins -> skins.getSkin(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier getSkinTexture(GameProfile profile) {
|
public Identifier getSkinTexture(GameProfile profile) {
|
||||||
return HDSkins.getInstance().getProfileRepository()
|
return HDSkins.getInstance().getProfileRepository()
|
||||||
.getNow(profile)
|
.load(profile).getNow(ProvidedSkins.EMPTY)
|
||||||
.getSkin(SkinType.SKIN)
|
.getSkin(SkinType.SKIN)
|
||||||
.orElseGet(() -> super.getSkinTexture(profile));
|
.orElseGet(() -> super.getSkinTexture(profile));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class PonifiedDualCarouselWidget extends DualCarouselWidget {
|
||||||
return super.getDefaultSkin(SkinType.SKIN, modelVariant);
|
return super.getDefaultSkin(SkinType.SKIN, modelVariant);
|
||||||
}
|
}
|
||||||
|
|
||||||
Wearable wearable = MineLPHDSkins.wearableTypes.getOrDefault(type, Wearable.NONE);
|
Wearable wearable = MineLPHDSkins.WEARABLE_TYPES.getOrDefault(type, Wearable.NONE);
|
||||||
|
|
||||||
if (wearable != Wearable.NONE) {
|
if (wearable != Wearable.NONE) {
|
||||||
return NativeImageFilters.GREYSCALE.load(wearable.getDefaultTexture(), wearable.getDefaultTexture(), getExclusion());
|
return NativeImageFilters.GREYSCALE.load(wearable.getDefaultTexture(), wearable.getDefaultTexture(), getExclusion());
|
||||||
|
|
|
@ -12,11 +12,11 @@ import net.minecraft.client.render.Camera;
|
||||||
|
|
||||||
@Mixin(Camera.class)
|
@Mixin(Camera.class)
|
||||||
abstract class MixinCamera {
|
abstract class MixinCamera {
|
||||||
@Inject(method = "clipToSpace(D)D",
|
@Inject(method = "clipToSpace(F)F",
|
||||||
at = @At("RETURN"),
|
at = @At("RETURN"),
|
||||||
cancellable = true)
|
cancellable = true)
|
||||||
private void redirectCameraDistance(double initial, CallbackInfoReturnable<Double> info) {
|
private void redirectCameraDistance(float initial, CallbackInfoReturnable<Float> info) {
|
||||||
double value = info.getReturnValueD();
|
float value = info.getReturnValueF();
|
||||||
|
|
||||||
Pony pony = Pony.getManager().getPony(MinecraftClient.getInstance().player);
|
Pony pony = Pony.getManager().getPony(MinecraftClient.getInstance().player);
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,10 @@
|
||||||
package com.minelittlepony.client.mixin;
|
package com.minelittlepony.client.mixin;
|
||||||
|
|
||||||
import com.minelittlepony.api.pony.Pony;
|
|
||||||
import com.minelittlepony.client.render.EquineRenderManager;
|
import com.minelittlepony.client.render.EquineRenderManager;
|
||||||
|
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
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.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)
|
@Mixin(ClientPlayerEntity.class)
|
||||||
abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity implements EquineRenderManager.RegistrationHandler {
|
abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity implements EquineRenderManager.RegistrationHandler {
|
||||||
|
@ -21,39 +12,8 @@ abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity implem
|
||||||
|
|
||||||
private final EquineRenderManager.SyncedPony syncedPony = new EquineRenderManager.SyncedPony();
|
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
|
@Override
|
||||||
public EquineRenderManager.SyncedPony getSyncedPony() {
|
public EquineRenderManager.SyncedPony getSyncedPony() {
|
||||||
return syncedPony;
|
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,7 +1,6 @@
|
||||||
package com.minelittlepony.client.mixin;
|
package com.minelittlepony.client.mixin;
|
||||||
|
|
||||||
import net.minecraft.client.render.*;
|
import net.minecraft.client.render.*;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
@ -14,12 +13,12 @@ import com.minelittlepony.api.model.RenderPass;
|
||||||
@Mixin(GameRenderer.class)
|
@Mixin(GameRenderer.class)
|
||||||
abstract class MixinGameRenderer {
|
abstract class MixinGameRenderer {
|
||||||
@Inject(method = "renderWorld", at = @At("HEAD"))
|
@Inject(method = "renderWorld", at = @At("HEAD"))
|
||||||
private void beforeRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
private void beforeRenderWorld(float tickDelta, long limitTime, CallbackInfo info) {
|
||||||
RenderPass.swap(RenderPass.WORLD);
|
RenderPass.swap(RenderPass.WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "renderWorld", at = @At("RETURN"))
|
@Inject(method = "renderWorld", at = @At("RETURN"))
|
||||||
private void afterRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
private void afterRenderWorld(float tickDelta, long limitTime, CallbackInfo info) {
|
||||||
RenderPass.swap(RenderPass.GUI);
|
RenderPass.swap(RenderPass.GUI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +30,14 @@ abstract class MixinWorldRenderer {
|
||||||
target = "net.minecraft.client.render.VertexConsumerProvider$Immediate.drawCurrentLayer()V",
|
target = "net.minecraft.client.render.VertexConsumerProvider$Immediate.drawCurrentLayer()V",
|
||||||
ordinal = 0
|
ordinal = 0
|
||||||
))
|
))
|
||||||
private void onRender(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo info) {
|
private void onRender( float tickDelta,
|
||||||
|
long limitTime,
|
||||||
|
boolean renderBlockOutline,
|
||||||
|
Camera camera,
|
||||||
|
GameRenderer gameRenderer,
|
||||||
|
LightmapTextureManager lightmapTextureManager,
|
||||||
|
Matrix4f matrix4f,
|
||||||
|
Matrix4f matrix4f2, CallbackInfo info) {
|
||||||
RenderPass.swap(RenderPass.HUD);
|
RenderPass.swap(RenderPass.HUD);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
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.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import com.minelittlepony.api.pony.Pony;
|
||||||
|
|
||||||
|
@Mixin(PlayerEntity.class)
|
||||||
|
abstract class MixinPlayerEntity {
|
||||||
|
@Inject(method = "getBaseDimensions", at = @At("RETURN"), cancellable = true)
|
||||||
|
private void onGetBaseDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> info) {
|
||||||
|
Pony pony = Pony.getManager().getPony((PlayerEntity)(Object)this);
|
||||||
|
|
||||||
|
if (!pony.race().isHuman()) {
|
||||||
|
float factor = pony.size().eyeHeightFactor();
|
||||||
|
if (factor != 1) {
|
||||||
|
EntityDimensions dimensions = info.getReturnValue();
|
||||||
|
info.setReturnValue(dimensions.withEyeHeight(dimensions.eyeHeight() * factor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.render.block.entity.SkullBlockEntityModel;
|
import net.minecraft.client.render.block.entity.SkullBlockEntityModel;
|
||||||
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
|
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.component.type.ProfileComponent;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
@ -17,7 +18,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
|
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@ -39,18 +39,18 @@ abstract class MixinSkullBlockEntityRenderer implements BlockEntityRenderer<Skul
|
||||||
SkullBlockEntityModel model, RenderLayer layer,
|
SkullBlockEntityModel model, RenderLayer layer,
|
||||||
CallbackInfo info) {
|
CallbackInfo info) {
|
||||||
|
|
||||||
if (!info.isCancelled() && PonySkullRenderer.renderSkull(direction, angle, poweredTicks, stack, renderContext, layer, lightUv)) {
|
if (!info.isCancelled() && PonySkullRenderer.INSTANCE.renderSkull(direction, angle, poweredTicks, stack, renderContext, layer, lightUv)) {
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getRenderLayer("
|
@Inject(method = "getRenderLayer("
|
||||||
+ "Lnet/minecraft/block/SkullBlock$SkullType;"
|
+ "Lnet/minecraft/block/SkullBlock$SkullType;"
|
||||||
+ "Lcom/mojang/authlib/GameProfile;"
|
+ "Lnet/minecraft/component/type/ProfileComponent;"
|
||||||
+ ")Lnet/minecraft/client/render/RenderLayer;", at = @At("HEAD"), cancellable = true)
|
+ ")Lnet/minecraft/client/render/RenderLayer;", at = @At("HEAD"), cancellable = true)
|
||||||
private static void onGetRenderLayer(SkullBlock.SkullType skullType, @Nullable GameProfile profile, CallbackInfoReturnable<RenderLayer> info) {
|
private static void onGetRenderLayer(SkullBlock.SkullType skullType, @Nullable ProfileComponent profile, CallbackInfoReturnable<RenderLayer> info) {
|
||||||
if (!info.isCancelled()) {
|
if (!info.isCancelled()) {
|
||||||
RenderLayer result = PonySkullRenderer.getSkullRenderLayer(skullType, profile);
|
RenderLayer result = PonySkullRenderer.INSTANCE.getSkullRenderLayer(skullType, profile);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
info.setReturnValue(result);
|
info.setReturnValue(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.minelittlepony.client.mixin;
|
package com.minelittlepony.client.mixin;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.*;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArraySet;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.render.VertexConsumers;
|
import net.minecraft.client.render.VertexConsumers;
|
||||||
|
|
||||||
|
@ -25,15 +25,12 @@ abstract class MixinVertextConsumers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "union([" + T + ")" + T, at = @At("HEAD"), cancellable = true)
|
@ModifyVariable(method = "union([" + T + ")" + T, at = @At("HEAD"), argsOnly = true)
|
||||||
private static void onUnion(VertexConsumer[] delegates, CallbackInfoReturnable<VertexConsumer> info) {
|
private static VertexConsumer[] onUnion(VertexConsumer[] delegates) {
|
||||||
int oldLength = delegates.length;
|
Set<VertexConsumer> set = new ObjectArraySet<>(delegates.length);
|
||||||
delegates = Arrays.stream(delegates).distinct().toArray(VertexConsumer[]::new);
|
for (VertexConsumer delegate : delegates) {
|
||||||
|
set.add(delegate);
|
||||||
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.events.PonyModelPrepareCallback;
|
||||||
import com.minelittlepony.api.pony.meta.SizePreset;
|
import com.minelittlepony.api.pony.meta.SizePreset;
|
||||||
import com.minelittlepony.client.transform.PonyTransformation;
|
import com.minelittlepony.client.transform.PonyTransformation;
|
||||||
import com.minelittlepony.client.util.render.RenderList;
|
import com.minelittlepony.mson.util.RenderList;
|
||||||
import com.minelittlepony.util.MathUtil;
|
import com.minelittlepony.util.MathUtil;
|
||||||
import com.minelittlepony.util.MathUtil.Angles;
|
import com.minelittlepony.util.MathUtil.Angles;
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
|
|
||||||
public static final Pivot ORIGIN = new Pivot(0, 0, 0);
|
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_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_SNEAKING = new Pivot(0, 7, -4);
|
||||||
public static final Pivot BODY_RIDING = new Pivot(0, 1, 4);
|
public static final Pivot BODY_RIDING = new Pivot(0, 1, 4);
|
||||||
public static final Pivot FONT_LEGS_SLEEPING = new Pivot(0, 2, 6);
|
public static final Pivot FONT_LEGS_SLEEPING = new Pivot(0, 2, 6);
|
||||||
|
@ -72,27 +71,27 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RenderList forPart(Supplier<SubModel> part) {
|
protected RenderList forPart(Supplier<SubModel> part) {
|
||||||
return (stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
return (stack, vertices, overlay, light, color) -> {
|
||||||
part.get().renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes);
|
part.get().renderPart(stack, vertices, overlay, light, color, attributes);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RenderList forPart(SubModel part) {
|
protected RenderList forPart(SubModel part) {
|
||||||
return (stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
return (stack, vertices, overlay, light, color) -> {
|
||||||
part.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes);
|
part.renderPart(stack, vertices, overlay, light, color, attributes);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color) {
|
||||||
mainRenderList.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
mainRenderList.accept(stack, vertices, overlay, light, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RenderList withStage(BodyPart part, RenderList action) {
|
protected RenderList withStage(BodyPart part, RenderList action) {
|
||||||
return (stack, vertices, overlayUv, lightUv, red, green, blue, alpha) -> {
|
return (stack, vertices, overlay, light, color) -> {
|
||||||
stack.push();
|
stack.push();
|
||||||
transform(part, stack);
|
transform(part, stack);
|
||||||
action.accept(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
action.accept(stack, vertices, overlay, light, color);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -195,8 +194,6 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
rightLeg.pitch = MathUtil.Angles._90_DEG;
|
rightLeg.pitch = MathUtil.Angles._90_DEG;
|
||||||
leftLeg.pitch = MathUtil.Angles._90_DEG;
|
leftLeg.pitch = MathUtil.Angles._90_DEG;
|
||||||
|
|
||||||
HEAD_SLEEPING.set(head);
|
|
||||||
|
|
||||||
FONT_LEGS_SLEEPING.add(rightArm);
|
FONT_LEGS_SLEEPING.add(rightArm);
|
||||||
FONT_LEGS_SLEEPING.add(leftArm);
|
FONT_LEGS_SLEEPING.add(leftArm);
|
||||||
BACK_LEGS_SLEEPING.add(rightLeg);
|
BACK_LEGS_SLEEPING.add(rightLeg);
|
||||||
|
@ -204,14 +201,9 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ponySit() {
|
protected void ponySit() {
|
||||||
adjustBodyComponents(BODY_RIDING_PITCH * (attributes.isRidingInteractive ? 2 : 1), BODY_RIDING);
|
adjustBodyComponents(BODY_RIDING_PITCH, BODY_RIDING);
|
||||||
if (attributes.isRidingInteractive) {
|
|
||||||
neck.setPivot(NECK_X, 0, -4);
|
|
||||||
head.setPivot(0, -2, -5);
|
|
||||||
} else {
|
|
||||||
neck.setPivot(NECK_X, 0, 0);
|
neck.setPivot(NECK_X, 0, 0);
|
||||||
head.setPivot(0, 0, 0);
|
head.setPivot(0, 0, 0);
|
||||||
}
|
|
||||||
|
|
||||||
leftLeg.pivotZ = 14;
|
leftLeg.pivotZ = 14;
|
||||||
leftLeg.pivotY = 17;
|
leftLeg.pivotY = 17;
|
||||||
|
@ -231,26 +223,6 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
leftArm.pitch += body.pitch;
|
leftArm.pitch += body.pitch;
|
||||||
rightArm.roll = MathHelper.PI * 0.06f;
|
rightArm.roll = MathHelper.PI * 0.06f;
|
||||||
rightArm.pitch += body.pitch;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -600,10 +572,6 @@ 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);
|
matrices.translate(-left * 0.1F, 0.45F, 0);
|
||||||
|
|
||||||
if (getAttributes().heldStack.getUseAction() == UseAction.BLOCK && getAttributes().itemUseTime == 0) {
|
if (getAttributes().heldStack.getUseAction() == UseAction.BLOCK && getAttributes().itemUseTime == 0) {
|
||||||
|
@ -623,11 +591,8 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180));
|
stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean crouching = attributes.isCrouching;
|
|
||||||
|
|
||||||
if (attributes.isLyingDown && !attributes.isSleeping) {
|
if (attributes.isLyingDown && !attributes.isSleeping) {
|
||||||
stack.translate(0, 1.35F, 0);
|
stack.translate(0, 1.35F, 0);
|
||||||
attributes.isCrouching = sneaking;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attributes.isHorsey) {
|
if (attributes.isHorsey) {
|
||||||
|
@ -641,7 +606,5 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
}
|
}
|
||||||
|
|
||||||
PonyTransformation.forSize(getSize()).transform(this, part, stack);
|
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.LivingEntity;
|
||||||
import net.minecraft.entity.mob.VexEntity;
|
import net.minecraft.entity.mob.VexEntity;
|
||||||
import net.minecraft.entity.passive.*;
|
import net.minecraft.entity.passive.*;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
import com.minelittlepony.api.model.BodyPart;
|
import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
import com.minelittlepony.api.model.PonyModel;
|
||||||
import com.minelittlepony.api.model.gear.*;
|
import com.minelittlepony.api.model.gear.*;
|
||||||
import com.minelittlepony.api.pony.meta.Race;
|
import com.minelittlepony.api.pony.meta.Race;
|
||||||
import com.minelittlepony.api.pony.meta.Wearable;
|
import com.minelittlepony.api.pony.meta.Wearable;
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.armour.PonyArmourModel;
|
import com.minelittlepony.client.model.armour.PonyArmourModel;
|
||||||
import com.minelittlepony.client.model.entity.*;
|
import com.minelittlepony.client.model.entity.*;
|
||||||
import com.minelittlepony.client.model.entity.race.*;
|
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<?>> 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 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));
|
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<SaddleBags> SADDLEBAGS_BOTH = registerGear("saddlebags", Wearable.SADDLE_BAGS_BOTH, t -> new SaddleBags(t, Wearable.SADDLE_BAGS_BOTH));
|
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_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));
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
static <T extends AbstractGearModel> GearModelKey<T> registerGear(String name, Wearable wearable, MsonModel.Factory<T> constructor) {
|
static <T extends AbstractGearModel> GearModelKey<T> registerGear(String name, Wearable wearable, MsonModel.Factory<T> constructor) {
|
||||||
return (GearModelKey<T>)GEAR_MODELS.computeIfAbsent(wearable, w -> {
|
return (GearModelKey<T>)GEAR_MODELS.computeIfAbsent(wearable, w -> {
|
||||||
return new GearModelKey<T>(Mson.getInstance().registerModel(new Identifier("minelittlepony", "gear/" + name), constructor), constructor);
|
return new GearModelKey<T>(Mson.getInstance().registerModel(MineLittlePony.id("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) {
|
static <T extends Model> ModelKey<T> register(String name, MsonModel.Factory<T> constructor) {
|
||||||
return new ModelKeyImpl<T>(new Identifier("minelittlepony", name), constructor);
|
return new ModelKeyImpl<T>(MineLittlePony.id(name), constructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -3,12 +3,12 @@ package com.minelittlepony.client.model;
|
||||||
import net.minecraft.client.model.Model;
|
import net.minecraft.client.model.Model;
|
||||||
import net.minecraft.client.model.ModelPart;
|
import net.minecraft.client.model.ModelPart;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.Models;
|
import com.minelittlepony.api.model.Models;
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
import com.minelittlepony.api.model.PonyModel;
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.armour.PonyArmourModel;
|
import com.minelittlepony.client.model.armour.PonyArmourModel;
|
||||||
import com.minelittlepony.mson.api.*;
|
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) {
|
PlayerModelKey(String name, BiFunction<ModelPart, Boolean, M> modelFactory, MsonModel.Factory<PonyArmourModel<T>> armorFactory) {
|
||||||
this(
|
this(
|
||||||
new ModelKeyImpl<>(new Identifier("minelittlepony", "races/steve/" + name), tree -> modelFactory.apply(tree, false)),
|
new ModelKeyImpl<>(MineLittlePony.id("races/steve/" + name), tree -> modelFactory.apply(tree, false)),
|
||||||
new ModelKeyImpl<>(new Identifier("minelittlepony", "races/alex/" + name), tree -> modelFactory.apply(tree, true)),
|
new ModelKeyImpl<>(MineLittlePony.id("races/alex/" + name), tree -> modelFactory.apply(tree, true)),
|
||||||
armorFactory
|
armorFactory
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
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;
|
package com.minelittlepony.client.model.armour;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
||||||
import net.minecraft.client.texture.TextureManager;
|
import net.minecraft.component.DataComponentTypes;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.component.type.CustomModelDataComponent;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.item.*;
|
||||||
import net.minecraft.item.ArmorItem;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NbtElement;
|
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.resource.ResourceManager;
|
||||||
|
import net.minecraft.util.Colors;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import com.google.common.base.Strings;
|
import net.minecraft.util.profiler.Profiler;
|
||||||
import com.google.common.cache.Cache;
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
|
||||||
import com.minelittlepony.api.config.PonyConfig;
|
|
||||||
import com.minelittlepony.util.ResourceUtil;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import com.google.common.cache.*;
|
||||||
|
import com.google.common.collect.Interner;
|
||||||
|
import com.google.common.collect.Interners;
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default texture resolver used by Mine Little Pony.
|
* The default texture resolver used by Mine Little Pony.
|
||||||
|
@ -35,100 +35,89 @@ import java.util.concurrent.TimeUnit;
|
||||||
* - the "minecraft" namespace is always replaced with "minelittlepony"
|
* - the "minecraft" namespace is always replaced with "minelittlepony"
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
public class ArmourTextureResolver {
|
public class ArmourTextureResolver implements ArmourTextureLookup, IdentifiableResourceReloadListener {
|
||||||
|
public static final Identifier ID = MineLittlePony.id("armor_textures");
|
||||||
public static final ArmourTextureResolver INSTANCE = new ArmourTextureResolver();
|
public static final ArmourTextureResolver INSTANCE = new ArmourTextureResolver();
|
||||||
|
|
||||||
private final Cache<String, Identifier> cache = CacheBuilder.newBuilder()
|
private static final Interner<ArmorMaterial.Layer> LAYER_INTERNER = Interners.newWeakInterner();
|
||||||
|
|
||||||
|
private final LoadingCache<ArmourParameters, ArmourTexture> layerCache = CacheBuilder.newBuilder()
|
||||||
.expireAfterAccess(30, TimeUnit.SECONDS)
|
.expireAfterAccess(30, TimeUnit.SECONDS)
|
||||||
.<String, Identifier>build();
|
.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();
|
||||||
|
}
|
||||||
|
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
cache.invalidateAll();
|
layerCache.invalidateAll();
|
||||||
|
nonDyedLayers.invalidateAll();
|
||||||
|
dyedLayers.invalidateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Identifier getTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot, ArmourLayer layer, @Nullable String type) {
|
@Override
|
||||||
Identifier material = stack.getItem() instanceof ArmorItem armor
|
public CompletableFuture<Void> reload(Synchronizer synchronizer, ResourceManager manager, Profiler prepareProfiler, Profiler applyProfiler, Executor prepareExecutor, Executor applyExecutor) {
|
||||||
? new Identifier(armor.getMaterial().getName())
|
return CompletableFuture.runAsync(this::invalidate, prepareExecutor).thenCompose(synchronizer::whenPrepared);
|
||||||
: 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);
|
@Override
|
||||||
if (texture != null) {
|
public Identifier getFabricId() {
|
||||||
return texture;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TextureManager.MISSING_IDENTIFIER;
|
@Override
|
||||||
});
|
public ArmourTexture getTexture(ItemStack stack, ArmourLayer layer, ArmorMaterial.Layer armorLayer) {
|
||||||
} catch (ExecutionException ignored) {
|
return layerCache.getUnchecked(new ArmourParameters(layer, armorLayer, getCustom(stack)));
|
||||||
return TextureManager.MISSING_IDENTIFIER;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCustom(ItemStack stack) {
|
@Override
|
||||||
if (stack.hasNbt() && stack.getNbt().contains("CustomModelData", NbtElement.NUMBER_TYPE)) {
|
public List<ArmorMaterial.Layer> getArmorLayers(ItemStack stack, int dyeColor) {
|
||||||
return "custom_" + stack.getNbt().getInt("CustomModelData");
|
if (stack.getItem() instanceof ArmorItem armor) {
|
||||||
}
|
return armor.getMaterial().value().layers();
|
||||||
return "none";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
return (dyeColor == Colors.WHITE ? nonDyedLayers : dyedLayers).getUnchecked(Registries.ITEM.getId(stack.getItem()));
|
||||||
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);
|
|
||||||
|
|
||||||
if (texture != null) {
|
|
||||||
return texture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 record ArmourParameters(ArmourLayer layer, ArmorMaterial.Layer material, int customModelId) {
|
||||||
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 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
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color) {
|
||||||
stack.push();
|
stack.push();
|
||||||
stack.translate(0, -1.15F, 0);
|
stack.translate(0, -1.15F, 0);
|
||||||
super.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
super.render(stack, vertices, overlay, light, color);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ public class GuardianPonyModel extends GuardianEntityModel implements PonyModelM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color) {
|
||||||
mixin().render(matrices, vertices, light, overlay, red, green, blue, alpha);
|
mixin().render(matrices, vertices, light, overlay, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class ParaspriteModel<T extends LivingEntity> extends EntityModel<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color) {
|
||||||
root.render(matrices, vertices, light, overlay, red, green, blue, alpha);
|
root.render(matrices, vertices, light, overlay, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -53,6 +53,13 @@ public class PiglinPonyModel extends ZomponyModel<HostileEntity> {
|
||||||
leftFlap.roll = 0.5235988F + MathHelper.cos(progress) * range;
|
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
|
@Override
|
||||||
protected void rotateLegs(float move, float swing, float ticks, HostileEntity entity) {
|
protected void rotateLegs(float move, float swing, float ticks, HostileEntity entity) {
|
||||||
super.rotateLegs(move, swing, ticks, entity);
|
super.rotateLegs(move, swing, ticks, entity);
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class SaddleModel<T extends LivingEntity> extends EntityModel<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color) {
|
||||||
root.render(matrices, vertices, light, overlay, red, green, blue, alpha);
|
root.render(matrices, vertices, light, overlay, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.util.Arm;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.MobPosingHelper;
|
import com.minelittlepony.api.model.MobPosingHelper;
|
||||||
|
import com.minelittlepony.api.pony.meta.Race;
|
||||||
import com.minelittlepony.client.model.entity.race.AlicornModel;
|
import com.minelittlepony.client.model.entity.race.AlicornModel;
|
||||||
|
|
||||||
public class SkeleponyModel<T extends HostileEntity> extends AlicornModel<T> {
|
public class SkeleponyModel<T extends HostileEntity> extends AlicornModel<T> {
|
||||||
|
@ -58,11 +59,11 @@ public class SkeleponyModel<T extends HostileEntity> extends AlicornModel<T> {
|
||||||
@Override
|
@Override
|
||||||
protected void rotateLegs(float move, float swing, float ticks, T entity) {
|
protected void rotateLegs(float move, float swing, float ticks, T entity) {
|
||||||
super.rotateLegs(move, swing, ticks, entity);
|
super.rotateLegs(move, swing, ticks, entity);
|
||||||
if (rightArmPose != ArmPose.EMPTY) {
|
if (rightArmPose != ArmPose.EMPTY && entity.isAttacking()) {
|
||||||
rotateArmHolding(getArm(Arm.RIGHT), -1, getSwingAmount(), ticks);
|
rotateArmHolding(getArm(Arm.RIGHT), -1, getSwingAmount(), ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftArmPose != ArmPose.EMPTY) {
|
if (leftArmPose != ArmPose.EMPTY && entity.isAttacking()) {
|
||||||
rotateArmHolding(getArm(Arm.LEFT), -1, getSwingAmount(), ticks);
|
rotateArmHolding(getArm(Arm.LEFT), -1, getSwingAmount(), ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,8 +73,8 @@ public class SkeleponyModel<T extends HostileEntity> extends AlicornModel<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMagic() {
|
public Race getRace() {
|
||||||
return isUnicorn;
|
return isUnicorn ? super.getRace() : Race.EARTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,12 +5,13 @@ import com.minelittlepony.api.model.*;
|
||||||
import com.minelittlepony.api.pony.meta.Size;
|
import com.minelittlepony.api.pony.meta.Size;
|
||||||
import com.minelittlepony.api.pony.meta.SizePreset;
|
import com.minelittlepony.api.pony.meta.SizePreset;
|
||||||
import com.minelittlepony.client.model.part.UnicornHorn;
|
import com.minelittlepony.client.model.part.UnicornHorn;
|
||||||
import com.minelittlepony.client.util.render.RenderList;
|
|
||||||
import com.minelittlepony.mson.api.ModelView;
|
import com.minelittlepony.mson.api.ModelView;
|
||||||
|
import com.minelittlepony.mson.util.RenderList;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelPart;
|
import net.minecraft.client.model.ModelPart;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +35,7 @@ public class UnicornModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
||||||
super.init(context);
|
super.init(context);
|
||||||
horn = addPart(context.findByName("horn"));
|
horn = addPart(context.findByName("horn"));
|
||||||
headRenderList.add(RenderList.of().add(head::rotate).add(forPart(horn)).checked(() -> getRace().hasHorn()));
|
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, overlayUv, lightUv, red, green, blue, alpha) -> {
|
this.mainRenderList.add(withStage(BodyPart.HEAD, RenderList.of().add(head::rotate).add((stack, vertices, overlay, light, color) -> {
|
||||||
horn.renderMagic(stack, vertices, getAttributes().metadata.glowColor());
|
horn.renderMagic(stack, vertices, getAttributes().metadata.glowColor());
|
||||||
})).checked(() -> hasMagic() && isCasting()));
|
})).checked(() -> hasMagic() && isCasting()));
|
||||||
}
|
}
|
||||||
|
@ -89,8 +90,11 @@ public class UnicornModel<T extends LivingEntity> extends EarthPonyModel<T> impl
|
||||||
matrices.translate(0.4F - (0.3F * left), -0.675F, -0.3F);
|
matrices.translate(0.4F - (0.3F * left), -0.675F, -0.3F);
|
||||||
|
|
||||||
UseAction action = getAttributes().heldStack.getUseAction();
|
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 ((action == UseAction.SPYGLASS || action == UseAction.BOW) && getAttributes().itemUseTime > 0) {
|
if (shouldAimItem) {
|
||||||
Arm main = getAttributes().mainArm;
|
Arm main = getAttributes().mainArm;
|
||||||
if (getAttributes().activeHand == Hand.OFF_HAND) {
|
if (getAttributes().activeHand == Hand.OFF_HAND) {
|
||||||
main = main.getOpposite();
|
main = main.getOpposite();
|
||||||
|
|
|
@ -10,7 +10,6 @@ import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
import com.minelittlepony.api.model.PonyModel;
|
||||||
import com.minelittlepony.api.model.gear.WearableGear;
|
import com.minelittlepony.api.model.gear.WearableGear;
|
||||||
import com.minelittlepony.api.pony.meta.Wearable;
|
import com.minelittlepony.api.pony.meta.Wearable;
|
||||||
import com.minelittlepony.common.util.Color;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -63,14 +62,12 @@ public class DeerAntlers extends WearableGear {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
public void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, UUID interpolatorId) {
|
||||||
if (tint != 0) {
|
if (tint != 0) {
|
||||||
red = Color.r(tint);
|
color = tint;
|
||||||
green = Color.g(tint);
|
|
||||||
blue = Color.b(tint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
left.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
left.render(stack, vertices, overlay, light, color);
|
||||||
right.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
right.render(stack, vertices, overlay, light, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class SaddleBags extends WearableGear {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumer renderContext, int overlayUv, int lightUv, float red, float green, float blue, float alpha, UUID interpolatorId) {
|
public void render(MatrixStack stack, VertexConsumer renderContext, int overlay, int light, int color, UUID interpolatorId) {
|
||||||
|
|
||||||
stack.push();
|
stack.push();
|
||||||
if (wearable == Wearable.SADDLE_BAGS_BOTH) {
|
if (wearable == Wearable.SADDLE_BAGS_BOTH) {
|
||||||
|
@ -77,11 +77,11 @@ public class SaddleBags extends WearableGear {
|
||||||
stack.translate(0, 0.3F, -0.3F);
|
stack.translate(0, 0.3F, -0.3F);
|
||||||
}
|
}
|
||||||
|
|
||||||
leftBag.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
leftBag.render(stack, renderContext, overlay, light, color);
|
||||||
rightBag.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
rightBag.render(stack, renderContext, overlay, light, color);
|
||||||
|
|
||||||
stack.pop();
|
stack.pop();
|
||||||
strap.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
strap.render(stack, renderContext, overlay, light, color);
|
||||||
|
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class LionTail implements SubModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||||
tail.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
tail.render(stack, vertices, overlay, light, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class PonyEars implements SubModel, MsonModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class PonySnout implements SubModel, MsonModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -86,12 +86,12 @@ public class PonyTail implements SubModel, MsonModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||||
stack.push();
|
stack.push();
|
||||||
tail.rotate(stack);
|
tail.rotate(stack);
|
||||||
|
|
||||||
for (int i = 0; i < segments.size(); i++) {
|
for (int i = 0; i < segments.size(); i++) {
|
||||||
segments.get(i).render(this, stack, vertices, i, overlayUv, lightUv, red, green, blue, alpha, attributes);
|
segments.get(i).render(this, stack, vertices, i, overlay, light, color, attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.pop();
|
stack.pop();
|
||||||
|
@ -104,7 +104,7 @@ public class PonyTail implements SubModel, MsonModel {
|
||||||
this.tree = tree;
|
this.tree = tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
public void render(PonyTail tail, MatrixStack stack, VertexConsumer renderContext, int index, int overlay, int light, int color, ModelAttributes attributes) {
|
||||||
if (index >= tail.tailStop) {
|
if (index >= tail.tailStop) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public class PonyTail implements SubModel, MsonModel {
|
||||||
|
|
||||||
if (attributes.isHorsey || tail.shape == TailShape.STRAIGHT) {
|
if (attributes.isHorsey || tail.shape == TailShape.STRAIGHT) {
|
||||||
tree.yaw = 0;
|
tree.yaw = 0;
|
||||||
tree.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
tree.render(stack, renderContext, overlay, light, color);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ public class PonyTail implements SubModel, MsonModel {
|
||||||
tree.yaw = 0.2F * (index % 2 - 1);
|
tree.yaw = 0.2F * (index % 2 - 1);
|
||||||
tree.pivotZ = 9;
|
tree.pivotZ = 9;
|
||||||
}
|
}
|
||||||
tree.render(stack, renderContext, overlayUv, lightUv, red, green, blue, alpha);
|
tree.render(stack, renderContext, overlay, light, color);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,9 +96,9 @@ public class PonyWings<T extends Model & WingedPonyModel<?>> implements SubModel
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||||
getLeft().render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
getLeft().render(stack, vertices, overlay, light, color);
|
||||||
getRight().render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
getRight().render(stack, vertices, overlay, light, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Wing implements MsonModel {
|
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 overlayUv, int lightUv, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color) {
|
||||||
stack.push();
|
stack.push();
|
||||||
stack.scale(wingScale, wingScale, wingScale);
|
stack.scale(wingScale, wingScale, wingScale);
|
||||||
|
|
||||||
if (pegasus.wingsAreOpen()) {
|
if (pegasus.wingsAreOpen()) {
|
||||||
extended.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
extended.render(stack, vertices, overlay, light, color);
|
||||||
} else {
|
} else {
|
||||||
boolean bags = pegasus.isWearing(Wearable.SADDLE_BAGS_BOTH);
|
boolean bags = pegasus.isWearing(Wearable.SADDLE_BAGS_BOTH);
|
||||||
if (bags) {
|
if (bags) {
|
||||||
stack.push();
|
stack.push();
|
||||||
stack.translate(0, 0, 0.198F);
|
stack.translate(0, 0, 0.198F);
|
||||||
}
|
}
|
||||||
folded.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
folded.render(stack, vertices, overlay, light, color);
|
||||||
if (bags) {
|
if (bags) {
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class SeaponyTail implements SubModel, MsonModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||||
tailBase.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
tailBase.render(stack, vertices, overlay, light, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import net.minecraft.client.util.math.MatrixStack;
|
||||||
import com.minelittlepony.api.model.SubModel;
|
import com.minelittlepony.api.model.SubModel;
|
||||||
import com.minelittlepony.api.model.ModelAttributes;
|
import com.minelittlepony.api.model.ModelAttributes;
|
||||||
import com.minelittlepony.client.render.MagicGlow;
|
import com.minelittlepony.client.render.MagicGlow;
|
||||||
import com.minelittlepony.common.util.Color;
|
|
||||||
|
|
||||||
public class UnicornHorn implements SubModel {
|
public class UnicornHorn implements SubModel {
|
||||||
|
|
||||||
|
@ -25,8 +24,8 @@ public class UnicornHorn implements SubModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlayUv, int lightUv, float red, float green, float blue, float alpha, ModelAttributes attributes) {
|
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color, ModelAttributes attributes) {
|
||||||
horn.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
|
horn.render(stack, vertices, overlay, light, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderMagic(MatrixStack stack, VertexConsumer verts, int tint) {
|
public void renderMagic(MatrixStack stack, VertexConsumer verts, int tint) {
|
||||||
|
@ -34,8 +33,7 @@ public class UnicornHorn implements SubModel {
|
||||||
Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
|
Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
|
||||||
|
|
||||||
VertexConsumer vertices = immediate.getBuffer(MagicGlow.getRenderLayer());
|
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,7 +5,6 @@ import com.minelittlepony.api.events.Channel;
|
||||||
import com.minelittlepony.api.events.PonyDataCallback;
|
import com.minelittlepony.api.events.PonyDataCallback;
|
||||||
import com.minelittlepony.api.model.*;
|
import com.minelittlepony.api.model.*;
|
||||||
import com.minelittlepony.api.pony.Pony;
|
import com.minelittlepony.api.pony.Pony;
|
||||||
import com.minelittlepony.client.MineLittlePony;
|
|
||||||
import com.minelittlepony.client.transform.PonyPosture;
|
import com.minelittlepony.client.transform.PonyPosture;
|
||||||
import com.minelittlepony.mson.api.ModelKey;
|
import com.minelittlepony.mson.api.ModelKey;
|
||||||
import com.minelittlepony.util.MathUtil;
|
import com.minelittlepony.util.MathUtil;
|
||||||
|
@ -19,7 +18,6 @@ import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.render.Frustum;
|
import net.minecraft.client.render.Frustum;
|
||||||
import net.minecraft.client.render.entity.model.EntityModel;
|
import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
|
@ -86,55 +84,27 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float tickDelta) {
|
public void setupTransforms(T entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||||
float s = getScaleFactor();
|
float s = getScaleFactor();
|
||||||
stack.scale(s, s, s);
|
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 (entity instanceof PlayerEntity) {
|
||||||
if (getModels().body().getAttributes().isSitting) {
|
if (getModels().body().getAttributes().isSitting) {
|
||||||
stack.translate(0, 0.125D, 0);
|
stack.translate(0, 0.125D, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rotationYaw = getMountedYaw(entity, rotationYaw, tickDelta);
|
bodyYaw = getMountedYaw(entity, bodyYaw, tickDelta);
|
||||||
transformer.setupTransforms(entity, stack, ageInTicks, rotationYaw, tickDelta);
|
transformer.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
|
||||||
|
|
||||||
PonyPosture.of(getModels().body().getAttributes()).apply(entity, getModels().body(), stack, rotationYaw, tickDelta, 1);
|
PonyPosture.of(getModels().body().getAttributes()).apply(entity, getModels().body(), stack, bodyYaw, tickDelta, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void translateRider(T entity, Pony pony, LivingEntity passenger, Pony passengerPony, MatrixStack stack, float tickDelta) {
|
private float getMountedYaw(T entity, float bodyYaw, float tickDelta) {
|
||||||
if (!passengerPony.race().isHuman()) {
|
if (entity.hasVehicle() && entity.getVehicle() instanceof LivingEntity mount) {
|
||||||
float yaw = MathUtil.interpolateDegress((float)entity.prevY, (float)entity.getY(), tickDelta);
|
return bodyYaw + MathUtil.interpolateDegress(mount.prevBodyYaw, mount.bodyYaw, 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() {
|
public float getScaleFactor() {
|
||||||
|
@ -168,7 +138,7 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Transformer<T extends LivingEntity> {
|
public interface Transformer<T extends LivingEntity> {
|
||||||
void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks);
|
void setupTransforms(T entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface RegistrationHandler {
|
public interface RegistrationHandler {
|
||||||
|
|
|
@ -1,31 +1,36 @@
|
||||||
package com.minelittlepony.client.render;
|
package com.minelittlepony.client.render;
|
||||||
|
|
||||||
import com.minelittlepony.api.config.PonyConfig;
|
import com.minelittlepony.api.config.PonyConfig;
|
||||||
|
import com.minelittlepony.api.model.HornedPonyModel;
|
||||||
import com.minelittlepony.api.pony.Pony;
|
import com.minelittlepony.api.pony.Pony;
|
||||||
import com.minelittlepony.client.util.render.RenderLayerUtil;
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
|
import com.minelittlepony.common.util.render.RenderLayerUtil;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.render.*;
|
import net.minecraft.client.render.*;
|
||||||
import net.minecraft.client.render.item.ItemRenderer;
|
import net.minecraft.client.render.item.ItemRenderer;
|
||||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.component.DataComponentTypes;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.item.CrossbowItem;
|
import net.minecraft.item.*;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.screen.PlayerScreenHandler;
|
import net.minecraft.screen.PlayerScreenHandler;
|
||||||
import net.minecraft.util.UseAction;
|
import net.minecraft.util.UseAction;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.RotationAxis;
|
import net.minecraft.util.math.RotationAxis;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class LevitatingItemRenderer {
|
public class LevitatingItemRenderer {
|
||||||
private VertexConsumerProvider getProvider(Pony pony, VertexConsumerProvider renderContext) {
|
private VertexConsumerProvider getProvider(Pony pony, VertexConsumerProvider provider) {
|
||||||
final int color = pony.metadata().glowColor();
|
final int color = pony.metadata().glowColor();
|
||||||
return layer -> {
|
return layer -> {
|
||||||
if (layer.getVertexFormat() != VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL) {
|
if (layer.getVertexFormat() != VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL) {
|
||||||
return renderContext.getBuffer(layer);
|
return provider.getBuffer(layer);
|
||||||
}
|
}
|
||||||
return renderContext.getBuffer(MagicGlow.getColoured(RenderLayerUtil.getTexture(layer).orElse(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE), color));
|
return provider.getBuffer(MagicGlow.getColoured(RenderLayerUtil.getTexture(layer).orElse(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE), color));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,14 +39,16 @@ 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) {
|
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 (mode.isFirstPerson()
|
if (entity != null && (mode.isFirstPerson()
|
||||||
|| mode == ModelTransformationMode.THIRD_PERSON_LEFT_HAND
|
|| mode == ModelTransformationMode.THIRD_PERSON_LEFT_HAND
|
||||||
|| mode == ModelTransformationMode.THIRD_PERSON_RIGHT_HAND
|
|| mode == ModelTransformationMode.THIRD_PERSON_RIGHT_HAND)
|
||||||
) {
|
) {
|
||||||
Pony.getManager().getPony(entity).ifPresentOrElse(pony -> {
|
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();
|
matrix.push();
|
||||||
|
|
||||||
boolean doMagic = PonyConfig.getInstance().fpsmagic.get() && pony.hasMagic();
|
boolean doMagic = (mode.isFirstPerson() ? PonyConfig.getInstance().fpsmagic : PonyConfig.getInstance().tpsmagic).get() && model.hasMagic();
|
||||||
|
|
||||||
if (doMagic && mode.isFirstPerson()) {
|
if (doMagic && mode.isFirstPerson()) {
|
||||||
setupPerspective(itemRenderer, entity, stack, left, matrix);
|
setupPerspective(itemRenderer, entity, stack, left, matrix);
|
||||||
|
@ -52,22 +59,36 @@ public class LevitatingItemRenderer {
|
||||||
if (doMagic) {
|
if (doMagic) {
|
||||||
VertexConsumerProvider interceptedContext = getProvider(pony, renderContext);
|
VertexConsumerProvider interceptedContext = getProvider(pony, renderContext);
|
||||||
|
|
||||||
matrix.scale(1.1F, 1.1F, 1.1F);
|
if (stack.hasGlint()) {
|
||||||
matrix.translate(0.015F, 0.01F, 0.01F);
|
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);
|
itemRenderer.renderItem(entity, stack, mode, left, matrix, interceptedContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||||
matrix.translate(-0.03F, -0.02F, -0.02F);
|
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);
|
itemRenderer.renderItem(entity, stack, mode, left, matrix, interceptedContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||||
}
|
}
|
||||||
|
|
||||||
matrix.pop();
|
matrix.pop();
|
||||||
}, () -> {
|
return;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
itemRenderer.renderItem(entity, stack, mode, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves held items to look like they're floating in the player's field.
|
* Moves held items to look like they're floating in the player's field.
|
||||||
|
@ -87,7 +108,10 @@ public class LevitatingItemRenderer {
|
||||||
boolean handHeldTool =
|
boolean handHeldTool =
|
||||||
action == UseAction.BOW
|
action == UseAction.BOW
|
||||||
|| action == UseAction.CROSSBOW
|
|| action == UseAction.CROSSBOW
|
||||||
|| action == UseAction.BLOCK;
|
|| action == UseAction.BLOCK
|
||||||
|
|| item.getItem() instanceof ToolItem
|
||||||
|
|| item.getItem() instanceof RangedWeaponItem
|
||||||
|
|| PonyConfig.getInstance().forwardHoldingItems.get().contains(Registries.ITEM.getId(item.getItem()));
|
||||||
|
|
||||||
float distanceChange = handHeldTool ? -0.3F : -0.6F;
|
float distanceChange = handHeldTool ? -0.3F : -0.6F;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ public abstract class MagicGlow extends RenderPhase {
|
||||||
.transparency(LIGHTNING_TRANSPARENCY)
|
.transparency(LIGHTNING_TRANSPARENCY)
|
||||||
.lightmap(DISABLE_LIGHTMAP)
|
.lightmap(DISABLE_LIGHTMAP)
|
||||||
.cull(DISABLE_CULLING)
|
.cull(DISABLE_CULLING)
|
||||||
|
.layering(VIEW_OFFSET_Z_LAYERING)
|
||||||
.build(false));
|
.build(false));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ public abstract class MagicGlow extends RenderPhase {
|
||||||
.transparency(LIGHTNING_TRANSPARENCY)
|
.transparency(LIGHTNING_TRANSPARENCY)
|
||||||
.lightmap(DISABLE_LIGHTMAP)
|
.lightmap(DISABLE_LIGHTMAP)
|
||||||
.cull(DISABLE_CULLING)
|
.cull(DISABLE_CULLING)
|
||||||
|
.layering(VIEW_OFFSET_Z_LAYERING)
|
||||||
.build(true));
|
.build(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,9 @@ package com.minelittlepony.client.render;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
import com.minelittlepony.api.model.PonyModel;
|
||||||
|
import com.minelittlepony.api.model.PreviewModel;
|
||||||
import com.minelittlepony.api.pony.*;
|
import com.minelittlepony.api.pony.*;
|
||||||
import com.minelittlepony.client.mixin.MixinEntityRenderers;
|
import com.minelittlepony.client.mixin.MixinEntityRenderers;
|
||||||
import com.minelittlepony.client.render.entity.*;
|
import com.minelittlepony.client.render.entity.*;
|
||||||
|
@ -18,7 +20,6 @@ import net.minecraft.client.util.SkinTextures;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render manager responsible for replacing and restoring entity renderers when the client settings change.
|
* Render manager responsible for replacing and restoring entity renderers when the client settings change.
|
||||||
|
@ -26,6 +27,17 @@ import net.minecraft.util.Identifier;
|
||||||
public class PonyRenderDispatcher {
|
public class PonyRenderDispatcher {
|
||||||
private LevitatingItemRenderer magicRenderer = new LevitatingItemRenderer();
|
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() {
|
public LevitatingItemRenderer getMagicRenderer() {
|
||||||
return magicRenderer;
|
return magicRenderer;
|
||||||
}
|
}
|
||||||
|
@ -34,42 +46,20 @@ public class PonyRenderDispatcher {
|
||||||
* Registers all new player skin types. (currently only pony and slimpony).
|
* Registers all new player skin types. (currently only pony and slimpony).
|
||||||
*/
|
*/
|
||||||
public void initialise(EntityRenderDispatcher manager, boolean force) {
|
public void initialise(EntityRenderDispatcher manager, boolean force) {
|
||||||
|
PonyForm.REGISTRY.values().forEach(form -> {
|
||||||
for (SkinTextures.Model armShape : SkinTextures.Model.values()) {
|
for (SkinTextures.Model armShape : SkinTextures.Model.values()) {
|
||||||
addPlayerRenderer(armShape);
|
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)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
MobRenderers.REGISTRY.values().forEach(i -> i.apply(this, force));
|
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.
|
* Replaces an entity renderer depending on whether we want ponies or not.
|
||||||
|
@ -80,25 +70,17 @@ public class PonyRenderDispatcher {
|
||||||
* @param <T> The entity type
|
* @param <T> The entity type
|
||||||
*/
|
*/
|
||||||
<T extends Entity, V extends T> void switchRenderer(MobRenderers state, EntityType<V> type, Function<EntityRendererFactory.Context, EntityRenderer<T>> factory) {
|
<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 -> {
|
Mson.getInstance().getEntityRendererRegistry().registerEntityRenderer(type, ctx -> state.get()
|
||||||
if (!state.get()) {
|
? factory.apply(ctx)
|
||||||
return MixinEntityRenderers.getRendererFactories().get(type).create(ctx);
|
: MixinEntityRenderers.getRendererFactories().get(type).create(ctx)
|
||||||
}
|
);
|
||||||
return factory.apply(ctx);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Nullable
|
@Nullable
|
||||||
public <T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> PonyRenderContext<T, M> getPonyRenderer(@Nullable T entity) {
|
public <T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> PonyRenderContext<T, M> getPonyRenderer(@Nullable T entity) {
|
||||||
if (entity == null) {
|
if (entity != null && MinecraftClient.getInstance().getEntityRenderDispatcher().getRenderer(entity) instanceof PonyRenderContext c) {
|
||||||
return null;
|
return c;
|
||||||
}
|
|
||||||
|
|
||||||
EntityRenderer<?> renderer = MinecraftClient.getInstance().getEntityRenderDispatcher().getRenderer(entity);
|
|
||||||
|
|
||||||
if (renderer instanceof PonyRenderContext) {
|
|
||||||
return (PonyRenderContext<T, M>) renderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -7,13 +7,13 @@ import com.minelittlepony.client.model.AbstractPonyModel;
|
||||||
import com.minelittlepony.client.render.MobRenderers;
|
import com.minelittlepony.client.render.MobRenderers;
|
||||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer.ISkull;
|
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer.ISkull;
|
||||||
import com.minelittlepony.mson.api.ModelKey;
|
import com.minelittlepony.mson.api.ModelKey;
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelPart;
|
import net.minecraft.client.model.ModelPart;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.component.type.ProfileComponent;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.RotationAxis;
|
import net.minecraft.util.math.RotationAxis;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class MobSkull implements ISkull {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier getSkinResource(@Nullable GameProfile profile) {
|
public Identifier getSkinResource(@Nullable ProfileComponent profile) {
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class MobSkull implements ISkull {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumer vertices, int lightUv, int overlayUv, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack stack, VertexConsumer vertices, int light, int overlay, int color) {
|
||||||
ponyHead.get().headRenderList.accept(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
ponyHead.get().headRenderList.accept(stack, vertices, light, overlay, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.minelittlepony.api.pony.SkinsProxy;
|
||||||
import com.minelittlepony.api.pony.meta.Race;
|
import com.minelittlepony.api.pony.meta.Race;
|
||||||
import com.minelittlepony.client.model.*;
|
import com.minelittlepony.client.model.*;
|
||||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer.ISkull;
|
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer.ISkull;
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -15,6 +14,7 @@ import java.util.Map;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.util.DefaultSkinHelper;
|
import net.minecraft.client.util.DefaultSkinHelper;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.component.type.ProfileComponent;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.RotationAxis;
|
import net.minecraft.util.math.RotationAxis;
|
||||||
|
|
||||||
|
@ -35,17 +35,17 @@ public class PlayerPonySkull implements ISkull {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier getSkinResource(@Nullable GameProfile profile) {
|
public Identifier getSkinResource(@Nullable ProfileComponent profile) {
|
||||||
renderingEars = profile != null && "deadmau5".equals(profile.getName());
|
renderingEars = profile != null && "deadmau5".equals(profile.gameProfile().getName());
|
||||||
|
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
Identifier skin = SkinsProxy.instance.getSkinTexture(profile);
|
Identifier skin = SkinsProxy.instance.getSkinTexture(profile.gameProfile());
|
||||||
|
|
||||||
if (skin != null) {
|
if (skin != null) {
|
||||||
return skin;
|
return skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefaultSkinHelper.getSkinTextures(profile).texture();
|
return DefaultSkinHelper.getSkinTextures(profile.gameProfile()).texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefaultSkinHelper.getTexture();
|
return DefaultSkinHelper.getTexture();
|
||||||
|
@ -80,18 +80,18 @@ public class PlayerPonySkull implements ISkull {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumer vertices, int lightUv, int overlayUv, float red, float green, float blue, float alpha) {
|
public void render(MatrixStack stack, VertexConsumer vertices, int light, int overlay, int color) {
|
||||||
stack.push();
|
stack.push();
|
||||||
ponyHead.headRenderList.accept(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
ponyHead.headRenderList.accept(stack, vertices, light, overlay, color);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
stack.push();
|
stack.push();
|
||||||
ponyHead.helmetRenderList.accept(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
ponyHead.helmetRenderList.accept(stack, vertices, light, overlay, color);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
if (renderingEars) {
|
if (renderingEars) {
|
||||||
stack.push();
|
stack.push();
|
||||||
stack.scale(1.3333334f, 1.3333334f, 1.3333334f);
|
stack.scale(1.3333334f, 1.3333334f, 1.3333334f);
|
||||||
stack.translate(0, 0.05F, 0);
|
stack.translate(0, 0.05F, 0);
|
||||||
deadMau5.render(stack, vertices, lightUv, overlayUv, red, green, blue, alpha);
|
deadMau5.render(stack, vertices, light, overlay, color);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,36 @@
|
||||||
package com.minelittlepony.client.render.blockentity.skull;
|
package com.minelittlepony.client.render.blockentity.skull;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.minelittlepony.api.config.PonyConfig;
|
import com.minelittlepony.api.config.PonyConfig;
|
||||||
import com.minelittlepony.api.pony.Pony;
|
import com.minelittlepony.api.pony.Pony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
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.MobRenderers;
|
||||||
import com.minelittlepony.client.render.entity.SkeleponyRenderer;
|
import com.minelittlepony.client.render.entity.*;
|
||||||
import com.minelittlepony.client.render.entity.ZomponyRenderer;
|
import com.minelittlepony.common.util.Color;
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
|
|
||||||
|
import net.minecraft.block.AbstractSkullBlock;
|
||||||
import net.minecraft.block.SkullBlock;
|
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.OverlayTexture;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
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.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.Identifier;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@ -25,29 +38,44 @@ import org.jetbrains.annotations.Nullable;
|
||||||
* PonySkullRenderer! It renders ponies as skulls, or something...
|
* PonySkullRenderer! It renders ponies as skulls, or something...
|
||||||
*/
|
*/
|
||||||
public class PonySkullRenderer {
|
public class PonySkullRenderer {
|
||||||
|
public static final PonySkullRenderer INSTANCE = new PonySkullRenderer();
|
||||||
|
|
||||||
private static final Map<SkullBlock.SkullType, ISkull> SKULLS = Maps.newHashMap();
|
private Map<SkullBlock.SkullType, ISkull> skulls = Map.of();
|
||||||
|
private Map<SkullBlock.SkullType, SkullBlockEntityModel> headModels = Map.of();
|
||||||
|
|
||||||
private static ISkull selectedSkull;
|
private ISkull selectedSkull;
|
||||||
private static Identifier selectedSkin;
|
private Identifier selectedSkin;
|
||||||
|
|
||||||
public static void reload() {
|
boolean isBeingWorn;
|
||||||
SKULLS.clear();
|
boolean isPony;
|
||||||
loadSkulls(SKULLS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadSkulls(Map<SkullBlock.SkullType, ISkull> skullMap) {
|
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.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.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.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());
|
skullMap.put(SkullBlock.Type.PLAYER, new PlayerPonySkull());
|
||||||
|
});
|
||||||
|
headModels = SkullBlockEntityRenderer.getModels(MinecraftClient.getInstance().getEntityModelLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RenderLayer getSkullRenderLayer(SkullBlock.SkullType skullType, @Nullable GameProfile profile) {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RenderLayer getSkullRenderLayer(SkullBlock.SkullType skullType, @Nullable ProfileComponent profile) {
|
||||||
selectedSkull = null;
|
selectedSkull = null;
|
||||||
selectedSkin = null;
|
selectedSkin = null;
|
||||||
|
|
||||||
ISkull skull = SKULLS.get(skullType);
|
ISkull skull = skulls.get(skullType);
|
||||||
|
|
||||||
if (skull == null || !skull.canRender(PonyConfig.getInstance())) {
|
if (skull == null || !skull.canRender(PonyConfig.getInstance())) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -58,16 +86,12 @@ public class PonySkullRenderer {
|
||||||
return RenderLayer.getEntityTranslucent(selectedSkin);
|
return RenderLayer.getEntityTranslucent(selectedSkin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean renderSkull(@Nullable Direction direction,
|
public boolean renderSkull(@Nullable Direction direction,
|
||||||
float yaw, float animationProgress,
|
float yaw, float animationProgress,
|
||||||
MatrixStack stack, VertexConsumerProvider renderContext, RenderLayer layer,
|
MatrixStack stack, VertexConsumerProvider renderContext, RenderLayer layer,
|
||||||
int lightUv) {
|
int light) {
|
||||||
|
|
||||||
if (selectedSkull == null || !selectedSkull.canRender(PonyConfig.getInstance())) {
|
if (selectedSkull == null || !selectedSkull.canRender(PonyConfig.getInstance()) || !selectedSkull.bindPony(Pony.getManager().getPony(selectedSkin))) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selectedSkull.bindPony(Pony.getManager().getPony(selectedSkin))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +100,6 @@ public class PonySkullRenderer {
|
||||||
if (direction == null) {
|
if (direction == null) {
|
||||||
stack.translate(0.5, 0, 0.5);
|
stack.translate(0.5, 0, 0.5);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
final float offset = 0.25F;
|
final float offset = 0.25F;
|
||||||
stack.translate(
|
stack.translate(
|
||||||
0.5F - direction.getOffsetX() * offset,
|
0.5F - direction.getOffsetX() * offset,
|
||||||
|
@ -89,7 +112,7 @@ public class PonySkullRenderer {
|
||||||
VertexConsumer vertices = renderContext.getBuffer(layer);
|
VertexConsumer vertices = renderContext.getBuffer(layer);
|
||||||
|
|
||||||
selectedSkull.setAngles(yaw, animationProgress);
|
selectedSkull.setAngles(yaw, animationProgress);
|
||||||
selectedSkull.render(stack, vertices, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
selectedSkull.render(stack, vertices, light, OverlayTexture.DEFAULT_UV, Color.argbToHex(ArmourRendererPlugin.INSTANCE.get().getArmourAlpha(EquipmentSlot.HEAD, ArmourLayer.OUTER), 1, 1, 1));
|
||||||
|
|
||||||
stack.pop();
|
stack.pop();
|
||||||
|
|
||||||
|
@ -102,15 +125,18 @@ public class PonySkullRenderer {
|
||||||
* Implement this interface if you want to extend our behaviour, modders.
|
* Implement this interface if you want to extend our behaviour, modders.
|
||||||
*/
|
*/
|
||||||
public interface ISkull {
|
public interface ISkull {
|
||||||
|
|
||||||
void setAngles(float angle, float poweredTicks);
|
void setAngles(float angle, float poweredTicks);
|
||||||
|
|
||||||
void render(MatrixStack stack, VertexConsumer vertices, int lightUv, int overlayUv, float red, float green, float blue, float alpha);
|
void render(MatrixStack stack, VertexConsumer vertices, int light, int overlay, int color);
|
||||||
|
|
||||||
boolean canRender(PonyConfig config);
|
boolean canRender(PonyConfig config);
|
||||||
|
|
||||||
Identifier getSkinResource(@Nullable GameProfile profile);
|
Identifier getSkinResource(@Nullable ProfileComponent profile);
|
||||||
|
|
||||||
boolean bindPony(Pony pony);
|
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) {
|
protected void addFeatures(EntityRendererFactory.Context context) {
|
||||||
addFeature(new ArmourFeature<>(this, context.getModelManager()));
|
addFeature(new ArmourFeature<>(this, context.getModelManager()));
|
||||||
addFeature(createHeldItemFeature(context));
|
addFeature(createHeldItemFeature(context));
|
||||||
addFeature(new SkullFeature<>(this, context.getModelLoader()));
|
addFeature(new SkullFeature<>(this, context.getModelLoader(), context.getItemRenderer()));
|
||||||
addFeature(new ElytraFeature<>(this));
|
addFeature(new ElytraFeature<>(this));
|
||||||
addFeature(new GearFeature<>(this));
|
addFeature(new GearFeature<>(this));
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,8 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
protected void setupTransforms(T entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||||
manager.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
manager.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,18 +94,20 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
|
||||||
if (!entity.hasVehicle()) {
|
if (!entity.hasVehicle()) {
|
||||||
stack.translate(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
|
stack.translate(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
|
||||||
} else {
|
} else {
|
||||||
stack.translate(0, entity.getRidingOffset(entity.getVehicle()), 0);
|
if (manager.getModels().body().getAttributes().isSitting && entity.hasVehicle()) {
|
||||||
|
stack.translate(0, 0.25F, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.scale(scale, scale, scale);
|
stack.scale(scale, scale, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderLabelIfPresent(T entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) {
|
protected void renderLabelIfPresent(T entity, Text name, MatrixStack matrices, VertexConsumerProvider vertices, int light, float tickDelta) {
|
||||||
stack.push();
|
matrices.push();
|
||||||
stack.translate(0, manager.getNamePlateYOffset(entity), 0);
|
matrices.translate(0, manager.getNamePlateYOffset(entity), 0);
|
||||||
super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance);
|
super.renderLabelIfPresent(entity, name, matrices, vertices, light, tickDelta);
|
||||||
stack.pop();
|
matrices.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,7 +16,7 @@ import com.minelittlepony.client.model.entity.BreezieModel;
|
||||||
* AKA a breezie :D
|
* AKA a breezie :D
|
||||||
*/
|
*/
|
||||||
public class AllayRenderer extends MobEntityRenderer<AllayEntity, BreezieModel<AllayEntity>> {
|
public class AllayRenderer extends MobEntityRenderer<AllayEntity, BreezieModel<AllayEntity>> {
|
||||||
public static final Identifier BREEZIE_PONIES = new Identifier("minelittlepony", "textures/entity/allay/pony");
|
public static final Identifier BREEZIE_PONIES = MineLittlePony.id("textures/entity/allay/pony");
|
||||||
|
|
||||||
public AllayRenderer(EntityRendererFactory.Context context) {
|
public AllayRenderer(EntityRendererFactory.Context context) {
|
||||||
super(context, ModelType.ALLAY.createModel(), 0.4f);
|
super(context, ModelType.ALLAY.createModel(), 0.4f);
|
||||||
|
|
|
@ -5,16 +5,19 @@ import com.minelittlepony.api.pony.*;
|
||||||
import com.minelittlepony.api.pony.meta.Race;
|
import com.minelittlepony.api.pony.meta.Race;
|
||||||
import com.minelittlepony.util.MathUtil;
|
import com.minelittlepony.util.MathUtil;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class AquaticPlayerPonyRenderer extends FormChangingPlayerPonyRenderer {
|
public class AquaticPlayerPonyRenderer extends FormChangingPlayerPonyRenderer {
|
||||||
|
|
||||||
public AquaticPlayerPonyRenderer(EntityRendererFactory.Context context, boolean slim) {
|
public AquaticPlayerPonyRenderer(EntityRendererFactory.Context context, boolean slim, Identifier alternateFormSkinId, Predicate<AbstractClientPlayerEntity> formModifierPredicate) {
|
||||||
super(context, slim, DefaultPonySkinHelper.SEAPONY_SKIN_TYPE_ID, PonyPosture::isSeaponyModifier);
|
super(context, slim, alternateFormSkinId, formModifierPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,18 +35,18 @@ public class AquaticPlayerPonyRenderer extends FormChangingPlayerPonyRenderer {
|
||||||
@Override
|
@Override
|
||||||
protected Race getPlayerRace(AbstractClientPlayerEntity entity, Pony pony) {
|
protected Race getPlayerRace(AbstractClientPlayerEntity entity, Pony pony) {
|
||||||
Race race = super.getPlayerRace(entity, pony);
|
Race race = super.getPlayerRace(entity, pony);
|
||||||
return PonyPosture.isSeaponyModifier(entity) ? Race.SEAPONY : race == Race.SEAPONY ? Race.UNICORN : race;
|
return transformed ? Race.SEAPONY : race == Race.SEAPONY ? Race.UNICORN : race;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupTransforms(AbstractClientPlayerEntity player, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
protected void setupTransforms(AbstractClientPlayerEntity player, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||||
if (PonyPosture.isSeaponyModifier(player)) {
|
if (transformed) {
|
||||||
stack.translate(0, 0.6, 0);
|
matrices.translate(0, 0.6 * scale, 0);
|
||||||
if (player.isInSneakingPose()) {
|
if (player.isInSneakingPose()) {
|
||||||
stack.translate(0, 0.125, 0);
|
matrices.translate(0, 0.125 * scale, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.setupTransforms(player, stack, ageInTicks, rotationYaw, partialTicks);
|
super.setupTransforms(player, matrices, animationProgress, bodyYaw, tickDelta, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.minelittlepony.client.render.entity;
|
package com.minelittlepony.client.render.entity;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.EnderStallionModel;
|
import com.minelittlepony.client.model.entity.EnderStallionModel;
|
||||||
import com.minelittlepony.client.render.entity.feature.GlowingEyesFeature;
|
import com.minelittlepony.client.render.entity.feature.GlowingEyesFeature;
|
||||||
|
@ -19,9 +20,8 @@ import net.minecraft.util.Identifier;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class EnderStallionRenderer extends PonyRenderer<EndermanEntity, EnderStallionModel> implements IGlowingRenderer {
|
public class EnderStallionRenderer extends PonyRenderer<EndermanEntity, EnderStallionModel> implements IGlowingRenderer {
|
||||||
|
public static final Identifier ENDERMAN = MineLittlePony.id("textures/entity/enderman/enderman_pony.png");
|
||||||
public static final Identifier ENDERMAN = new Identifier("minelittlepony", "textures/entity/enderman/enderman_pony.png");
|
private static final Identifier EYES = MineLittlePony.id("textures/entity/enderman/enderman_pony_eyes.png");
|
||||||
private static final Identifier EYES = new Identifier("minelittlepony", "textures/entity/enderman/enderman_pony_eyes.png");
|
|
||||||
|
|
||||||
private final Random rnd = new Random();
|
private final Random rnd = new Random();
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
package com.minelittlepony.client.render.entity;
|
package com.minelittlepony.client.render.entity;
|
||||||
|
|
||||||
|
import com.minelittlepony.api.model.ModelAttributes;
|
||||||
import com.minelittlepony.api.pony.*;
|
import com.minelittlepony.api.pony.*;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
|
||||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
import net.minecraft.util.Arm;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class FormChangingPlayerPonyRenderer extends PlayerPonyRenderer {
|
public class FormChangingPlayerPonyRenderer extends PlayerPonyRenderer {
|
||||||
|
@ -33,14 +31,8 @@ public class FormChangingPlayerPonyRenderer extends PlayerPonyRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(AbstractClientPlayerEntity player, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int light) {
|
protected final void preRender(AbstractClientPlayerEntity player, ModelAttributes.Mode mode) {
|
||||||
super.render(player, entityYaw, tickDelta, stack, renderContext, light);
|
super.preRender(player, mode);
|
||||||
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);
|
updateForm(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import com.minelittlepony.client.model.*;
|
||||||
import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
|
import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
|
||||||
import com.minelittlepony.client.render.PonyRenderContext;
|
import com.minelittlepony.client.render.PonyRenderContext;
|
||||||
import com.minelittlepony.client.render.entity.feature.*;
|
import com.minelittlepony.client.render.entity.feature.*;
|
||||||
import com.minelittlepony.client.util.render.RenderLayerUtil;
|
import com.minelittlepony.common.util.render.RenderLayerUtil;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -56,7 +56,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
||||||
addLayer(new HeldItemFeature(this, context.getHeldItemRenderer()));
|
addLayer(new HeldItemFeature(this, context.getHeldItemRenderer()));
|
||||||
addLayer(new DJPon3Feature<>(this));
|
addLayer(new DJPon3Feature<>(this));
|
||||||
addLayer(new CapeFeature<>(this));
|
addLayer(new CapeFeature<>(this));
|
||||||
addLayer(new SkullFeature<>(this, context.getModelLoader()));
|
addLayer(new SkullFeature<>(this, context.getModelLoader(), context.getItemRenderer()));
|
||||||
addLayer(new ElytraFeature<>(this));
|
addLayer(new ElytraFeature<>(this));
|
||||||
addLayer(new PassengerFeature<>(this, context));
|
addLayer(new PassengerFeature<>(this, context));
|
||||||
addLayer(new GearFeature<>(this));
|
addLayer(new GearFeature<>(this));
|
||||||
|
@ -70,14 +70,19 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
||||||
@Override
|
@Override
|
||||||
protected void scale(AbstractClientPlayerEntity entity, MatrixStack stack, float tickDelta) {
|
protected void scale(AbstractClientPlayerEntity entity, MatrixStack stack, float tickDelta) {
|
||||||
if (manager.getModels().body().getAttributes().isSitting && entity.hasVehicle()) {
|
if (manager.getModels().body().getAttributes().isSitting && entity.hasVehicle()) {
|
||||||
stack.translate(0, entity.getRidingOffset(entity.getVehicle()), 0);
|
stack.translate(0, -0.25F * manager.getScaleFactor(), 0);
|
||||||
}
|
}
|
||||||
|
super.scale(entity, stack, tickDelta);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void preRender(AbstractClientPlayerEntity player, ModelAttributes.Mode mode) {
|
||||||
|
manager.preRender(player, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(AbstractClientPlayerEntity entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
|
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
|
// EntityModelFeatures: We have to force it to use our models otherwise EMF overrides it and breaks pony rendering
|
||||||
manager.preRender(entity, ModelAttributes.Mode.THIRD_PERSON);
|
preRender(entity, ModelAttributes.Mode.THIRD_PERSON);
|
||||||
shadowRadius = manager.getShadowSize();
|
shadowRadius = manager.getShadowSize();
|
||||||
super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv);
|
super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv);
|
||||||
DebugBoundingBoxRenderer.render(getEntityPony(entity), this, entity, stack, renderContext, tickDelta);
|
DebugBoundingBoxRenderer.render(getEntityPony(entity), this, entity, stack, renderContext, tickDelta);
|
||||||
|
@ -102,8 +107,8 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupTransforms(AbstractClientPlayerEntity entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
protected void setupTransforms(AbstractClientPlayerEntity entity, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||||
manager.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
manager.setupTransforms(entity, matrices, animationProgress, bodyYaw, tickDelta, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,7 +121,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderLabelIfPresent(AbstractClientPlayerEntity entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) {
|
protected void renderLabelIfPresent(AbstractClientPlayerEntity entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int light, float tickDelta) {
|
||||||
stack.push();
|
stack.push();
|
||||||
|
|
||||||
if (entity.isSleeping()) {
|
if (entity.isSleeping()) {
|
||||||
|
@ -127,7 +132,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stack.translate(0, manager.getNamePlateYOffset(entity), 0);
|
stack.translate(0, manager.getNamePlateYOffset(entity), 0);
|
||||||
super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance);
|
super.renderLabelIfPresent(entity, name, stack, renderContext, light, tickDelta);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +147,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderArm(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, Arm side) {
|
protected void renderArm(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, Arm side) {
|
||||||
manager.preRender(player, ModelAttributes.Mode.FIRST_PERSON);
|
preRender(player, ModelAttributes.Mode.FIRST_PERSON);
|
||||||
|
|
||||||
stack.push();
|
stack.push();
|
||||||
float reflect = side == Arm.LEFT ? 1 : -1;
|
float reflect = side == Arm.LEFT ? 1 : -1;
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class PonyPigRenderer extends PigEntityRenderer {
|
||||||
model.animateModel(entity, limbAngle, limbDistance, tickDelta);
|
model.animateModel(entity, limbAngle, limbDistance, tickDelta);
|
||||||
model.setAngles(entity, limbAngle, limbDistance, animationProgress, headYaw, headPitch);
|
model.setAngles(entity, limbAngle, limbDistance, animationProgress, headYaw, headPitch);
|
||||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCull(Wearable.CROWN.getDefaultTexture()));
|
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCull(Wearable.CROWN.getDefaultTexture()));
|
||||||
model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,15 @@ import net.minecraft.entity.mob.AbstractPiglinEntity;
|
||||||
import net.minecraft.entity.mob.HostileEntity;
|
import net.minecraft.entity.mob.HostileEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.PiglinPonyModel;
|
import com.minelittlepony.client.model.entity.PiglinPonyModel;
|
||||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||||
|
|
||||||
public class PonyPiglinRenderer extends PonyRenderer<HostileEntity, PiglinPonyModel> {
|
public class PonyPiglinRenderer extends PonyRenderer<HostileEntity, PiglinPonyModel> {
|
||||||
private static final Identifier PIGLIN = new Identifier("minelittlepony", "textures/entity/piglin/piglin_pony.png");
|
public static final Identifier PIGLIN = MineLittlePony.id("textures/entity/piglin/piglin_pony.png");
|
||||||
private static final Identifier PIGLIN_BRUTE = new Identifier("minelittlepony", "textures/entity/piglin/piglin_brute_pony.png");
|
public static final Identifier PIGLIN_BRUTE = MineLittlePony.id("textures/entity/piglin/piglin_brute_pony.png");
|
||||||
private static final Identifier ZOMBIFIED_PIGLIN = new Identifier("minelittlepony", "textures/entity/piglin/zombified_piglin_pony.png");
|
public static final Identifier ZOMBIFIED_PIGLIN = MineLittlePony.id("textures/entity/piglin/zombified_piglin_pony.png");
|
||||||
|
|
||||||
public PonyPiglinRenderer(EntityRendererFactory.Context context, Identifier texture, float scale) {
|
public PonyPiglinRenderer(EntityRendererFactory.Context context, Identifier texture, float scale) {
|
||||||
super(context, ModelType.PIGLIN, TextureSupplier.of(texture), scale);
|
super(context, ModelType.PIGLIN, TextureSupplier.of(texture), scale);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import net.minecraft.client.render.entity.feature.*;
|
||||||
import net.minecraft.client.render.entity.model.ArmorStandArmorEntityModel;
|
import net.minecraft.client.render.entity.model.ArmorStandArmorEntityModel;
|
||||||
import net.minecraft.client.render.entity.model.EntityModelLayers;
|
import net.minecraft.client.render.entity.model.EntityModelLayers;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.entity.decoration.ArmorStandEntity;
|
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
@ -15,7 +14,6 @@ import com.minelittlepony.api.model.Models;
|
||||||
import com.minelittlepony.api.pony.PonyData;
|
import com.minelittlepony.api.pony.PonyData;
|
||||||
import com.minelittlepony.api.pony.meta.Race;
|
import com.minelittlepony.api.pony.meta.Race;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
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.PonyArmourStandModel;
|
||||||
import com.minelittlepony.client.model.entity.race.EarthPonyModel;
|
import com.minelittlepony.client.model.entity.race.EarthPonyModel;
|
||||||
import com.minelittlepony.client.render.entity.feature.ArmourFeature;
|
import com.minelittlepony.client.render.entity.feature.ArmourFeature;
|
||||||
|
@ -52,10 +50,10 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupTransforms(ArmorStandEntity entity, MatrixStack stack, float f, float g, float h) {
|
protected void setupTransforms(ArmorStandEntity entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||||
super.setupTransforms(entity, stack, f, g, h);
|
super.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
|
||||||
if (isPonita(entity)) {
|
if (isPonita(entity)) {
|
||||||
stack.translate(0, 0, -4/16F);
|
stack.translate(0, 0, scale * -4/16F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,13 +80,7 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
||||||
pony.body().animateModel(entity, limbDistance, limbAngle, tickDelta);
|
pony.body().animateModel(entity, limbDistance, limbAngle, tickDelta);
|
||||||
pony.body().setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
pony.body().setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
||||||
PonyStandRenderer.this.pony.applyAnglesTo(pony.body());
|
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 {
|
} else {
|
||||||
super.render(stack, renderContext, lightUv, entity, limbDistance, limbAngle, tickDelta, age, headYaw, headPitch);
|
super.render(stack, renderContext, lightUv, entity, limbDistance, limbAngle, tickDelta, age, headYaw, headPitch);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.client.render.entity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.ModelAttributes;
|
import com.minelittlepony.api.model.ModelAttributes;
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.mixin.IResizeable;
|
import com.minelittlepony.client.mixin.IResizeable;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.GuardianPonyModel;
|
import com.minelittlepony.client.model.entity.GuardianPonyModel;
|
||||||
|
@ -17,10 +18,10 @@ import net.minecraft.entity.mob.GuardianEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class SeaponyRenderer extends GuardianEntityRenderer {
|
public class SeaponyRenderer extends GuardianEntityRenderer {
|
||||||
public static final Identifier SEAPONY = new Identifier("minelittlepony", "textures/entity/guardian/blueball.png");
|
public static final Identifier SEAPONY = MineLittlePony.id("textures/entity/guardian/blueball.png");
|
||||||
private static final Identifier SEAPONY_TEXTURES = new Identifier("minelittlepony", "textures/entity/guardian");
|
private static final Identifier SEAPONY_TEXTURES = MineLittlePony.id("textures/entity/guardian");
|
||||||
public static final Identifier ELDER_SEAPONY = new Identifier("minelittlepony", "textures/entity/elder_guardian/blueball.png");
|
public static final Identifier ELDER_SEAPONY = MineLittlePony.id("textures/entity/elder_guardian/blueball.png");
|
||||||
private static final Identifier ELDER_SEAPONY_TEXTURES = new Identifier("minelittlepony", "textures/entity/elder_guardian");
|
private static final Identifier ELDER_SEAPONY_TEXTURES = MineLittlePony.id("textures/entity/elder_guardian");
|
||||||
|
|
||||||
private final AbstractPonyRenderer<GuardianEntity, GuardianPonyModel> ponyRenderer;
|
private final AbstractPonyRenderer<GuardianEntity, GuardianPonyModel> ponyRenderer;
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ public class SeaponyRenderer extends GuardianEntityRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupTransforms(GuardianEntity entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
protected void setupTransforms(GuardianEntity entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||||
ponyRenderer.manager.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
ponyRenderer.manager.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.minelittlepony.client.render.entity;
|
package com.minelittlepony.client.render.entity;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.SkeleponyModel;
|
import com.minelittlepony.client.model.entity.SkeleponyModel;
|
||||||
import com.minelittlepony.client.render.entity.feature.StrayClothingFeature;
|
import com.minelittlepony.client.render.entity.feature.StrayClothingFeature;
|
||||||
|
@ -10,10 +11,9 @@ import net.minecraft.entity.mob.*;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class SkeleponyRenderer<Skeleton extends AbstractSkeletonEntity> extends PonyRenderer<Skeleton, SkeleponyModel<Skeleton>> {
|
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 SKELETON = new Identifier("minelittlepony", "textures/entity/skeleton/skeleton_pony.png");
|
public static final Identifier WITHER = MineLittlePony.id("textures/entity/skeleton/skeleton_wither_pony.png");
|
||||||
public static final Identifier WITHER = new Identifier("minelittlepony", "textures/entity/skeleton/skeleton_wither_pony.png");
|
public static final Identifier STRAY = MineLittlePony.id("textures/entity/skeleton/stray_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) {
|
public SkeleponyRenderer(EntityRendererFactory.Context context, Identifier texture, float scale) {
|
||||||
super(context, ModelType.SKELETON, TextureSupplier.of(texture), scale);
|
super(context, ModelType.SKELETON, TextureSupplier.of(texture), scale);
|
||||||
|
|
|
@ -13,10 +13,10 @@ import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
|
|
||||||
public class StriderRenderer extends MobEntityRenderer<StriderEntity, EntityModel<StriderEntity>> {
|
public class StriderRenderer extends MobEntityRenderer<StriderEntity, EntityModel<StriderEntity>> {
|
||||||
public static final Identifier DRAGON_PONIES = new Identifier("minelittlepony", "textures/entity/strider/pony");
|
public static final Identifier DRAGON_PONIES = MineLittlePony.id("textures/entity/strider/pony");
|
||||||
public static final Identifier COLD_DRAGON_PONIES = new Identifier("minelittlepony", "textures/entity/strider/cold_pony");
|
public static final Identifier COLD_DRAGON_PONIES = MineLittlePony.id("textures/entity/strider/cold_pony");
|
||||||
|
|
||||||
private static final Identifier SADDLE = new Identifier("minelittlepony", "textures/entity/strider/strider_saddle_pony.png");
|
private static final Identifier SADDLE = MineLittlePony.id("textures/entity/strider/strider_saddle_pony.png");
|
||||||
|
|
||||||
public StriderRenderer(EntityRendererFactory.Context context) {
|
public StriderRenderer(EntityRendererFactory.Context context) {
|
||||||
super(context, ModelType.STRIDER.createModel(), 0.5F);
|
super(context, ModelType.STRIDER.createModel(), 0.5F);
|
||||||
|
|
|
@ -11,7 +11,7 @@ import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.ParaspriteModel;
|
import com.minelittlepony.client.model.entity.ParaspriteModel;
|
||||||
|
|
||||||
public class VexRenderer extends MobEntityRenderer<VexEntity, ParaspriteModel<VexEntity>> {
|
public class VexRenderer extends MobEntityRenderer<VexEntity, ParaspriteModel<VexEntity>> {
|
||||||
public static final Identifier PARASPRITE_PONIES = new Identifier("minelittlepony", "textures/entity/illager/vex_pony");
|
public static final Identifier PARASPRITE_PONIES = MineLittlePony.id("textures/entity/illager/vex_pony");
|
||||||
|
|
||||||
public VexRenderer(EntityRendererFactory.Context context) {
|
public VexRenderer(EntityRendererFactory.Context context) {
|
||||||
super(context, ModelType.VEX.createModel(), 0.3F);
|
super(context, ModelType.VEX.createModel(), 0.3F);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.minelittlepony.client.render.entity;
|
package com.minelittlepony.client.render.entity;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.WitchPonyModel;
|
import com.minelittlepony.client.model.entity.WitchPonyModel;
|
||||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||||
|
@ -9,8 +10,7 @@ import net.minecraft.entity.mob.WitchEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class WitchRenderer extends PonyRenderer<WitchEntity, WitchPonyModel> {
|
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) {
|
public WitchRenderer(EntityRendererFactory.Context context) {
|
||||||
super(context, ModelType.WITCH, TextureSupplier.of(WITCH_TEXTURES), BASE_MODEL_SCALE);
|
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.entity.mob.*;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.ZomponyModel;
|
import com.minelittlepony.client.model.entity.ZomponyModel;
|
||||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||||
|
|
||||||
public class ZomponyRenderer<Zombie extends HostileEntity> extends PonyRenderer<Zombie, ZomponyModel<Zombie>> {
|
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 ZOMBIE = new Identifier("minelittlepony", "textures/entity/zombie/zombie_pony.png");
|
public static final Identifier DEMON_CHILD = MineLittlePony.id("textures/entity/zombie/demon_child.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) {
|
public ZomponyRenderer(EntityRendererFactory.Context context, TextureSupplier<Zombie> texture, float scale) {
|
||||||
super(context, ModelType.ZOMBIE, texture, scale);
|
super(context, ModelType.ZOMBIE, texture, scale);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.util.Colors;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
import com.minelittlepony.api.model.PonyModel;
|
||||||
|
@ -31,7 +32,7 @@ public abstract class AbstractClothingFeature<T extends LivingEntity, M extends
|
||||||
overlayModel.setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
overlayModel.setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
||||||
|
|
||||||
VertexConsumer vertexConsumer = renderContext.getBuffer(overlayModel.getLayer(getOverlayTexture()));
|
VertexConsumer vertexConsumer = renderContext.getBuffer(overlayModel.getLayer(getOverlayTexture()));
|
||||||
overlayModel.render(stack, vertexConsumer, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
overlayModel.render(stack, vertexConsumer, lightUv, OverlayTexture.DEFAULT_UV, Colors.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract M getOverlayModel();
|
protected abstract M getOverlayModel();
|
||||||
|
|
|
@ -3,109 +3,119 @@ package com.minelittlepony.client.render.entity.feature;
|
||||||
import com.minelittlepony.api.model.Models;
|
import com.minelittlepony.api.model.Models;
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
import com.minelittlepony.api.model.PonyModel;
|
||||||
import com.minelittlepony.client.model.armour.*;
|
import com.minelittlepony.client.model.armour.*;
|
||||||
import com.minelittlepony.client.render.ArmorRenderLayers;
|
|
||||||
import com.minelittlepony.client.render.PonyRenderContext;
|
import com.minelittlepony.client.render.PonyRenderContext;
|
||||||
import com.minelittlepony.common.util.Color;
|
import com.minelittlepony.common.util.Color;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import java.util.*;
|
||||||
|
|
||||||
import net.minecraft.client.render.*;
|
import net.minecraft.client.render.*;
|
||||||
import net.minecraft.client.render.entity.model.*;
|
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.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.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.component.DataComponentTypes;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.item.*;
|
import net.minecraft.item.*;
|
||||||
import net.minecraft.item.trim.ArmorTrim;
|
import net.minecraft.item.trim.ArmorTrim;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Colors;
|
||||||
|
|
||||||
public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> extends AbstractPonyFeature<T, M> {
|
public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> extends AbstractPonyFeature<T, M> {
|
||||||
|
|
||||||
public ArmourFeature(PonyRenderContext<T, M> context, BakedModelManager bakery) {
|
public ArmourFeature(PonyRenderContext<T, M> context, BakedModelManager bakery) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
public void render(MatrixStack matrices, VertexConsumerProvider provider, int light, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||||
Models<T, M> pony = getModelWrapper();
|
renderArmor(getModelWrapper(), matrices, provider, light, entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
||||||
|
|
||||||
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(
|
public static <T extends LivingEntity, V extends PonyArmourModel<T>> void renderArmor(
|
||||||
Models<T, ? extends PonyModel<T>> pony, MatrixStack matrices,
|
Models<T, ? extends PonyModel<T>> pony, MatrixStack matrices,
|
||||||
VertexConsumerProvider renderContext, int light, T entity,
|
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,
|
||||||
float limbDistance, float limbAngle,
|
float limbDistance, float limbAngle,
|
||||||
float age, float headYaw, float headPitch,
|
float age, float headYaw, float headPitch,
|
||||||
EquipmentSlot armorSlot, ArmourLayer layer) {
|
EquipmentSlot armorSlot, ArmourLayer layer, ArmourRendererPlugin plugin) {
|
||||||
|
|
||||||
ItemStack stack = entity.getEquippedStack(armorSlot);
|
|
||||||
|
|
||||||
|
for (ItemStack stack : plugin.getArmorStacks(entity, armorSlot, layer, ArmourRendererPlugin.ArmourType.ARMOUR)) {
|
||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier texture = ArmourTextureResolver.INSTANCE.getTexture(entity, stack, armorSlot, layer, null);
|
float glintAlpha = plugin.getGlintAlpha(armorSlot, stack);
|
||||||
ArmourVariant variant = ArmourTextureResolver.INSTANCE.getVariant(layer, texture);
|
boolean glint = glintAlpha > 0;
|
||||||
|
int color = plugin.getDyeColor(armorSlot, stack);
|
||||||
|
|
||||||
boolean glint = stack.hasGlint();
|
Set<PonyArmourModel<?>> models = glint ? new HashSet<>() : null;
|
||||||
Item item = stack.getItem();
|
|
||||||
|
|
||||||
pony.getArmourModel(stack, layer, variant)
|
ArmourTextureLookup textureLookup = plugin.getTextureLookup();
|
||||||
.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) {
|
float alpha = plugin.getArmourAlpha(armorSlot, layer);
|
||||||
int color = dyeable.getColor(stack);
|
|
||||||
red = Color.r(color);
|
if (alpha > 0) {
|
||||||
green = Color.g(color);
|
for (ArmorMaterial.Layer armorLayer : textureLookup.getArmorLayers(stack, color)) {
|
||||||
blue = Color.b(color);
|
ArmourTexture layerTexture = textureLookup.getTexture(stack, layer, armorLayer);
|
||||||
|
|
||||||
|
if (layerTexture == ArmourTexture.UNKNOWN) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
model.render(matrices, getArmorConsumer(renderContext, texture, glint), light, OverlayTexture.DEFAULT_UV, red, green, blue, 1);
|
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())) {
|
||||||
if (item instanceof DyeableArmorItem) {
|
VertexConsumer armorConsumer = plugin.getArmourConsumer(armorSlot, provider, layerTexture.texture(), layer);
|
||||||
Identifier tex = ArmourTextureResolver.INSTANCE.getTexture(entity, stack, armorSlot, layer, "overlay");
|
if (armorConsumer != null) {
|
||||||
pony.getArmourModel(stack, layer, ArmourTextureResolver.INSTANCE.getVariant(layer, tex))
|
int armorTint = Colors.WHITE;
|
||||||
.filter(m -> m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body()))
|
if (armorLayer.isDyeable() && color != Colors.WHITE) {
|
||||||
.ifPresent(m -> {
|
armorTint = color;
|
||||||
m.render(matrices, getArmorConsumer(renderContext, tex, false), light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
}
|
||||||
});
|
m.render(matrices, armorConsumer, light, OverlayTexture.DEFAULT_UV, (armorTint & 0xFFFFFF) | ((int)(alpha * 255) << 24));
|
||||||
|
}
|
||||||
|
if (glint) {
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getItem() instanceof ArmorItem armor) {
|
ArmorTrim trim = stack.get(DataComponentTypes.TRIM);
|
||||||
ArmorTrim.getTrim(entity.getWorld().getRegistryManager(), stack, true).ifPresent(trim -> {
|
|
||||||
pony.getArmourModel(stack, layer, ArmourVariant.TRIM)
|
if (trim != null && stack.getItem() instanceof ArmorItem armor) {
|
||||||
.filter(m -> m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body()))
|
float trimAlpha = plugin.getTrimAlpha(armorSlot, armor.getMaterial(), trim, layer);
|
||||||
.ifPresent(m -> {
|
if (trimAlpha > 0) {
|
||||||
m.render(matrices, getTrimConsumer(renderContext, armor.getMaterial(), trim, layer, glint), light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static VertexConsumer getArmorConsumer(VertexConsumerProvider provider, Identifier texture, boolean glint) {
|
if (glint) {
|
||||||
return ItemRenderer.getArmorGlintConsumer(provider, ArmorRenderLayers.getArmorTranslucentNoCull(texture, false), false, 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static VertexConsumer getTrimConsumer(VertexConsumerProvider provider, ArmorMaterial material, ArmorTrim trim, ArmourLayer layer, boolean glint) {
|
plugin.onArmourRendered(entity, matrices, provider, armorSlot, layer, ArmourRendererPlugin.ArmourType.ARMOUR);
|
||||||
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.api.model.BodyPart;
|
||||||
import com.minelittlepony.client.model.ClientPonyModel;
|
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 com.minelittlepony.client.render.PonyRenderContext;
|
||||||
|
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.render.OverlayTexture;
|
import net.minecraft.client.render.OverlayTexture;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.entity.PlayerModelPart;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.util.math.*;
|
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.entity.player.PlayerModelPart;
|
||||||
|
import net.minecraft.util.math.*;
|
||||||
|
|
||||||
public class CapeFeature<M extends ClientPonyModel<AbstractClientPlayerEntity>> extends AbstractPonyFeature<AbstractClientPlayerEntity, M> {
|
public class CapeFeature<M extends ClientPonyModel<AbstractClientPlayerEntity>> extends AbstractPonyFeature<AbstractClientPlayerEntity, M> {
|
||||||
|
|
||||||
|
@ -22,21 +22,28 @@ public class CapeFeature<M extends ClientPonyModel<AbstractClientPlayerEntity>>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
public void render(MatrixStack matrices, VertexConsumerProvider provider, int light, AbstractClientPlayerEntity player, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||||
M model = getModelWrapper().body();
|
M model = getModelWrapper().body();
|
||||||
|
|
||||||
if (!player.isInvisible()
|
if (!player.isInvisible()
|
||||||
&& player.isPartVisible(PlayerModelPart.CAPE) && player.getSkinTextures().capeTexture() != null
|
&& player.isPartVisible(PlayerModelPart.CAPE)
|
||||||
&& player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) {
|
&& player.getSkinTextures().capeTexture() != null) {
|
||||||
|
|
||||||
stack.push();
|
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||||
|
|
||||||
stack.translate(0, 0.24F, 0);
|
VertexConsumer vertices = plugin.getCapeConsumer(player, provider, player.getSkinTextures().capeTexture());
|
||||||
if (model.getAttributes().isLyingDown) {
|
if (vertices == null) {
|
||||||
stack.translate(0, -0.05F, 0);
|
return;
|
||||||
}
|
}
|
||||||
model.transform(BodyPart.BODY, stack);
|
|
||||||
model.getBodyPart(BodyPart.BODY).rotate(stack);
|
matrices.push();
|
||||||
|
|
||||||
|
matrices.translate(0, 0.24F, 0);
|
||||||
|
if (model.getAttributes().isLyingDown) {
|
||||||
|
matrices.translate(0, -0.05F, 0);
|
||||||
|
}
|
||||||
|
model.transform(BodyPart.BODY, matrices);
|
||||||
|
model.getBodyPart(BodyPart.BODY).rotate(matrices);
|
||||||
|
|
||||||
double capeX = MathHelper.lerp(tickDelta, player.capeX, player.prevCapeX) - MathHelper.lerp(tickDelta, player.prevX, player.getX());
|
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());
|
double capeY = MathHelper.lerp(tickDelta, player.capeY, player.prevCapeY) - MathHelper.lerp(tickDelta, player.prevY, player.getY());
|
||||||
|
@ -61,15 +68,16 @@ public class CapeFeature<M extends ClientPonyModel<AbstractClientPlayerEntity>>
|
||||||
float camera = MathHelper.lerp(tickDelta, player.prevStrideDistance, player.strideDistance);
|
float camera = MathHelper.lerp(tickDelta, player.prevStrideDistance, player.strideDistance);
|
||||||
capeMotionY += MathHelper.sin(MathHelper.lerp(tickDelta, player.prevHorizontalSpeed, player.horizontalSpeed) * 6) * 32 * camera;
|
capeMotionY += MathHelper.sin(MathHelper.lerp(tickDelta, player.prevHorizontalSpeed, player.horizontalSpeed) * 6) * 32 * camera;
|
||||||
|
|
||||||
stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(2 + capeMotionX / 12 + capeMotionY));
|
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(2 + capeMotionX / 12 + capeMotionY));
|
||||||
stack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees( diagMotion / 2));
|
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees( diagMotion / 2));
|
||||||
stack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-diagMotion / 2));
|
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-diagMotion / 2));
|
||||||
stack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180));
|
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180));
|
||||||
stack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(90));
|
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(90));
|
||||||
|
|
||||||
VertexConsumer vertices = renderContext.getBuffer(RenderLayer.getEntitySolid(player.getSkinTextures().capeTexture()));
|
model.renderCape(matrices, vertices, light, OverlayTexture.DEFAULT_UV);
|
||||||
model.renderCape(stack, vertices, lightUv, OverlayTexture.DEFAULT_UV);
|
matrices.pop();
|
||||||
stack.pop();
|
|
||||||
|
plugin.onArmourRendered(player, matrices, provider, EquipmentSlot.BODY, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.CAPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.entity.model.EntityModel;
|
import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.util.Colors;
|
||||||
|
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.api.model.BodyPart;
|
import com.minelittlepony.api.model.BodyPart;
|
||||||
|
@ -22,7 +23,7 @@ public class DJPon3Feature<T extends AbstractClientPlayerEntity, M extends Entit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int light, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||||
if ("deadmau5".equals(entity.getName().getString())) {
|
if ("deadmau5".equals(entity.getName().getString())) {
|
||||||
stack.push();
|
stack.push();
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ public class DJPon3Feature<T extends AbstractClientPlayerEntity, M extends Entit
|
||||||
|
|
||||||
VertexConsumer vertices = renderContext.getBuffer(deadMau5.getLayer(entity.getSkinTextures().texture()));
|
VertexConsumer vertices = renderContext.getBuffer(deadMau5.getLayer(entity.getSkinTextures().texture()));
|
||||||
|
|
||||||
deadMau5.render(stack, vertices, OverlayTexture.DEFAULT_UV, lightUv, limbDistance, limbAngle, tickDelta, 1);
|
deadMau5.render(stack, vertices, OverlayTexture.DEFAULT_UV, light, Colors.WHITE);
|
||||||
|
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,55 +5,60 @@ import com.minelittlepony.api.model.PonyModel;
|
||||||
import com.minelittlepony.api.pony.PonyPosture;
|
import com.minelittlepony.api.pony.PonyPosture;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.PonyElytra;
|
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 com.minelittlepony.client.render.PonyRenderContext;
|
||||||
|
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.render.OverlayTexture;
|
import net.minecraft.client.render.OverlayTexture;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
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.entity.model.EntityModel;
|
||||||
import net.minecraft.client.render.item.ItemRenderer;
|
|
||||||
import net.minecraft.client.util.SkinTextures;
|
import net.minecraft.client.util.SkinTextures;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.entity.player.PlayerModelPart;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Colors;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class ElytraFeature<T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> extends AbstractPonyFeature<T, M> {
|
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 static final Identifier TEXTURE_ELYTRA = new Identifier("textures/entity/elytra.png");
|
private final PonyElytra<T> model = ModelType.ELYTRA.createModel();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public ElytraFeature(PonyRenderContext<T, M> context) {
|
||||||
private final PonyElytra<T> modelElytra = (PonyElytra<T>)ModelType.ELYTRA.createModel();
|
super(context);
|
||||||
|
|
||||||
public ElytraFeature(PonyRenderContext<T, M> rp) {
|
|
||||||
super(rp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
public void render(MatrixStack matrices, VertexConsumerProvider provider, int light, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||||
ItemStack itemstack = entity.getEquippedStack(EquipmentSlot.CHEST);
|
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||||
|
|
||||||
if (itemstack.getItem() == Items.ELYTRA) {
|
for (ItemStack stack : plugin.getArmorStacks(entity, EquipmentSlot.CHEST, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.ELYTRA)) {
|
||||||
stack.push();
|
float alpha = plugin.getElytraAlpha(stack, model, entity);
|
||||||
preRenderCallback(stack);
|
if (alpha <= 0) {
|
||||||
|
return;
|
||||||
EntityModel<T> elytra = getElytraModel();
|
|
||||||
|
|
||||||
getContextModel().copyStateTo(elytra);
|
|
||||||
if (elytra instanceof PonyElytra) {
|
|
||||||
((PonyElytra<T>)elytra).isSneaking = PonyPosture.isCrouching(getContext().getEntityPony(entity), entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elytra.setAngles(entity, limbDistance, limbAngle, age, headYaw, headPitch);
|
VertexConsumer vertexConsumer = plugin.getElytraConsumer(stack, model, entity, provider, getElytraTexture(entity));
|
||||||
VertexConsumer vertexConsumer = ItemRenderer.getDirectItemGlintConsumer(renderContext, modelElytra.getLayer(getElytraTexture(entity)), false, itemstack.hasGlint());
|
if (vertexConsumer == null) {
|
||||||
modelElytra.render(stack, vertexConsumer, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
return;
|
||||||
|
|
||||||
stack.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.onArmourRendered(entity, matrices, provider, EquipmentSlot.BODY, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.ELYTRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void preRenderCallback(MatrixStack stack) {
|
protected void preRenderCallback(MatrixStack stack) {
|
||||||
|
@ -62,10 +67,6 @@ public class ElytraFeature<T extends LivingEntity, M extends EntityModel<T> & Po
|
||||||
body.transform(BodyPart.BODY, stack);
|
body.transform(BodyPart.BODY, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EntityModel<T> getElytraModel() {
|
|
||||||
return modelElytra;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Identifier getElytraTexture(T entity) {
|
protected Identifier getElytraTexture(T entity) {
|
||||||
if (entity instanceof AbstractClientPlayerEntity player) {
|
if (entity instanceof AbstractClientPlayerEntity player) {
|
||||||
SkinTextures textures = player.getSkinTextures();
|
SkinTextures textures = player.getSkinTextures();
|
||||||
|
@ -79,6 +80,6 @@ public class ElytraFeature<T extends LivingEntity, M extends EntityModel<T> & Po
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TEXTURE_ELYTRA;
|
return TEXTURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,17 @@ package com.minelittlepony.client.render.entity.feature;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2FloatLinkedOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2FloatLinkedOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
|
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
|
||||||
|
import net.minecraft.block.SkullBlock;
|
||||||
import net.minecraft.client.render.*;
|
import net.minecraft.client.render.*;
|
||||||
import net.minecraft.client.render.entity.model.EntityModel;
|
import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.entity.LivingEntity;
|
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.util.math.random.Random;
|
||||||
|
import net.minecraft.world.EmptyBlockView;
|
||||||
|
|
||||||
import com.google.common.cache.*;
|
import com.google.common.cache.*;
|
||||||
import com.google.common.collect.Streams;
|
import com.google.common.collect.Streams;
|
||||||
|
@ -15,6 +21,8 @@ import com.minelittlepony.api.model.PonyModel;
|
||||||
import com.minelittlepony.api.model.gear.Gear;
|
import com.minelittlepony.api.model.gear.Gear;
|
||||||
import com.minelittlepony.api.pony.meta.Wearable;
|
import com.minelittlepony.api.pony.meta.Wearable;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
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 com.minelittlepony.client.render.PonyRenderContext;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -52,6 +60,14 @@ public class GearFeature<T extends LivingEntity, M extends EntityModel<T> & Pony
|
||||||
return;
|
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 M model = getModelWrapper().body();
|
||||||
final Object2FloatMap<BodyPart> renderStackingOffsets = new Object2FloatLinkedOpenHashMap<>();
|
final Object2FloatMap<BodyPart> renderStackingOffsets = new Object2FloatLinkedOpenHashMap<>();
|
||||||
|
|
||||||
|
@ -60,9 +76,12 @@ public class GearFeature<T extends LivingEntity, M extends EntityModel<T> & Pony
|
||||||
stack.push();
|
stack.push();
|
||||||
Gear gear = entry.gear();
|
Gear gear = entry.gear();
|
||||||
gear.transform(model, stack);
|
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()) {
|
if (gear.isStackable()) {
|
||||||
BodyPart part = gear.getGearLocation();
|
|
||||||
float v = renderStackingOffsets.getFloat(part);
|
float v = renderStackingOffsets.getFloat(part);
|
||||||
if (v != 0) {
|
if (v != 0) {
|
||||||
stack.translate(0, -v, 0);
|
stack.translate(0, -v, 0);
|
||||||
|
@ -78,7 +97,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) {
|
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.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, 1, 1, 1, 1, entity.getUuid());
|
gear.render(stack, renderContext.getBuffer(gear.getLayer(entity, getContext())), lightUv, OverlayTexture.DEFAULT_UV, Colors.WHITE, entity.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
static record Entry(Gear gear, Wearable wearable) { }
|
static record Entry(Gear gear, Wearable wearable) { }
|
||||||
|
|
|
@ -2,106 +2,79 @@ package com.minelittlepony.client.render.entity.feature;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.BodyPart;
|
import com.minelittlepony.api.model.BodyPart;
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
import com.minelittlepony.api.model.PonyModel;
|
||||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||||
|
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||||
import com.minelittlepony.client.render.PonyRenderContext;
|
import com.minelittlepony.client.render.PonyRenderContext;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.block.AbstractSkullBlock;
|
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.*;
|
||||||
import net.minecraft.client.render.block.entity.SkullBlockEntityModel;
|
import net.minecraft.client.render.entity.feature.HeadFeatureRenderer;
|
||||||
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
|
|
||||||
import net.minecraft.client.render.entity.model.EntityModel;
|
import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
import net.minecraft.client.render.entity.model.EntityModelLoader;
|
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.render.model.json.ModelTransformationMode;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.util.math.RotationAxis;
|
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.entity.LivingEntity;
|
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.ArmorItem;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
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> {
|
public class SkullFeature<T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> extends AbstractPonyFeature<T, M> {
|
||||||
|
private final ItemRenderer itemRenderer;
|
||||||
|
|
||||||
private final Map<SkullBlock.SkullType, SkullBlockEntityModel> headModels;
|
public SkullFeature(PonyRenderContext<T, M> renderPony, EntityModelLoader entityModelLoader, ItemRenderer itemRenderer) {
|
||||||
|
|
||||||
public SkullFeature(PonyRenderContext<T, M> renderPony, EntityModelLoader entityModelLoader) {
|
|
||||||
super(renderPony);
|
super(renderPony);
|
||||||
headModels = SkullBlockEntityRenderer.getModels(entityModelLoader);
|
this.itemRenderer = itemRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
public void render(MatrixStack matrices, VertexConsumerProvider provider, int light, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
|
||||||
ItemStack itemstack = entity.getEquippedStack(EquipmentSlot.HEAD);
|
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||||
if (!itemstack.isEmpty()) {
|
|
||||||
|
for (ItemStack stack : plugin.getArmorStacks(entity, EquipmentSlot.HEAD, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.SKULL)) {
|
||||||
|
if (stack.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
M model = getModelWrapper().body();
|
M model = getModelWrapper().body();
|
||||||
Item item = itemstack.getItem();
|
Item item = stack.getItem();
|
||||||
|
|
||||||
stack.push();
|
matrices.push();
|
||||||
|
|
||||||
model.transform(BodyPart.HEAD, stack);
|
if (entity.isBaby() && !(entity instanceof VillagerEntity)) {
|
||||||
model.getHead().rotate(stack);
|
matrices.translate(0, 0.03125F, 0);
|
||||||
|
matrices.scale(0.7F, 0.7F, 0.7F);
|
||||||
if (model instanceof AbstractPonyModel) {
|
matrices.translate(0, 1, 0);
|
||||||
stack.translate(0, 0.225F, 0);
|
|
||||||
} else {
|
|
||||||
stack.translate(0, 0, 0.15F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof AbstractSkullBlock) {
|
model.transform(BodyPart.HEAD, matrices);
|
||||||
boolean isVillager = entity instanceof VillagerDataContainer;
|
model.getHead().rotate(matrices);
|
||||||
|
|
||||||
renderSkull(stack, renderContext, itemstack, isVillager, limbDistance, lightUv);
|
boolean isVillager = entity instanceof VillagerEntity || entity instanceof ZombieVillagerEntity;
|
||||||
} else if (!(item instanceof ArmorItem) || ((ArmorItem)item).getSlotType() != EquipmentSlot.HEAD) {
|
|
||||||
renderBlock(stack, renderContext, entity, itemstack, lightUv);
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.pop();
|
matrices.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.entity.mob.AbstractSkeletonEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.SkeleponyModel;
|
import com.minelittlepony.client.model.entity.SkeleponyModel;
|
||||||
|
|
||||||
public class StrayClothingFeature<Skeleton extends AbstractSkeletonEntity> extends AbstractClothingFeature<Skeleton, SkeleponyModel<Skeleton>> {
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
private final SkeleponyModel<Skeleton> overlayModel = (SkeleponyModel<Skeleton>)ModelType.SKELETON_CLOTHES.createModel();
|
private final SkeleponyModel<Skeleton> overlayModel = (SkeleponyModel<Skeleton>)ModelType.SKELETON_CLOTHES.createModel();
|
||||||
|
|
|
@ -13,7 +13,6 @@ import com.minelittlepony.api.pony.meta.Race;
|
||||||
import com.minelittlepony.api.pony.meta.Wearable;
|
import com.minelittlepony.api.pony.meta.Wearable;
|
||||||
import com.minelittlepony.client.model.*;
|
import com.minelittlepony.client.model.*;
|
||||||
import com.minelittlepony.client.render.entity.PonyRenderer;
|
import com.minelittlepony.client.render.entity.PonyRenderer;
|
||||||
import com.minelittlepony.client.render.entity.feature.*;
|
|
||||||
import com.minelittlepony.client.render.entity.npc.textures.*;
|
import com.minelittlepony.client.render.entity.npc.textures.*;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -34,12 +33,6 @@ abstract class AbstractNpcRenderer<T extends MobEntity & VillagerDataContainer>
|
||||||
addFeature(clothing);
|
addFeature(clothing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addFeatures(EntityRendererFactory.Context context) {
|
|
||||||
addFeature(createHeldItemFeature(context));
|
|
||||||
addFeature(new GearFeature<>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRender(ClientPonyModel<T> model, T entity, Wearable wearable, Gear gear) {
|
public boolean shouldRender(ClientPonyModel<T> model, T entity, Wearable wearable, Gear gear) {
|
||||||
if (wearable == Wearable.SADDLE_BAGS_BOTH) {
|
if (wearable == Wearable.SADDLE_BAGS_BOTH) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.minelittlepony.client.render.entity.npc;
|
package com.minelittlepony.client.render.entity.npc;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.IllagerPonyModel;
|
import com.minelittlepony.client.model.entity.IllagerPonyModel;
|
||||||
import com.minelittlepony.client.render.entity.feature.IllagerHeldItemFeature;
|
import com.minelittlepony.client.render.entity.feature.IllagerHeldItemFeature;
|
||||||
|
@ -19,9 +20,9 @@ import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public class IllagerPonyRenderer<T extends IllagerEntity> extends PonyRenderer<T, IllagerPonyModel<T>> {
|
public class IllagerPonyRenderer<T extends IllagerEntity> extends PonyRenderer<T, IllagerPonyModel<T>> {
|
||||||
public static final Identifier ILLUSIONIST = new Identifier("minelittlepony", "textures/entity/illager/illusionist_pony.png");
|
public static final Identifier ILLUSIONIST = MineLittlePony.id("textures/entity/illager/illusionist_pony.png");
|
||||||
public static final Identifier EVOKER = new Identifier("minelittlepony", "textures/entity/illager/evoker_pony.png");
|
public static final Identifier EVOKER = MineLittlePony.id("textures/entity/illager/evoker_pony.png");
|
||||||
public static final Identifier VINDICATOR = new Identifier("minelittlepony", "textures/entity/illager/vindicator_pony.png");
|
public static final Identifier VINDICATOR = MineLittlePony.id("textures/entity/illager/vindicator_pony.png");
|
||||||
|
|
||||||
public IllagerPonyRenderer(EntityRendererFactory.Context context, Identifier texture) {
|
public IllagerPonyRenderer(EntityRendererFactory.Context context, Identifier texture) {
|
||||||
super(context, ModelType.ILLAGER, TextureSupplier.of(texture), BASE_MODEL_SCALE);
|
super(context, ModelType.ILLAGER, TextureSupplier.of(texture), BASE_MODEL_SCALE);
|
||||||
|
|
|
@ -8,8 +8,7 @@ import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.Util;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.village.VillagerData;
|
import net.minecraft.village.VillagerData;
|
||||||
import net.minecraft.village.VillagerDataContainer;
|
import net.minecraft.village.VillagerDataContainer;
|
||||||
|
@ -17,6 +16,7 @@ import net.minecraft.village.VillagerProfession;
|
||||||
import net.minecraft.village.VillagerType;
|
import net.minecraft.village.VillagerType;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.PonyModel;
|
import com.minelittlepony.api.model.PonyModel;
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.render.PonyRenderContext;
|
import com.minelittlepony.client.render.PonyRenderContext;
|
||||||
import com.minelittlepony.client.render.entity.feature.AbstractPonyFeature;
|
import com.minelittlepony.client.render.entity.feature.AbstractPonyFeature;
|
||||||
import com.minelittlepony.client.util.render.TextureFlattener;
|
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> {
|
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 -> {
|
private static final Int2ObjectMap<Identifier> LEVEL_TO_ID = Util.make(new Int2ObjectOpenHashMap<>(), a -> {
|
||||||
a.put(1, new Identifier("stone"));
|
a.put(1, Identifier.ofVanilla("stone"));
|
||||||
a.put(2, new Identifier("iron"));
|
a.put(2, Identifier.ofVanilla("iron"));
|
||||||
a.put(3, new Identifier("gold"));
|
a.put(3, Identifier.ofVanilla("gold"));
|
||||||
a.put(4, new Identifier("emerald"));
|
a.put(4, Identifier.ofVanilla("emerald"));
|
||||||
a.put(5, new Identifier("diamond"));
|
a.put(5, Identifier.ofVanilla("diamond"));
|
||||||
});
|
});
|
||||||
private final Set<Identifier> loadedTextures = new HashSet<>();
|
private final Set<Identifier> loadedTextures = new HashSet<>();
|
||||||
|
|
||||||
|
@ -59,9 +59,9 @@ class NpcClothingFeature<
|
||||||
if (!ResourceUtil.textureExists(typeSkin)) {
|
if (!ResourceUtil.textureExists(typeSkin)) {
|
||||||
typeSkin = createTexture("type", Registries.VILLAGER_TYPE.getId(VillagerType.PLAINS));
|
typeSkin = createTexture("type", Registries.VILLAGER_TYPE.getId(VillagerType.PLAINS));
|
||||||
}
|
}
|
||||||
renderModel(entityModel, typeSkin, matrixStack, provider, i, entity, 1, 1, 1);
|
renderModel(entityModel, typeSkin, matrixStack, provider, i, entity, Colors.WHITE);
|
||||||
} else {
|
} else {
|
||||||
renderModel(entityModel, getMergedTexture(data), matrixStack, provider, i, entity, 1, 1, 1);
|
renderModel(entityModel, getMergedTexture(data), matrixStack, provider, i, entity, Colors.WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class NpcClothingFeature<
|
||||||
Identifier typeId = Registries.VILLAGER_TYPE.getId(type);
|
Identifier typeId = Registries.VILLAGER_TYPE.getId(type);
|
||||||
Identifier profId = Registries.VILLAGER_PROFESSION.getId(profession);
|
Identifier profId = Registries.VILLAGER_PROFESSION.getId(profession);
|
||||||
|
|
||||||
Identifier key = new Identifier("minelittlepony", (typeId + "/" + profId + "/" + level).replace(':', '_'));
|
Identifier key = MineLittlePony.id((typeId + "/" + profId + "/" + level).replace(':', '_'));
|
||||||
|
|
||||||
if (loadedTextures.add(key) && !ResourceUtil.textureExists(key)) {
|
if (loadedTextures.add(key) && !ResourceUtil.textureExists(key)) {
|
||||||
TextureFlattener.flatten(computeTextures(typeId, profId, profession == VillagerProfession.NITWIT ? -1 : level), key);
|
TextureFlattener.flatten(computeTextures(typeId, profId, profession == VillagerProfession.NITWIT ? -1 : level), key);
|
||||||
|
@ -91,7 +91,7 @@ class NpcClothingFeature<
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier profTexture = createTexture("profession", profId);
|
Identifier profTexture = createTexture("profession", profId);
|
||||||
skins.add(ResourceUtil.textureExists(profTexture) ? profTexture : createTexture("profession", new Identifier(VillagerProfession.NITWIT.id())));
|
skins.add(ResourceUtil.textureExists(profTexture) ? profTexture : createTexture("profession", Identifier.of(VillagerProfession.NITWIT.id())));
|
||||||
|
|
||||||
if (level != -1) {
|
if (level != -1) {
|
||||||
skins.add(createTexture("profession_level", LEVEL_TO_ID.get(level)));
|
skins.add(createTexture("profession_level", LEVEL_TO_ID.get(level)));
|
||||||
|
@ -105,6 +105,6 @@ class NpcClothingFeature<
|
||||||
}
|
}
|
||||||
|
|
||||||
private Identifier createTexture(String category, Identifier identifier) {
|
private Identifier createTexture(String category, Identifier identifier) {
|
||||||
return new Identifier("minelittlepony", String.format("textures/entity/%s/%s/%s.png", entityType, category, identifier.getPath()));
|
return MineLittlePony.id(String.format("textures/entity/%s/%s/%s.png", entityType, category, identifier.getPath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||||
import net.minecraft.entity.mob.PillagerEntity;
|
import net.minecraft.entity.mob.PillagerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.PillagerPonyModel;
|
import com.minelittlepony.client.model.entity.PillagerPonyModel;
|
||||||
import com.minelittlepony.client.render.entity.feature.IllagerHeldItemFeature;
|
import com.minelittlepony.client.render.entity.feature.IllagerHeldItemFeature;
|
||||||
|
@ -12,8 +13,7 @@ import com.minelittlepony.client.render.entity.PonyRenderer;
|
||||||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||||
|
|
||||||
public class PillagerRenderer extends PonyRenderer<PillagerEntity, PillagerPonyModel<PillagerEntity>> {
|
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) {
|
public PillagerRenderer(EntityRendererFactory.Context context) {
|
||||||
super(context, ModelType.PILLAGER, TextureSupplier.of(TEXTURE));
|
super(context, ModelType.PILLAGER, TextureSupplier.of(TEXTURE));
|
||||||
|
|
|
@ -4,14 +4,14 @@ import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||||
import net.minecraft.entity.passive.WanderingTraderEntity;
|
import net.minecraft.entity.passive.WanderingTraderEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.model.entity.race.AlicornModel;
|
import com.minelittlepony.client.model.entity.race.AlicornModel;
|
||||||
import com.minelittlepony.client.render.entity.PonyRenderer;
|
import com.minelittlepony.client.render.entity.PonyRenderer;
|
||||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||||
|
|
||||||
public class TraderRenderer extends PonyRenderer<WanderingTraderEntity, AlicornModel<WanderingTraderEntity>> {
|
public class TraderRenderer extends PonyRenderer<WanderingTraderEntity, AlicornModel<WanderingTraderEntity>> {
|
||||||
|
public static final Identifier TEXTURE = MineLittlePony.id("textures/entity/wandering_trader_pony.png");
|
||||||
public static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/entity/wandering_trader_pony.png");
|
|
||||||
|
|
||||||
public TraderRenderer(EntityRendererFactory.Context context) {
|
public TraderRenderer(EntityRendererFactory.Context context) {
|
||||||
super(context, ModelType.ALICORN.getKey(false), TextureSupplier.of(TEXTURE), BASE_MODEL_SCALE);
|
super(context, ModelType.ALICORN.getKey(false), TextureSupplier.of(TEXTURE), BASE_MODEL_SCALE);
|
||||||
|
|
|
@ -33,11 +33,11 @@ public class ZomponyVillagerRenderer extends AbstractNpcRenderer<ZombieVillagerE
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupTransforms(ZombieVillagerEntity entity, MatrixStack stack, float move, float rotationYaw, float ticks) {
|
protected void setupTransforms(ZombieVillagerEntity entity, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, float scale) {
|
||||||
if (entity.isConverting()) {
|
if (entity.isConverting()) {
|
||||||
rotationYaw += (float) (Math.cos(entity.age * 3.25D) * (Math.PI / 4));
|
bodyYaw += (float) (Math.cos(entity.age * 3.25D) * (Math.PI / 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
super.setupTransforms(entity, stack, move, rotationYaw, ticks);
|
super.setupTransforms(entity, matrices, animationProgress, bodyYaw, tickDelta, scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.function.Function;
|
||||||
public class PlayerTextureSupplier {
|
public class PlayerTextureSupplier {
|
||||||
public static <T extends LivingEntity> TextureSupplier<T> create(TextureSupplier<T> fallback) {
|
public static <T extends LivingEntity> TextureSupplier<T> create(TextureSupplier<T> fallback) {
|
||||||
Function<String, CompletableFuture<Identifier>> customNameCache = Util.memoize(name -> {
|
Function<String, CompletableFuture<Identifier>> customNameCache = Util.memoize(name -> {
|
||||||
return SkullBlockEntity.fetchProfile(name).thenApply(profile -> {
|
return SkullBlockEntity.fetchProfileByName(name).thenApply(profile -> {
|
||||||
return profile
|
return profile
|
||||||
.map(p -> SkinsProxy.instance.getSkinTexture(p))
|
.map(p -> SkinsProxy.instance.getSkinTexture(p))
|
||||||
.filter(skin -> !Pony.getManager().getPony(skin).race().isHuman())
|
.filter(skin -> !Pony.getManager().getPony(skin).race().isHuman())
|
||||||
|
|
|
@ -24,7 +24,7 @@ public interface TextureSupplier<T> extends Function<T, Identifier> {
|
||||||
Identifier apply(T key);
|
Identifier apply(T key);
|
||||||
|
|
||||||
static TextureSupplier<String> formatted(String domain, String path) {
|
static TextureSupplier<String> formatted(String domain, String path) {
|
||||||
return key -> new Identifier(domain, String.format(path, key));
|
return key -> Identifier.of(domain, String.format(path, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
static <T extends LivingEntity> TextureSupplier<T> ofVariations(Identifier poolId, TextureSupplier<T> fallback) {
|
static <T extends LivingEntity> TextureSupplier<T> ofVariations(Identifier poolId, TextureSupplier<T> fallback) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue