Initial port to 1.14/Fabric

This commit is contained in:
Sollace 2019-05-27 17:59:15 +02:00
parent 27df5a9f4c
commit c1c9951412
177 changed files with 2578 additions and 2447 deletions

View file

@ -1,30 +1,36 @@
// Frabric build script
// 24/05/2019
// https://github.com/FabricMC/fabric-example-mod/blob/master/build.gradle
buildscript { buildscript {
repositories { repositories {
jcenter() jcenter()
maven { maven {
name 'forge' name = 'Fabric'
url 'http://files.minecraftforge.net/maven' url = 'https://maven.fabricmc.net/'
} }
// maven { gradlePluginPortal()
// name = 'sponge' }
// url = 'https://repo.spongepowered.org/maven'
// }
}
dependencies { dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true classpath 'fabric-loom:fabric-loom.gradle.plugin:0.2.2-SNAPSHOT'
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
classpath 'org.ajoberstar.grgit:grgit-gradle:3.1.1' classpath 'org.ajoberstar.grgit:grgit-gradle:3.1.1'
} }
} }
apply plugin: 'net.minecraftforge.gradle' repositories {
apply plugin: 'eclipse' maven {
name = 'Jit'
url = 'https://jitpack.io'
}
}
apply plugin: 'fabric-loom'
apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'org.ajoberstar.grgit' apply plugin: 'org.ajoberstar.grgit'
// From the forge MDK: Need this here so eclipse task generates correctly. targetCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = compileJava.targetCompatibility = 1.8 sourceCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = compileJava.sourceCompatibility = 1.8
ext { ext {
revision = grgit.log().size() revision = grgit.log().size()
@ -49,77 +55,59 @@ group = project.group
description = project.displayname description = project.displayname
archivesBaseName = project.name archivesBaseName = project.name
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}"
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modCompile "com.github.MineLittlePony:Kirin:${project.kirin_version}"
include "com.github.MineLittlePony:Kirin:${project.kirin_version}"
// TODO: HD Skins can be made optional later
modCompile "com.github.MineLittlePony:HDSkins:${hd_skins_version}"
include "com.github.MineLittlePony:HDSkins:${hd_skins_version}"
}
sourceSets { sourceSets {
main {}
client { client {
// Client-only code // Client-only code
compileClasspath += main.compileClasspath compileClasspath += main.compileClasspath
compileClasspath += main.output compileClasspath += main.output
} }
fml {
compileClasspath += main.compileClasspath
compileClasspath += main.output
compileClasspath += client.output
}
} }
minecraft { processResources {
mappings channel: project.mappings_channel, version: project.mappings_version + "-" + project.minecraft_version inputs.property "version", project.version
runs { from(sourceSets.main.resources.srcDirs) {
client { include "fabric.mod.json"
workingDirectory project.file('run') expand "version": project.version
}
property 'forge.logging.markers', 'SCAN' from(sourceSets.main.resources.srcDirs) {
property 'forge.logging.console.level', 'debug' exclude "fabric.mod.json"
}
mods {
minelittlepony {
source sourceSets.fml
}
}
ideaModule = "${project.name}.fml"
}
}
}
repositories {
maven {
url = 'https://repo.spongepowered.org/maven'
}
maven {
url = 'https://jitpack.io'
}
}
dependencies {
minecraft "net.minecraftforge:forge:" + project.minecraft_version + "-" + project.forge_version
compile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
transitive = false
}
compile fg.deobf("com.github.MineLittlePony:Kirin:master-SNAPSHOT")
compile fg.deobf(project.dependencies.create("com.github.MineLittlePony:HDSkins:1.13-SNAPSHOT") {
transitive = false
})
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
it.options.compilerArgs += '-proc:none' options.encoding = "UTF-8"
} }
manifest {
attributes(
"Implementation-Version": "${version} (git-${project.hash})", task sourcesJar(type: Jar, dependsOn: classes) {
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") classifier = "sources"
) from sourceSets.main.allSource
from sourceSets.client.allSource
} }
jar { jar {
from sourceSets.main.output from sourceSets.main.output
from sourceSets.client.output from sourceSets.client.output
from sourceSets.fml.output from "LICENSE"
} }
// //

View file

@ -1,12 +1,22 @@
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false org.gradle.daemon=false
group=com.minelittlepony
displayname=Mine Little Pony # Fabric Properties
authors=Verdana, Rene_Z, Mumfrey, Killjoy1221, Sollace # check these on https://fabricmc.net/use
description=Mine Little Pony turns players and mobs into ponies. Press F9 ingame to access settings. minecraft_version=1.14.1
version=3.2 yarn_mappings=1.14.1+build.5
release=SNAPSHOT loader_version=0.4.7+build.147
minecraft_version=1.13.2
forge_version=25.0.107 # Mod Properties
mappings_channel=snapshot group=com.minelittlepony
mappings_version=20190324 displayname=Mine Little Pony
authors=Verdana, Rene_Z, Mumfrey, Killjoy1221, Sollace
description=Mine Little Pony turns players and mobs into ponies. Press F9 ingame to access settings.
version=3.2
release=SNAPSHOT
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric
fabric_version=0.3.0-pre+build.156
kirin_version=1.14-fabric-SNAPSHOT
hd_skins_version=1.14-fabric-SNAPSHOT

View file

@ -1,3 +1 @@
rootProject.name = 'MineLittlePony' rootProject.name = 'MineLittlePony'
// Checkout to parent dir to dev both
//includeBuild '../HDSkins'

View file

@ -0,0 +1,50 @@
package com.minelittlepony.client;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.entity.Entity;
import com.minelittlepony.hdskins.mixin.MixinEntityRenderDispatcher;
import java.nio.file.Path;
import java.util.function.Function;
public class FabMod implements ClientModInitializer, IModUtilities {
private final MineLPClient mlp = new MineLPClient(this);
@Override
public void onInitializeClient() {
mlp.init(Config.of(getConfigDirectory()));
mlp.postInit(MinecraftClient.getInstance());
}
@Override
public <T extends BlockEntity> void addRenderer(Class<T> type, BlockEntityRenderer<T> renderer) {
}
@Override
public <T extends Entity> void addRenderer(Class<T> type, Function<EntityRenderDispatcher, EntityRenderer<T>> renderer) {
EntityRenderDispatcher mx = MinecraftClient.getInstance().getEntityRenderManager();
((MixinEntityRenderDispatcher)mx).getRenderers().put(type, renderer.apply(mx));
}
public float getRenderPartialTicks() {
return MinecraftClient.getInstance().getTickDelta();
}
@Override
public Path getConfigDirectory() {
return FabricLoader.getInstance().getConfigDirectory().toPath();
}
@Override
public Path getAssetsDirectory() {
return FabricLoader.getInstance().getGameDirectory().toPath().resolve("assets");
}
}

View file

@ -1,11 +1,10 @@
package com.minelittlepony.client; package com.minelittlepony.client;
import net.minecraft.client.renderer.entity.model.ModelBiped; import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EquipmentSlot;
import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.client.ForgeHooksClient;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -24,9 +23,9 @@ public class ForgeProxy {
* @param type unknown * @param type unknown
* @return * @return
*/ */
public static String getArmorTexture(Entity entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) { public static String getArmorTexture(Entity entity, ItemStack item, String def, EquipmentSlot slot, @Nullable String type) {
if (MineLPClient.getInstance().getModUtilities().hasFml()) /*if (MineLPClient.getInstance().getModUtilities().hasFml())
return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type); return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type);*/
return def; return def;
} }
@ -38,10 +37,10 @@ public class ForgeProxy {
* @param slot The slot this armour piece is place in. * @param slot The slot this armour piece is place in.
* @param def Default return value if no mods present * @param def Default return value if no mods present
*/ */
public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) { public static <T extends LivingEntity> BipedEntityModel<T> getArmorModel(T entity, ItemStack item, EquipmentSlot slot, BipedEntityModel<T> def) {
if (MineLPClient.getInstance().getModUtilities().hasFml()) { /*if (MineLPClient.getInstance().getModUtilities().hasFml()) {
return ForgeHooksClient.getArmorModel(entity, item, slot, def); return ForgeHooksClient.getArmorModel(entity, item, slot, def);
} }*/
return def; return def;
} }
} }

View file

@ -1,16 +1,26 @@
package com.minelittlepony.client; package com.minelittlepony.client;
import net.minecraft.client.renderer.entity.Render; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import java.nio.file.Path;
import java.util.function.Function;
public interface IModUtilities { public interface IModUtilities {
<T extends TileEntity> void addRenderer(Class<T> type, TileEntityRenderer<T> renderer); <T extends BlockEntity> void addRenderer(Class<T> type, BlockEntityRenderer<T> renderer);
<T extends Entity> void addRenderer(Class<T> type, Render<T> renderer); <T extends Entity> void addRenderer(Class<T> type, Function<EntityRenderDispatcher, EntityRenderer<T>> renderer);
boolean hasFml(); default boolean hasFml() {
return false;
}
float getRenderPartialTicks(); float getRenderPartialTicks();
Path getConfigDirectory();
Path getAssetsDirectory();
} }

View file

@ -12,16 +12,16 @@ import com.minelittlepony.hdskins.net.SkinServer;
import com.minelittlepony.hdskins.net.ValhallaSkinServer; import com.minelittlepony.hdskins.net.ValhallaSkinServer;
import com.minelittlepony.settings.PonyConfig; import com.minelittlepony.settings.PonyConfig;
import net.minecraft.client.Minecraft; import net.minecraft.ChatFormat;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.MinecraftClient;
import net.minecraft.resources.IReloadableResourceManager; import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.util.InputMappings; import net.minecraft.client.util.InputUtil;
import net.minecraft.util.Util; import net.minecraft.network.chat.Style;
import net.minecraft.util.text.Style; import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.resource.ReloadableResourceManager;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.SystemUtil;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
@ -58,8 +58,8 @@ public class MineLPClient extends MineLittlePony {
config = newConfig; config = newConfig;
ponyManager = new PonyManager(config); ponyManager = new PonyManager(config);
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getInstance().getResourceManager(); ReloadableResourceManager irrm = (ReloadableResourceManager) MinecraftClient.getInstance().getResourceManager();
irrm.addReloadListener(ponyManager); irrm.registerListener(ponyManager);
// This also makes it the default gateway server. // This also makes it the default gateway server.
SkinServer.defaultServers.add(new LegacySkinServer(MINELP_LEGACY_SERVER, MINELP_LEGACY_GATEWAY)); SkinServer.defaultServers.add(new LegacySkinServer(MINELP_LEGACY_SERVER, MINELP_LEGACY_GATEWAY));
@ -69,7 +69,7 @@ public class MineLPClient extends MineLittlePony {
/** /**
* Called when the game is ready. * Called when the game is ready.
*/ */
void postInit(Minecraft minecraft) { void postInit(MinecraftClient minecraft) {
HDSkins manager = HDSkins.getInstance(); HDSkins manager = HDSkins.getInstance();
// manager.setSkinUrl(SKIN_SERVER_URL); // manager.setSkinUrl(SKIN_SERVER_URL);
@ -81,27 +81,27 @@ public class MineLPClient extends MineLittlePony {
manager.setSkinsGui(GuiSkinsMineLP::new); manager.setSkinsGui(GuiSkinsMineLP::new);
RenderManager rm = minecraft.getRenderManager(); EntityRenderDispatcher rm = minecraft.getEntityRenderManager();
renderManager.initialisePlayerRenderers(rm); renderManager.initialiseRenderers(rm);
renderManager.initializeMobRenderers(rm, config);
} }
void onTick(Minecraft minecraft, boolean inGame) { void onTick(MinecraftClient minecraft, boolean inGame) {
if (inGame && minecraft.currentScreen == null) { if (inGame && minecraft.currentScreen == null) {
if (SETTINGS_GUI.isPressed()) { if (SETTINGS_GUI.isPressed()) {
minecraft.displayGuiScreen(new GuiHost(new GuiPonySettings())); minecraft.disconnect(new GuiHost(new GuiPonySettings()));
} else { } else {
long handle = minecraft.window.getHandle();
if ((Util.milliTime() % 10) == 0) { if ((SystemUtil.getMeasuringTimeMs() % 10) == 0) {
if (InputMappings.isKeyDown(GLFW.GLFW_KEY_F3) && InputMappings.isKeyDown(GLFW.GLFW_KEY_M)) { if (InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_F3) && InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_M)) {
if (!reloadingModels) { if (!reloadingModels) {
minecraft.ingameGUI.getChatGUI().printChatMessage( minecraft.inGameHud.getChatHud().addMessage(
(new TextComponentString("")).appendSibling( (new TextComponent("")).append(
new TextComponentTranslation("debug.prefix") new TranslatableComponent("debug.prefix")
.setStyle(new Style().setColor(TextFormatting.YELLOW).setBold(true))) .setStyle(new Style().setColor(ChatFormat.YELLOW).setBold(true)))
.appendText(" ") .append(" ")
.appendSibling(new TextComponentTranslation("minelp.debug.reload_models.message"))); .append(new TranslatableComponent("minelp.debug.reload_models.message")));
reloadingModels = true; reloadingModels = true;
modelUpdateCounter++; modelUpdateCounter++;

View file

@ -1,26 +1,28 @@
package com.minelittlepony.client; package com.minelittlepony.client;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.minelittlepony.client.ducks.IRenderPony;
import com.minelittlepony.client.gui.hdskins.EntityPonyModel; import com.minelittlepony.client.gui.hdskins.EntityPonyModel;
import com.minelittlepony.client.gui.hdskins.RenderPonyModel; import com.minelittlepony.client.gui.hdskins.RenderPonyModel;
import com.minelittlepony.client.mixin.MixinRenderManager; import com.minelittlepony.client.mixin.MixinRenderManager;
import com.minelittlepony.client.model.races.PlayerModels; import com.minelittlepony.client.model.races.PlayerModels;
import com.minelittlepony.client.render.LevitatingItemRenderer; import com.minelittlepony.client.render.LevitatingItemRenderer;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.client.render.entities.MobRenderers; import com.minelittlepony.client.render.entities.MobRenderers;
import com.minelittlepony.client.render.entities.player.RenderPonyPlayer; import com.minelittlepony.client.render.entities.player.RenderPonyPlayer;
import com.minelittlepony.settings.PonyConfig; import com.minelittlepony.model.IPonyModel;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.LivingEntity;
/** /**
* 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.
@ -40,62 +42,54 @@ public class PonyRenderManager {
private LevitatingItemRenderer magicRenderer = new LevitatingItemRenderer(); private LevitatingItemRenderer magicRenderer = new LevitatingItemRenderer();
private final Map<Class<? extends Entity>, Render<?>> renderMap = Maps.newHashMap(); private final Map<Class<? extends Entity>, EntityRenderer<?>> renderMap = Maps.newHashMap();
/** /**
* Registers all new player skin types. (currently only pony and slimpony). * Registers all new player skin types. (currently only pony and slimpony).
*/ */
public void initialisePlayerRenderers(RenderManager manager) { public void initialiseRenderers(EntityRenderDispatcher manager) {
// Preview on the select skin gui // Preview on the select skin gui
MineLPClient.getInstance().getModUtilities().addRenderer(EntityPonyModel.class, new RenderPonyModel(manager)); MineLPClient.getInstance().getModUtilities().addRenderer(EntityPonyModel.class, RenderPonyModel::new);
PlayerModels[] models = PlayerModels.values(); PlayerModels[] models = PlayerModels.values();
for (int i = 1; i < models.length; i++) { for (int i = 1; i < models.length; i++) {
registerPlayerSkin(manager, models[i]); registerPlayerSkin(manager, models[i]);
} }
MobRenderers.registry.forEach(i -> i.apply(this));
} }
private void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) { private void registerPlayerSkin(EntityRenderDispatcher manager, PlayerModels playerModel) {
addPlayerSkin(manager, false, playerModel); addPlayerSkin(manager, false, playerModel);
addPlayerSkin(manager, true, playerModel); addPlayerSkin(manager, true, playerModel);
} }
private void addPlayerSkin(RenderManager manager, boolean slimArms, PlayerModels playerModel) { private void addPlayerSkin(EntityRenderDispatcher manager, boolean slimArms, PlayerModels playerModel) {
RenderPonyPlayer renderer = playerModel.createRenderer(manager, slimArms); RenderPonyPlayer renderer = playerModel.createRenderer(manager, slimArms);
((MixinRenderManager)manager).getMutableSkinMap().put(playerModel.getId(slimArms), renderer); ((MixinRenderManager)manager).getMutableSkinMap().put(playerModel.getId(slimArms), renderer);
} }
/**
* Registers all entity model replacements. (except for players).
*/
public void initializeMobRenderers(RenderManager manager, PonyConfig config) {
for (MobRenderers i : MobRenderers.values()) {
i.apply(this, manager);
}
}
/** /**
* *
* Replaces an entity renderer depending on whether we want ponies or not. * Replaces an entity renderer depending on whether we want ponies or not.
* *
* @param state True if we want ponies (the original will be stored) * @param state True if we want ponies (the original will be stored)
* @param manager The render manager
* @param type The type to replace * @param type The type to replace
* @param renderer The replacement value * @param renderer The replacement value
* @param <T> The entity type * @param <T> The entity type
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Entity, V extends T> void switchRenderer(boolean state, RenderManager manager, Class<V> type, Render<T> renderer) { public <T extends Entity, V extends T> void switchRenderer(boolean state, Class<V> type, Function<EntityRenderDispatcher, EntityRenderer<T>> func) {
if (state) { if (state) {
if (!renderMap.containsKey(type)) { if (!renderMap.containsKey(type)) {
renderMap.put(type, manager.getEntityClassRenderObject(type)); renderMap.put(type, MinecraftClient.getInstance().getEntityRenderManager().getRenderer(type));
} }
MineLPClient.getInstance().getModUtilities().addRenderer((Class<T>)type, renderer); MineLPClient.getInstance().getModUtilities().addRenderer((Class<T>)type, func);
} else { } else {
if (renderMap.containsKey(type)) { if (renderMap.containsKey(type)) {
MineLPClient.getInstance().getModUtilities().addRenderer(type, (Render<V>)renderMap.get(type)); MineLPClient.getInstance().getModUtilities().addRenderer(type, m -> (EntityRenderer<V>)renderMap.get(type));
} }
} }
} }
@ -106,14 +100,14 @@ public class PonyRenderManager {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Nullable @Nullable
public <T extends EntityLivingBase, R extends RenderLivingBase<T> & IRenderPony<T>> R getPonyRenderer(@Nullable Entity entity) { public <T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>, R extends LivingEntityRenderer<T, M> & IPonyRender<T, M>> R getPonyRenderer(@Nullable Entity entity) {
if (entity == null || !(entity instanceof EntityLivingBase)) { if (entity == null || !(entity instanceof LivingEntity)) {
return null; return null;
} }
Render<Entity> renderer = Minecraft.getInstance().getRenderManager().getEntityRenderObject(entity); EntityRenderer<Entity> renderer = MinecraftClient.getInstance().getEntityRenderManager().getRenderer(entity);
if (renderer instanceof RenderLivingBase && renderer instanceof IRenderPony) { if (renderer instanceof IPonyRender) {
return (R)(Object)renderer; return (R)(Object)renderer;
} }

View file

@ -7,14 +7,14 @@ import com.minelittlepony.hdskins.VanillaModels;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import java.util.Map; import java.util.Map;
public class PonySkinParser implements ISkinParser { public class PonySkinParser implements ISkinParser {
@Override @Override
public void parse(GameProfile profile, MinecraftProfileTexture.Type type, ResourceLocation resource, public void parse(GameProfile profile, MinecraftProfileTexture.Type type, Identifier resource,
Map<String, String> metadata) { Map<String, String> metadata) {
if (type == MinecraftProfileTexture.Type.SKIN) { if (type == MinecraftProfileTexture.Type.SKIN) {
boolean slim = VanillaModels.isSlim(metadata.get("model")); boolean slim = VanillaModels.isSlim(metadata.get("model"));

View file

@ -1,6 +1,6 @@
package com.minelittlepony.client.ducks; package com.minelittlepony.client.ducks;
import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.client.texture.NativeImage;
public interface IBufferedTexture { public interface IBufferedTexture {
NativeImage getBufferedImage(); NativeImage getBufferedImage();

View file

@ -1,45 +0,0 @@
package com.minelittlepony.client.ducks;
import com.minelittlepony.client.model.IClientModel;
import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.render.RenderPony;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.util.math.MathUtil;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
/**
* I Render Pony now, oky?
*/
public interface IRenderPony<T extends EntityLivingBase> extends PonyModelConstants {
/**
* Gets the wrapped pony model for this renderer.
*/
ModelWrapper getModelWrapper();
IPony getEntityPony(T entity);
RenderPony<T> getInternalRenderer();
ResourceLocation getTexture(T entity);
/**
* Called by riders to have their transportation adjust their position.
*/
default void translateRider(T entity, IPony entityPony, EntityLivingBase passenger, IPony passengerPony, float ticks) {
if (!passengerPony.getRace(false).isHuman()) {
float yaw = MathUtil.interpolateDegress(entity.prevRenderYawOffset, entity.renderYawOffset, ticks);
getModelWrapper().apply(entityPony.getMetadata());
IClientModel model = getModelWrapper().getBody();
model.transform(BodyPart.BACK);
getInternalRenderer().applyPostureRiding(entity, yaw, ticks);
}
}
}

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.ducks; package com.minelittlepony.client.ducks;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,7 +1,7 @@
package com.minelittlepony.client.gui; package com.minelittlepony.client.gui;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.Screen;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resource.language.I18n;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.render.entities.MobRenderers; import com.minelittlepony.client.render.entities.MobRenderers;
@ -50,16 +50,16 @@ public class GuiPonySettings implements IGuiGuest {
config.setPonyLevel(level); config.setPonyLevel(level);
return (float)level.ordinal(); return (float)level.ordinal();
}) })
.setFormatter(value -> I18n.format(PONY_LEVEL + "." + PonyLevel.valueFor(value).name().toLowerCase()))); .setFormatter(value -> I18n.translate(PONY_LEVEL + "." + PonyLevel.valueFor(value).name().toLowerCase())));
if (GuiScreen.isCtrlKeyDown() && GuiScreen.isShiftKeyDown()) { if (Screen.hasControlDown() && Screen.hasShiftDown()) {
host.addButton(new Label(LEFT, row += 30)).getStyle().setText("minelp.debug.scale"); host.addButton(new Label(LEFT, row += 30)).getStyle().setText("minelp.debug.scale");
host.addButton(new Slider(LEFT, row += 15, 0.1F, 3, config.getGlobalScaleFactor()) host.addButton(new Slider(LEFT, row += 15, 0.1F, 3, config.getGlobalScaleFactor())
.onChange(v -> { .onChange(v -> {
config.setGlobalScaleFactor(v); config.setGlobalScaleFactor(v);
return config.getGlobalScaleFactor(); return config.getGlobalScaleFactor();
}) })
.setFormatter(value -> I18n.format("minelp.debug.scale.value", I18n.format(describeCurrentScale(value))))); .setFormatter(value -> I18n.translate("minelp.debug.scale.value", I18n.translate(describeCurrentScale(value)))));
} }
row += 15; row += 15;
@ -86,26 +86,26 @@ public class GuiPonySettings implements IGuiGuest {
public String describeCurrentScale(float value) { public String describeCurrentScale(float value) {
if (value >= 3) { if (value >= 3) {
return I18n.format("minelp.debug.scale.meg"); return I18n.translate("minelp.debug.scale.meg");
} }
if (value == 2) { if (value == 2) {
return I18n.format("minelp.debug.scale.max"); return I18n.translate("minelp.debug.scale.max");
} }
if (value == 1) { if (value == 1) {
return I18n.format("minelp.debug.scale.mid"); return I18n.translate("minelp.debug.scale.mid");
} }
if (value == 0.9F) { if (value == 0.9F) {
return I18n.format("minelp.debug.scale.sa"); return I18n.translate("minelp.debug.scale.sa");
} }
if (value <= 0.1F) { if (value <= 0.1F) {
return I18n.format("minelp.debug.scale.min"); return I18n.translate("minelp.debug.scale.min");
} }
return String.format("%f", value); return String.format("%f", value);
} }
@Override @Override
public boolean render(GuiHost host, int mouseX, int mouseY, float partialTicks) { public boolean render(GuiHost host, int mouseX, int mouseY, float partialTicks) {
host.drawDefaultBackground(); host.renderBackground();
return true; return true;
} }

View file

@ -4,15 +4,15 @@ import com.minelittlepony.hdskins.gui.EntityPlayerModel;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
/** /**
* Dummy model used for the skin uploading screen. * Dummy model used for the skin uploading screen.
*/ */
public class EntityPonyModel extends EntityPlayerModel { public class EntityPonyModel extends EntityPlayerModel {
public static final ResourceLocation NO_SKIN_PONY = new ResourceLocation("minelittlepony", "textures/mob/noskin.png"); public static final Identifier NO_SKIN_PONY = new Identifier("minelittlepony", "textures/mob/noskin.png");
public static final ResourceLocation NO_SKIN_SEAPONY = new ResourceLocation("minelittlepony", "textures/mob/noskin_seapony.png"); public static final Identifier NO_SKIN_SEAPONY = new Identifier("minelittlepony", "textures/mob/noskin_seapony.png");
public boolean wet = false; public boolean wet = false;
@ -21,7 +21,7 @@ public class EntityPonyModel extends EntityPlayerModel {
} }
@Override @Override
public ResourceLocation getBlankSkin(Type type) { public Identifier getBlankSkin(Type type) {
if (type == Type.SKIN) { if (type == Type.SKIN) {
return wet ? NO_SKIN_SEAPONY : NO_SKIN_PONY; return wet ? NO_SKIN_SEAPONY : NO_SKIN_PONY;
} }

View file

@ -11,10 +11,10 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import net.minecraft.init.Items; import net.minecraft.item.Items;
import net.minecraft.init.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import java.util.List; import java.util.List;
@ -43,8 +43,8 @@ public class GuiSkinsMineLP extends GuiSkins {
} }
@Override @Override
public void initGui() { public void init() {
super.initGui(); super.init();
addButton(new IconicToggle(width - 25, 142)) addButton(new IconicToggle(width - 25, 142))
.setStyles( .setStyles(
@ -56,10 +56,10 @@ public class GuiSkinsMineLP extends GuiSkins {
} }
@Override @Override
protected ResourceLocation getBackground() { protected Identifier getBackground() {
int i = (int)Math.floor(Math.random() * panoramas.length); int i = (int)Math.floor(Math.random() * panoramas.length);
return new ResourceLocation(panoramas[i]); return new Identifier(panoramas[i]);
} }
protected int setWet(int wet) { protected int setWet(int wet) {
@ -85,7 +85,7 @@ public class GuiSkinsMineLP extends GuiSkins {
} }
@Override @Override
public void onSetRemoteSkin(Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) { public void onSetRemoteSkin(Type type, Identifier location, MinecraftProfileTexture profileTexture) {
super.onSetRemoteSkin(type, location, profileTexture); super.onSetRemoteSkin(type, location, profileTexture);
MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin"); MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin");

View file

@ -1,10 +1,11 @@
package com.minelittlepony.client.gui.hdskins; package com.minelittlepony.client.gui.hdskins;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.ducks.IRenderPony; import com.minelittlepony.client.model.ClientPonyModel;
import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.model.races.PlayerModels; import com.minelittlepony.client.model.races.PlayerModels;
import com.minelittlepony.client.pony.Pony; import com.minelittlepony.client.pony.Pony;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.client.render.RenderPony; import com.minelittlepony.client.render.RenderPony;
import com.minelittlepony.client.render.layer.LayerGear; import com.minelittlepony.client.render.layer.LayerGear;
import com.minelittlepony.client.render.layer.LayerPonyElytra; import com.minelittlepony.client.render.layer.LayerPonyElytra;
@ -12,58 +13,57 @@ import com.minelittlepony.hdskins.gui.RenderPlayerModel;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import com.minelittlepony.pony.meta.Race; import com.minelittlepony.pony.meta.Race;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.entity.model.ModelBase; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.model.ModelElytra; import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.renderer.entity.model.ModelPlayer; import net.minecraft.client.render.entity.model.ElytraEntityModel;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.util.Identifier;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
/** /**
* Renderer used for the dummy pony model when selecting a skin. * Renderer used for the dummy pony model when selecting a skin.
*/ */
public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> implements IRenderPony<EntityPonyModel> { public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel, ClientPonyModel<EntityPonyModel>> implements IPonyRender<EntityPonyModel, ClientPonyModel<EntityPonyModel>> {
boolean renderingAsHuman = false; boolean renderingAsHuman = false;
protected final RenderPony<EntityPonyModel> renderPony = new RenderPony<>(this); protected final RenderPony<EntityPonyModel, ClientPonyModel<EntityPonyModel>> renderPony = new RenderPony<>(this);
public RenderPonyModel(RenderManager manager) { public RenderPonyModel(EntityRenderDispatcher manager) {
super(manager); super(manager);
addLayer(new LayerGear<>(this)); addFeature(new LayerGear<>(this));
} }
private ModelWrapper playerModel; private ModelWrapper<EntityPonyModel, ClientPonyModel<EntityPonyModel>> playerModel;
@Override @Override
public ModelWrapper getModelWrapper() { public ModelWrapper<EntityPonyModel, ClientPonyModel<EntityPonyModel>> getModelWrapper() {
return playerModel; return playerModel;
} }
@Override @Override
public IPony getEntityPony(EntityPonyModel entity) { public IPony getEntityPony(EntityPonyModel entity) {
return MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity)); return MineLittlePony.getInstance().getManager().getPony(getTexture(entity));
} }
@Override @Override
protected void preRenderCallback(EntityPonyModel entity, float ticks) { protected void scale(EntityPonyModel entity, float ticks) {
if (renderingAsHuman) { if (renderingAsHuman) {
super.preRenderCallback(entity, ticks); super.scale(entity, ticks);
} else { } else {
renderPony.preRenderCallback(entity, ticks); renderPony.preRenderCallback(entity, ticks);
GlStateManager.translatef(0, 0, -entity.width / 2); // move us to the center of the shadow GlStateManager.translatef(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
} }
} }
@SuppressWarnings("unchecked")
@Override @Override
public ModelPlayer getEntityModel(EntityPonyModel playermodel) { public ClientPonyModel<EntityPonyModel> getEntityModel(EntityPonyModel playermodel) {
renderingAsHuman = true; renderingAsHuman = true;
ResourceLocation loc = getEntityTexture(playermodel); Identifier loc = getTexture(playermodel);
if (loc == null || Pony.getBufferedImage(loc) == null) { if (loc == null || Pony.getBufferedImage(loc) == null) {
return super.getEntityModel(playermodel); return super.getEntityModel(playermodel);
} }
@ -91,9 +91,9 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> implemen
} }
@Override @Override
protected LayerRenderer<? extends EntityLivingBase> getElytraLayer() { protected FeatureRenderer<EntityPonyModel, ClientPonyModel<EntityPonyModel>> getElytraLayer() {
return new LayerPonyElytra<EntityPonyModel>(this) { return new LayerPonyElytra<EntityPonyModel, ClientPonyModel<EntityPonyModel>>(this) {
private final ModelElytra modelElytra = new ModelElytra(); private final ElytraEntityModel<EntityPonyModel> modelElytra = new ElytraEntityModel<>();
@Override @Override
protected void preRenderCallback() { protected void preRenderCallback() {
@ -103,24 +103,24 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> implemen
} }
@Override @Override
protected ModelBase getElytraModel() { protected EntityModel<EntityPonyModel> getElytraModel() {
return renderingAsHuman ? modelElytra : super.getElytraModel(); return renderingAsHuman ? modelElytra : super.getElytraModel();
} }
@Override @Override
protected ResourceLocation getElytraTexture(EntityPonyModel entity) { protected Identifier getElytraTexture(EntityPonyModel entity) {
return entity.getLocal(Type.ELYTRA).getTexture(); return entity.getLocal(Type.ELYTRA).getTexture();
} }
}; };
} }
@Override @Override
public RenderPony<EntityPonyModel> getInternalRenderer() { public RenderPony<EntityPonyModel, ClientPonyModel<EntityPonyModel>> getInternalRenderer() {
return renderPony; return renderPony;
} }
@Override @Override
public ResourceLocation getTexture(EntityPonyModel entity) { public Identifier findTexture(EntityPonyModel entity) {
return getEntityTexture(entity); return getTexture(entity);
} }
} }

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.gui.hdskins; package com.minelittlepony.client.gui.hdskins;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.gui; package com.minelittlepony.client.gui;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -0,0 +1,16 @@
package com.minelittlepony.client.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntitySize;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(Entity.class)
public interface IResizeable {
@Accessor("size")
EntitySize getCurrentSize();
@Accessor("size")
void setCurrentSize(EntitySize size);
}

View file

@ -5,8 +5,8 @@ import com.minelittlepony.client.model.races.PlayerModels;
import com.minelittlepony.pony.IPonyManager; import com.minelittlepony.pony.IPonyManager;
import com.minelittlepony.settings.PonyLevel; import com.minelittlepony.settings.PonyLevel;
import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
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.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@ -14,24 +14,30 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.UUID; import java.util.UUID;
@Mixin(DefaultPlayerSkin.class) @Mixin(DefaultSkinHelper.class)
public abstract class MixinDefaultPlayerSkin { public abstract class MixinDefaultPlayerSkin {
@Inject(method = "getDefaultSkinLegacy", at = @At("HEAD"), cancellable = true) @Inject(method = "getTexture",
private static void legacySkin(CallbackInfoReturnable<ResourceLocation> cir) { at = @At("HEAD"),
cancellable = true)
private static void legacySkin(CallbackInfoReturnable<Identifier> cir) {
if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) { if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) {
cir.setReturnValue(IPonyManager.STEVE); cir.setReturnValue(IPonyManager.STEVE);
} }
} }
@Inject(method = "getDefaultSkin", at = @At("HEAD"), cancellable = true) @Inject(method = "getTexture",
private static void defaultSkin(UUID uuid, CallbackInfoReturnable<ResourceLocation> cir) { at = @At("HEAD"),
cancellable = true)
private static void defaultSkin(UUID uuid, CallbackInfoReturnable<Identifier> cir) {
if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) { if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) {
cir.setReturnValue(IPonyManager.getDefaultSkin(uuid)); cir.setReturnValue(IPonyManager.getDefaultSkin(uuid));
} }
} }
@Inject(method = "getSkinType", at = @At("HEAD"), cancellable = true) @Inject(method = "getModel",
at = @At("HEAD"),
cancellable = true)
private static void skinType(UUID uuid, CallbackInfoReturnable<String> cir) { private static void skinType(UUID uuid, CallbackInfoReturnable<String> cir) {
if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) { if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) {

View file

@ -6,27 +6,27 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import com.minelittlepony.client.PonyRenderManager; import com.minelittlepony.client.PonyRenderManager;
import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.renderer.FirstPersonRenderer; import net.minecraft.client.render.FirstPersonRenderer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it. @SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it.
@Mixin(FirstPersonRenderer.class) @Mixin(FirstPersonRenderer.class)
public class MixinFirstPersonRenderer { public class MixinFirstPersonRenderer {
@Redirect(method = "renderItemInFirstPerson(" @Redirect(method = "renderFirstPersonItem("
+ "Lnet/minecraft/client/entity/AbstractClientPlayer;FF" + "Lnet/minecraft/client/entity/AbstractClientPlayer;FF"
+ "Lnet/minecraft/util/EnumHand;F" + "Lnet/minecraft/util/Hand;F"
+ "Lnet/minecraft/item/ItemStack;F)V", + "Lnet/minecraft/item/ItemStack;F)V",
at = @At(value = "INVOKE", at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/renderer/FirstPersonRenderer;renderItemSide(" target = "Lnet/minecraft/client/render/FirstPersonRenderer;renderItemFromSide("
+ "Lnet/minecraft/entity/EntityLivingBase;" + "Lnet/minecraft/entity/LivingEntity;"
+ "Lnet/minecraft/item/ItemStack;" + "Lnet/minecraft/item/ItemStack;"
+ "Lnet/minecraft/client/renderer/model/ItemCameraTransforms$TransformType;Z)V")) + "Lnet/minecraft/client/render/model/json/ModelTransformation$Type;Z)V"))
private void redirectRenderItemSide(ItemRenderer self, EntityLivingBase entity, ItemStack stack, TransformType transform, boolean left) { private void redirectRenderItemSide(ItemRenderer self, LivingEntity entity, ItemStack stack, ModelTransformation.Type transform, boolean left) {
PonyRenderManager.getInstance().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayer)entity, stack, transform, left); PonyRenderManager.getInstance().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayerEntity)entity, stack, transform, left);
} }
} }

View file

@ -8,14 +8,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.client.render.LevitatingItemRenderer; import com.minelittlepony.client.render.LevitatingItemRenderer;
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer; import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
import net.minecraft.client.renderer.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
@Mixin(GlStateManager.class) @Mixin(GlStateManager.class)
public abstract class MixinGlStateManager { public abstract class MixinGlStateManager {
@Inject(method = "enableBlendProfile(Lnet/minecraft/client/renderer/GlStateManager$Profile;)V", at = @At("HEAD"), cancellable = true) @Inject(method = "setProfile("
private static void enableBlendProfile(GlStateManager.Profile profile, CallbackInfo info) { + "Lcom/mojang/blaze3d/platform/GlStateManager$RenderMode;)V",
if (profile == GlStateManager.Profile.PLAYER_SKIN && PonySkullRenderer.ponyInstance.usesTransparency()) { at = @At("HEAD"),
cancellable = true,
remap = false)
private static void enableBlendProfile(GlStateManager.RenderMode profile, CallbackInfo info) {
if (profile == GlStateManager.RenderMode.PLAYER_SKIN && PonySkullRenderer.ponyInstance.usesTransparency()) {
LevitatingItemRenderer.enableItemGlowRenderProfile(); LevitatingItemRenderer.enableItemGlowRenderProfile();
info.cancel(); info.cancel();
} }

View file

@ -3,10 +3,10 @@ package com.minelittlepony.client.mixin;
import com.minelittlepony.client.ducks.IRenderItem; import com.minelittlepony.client.ducks.IRenderItem;
import com.minelittlepony.client.render.LevitatingItemRenderer; import com.minelittlepony.client.render.LevitatingItemRenderer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.render.model.BakedModel;
import net.minecraft.resources.IResourceManagerReloadListener;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.resource.SynchronousResourceReloadListener;
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.At;
@ -14,9 +14,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@SuppressWarnings("deprecation") // IResourceManagerReloadListener is deprecated by forge but it's part of the signature. We can't remove it.
@Mixin(ItemRenderer.class) @Mixin(ItemRenderer.class)
public abstract class MixinItemRenderer implements IResourceManagerReloadListener, IRenderItem { public abstract class MixinItemRenderer implements SynchronousResourceReloadListener, IRenderItem {
private boolean transparency; private boolean transparency;
@ -25,23 +24,34 @@ public abstract class MixinItemRenderer implements IResourceManagerReloadListene
this.transparency = transparency; this.transparency = transparency;
} }
@Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/renderer/block/model/IBakedModel;)V", at = @At("HEAD")) @Inject(method = "renderItemAndGlow("
private void onRenderItem(ItemStack stack, IBakedModel model, CallbackInfo info) { + "Lnet/minecraft/item/ItemStack;"
+ "Lnet/minecraft/client/render/model/BakedModel;)V",
at = @At("HEAD"))
private void onRenderItem(ItemStack stack, BakedModel model, CallbackInfo info) {
if (transparency) { if (transparency) {
LevitatingItemRenderer.enableItemGlowRenderProfile(); LevitatingItemRenderer.enableItemGlowRenderProfile();
} }
} }
@ModifyArg(method = "renderQuads(Lnet/minecraft/client/renderer/BufferBuilder;Ljava/util/List;ILnet/minecraft/item/ItemStack;)V", @ModifyArg(method = "renderQuads("
+ "Lnet/minecraft/client/render/BufferBuilder;"
+ "Ljava/util/List;I"
+ "Lnet/minecraft/item/ItemStack;)V",
at = @At(value = "INVOKE", at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/renderer/RenderItem;renderQuad(Lnet/minecraft/client/renderer/BufferBuilder;Lnet/minecraft/client/renderer/block/model/BakedQuad;I)V"), target = "Lnet/minecraft/client/render/item/ItemRenderer;renderQuad("
+ "Lnet/minecraft/client/render/BufferBuilder;"
+ "Lnet/minecraft/client/render/model/BakedQuad;I)V"),
index = 2) index = 2)
private int modifyItemRenderTint(int color) { private int modifyItemRenderTint(int color) {
return transparency ? -1 : color; return transparency ? -1 : color;
} }
@Inject(method = "renderEffect(Lnet/minecraft/client/renderer/block/model/IBakedModel;)V", at = @At("HEAD"), cancellable = true) @Inject(method = "renderEffect("
private void renderEffect(IBakedModel model, CallbackInfo info) { + "Lnet/minecraft/client/render/model/BakedModel;)V",
at = @At("HEAD"),
cancellable = true)
private void renderEffect(BakedModel model, CallbackInfo info) {
if (transparency) { if (transparency) {
info.cancel(); info.cancel();
} }

View file

@ -5,12 +5,11 @@ import java.util.Map;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.client.render.entity.PlayerEntityRenderer;
@Mixin(RenderManager.class) @Mixin(EntityRenderDispatcher.class)
public interface MixinRenderManager { public interface MixinRenderManager {
// There is a method to get it, but it's made immutable my Forge. @Accessor("modelRenderers")
@Accessor("skinMap") Map<String, PlayerEntityRenderer> getMutableSkinMap();
Map<String, RenderPlayer> getMutableSkinMap();
} }

View file

@ -1,8 +1,8 @@
package com.minelittlepony.client.mixin; package com.minelittlepony.client.mixin;
import net.minecraft.client.renderer.texture.ThreadDownloadImageData; import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.client.texture.PlayerSkinTexture;
import net.minecraft.client.renderer.texture.SimpleTexture; import net.minecraft.client.texture.ResourceTexture;
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.At;
@ -10,19 +10,20 @@ import org.spongepowered.asm.mixin.injection.Inject;
import com.minelittlepony.client.ducks.IBufferedTexture; import com.minelittlepony.client.ducks.IBufferedTexture;
@Mixin(ThreadDownloadImageData.class) @Mixin(PlayerSkinTexture.class)
public abstract class MixinThreadDownloadImageData extends SimpleTexture implements IBufferedTexture { public abstract class MixinThreadDownloadImageData extends ResourceTexture implements IBufferedTexture {
MixinThreadDownloadImageData() {super(null);} MixinThreadDownloadImageData() {super(null);}
private NativeImage cachedImage; private NativeImage cachedImage;
@Override @Override
public NativeImage getBufferedImage() { public NativeImage getBufferedImage() {
return cachedImage; return cachedImage;
} }
@Inject(method = "setImage(Lnet/minecraft/client/renderer/texture/NativeImage;)V", @Inject(method = "method_4534("
+ "Lnet/minecraft/client/texture/NativeImage;)V",
at = @At("HEAD")) at = @At("HEAD"))
private void onSetImage(NativeImage nativeImageIn) { private void onSetImage(NativeImage nativeImageIn) {
cachedImage = nativeImageIn; cachedImage = nativeImageIn;

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.mixin; package com.minelittlepony.client.mixin;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -11,31 +11,28 @@ import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPart; import com.minelittlepony.model.IPart;
import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.model.armour.IEquestrianArmour;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import com.minelittlepony.pony.IPonyData; import com.minelittlepony.pony.IPonyData;
import com.minelittlepony.pony.meta.Size; import com.minelittlepony.pony.meta.Size;
import com.minelittlepony.util.math.MathUtil; import com.minelittlepony.util.math.MathUtil;
import net.minecraft.client.renderer.entity.model.ModelBase; import net.minecraft.client.model.Cuboid;
import net.minecraft.client.renderer.entity.model.ModelPlayer; import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.renderer.entity.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.LivingEntity;
import net.minecraft.util.EnumHandSide; import net.minecraft.util.AbsoluteHand;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import java.util.Random;
import java.util.UUID; import java.util.UUID;
import static net.minecraft.client.renderer.GlStateManager.*; import static com.mojang.blaze3d.platform.GlStateManager.*;
/** /**
* Foundation class for all types of ponies. * Foundation class for all types of ponies.
*/ */
public abstract class AbstractPonyModel extends ModelPlayer implements IClientModel, PonyModelConstants { public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPonyModel<T> {
public boolean isSleeping; public boolean isSleeping;
public boolean isFlying; public boolean isFlying;
@ -76,14 +73,15 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
@Override @Override
public IEquestrianArmour<?> createArmour() { public IEquestrianArmour<?> createArmour() {
return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor()); return new PonyArmor<>(new ModelPonyArmor<>(), new ModelPonyArmor<>());
} }
/** /**
* Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast. * Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast.
*/ */
private void checkRainboom(Entity entity, float swing) { private void checkRainboom(T entity, float swing) {
double zMotion = Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ); Vec3d motion = entity.getVelocity();
double zMotion = Math.sqrt(motion.x * motion.x + motion.z * motion.z);
rainboom = (isFlying() && canFly()) || isElytraFlying(); rainboom = (isFlying() && canFly()) || isElytraFlying();
rainboom &= zMotion > 0.4F; rainboom &= zMotion > 0.4F;
@ -91,17 +89,17 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
motionLerp = MathUtil.clampLimit(zMotion * 30, 1); motionLerp = MathUtil.clampLimit(zMotion * 30, 1);
} }
public void updateLivingState(EntityLivingBase entity, IPony pony) { public void updateLivingState(T entity, IPony pony) {
isChild = entity.isChild(); isChild = entity.isBaby();
isSneak = entity.isSneaking(); isSneaking = entity.isSneaking();
isCrouching = pony.isCrouching(entity); isCrouching = pony.isCrouching(entity);
isSleeping = entity.isPlayerSleeping(); isSleeping = entity.isSleeping();
isFlying = pony.isFlying(entity); isFlying = pony.isFlying(entity);
isElytraFlying = entity.isElytraFlying(); isElytraFlying = entity.isFallFlying();
isSwimming = pony.isSwimming(entity); isSwimming = pony.isSwimming(entity);
headGear = pony.isWearingHeadgear(entity); headGear = pony.isWearingHeadgear(entity);
isRidingInteractive = pony.isRidingInteractive(entity); isRidingInteractive = pony.isRidingInteractive(entity);
interpolatorId = entity.getUniqueID(); interpolatorId = entity.getUuid();
} }
/** /**
@ -116,12 +114,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* @param entity The entity we're being called for. * @param entity The entity we're being called for.
*/ */
@Override @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
checkRainboom(entity, swing); checkRainboom(entity, swing);
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
float headRotateAngleY = isSleeping() ? (Math.abs(entity.getUniqueID().getMostSignificantBits()) % 2.8F) - 1.9F : headYaw / 57.29578F; float headRotateAngleY = isSleeping() ? (Math.abs(entity.getUuid().getMostSignificantBits()) % 2.8F) - 1.9F : headYaw / 57.29578F;
float headRotateAngleX = isSleeping() ? 0.1f : headPitch / 57.29578F; float headRotateAngleX = isSleeping() ? 0.1f : headPitch / 57.29578F;
headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch))); headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch)));
@ -144,8 +142,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
} else { } else {
adjustBody(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); adjustBody(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; rightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; leftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
swingArms(ticks); swingArms(ticks);
setHead(0, 0, 0); setHead(0, 0, 0);
} }
@ -162,11 +160,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
@Override @Override
public float getWobbleAmount() { public float getWobbleAmount() {
if (swingProgress <= 0) { if (getSwingAmount() <= 0) {
return 0; return 0;
} }
return MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.04F; return MathHelper.sin(MathHelper.sqrt(getSwingAmount()) * PI * 2) * 0.04F;
} }
/** /**
@ -176,26 +174,26 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
adjustBody(BODY_ROT_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); adjustBody(BODY_ROT_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
setHead(0, 6, -2); setHead(0, 6, -2);
bipedRightArm.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ; rightArm.pitch -= LEG_ROT_X_SNEAK_ADJ;
bipedLeftArm.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ; leftArm.pitch -= LEG_ROT_X_SNEAK_ADJ;
bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; leftLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; rightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
} }
protected void ponySleep() { protected void ponySleep() {
bipedRightArm.rotateAngleX = ROTATE_270; rightArm.pitch = ROTATE_270;
bipedLeftArm.rotateAngleX = ROTATE_270; leftArm.pitch = ROTATE_270;
bipedRightLeg.rotateAngleX = ROTATE_90; rightLeg.pitch = ROTATE_90;
bipedLeftLeg.rotateAngleX = ROTATE_90; leftLeg.pitch = ROTATE_90;
setHead(1, 2, isSneak ? -1 : 1); setHead(1, 2, isSneaking ? -1 : 1);
AbstractRenderer.shiftRotationPoint(bipedRightArm, 0, 2, 6); AbstractRenderer.shiftRotationPoint(rightArm, 0, 2, 6);
AbstractRenderer.shiftRotationPoint(bipedLeftArm, 0, 2, 6); AbstractRenderer.shiftRotationPoint(leftArm, 0, 2, 6);
AbstractRenderer.shiftRotationPoint(bipedRightLeg, 0, 2, -8); AbstractRenderer.shiftRotationPoint(rightLeg, 0, 2, -8);
AbstractRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8); AbstractRenderer.shiftRotationPoint(leftLeg, 0, 2, -8);
} }
protected void ponyRide() { protected void ponyRide() {
@ -209,37 +207,37 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
setHead(0, 0, 0); setHead(0, 0, 0);
} }
bipedLeftLeg.rotationPointZ = 15; leftLeg.rotationPointZ = 15;
bipedLeftLeg.rotationPointY = 9; leftLeg.rotationPointY = 9;
bipedLeftLeg.rotateAngleX = -PI / 4; leftLeg.pitch = -PI / 4;
bipedLeftLeg.rotateAngleY = -PI / 5; leftLeg.yaw = -PI / 5;
bipedRightLeg.rotationPointZ = 15; rightLeg.rotationPointZ = 15;
bipedRightLeg.rotationPointY = 9; rightLeg.rotationPointY = 9;
bipedRightLeg.rotateAngleX = -PI / 4; rightLeg.pitch = -PI / 4;
bipedRightLeg.rotateAngleY = PI / 5; rightLeg.yaw = PI / 5;
bipedLeftArm.rotateAngleZ = -PI * 0.06f; leftArm.roll = -PI * 0.06f;
bipedRightArm.rotateAngleZ = PI * 0.06f; rightArm.roll = PI * 0.06f;
if (isRidingInteractive) { if (isRidingInteractive) {
bipedLeftLeg.rotateAngleY = PI / 15; leftLeg.yaw = PI / 15;
bipedLeftLeg.rotateAngleX = PI / 9; leftLeg.pitch = PI / 9;
bipedLeftLeg.rotationPointZ = 10; leftLeg.rotationPointZ = 10;
bipedLeftLeg.rotationPointY = 7; leftLeg.rotationPointY = 7;
bipedRightLeg.rotateAngleY = -PI / 15; rightLeg.yaw = -PI / 15;
bipedRightLeg.rotateAngleX = PI / 9; rightLeg.pitch = PI / 9;
bipedRightLeg.rotationPointZ = 10; rightLeg.rotationPointZ = 10;
bipedRightLeg.rotationPointY = 7; rightLeg.rotationPointY = 7;
bipedLeftArm.rotateAngleX = PI / 6; leftArm.pitch = PI / 6;
bipedRightArm.rotateAngleX = PI / 6; rightArm.pitch = PI / 6;
bipedLeftArm.rotateAngleZ *= 2; leftArm.roll *= 2;
bipedRightArm.rotateAngleZ *= 2; rightArm.roll *= 2;
} }
} }
@ -254,22 +252,22 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
protected void shakeBody(float move, float swing, float bodySwing, float ticks) { protected void shakeBody(float move, float swing, float bodySwing, float ticks) {
tail.setRotationAndAngles(isSwimming() || rainboom, interpolatorId, move, swing, bodySwing * 5, ticks); tail.setRotationAndAngles(isSwimming() || rainboom, interpolatorId, move, swing, bodySwing * 5, ticks);
upperTorso.rotateAngleY = bodySwing; upperTorso.yaw = bodySwing;
bipedBody.rotateAngleY = bodySwing; body.yaw = bodySwing;
neck.rotateAngleY = bodySwing; neck.yaw = bodySwing;
} }
private void animateWears() { private void animateWears() {
copyModelAngles(bipedLeftArm, bipedLeftArmwear); leftArmOverlay.copyRotation(leftArm);
copyModelAngles(bipedRightArm, bipedRightArmwear); rightArmOverlay.copyRotation(rightArm);
copyModelAngles(bipedLeftLeg, bipedLeftLegwear); leftLegOverlay.copyRotation(leftLeg);
copyModelAngles(bipedRightLeg, bipedRightLegwear); rightLegOverlay.copyRotation(rightLeg);
copyModelAngles(bipedBody, bipedBodyWear); bodyOverlay.copyRotation(body);
} }
@Override @Override
public ModelRenderer getHead() { public Cuboid getHead() {
return bipedHead; return head;
} }
@Override @Override
@ -286,8 +284,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* Sets the head rotation point. * Sets the head rotation point.
*/ */
protected void setHead(float posX, float posY, float posZ) { protected void setHead(float posX, float posY, float posZ) {
bipedHead.setRotationPoint(posX, posY, posZ); head.setRotationPoint(posX, posY, posZ);
bipedHeadwear.setRotationPoint(posX, posY, posZ); headwear.setRotationPoint(posX, posY, posZ);
} }
/** /**
@ -297,8 +295,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* @param y New rotation Y * @param y New rotation Y
*/ */
protected void updateHeadRotation(float x, float y) { protected void updateHeadRotation(float x, float y) {
bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = y; headwear.yaw = head.yaw = y;
bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = x; headwear.pitch = head.pitch = x;
} }
/** /**
@ -308,7 +306,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles} * Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
* *
*/ */
protected void rotateLegs(float move, float swing, float ticks, Entity entity) { protected void rotateLegs(float move, float swing, float ticks, T entity) {
if (isSwimming()) { if (isSwimming()) {
rotateLegsSwimming(move, swing, ticks, entity); rotateLegsSwimming(move, swing, ticks, entity);
} else if (isGoingFast()) { } else if (isGoingFast()) {
@ -317,29 +315,29 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
rotateLegsOnGround(move, swing, ticks, entity); rotateLegsOnGround(move, swing, ticks, entity);
} }
float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; float sin = MathHelper.sin(body.yaw) * 5;
float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; float cos = MathHelper.cos(body.yaw) * 5;
float spread = getLegSpread(); float spread = getLegSpread();
bipedRightArm.rotationPointZ = spread + sin; rightArm.rotationPointZ = spread + sin;
bipedLeftArm.rotationPointZ = spread - sin; leftArm.rotationPointZ = spread - sin;
float legRPX = cos - getLegOutset() - 0.001F; float legRPX = cos - getLegOutset() - 0.001F;
legRPX = metadata.getInterpolator(entity.getUniqueID()).interpolate("legOffset", legRPX, 3); legRPX = metadata.getInterpolator(entity.getUuid()).interpolate("legOffset", legRPX, 3);
bipedRightArm.rotationPointX = -legRPX; rightArm.rotationPointX = -legRPX;
bipedRightLeg.rotationPointX = -legRPX; rightLeg.rotationPointX = -legRPX;
bipedLeftArm.rotationPointX = legRPX; leftArm.rotationPointX = legRPX;
bipedLeftLeg.rotationPointX = legRPX; leftLeg.rotationPointX = legRPX;
bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; rightArm.yaw += body.yaw;
bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; leftArm.yaw += body.yaw;
bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8; rightArm.rotationPointY = leftArm.rotationPointY = 8;
bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; rightLeg.rotationPointZ = leftLeg.rotationPointZ = 10;
} }
/** /**
@ -351,26 +349,26 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* @param entity The entity we're being called for. * @param entity The entity we're being called for.
* *
*/ */
protected void rotateLegsSwimming(float move, float swing, float ticks, Entity entity) { protected void rotateLegsSwimming(float move, float swing, float ticks, T entity) {
float legLeft = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI/3) / 2) * (float)motionLerp; float legLeft = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI/3) / 2) * (float)motionLerp;
float left = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI) / 2) * (float)motionLerp; float left = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI) / 2) * (float)motionLerp;
float right = (ROTATE_90 + MathHelper.sin(move / 3) / 2) * (float)motionLerp; float right = (ROTATE_90 + MathHelper.sin(move / 3) / 2) * (float)motionLerp;
bipedLeftArm.rotateAngleX = -left; leftArm.pitch = -left;
bipedLeftArm.rotateAngleY = -left/2; leftArm.yaw = -left/2;
bipedLeftArm.rotateAngleZ = left/2; leftArm.roll = left/2;
bipedRightArm.rotateAngleX = -right; rightArm.pitch = -right;
bipedRightArm.rotateAngleY = right/2; rightArm.yaw = right/2;
bipedRightArm.rotateAngleZ = -right/2; rightArm.roll = -right/2;
bipedLeftLeg.rotateAngleX = legLeft; leftLeg.pitch = legLeft;
bipedRightLeg.rotateAngleX = right; rightLeg.pitch = right;
bipedLeftLeg.rotateAngleY = 0; leftLeg.yaw = 0;
bipedRightLeg.rotateAngleY = 0; rightLeg.yaw = 0;
} }
/** /**
@ -386,20 +384,20 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
float armX = rainboom ? ROTATE_270 : MathHelper.sin(-swing / 2); float armX = rainboom ? ROTATE_270 : MathHelper.sin(-swing / 2);
float legX = rainboom ? ROTATE_90 : MathHelper.sin(swing / 2); float legX = rainboom ? ROTATE_90 : MathHelper.sin(swing / 2);
bipedLeftArm.rotateAngleX = armX; leftArm.pitch = armX;
bipedRightArm.rotateAngleX = armX; rightArm.pitch = armX;
bipedLeftLeg.rotateAngleX = legX; leftLeg.pitch = legX;
bipedRightLeg.rotateAngleX = legX; rightLeg.pitch = legX;
bipedLeftArm.rotateAngleY = -0.2F; leftArm.yaw = -0.2F;
bipedLeftLeg.rotateAngleY = 0.2F; leftLeg.yaw = 0.2F;
bipedRightArm.rotateAngleY = 0.2F; rightArm.yaw = 0.2F;
bipedRightLeg.rotateAngleY = -0.2F; rightLeg.yaw = -0.2F;
bipedRightArm.rotateAngleZ = 0; rightArm.roll = 0;
bipedLeftArm.rotateAngleZ = 0; leftArm.roll = 0;
} }
/** /**
@ -411,26 +409,26 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* @param entity The entity we're being called for. * @param entity The entity we're being called for.
* *
*/ */
protected void rotateLegsOnGround(float move, float swing, float ticks, Entity entity) { protected void rotateLegsOnGround(float move, float swing, float ticks, T entity) {
float angle = PI * (float) Math.pow(swing, 16); float angle = PI * (float) Math.pow(swing, 16);
float baseRotation = move * 0.6662F; // magic number ahoy float baseRotation = move * 0.6662F; // magic number ahoy
float scale = swing / 4; float scale = swing / 4;
bipedLeftArm.rotateAngleX = MathHelper.cos(baseRotation + angle) * scale; leftArm.pitch = MathHelper.cos(baseRotation + angle) * scale;
bipedRightArm.rotateAngleX = MathHelper.cos(baseRotation + PI + angle / 2) * scale; rightArm.pitch = MathHelper.cos(baseRotation + PI + angle / 2) * scale;
bipedLeftLeg.rotateAngleX = MathHelper.cos(baseRotation + PI - (angle * 0.4f)) * scale; leftLeg.pitch = MathHelper.cos(baseRotation + PI - (angle * 0.4f)) * scale;
bipedRightLeg.rotateAngleX = MathHelper.cos(baseRotation + angle / 5) * scale; rightLeg.pitch = MathHelper.cos(baseRotation + angle / 5) * scale;
bipedLeftArm.rotateAngleY = 0; leftArm.yaw = 0;
bipedRightArm.rotateAngleY = 0; rightArm.yaw = 0;
bipedLeftLeg.rotateAngleY = 0; leftLeg.yaw = 0;
bipedRightLeg.rotateAngleY = 0; rightLeg.yaw = 0;
bipedRightArm.rotateAngleZ = 0; rightArm.roll = 0;
bipedLeftArm.rotateAngleZ = 0; leftArm.roll = 0;
} }
protected float getLegOutset() { protected float getLegOutset() {
@ -457,19 +455,19 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
protected void holdItem(float swing) { protected void holdItem(float swing) {
boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM;
alignArmForAction(bipedLeftArm, leftArmPose, rightArmPose, both, swing, 1); alignArmForAction(leftArm, leftArmPose, rightArmPose, both, swing, 1);
alignArmForAction(bipedRightArm, rightArmPose, leftArmPose, both, swing, -1); alignArmForAction(rightArm, rightArmPose, leftArmPose, both, swing, -1);
} }
@Override @Override
public ModelRenderer getBodyPart(BodyPart part) { public Cuboid getBodyPart(BodyPart part) {
switch (part) { switch (part) {
default: default:
case HEAD: return bipedHead; case HEAD: return head;
case NECK: return neck; case NECK: return neck;
case TAIL: case TAIL:
case LEGS: case LEGS:
case BODY: return bipedBody; case BODY: return body;
} }
} }
@ -481,7 +479,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* @param both True if we have something in both hands * @param both True if we have something in both hands
* @param swing Degree to which each 'limb' swings. * @param swing Degree to which each 'limb' swings.
*/ */
protected void alignArmForAction(ModelRenderer arm, ArmPose pose, ArmPose complement, boolean both, float swing, float reflect) { protected void alignArmForAction(Cuboid arm, ArmPose pose, ArmPose complement, boolean both, float swing, float reflect) {
switch (pose) { switch (pose) {
case ITEM: case ITEM:
float swag = 1; float swag = 1;
@ -489,19 +487,19 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
swag -= (float)Math.pow(swing, 2); swag -= (float)Math.pow(swing, 2);
} }
float mult = 1 - swag/2; float mult = 1 - swag/2;
arm.rotateAngleX = arm.rotateAngleX * mult - (PI / 10) * swag; arm.pitch = arm.pitch * mult - (PI / 10) * swag;
arm.rotateAngleZ = -reflect * (PI / 15); arm.roll = -reflect * (PI / 15);
if (isCrouching()) { if (isCrouching()) {
arm.rotationPointX -= reflect * 2; arm.rotationPointX -= reflect * 2;
} }
case EMPTY: case EMPTY:
arm.rotateAngleY = 0; arm.yaw = 0;
break; break;
case BLOCK: case BLOCK:
arm.rotateAngleX = (arm.rotateAngleX / 2 - 0.9424779F) - 0.3F; arm.pitch = (arm.pitch / 2 - 0.9424779F) - 0.3F;
arm.rotateAngleY = reflect * PI / 9; arm.yaw = reflect * PI / 9;
if (complement == pose) { if (complement == pose) {
arm.rotateAngleY -= reflect * PI / 18; arm.yaw -= reflect * PI / 18;
} }
arm.rotationPointX += reflect; arm.rotationPointX += reflect;
arm.rotationPointZ += 3; arm.rotationPointZ += 3;
@ -516,12 +514,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
} }
} }
protected void aimBow(ModelRenderer arm, float ticks) { protected void aimBow(Cuboid arm, float ticks) {
arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX + (MathHelper.sin(ticks * 0.067F) * 0.05F); arm.pitch = ROTATE_270 + head.pitch + (MathHelper.sin(ticks * 0.067F) * 0.05F);
arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; arm.yaw = head.yaw - 0.06F;
arm.rotateAngleZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; arm.roll = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
if (isSneak) { if (isSneaking) {
arm.rotationPointY += 4; arm.rotationPointY += 4;
} }
} }
@ -532,11 +530,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* *
* @param entity The entity we are being called for. * @param entity The entity we are being called for.
*/ */
protected void swingItem(Entity entity) { protected void swingItem(T entity) {
if (swingProgress > 0 && !isSleeping()) { if (getSwingAmount() > 0 && !isSleeping()) {
EnumHandSide mainSide = getMainHand(entity); AbsoluteHand mainSide = getPreferedHand(entity);
swingArm(getArmForSide(mainSide)); swingArm(getArm(mainSide));
} }
} }
@ -545,17 +543,17 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* *
* @param arm The arm to swing * @param arm The arm to swing
*/ */
protected void swingArm(ModelRenderer arm) { protected void swingArm(Cuboid arm) {
float swing = 1 - (float)Math.pow(1 - swingProgress, 3); float swing = 1 - (float)Math.pow(1 - getSwingAmount(), 3);
float deltaX = MathHelper.sin(swing * PI); float deltaX = MathHelper.sin(swing * PI);
float deltaZ = MathHelper.sin(swingProgress * PI); float deltaZ = MathHelper.sin(getSwingAmount() * PI);
float deltaAim = deltaZ * (0.7F - bipedHead.rotateAngleX) * 0.75F; float deltaAim = deltaZ * (0.7F - head.pitch) * 0.75F;
arm.rotateAngleX -= deltaAim + deltaX * 1.2F; arm.pitch -= deltaAim + deltaX * 1.2F;
arm.rotateAngleY += bipedBody.rotateAngleY * 2; arm.yaw += body.yaw * 2;
arm.rotateAngleZ = -deltaZ * 0.4F; arm.roll = -deltaZ * 0.4F;
} }
/** /**
@ -572,13 +570,13 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
float sin = MathHelper.sin(ticks * 0.067F) * 0.05F; float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
if (rightArmPose != ArmPose.EMPTY) { if (rightArmPose != ArmPose.EMPTY) {
bipedRightArm.rotateAngleZ += cos; rightArm.roll += cos;
bipedRightArm.rotateAngleX += sin; rightArm.pitch += sin;
} }
if (leftArmPose != ArmPose.EMPTY) { if (leftArmPose != ArmPose.EMPTY) {
bipedLeftArm.rotateAngleZ += cos; leftArm.roll += cos;
bipedLeftArm.rotateAngleX += sin; leftArm.pitch += sin;
} }
} }
@ -588,11 +586,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
} }
protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) { protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) {
bipedBody.rotateAngleX = rotateAngleX; body.pitch = rotateAngleX;
bipedBody.rotationPointY = rotationPointY; body.rotationPointY = rotationPointY;
bipedBody.rotationPointZ = rotationPointZ; body.rotationPointZ = rotationPointZ;
upperTorso.rotateAngleX = rotateAngleX; upperTorso.pitch = rotateAngleX;
upperTorso.rotationPointY = rotationPointY; upperTorso.rotationPointY = rotationPointY;
upperTorso.rotationPointZ = rotationPointZ; upperTorso.rotationPointZ = rotationPointZ;
} }
@ -603,7 +601,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
@Override @Override
public void init(float yOffset, float stretch) { public void init(float yOffset, float stretch) {
boxList.clear(); cuboidList.clear();
initHead(yOffset, stretch); initHead(yOffset, stretch);
initBody(yOffset, stretch); initBody(yOffset, stretch);
@ -612,13 +610,13 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
} }
protected void initHead(float yOffset, float stretch) { protected void initHead(float yOffset, float stretch) {
bipedHead = new PonyRenderer(this, 0, 0) head = new PonyRenderer(this, 0, 0)
.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) .offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2)
.box(-4, -4, -4, 8, 8, 8, stretch); .box(-4, -4, -4, 8, 8, 8, stretch);
initEars(((PonyRenderer)bipedHead), yOffset, stretch); initEars(((PonyRenderer)head), yOffset, stretch);
bipedHeadwear = new PonyRenderer(this, 32, 0) headwear = new PonyRenderer(this, 32, 0)
.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) .offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2)
.box(-4, -4, -4, 8, 8, 8, stretch + 0.7504F); .box(-4, -4, -4, 8, 8, 8, stretch + 0.7504F);
@ -643,15 +641,16 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
*/ */
protected void initBody(float yOffset, float stretch) { protected void initBody(float yOffset, float stretch) {
if (textureHeight == 64) { if (textureHeight == 64) {
bipedBodyWear = new ModelRenderer(this, 16, 32); bodyOverlay.boxes.clear();
cuboidList.add(bodyOverlay);
} }
bipedBody = new PonyRenderer(this, 16, 16) body = new PonyRenderer(this, 16, 16)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.box(-4, 4, -2, 8, 8, 4, stretch); .box(-4, 4, -2, 8, 8, 4, stretch);
bipedBodyWear.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F); bodyOverlay.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F);
bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); bodyOverlay.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
upperTorso = new PlaneRenderer(this, 24, 0); upperTorso = new PlaneRenderer(this, 24, 0);
upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z) upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z)
@ -684,19 +683,27 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
} }
protected void preInitLegs() { protected void preInitLegs() {
bipedLeftArm = new ModelRenderer(this, 32, 48); leftArm = new Cuboid(this, 32, 48);
bipedRightArm = new ModelRenderer(this, 40, 16); rightArm = new Cuboid(this, 40, 16);
bipedLeftLeg = new ModelRenderer(this, 16, 48); leftLeg = new Cuboid(this, 16, 48);
bipedRightLeg = new ModelRenderer(this, 0, 16); rightLeg = new Cuboid(this, 0, 16);
} }
protected void preInitLegwear() { protected void preInitLegwear() {
bipedLeftArmwear = new ModelRenderer(this, 48, 48); leftArmOverlay.boxes.clear();
bipedRightArmwear = new ModelRenderer(this, 40, 32); cuboidList.add(leftArmOverlay);
bipedLeftLegwear = new ModelRenderer(this, 0, 48); rightArmOverlay.boxes.clear();
bipedRightLegwear = new ModelRenderer(this, 0, 32); cuboidList.add(rightArmOverlay);
leftLegOverlay.boxes.clear();
cuboidList.add(leftLegOverlay);
leftLegOverlay.setTextureOffset(0, 48);
rightLegOverlay.boxes.clear();
cuboidList.add(rightLegOverlay);
rightLegOverlay.setTextureOffset(0, 32);
} }
protected void initLegs(float yOffset, float stretch) { protected void initLegs(float yOffset, float stretch) {
@ -714,29 +721,29 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
float armY = THIRDP_ARM_CENTRE_Y; float armY = THIRDP_ARM_CENTRE_Y;
float armZ = BODY_CENTRE_Z / 2 - 1 - armDepth; float armZ = BODY_CENTRE_Z / 2 - 1 - armDepth;
bipedLeftArm .addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch); leftArm .addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch);
bipedRightArm.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch); rightArm.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch);
bipedLeftLeg .addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch); leftLeg .addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch);
bipedRightLeg.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch); rightLeg.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch);
bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); leftArm .setRotationPoint( rarmX, yOffset + rarmY, 0);
bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); rightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0);
bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0); leftLeg .setRotationPoint( rarmX, yOffset, 0);
bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0); rightLeg.setRotationPoint(-rarmX, yOffset, 0);
bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); leftArmOverlay.addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f);
bipedLeftArmwear.setRotationPoint(rarmX, yOffset + rarmY, 0); leftArmOverlay.setRotationPoint(rarmX, yOffset + rarmY, 0);
bipedRightArmwear.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); rightArmOverlay.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f);
bipedRightArmwear.setRotationPoint(-rarmX, yOffset + rarmY, 0); rightArmOverlay.setRotationPoint(-rarmX, yOffset + rarmY, 0);
bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); leftArmOverlay.addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f);
bipedRightLegwear.setRotationPoint(rarmX, yOffset, 0); rightLegOverlay.setRotationPoint(rarmX, yOffset, 0);
bipedRightLegwear.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); rightLegOverlay.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f);
bipedRightLegwear.setRotationPoint(-rarmX, yOffset, 0); rightLegOverlay.setRotationPoint(-rarmX, yOffset, 0);
} }
protected int getArmWidth() { protected int getArmWidth() {
@ -759,8 +766,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
return 8; return 8;
} }
public ArmPose getArmPoseForSide(EnumHandSide side) { public ArmPose getArmPoseForSide(AbsoluteHand side) {
return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose; return side == AbsoluteHand.RIGHT ? rightArmPose : leftArmPose;
} }
@Override @Override
@ -825,7 +832,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
@Override @Override
public float getSwingAmount() { public float getSwingAmount() {
return swingProgress; return handSwingProgress;
} }
@Override @Override
@ -861,7 +868,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}. * @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}.
*/ */
@Override @Override
public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { public void render(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
pushMatrix(); pushMatrix();
transform(BodyPart.HEAD); transform(BodyPart.HEAD);
@ -892,14 +899,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles} * Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
* *
*/ */
protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { protected void renderHead(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
bipedHead.render(scale); head.render(scale);
bipedHeadwear.render(scale); headwear.render(scale);
bipedHead.postRender(scale); head.applyTransform(scale);
} }
protected void renderNeck(float scale) { protected void renderNeck(float scale) {
GlStateManager.scalef(0.9F, 0.9F, 0.9F); scalef(0.9F, 0.9F, 0.9F);
neck.render(scale); neck.render(scale);
} }
@ -910,29 +917,29 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles} * Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
* *
*/ */
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
bipedBody.render(scale); body.render(scale);
if (textureHeight == 64) { if (textureHeight == 64) {
bipedBodyWear.render(scale); bodyOverlay.render(scale);
} }
upperTorso.render(scale); upperTorso.render(scale);
bipedBody.postRender(scale); body.applyTransform(scale);
tail.renderPart(scale, entity.getUniqueID()); tail.renderPart(scale, entity.getUuid());
} }
protected void renderLegs(float scale) { protected void renderLegs(float scale) {
if (!isSneak) bipedBody.postRender(scale); if (!isSneaking) body.applyTransform(scale);
bipedLeftArm.render(scale); leftArm.render(scale);
bipedRightArm.render(scale); rightArm.render(scale);
bipedLeftLeg.render(scale); leftLeg.render(scale);
bipedRightLeg.render(scale); rightLeg.render(scale);
if (textureHeight == 64) { if (textureHeight == 64) {
bipedLeftArmwear.render(scale); leftArmOverlay.render(scale);
bipedRightArmwear.render(scale); rightArmOverlay.render(scale);
bipedLeftLegwear.render(scale); leftLegOverlay.render(scale);
bipedRightLegwear.render(scale); rightArmOverlay.render(scale);
} }
} }
@ -954,10 +961,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
* Copies this model's attributes from some other. * Copies this model's attributes from some other.
*/ */
@Override @Override
public void setModelAttributes(ModelBase model) { public void setAttributes(BipedEntityModel<T> model) {
super.setModelAttributes(model); super.setAttributes(model);
if (model instanceof AbstractPonyModel) { if (model instanceof AbstractPonyModel) {
AbstractPonyModel pony = (AbstractPonyModel) model; AbstractPonyModel<T> pony = (AbstractPonyModel<T>) model;
isFlying = pony.isFlying; isFlying = pony.isFlying;
isCrouching = pony.isCrouching; isCrouching = pony.isCrouching;
isElytraFlying = pony.isElytraFlying; isElytraFlying = pony.isElytraFlying;
@ -969,31 +977,4 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo
rainboom = pony.rainboom; rainboom = pony.rainboom;
} }
} }
@Override
public ModelRenderer getRandomModelBox(Random rand) {
// grab one at random, but cycle through the list until you find one that's filled.
// Return if you find one, or if you get back to where you started in which case there isn't any.
int randomI = rand.nextInt(boxList.size());
int index = randomI;
ModelRenderer result;
do {
result = boxList.get(randomI);
if (!result.cubeList.isEmpty()) return result;
index = (index + 1) % boxList.size();
} while (index != randomI);
if (result.cubeList.isEmpty()) {
result.addBox(0, 0, 0, 0, 0, 0);
}
if (result.cubeList.isEmpty()) {
throw new IllegalStateException("This model contains absolutely no boxes and a box could not be added!");
}
return result;
}
} }

View file

@ -0,0 +1,43 @@
package com.minelittlepony.client.model;
import net.minecraft.client.model.Cuboid;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.entity.LivingEntity;
import com.minelittlepony.model.IPonyModel;
import java.util.Random;
public abstract class ClientPonyModel<T extends LivingEntity> extends PlayerEntityModel<T> implements IPonyModel<T> {
public ClientPonyModel(float float_1, boolean boolean_1) {
super(float_1, boolean_1);
}
@Override
public Cuboid getRandomCuboid(Random rand) {
// grab one at random, but cycle through the list until you find one that's filled.
// Return if you find one, or if you get back to where you started in which case there isn't any.
int randomI = rand.nextInt(cuboidList.size());
int index = randomI;
Cuboid result;
do {
result = cuboidList.get(randomI);
if (!result.boxes.isEmpty()) return result;
index = (index + 1) % cuboidList.size();
} while (index != randomI);
if (result.boxes.isEmpty()) {
result.addBox(0, 0, 0, 0, 0, 0);
}
if (result.boxes.isEmpty()) {
throw new IllegalStateException("This model contains absolutely no boxes and a box could not be added!");
}
return result;
}
}

View file

@ -1,12 +0,0 @@
package com.minelittlepony.client.model;
import net.minecraft.client.renderer.entity.model.ModelRenderer;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.ICapitated;
import com.minelittlepony.model.IModel;
public interface IClientModel extends IModel, ICapitated<ModelRenderer> {
ModelRenderer getBodyPart(BodyPart part);
}

View file

@ -1,6 +1,7 @@
package com.minelittlepony.client.model; package com.minelittlepony.client.model;
import net.minecraft.client.renderer.entity.model.ModelRenderer; import net.minecraft.client.model.Cuboid;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.model.races.ModelAlicorn; import com.minelittlepony.client.model.races.ModelAlicorn;
@ -9,7 +10,7 @@ import com.minelittlepony.client.model.races.ModelAlicorn;
* Common class for all humanoid (ponioid?) non-player enemies. * Common class for all humanoid (ponioid?) non-player enemies.
* *
*/ */
public abstract class ModelMobPony extends ModelAlicorn { public abstract class ModelMobPony<T extends LivingEntity> extends ModelAlicorn<T> {
public ModelMobPony() { public ModelMobPony() {
super(false); super(false);
@ -23,18 +24,18 @@ public abstract class ModelMobPony extends ModelAlicorn {
* @param swingProgress How far we are through the current swing * @param swingProgress How far we are through the current swing
* @param ticks Render partial ticks * @param ticks Render partial ticks
*/ */
protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float ticks) { protected void rotateArmHolding(Cuboid arm, float direction, float swingProgress, float ticks) {
float swing = MathHelper.sin(swingProgress * PI); float swing = MathHelper.sin(swingProgress * PI);
float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PI); float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PI);
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(ticks * 0.067F) / 10; float sin = MathHelper.sin(ticks * 0.067F) / 10;
arm.rotateAngleX = -1.5707964F; arm.pitch = -1.5707964F;
arm.rotateAngleX -= swing * 1.2F - roll * 0.4F; arm.pitch -= swing * 1.2F - roll * 0.4F;
arm.rotateAngleX += sin; arm.pitch += sin;
arm.rotateAngleY = direction * (0.1F - swing * 0.6F); arm.yaw = direction * (0.1F - swing * 0.6F);
arm.rotateAngleZ = cos; arm.roll = cos;
} }
} }

View file

@ -1,6 +1,10 @@
package com.minelittlepony.client.model; package com.minelittlepony.client.model;
import net.minecraft.entity.LivingEntity;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.model.IModel;
import com.minelittlepony.model.armour.IArmour;
import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.model.armour.IEquestrianArmour;
import com.minelittlepony.model.capabilities.IModelWrapper; import com.minelittlepony.model.capabilities.IModelWrapper;
import com.minelittlepony.pony.IPonyData; import com.minelittlepony.pony.IPonyData;
@ -8,9 +12,9 @@ import com.minelittlepony.pony.IPonyData;
/** /**
* Container class for the various models and their associated piece of armour. * Container class for the various models and their associated piece of armour.
*/ */
public class ModelWrapper implements IModelWrapper { public class ModelWrapper<T extends LivingEntity, M extends IModel> implements IModelWrapper {
private final AbstractPonyModel body; private final M body;
private final IEquestrianArmour<?> armor; private final IEquestrianArmour<?> armor;
@ -19,7 +23,7 @@ public class ModelWrapper implements IModelWrapper {
/** /**
* Creates a new model wrapper to contain the given pony. * Creates a new model wrapper to contain the given pony.
*/ */
public ModelWrapper(AbstractPonyModel model) { public ModelWrapper(M model) {
body = model; body = model;
armor = model.createArmour(); armor = model.createArmour();
armor.apply(model.getMetadata()); armor.apply(model.getMetadata());
@ -31,15 +35,16 @@ public class ModelWrapper implements IModelWrapper {
} }
} }
public AbstractPonyModel getBody() { public M getBody() {
return body; return body;
} }
/** /**
* Returns the contained armour model. * Returns the contained armour model.
*/ */
public IEquestrianArmour<?> getArmor() { @SuppressWarnings("unchecked")
return armor; public <V extends IArmour> IEquestrianArmour<V> getArmor() {
return (IEquestrianArmour<V>)armor;
} }
@Override @Override

View file

@ -1,13 +1,14 @@
package com.minelittlepony.client.model.armour; package com.minelittlepony.client.model.armour;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.resources.ResourcePackInfoClient; import net.minecraft.client.resource.ClientResourcePackContainer;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.LivingEntity;
import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.resources.ResourcePackType; import net.minecraft.resource.ResourcePack;
import net.minecraft.util.ResourceLocation; import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.minelittlepony.client.ForgeProxy; import com.minelittlepony.client.ForgeProxy;
@ -19,15 +20,15 @@ import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
public class DefaultPonyArmorTextureResolver<T extends EntityLivingBase> implements IArmourTextureResolver<T> { public class DefaultPonyArmorTextureResolver<T extends LivingEntity> implements IArmourTextureResolver<T> {
private final Map<String, ResourceLocation> HUMAN_ARMOUR = Maps.newHashMap(); private final Map<String, Identifier> HUMAN_ARMOUR = Maps.newHashMap();
private final Map<ResourceLocation, ResourceLocation> PONY_ARMOUR = Maps.newHashMap(); private final Map<Identifier, Identifier> PONY_ARMOUR = Maps.newHashMap();
@Override @Override
public ResourceLocation getArmourTexture(T entity, ItemStack itemstack, EntityEquipmentSlot slot, ArmourLayer layer, @Nullable String type) { public Identifier getArmourTexture(T entity, ItemStack itemstack, EquipmentSlot slot, ArmourLayer layer, @Nullable String type) {
ItemArmor item = (ItemArmor) itemstack.getItem(); ArmorItem item = (ArmorItem) itemstack.getItem();
String texture = item.getArmorMaterial().getName(); String texture = item.getMaterial().getName();
String domain = "minecraft"; String domain = "minecraft";
@ -42,20 +43,21 @@ public class DefaultPonyArmorTextureResolver<T extends EntityLivingBase> impleme
String ponyRes = String.format("%s:textures/models/armor/%s_layer_%s%s.png", domain, texture, layer.name().toLowerCase(), customType); String ponyRes = String.format("%s:textures/models/armor/%s_layer_%s%s.png", domain, texture, layer.name().toLowerCase(), customType);
String oldPonyRes = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, layer == ArmourLayer.INNER ? 2 : 1, customType); String oldPonyRes = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, layer == ArmourLayer.INNER ? 2 : 1, customType);
ResourceLocation human = getArmorTexture(entity, itemstack, ponyRes, slot, type); Identifier human = getArmorTexture(entity, itemstack, ponyRes, slot, type);
ResourceLocation pony = ponifyResource(human); Identifier pony = ponifyResource(human);
ResourceLocation oldHuman = getArmorTexture(entity, itemstack, oldPonyRes, slot, type); Identifier oldHuman = getArmorTexture(entity, itemstack, oldPonyRes, slot, type);
ResourceLocation oldPony = ponifyResource(oldHuman); Identifier oldPony = ponifyResource(oldHuman);
return resolve(pony, oldPony, oldHuman, human); return resolve(pony, oldPony, oldHuman, human);
} }
private ResourceLocation resolve(ResourceLocation... resources) { private Identifier resolve(Identifier... resources) {
// check resource packs for either texture. // check resource packs for either texture.
for (ResourcePackInfoClient entry : Minecraft.getInstance().getResourcePackList().getAllPacks()) { for (ClientResourcePackContainer entry : MinecraftClient.getInstance().getResourcePackContainerManager().getEnabledContainers()) {
for (ResourceLocation candidate : resources) { ResourcePack pack = entry.createResourcePack();
if (entry.getResourcePack().resourceExists(ResourcePackType.CLIENT_RESOURCES, candidate)) { for (Identifier candidate : resources) {
if (pack.contains(ResourceType.CLIENT_RESOURCES, candidate)) {
// ponies are more important // ponies are more important
return candidate; return candidate;
} }
@ -63,9 +65,9 @@ public class DefaultPonyArmorTextureResolver<T extends EntityLivingBase> impleme
} }
// the default pack // the default pack
for (ResourceLocation candidate : resources) { for (Identifier candidate : resources) {
try { try {
Minecraft.getInstance().getResourceManager().getResource(candidate); MinecraftClient.getInstance().getResourceManager().getResource(candidate);
return candidate; return candidate;
} catch (IOException e) { } } catch (IOException e) { }
} }
@ -73,19 +75,19 @@ public class DefaultPonyArmorTextureResolver<T extends EntityLivingBase> impleme
return resources[resources.length - 1]; return resources[resources.length - 1];
} }
private ResourceLocation ponifyResource(ResourceLocation human) { private Identifier ponifyResource(Identifier human) {
return PONY_ARMOUR.computeIfAbsent(human, key -> { return PONY_ARMOUR.computeIfAbsent(human, key -> {
String domain = human.getNamespace(); String domain = human.getNamespace();
if ("minecraft".equals(domain)) { if ("minecraft".equals(domain)) {
domain = "minelittlepony"; // it's a vanilla armor. I provide these. domain = "minelittlepony"; // it's a vanilla armor. I provide these.
} }
return new ResourceLocation(domain, human.getPath().replace(".png", "_pony.png")); return new Identifier(domain, human.getPath().replace(".png", "_pony.png"));
}); });
} }
private ResourceLocation getArmorTexture(T entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) { private Identifier getArmorTexture(T entity, ItemStack item, String def, EquipmentSlot slot, @Nullable String type) {
return HUMAN_ARMOUR.computeIfAbsent(ForgeProxy.getArmorTexture(entity, item, def, slot, type), ResourceLocation::new); return HUMAN_ARMOUR.computeIfAbsent(ForgeProxy.getArmorTexture(entity, item, def, slot, type), Identifier::new);
} }
} }

View file

@ -1,14 +1,14 @@
package com.minelittlepony.client.model.armour; package com.minelittlepony.client.model.armour;
import net.minecraft.client.renderer.entity.model.ModelBiped; import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity;
import com.minelittlepony.client.model.AbstractPonyModel; import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.IModel; import com.minelittlepony.model.IModel;
import com.minelittlepony.model.armour.IArmour; import com.minelittlepony.model.armour.IArmour;
public class ModelPonyArmor extends AbstractPonyModel implements IArmour { public class ModelPonyArmor<T extends LivingEntity> extends AbstractPonyModel<T> implements IArmour {
public PonyRenderer chestPiece; public PonyRenderer chestPiece;
@ -21,26 +21,27 @@ public class ModelPonyArmor extends AbstractPonyModel implements IArmour {
protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) { protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) {
super.adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ); super.adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ);
chestPiece.rotateAngleX = rotateAngleX; chestPiece.pitch = rotateAngleX;
chestPiece.rotationPointY = rotationPointY; chestPiece.rotationPointY = rotationPointY;
chestPiece.rotationPointZ = rotationPointZ; chestPiece.rotationPointZ = rotationPointZ;
} }
@Override @Override
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
chestPiece.render(scale); chestPiece.render(scale);
} }
@Override @Override
public void synchroniseLegs(IModel model) { public void synchroniseLegs(IModel model) {
if (model instanceof ModelBiped) { if (model instanceof BipedEntityModel) {
ModelBiped mainModel = (ModelBiped)model; @SuppressWarnings("unchecked")
copyModelAngles(mainModel.bipedBody, bipedBody); BipedEntityModel<T> mainModel = (BipedEntityModel<T>)model;
copyModelAngles(mainModel.bipedRightArm, bipedRightArm); body.copyRotation(mainModel.body);
copyModelAngles(mainModel.bipedLeftArm, bipedLeftArm); rightArm.copyRotation(mainModel.rightArm);
copyModelAngles(mainModel.bipedRightLeg, bipedRightLeg); leftArm.copyRotation(mainModel.leftArm);
copyModelAngles(mainModel.bipedLeftLeg, bipedLeftLeg); rightLeg.copyRotation(mainModel.rightLeg);
leftLeg.copyRotation(mainModel.leftLeg);
} }
} }
@ -62,31 +63,31 @@ public class ModelPonyArmor extends AbstractPonyModel implements IArmour {
@Override @Override
protected void preInitLegs() { protected void preInitLegs() {
bipedLeftArm = new PonyRenderer(this, 0, 16).flip(); leftArm = new PonyRenderer(this, 0, 16).flip();
bipedRightArm = new PonyRenderer(this, 0, 16); rightArm = new PonyRenderer(this, 0, 16);
bipedLeftLeg = new PonyRenderer(this, 48, 8).flip(); leftLeg = new PonyRenderer(this, 48, 8).flip();
bipedRightLeg = new PonyRenderer(this, 48, 8); rightLeg = new PonyRenderer(this, 48, 8);
} }
@Override @Override
public void setInVisible() { public void setInVisible() {
setVisible(false); setVisible(false);
bipedBody.showModel = true; body.visible = true;
chestPiece.showModel = false; chestPiece.visible = false;
bipedHead.showModel = false; head.visible = false;
neck.showModel = false; neck.visible = false;
tail.setVisible(false); tail.setVisible(false);
upperTorso.isHidden = true; upperTorso.field_3664 = true;
snout.isHidden = true; snout.isHidden = true;
} }
@Override @Override
public void showBoots() { public void showBoots() {
bipedRightArm.showModel = true; rightArm.visible = true;
bipedLeftArm.showModel = true; leftArm.visible = true;
bipedRightLeg.showModel = true; rightLeg.visible = true;
bipedLeftLeg.showModel = true; leftLeg.visible = true;
} }
@Override @Override
@ -96,18 +97,18 @@ public class ModelPonyArmor extends AbstractPonyModel implements IArmour {
@Override @Override
public void showChestplate() { public void showChestplate() {
chestPiece.showModel = true; chestPiece.visible = true;
neck.showModel = true; neck.visible = true;
} }
@Override @Override
public void showSaddle() { public void showSaddle() {
chestPiece.showModel = true; chestPiece.visible = true;
neck.showModel = true; neck.visible = true;
} }
@Override @Override
public void showHelmet() { public void showHelmet() {
bipedHead.showModel = true; head.visible = true;
} }
} }

View file

@ -1,15 +1,17 @@
package com.minelittlepony.client.model.armour; package com.minelittlepony.client.model.armour;
import net.minecraft.entity.LivingEntity;
import com.minelittlepony.model.armour.ArmourLayer; import com.minelittlepony.model.armour.ArmourLayer;
import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.model.armour.IEquestrianArmour;
import com.minelittlepony.pony.IPonyData; import com.minelittlepony.pony.IPonyData;
public class PonyArmor implements IEquestrianArmour<ModelPonyArmor> { public class PonyArmor<T extends LivingEntity> implements IEquestrianArmour<ModelPonyArmor<T>> {
private final ModelPonyArmor outerLayer; private final ModelPonyArmor<T> outerLayer;
private final ModelPonyArmor innerLayer; private final ModelPonyArmor<T> innerLayer;
public PonyArmor(ModelPonyArmor outer, ModelPonyArmor inner) { public PonyArmor(ModelPonyArmor<T> outer, ModelPonyArmor<T> inner) {
outerLayer = outer; outerLayer = outer;
innerLayer = inner; innerLayer = inner;
} }
@ -27,7 +29,7 @@ public class PonyArmor implements IEquestrianArmour<ModelPonyArmor> {
} }
@Override @Override
public ModelPonyArmor getArmorForLayer(ArmourLayer layer) { public ModelPonyArmor<T> getArmorForLayer(ArmourLayer layer) {
if (layer == ArmourLayer.INNER) { if (layer == ArmourLayer.INNER) {
return innerLayer; return innerLayer;

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.model.armour; package com.minelittlepony.client.model.armour;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,14 +1,15 @@
package com.minelittlepony.client.model.components; package com.minelittlepony.client.model.components;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.model.Model;
import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.IPegasus; import com.minelittlepony.model.IPegasus;
import com.mojang.blaze3d.platform.GlStateManager;
import java.util.UUID; import java.util.UUID;
public class BatWings<T extends AbstractPonyModel & IPegasus> extends PegasusWings<T> { public class BatWings<T extends Model & IPegasus> extends PegasusWings<T> {
public BatWings(T model, float yOffset, float stretch) { public BatWings(T model, float yOffset, float stretch) {
super(model, yOffset, stretch); super(model, yOffset, stretch);
@ -48,7 +49,7 @@ public class BatWings<T extends AbstractPonyModel & IPegasus> extends PegasusWin
.tex(56, 16).box(x, 5, 6, 1, 7, 1, scale) .tex(56, 16).box(x, 5, 6, 1, 7, 1, scale)
.box(x, 5, 5, 1, 6, 1, scale) .box(x, 5, 5, 1, 6, 1, scale)
.tex(56, 16).box(x * 0.9F, 5, 7, 1, 7, 1, scale) .tex(56, 16).box(x * 0.9F, 5, 7, 1, 7, 1, scale)
.rotateAngleX = ROTATE_90; .pitch = ROTATE_90;
} }
@Override @Override
@ -57,7 +58,7 @@ public class BatWings<T extends AbstractPonyModel & IPegasus> extends PegasusWin
extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY - 1, EXT_WING_RP_Z - 3) extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY - 1, EXT_WING_RP_Z - 3)
.mirror(right) .mirror(right)
.rotateAngleY = r * 3; .yaw = r * 3;
extended.child().tex(60, 16) extended.child().tex(60, 16)
.mirror(right) // children are unaware of their parents being mirrored, sadly .mirror(right) // children are unaware of their parents being mirrored, sadly
@ -85,7 +86,7 @@ public class BatWings<T extends AbstractPonyModel & IPegasus> extends PegasusWin
@Override @Override
public void rotateWalking(float swing) { public void rotateWalking(float swing) {
folded.rotateAngleY = swing * 0.05F; folded.yaw = swing * 0.05F;
} }
} }
} }

View file

@ -1,10 +1,11 @@
package com.minelittlepony.client.model.components; package com.minelittlepony.client.model.components;
import com.minelittlepony.client.model.AbstractPonyModel; import net.minecraft.client.model.Model;
import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.IPegasus; import com.minelittlepony.model.IPegasus;
public class BugWings<T extends AbstractPonyModel & IPegasus> extends PegasusWings<T> { public class BugWings<T extends Model & IPegasus> extends PegasusWings<T> {
public BugWings(T model, float yOffset, float stretch) { public BugWings(T model, float yOffset, float stretch) {
super(model, yOffset, stretch); super(model, yOffset, stretch);
@ -34,7 +35,7 @@ public class BugWings<T extends AbstractPonyModel & IPegasus> extends PegasusWin
extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY, EXT_WING_RP_Z - 2) extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY, EXT_WING_RP_Z - 2)
.mirror(right) .mirror(right)
.rotateAngleY = r * 3; .yaw = r * 3;
PlaneRenderer primary = new PlaneRenderer(pegasus) PlaneRenderer primary = new PlaneRenderer(pegasus)
.tex(56, 16) .tex(56, 16)

View file

@ -1,18 +1,17 @@
package com.minelittlepony.client.model.components; package com.minelittlepony.client.model.components;
import net.minecraft.client.renderer.entity.model.ModelRenderer; import net.minecraft.client.render.entity.model.SkullEntityModel;
import net.minecraft.client.renderer.entity.model.ModelSkeletonHead;
public class ModelDeadMau5Ears extends ModelSkeletonHead { public class ModelDeadMau5Ears extends SkullEntityModel {
public ModelDeadMau5Ears() { public ModelDeadMau5Ears() {
super(); super(24, 0, 64, 64);
skeletonHead = new ModelRenderer(this, 24, 0); field_3564.boxes.clear();
skeletonHead.addBox(-9, -13, -1, 6, 6, 1, 0); field_3564.addBox(-9, -13, -1, 6, 6, 1, 0);
skeletonHead.addBox(3, -13, -1, 6, 6, 1, 0); field_3564.addBox(3, -13, -1, 6, 6, 1, 0);
} }
public void setVisible(boolean show) { public void setVisible(boolean show) {
skeletonHead.isHidden = !show; field_3564.field_3664 = !show;
} }
} }

View file

@ -5,11 +5,10 @@ import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.ICapitated; import com.minelittlepony.model.ICapitated;
import com.minelittlepony.pony.IPonyData; import com.minelittlepony.pony.IPonyData;
import net.minecraft.client.renderer.entity.model.ModelHumanoidHead; import net.minecraft.client.model.Cuboid;
import net.minecraft.client.renderer.entity.model.ModelRenderer; import net.minecraft.client.render.entity.model.SkullOverlayEntityModel;
import net.minecraft.entity.Entity;
public class ModelPonyHead extends ModelHumanoidHead implements ICapitated<ModelRenderer> { public class ModelPonyHead extends SkullOverlayEntityModel implements ICapitated<Cuboid> {
private PonySnout snout; private PonySnout snout;
@ -32,12 +31,12 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated<Model
.tex(12, 16).box(-3.999F, -6, 1, 2, 2, 2, 0) .tex(12, 16).box(-3.999F, -6, 1, 2, 2, 2, 0)
.flip().box( 1.999F, -6, 1, 2, 2, 2, 0); .flip().box( 1.999F, -6, 1, 2, 2, 2, 0);
skeletonHead.addChild(ears); getHead().addChild(ears);
} }
@Override @Override
public ModelRenderer getHead() { public Cuboid getHead() {
return skeletonHead; return field_3564;
} }
@Override @Override
@ -46,17 +45,17 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated<Model
} }
@Override @Override
public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
snout.isHidden = metadata.getRace().isHuman(); snout.isHidden = metadata.getRace().isHuman();
ears.isHidden = snout.isHidden; ears.field_3664 = snout.isHidden;
snout.setGender(metadata.getGender()); snout.setGender(metadata.getGender());
super.render(entity, move, swing, ticks, headYaw, headPitch, scale); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale);
if (metadata.hasMagic()) { if (metadata.hasMagic()) {
skeletonHead.postRender(scale); getHead().applyTransform(scale);
horn.renderPart(scale, entity.getUniqueID()); horn.renderPart(scale, null);
} }
} }
} }

View file

@ -1,18 +1,18 @@
package com.minelittlepony.client.model.components; package com.minelittlepony.client.model.components;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.model.Model;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.IPart; import com.minelittlepony.model.IPart;
import com.minelittlepony.model.IPegasus; import com.minelittlepony.model.IPegasus;
import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
import com.mojang.blaze3d.platform.GlStateManager;
import java.util.UUID; import java.util.UUID;
public class PegasusWings<T extends AbstractPonyModel & IPegasus> implements IPart, PonyModelConstants { public class PegasusWings<T extends Model & IPegasus> implements IPart, PonyModelConstants {
protected final T pegasus; protected final T pegasus;
@ -110,20 +110,20 @@ public class PegasusWings<T extends AbstractPonyModel & IPegasus> implements IPa
.box(x, 5, 2, 2, 6, 2, scale) .box(x, 5, 2, 2, 6, 2, scale)
.box(x, 5, 4, 2, 8, 2, scale) .box(x, 5, 4, 2, 8, 2, scale)
.box(x, 5, 6, 2, 6, 2, scale) .box(x, 5, 6, 2, 6, 2, scale)
.rotateAngleX = ROTATE_90; .pitch = ROTATE_90;
} }
protected void addFeathers(boolean right, boolean l, float rotationPointY, float scale) { protected void addFeathers(boolean right, boolean l, float rotationPointY, float scale) {
float r = right ? -1 : 1; float r = right ? -1 : 1;
extended.around(r * EXT_WING_RP_X, EXT_WING_RP_Y + rotationPointY, EXT_WING_RP_Z) extended.around(r * EXT_WING_RP_X, EXT_WING_RP_Y + rotationPointY, EXT_WING_RP_Z)
.rotateAngleY = r * 3; .pitch = r * 3;
addFeather(0, l, 6, 0, 9, scale + 0.1F); addFeather(0, l, 6, 0, 9, scale + 0.1F);
addFeather(1, l, -1, -0.3F, 8, scale + 0.1F) .rotateAngleX = -0.85F; addFeather(1, l, -1, -0.3F, 8, scale + 0.1F) .pitch = -0.85F;
addFeather(2, l, 1.8F, 1.3F, 8, scale - 0.1F) .rotateAngleX = -0.75F; addFeather(2, l, 1.8F, 1.3F, 8, scale - 0.1F) .pitch = -0.75F;
addFeather(3, l, 5, 2, 8, scale) .rotateAngleX = -0.5F; addFeather(3, l, 5, 2, 8, scale) .pitch = -0.5F;
addFeather(4, l, 0, -0.2F, 6, scale + 0.3F); addFeather(4, l, 0, -0.2F, 6, scale + 0.3F);
addFeather(5, l, 0, 0, 3, scale + 0.19F).rotateAngleX = -0.85F; addFeather(5, l, 0, 0, 3, scale + 0.19F).pitch = -0.85F;
} }
private PonyRenderer addFeather(int i, boolean l, float y, float z, int h, float scale) { private PonyRenderer addFeather(int i, boolean l, float y, float z, int h, float scale) {
@ -131,11 +131,11 @@ public class PegasusWings<T extends AbstractPonyModel & IPegasus> implements IPa
} }
public void rotateWalking(float swing) { public void rotateWalking(float swing) {
folded.rotateAngleY = swing * 0.15F; folded.yaw = swing * 0.15F;
} }
public void rotateFlying(float angle) { public void rotateFlying(float angle) {
extended.rotateAngleZ = angle; extended.roll = angle;
} }
public void render(float scale) { public void render(float scale) {

View file

@ -1,21 +1,20 @@
package com.minelittlepony.client.model.components; package com.minelittlepony.client.model.components;
import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.renderer.entity.model.ModelBase; import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import com.minelittlepony.client.model.AbstractPonyModel; import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.mojang.blaze3d.platform.GlStateManager;
import static com.minelittlepony.model.PonyModelConstants.*; import static com.minelittlepony.model.PonyModelConstants.*;
/** /**
* Modified from ModelElytra. * Modified from ModelElytra.
*/ */
public class PonyElytra extends ModelBase { public class PonyElytra<T extends LivingEntity> extends EntityModel<T> {
public boolean isSneaking; public boolean isSneaking;
@ -33,7 +32,7 @@ public class PonyElytra extends ModelBase {
* See {@link AbstractPonyModel.render} for an explanation of the various parameters. * See {@link AbstractPonyModel.render} for an explanation of the various parameters.
*/ */
@Override @Override
public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { public void render(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
GlStateManager.disableRescaleNormal(); GlStateManager.disableRescaleNormal();
GlStateManager.disableCull(); GlStateManager.disableCull();
leftWing.render(scale); leftWing.render(scale);
@ -46,8 +45,8 @@ public class PonyElytra extends ModelBase {
* See {@link AbstractPonyModel.setRotationAngles} for an explanation of the various parameters. * See {@link AbstractPonyModel.setRotationAngles} for an explanation of the various parameters.
*/ */
@Override @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
float rotateX = PI / 2; float rotateX = PI / 2;
float rotateY = PI / 8; float rotateY = PI / 8;
@ -55,12 +54,12 @@ public class PonyElytra extends ModelBase {
float rpY = BODY_RP_Y_NOTSNEAK; float rpY = BODY_RP_Y_NOTSNEAK;
if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { if (entity.isFallFlying()) {
float velY = 1; float velY = 1;
if (entity.motionY < 0) { Vec3d motion = entity.getVelocity();
Vec3d motion = new Vec3d(entity.motionX, entity.motionY, entity.motionZ).normalize(); if (motion.y < 0) {
velY = 1 - (float) Math.pow(-motion.y, 1.5); velY = 1 - (float) Math.pow(-motion.normalize().y, 1.5);
} }
rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX; rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX;
@ -75,27 +74,27 @@ public class PonyElytra extends ModelBase {
leftWing.rotationPointX = 5; leftWing.rotationPointX = 5;
leftWing.rotationPointY = rpY; leftWing.rotationPointY = rpY;
if (entity instanceof AbstractClientPlayer) { if (entity instanceof AbstractClientPlayerEntity) {
AbstractClientPlayer player = (AbstractClientPlayer) entity; AbstractClientPlayerEntity player = (AbstractClientPlayerEntity) entity;
player.rotateElytraX += (rotateX - player.rotateElytraX) / 10; player.elytraPitch += (rotateX - player.elytraPitch) / 10;
player.rotateElytraY += (rotateY - player.rotateElytraY) / 10; player.elytraYaw += (rotateY - player.elytraYaw) / 10;
player.rotateElytraZ += (rotateZ - player.rotateElytraZ) / 10; player.elytraRoll += (rotateZ - player.elytraRoll) / 10;
leftWing.rotateAngleX = player.rotateElytraX; leftWing.pitch = player.elytraPitch;
leftWing.rotateAngleY = player.rotateElytraY; leftWing.yaw = player.elytraYaw;
leftWing.rotateAngleZ = player.rotateElytraZ; leftWing.roll = player.elytraRoll;
} else { } else {
leftWing.rotateAngleX = rotateX; leftWing.pitch = rotateX;
leftWing.rotateAngleZ = rotateZ; leftWing.yaw = rotateZ;
leftWing.rotateAngleY = rotateY; leftWing.roll = rotateY;
} }
rightWing.rotationPointX = -leftWing.rotationPointX; rightWing.rotationPointX = -leftWing.rotationPointX;
rightWing.rotationPointY = leftWing.rotationPointY; rightWing.rotationPointY = leftWing.rotationPointY;
rightWing.rotateAngleX = leftWing.rotateAngleX; rightWing.pitch = leftWing.pitch;
rightWing.rotateAngleY = -leftWing.rotateAngleY; rightWing.yaw = -leftWing.yaw;
rightWing.rotateAngleZ = -leftWing.rotateAngleZ; rightWing.roll = -leftWing.roll;
} }
} }

View file

@ -1,7 +1,7 @@
package com.minelittlepony.client.model.components; package com.minelittlepony.client.model.components;
import net.minecraft.client.renderer.entity.model.ModelBase; import net.minecraft.client.model.Cuboid;
import net.minecraft.client.renderer.entity.model.ModelRenderer; import net.minecraft.client.model.Model;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.client.util.render.plane.PlaneRenderer;
@ -17,13 +17,13 @@ public class PonySnout {
private PlaneRenderer mare; private PlaneRenderer mare;
private PlaneRenderer stallion; private PlaneRenderer stallion;
private final ICapitated<ModelRenderer> head; private final ICapitated<Cuboid> head;
public <T extends ModelBase & ICapitated<ModelRenderer>> PonySnout(T pony) { public <T extends Model & ICapitated<Cuboid>> PonySnout(T pony) {
this(pony, 0, 0, 0); this(pony, 0, 0, 0);
} }
public <T extends ModelBase & ICapitated<ModelRenderer>> PonySnout(T pony, int x, int y, int z) { public <T extends Model & ICapitated<Cuboid>> PonySnout(T pony, int x, int y, int z) {
head = pony; head = pony;
mare = new PlaneRenderer(pony).offset(HEAD_CENTRE_X + x, HEAD_CENTRE_Y + y, HEAD_CENTRE_Z + z + 0.25F); mare = new PlaneRenderer(pony).offset(HEAD_CENTRE_X + x, HEAD_CENTRE_Y + y, HEAD_CENTRE_Z + z + 0.25F);
@ -61,7 +61,7 @@ public class PonySnout {
public void setGender(Gender gender) { public void setGender(Gender gender) {
boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getInstance().getConfig().snuzzles; boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getInstance().getConfig().snuzzles;
mare.isHidden = !(show && gender.isMare()); mare.field_3664 = !(show && gender.isMare());
stallion.isHidden = !(show && gender.isStallion()); stallion.field_3664 = !(show && gender.isStallion());
} }
} }

View file

@ -1,6 +1,6 @@
package com.minelittlepony.client.model.components; package com.minelittlepony.client.model.components;
import net.minecraft.client.renderer.entity.model.ModelBase; import net.minecraft.client.model.Model;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.model.AbstractPonyModel; import com.minelittlepony.client.model.AbstractPonyModel;
@ -9,17 +9,15 @@ import com.minelittlepony.model.IPart;
import java.util.UUID; import java.util.UUID;
import static com.minelittlepony.model.PonyModelConstants.*;
public class PonyTail extends PlaneRenderer implements IPart { public class PonyTail extends PlaneRenderer implements IPart {
private static final int SEGMENTS = 4; private static final int SEGMENTS = 4;
private final AbstractPonyModel theModel; private final AbstractPonyModel<?> theModel;
private int tailStop = 0; private int tailStop = 0;
public PonyTail(AbstractPonyModel model) { public PonyTail(AbstractPonyModel<?> model) {
super(model); super(model);
theModel = model; theModel = model;
} }
@ -33,21 +31,21 @@ public class PonyTail extends PlaneRenderer implements IPart {
@Override @Override
public void setRotationAndAngles(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) { public void setRotationAndAngles(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing; roll = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing;
rotateAngleY = bodySwing; yaw = bodySwing;
if (theModel.isCrouching() && !rainboom) { if (theModel.isCrouching() && !rainboom) {
rotateSneak(); rotateSneak();
} else if (theModel.isRiding()) { } else if (theModel.isRiding()) {
rotationPointZ = TAIL_RP_Z_RIDING; rotationPointZ = TAIL_RP_Z_RIDING;
rotationPointY = TAIL_RP_Y_RIDING; rotationPointY = TAIL_RP_Y_RIDING;
rotateAngleX = PI / 5; pitch = PI / 5;
} else { } else {
setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK); setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK);
if (rainboom) { if (rainboom) {
rotateAngleX = ROTATE_90 + MathHelper.sin(move) / 10; pitch = ROTATE_90 + MathHelper.sin(move) / 10;
} else { } else {
rotateAngleX = swing / 2; pitch = swing / 2;
swingX(ticks); swingX(ticks);
} }
@ -63,18 +61,18 @@ public class PonyTail extends PlaneRenderer implements IPart {
private void swingX(float ticks) { private void swingX(float ticks) {
float sinTickFactor = MathHelper.sin(ticks * 0.067f) * 0.05f; float sinTickFactor = MathHelper.sin(ticks * 0.067f) * 0.05f;
rotateAngleX += sinTickFactor; pitch += sinTickFactor;
rotateAngleY += sinTickFactor; yaw += sinTickFactor;
} }
private void rotateSneak() { private void rotateSneak() {
setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_SNEAK); setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_SNEAK);
rotateAngleX = -BODY_ROT_X_SNEAK + 0.1F; pitch = -BODY_ROT_X_SNEAK + 0.1F;
} }
@Override @Override
public void setVisible(boolean visible) { public void setVisible(boolean visible) {
isHidden = !visible; field_3664 = !visible;
} }
@Override @Override
@ -86,11 +84,11 @@ public class PonyTail extends PlaneRenderer implements IPart {
private final int index; private final int index;
public TailSegment(ModelBase model, int index, float yOffset, float stretch) { public TailSegment(Model model, int index, float yOffset, float stretch) {
super(model); super(model);
this.index = index; this.index = index;
offsetY = ((float)index)/4 + 0.063f; y = ((float)index)/4 + 0.063f;
init(yOffset, stretch); init(yOffset, stretch);
} }

View file

@ -1,16 +1,14 @@
package com.minelittlepony.client.model.components; package com.minelittlepony.client.model.components;
import com.minelittlepony.client.model.AbstractPonyModel; import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.model.IClientModel;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.IPart; import com.minelittlepony.model.IPart;
import com.minelittlepony.model.IPonyModel;
import com.mojang.blaze3d.platform.GlStateManager;
import java.util.UUID; import java.util.UUID;
import static com.minelittlepony.model.PonyModelConstants.*;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -24,9 +22,9 @@ public class SeaponyTail implements IPart {
private PlaneRenderer tailTip; private PlaneRenderer tailTip;
private PlaneRenderer tailFins; private PlaneRenderer tailFins;
private IClientModel model; private IPonyModel<?> model;
public SeaponyTail(AbstractPonyModel model) { public SeaponyTail(AbstractPonyModel<?> model) {
this.model = model; this.model = model;
tailBase = new PonyRenderer(model, 0, 38); tailBase = new PonyRenderer(model, 0, 38);
@ -57,9 +55,9 @@ public class SeaponyTail implements IPart {
public void setRotationAndAngles(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) { public void setRotationAndAngles(boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
float rotation = model.isSleeping() ? 0 : MathHelper.sin(ticks * 0.536f) / 4; float rotation = model.isSleeping() ? 0 : MathHelper.sin(ticks * 0.536f) / 4;
tailBase.rotateAngleX = TAIL_ROTX + rotation; tailBase.pitch = TAIL_ROTX + rotation;
tailTip.rotateAngleX = rotation; tailTip.pitch = rotation;
tailFins.rotateAngleX = rotation - TAIL_ROTX; tailFins.pitch = rotation - TAIL_ROTX;
} }
@Override @Override

View file

@ -1,19 +1,20 @@
package com.minelittlepony.client.model.components; package com.minelittlepony.client.model.components;
import net.minecraft.client.model.Cuboid;
import net.minecraft.client.model.Model;
import com.minelittlepony.client.util.render.GlowRenderer; import com.minelittlepony.client.util.render.GlowRenderer;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.ICapitated; import com.minelittlepony.model.ICapitated;
import com.minelittlepony.model.IPart; import com.minelittlepony.model.IPart;
import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
import static com.minelittlepony.model.PonyModelConstants.*; import static com.mojang.blaze3d.platform.GlStateManager.*;
import net.minecraft.client.renderer.entity.model.ModelBase;
import net.minecraft.client.renderer.entity.model.ModelRenderer;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import static net.minecraft.client.renderer.GlStateManager.*;
public class UnicornHorn implements IPart { public class UnicornHorn implements IPart {
@ -22,18 +23,18 @@ public class UnicornHorn implements IPart {
protected boolean isVisible = true; protected boolean isVisible = true;
public <T extends ModelBase & ICapitated<ModelRenderer>> UnicornHorn(T pony, float yOffset, float stretch) { public <T extends Model & ICapitated<Cuboid>> UnicornHorn(T pony, float yOffset, float stretch) {
this(pony, yOffset, stretch, 0, 0, 0); this(pony, yOffset, stretch, 0, 0, 0);
} }
public <T extends ModelBase & ICapitated<ModelRenderer>> UnicornHorn(T pony, float yOffset, float stretch, int x, int y, int z) { public <T extends Model & ICapitated<Cuboid>> UnicornHorn(T pony, float yOffset, float stretch, int x, int y, int z) {
horn = new PonyRenderer(pony, 0, 3); horn = new PonyRenderer(pony, 0, 3);
glow = new GlowRenderer(pony, 0, 3); glow = new GlowRenderer(pony, 0, 3);
horn.offset(HORN_X + x, HORN_Y + y, HORN_Z + z) horn.offset(HORN_X + x, HORN_Y + y, HORN_Z + z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.box(0, 0, 0, 1, 4, 1, stretch) .box(0, 0, 0, 1, 4, 1, stretch)
.rotateAngleX = 0.5F; .pitch = 0.5F;
glow.offset(HORN_X + x, HORN_Y + y, HORN_Z + z) glow.offset(HORN_X + x, HORN_Y + y, HORN_Z + z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
@ -42,7 +43,7 @@ public class UnicornHorn implements IPart {
} }
@Override @Override
public void renderPart(float scale, UUID interpolatorId) { public void renderPart(float scale, @Nullable UUID interpolatorId) {
if (isVisible) { if (isVisible) {
horn.render(scale); horn.render(scale);
} }
@ -51,15 +52,15 @@ public class UnicornHorn implements IPart {
public void renderMagic(int tint, float scale) { public void renderMagic(int tint, float scale) {
if (isVisible) { if (isVisible) {
glPushAttrib(24577); glPushAttrib(24577);
disableTexture2D(); disableTexture();
disableLighting(); disableLighting();
enableBlend(); enableBlend();
blendFunc(GL_SRC_ALPHA, GL_ONE); blendFunc(GL_SRC_ALPHA, GL_ONE);
horn.postRender(scale); horn.applyTransform(scale);
glow.setTint(tint).render(scale); glow.setTint(tint).render(scale);
enableTexture2D(); enableTexture();
enableLighting(); enableLighting();
disableBlend(); disableBlend();
glPopAttrib(); glPopAttrib();

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.model.components; package com.minelittlepony.client.model.components;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,16 +1,16 @@
package com.minelittlepony.client.model.entities; package com.minelittlepony.client.model.entities;
import net.minecraft.client.renderer.entity.model.ModelBiped; import net.minecraft.client.model.Cuboid;
import net.minecraft.client.renderer.entity.model.ModelRenderer; import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity;
import net.minecraft.util.EnumHandSide; import net.minecraft.util.AbsoluteHand;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import static com.minelittlepony.model.PonyModelConstants.PI; import static com.minelittlepony.model.PonyModelConstants.PI;
public class ModelBreezie extends ModelBiped { public class ModelBreezie<T extends LivingEntity> extends BipedEntityModel<T> {
PonyRenderer neck; PonyRenderer neck;
PonyRenderer tail; PonyRenderer tail;
@ -23,8 +23,8 @@ public class ModelBreezie extends ModelBiped {
textureWidth = 64; textureWidth = 64;
textureHeight = 64; textureHeight = 64;
bipedHeadwear.showModel = false; headwear.visible = false;
bipedHead = new PonyRenderer(this) head = new PonyRenderer(this)
.child(new PonyRenderer(this) .child(new PonyRenderer(this)
.addBox(-3, -6, -3, 6, 6, 6).around(0, 0, -4) .addBox(-3, -6, -3, 6, 6, 6).around(0, 0, -4)
.tex(28, 0).addBox( 2, -7, 1, 1, 1, 1) .tex(28, 0).addBox( 2, -7, 1, 1, 1, 1)
@ -35,13 +35,13 @@ public class ModelBreezie extends ModelBiped {
.tex(24, 2).addBox(-2, -11, -2, 1, 6, 1) .tex(24, 2).addBox(-2, -11, -2, 1, 6, 1)
.rotate(-0.2617994F, 0, 0)); .rotate(-0.2617994F, 0, 0));
bipedBody = new PonyRenderer(this, 2, 12) body = new PonyRenderer(this, 2, 12)
.addBox(0, 0, 0, 6, 7, 14).rotate(-0.5235988F, 0, 0).around(-3, 1, -3); .addBox(0, 0, 0, 6, 7, 14).rotate(-0.5235988F, 0, 0).around(-3, 1, -3);
bipedLeftArm = new PonyRenderer(this, 28, 12).addBox(0, 0, 0, 2, 12, 2).around( 1, 8, -5); leftArm = new PonyRenderer(this, 28, 12).addBox(0, 0, 0, 2, 12, 2).around( 1, 8, -5);
bipedRightArm = new PonyRenderer(this, 36, 12).addBox(0, 0, 0, 2, 12, 2).around(-3, 8, -5); rightArm = new PonyRenderer(this, 36, 12).addBox(0, 0, 0, 2, 12, 2).around(-3, 8, -5);
bipedLeftLeg = new PonyRenderer(this, 8, 12) .addBox(0, 0, 0, 2, 12, 2).around( 1, 12, 3); leftLeg = new PonyRenderer(this, 8, 12) .addBox(0, 0, 0, 2, 12, 2).around( 1, 12, 3);
bipedRightLeg = new PonyRenderer(this, 0, 12) .addBox(0, 0, 0, 2, 12, 2).around(-3, 12, 3); rightLeg = new PonyRenderer(this, 0, 12) .addBox(0, 0, 0, 2, 12, 2).around(-3, 12, 3);
neck = new PonyRenderer(this, 40, 0) neck = new PonyRenderer(this, 40, 0)
.addBox(0, 0, 0, 2, 5, 2) .addBox(0, 0, 0, 2, 5, 2)
@ -66,7 +66,7 @@ public class ModelBreezie extends ModelBiped {
} }
@Override @Override
public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { public void render(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.render(entity, move, swing, ticks, headYaw, headPitch, scale); super.render(entity, move, swing, ticks, headYaw, headPitch, scale);
neck.render(scale); neck.render(scale);
tailStub.render(scale); tailStub.render(scale);
@ -77,46 +77,46 @@ public class ModelBreezie extends ModelBiped {
@SuppressWarnings("incomplete-switch") @SuppressWarnings("incomplete-switch")
@Override @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
bipedHead.rotateAngleY = headYaw * 0.017453292F; head.yaw = headYaw * 0.017453292F;
bipedHead.rotateAngleX = headPitch * 0.017453292F; head.pitch = headPitch * 0.017453292F;
bipedLeftArm.rotateAngleX = MathHelper.cos(move * 0.6662F) * swing; leftArm.pitch = MathHelper.cos(move * 0.6662F) * swing;
bipedLeftArm.rotateAngleZ = 0; leftArm.roll = 0;
((PonyRenderer)bipedRightArm).rotate(swing * MathHelper.cos(move * 0.6662F + PI), 0, 0); ((PonyRenderer)rightArm).rotate(swing * MathHelper.cos(move * 0.6662F + PI), 0, 0);
((PonyRenderer)bipedLeftLeg) .rotate(swing * MathHelper.cos(move * 0.6662F + PI) * 1.4F, 0, 0); ((PonyRenderer)leftLeg) .rotate(swing * MathHelper.cos(move * 0.6662F + PI) * 1.4F, 0, 0);
((PonyRenderer)bipedRightLeg).rotate(swing * MathHelper.cos(move * 0.6662F) * 1.4F, 0, 0); ((PonyRenderer)rightLeg).rotate(swing * MathHelper.cos(move * 0.6662F) * 1.4F, 0, 0);
if (isRiding) { if (isRiding) {
bipedLeftArm.rotateAngleX += -PI / 5; leftArm.pitch += -PI / 5;
bipedRightArm.rotateAngleX += -PI / 5; rightArm.pitch += -PI / 5;
rotateLegRiding(((PonyRenderer)bipedLeftLeg), -1); rotateLegRiding(((PonyRenderer)leftLeg), -1);
rotateLegRiding(((PonyRenderer)bipedRightLeg), 1); rotateLegRiding(((PonyRenderer)rightLeg), 1);
} }
rotateArm(bipedLeftArm, leftArmPose, 1); rotateArm(leftArm, leftArmPose, 1);
rotateArm(bipedRightArm, rightArmPose, 1); rotateArm(rightArm, rightArmPose, 1);
if (swingProgress > 0) { if (handSwingProgress > 0) {
swingArms(getMainHand(entity)); swingArms(getPreferedHand(entity));
} }
float rotX = MathHelper.sin(ticks * 0.067F) * 0.05F; float rotX = MathHelper.sin(ticks * 0.067F) * 0.05F;
float rotZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; float rotZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
bipedLeftArm.rotateAngleX -= rotX; leftArm.pitch -= rotX;
bipedLeftArm.rotateAngleZ -= rotZ; leftArm.roll -= rotZ;
bipedRightArm.rotateAngleX += rotX; rightArm.pitch += rotX;
bipedRightArm.rotateAngleZ += rotZ; rightArm.roll += rotZ;
if (rightArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { if (rightArmPose == ArmPose.BOW_AND_ARROW) {
raiseArm(bipedRightArm, bipedLeftArm, -1); raiseArm(rightArm, leftArm, -1);
} else if (leftArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { } else if (leftArmPose == ArmPose.BOW_AND_ARROW) {
raiseArm(bipedLeftArm, bipedRightArm, 1); raiseArm(leftArm, rightArm, 1);
} }
} }
@ -124,57 +124,57 @@ public class ModelBreezie extends ModelBiped {
leg.rotate(-1.4137167F, factor * PI / 10, factor * 0.07853982F); leg.rotate(-1.4137167F, factor * PI / 10, factor * 0.07853982F);
} }
protected void swingArms(EnumHandSide mainHand) { protected void swingArms(AbsoluteHand mainHand) {
bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) / 5; body.yaw = MathHelper.sin(MathHelper.sqrt(handSwingProgress) * PI * 2) / 5;
if (mainHand == EnumHandSide.LEFT) { if (mainHand == AbsoluteHand.LEFT) {
bipedBody.rotateAngleY *= -1; body.yaw *= -1;
} }
float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; float sin = MathHelper.sin(body.yaw) * 5;
float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; float cos = MathHelper.cos(body.yaw) * 5;
bipedLeftArm.rotateAngleX += bipedBody.rotateAngleY; leftArm.pitch += body.yaw;
bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; leftArm.yaw += body.yaw;
bipedLeftArm.rotationPointX = cos; leftArm.rotationPointX = cos;
bipedLeftArm.rotationPointZ = -sin; leftArm.rotationPointZ = -sin;
bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; rightArm.yaw += body.yaw;
bipedRightArm.rotationPointX = -cos; rightArm.rotationPointX = -cos;
bipedRightArm.rotationPointZ = sin; rightArm.rotationPointZ = sin;
float swingAmount = 1 - (float)Math.pow(1 - swingProgress, 4); float swingAmount = 1 - (float)Math.pow(1 - handSwingProgress, 4);
float swingFactorX = MathHelper.sin(swingAmount * PI); float swingFactorX = MathHelper.sin(swingAmount * PI);
float swingX = MathHelper.sin(swingProgress * PI) * (0.7F - bipedHead.rotateAngleX) * 0.75F; float swingX = MathHelper.sin(handSwingProgress * PI) * (0.7F - head.pitch) * 0.75F;
ModelRenderer mainArm = getArmForSide(mainHand); Cuboid mainArm = getArm(mainHand);
mainArm.rotateAngleX -= swingFactorX * 1.2F + swingX; mainArm.pitch -= swingFactorX * 1.2F + swingX;
mainArm.rotateAngleY += bipedBody.rotateAngleY * 2; mainArm.yaw += body.yaw * 2;
mainArm.rotateAngleZ -= MathHelper.sin(swingProgress * PI) * 0.4F; mainArm.roll -= MathHelper.sin(handSwingProgress * PI) * 0.4F;
} }
protected void rotateArm(ModelRenderer arm, ArmPose pose, float factor) { protected void rotateArm(Cuboid arm, ArmPose pose, float factor) {
switch (pose) { switch (pose) {
case EMPTY: case EMPTY:
arm.rotateAngleY = 0; arm.yaw = 0;
break; break;
case ITEM: case ITEM:
arm.rotateAngleX = arm.rotateAngleX / 2 - (PI / 10); arm.pitch = arm.pitch / 2 - (PI / 10);
arm.rotateAngleY = 0; arm.yaw = 0;
case BLOCK: case BLOCK:
arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; arm.pitch = arm.pitch / 2 - 0.9424779F;
arm.rotateAngleY = factor * 0.5235988F; arm.yaw = factor * 0.5235988F;
break; break;
default: default:
} }
} }
protected void raiseArm(ModelRenderer up, ModelRenderer down, float factor) { protected void raiseArm(Cuboid up, Cuboid down, float factor) {
up.rotateAngleY = bipedHead.rotateAngleY + (factor / 10); up.yaw = head.yaw + (factor / 10);
up.rotateAngleX = bipedHead.rotateAngleX - (PI / 2); up.pitch = head.pitch - (PI / 2);
down.rotateAngleY = bipedHead.rotateAngleY - (factor / 2); down.yaw = head.yaw - (factor / 2);
down.rotateAngleX = bipedHead.rotateAngleX - (PI / 2); down.pitch = head.pitch - (PI / 2);
} }
} }

View file

@ -1,15 +1,15 @@
package com.minelittlepony.client.model.entities; package com.minelittlepony.client.model.entities;
import net.minecraft.client.renderer.entity.model.ModelRenderer; import net.minecraft.client.model.Cuboid;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.mob.EndermanEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.model.components.PonySnout; import com.minelittlepony.client.model.components.PonySnout;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
public class ModelEnderStallion extends ModelSkeletonPony { import com.mojang.blaze3d.platform.GlStateManager;
public class ModelEnderStallion extends ModelSkeletonPony<EndermanEntity> {
public boolean isCarrying; public boolean isCarrying;
public boolean isAttacking; public boolean isAttacking;
@ -21,27 +21,27 @@ public class ModelEnderStallion extends ModelSkeletonPony {
private PonyRenderer rightHorn; private PonyRenderer rightHorn;
@Override @Override
public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { public void animateModel(EndermanEntity entity, float move, float swing, float ticks) {
rightArmPose = isCarrying ? ArmPose.BLOCK : ArmPose.EMPTY; rightArmPose = isCarrying ? ArmPose.BLOCK : ArmPose.EMPTY;
leftArmPose = rightArmPose; leftArmPose = rightArmPose;
isUnicorn = true; isUnicorn = true;
isAlicorn = entity.getUniqueID().getLeastSignificantBits() % 3 == 0; isAlicorn = entity.getUuid().getLeastSignificantBits() % 3 == 0;
isBoss = !isAlicorn && entity.getUniqueID().getLeastSignificantBits() % 90 == 0; isBoss = !isAlicorn && entity.getUuid().getLeastSignificantBits() % 90 == 0;
leftHorn.isHidden = rightHorn.isHidden = !isBoss; leftHorn.field_3664 = rightHorn.field_3664 = !isBoss;
horn.setVisible(!isBoss); horn.setVisible(!isBoss);
tail.setVisible(false); tail.setVisible(false);
snout.isHidden = true; snout.isHidden = true;
bipedLeftArmwear.isHidden = true; leftArmOverlay.field_3664 = true;
bipedRightArmwear.isHidden = true; rightArmOverlay.field_3664 = true;
bipedLeftLegwear.isHidden = true; leftLegOverlay.field_3664 = true;
bipedRightLegwear.isHidden = true; rightLegOverlay.field_3664 = true;
leftHorn.rotateAngleX = 0.5F; leftHorn.pitch = 0.5F;
rightHorn.rotateAngleX = 0.5F; rightHorn.pitch = 0.5F;
} }
@Override @Override
@ -51,17 +51,16 @@ public class ModelEnderStallion extends ModelSkeletonPony {
} }
@Override @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setAngles(EndermanEntity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
if (isAttacking) { if (isAttacking) {
bipedHead.rotationPointY -= 5; head.rotationPointY -= 5;
} }
} }
@Override @Override
public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { public void render(EndermanEntity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translatef(0, -1.15F, 0); GlStateManager.translatef(0, -1.15F, 0);
super.render(entity, move, swing, ticks, headYaw, headPitch, scale); super.render(entity, move, swing, ticks, headYaw, headPitch, scale);
@ -75,14 +74,14 @@ public class ModelEnderStallion extends ModelSkeletonPony {
@Override @Override
protected void initHead(float yOffset, float stretch) { protected void initHead(float yOffset, float stretch) {
bipedHead = new PonyRenderer(this, 0, 0) head = new PonyRenderer(this, 0, 0)
.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) .offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2)
.box(-4, -4, -4, 8, 8, 8, stretch) .box(-4, -4, -4, 8, 8, 8, stretch)
.tex(12, 16).box(-4, -6, 1, 2, 2, 2, stretch) .tex(12, 16).box(-4, -6, 1, 2, 2, 2, stretch)
.flip().box( 2, -6, 1, 2, 2, 2, stretch); .flip().box( 2, -6, 1, 2, 2, 2, stretch);
leftHorn = ((PonyRenderer)bipedHead).child().tex(0, 52); leftHorn = ((PonyRenderer)head).child().tex(0, 52);
leftHorn.tex(0, 52) leftHorn.tex(0, 52)
.rotate(0.1F, 0, -0.8F) .rotate(0.1F, 0, -0.8F)
.offset(-2, -10, -3) .offset(-2, -10, -3)
@ -92,7 +91,7 @@ public class ModelEnderStallion extends ModelSkeletonPony {
.around(-3.9F, -6, 0.001F) .around(-3.9F, -6, 0.001F)
.box(0, 0, 0, 2, 6, 2, stretch); .box(0, 0, 0, 2, 6, 2, stretch);
rightHorn = ((PonyRenderer)bipedHead).child().tex(0, 52); rightHorn = ((PonyRenderer)head).child().tex(0, 52);
rightHorn.tex(8, 52) rightHorn.tex(8, 52)
.rotate(0.1F, 0, 0.8F) .rotate(0.1F, 0, 0.8F)
.offset(0, -10, -3) .offset(0, -10, -3)
@ -102,7 +101,7 @@ public class ModelEnderStallion extends ModelSkeletonPony {
.around(3.9F, -6, 0.001F) .around(3.9F, -6, 0.001F)
.box(0, 0, 0, 2, 6, 2, stretch); .box(0, 0, 0, 2, 6, 2, stretch);
bipedHeadwear = new PonyRenderer(this, 32, 0) headwear = new PonyRenderer(this, 32, 0)
.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z) .offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2)
.box(-4, -4, -4, 8, 8, 8, stretch - 0.5F); .box(-4, -4, -4, 8, 8, 8, stretch - 0.5F);
@ -112,18 +111,18 @@ public class ModelEnderStallion extends ModelSkeletonPony {
} }
@Override @Override
protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float ticks) { protected void rotateArmHolding(Cuboid arm, float direction, float swingProgress, float ticks) {
arm.rotateAngleX = -0.3707964F; arm.pitch = -0.3707964F;
arm.rotateAngleX += 0.4F + MathHelper.sin(ticks * 0.067F) / 10; arm.pitch += 0.4F + MathHelper.sin(ticks * 0.067F) / 10;
} }
@Override @Override
protected void preInitLegs() { protected void preInitLegs() {
bipedLeftArm = new ModelRenderer(this, 0, 20); leftArm = new Cuboid(this, 0, 20);
bipedRightArm = new ModelRenderer(this, 0, 20); rightArm = new Cuboid(this, 0, 20);
bipedLeftLeg = new ModelRenderer(this, 0, 20); leftLeg = new Cuboid(this, 0, 20);
bipedRightLeg = new ModelRenderer(this, 0, 20); rightLeg = new Cuboid(this, 0, 20);
} }
@Override @Override

View file

@ -0,0 +1,37 @@
package com.minelittlepony.client.model.entities;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.GuardianEntityModel;
import net.minecraft.entity.mob.GuardianEntity;
import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.IPonyMixinModel;
public class ModelGuardianPony extends GuardianEntityModel implements IPonyMixinModel.Caster<GuardianEntity, ModelSeapony<GuardianEntity>, PonyRenderer> {
private final ModelSeapony<GuardianEntity> mixin = new ModelSeapony<>();
@Override
public void setAngles(GuardianEntity entity_1, float float_1, float float_2, float float_3, float float_4, float float_5, float float_6) {
mixin().setAngles(entity_1, float_1, float_2, float_3, float_4, float_5, float_6);
}
@Override
public void render(GuardianEntity var1, float var2, float var3, float var4, float var5, float var6, float var7) {
mixin().render(var1, var2, var3, var4, var5, var6, var7);
}
@Override
public void animateModel(GuardianEntity entity_1, float float_1, float float_2, float float_3) {
mixin().animateModel(entity_1, float_1, float_2, float_3);
}
@Override
public void copyStateTo(EntityModel<GuardianEntity> entityModel_1) {
mixin().copyStateTo(entityModel_1);
}
@Override
public ModelSeapony<GuardianEntity> mixin() {
return mixin;
}
}

View file

@ -1,59 +1,56 @@
package com.minelittlepony.client.model.entities; package com.minelittlepony.client.model.entities;
import net.minecraft.client.renderer.entity.model.ModelRenderer; import net.minecraft.client.model.Cuboid;
import net.minecraft.entity.Entity; import net.minecraft.entity.mob.IllagerEntity;
import net.minecraft.entity.monster.AbstractIllager; import net.minecraft.util.AbsoluteHand;
import net.minecraft.entity.monster.AbstractIllager.IllagerArmPose;
import net.minecraft.util.EnumHandSide;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.model.ModelMobPony; import com.minelittlepony.client.model.ModelMobPony;
public class ModelIllagerPony extends ModelMobPony { public class ModelIllagerPony<T extends IllagerEntity> extends ModelMobPony<T> {
@Override @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setAngles(T illager, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setAngles(illager, move, swing, ticks, headYaw, headPitch, scale);
AbstractIllager illager = (AbstractIllager) entity; IllagerEntity.State pose = illager.getState();
IllagerArmPose pose = illager.getArmPose();
boolean rightHanded = illager.getPrimaryHand() == EnumHandSide.RIGHT; boolean rightHanded = illager.getMainHand() == AbsoluteHand.RIGHT;
float mult = rightHanded ? 1 : -1; float mult = rightHanded ? 1 : -1;
ModelRenderer arm = getArm(illager.getPrimaryHand()); Cuboid arm = getArm(illager.getMainHand());
if (pose == IllagerArmPose.ATTACKING) { if (pose == IllagerEntity.State.ATTACKING) {
// vindicator attacking // vindicator attacking
float f = MathHelper.sin(swingProgress * (float) Math.PI); float f = MathHelper.sin(getSwingAmount() * (float) Math.PI);
float f1 = MathHelper.sin((1.0F - (1.0F - swingProgress) * (1.0F - swingProgress)) * (float) Math.PI); float f1 = MathHelper.sin((1 - (1 - getSwingAmount()) * (1 - getSwingAmount())) * (float) Math.PI);
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(ticks * 0.067F) * 0.05F; float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
bipedRightArm.rotateAngleZ = cos; rightArm.roll = cos;
bipedLeftArm.rotateAngleZ = cos; leftArm.roll = cos;
bipedRightArm.rotateAngleY = 0.15707964F; rightArm.yaw = 0.15707964F;
bipedLeftArm.rotateAngleY = -0.15707964F; leftArm.yaw = -0.15707964F;
arm.rotateAngleX = -1.8849558F + MathHelper.cos(ticks * 0.09F) * 0.15F; arm.pitch = -1.8849558F + MathHelper.cos(ticks * 0.09F) * 0.15F;
arm.rotateAngleX += f * 2.2F - f1 * 0.4F; arm.pitch += f * 2.2F - f1 * 0.4F;
bipedRightArm.rotateAngleX += sin; rightArm.pitch += sin;
bipedLeftArm.rotateAngleX -= sin; leftArm.pitch -= sin;
} else if (pose == IllagerArmPose.SPELLCASTING) { } else if (pose == IllagerEntity.State.SPELLCASTING) {
// waving arms! // waving arms!
// this.bipedRightArm.rotationPointZ = 0; // rightArm.rotationPointZ = 0;
arm.rotateAngleX = (float) (-.75F * Math.PI); arm.pitch = (float) (-.75F * Math.PI);
arm.rotateAngleZ = mult * MathHelper.cos(ticks * 0.6662F) / 4; arm.roll = mult * MathHelper.cos(ticks * 0.6662F) / 4;
arm.rotateAngleY = mult * 1.1F; arm.yaw = mult * 1.1F;
} else if (pose == IllagerArmPose.BOW_AND_ARROW) { } else if (pose == IllagerEntity.State.BOW_AND_ARROW) {
aimBow(arm, ticks); aimBow(arm, ticks);
} }
} }
public ModelRenderer getArm(EnumHandSide side) { @Override
return canCast() ? getUnicornArmForSide(side) : getArmForSide(side); public Cuboid getArm(AbsoluteHand side) {
return canCast() ? getUnicornArmForSide(side) : super.getArm(side);
} }
} }

View file

@ -9,15 +9,14 @@ import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.model.armour.IEquestrianArmour;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class ModelSeapony extends ModelUnicorn { public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
PonyRenderer bodyCenter; PonyRenderer bodyCenter;
@ -32,15 +31,15 @@ public class ModelSeapony extends ModelUnicorn {
@Override @Override
public IEquestrianArmour<?> createArmour() { public IEquestrianArmour<?> createArmour() {
return new PonyArmor(new Armour(), new Armour()); return new PonyArmor<>(new Armour(), new Armour());
} }
@Override @Override
public void updateLivingState(EntityLivingBase entity, IPony pony) { public void updateLivingState(T entity, IPony pony) {
super.updateLivingState(entity, pony); super.updateLivingState(entity, pony);
// Seaponies can't sneak, silly // Seaponies can't sneak, silly
isSneak = false; isSneaking = false;
} }
@Override @Override
@ -57,10 +56,10 @@ public class ModelSeapony extends ModelUnicorn {
protected void initLegs(float yOffset, float stretch) { protected void initLegs(float yOffset, float stretch) {
super.initLegs(yOffset, stretch); super.initLegs(yOffset, stretch);
// hide the back legs // hide the back legs
bipedLeftLeg.showModel = false; leftLeg.visible = false;
bipedRightLeg.showModel = false; rightLeg.visible = false;
bipedLeftLegwear.showModel = false; leftLegOverlay.visible = false;
bipedRightLegwear.showModel = false; rightLegOverlay.visible = false;
centerFin = new PlaneRenderer(this, 58, 28) centerFin = new PlaneRenderer(this, 58, 28)
.rotate(PI / 2 - 0.1F, 0, 0).around(0, 6, 9) .rotate(PI / 2 - 0.1F, 0, 0).around(0, 6, 9)
@ -90,8 +89,8 @@ public class ModelSeapony extends ModelUnicorn {
} }
@Override @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
float flapMotion = MathHelper.cos(ticks / 10) / 5; float flapMotion = MathHelper.cos(ticks / 10) / 5;
@ -101,41 +100,41 @@ public class ModelSeapony extends ModelUnicorn {
float finAngle = FIN_ROT_Y + flapMotion; float finAngle = FIN_ROT_Y + flapMotion;
leftFin.rotateAngleY = finAngle; leftFin.yaw = finAngle;
rightFin.rotateAngleY = -finAngle; rightFin.yaw = -finAngle;
if (!isSleeping()) { if (!isSleeping()) {
centerFin.rotateAngleZ = flapMotion; centerFin.roll = flapMotion;
} }
if (!entity.isInWater()) { if (!entity.isInWater()) {
bipedLeftArm.rotateAngleX -= 0.5F; leftArm.pitch -= 0.5F;
bipedRightArm.rotateAngleX -= 0.5F; rightArm.pitch -= 0.5F;
} }
if (!entity.isInWater() || entity.onGround) { if (!entity.isInWater() || entity.onGround) {
bipedLeftArm.rotateAngleY -= 0.5F; leftArm.yaw -= 0.5F;
bipedRightArm.rotateAngleY += 0.5F; rightArm.yaw += 0.5F;
} }
} }
@Override @Override
protected void rotateLegs(float move, float swing, float ticks, Entity entity) { protected void rotateLegs(float move, float swing, float ticks, T entity) {
super.rotateLegs(move, swing, ticks, entity); super.rotateLegs(move, swing, ticks, entity);
bipedLeftArm.rotateAngleX -= 1.4F; leftArm.pitch -= 1.4F;
bipedLeftArm.rotateAngleY -= 0.3F; leftArm.yaw -= 0.3F;
bipedRightArm.rotateAngleX -= 1.4F; rightArm.pitch -= 1.4F;
bipedRightArm.rotateAngleY += 0.3F; rightArm.yaw += 0.3F;
} }
@Override @Override
protected void rotateLegsSwimming(float move, float swing, float ticks, Entity entity) { protected void rotateLegsSwimming(float move, float swing, float ticks, T entity) {
super.rotateLegsOnGround(move, swing, ticks, entity); super.rotateLegsOnGround(move, swing, ticks, entity);
} }
@Override @Override
public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { public void render(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
setVisible(bipedLeftArmwear.showModel); setVisible(leftArmOverlay.visible);
super.render(entity, move, swing, ticks, headYaw, headPitch, scale); super.render(entity, move, swing, ticks, headYaw, headPitch, scale);
} }
@ -148,12 +147,12 @@ public class ModelSeapony extends ModelUnicorn {
} }
@Override @Override
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
bipedBody.render(scale); body.render(scale);
bodyCenter.render(scale); bodyCenter.render(scale);
bipedBody.postRender(scale); body.applyTransform(scale);
tail.renderPart(scale, entity.getUniqueID()); tail.renderPart(scale, entity.getUuid());
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GlStateManager.enableBlend(); GlStateManager.enableBlend();
@ -178,30 +177,30 @@ public class ModelSeapony extends ModelUnicorn {
super.setVisible(visible); super.setVisible(visible);
// hide the back legs // hide the back legs
bipedLeftLeg.showModel = false; leftLeg.visible = false;
bipedRightLeg.showModel = false; rightLeg.visible = false;
bipedLeftLegwear.showModel = false; leftLegOverlay.visible = false;
bipedRightLegwear.showModel = false; rightLegOverlay.visible = false;
} }
class Armour extends ModelPonyArmor { class Armour extends ModelPonyArmor<T> {
@Override @Override
public void showBoots() { public void showBoots() {
bipedRightArm.showModel = true; rightArm.visible = true;
bipedLeftArm.showModel = true; leftArm.visible = true;
} }
@Override @Override
public void updateLivingState(EntityLivingBase entity, IPony pony) { public void updateLivingState(T entity, IPony pony) {
super.updateLivingState(entity, pony); super.updateLivingState(entity, pony);
// Seaponies can't sneak, silly // Seaponies can't sneak, silly
isSneak = false; isSneaking = false;
} }
@Override @Override
protected void rotateLegsSwimming(float move, float swing, float ticks, Entity entity) { protected void rotateLegsSwimming(float move, float swing, float ticks, T entity) {
super.rotateLegsOnGround(move, swing, ticks, entity); super.rotateLegsOnGround(move, swing, ticks, entity);
} }

View file

@ -1,34 +1,32 @@
package com.minelittlepony.client.model.entities; package com.minelittlepony.client.model.entities;
import net.minecraft.entity.Entity; import net.minecraft.entity.mob.WitherSkeletonEntity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.monster.AbstractSkeleton; import net.minecraft.item.Items;
import net.minecraft.entity.monster.EntityWitherSkeleton;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand; import net.minecraft.util.AbsoluteHand;
import net.minecraft.util.EnumHandSide; import net.minecraft.util.Hand;
import com.minelittlepony.client.model.ModelMobPony; import com.minelittlepony.client.model.ModelMobPony;
public class ModelSkeletonPony extends ModelMobPony { public class ModelSkeletonPony<T extends HostileEntity> extends ModelMobPony<T> {
public boolean isUnicorn; public boolean isUnicorn;
public boolean isWithered; public boolean isWithered;
@Override @Override
public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { public void animateModel(T entity, float move, float swing, float ticks) {
isUnicorn = entity.getUniqueID().getLeastSignificantBits() % 3 != 0; isUnicorn = entity.getUuid().getLeastSignificantBits() % 3 != 0;
isWithered = entity instanceof EntityWitherSkeleton; isWithered = entity instanceof WitherSkeletonEntity;
rightArmPose = ArmPose.EMPTY; rightArmPose = ArmPose.EMPTY;
leftArmPose = ArmPose.EMPTY; leftArmPose = ArmPose.EMPTY;
ItemStack mainHand = entity.getHeldItem(EnumHand.MAIN_HAND); ItemStack mainHand = entity.getStackInHand(Hand.MAIN_HAND);
ItemStack offHand = entity.getHeldItem(EnumHand.OFF_HAND); ItemStack offHand = entity.getStackInHand(Hand.OFF_HAND);
boolean right = entity.getPrimaryHand() == EnumHandSide.RIGHT; boolean right = entity.getMainHand() == AbsoluteHand.RIGHT;
if (!offHand.isEmpty()) { if (!offHand.isEmpty()) {
if (right) { if (right) {
@ -39,7 +37,7 @@ public class ModelSkeletonPony extends ModelMobPony {
} }
if (!mainHand.isEmpty()) { if (!mainHand.isEmpty()) {
ArmPose pose = mainHand.getItem() == Items.BOW && ((AbstractSkeleton)entity).isSwingingArms() ? ArmPose.BOW_AND_ARROW : ArmPose.ITEM; ArmPose pose = mainHand.getItem() == Items.BOW && entity.isAttacking() ? ArmPose.BOW_AND_ARROW : ArmPose.ITEM;
if (right) { if (right) {
rightArmPose = pose; rightArmPose = pose;
@ -49,25 +47,25 @@ public class ModelSkeletonPony extends ModelMobPony {
} }
super.setLivingAnimations(entity, move, swing, ticks); super.animateModel(entity, move, swing, ticks);
} }
@Override @Override
protected void rotateLegs(float move, float swing, float ticks, Entity 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) {
if (canCast()) { if (canCast()) {
rotateArmHolding(unicornArmRight, -1, swingProgress, ticks); rotateArmHolding(unicornArmRight, -1, getSwingAmount(), ticks);
} else { } else {
rotateArmHolding(bipedRightArm, -1, swingProgress, ticks); rotateArmHolding(rightArm, -1, getSwingAmount(), ticks);
} }
} }
if (leftArmPose != ArmPose.EMPTY) { if (leftArmPose != ArmPose.EMPTY) {
if (canCast()) { if (canCast()) {
rotateArmHolding(unicornArmLeft, -1, swingProgress, ticks); rotateArmHolding(unicornArmLeft, -1, getSwingAmount(), ticks);
} else { } else {
rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); rotateArmHolding(leftArm, -1, getSwingAmount(), ticks);
} }
} }
} }

View file

@ -1,20 +1,19 @@
package com.minelittlepony.client.model.entities; package com.minelittlepony.client.model.entities;
import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.village.VillagerDataContainer;
import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.village.VillagerProfession;
import net.minecraft.entity.passive.EntityVillager;
import com.minelittlepony.client.model.ModelMobPony; import com.minelittlepony.client.model.ModelMobPony;
import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
public class ModelVillagerPony extends ModelMobPony { public class ModelVillagerPony<T extends LivingEntity & VillagerDataContainer> extends ModelMobPony<T> {
public PlaneRenderer apron; public PlaneRenderer apron;
public PlaneRenderer trinket; public PlaneRenderer trinket;
private int profession; private VillagerProfession profession;
public boolean special; public boolean special;
public boolean special2; public boolean special2;
@ -22,25 +21,25 @@ public class ModelVillagerPony extends ModelMobPony {
@Override @Override
protected void shakeBody(float move, float swing, float bodySwing, float ticks) { protected void shakeBody(float move, float swing, float bodySwing, float ticks) {
super.shakeBody(move, swing, bodySwing, ticks); super.shakeBody(move, swing, bodySwing, ticks);
apron.rotateAngleY = bodySwing; apron.yaw = bodySwing;
trinket.rotateAngleY = bodySwing; trinket.yaw = bodySwing;
} }
@Override @Override
public void setLivingAnimations(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTickTime) { public void animateModel(T entity, float limbSwing, float limbSwingAmount, float partialTickTime) {
profession = getProfession(entity); profession = entity.getVillagerData().getProfession();
special = "Derpy".equals(entity.getCustomName().getUnformattedComponentText()); special = "Derpy".equals(entity.getCustomName().getString());
special2 = special && entity.getUniqueID().getLeastSignificantBits() % 20 == 0; special2 = special && entity.getUuid().getLeastSignificantBits() % 20 == 0;
} }
@Override @Override
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale); super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale);
if (!special) { if (!special && profession != VillagerProfession.NONE && profession != VillagerProfession.NITWIT) {
if (profession == 2) { if (profession == VillagerProfession.BUTCHER) {
trinket.render(scale); trinket.render(scale);
} else if (profession > 2) { } else {
apron.render(scale); apron.render(scale);
} }
} }
@ -54,7 +53,7 @@ public class ModelVillagerPony extends ModelMobPony {
@Override @Override
public boolean isWearing(Wearable wearable) { public boolean isWearing(Wearable wearable) {
if (wearable == Wearable.SADDLE_BAGS) { if (wearable == Wearable.SADDLE_BAGS) {
return !special && profession > -1 && profession < 2; return !special && profession != VillagerProfession.NONE && profession == VillagerProfession.NITWIT;
} }
if (wearable == Wearable.MUFFIN) { if (wearable == Wearable.MUFFIN) {
@ -64,17 +63,6 @@ public class ModelVillagerPony extends ModelMobPony {
return super.isWearing(wearable); return super.isWearing(wearable);
} }
@SuppressWarnings("deprecation") // let me use getProfession in peace. I don't care that forge has their own one.
protected int getProfession(Entity entity) {
if (entity instanceof EntityVillager) {
return ((EntityVillager) entity).getProfession();
}
if (entity instanceof EntityZombieVillager) {
return ((EntityZombieVillager) entity).getProfession();
}
return -1;
}
@Override @Override
public void init(float yOffset, float stretch) { public void init(float yOffset, float stretch) {
super.init(yOffset, stretch); super.init(yOffset, stretch);

View file

@ -1,38 +1,35 @@
package com.minelittlepony.client.model.entities; package com.minelittlepony.client.model.entities;
import net.minecraft.entity.Entity; import net.minecraft.entity.mob.WitchEntity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityWitch;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.model.races.ModelZebra; import com.minelittlepony.client.model.races.ModelZebra;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
public class ModelWitchPony extends ModelZebra { public class ModelWitchPony extends ModelZebra<WitchEntity> {
public ModelWitchPony() { public ModelWitchPony() {
super(false); super(false);
} }
@Override @Override
public void updateLivingState(EntityLivingBase entity, IPony pony) { public void updateLivingState(WitchEntity entity, IPony pony) {
super.updateLivingState(entity, pony); super.updateLivingState(entity, pony);
EntityWitch witch = ((EntityWitch) entity);
if ("Filly".equals(entity.getCustomName().getUnformattedComponentText())) { if ("Filly".equals(entity.getCustomName().getString())) {
isChild = true; isChild = true;
} }
leftArmPose = ArmPose.EMPTY; leftArmPose = ArmPose.EMPTY;
rightArmPose = witch.getHeldItemMainhand().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM; rightArmPose = entity.getMainHandStack().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM;
} }
@Override @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setAngles(WitchEntity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
if (((EntityWitch)entity).isDrinkingPotion()) { if (entity.isDrinking()) {
float noseRot = MathHelper.sin(entity.ticksExisted); float noseRot = MathHelper.sin(entity.age);
snout.rotate(noseRot * 4.5F * 0.02F, 0, noseRot * 2.5F * 0.02F); snout.rotate(noseRot * 4.5F * 0.02F, 0, noseRot * 2.5F * 0.02F);
} else { } else {
@ -47,20 +44,20 @@ public class ModelWitchPony extends ModelZebra {
float legDrinkingAngle = -1 * PI/3 + rot; float legDrinkingAngle = -1 * PI/3 + rot;
bipedRightArm.rotateAngleX = legDrinkingAngle; rightArm.pitch = legDrinkingAngle;
bipedRightArmwear.rotateAngleX = legDrinkingAngle; rightArmOverlay.pitch = legDrinkingAngle;
bipedRightArm.rotateAngleY = 0.1F; rightArm.yaw = 0.1F;
bipedRightArmwear.rotateAngleY = 0.1F; rightArmOverlay.yaw = 0.1F;
bipedRightArm.offsetZ = 0.1f; rightArm.z = 0.1f;
bipedRightArmwear.offsetZ = 0.1f; rightArmOverlay.z = 0.1f;
if (rot > 0) rot = 0; if (rot > 0) rot = 0;
bipedHead.rotateAngleX = -rot / 2; head.pitch = -rot / 2;
bipedHeadwear.rotateAngleX = -rot / 2; headwear.pitch = -rot / 2;
} else { } else {
bipedRightArm.offsetZ = 0; rightArm.z = 0;
bipedRightArmwear.offsetZ = 0; rightArmOverlay.z = 0;
} }

View file

@ -3,30 +3,29 @@ package com.minelittlepony.client.model.entities;
import com.minelittlepony.client.model.ModelMobPony; import com.minelittlepony.client.model.ModelMobPony;
import com.minelittlepony.client.util.render.AbstractRenderer; import com.minelittlepony.client.util.render.AbstractRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class ModelZombiePony extends ModelMobPony { public class ModelZombiePony<Zombie extends HostileEntity> extends ModelMobPony<Zombie> {
public boolean isPegasus; public boolean isPegasus;
@Override @Override
public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { public void animateModel(Zombie entity, float move, float swing, float ticks) {
isPegasus = entity.getUniqueID().getLeastSignificantBits() % 30 == 0; isPegasus = entity.getUuid().getLeastSignificantBits() % 30 == 0;
} }
@Override @Override
protected void rotateLegs(float move, float swing, float ticks, Entity entity) { protected void rotateLegs(float move, float swing, float ticks, Zombie entity) {
super.rotateLegs(move, swing, ticks, entity); super.rotateLegs(move, swing, ticks, entity);
if (rightArmPose != ArmPose.EMPTY) return; if (rightArmPose != ArmPose.EMPTY) return;
if (islookAngleRight(move)) { if (islookAngleRight(move)) {
rotateArmHolding(bipedRightArm, 1, swingProgress, ticks); rotateArmHolding(rightArm, 1, getSwingAmount(), ticks);
AbstractRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); AbstractRenderer.shiftRotationPoint(rightArm, 0.5F, 1.5F, 3);
} else { } else {
rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); rotateArmHolding(leftArm, -1, getSwingAmount(), ticks);
AbstractRenderer.shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); AbstractRenderer.shiftRotationPoint(leftArm, -0.5F, 1.5F, 3);
} }
} }

View file

@ -1,23 +1,23 @@
package com.minelittlepony.client.model.entities; package com.minelittlepony.client.model.entities;
import net.minecraft.entity.Entity; import net.minecraft.entity.mob.ZombieVillagerEntity;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.util.render.AbstractRenderer; import com.minelittlepony.client.util.render.AbstractRenderer;
public class ModelZombieVillagerPony extends ModelVillagerPony { public class ModelZombieVillagerPony extends ModelVillagerPony<ZombieVillagerEntity> {
@Override @Override
protected void rotateLegs(float move, float swing, float ticks, Entity entity) { protected void rotateLegs(float move, float swing, float ticks, ZombieVillagerEntity entity) {
super.rotateLegs(move, swing, ticks, entity); super.rotateLegs(move, swing, ticks, entity);
if (rightArmPose != ArmPose.EMPTY) return; if (rightArmPose != ArmPose.EMPTY) return;
if (islookAngleRight(move)) { if (islookAngleRight(move)) {
rotateArmHolding(bipedRightArm, 1, swingProgress, ticks); rotateArmHolding(rightArm, 1, getSwingAmount(), ticks);
AbstractRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); AbstractRenderer.shiftRotationPoint(rightArm, 0.5F, 1.5F, 3);
} else { } else {
rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); rotateArmHolding(leftArm, -1, getSwingAmount(), ticks);
AbstractRenderer.shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); AbstractRenderer.shiftRotationPoint(leftArm, -0.5F, 1.5F, 3);
} }
} }

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.model.entities; package com.minelittlepony.client.model.entities;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,15 +1,15 @@
package com.minelittlepony.client.model.gear; package com.minelittlepony.client.model.gear;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.renderer.entity.model.ModelBase; import net.minecraft.client.model.Model;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.texture.TextureManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.model.gear.IGear;
public abstract class AbstractGear extends ModelBase implements IGear, PonyModelConstants { public abstract class AbstractGear extends Model implements IGear {
public AbstractGear() { public AbstractGear() {
textureWidth = 64; textureWidth = 64;
@ -22,10 +22,10 @@ public abstract class AbstractGear extends ModelBase implements IGear, PonyModel
public void renderSeparately(Entity entity, float scale) { public void renderSeparately(Entity entity, float scale) {
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
TextureManager tex = Minecraft.getInstance().getRenderManager().textureManager; TextureManager tex = MinecraftClient.getInstance().getEntityRenderManager().textureManager;
tex.bindTexture(getTexture(entity)); tex.bindTexture(getTexture(entity));
renderPart(scale, entity.getUniqueID()); renderPart(scale, entity.getUuid());
GL11.glPopAttrib(); GL11.glPopAttrib();
} }

View file

@ -1,15 +1,15 @@
package com.minelittlepony.client.model.gear; package com.minelittlepony.client.model.gear;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.minelittlepony.client.model.IClientModel;
import com.minelittlepony.client.util.render.Color; import com.minelittlepony.client.util.render.Color;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
import java.util.Calendar; import java.util.Calendar;
@ -17,7 +17,7 @@ import java.util.UUID;
public class ChristmasHat extends AbstractGear { public class ChristmasHat extends AbstractGear {
private static final ResourceLocation TEXTURE = new ResourceLocation("minelittlepony", "textures/models/antlers.png"); private static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/models/antlers.png");
private PonyRenderer left; private PonyRenderer left;
private PonyRenderer right; private PonyRenderer right;
@ -26,7 +26,7 @@ public class ChristmasHat extends AbstractGear {
@Override @Override
public void init(float yOffset, float stretch) { public void init(float yOffset, float stretch) {
this.boxList.clear(); this.cuboidList.clear();
left = new PonyRenderer(this, 0, 0).size(16, 8) left = new PonyRenderer(this, 0, 0).size(16, 8)
.around(-7, 0.5F, 0.5F) .around(-7, 0.5F, 0.5F)
@ -48,12 +48,12 @@ public class ChristmasHat extends AbstractGear {
} }
@Override @Override
public boolean canRender(IClientModel model, Entity entity) { public boolean canRender(IPonyModel<?> model, Entity entity) {
return isChristmasDay() || model.isWearing(Wearable.ANTLERS); return isChristmasDay() || model.isWearing(Wearable.ANTLERS);
} }
@Override @Override
public void setLivingAnimations(IClientModel model, Entity entity) { public void setLivingAnimations(IPonyModel<?> model, Entity entity) {
tint = model.getMetadata().getGlowColor(); tint = model.getMetadata().getGlowColor();
} }
@ -68,8 +68,8 @@ public class ChristmasHat extends AbstractGear {
bodySwing += 0.1F; bodySwing += 0.1F;
left.rotateAngleZ = bodySwing; left.roll = bodySwing;
right.rotateAngleZ = -bodySwing; right.roll = -bodySwing;
} }
private boolean isChristmasDay() { private boolean isChristmasDay() {
@ -84,7 +84,7 @@ public class ChristmasHat extends AbstractGear {
} }
@Override @Override
public ResourceLocation getTexture(Entity entity) { public Identifier getTexture(Entity entity) {
return TEXTURE; return TEXTURE;
} }

View file

@ -1,18 +1,19 @@
package com.minelittlepony.client.model.gear; package com.minelittlepony.client.model.gear;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import com.minelittlepony.client.model.IClientModel;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.gear.IStackable;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
import java.util.UUID; import java.util.UUID;
public class Muffin extends AbstractGear implements IStackable { public class Muffin extends AbstractGear implements IStackable {
private static final ResourceLocation TEXTURE = new ResourceLocation("minelittlepony", "textures/models/muffin.png"); private static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/models/muffin.png");
private PonyRenderer crown; private PonyRenderer crown;
@ -33,7 +34,7 @@ public class Muffin extends AbstractGear implements IStackable {
} }
@Override @Override
public boolean canRender(IClientModel model, Entity entity) { public boolean canRender(IPonyModel<?> model, Entity entity) {
return model.isWearing(Wearable.MUFFIN); return model.isWearing(Wearable.MUFFIN);
} }
@ -43,7 +44,7 @@ public class Muffin extends AbstractGear implements IStackable {
} }
@Override @Override
public ResourceLocation getTexture(Entity entity) { public Identifier getTexture(Entity entity) {
return TEXTURE; return TEXTURE;
} }

View file

@ -1,16 +1,16 @@
package com.minelittlepony.client.model.gear; package com.minelittlepony.client.model.gear;
import com.minelittlepony.client.model.IClientModel;
import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPegasus; import com.minelittlepony.model.IPegasus;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
import com.mojang.blaze3d.platform.GlStateManager;
import java.util.UUID; import java.util.UUID;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class SaddleBags extends AbstractGear { public class SaddleBags extends AbstractGear {
@ -25,7 +25,7 @@ public class SaddleBags extends AbstractGear {
float dropAmount = 0; float dropAmount = 0;
private IClientModel model; private IPonyModel<?> model;
@Override @Override
public void init(float yOffset, float stretch) { public void init(float yOffset, float stretch) {
@ -47,7 +47,7 @@ public class SaddleBags extends AbstractGear {
.west( 4.0002F, -1, 0, 1, 3, stretch) // otherwise straps .west( 4.0002F, -1, 0, 1, 3, stretch) // otherwise straps
.west(-4.0002F, 0, 0, 1, 3, stretch) // clip into the body .west(-4.0002F, 0, 0, 1, 3, stretch) // clip into the body
.west(-4.0002F, -1, 0, 1, 3, stretch) .west(-4.0002F, -1, 0, 1, 3, stretch)
.rotateAngleX = ROTATE_270; .pitch = ROTATE_270;
leftBag.offset(x, y, z).around(0, 4, 4) leftBag.offset(x, y, z).around(0, 4, 4)
.tex(56, 25).south(0, 0, 0, 3, 6, stretch) .tex(56, 25).south(0, 0, 0, 3, 6, stretch)
@ -57,7 +57,7 @@ public class SaddleBags extends AbstractGear {
.child(0).offset(z, y, -x).tex(56, 16) .child(0).offset(z, y, -x).tex(56, 16)
.top(0, 0, -3, 8, 3, stretch) .top(0, 0, -3, 8, 3, stretch)
.tex(56, 22).flipZ().bottom(0, 6, -3, 8, 3, stretch) .tex(56, 22).flipZ().bottom(0, 6, -3, 8, 3, stretch)
.rotateAngleY = ROTATE_270; .yaw = ROTATE_270;
x += 3; x += 3;
@ -69,11 +69,11 @@ public class SaddleBags extends AbstractGear {
.child(0).offset(z, y, x).tex(56, 16) .child(0).offset(z, y, x).tex(56, 16)
.flipZ().top(0, 0, -3, 8, 3, stretch) .flipZ().top(0, 0, -3, 8, 3, stretch)
.tex(56, 22).flipZ().bottom(0, 6, -3, 8, 3, stretch) .tex(56, 22).flipZ().bottom(0, 6, -3, 8, 3, stretch)
.rotateAngleY = ROTATE_270; .yaw = ROTATE_270;
} }
@Override @Override
public void setLivingAnimations(IClientModel model, Entity entity) { public void setLivingAnimations(IPonyModel<?> model, Entity entity) {
this.model = model; this.model = model;
hangLow = false; hangLow = false;
@ -92,16 +92,16 @@ public class SaddleBags extends AbstractGear {
bodySwing = MathHelper.cos(mve + pi) * srt; bodySwing = MathHelper.cos(mve + pi) * srt;
leftBag.rotateAngleX = bodySwing; leftBag.pitch = bodySwing;
rightBag.rotateAngleX = bodySwing; rightBag.pitch = bodySwing;
if (model instanceof IPegasus && model.isFlying()) { if (model instanceof IPegasus && model.isFlying()) {
bodySwing = ((IPegasus)model).getWingRotationFactor(ticks) - ROTATE_270; bodySwing = ((IPegasus)model).getWingRotationFactor(ticks) - ROTATE_270;
bodySwing /= 10; bodySwing /= 10;
} }
leftBag.rotateAngleZ = bodySwing; leftBag.roll = bodySwing;
rightBag.rotateAngleZ = -bodySwing; rightBag.roll = -bodySwing;
dropAmount = hangLow ? 0.15F : 0; dropAmount = hangLow ? 0.15F : 0;
} }
@ -126,7 +126,7 @@ public class SaddleBags extends AbstractGear {
} }
@Override @Override
public boolean canRender(IClientModel model, Entity entity) { public boolean canRender(IPonyModel<?> model, Entity entity) {
return model.isWearing(Wearable.SADDLE_BAGS); return model.isWearing(Wearable.SADDLE_BAGS);
} }
@ -136,7 +136,7 @@ public class SaddleBags extends AbstractGear {
} }
@Override @Override
public ResourceLocation getTexture(Entity entity) { public Identifier getTexture(Entity entity) {
// use the default // use the default
return null; return null;
} }

View file

@ -1,18 +1,19 @@
package com.minelittlepony.client.model.gear; package com.minelittlepony.client.model.gear;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import com.minelittlepony.client.model.IClientModel;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.gear.IStackable;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
import java.util.UUID; import java.util.UUID;
public class Stetson extends AbstractGear implements IStackable { public class Stetson extends AbstractGear implements IStackable {
private static final ResourceLocation TEXTURE = new ResourceLocation("minelittlepony", "textures/models/stetson.png"); private static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/models/stetson.png");
private PlaneRenderer rimshot; private PlaneRenderer rimshot;
@ -38,7 +39,7 @@ public class Stetson extends AbstractGear implements IStackable {
} }
@Override @Override
public ResourceLocation getTexture(Entity entity) { public Identifier getTexture(Entity entity) {
return TEXTURE; return TEXTURE;
} }
@ -48,7 +49,7 @@ public class Stetson extends AbstractGear implements IStackable {
} }
@Override @Override
public boolean canRender(IClientModel model, Entity entity) { public boolean canRender(IPonyModel<?> model, Entity entity) {
return model.isWearing(Wearable.STETSON); return model.isWearing(Wearable.STETSON);
} }

View file

@ -1,18 +1,19 @@
package com.minelittlepony.client.model.gear; package com.minelittlepony.client.model.gear;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import com.minelittlepony.client.model.IClientModel;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.gear.IStackable;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
import java.util.UUID; import java.util.UUID;
public class WitchHat extends AbstractGear implements IStackable { public class WitchHat extends AbstractGear implements IStackable {
private static final ResourceLocation WITCH_TEXTURES = new ResourceLocation("textures/entity/witch.png"); private static final Identifier WITCH_TEXTURES = new Identifier("textures/entity/witch.png");
private PonyRenderer witchHat; private PonyRenderer witchHat;
@ -39,7 +40,7 @@ public class WitchHat extends AbstractGear implements IStackable {
@Override @Override
public boolean canRender(IClientModel model, Entity entity) { public boolean canRender(IPonyModel<?> model, Entity entity) {
return model.isWearing(Wearable.HAT); return model.isWearing(Wearable.HAT);
} }
@ -49,7 +50,7 @@ public class WitchHat extends AbstractGear implements IStackable {
} }
@Override @Override
public ResourceLocation getTexture(Entity entity) { public Identifier getTexture(Entity entity) {
return WITCH_TEXTURES; return WITCH_TEXTURES;
} }

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.model.gear; package com.minelittlepony.client.model.gear;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.model; package com.minelittlepony.client.model;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -3,11 +3,11 @@ package com.minelittlepony.client.model.races;
import com.minelittlepony.client.model.components.PegasusWings; import com.minelittlepony.client.model.components.PegasusWings;
import com.minelittlepony.model.IPegasus; import com.minelittlepony.model.IPegasus;
import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity;
public class ModelAlicorn extends ModelUnicorn implements IPegasus { public class ModelAlicorn<T extends LivingEntity> extends ModelUnicorn<T> implements IPegasus {
public PegasusWings<ModelAlicorn> wings; public PegasusWings<ModelAlicorn<T>> wings;
public ModelAlicorn(boolean smallArms) { public ModelAlicorn(boolean smallArms) {
super(smallArms); super(smallArms);
@ -24,19 +24,20 @@ public class ModelAlicorn extends ModelUnicorn implements IPegasus {
} }
@Override @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
if (canFly()) { if (canFly()) {
wings.setRotationAndAngles(rainboom, entity.getUniqueID(), move, swing, 0, ticks); wings.setRotationAndAngles(rainboom, entity.getUuid(), move, swing, 0, ticks);
} }
} }
@Override @Override
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale); super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale);
if (canFly()) { if (canFly()) {
wings.renderPart(scale, entity.getUniqueID()); wings.renderPart(scale, entity.getUuid());
} }
} }
} }

View file

@ -1,10 +1,12 @@
package com.minelittlepony.client.model.races; package com.minelittlepony.client.model.races;
import net.minecraft.entity.LivingEntity;
import com.minelittlepony.client.model.components.BatWings; import com.minelittlepony.client.model.components.BatWings;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
public class ModelBatpony extends ModelPegasus { public class ModelBatpony<T extends LivingEntity> extends ModelPegasus<T> {
public ModelBatpony(boolean smallArms) { public ModelBatpony(boolean smallArms) {
super(smallArms); super(smallArms);

View file

@ -1,11 +1,12 @@
package com.minelittlepony.client.model.races; package com.minelittlepony.client.model.races;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import com.minelittlepony.client.model.components.BugWings; import com.minelittlepony.client.model.components.BugWings;
import com.minelittlepony.pony.meta.Wearable; import com.minelittlepony.pony.meta.Wearable;
public class ModelChangeling extends ModelAlicorn { public class ModelChangeling<T extends LivingEntity> extends ModelAlicorn<T> {
public ModelChangeling(boolean smallArms) { public ModelChangeling(boolean smallArms) {
super(smallArms); super(smallArms);

View file

@ -3,9 +3,9 @@ package com.minelittlepony.client.model.races;
import com.minelittlepony.client.model.AbstractPonyModel; import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity;
public class ModelEarthPony extends AbstractPonyModel { public class ModelEarthPony<T extends LivingEntity> extends AbstractPonyModel<T> {
private final boolean smallArms; private final boolean smallArms;
@ -17,11 +17,11 @@ public class ModelEarthPony extends AbstractPonyModel {
} }
@Override @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
if (bipedCape != null) { if (bipedCape != null) {
bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; bipedCape.rotationPointY = isSneaking ? 2 : isRiding ? -4 : 0;
} }
} }

View file

@ -3,11 +3,11 @@ package com.minelittlepony.client.model.races;
import com.minelittlepony.client.model.components.PegasusWings; import com.minelittlepony.client.model.components.PegasusWings;
import com.minelittlepony.model.IPegasus; import com.minelittlepony.model.IPegasus;
import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity;
public class ModelPegasus extends ModelEarthPony implements IPegasus { public class ModelPegasus<T extends LivingEntity> extends ModelEarthPony<T> implements IPegasus {
public PegasusWings<ModelPegasus> wings; public PegasusWings<ModelPegasus<T>> wings;
public ModelPegasus(boolean smallArms) { public ModelPegasus(boolean smallArms) {
super(smallArms); super(smallArms);
@ -24,14 +24,14 @@ public class ModelPegasus extends ModelEarthPony implements IPegasus {
} }
@Override @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale);
wings.setRotationAndAngles(rainboom, entity.getUniqueID(), move, swing, 0, ticks); wings.setRotationAndAngles(rainboom, entity.getUuid(), move, swing, 0, ticks);
} }
@Override @Override
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale); super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale);
wings.renderPart(scale, entity.getUniqueID()); wings.renderPart(scale, entity.getUuid());
} }
} }

View file

@ -4,14 +4,14 @@ import com.minelittlepony.client.model.components.UnicornHorn;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.IUnicorn; import com.minelittlepony.model.IUnicorn;
import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity;
import net.minecraft.util.EnumHandSide; import net.minecraft.util.AbsoluteHand;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
/** /**
* Used for both unicorns and alicorns since there's no logical way to keep them distinct and not duplicate stuff. * Used for both unicorns and alicorns since there's no logical way to keep them distinct and not duplicate stuff.
*/ */
public class ModelUnicorn extends ModelEarthPony implements IUnicorn<PonyRenderer> { public class ModelUnicorn<T extends LivingEntity> extends ModelEarthPony<T> implements IUnicorn<PonyRenderer> {
public PonyRenderer unicornArmRight; public PonyRenderer unicornArmRight;
public PonyRenderer unicornArmLeft; public PonyRenderer unicornArmLeft;
@ -29,11 +29,11 @@ public class ModelUnicorn extends ModelEarthPony implements IUnicorn<PonyRendere
} }
@Override @Override
protected void rotateLegsOnGround(float move, float swing, float ticks, Entity entity) { protected void rotateLegsOnGround(float move, float swing, float ticks, T entity) {
super.rotateLegsOnGround(move, swing, ticks, entity); super.rotateLegsOnGround(move, swing, ticks, entity);
unicornArmRight.rotateAngleY = 0; unicornArmRight.yaw = 0;
unicornArmLeft.rotateAngleY = 0; unicornArmLeft.yaw = 0;
} }
@Override @Override
@ -45,17 +45,17 @@ public class ModelUnicorn extends ModelEarthPony implements IUnicorn<PonyRendere
} }
@Override @Override
protected void rotateLegs(float move, float swing, float ticks, Entity entity) { protected void rotateLegs(float move, float swing, float ticks, T entity) {
super.rotateLegs(move, swing, ticks, entity); super.rotateLegs(move, swing, ticks, entity);
unicornArmRight.setRotationPoint(-7, 12, -2); unicornArmRight.setRotationPoint(-7, 12, -2);
unicornArmLeft.setRotationPoint(-7, 12, -2); unicornArmLeft.setRotationPoint(-7, 12, -2);
unicornArmLeft.rotateAngleZ = 0; unicornArmLeft.roll = 0;
unicornArmRight.rotateAngleZ = 0; unicornArmRight.roll = 0;
unicornArmLeft.rotateAngleX = 0; unicornArmLeft.pitch = 0;
unicornArmRight.rotateAngleX = 0; unicornArmRight.pitch = 0;
} }
@Override @Override
@ -71,11 +71,11 @@ public class ModelUnicorn extends ModelEarthPony implements IUnicorn<PonyRendere
} }
@Override @Override
protected void swingItem(Entity entity) { protected void swingItem(T entity) {
EnumHandSide mainSide = getMainHand(entity); AbsoluteHand mainSide = getPreferedHand(entity);
if (canCast() && getArmPoseForSide(mainSide) != ArmPose.EMPTY) { if (canCast() && getArmPoseForSide(mainSide) != ArmPose.EMPTY) {
if (swingProgress > -9990.0F && !isSleeping()) { if (getSwingAmount() > -9990 && !isSleeping()) {
swingArm(getUnicornArmForSide(mainSide)); swingArm(getUnicornArmForSide(mainSide));
} }
} else { } else {
@ -92,13 +92,13 @@ public class ModelUnicorn extends ModelEarthPony implements IUnicorn<PonyRendere
float sin = MathHelper.sin(ticks * 0.067F) * 0.05F; float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
if (rightArmPose != ArmPose.EMPTY) { if (rightArmPose != ArmPose.EMPTY) {
unicornArmRight.rotateAngleZ += cos; unicornArmRight.roll += cos;
unicornArmRight.rotateAngleX += sin; unicornArmRight.pitch += sin;
} }
if (leftArmPose != ArmPose.EMPTY) { if (leftArmPose != ArmPose.EMPTY) {
unicornArmLeft.rotateAngleZ += cos; unicornArmLeft.roll += cos;
unicornArmLeft.rotateAngleX += sin; unicornArmLeft.pitch += sin;
} }
} else { } else {
super.swingArms(ticks); super.swingArms(ticks);
@ -106,8 +106,8 @@ public class ModelUnicorn extends ModelEarthPony implements IUnicorn<PonyRendere
} }
@Override @Override
public PonyRenderer getUnicornArmForSide(EnumHandSide side) { public PonyRenderer getUnicornArmForSide(AbsoluteHand side) {
return side == EnumHandSide.LEFT ? unicornArmLeft : unicornArmRight; return side == AbsoluteHand.LEFT ? unicornArmLeft : unicornArmRight;
} }
@Override @Override
@ -118,16 +118,16 @@ public class ModelUnicorn extends ModelEarthPony implements IUnicorn<PonyRendere
@Override @Override
protected void ponyCrouch() { protected void ponyCrouch() {
super.ponyCrouch(); super.ponyCrouch();
unicornArmRight.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ; unicornArmRight.pitch -= LEG_ROT_X_SNEAK_ADJ;
unicornArmLeft.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ; unicornArmLeft.pitch -= LEG_ROT_X_SNEAK_ADJ;
} }
@Override @Override
protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { protected void renderHead(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderHead(entity, move, swing, ticks, headYaw, headPitch, scale); super.renderHead(entity, move, swing, ticks, headYaw, headPitch, scale);
if (canCast()) { if (canCast()) {
horn.renderPart(scale, entity.getUniqueID()); horn.renderPart(scale, entity.getUuid());
if (isCasting()) { if (isCasting()) {
horn.renderMagic(getMagicColor(), scale); horn.renderMagic(getMagicColor(), scale);
} }

View file

@ -1,14 +1,15 @@
package com.minelittlepony.client.model.races; package com.minelittlepony.client.model.races;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.LivingEntity;
import com.minelittlepony.client.model.armour.ModelPonyArmor; import com.minelittlepony.client.model.armour.ModelPonyArmor;
import com.minelittlepony.client.model.armour.PonyArmor; import com.minelittlepony.client.model.armour.PonyArmor;
import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.model.armour.IEquestrianArmour;
import com.mojang.blaze3d.platform.GlStateManager;
public class ModelZebra extends ModelEarthPony { public class ModelZebra<T extends LivingEntity> extends ModelEarthPony<T> {
public PonyRenderer bristles; public PonyRenderer bristles;
@ -18,7 +19,7 @@ public class ModelZebra extends ModelEarthPony {
@Override @Override
public IEquestrianArmour<?> createArmour() { public IEquestrianArmour<?> createArmour() {
return new PonyArmor(new Armour(), new Armour()); return new PonyArmor<>(new Armour(), new Armour());
} }
@Override @Override
@ -37,20 +38,20 @@ public class ModelZebra extends ModelEarthPony {
super.initHead(yOffset, stretch); super.initHead(yOffset, stretch);
bristles = new PonyRenderer(this, 56, 32); bristles = new PonyRenderer(this, 56, 32);
bipedHead.addChild(bristles); head.addChild(bristles);
bristles.offset(-1, -1, -3) bristles.offset(-1, -1, -3)
.box(0, -10, 2, 2, 6, 2, stretch) .box(0, -10, 2, 2, 6, 2, stretch)
.box(0, -10, 4, 2, 8, 2, stretch) .box(0, -10, 4, 2, 8, 2, stretch)
.box(0, -8, 6, 2, 6, 2, stretch) .box(0, -8, 6, 2, 6, 2, stretch)
.rotateAngleX = 0.3F; .pitch = 0.3F;
bristles.child(0).offset(-1.01F, 2, -7) //0.01 to prevent z-fighting bristles.child(0).offset(-1.01F, 2, -7) //0.01 to prevent z-fighting
.box(0, -10, 4, 2, 8, 2, stretch) .box(0, -10, 4, 2, 8, 2, stretch)
.box(0, -8, 6, 2, 6, 2, stretch) .box(0, -8, 6, 2, 6, 2, stretch)
.rotateAngleX = -1F; .pitch = -1F;
} }
class Armour extends ModelPonyArmor { class Armour extends ModelPonyArmor<T> {
@Override @Override
public void transform(BodyPart part) { public void transform(BodyPart part) {

View file

@ -7,9 +7,11 @@ import com.minelittlepony.client.model.entities.ModelSeapony;
import com.minelittlepony.client.render.entities.player.RenderPonyPlayer; import com.minelittlepony.client.render.entities.player.RenderPonyPlayer;
import com.minelittlepony.client.render.entities.player.RenderSeaponyPlayer; import com.minelittlepony.client.render.entities.player.RenderSeaponyPlayer;
import com.minelittlepony.hdskins.VanillaModels; import com.minelittlepony.hdskins.VanillaModels;
import com.minelittlepony.model.IModel;
import com.minelittlepony.pony.meta.Race; import com.minelittlepony.pony.meta.Race;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.entity.LivingEntity;
import java.util.Map; import java.util.Map;
@ -25,9 +27,9 @@ public enum PlayerModels {
ALICORN("alicorn", Race.ALICORN, ModelAlicorn::new), ALICORN("alicorn", Race.ALICORN, ModelAlicorn::new),
CHANGELING("changeling", Race.CHANGELING, ModelChangeling::new), CHANGELING("changeling", Race.CHANGELING, ModelChangeling::new),
ZEBRA("zebra", Race.ZEBRA, ModelZebra::new), ZEBRA("zebra", Race.ZEBRA, ModelZebra::new),
SEAPONY("seapony", Race.SEAPONY, a -> new ModelSeapony()) { SEAPONY("seapony", Race.SEAPONY, a -> new ModelSeapony<>()) {
@Override @Override
public RenderPonyPlayer createRenderer(RenderManager manager, boolean slimArms) { public RenderPonyPlayer createRenderer(EntityRenderDispatcher manager, boolean slimArms) {
return new RenderSeaponyPlayer(manager, slimArms, PlayerModels.UNICORN.getModel(slimArms), getModel(slimArms)); return new RenderSeaponyPlayer(manager, slimArms, PlayerModels.UNICORN.getModel(slimArms), getModel(slimArms));
} }
}; };
@ -42,8 +44,8 @@ public enum PlayerModels {
private final ModelResolver resolver; private final ModelResolver resolver;
private ModelWrapper normal; private ModelWrapper<?, ?> normal;
private ModelWrapper slim; private ModelWrapper<?, ?> slim;
private final String normalKey, slimKey; private final String normalKey, slimKey;
@ -62,28 +64,29 @@ public enum PlayerModels {
this.race = race; this.race = race;
} }
public ModelWrapper getModel(boolean isSlim) { @SuppressWarnings("unchecked")
public <T extends LivingEntity, M extends IModel> ModelWrapper<T, M> getModel(boolean isSlim) {
if (isSlim) { if (isSlim) {
if (slim == null) { if (slim == null) {
slim = new ModelWrapper(resolver.resolve(isSlim)); slim = new ModelWrapper<>(resolver.resolve(isSlim));
} }
return slim; return (ModelWrapper<T, M>)slim;
} }
if (normal == null) { if (normal == null) {
normal = new ModelWrapper(resolver.resolve(isSlim)); normal = new ModelWrapper<>(resolver.resolve(isSlim));
} }
return normal; return (ModelWrapper<T, M>)normal;
} }
public String getId(boolean useSlimArms) { public String getId(boolean useSlimArms) {
return useSlimArms ? slimKey : normalKey; return useSlimArms ? slimKey : normalKey;
} }
public RenderPonyPlayer createRenderer(RenderManager manager, boolean slimArms) { public RenderPonyPlayer createRenderer(EntityRenderDispatcher manager, boolean slimArms) {
return new RenderPonyPlayer(manager, slimArms, getModel(slimArms)); return new RenderPonyPlayer(manager, slimArms, getModel(slimArms));
} }
@ -96,6 +99,6 @@ public enum PlayerModels {
*/ */
@FunctionalInterface @FunctionalInterface
static interface ModelResolver { static interface ModelResolver {
AbstractPonyModel resolve(boolean slim); AbstractPonyModel<?> resolve(boolean slim);
} }
} }

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.model.races; package com.minelittlepony.client.model.races;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client; package com.minelittlepony.client;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -4,7 +4,7 @@ import com.google.common.base.MoreObjects;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.PonyRenderManager; import com.minelittlepony.client.PonyRenderManager;
import com.minelittlepony.client.ducks.IBufferedTexture; import com.minelittlepony.client.ducks.IBufferedTexture;
import com.minelittlepony.client.ducks.IRenderPony; import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.client.transform.PonyTransformation; import com.minelittlepony.client.transform.PonyTransformation;
import com.minelittlepony.hdskins.util.ProfileTextureUtil; import com.minelittlepony.hdskins.util.ProfileTextureUtil;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
@ -13,22 +13,22 @@ import com.minelittlepony.pony.meta.Race;
import com.minelittlepony.pony.meta.Size; import com.minelittlepony.pony.meta.Size;
import com.minelittlepony.util.chron.Touchable; import com.minelittlepony.util.chron.Touchable;
import net.minecraft.block.material.Material; import net.minecraft.block.Material;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.texture.Texture;
import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.texture.MissingSprite;
import net.minecraft.client.renderer.texture.MissingTextureSprite; import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.resources.IResource;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.resource.Resource;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BoundingBox;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@ -46,15 +46,15 @@ public class Pony extends Touchable<Pony> implements IPony {
private final int ponyId = ponyCount.getAndIncrement(); private final int ponyId = ponyCount.getAndIncrement();
private final ResourceLocation texture; private final Identifier texture;
private final IPonyData metadata; private final IPonyData metadata;
public Pony(ResourceLocation resource) { public Pony(Identifier resource) {
texture = resource; texture = resource;
metadata = checkSkin(texture); metadata = checkSkin(texture);
} }
private IPonyData checkSkin(ResourceLocation resource) { private IPonyData checkSkin(Identifier resource) {
IPonyData data = checkPonyMeta(resource); IPonyData data = checkPonyMeta(resource);
if (data != null) { if (data != null) {
return data; return data;
@ -63,25 +63,23 @@ public class Pony extends Touchable<Pony> implements IPony {
NativeImage ponyTexture = getBufferedImage(resource); NativeImage ponyTexture = getBufferedImage(resource);
if (ponyTexture == null) { if (ponyTexture == null) {
ponyTexture = ProfileTextureUtil.getDynamicBufferedImage(16, 16, MissingTextureSprite.getDynamicTexture()); ponyTexture = ProfileTextureUtil.getDynamicBufferedImage(16, 16, MissingSprite.getMissingSpriteTexture());
Minecraft.getInstance().getTextureManager().loadTexture(resource, new DynamicTexture(ponyTexture)); MinecraftClient.getInstance().getTextureManager().registerTexture(resource, new NativeImageBackedTexture(ponyTexture));
} }
return checkSkin(ponyTexture); return checkSkin(ponyTexture);
} }
@Nullable @Nullable
private IPonyData checkPonyMeta(ResourceLocation resource) { private IPonyData checkPonyMeta(Identifier resource) {
try { try {
IResource res = Minecraft.getInstance().getResourceManager().getResource(resource); Resource res = MinecraftClient.getInstance().getResourceManager().getResource(resource);
if (res.hasMetadata()) { PonyData data = res.getMetadata(PonyData.SERIALISER);
PonyData data = res.getMetadata(PonyData.SERIALISER);
if (data != null) { if (data != null) {
return data; return data;
}
} }
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// Ignore uploaded texture // Ignore uploaded texture
@ -93,20 +91,20 @@ public class Pony extends Touchable<Pony> implements IPony {
} }
@Nullable @Nullable
public static NativeImage getBufferedImage(@Nonnull ResourceLocation resource) { public static NativeImage getBufferedImage(@Nonnull Identifier resource) {
try { try {
IResource skin = Minecraft.getInstance().getResourceManager().getResource(resource); Resource skin = MinecraftClient.getInstance().getResourceManager().getResource(resource);
NativeImage skinImage = NativeImage.read(skin.getInputStream()); NativeImage skinImage = NativeImage.fromInputStream(skin.getInputStream());
MineLittlePony.logger.debug("Obtained skin from resource location {}", resource); MineLittlePony.logger.debug("Obtained skin from resource location {}", resource);
return skinImage; return skinImage;
} catch (IOException ignored) { } catch (IOException ignored) {
} }
ITextureObject texture = Minecraft.getInstance().getTextureManager().getTexture(resource); Texture texture = MinecraftClient.getInstance().getTextureManager().getTexture(resource);
if (texture instanceof DynamicTexture) { if (texture instanceof NativeImageBackedTexture) {
return ((DynamicTexture)texture).getTextureData(); return ((NativeImageBackedTexture)texture).getImage();
} }
if (texture instanceof IBufferedTexture) { if (texture instanceof IBufferedTexture) {
@ -122,14 +120,15 @@ public class Pony extends Touchable<Pony> implements IPony {
} }
@Override @Override
public boolean isPerformingRainboom(EntityLivingBase entity) { public boolean isPerformingRainboom(LivingEntity entity) {
double zMotion = Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ); Vec3d velocity = entity.getVelocity();
double zMotion = Math.sqrt(velocity.x * velocity.x + velocity.z * velocity.z);
return (isFlying(entity) && canFly()) || entity.isElytraFlying() & zMotion > 0.4F; return (isFlying(entity) && canFly()) || entity.isFallFlying() & zMotion > 0.4F;
} }
@Override @Override
public boolean isCrouching(EntityLivingBase entity) { public boolean isCrouching(LivingEntity entity) {
boolean isSneak = entity.isSneaking(); boolean isSneak = entity.isSneaking();
boolean isFlying = isFlying(entity); boolean isFlying = isFlying(entity);
@ -139,40 +138,40 @@ public class Pony extends Touchable<Pony> implements IPony {
} }
@Override @Override
public boolean isFlying(EntityLivingBase entity) { public boolean isFlying(LivingEntity entity) {
return !(entity.onGround return !(entity.onGround
|| entity.isPassenger() || entity.hasVehicle()
|| (entity.isOnLadder() && !(entity instanceof EntityPlayer && ((EntityPlayer)entity).abilities.isFlying)) || (entity.isClimbing() && !(entity instanceof PlayerEntity && ((PlayerEntity)entity).abilities.allowFlying))
|| entity.isInWater() || entity.isInWater()
|| entity.isPlayerSleeping()); || entity.isSleeping());
} }
@Override @Override
public boolean isSwimming(EntityLivingBase entity) { public boolean isSwimming(LivingEntity entity) {
return isFullySubmerged(entity) && !(entity.onGround || entity.isOnLadder()); return isFullySubmerged(entity) && !(entity.onGround || entity.isClimbing());
} }
@Override @Override
public boolean isPartiallySubmerged(EntityLivingBase entity) { public boolean isPartiallySubmerged(LivingEntity entity) {
return entity.isInWater() return entity.isInWater()
|| entity.getEntityWorld().getBlockState(new BlockPos(entity.posX, entity.posY, entity.posZ)).getMaterial() == Material.WATER; || entity.getEntityWorld().getBlockState(entity.getBlockPos()).getMaterial() == Material.WATER;
} }
@Override @Override
public boolean isFullySubmerged(EntityLivingBase entity) { public boolean isFullySubmerged(LivingEntity entity) {
return entity.isInWater() return entity.isInWater()
&& entity.getEntityWorld().getBlockState(new BlockPos(getVisualEyePosition(entity))).getMaterial() == Material.WATER; && entity.getEntityWorld().getBlockState(new BlockPos(getVisualEyePosition(entity))).getMaterial() == Material.WATER;
} }
protected Vec3d getVisualEyePosition(EntityLivingBase entity) { protected Vec3d getVisualEyePosition(LivingEntity entity) {
Size size = entity.isChild() ? Size.FOAL : metadata.getSize(); Size size = entity.isBaby() ? Size.FOAL : metadata.getSize();
return new Vec3d(entity.posX, entity.posY + (double) entity.getEyeHeight() * size.getScaleFactor(), entity.posZ); return new Vec3d(entity.x, entity.y + (double) entity.getEyeHeight(entity.getPose()) * size.getScaleFactor(), entity.z);
} }
@Override @Override
public boolean isWearingHeadgear(EntityLivingBase entity) { public boolean isWearingHeadgear(LivingEntity entity) {
ItemStack stack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); ItemStack stack = entity.getEquippedStack(EquipmentSlot.HEAD);
if (stack.isEmpty()) { if (stack.isEmpty()) {
return false; return false;
@ -180,7 +179,7 @@ public class Pony extends Touchable<Pony> implements IPony {
Item item = stack.getItem(); Item item = stack.getItem();
return !(item instanceof ItemArmor) || ((ItemArmor) item).getEquipmentSlot() != EntityEquipmentSlot.HEAD; return !(item instanceof ArmorItem) || ((ArmorItem) item).getSlotType() != EquipmentSlot.HEAD;
} }
@Override @Override
@ -189,7 +188,7 @@ public class Pony extends Touchable<Pony> implements IPony {
} }
@Override @Override
public ResourceLocation getTexture() { public Identifier getTexture() {
return texture; return texture;
} }
@ -199,48 +198,48 @@ public class Pony extends Touchable<Pony> implements IPony {
} }
@Override @Override
public boolean isRidingInteractive(EntityLivingBase entity) { public boolean isRidingInteractive(LivingEntity entity) {
return PonyRenderManager.getInstance().getPonyRenderer(entity.getRidingEntity()) != null; return PonyRenderManager.getInstance().getPonyRenderer(entity.getVehicle()) != null;
} }
@Override @Override
public IPony getMountedPony(EntityLivingBase entity) { public IPony getMountedPony(LivingEntity entity) {
Entity mount = entity.getRidingEntity(); Entity mount = entity.getVehicle();
IRenderPony<EntityLivingBase> render = PonyRenderManager.getInstance().getPonyRenderer(mount); IPonyRender<LivingEntity, ?> render = PonyRenderManager.getInstance().getPonyRenderer(mount);
return render == null ? null : render.getEntityPony((EntityLivingBase)mount); return render == null ? null : render.getEntityPony((LivingEntity)mount);
} }
@Override @Override
public Vec3d getAbsoluteRidingOffset(EntityLivingBase entity) { public Vec3d getAbsoluteRidingOffset(LivingEntity entity) {
IPony ridingPony = getMountedPony(entity); IPony ridingPony = getMountedPony(entity);
if (ridingPony != null) { if (ridingPony != null) {
EntityLivingBase ridee = (EntityLivingBase)entity.getRidingEntity(); LivingEntity ridee = (LivingEntity)entity.getVehicle();
Vec3d offset = PonyTransformation.forSize(ridingPony.getMetadata().getSize()).getRiderOffset(); Vec3d offset = PonyTransformation.forSize(ridingPony.getMetadata().getSize()).getRiderOffset();
float scale = ridingPony.getMetadata().getSize().getScaleFactor(); float scale = ridingPony.getMetadata().getSize().getScaleFactor();
return ridingPony.getAbsoluteRidingOffset(ridee) return ridingPony.getAbsoluteRidingOffset(ridee)
.add(0, offset.y - ridee.height * 1/scale, 0); .add(0, offset.y - ridee.getHeight() * 1/scale, 0);
} }
return entity.getPositionVector(); return entity.getPosVector();
} }
@Override @Override
public AxisAlignedBB getComputedBoundingBox(EntityLivingBase entity) { public BoundingBox getComputedBoundingBox(LivingEntity entity) {
float scale = getMetadata().getSize().getScaleFactor() + 0.1F; float scale = getMetadata().getSize().getScaleFactor() + 0.1F;
Vec3d pos = getAbsoluteRidingOffset(entity); Vec3d pos = getAbsoluteRidingOffset(entity);
float width = entity.width * scale; float width = entity.getWidth() * scale;
return new AxisAlignedBB( return new BoundingBox(
- width, (entity.height * scale), -width, - width, (entity.getHeight() * scale), -width,
width, 0, width).offset(pos); width, 0, width).offset(pos);
} }

View file

@ -1,6 +1,6 @@
package com.minelittlepony.client.pony; package com.minelittlepony.client.pony;
import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.client.texture.NativeImage;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;

View file

@ -3,21 +3,22 @@ package com.minelittlepony.client.pony;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.minecraft.resources.data.IMetadataSectionSerializer;
class PonyDataSerialiser implements IMetadataSectionSerializer<PonyData> { import net.minecraft.resource.metadata.ResourceMetadataReader;
class PonyDataSerialiser implements ResourceMetadataReader<PonyData> {
private static final Gson gson = new GsonBuilder() private static final Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation() .excludeFieldsWithoutExposeAnnotation()
.create(); .create();
@Override @Override
public String getSectionName() { public String getKey() {
return "pony"; return "pony";
} }
@Override @Override
public PonyData deserialize(JsonObject json) { public PonyData fromJson(JsonObject json) {
return gson.fromJson(json, PonyData.class); return gson.fromJson(json, PonyData.class);
} }
} }

View file

@ -15,15 +15,16 @@ import com.minelittlepony.util.math.MathUtil;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.resources.IResource; import net.minecraft.resource.Resource;
import net.minecraft.resources.IResourceManager; import net.minecraft.resource.ResourceManager;
import net.minecraft.resources.IResourceManagerReloadListener; import net.minecraft.resource.ResourceReloadListener;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -33,36 +34,38 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Queue; import java.util.Queue;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
/** /**
* The PonyManager is responsible for reading and recoding all the pony data associated with an entity of skin. * The PonyManager is responsible for reading and recoding all the pony data associated with an entity of skin.
* *
*/ */
public class PonyManager implements IPonyManager, IResourceManagerReloadListener, ISkinCacheClearListener { public class PonyManager implements IPonyManager, ResourceReloadListener, ISkinCacheClearListener {
private static final Gson GSON = new Gson(); private static final Gson GSON = new Gson();
/** /**
* All currently loaded background ponies. * All currently loaded background ponies.
*/ */
private List<ResourceLocation> backgroundPonyList = Lists.newArrayList(); private List<Identifier> backgroundPonyList = Lists.newArrayList();
private final PonyConfig config; private final PonyConfig config;
private final ChronicCache<ResourceLocation, Pony> poniesCache = new ChronicCache<>(); private final ChronicCache<Identifier, Pony> poniesCache = new ChronicCache<>();
public PonyManager(PonyConfig config) { public PonyManager(PonyConfig config) {
this.config = config; this.config = config;
} }
@Override @Override
public IPony getPony(ResourceLocation resource) { public IPony getPony(Identifier resource) {
return poniesCache.retrieve(resource, Pony::new); return poniesCache.retrieve(resource, Pony::new);
} }
@Override @Override
public IPony getPony(EntityPlayer player) { public IPony getPony(PlayerEntity player) {
ResourceLocation skin = getSkin(player); Identifier skin = getSkin(player);
UUID uuid = player.getGameProfile().getId(); UUID uuid = player.getGameProfile().getId();
if (Pony.getBufferedImage(skin) == null) { if (Pony.getBufferedImage(skin) == null) {
@ -73,17 +76,17 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener
} }
@Nullable @Nullable
ResourceLocation getSkin(EntityPlayer player) { Identifier getSkin(PlayerEntity player) {
if (player instanceof AbstractClientPlayer) { if (player instanceof AbstractClientPlayerEntity) {
return ((AbstractClientPlayer)player).getLocationSkin(); return ((AbstractClientPlayerEntity)player).getSkinTexture();
} }
return null; return null;
} }
public IPony getPony(NetworkPlayerInfo playerInfo) { public IPony getPony(PlayerListEntry playerInfo) {
ResourceLocation skin = playerInfo.getLocationSkin(); Identifier skin = playerInfo.getSkinTexture();
UUID uuid = playerInfo.getGameProfile().getId(); UUID uuid = playerInfo.getProfile().getId();
if (Pony.getBufferedImage(skin) == null) { if (Pony.getBufferedImage(skin) == null) {
return getDefaultPony(uuid); return getDefaultPony(uuid);
@ -93,7 +96,7 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener
} }
@Override @Override
public IPony getPony(ResourceLocation resource, UUID uuid) { public IPony getPony(Identifier resource, UUID uuid) {
IPony pony = getPony(resource); IPony pony = getPony(resource);
if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) { if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) {
@ -106,7 +109,7 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener
@Override @Override
public IPony getDefaultPony(UUID uuid) { public IPony getDefaultPony(UUID uuid) {
if (config.getPonyLevel() != PonyLevel.PONIES) { if (config.getPonyLevel() != PonyLevel.PONIES) {
return getPony(DefaultPlayerSkin.getDefaultSkin(uuid)); return getPony(DefaultSkinHelper.getTexture(uuid));
} }
return getBackgroundPony(uuid); return getBackgroundPony(uuid);
@ -124,31 +127,39 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener
} }
private boolean isUser(UUID uuid) { private boolean isUser(UUID uuid) {
return Minecraft.getInstance().player != null && Minecraft.getInstance().player.getUniqueID().equals(uuid); return MinecraftClient.getInstance().player != null && MinecraftClient.getInstance().player.getUuid().equals(uuid);
} }
@Override @Override
public IPony removePony(ResourceLocation resource) { public IPony removePony(Identifier resource) {
return poniesCache.remove(resource); return poniesCache.remove(resource);
} }
@Override @Override
public void onResourceManagerReload(IResourceManager resourceManager) { public CompletableFuture<Void> reload(Synchronizer sync, ResourceManager sender, Profiler profiler, Profiler profile2, Executor executor, Executor executor2) {
return CompletableFuture.runAsync(() -> {
profiler.push("Reloading all background ponies");
reloadAll(sender);
profiler.endTick();
});
}
public void reloadAll(ResourceManager resourceManager) {
poniesCache.clear(); poniesCache.clear();
backgroundPonyList.clear(); backgroundPonyList.clear();
List<ResourceLocation> collectedPaths = new LinkedList<>(); List<Identifier> collectedPaths = new LinkedList<>();
List<BackgroundPonies> collectedPonies = new LinkedList<>(); List<BackgroundPonies> collectedPonies = new LinkedList<>();
Queue<BackgroundPonies> processingQueue = new LinkedList<>(); Queue<BackgroundPonies> processingQueue = new LinkedList<>();
for (String domain : resourceManager.getResourceNamespaces()) { for (String domain : resourceManager.getAllNamespaces()) {
processingQueue.addAll(loadBgPonies(resourceManager, new ResourceLocation(domain, BGPONIES_JSON))); processingQueue.addAll(loadBgPonies(resourceManager, new Identifier(domain, BGPONIES_JSON)));
} }
BackgroundPonies item; BackgroundPonies item;
while ((item = processingQueue.poll()) != null) { while ((item = processingQueue.poll()) != null) {
for (ResourceLocation imp : item.getImports()) { for (Identifier imp : item.getImports()) {
if (!collectedPaths.contains(imp)) { if (!collectedPaths.contains(imp)) {
collectedPaths.add(imp); collectedPaths.add(imp);
processingQueue.addAll(loadBgPonies(resourceManager, imp)); processingQueue.addAll(loadBgPonies(resourceManager, imp));
@ -171,13 +182,13 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener
MineLittlePony.logger.info("Detected {} background ponies installed.", getNumberOfPonies()); MineLittlePony.logger.info("Detected {} background ponies installed.", getNumberOfPonies());
} }
private Queue<BackgroundPonies> loadBgPonies(IResourceManager resourceManager, ResourceLocation location) { private Queue<BackgroundPonies> loadBgPonies(ResourceManager resourceManager, Identifier location) {
Queue<BackgroundPonies> collectedPonies = new LinkedList<>(); Queue<BackgroundPonies> collectedPonies = new LinkedList<>();
try { try {
String path = location.getPath().replace("bgponies.json", ""); String path = location.getPath().replace("bgponies.json", "");
for (IResource res : resourceManager.getAllResources(location)) { for (Resource res : resourceManager.getAllResources(location)) {
try (Reader reader = new InputStreamReader((res.getInputStream()))) { try (Reader reader = new InputStreamReader((res.getInputStream()))) {
BackgroundPonies ponies = GSON.fromJson(reader, BackgroundPonies.class); BackgroundPonies ponies = GSON.fromJson(reader, BackgroundPonies.class);
@ -186,7 +197,7 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener
collectedPonies.add(ponies); collectedPonies.add(ponies);
} catch (JsonParseException e) { } catch (JsonParseException e) {
MineLittlePony.logger.error("Invalid bgponies.json in " + res.getPackName(), e); MineLittlePony.logger.error("Invalid bgponies.json in " + res.getResourcePackName(), e);
} }
} }
} catch (IOException ignored) { } catch (IOException ignored) {
@ -211,19 +222,19 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener
private String domain; private String domain;
private String path; private String path;
private ResourceLocation apply(String input) { private Identifier apply(String input) {
return new ResourceLocation(domain, String.format("%s%s.png", path, input)); return new Identifier(domain, String.format("%s%s.png", path, input));
} }
private ResourceLocation makeImport(String input) { private Identifier makeImport(String input) {
return new ResourceLocation(domain, String.format("%s%s/bgponies.json", path, input)); return new Identifier(domain, String.format("%s%s/bgponies.json", path, input));
} }
public List<ResourceLocation> getPonies() { public List<Identifier> getPonies() {
return MoreStreams.map(ponies, this::apply); return MoreStreams.map(ponies, this::apply);
} }
public List<ResourceLocation> getImports() { public List<Identifier> getImports() {
return MoreStreams.map(imports, this::makeImport); return MoreStreams.map(imports, this::makeImport);
} }
} }

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.pony; package com.minelittlepony.client.pony;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,15 +1,14 @@
package com.minelittlepony.client.render; package com.minelittlepony.client.render;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BoundingBox;
import net.minecraft.util.math.AxisAlignedBB;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import static net.minecraft.client.renderer.GlStateManager.*; import static com.mojang.blaze3d.platform.GlStateManager.*;
public class DebugBoundingBoxRenderer { public class DebugBoundingBoxRenderer {
@ -18,31 +17,31 @@ public class DebugBoundingBoxRenderer {
private DebugBoundingBoxRenderer() { private DebugBoundingBoxRenderer() {
} }
public void render(IPony pony, EntityLivingBase entity, float ticks) { public void render(IPony pony, LivingEntity entity, float ticks) {
Minecraft mc = Minecraft.getInstance(); MinecraftClient mc = MinecraftClient.getInstance();
EntityPlayer player = mc.player; PlayerEntity player = mc.player;
if (!mc.getRenderManager().isDebugBoundingBox() || entity.getDistanceSq(player) > 70) { if (!mc.getEntityRenderManager().shouldRenderHitboxes() || entity.squaredDistanceTo(player) > 70) {
return; return;
} }
AxisAlignedBB boundingBox = pony.getComputedBoundingBox(entity); BoundingBox boundingBox = pony.getComputedBoundingBox(entity);
double renderPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)ticks; double renderPosX = player.prevX + (player.x - player.prevX) * (double)ticks;
double renderPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)ticks; double renderPosY = player.prevY + (player.y - player.prevY) * (double)ticks;
double renderPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)ticks; double renderPosZ = player.prevZ + (player.z - player.prevZ) * (double)ticks;
enableBlend(); enableBlend();
blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
lineWidth(2); lineWidth(2);
disableTexture2D(); disableTexture();
depthMask(false); depthMask(false);
WorldRenderer.drawSelectionBoundingBox(boundingBox.grow(0.003D).offset(-renderPosX, -renderPosY, -renderPosZ), 1, 1, 0, 1); WorldRenderer.drawBoxOutline(boundingBox.expand(0.003D).offset(-renderPosX, -renderPosY, -renderPosZ), 1, 1, 0, 1);
depthMask(true); depthMask(true);
enableTexture2D(); enableTexture();
disableBlend(); disableBlend();
} }
} }

View file

@ -1,40 +1,40 @@
package com.minelittlepony.client.render; package com.minelittlepony.client.render;
import net.minecraft.client.renderer.culling.ICamera; import net.minecraft.client.render.VisibleRegion;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BoundingBox;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
public class FrustrumCheck<T extends EntityLivingBase> implements ICamera { public class FrustrumCheck<T extends LivingEntity> implements VisibleRegion {
private T entity; private T entity;
private ICamera vanilla; private VisibleRegion vanilla;
private final RenderPony<T> renderer; private final RenderPony<T, ?> renderer;
public FrustrumCheck(RenderPony<T> render) { public FrustrumCheck(RenderPony<T, ?> render) {
renderer = render; renderer = render;
} }
public ICamera withCamera(T entity, ICamera vanillaFrustrum) { public VisibleRegion withCamera(T entity, VisibleRegion vanillaFrustrum) {
this.entity = entity; this.entity = entity;
vanilla = vanillaFrustrum; vanilla = vanillaFrustrum;
return this; return this;
} }
@Override @Override
public boolean isBoundingBoxInFrustum(AxisAlignedBB bounds) { public boolean intersects(BoundingBox bounds) {
IPony pony = renderer.getPony(entity); IPony pony = renderer.getPony(entity);
AxisAlignedBB boundingBox = pony.getComputedBoundingBox(entity); BoundingBox boundingBox = pony.getComputedBoundingBox(entity);
return vanilla.isBoundingBoxInFrustum(boundingBox); return vanilla.intersects(boundingBox);
} }
@Override @Override
public void setPosition(double x, double y, double z) { public void setOrigin(double x, double y, double z) {
vanilla.setPosition(x, y, z); vanilla.setOrigin(x, y, z);
} }
} }

View file

@ -0,0 +1,46 @@
package com.minelittlepony.client.render;
import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.util.math.MathUtil;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
/**
* I Render Pony now, oky?
*/
public interface IPonyRender<T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>> extends PonyModelConstants {
/**
* Gets the wrapped pony model for this renderer.
*/
ModelWrapper<T, M> getModelWrapper();
IPony getEntityPony(T entity);
RenderPony<T, M> getInternalRenderer();
Identifier findTexture(T entity);
/**
* Called by riders to have their transportation adjust their position.
*/
default void translateRider(T entity, IPony entityPony, LivingEntity passenger, IPony passengerPony, float ticks) {
if (!passengerPony.getRace(false).isHuman()) {
//float yaw = MathUtil.interpolateDegress(entity.prevRenderYawOffset, entity.renderYawOffset, ticks);
float yaw = MathUtil.interpolateDegress((float)entity.prevRenderY, (float)entity.y, ticks);
getModelWrapper().apply(entityPony.getMetadata());
M model = getModelWrapper().getBody();
model.transform(BodyPart.BACK);
getInternalRenderer().applyPostureRiding(entity, yaw, ticks);
}
}
}

View file

@ -9,17 +9,16 @@ import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
import com.minelittlepony.client.util.render.Color; import com.minelittlepony.client.util.render.Color;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.renderer.GlStateManager.DestFactor; import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.renderer.GlStateManager.SourceFactor; import net.minecraft.entity.LivingEntity;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHandSide; import net.minecraft.util.AbsoluteHand;
import static net.minecraft.client.renderer.GlStateManager.*; import net.minecraft.util.UseAction;
import static com.mojang.blaze3d.platform.GlStateManager.*;
@SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it. @SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it.
public class LevitatingItemRenderer { public class LevitatingItemRenderer {
@ -27,27 +26,27 @@ public class LevitatingItemRenderer {
public static void enableItemGlowRenderProfile() { public static void enableItemGlowRenderProfile() {
enableBlend(); enableBlend();
blendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO); blendFuncSeparate(SourceFactor.CONSTANT_COLOR, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
Minecraft.getInstance().gameRenderer.disableLightmap(); MinecraftClient.getInstance().gameRenderer.disableLightmap();
} }
/** /**
* Renders a magical overlay over an item in third person. * Renders a magical overlay over an item in third person.
*/ */
public void renderItemGlow(EntityLivingBase entity, ItemStack drop, TransformType transform, EnumHandSide hand, int glowColor) { public void renderItemGlow(LivingEntity entity, ItemStack drop, ModelTransformation.Type transform, AbsoluteHand hand, int glowColor) {
pushMatrix(); pushMatrix();
disableLighting(); disableLighting();
setColor(glowColor); setColor(glowColor);
ItemRenderer renderItem = Minecraft.getInstance().getItemRenderer(); ItemRenderer renderItem = MinecraftClient.getInstance().getItemRenderer();
((IRenderItem) renderItem).useTransparency(true); ((IRenderItem) renderItem).useTransparency(true);
PonySkullRenderer.ponyInstance.useTransparency(true); PonySkullRenderer.ponyInstance.useTransparency(true);
scalef(1.1F, 1.1F, 1.1F); scalef(1.1F, 1.1F, 1.1F);
translatef(0, 0.01F, 0.01F); translatef(0, 0.01F, 0.01F);
renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); renderItem.renderHeldItem(drop, entity, transform, hand == AbsoluteHand.LEFT);
translatef(0.01F, -0.01F, -0.02F); translatef(0.01F, -0.01F, -0.02F);
renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); renderItem.renderHeldItem(drop, entity, transform, hand == AbsoluteHand.LEFT);
((IRenderItem) renderItem).useTransparency(false); ((IRenderItem) renderItem).useTransparency(false);
PonySkullRenderer.ponyInstance.useTransparency(false); PonySkullRenderer.ponyInstance.useTransparency(false);
@ -69,7 +68,7 @@ public class LevitatingItemRenderer {
/** /**
* Renders an item in first person optionally with a magical overlay. * Renders an item in first person optionally with a magical overlay.
*/ */
public void renderItemInFirstPerson(ItemRenderer renderer, AbstractClientPlayer entity, ItemStack stack, TransformType transform, boolean left) { public void renderItemInFirstPerson(ItemRenderer renderer, AbstractClientPlayerEntity entity, ItemStack stack, ModelTransformation.Type transform, boolean left) {
IPony pony = MineLittlePony.getInstance().getManager().getPony(entity); IPony pony = MineLittlePony.getInstance().getManager().getPony(entity);
pushMatrix(); pushMatrix();
@ -80,7 +79,7 @@ public class LevitatingItemRenderer {
setupPerspective(renderer, entity, stack, left); setupPerspective(renderer, entity, stack, left);
} }
renderer.renderItem(stack, entity, transform, left); renderer.renderHeldItem(stack, entity, transform, left);
if (doMagic) { if (doMagic) {
disableLighting(); disableLighting();
@ -93,9 +92,9 @@ public class LevitatingItemRenderer {
scalef(1.1F, 1.1F, 1.1F); scalef(1.1F, 1.1F, 1.1F);
translatef(-0.015F, 0.01F, 0.01F); translatef(-0.015F, 0.01F, 0.01F);
renderer.renderItem(stack, entity, transform, left); renderer.renderHeldItem(stack, entity, transform, left);
translatef(0.03F, -0.01F, -0.02F); translatef(0.03F, -0.01F, -0.02F);
renderer.renderItem(stack, entity, transform, left); renderer.renderHeldItem(stack, entity, transform, left);
((IRenderItem)renderer).useTransparency(false); ((IRenderItem)renderer).useTransparency(false);
@ -113,23 +112,23 @@ public class LevitatingItemRenderer {
/** /**
* 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.
*/ */
private void setupPerspective(ItemRenderer renderer, EntityLivingBase entity, ItemStack stack, boolean left) { private void setupPerspective(ItemRenderer renderer, LivingEntity entity, ItemStack stack, boolean left) {
EnumAction action = stack.getUseAction(); UseAction action = stack.getUseAction();
boolean doNormal = entity.getItemInUseCount() <= 0 || action == EnumAction.NONE; boolean doNormal = entity.getItemUseTime() <= 0 || action == UseAction.NONE;
if (doNormal) { // eating, blocking, and drinking are not transformed. Only held items. if (doNormal) { // eating, blocking, and drinking are not transformed. Only held items.
float ticks = MineLPClient.getInstance().getModUtilities().getRenderPartialTicks() - entity.ticksExisted; float ticks = MineLPClient.getInstance().getModUtilities().getRenderPartialTicks() - entity.age;
float floatAmount = (float)Math.sin(ticks / 9) / 40; float floatAmount = (float)Math.sin(ticks / 9) / 40;
float driftAmount = (float)Math.cos(ticks / 6) / 40; float driftAmount = (float)Math.cos(ticks / 6) / 40;
boolean handHeldTool = stack.getUseAction() == EnumAction.BOW boolean handHeldTool = stack.getUseAction() == UseAction.BOW
|| stack.getUseAction() == EnumAction.BLOCK; || stack.getUseAction() == UseAction.BLOCK;
translatef(driftAmount - floatAmount / 4, floatAmount, handHeldTool ? -0.3F : -0.6F); translatef(driftAmount - floatAmount / 4, floatAmount, handHeldTool ? -0.3F : -0.6F);
if (!renderer.shouldRenderItemIn3D(stack) && !handHeldTool) { // bows have to point forwards if (!renderer.hasDepthInGui(stack) && !handHeldTool) { // bows have to point forwards
if (left) { if (left) {
rotatef(-60, 0, 1, 0); rotatef(-60, 0, 1, 0);
rotatef(30, 0, 0, 1); rotatef(30, 0, 0, 1);

View file

@ -2,29 +2,30 @@ package com.minelittlepony.client.render;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.PonyRenderManager; import com.minelittlepony.client.PonyRenderManager;
import com.minelittlepony.client.ducks.IRenderPony;
import com.minelittlepony.client.model.AbstractPonyModel; import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.transform.PonyPosture; import com.minelittlepony.client.transform.PonyPosture;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import com.minelittlepony.util.math.MathUtil; import com.minelittlepony.util.math.MathUtil;
import com.mojang.blaze3d.platform.GlStateManager;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.render.VisibleRegion;
import net.minecraft.client.renderer.culling.ICamera; import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.LivingEntity;
public class RenderPony<T extends EntityLivingBase> { public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>> {
public ModelWrapper playerModel; public ModelWrapper<T, M> playerModel;
protected AbstractPonyModel ponyModel; protected AbstractPonyModel<T> ponyModel;
private IPony pony; private IPony pony;
private IRenderPony<T> renderer; private IPonyRender<T, M> renderer;
private FrustrumCheck<T> frustrum = new FrustrumCheck<>(this); private FrustrumCheck<T> frustrum = new FrustrumCheck<>(this);
@ -38,12 +39,12 @@ public class RenderPony<T extends EntityLivingBase> {
GlStateManager.disableBlend(); GlStateManager.disableBlend();
} }
public RenderPony(IRenderPony<T> renderer) { public RenderPony(IPonyRender<T, M> renderer) {
this.renderer = renderer; this.renderer = renderer;
} }
public ICamera getFrustrum(T entity, ICamera vanilla) { public VisibleRegion getFrustrum(T entity, VisibleRegion vanilla) {
if (entity.isPlayerSleeping() || !MineLittlePony.getInstance().getConfig().frustrum) { if (entity.isSleeping() || !MineLittlePony.getInstance().getConfig().frustrum) {
return vanilla; return vanilla;
} }
return frustrum.withCamera(entity, vanilla); return frustrum.withCamera(entity, vanilla);
@ -62,31 +63,31 @@ public class RenderPony<T extends EntityLivingBase> {
} }
public float getRenderYaw(T entity, float rotationYaw, float partialTicks) { public float getRenderYaw(T entity, float rotationYaw, float partialTicks) {
if (entity.isPassenger()) { if (entity.hasVehicle()) {
Entity mount = entity.getRidingEntity(); Entity mount = entity.getVehicle();
if (mount instanceof EntityLivingBase) { if (mount instanceof LivingEntity) {
return MathUtil.interpolateDegress(((EntityLivingBase)mount).prevRenderYawOffset, ((EntityLivingBase)mount).renderYawOffset, partialTicks); return MathUtil.interpolateDegress(((LivingEntity)mount).field_6220, ((LivingEntity)mount).field_6283, partialTicks);
} }
} }
return rotationYaw; return rotationYaw;
} }
protected void translateRider(EntityLivingBase entity, float ticks) { protected void translateRider(LivingEntity entity, float ticks) {
if (entity.isPassenger()) { if (entity.hasVehicle()) {
Entity ridingEntity = entity.getRidingEntity(); Entity ridingEntity = entity.getVehicle();
if (ridingEntity instanceof EntityLivingBase) { if (ridingEntity instanceof LivingEntity) {
IRenderPony<EntityLivingBase> renderer = PonyRenderManager.getInstance().getPonyRenderer((EntityLivingBase)ridingEntity); IPonyRender<LivingEntity, ?> renderer = PonyRenderManager.getInstance().getPonyRenderer((LivingEntity)ridingEntity);
if (renderer != null) { if (renderer != null) {
// negate vanilla translations so the rider begins at the ridees feet. // negate vanilla translations so the rider begins at the ridees feet.
GlStateManager.translatef(0, -ridingEntity.height, 0); GlStateManager.translatef(0, -ridingEntity.getHeight(), 0);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
IPony riderPony = renderer.getEntityPony((EntityLivingBase)ridingEntity); IPony riderPony = renderer.getEntityPony((LivingEntity)ridingEntity);
renderer.translateRider((EntityLivingBase)ridingEntity, riderPony, entity, pony, ticks); renderer.translateRider((LivingEntity)ridingEntity, riderPony, entity, pony, ticks);
} }
} }
} }
@ -96,10 +97,10 @@ public class RenderPony<T extends EntityLivingBase> {
public void applyPostureTransform(T player, float yaw, float ticks) { public void applyPostureTransform(T player, float yaw, float ticks) {
PonyPosture<?> posture = getPosture(player); PonyPosture<?> posture = getPosture(player);
if (posture != null && posture.applies(player)) { if (posture != null && posture.applies(player)) {
double motionX = player.posX - player.prevPosX; double motionX = player.x - player.prevX;
double motionY = player.onGround ? 0 : player.posY - player.prevPosY; double motionY = player.onGround ? 0 : player.y - player.prevY;
double motionZ = player.posZ - player.prevPosZ; double motionZ = player.x - player.prevZ;
((PonyPosture<EntityLivingBase>)posture).transform(ponyModel, player, motionX, motionY, motionZ, yaw, ticks); ((PonyPosture<LivingEntity>)posture).transform(ponyModel, player, motionX, motionY, motionZ, yaw, ticks);
} }
} }
@ -107,21 +108,21 @@ public class RenderPony<T extends EntityLivingBase> {
public void applyPostureRiding(T player, float yaw, float ticks) { public void applyPostureRiding(T player, float yaw, float ticks) {
PonyPosture<?> posture = getPosture(player); PonyPosture<?> posture = getPosture(player);
if (posture != null && posture.applies(player)) { if (posture != null && posture.applies(player)) {
double motionX = player.posX - player.prevPosX; double motionX = player.x - player.prevX;
double motionY = player.onGround ? 0 : player.posY - player.prevPosY; double motionY = player.onGround ? 0 : player.y - player.prevY;
double motionZ = player.posZ - player.prevPosZ; double motionZ = player.z - player.prevZ;
((PonyPosture<EntityLivingBase>)posture).transform(ponyModel, player, motionX, -motionY, motionZ, yaw, ticks); ((PonyPosture<LivingEntity>)posture).transform(ponyModel, player, motionX, -motionY, motionZ, yaw, ticks);
} }
} }
@Nullable @Nullable
private PonyPosture<?> getPosture(T entity) { private PonyPosture<?> getPosture(T entity) {
if (entity.isElytraFlying()) { if (entity.isFallFlying()) {
return PonyPosture.ELYTRA; return PonyPosture.ELYTRA;
} }
if (entity.isAlive() && entity.isPlayerSleeping()) { if (entity.isAlive() && entity.isSleeping()) {
return null; return null;
} }
@ -136,11 +137,12 @@ public class RenderPony<T extends EntityLivingBase> {
return PonyPosture.FALLING; return PonyPosture.FALLING;
} }
public AbstractPonyModel setPonyModel(ModelWrapper model) { @SuppressWarnings("unchecked")
public M setPonyModel(ModelWrapper<T, M> model) {
playerModel = model; playerModel = model;
ponyModel = playerModel.getBody(); ponyModel = (AbstractPonyModel<T>)playerModel.getBody();
return ponyModel; return (M)ponyModel;
} }
public void updateModel(T entity) { public void updateModel(T entity) {
@ -164,7 +166,7 @@ public class RenderPony<T extends EntityLivingBase> {
public double getNamePlateYOffset(T entity, double initial) { public double getNamePlateYOffset(T entity, double initial) {
// We start by negating the height calculation done by mohjong. // We start by negating the height calculation done by mohjong.
float y = -(entity.height + 0.5F - (entity.isSneaking() ? 0.25F : 0)); float y = -(entity.getHeight() + 0.5F - (entity.isSneaking() ? 0.25F : 0));
// Then we add our own offsets. // Then we add our own offsets.
y += ponyModel.getModelHeight() * getScaleFactor() + 0.25F; y += ponyModel.getModelHeight() * getScaleFactor() + 0.25F;
@ -173,11 +175,11 @@ public class RenderPony<T extends EntityLivingBase> {
y -= 0.25F; y -= 0.25F;
} }
if (entity.isPassenger()) { if (entity.hasVehicle()) {
y += entity.getRidingEntity().getEyeHeight(); y += entity.getVehicle().getEyeHeight(entity.getPose());
} }
if (entity.isPlayerSleeping()) { if (entity.isSleeping()) {
y /= 2; y /= 2;
} }

View file

@ -1,7 +1,7 @@
package com.minelittlepony.client.render; package com.minelittlepony.client.render;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.ducks.IRenderPony; import com.minelittlepony.client.model.ClientPonyModel;
import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.render.layer.LayerGear; import com.minelittlepony.client.render.layer.LayerGear;
import com.minelittlepony.client.render.layer.LayerHeldPonyItem; import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
@ -9,126 +9,142 @@ import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
import com.minelittlepony.client.render.layer.LayerPonyArmor; import com.minelittlepony.client.render.layer.LayerPonyArmor;
import com.minelittlepony.client.render.layer.LayerPonyCustomHead; import com.minelittlepony.client.render.layer.LayerPonyCustomHead;
import com.minelittlepony.client.render.layer.LayerPonyElytra; import com.minelittlepony.client.render.layer.LayerPonyElytra;
import com.minelittlepony.client.util.render.PonyRenderer;
import com.minelittlepony.hdskins.HDSkins; import com.minelittlepony.hdskins.HDSkins;
import com.minelittlepony.model.IPonyModel;
import com.minelittlepony.model.IUnicorn;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.render.VisibleRegion;
import net.minecraft.client.renderer.culling.ICamera; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer;
import net.minecraft.client.renderer.entity.layers.LayerArrow; import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.EntityLiving; import net.minecraft.util.Identifier;
import net.minecraft.util.ResourceLocation;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony<T> { public abstract class RenderPonyMob<T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>> extends LivingEntityRenderer<T, M> implements IPonyRender<T, M> {
protected RenderPony<T> renderPony = new RenderPony<T>(this); protected RenderPony<T, M> renderPony = new RenderPony<T, M>(this);
public RenderPonyMob(RenderManager manager, ModelWrapper model) { public RenderPonyMob(EntityRenderDispatcher manager, ModelWrapper<T, M> model) {
super(manager, model.getBody(), 0.5F); super(manager, model.getBody(), 0.5F);
mainModel = renderPony.setPonyModel(model); renderPony.setPonyModel(model);
addLayers(); addLayers();
} }
protected void addLayers() { protected void addLayers() {
addLayer(new LayerPonyArmor<>(this)); addFeature(new LayerPonyArmor<>(this));
addLayer(createItemHoldingLayer()); addFeature(createItemHoldingLayer());
addLayer(new LayerArrow(this)); addFeature(new StuckArrowsFeatureRenderer<>(this));
addLayer(new LayerPonyCustomHead<>(this)); addFeature(new LayerPonyCustomHead<>(this));
addLayer(new LayerPonyElytra<>(this)); addFeature(new LayerPonyElytra<>(this));
addLayer(new LayerGear<>(this)); addFeature(new LayerGear<>(this));
} }
protected LayerHeldPonyItem<T> createItemHoldingLayer() { protected abstract LayerHeldPonyItem<T, M> createItemHoldingLayer();
return new LayerHeldPonyItemMagical<>(this);
}
@Override @Override
public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) { public void render(T entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) {
if (entity.isSneaking()) { if (entity.isSneaking()) {
yPosition -= 0.125D; yPosition -= 0.125D;
} }
super.doRender(entity, xPosition, yPosition, zPosition, yaw, ticks); super.render(entity, xPosition, yPosition, zPosition, yaw, ticks);
DebugBoundingBoxRenderer.instance.render(renderPony.getPony(entity), entity, ticks); DebugBoundingBoxRenderer.instance.render(renderPony.getPony(entity), entity, ticks);
} }
@Override @Override
protected void applyRotations(T entity, float ageInTicks, float rotationYaw, float partialTicks) { protected void setupTransforms(T entity, float ageInTicks, float rotationYaw, float partialTicks) {
rotationYaw = renderPony.getRenderYaw(entity, rotationYaw, partialTicks); rotationYaw = renderPony.getRenderYaw(entity, rotationYaw, partialTicks);
super.applyRotations(entity, ageInTicks, rotationYaw, partialTicks); super.setupTransforms(entity, ageInTicks, rotationYaw, partialTicks);
} }
@Override @Override
public boolean shouldRender(T entity, ICamera camera, double camX, double camY, double camZ) { public boolean isVisible(T entity, VisibleRegion camera, double camX, double camY, double camZ) {
return super.shouldRender(entity, renderPony.getFrustrum(entity, camera), camX, camY, camZ); return super.isVisible(entity, renderPony.getFrustrum(entity, camera), camX, camY, camZ);
} }
@Override @Override
public void preRenderCallback(T entity, float ticks) { public void scale(T entity, float ticks) {
renderPony.preRenderCallback(entity, ticks); renderPony.preRenderCallback(entity, ticks);
shadowSize = renderPony.getShadowScale(); // shadowRadius
field_4673 = renderPony.getShadowScale();
if (entity.isChild()) { if (entity.isBaby()) {
shadowSize *= 3; // undo vanilla shadow scaling field_4673 *= 3; // undo vanilla shadow scaling
} }
if (!entity.isPassenger()) { if (!entity.hasVehicle()) {
GlStateManager.translatef(0, 0, -entity.width / 2); // move us to the center of the shadow GlStateManager.translatef(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
} else { } else {
GlStateManager.translated(0, entity.getYOffset(), 0); GlStateManager.translated(0, entity.getHeightOffset(), 0);
} }
} }
@Override @Override
public ModelWrapper getModelWrapper() { public ModelWrapper<T, M> getModelWrapper() {
return renderPony.playerModel; return renderPony.playerModel;
} }
@Override @Override
public IPony getEntityPony(T entity) { public IPony getEntityPony(T entity) {
return MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity)); return MineLittlePony.getInstance().getManager().getPony(findTexture(entity));
} }
@Override @Override
protected void renderLivingLabel(T entity, String name, double x, double y, double z, int maxDistance) { protected void renderLabel(T entity, String name, double x, double y, double z, int maxDistance) {
super.renderLivingLabel(entity, name, x, renderPony.getNamePlateYOffset(entity, y), z, maxDistance); super.renderLabel(entity, name, x, renderPony.getNamePlateYOffset(entity, y), z, maxDistance);
} }
@Deprecated
@Override @Override
@Nonnull @Nonnull
protected final ResourceLocation getEntityTexture(T entity) { public final Identifier getTexture(T entity) {
return HDSkins.getInstance().getConvertedSkin(getTexture(entity)); return HDSkins.getInstance().getConvertedSkin(findTexture(entity));
} }
@Override @Override
public RenderPony<T> getInternalRenderer() { public RenderPony<T, M> getInternalRenderer() {
return renderPony; return renderPony;
} }
public abstract static class Proxy<T extends EntityLiving> extends RenderPonyMob<T> { public abstract static class Caster<T extends LivingEntity, M extends ClientPonyModel<T> & IUnicorn<PonyRenderer>> extends RenderPonyMob<T, M> {
public Proxy(List<LayerRenderer<T>> exportedLayers, RenderManager manager, ModelWrapper model) { public Caster(EntityRenderDispatcher manager, ModelWrapper<T, M> model) {
super(manager, model);
}
@Override
protected LayerHeldPonyItem<T, M> createItemHoldingLayer() {
return new LayerHeldPonyItemMagical<>(this);
}
}
public abstract static class Proxy<T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>> extends RenderPonyMob<T, M> {
@SuppressWarnings({"rawtypes", "unchecked"})
public Proxy(List exportedLayers, EntityRenderDispatcher manager, ModelWrapper<T, M> model) {
super(manager, model); super(manager, model);
exportedLayers.addAll(layerRenderers); exportedLayers.addAll(features);
} }
@Override @Override
protected void addLayers() { protected void addLayers() {
layerRenderers.clear(); features.clear();
super.addLayers(); super.addLayers();
} }
public final ResourceLocation getTextureFor(T entity) { public final Identifier getTextureFor(T entity) {
return super.getEntityTexture(entity); return super.getTexture(entity);
} }
} }
} }

View file

@ -1,12 +1,13 @@
package com.minelittlepony.client.render.entities; package com.minelittlepony.client.render.entities;
import com.google.common.collect.Lists;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.PonyRenderManager; import com.minelittlepony.client.PonyRenderManager;
import com.minelittlepony.common.SensibleConfig.Setting; import com.minelittlepony.common.SensibleConfig.Setting;
import net.minecraft.client.Minecraft; import java.util.List;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.monster.*; import net.minecraft.entity.mob.*;
import net.minecraft.entity.passive.*; import net.minecraft.entity.passive.*;
/** /**
@ -17,66 +18,68 @@ import net.minecraft.entity.passive.*;
public enum MobRenderers implements Setting { public enum MobRenderers implements Setting {
VILLAGERS { VILLAGERS {
@Override @Override
public void register(boolean state, PonyRenderManager pony, RenderManager manager) { void register(boolean state, PonyRenderManager pony) {
pony.switchRenderer(state, manager, EntityVillager.class, new RenderPonyVillager(manager)); pony.switchRenderer(state, VillagerEntity.class, RenderPonyVillager::new);
pony.switchRenderer(state, manager, EntityWitch.class, new RenderPonyWitch(manager)); pony.switchRenderer(state, WitchEntity.class, RenderPonyWitch::new);
pony.switchRenderer(state, manager, EntityZombieVillager.class, new RenderPonyZombieVillager(manager)); pony.switchRenderer(state, ZombieVillagerEntity.class, RenderPonyZombieVillager::new);
} }
}, },
ZOMBIES { ZOMBIES {
@Override @Override
public void register(boolean state, PonyRenderManager pony, RenderManager manager) { void register(boolean state, PonyRenderManager pony) {
pony.switchRenderer(state, manager, EntityZombie.class, new RenderPonyZombie<>(manager)); pony.switchRenderer(state, ZombieEntity.class, RenderPonyZombie::new);
pony.switchRenderer(state, manager, EntityHusk.class, new RenderPonyZombie.Husk(manager)); pony.switchRenderer(state, HuskEntity.class, RenderPonyZombie.Husk::new);
pony.switchRenderer(state, manager, EntityGiantZombie.class, new RenderPonyZombie.Giant(manager)); pony.switchRenderer(state, GiantEntity.class, RenderPonyZombie.Giant::new);
} }
}, },
PIGZOMBIES { PIGZOMBIES {
@Override @Override
public void register(boolean state, PonyRenderManager pony, RenderManager manager) { void register(boolean state, PonyRenderManager pony) {
pony.switchRenderer(state, manager, EntityPigZombie.class, new RenderPonyZombie.Pigman(manager)); pony.switchRenderer(state, ZombiePigmanEntity.class, RenderPonyZombie.Pigman::new);
} }
}, },
SKELETONS { SKELETONS {
@Override @Override
public void register(boolean state, PonyRenderManager pony, RenderManager manager) { void register(boolean state, PonyRenderManager pony) {
pony.switchRenderer(state, manager, EntitySkeleton.class, new RenderPonySkeleton<>(manager)); pony.switchRenderer(state, SkeletonEntity.class, RenderPonySkeleton::new);
pony.switchRenderer(state, manager, EntityStray.class, new RenderPonySkeleton.Stray(manager)); pony.switchRenderer(state, StrayEntity.class, RenderPonySkeleton.Stray::new);
pony.switchRenderer(state, manager, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(manager)); pony.switchRenderer(state, WitherSkeletonEntity.class, RenderPonySkeleton.Wither::new);
} }
}, },
ILLAGERS { ILLAGERS {
@Override @Override
public void register(boolean state, PonyRenderManager pony, RenderManager manager) { void register(boolean state, PonyRenderManager pony) {
pony.switchRenderer(state, manager, EntityVex.class, new RenderPonyVex(manager)); pony.switchRenderer(state, VexEntity.class, RenderPonyVex::new);
pony.switchRenderer(state, manager, EntityEvoker.class, new RenderPonyIllager.Evoker(manager)); pony.switchRenderer(state, EvokerEntity.class, RenderPonyIllager.Evoker::new);
pony.switchRenderer(state, manager, EntityVindicator.class, new RenderPonyIllager.Vindicator(manager)); pony.switchRenderer(state, VindicatorEntity.class, RenderPonyIllager.Vindicator::new);
pony.switchRenderer(state, manager, EntityIllusionIllager.class, new RenderPonyIllager.Illusionist(manager)); pony.switchRenderer(state, IllusionerEntity.class, RenderPonyIllager.Illusionist::new);
} }
}, },
GUARDIANS { GUARDIANS {
@Override @Override
public void register(boolean state, PonyRenderManager pony, RenderManager manager) { void register(boolean state, PonyRenderManager pony) {
pony.switchRenderer(state, manager, EntityGuardian.class, new RenderPonyGuardian(manager)); pony.switchRenderer(state, GuardianEntity.class, RenderPonyGuardian::new);
pony.switchRenderer(state, manager, EntityElderGuardian.class, new RenderPonyGuardian.Elder(manager)); pony.switchRenderer(state, ElderGuardianEntity.class, RenderPonyGuardian::new);
} }
}, },
ENDERMEN { ENDERMEN {
@Override @Override
public void register(boolean state, PonyRenderManager pony, RenderManager manager) { void register(boolean state, PonyRenderManager pony) {
pony.switchRenderer(state, manager, EntityEnderman.class, new RenderEnderStallion(manager)); pony.switchRenderer(state, EndermanEntity.class, RenderEnderStallion::new);
} }
}; };
public static final List<MobRenderers> registry = Lists.newArrayList(values());
@Override @Override
public void set(boolean value) { public void set(boolean value) {
Setting.super.set(value); Setting.super.set(value);
apply(PonyRenderManager.getInstance(), Minecraft.getInstance().getRenderManager()); apply(PonyRenderManager.getInstance());
} }
public void apply(PonyRenderManager pony, RenderManager manager) { public void apply(PonyRenderManager pony) {
boolean state = get(); boolean state = get();
register(state, pony, manager); register(state, pony);
if (state) { if (state) {
MineLittlePony.logger.info(name() + " are now ponies."); MineLittlePony.logger.info(name() + " are now ponies.");
} else { } else {
@ -84,5 +87,5 @@ public enum MobRenderers implements Setting {
} }
} }
public abstract void register(boolean state, PonyRenderManager pony, RenderManager manager); abstract void register(boolean state, PonyRenderManager pony);
} }

View file

@ -8,41 +8,41 @@ import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical; import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
import com.minelittlepony.client.render.layer.LayerEyeGlow.IGlowingRenderer; import com.minelittlepony.client.render.layer.LayerEyeGlow.IGlowingRenderer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.layers.LayerArrow; import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer;
import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.entity.mob.EndermanEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import java.util.Random; import java.util.Random;
public class RenderEnderStallion extends RenderPonyMob<EntityEnderman> implements IGlowingRenderer { public class RenderEnderStallion extends RenderPonyMob<EndermanEntity, ModelEnderStallion> implements IGlowingRenderer {
public static final ResourceLocation ENDERMAN = new ResourceLocation("minelittlepony", "textures/entity/enderman/enderman_pony.png"); public static final Identifier ENDERMAN = new Identifier("minelittlepony", "textures/entity/enderman/enderman_pony.png");
private static final ResourceLocation EYES = new ResourceLocation("minelittlepony", "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();
private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelEnderStallion()); private static final ModelWrapper<EndermanEntity, ModelEnderStallion> MODEL_WRAPPER = new ModelWrapper<>(new ModelEnderStallion());
public RenderEnderStallion(RenderManager manager) { public RenderEnderStallion(EntityRenderDispatcher manager) {
super(manager, MODEL_WRAPPER); super(manager, MODEL_WRAPPER);
} }
@Override @Override
protected void addLayers() { protected void addLayers() {
addLayer(createItemHoldingLayer()); addFeature(createItemHoldingLayer());
addLayer(new LayerArrow(this)); addFeature(new StuckArrowsFeatureRenderer<>(this));
addLayer(new LayerEyeGlow<>(this)); addFeature(new LayerEyeGlow<>(this));
} }
@Override @Override
protected LayerHeldPonyItem<EntityEnderman> createItemHoldingLayer() { protected LayerHeldPonyItem<EndermanEntity, ModelEnderStallion> createItemHoldingLayer() {
return new LayerHeldPonyItemMagical<EntityEnderman>(this) { return new LayerHeldPonyItemMagical<EndermanEntity, ModelEnderStallion>(this) {
@Override @Override
protected ItemStack getRightItem(EntityEnderman entity) { protected ItemStack getRightItem(EndermanEntity entity) {
IBlockState state = entity.getHeldBlockState(); BlockState state = entity.getCarriedBlock();
if (state == null) { if (state == null) {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
@ -53,27 +53,27 @@ public class RenderEnderStallion extends RenderPonyMob<EntityEnderman> implement
} }
@Override @Override
public ResourceLocation getTexture(EntityEnderman entity) { public Identifier findTexture(EndermanEntity entity) {
return ENDERMAN; return ENDERMAN;
} }
@Override @Override
public void doRender(EntityEnderman entity, double x, double y, double z, float entityYaw, float partialTicks) { public void render(EndermanEntity entity, double x, double y, double z, float entityYaw, float partialTicks) {
ModelEnderStallion modelenderman = (ModelEnderStallion)getMainModel(); ModelEnderStallion modelenderman = getModel();
modelenderman.isCarrying = entity.getHeldBlockState() != null; modelenderman.isCarrying = entity.getCarriedBlock() != null;
modelenderman.isAttacking = entity.isScreaming(); modelenderman.isAttacking = entity.isAngry();
if (entity.isScreaming()) { if (entity.isAngry()) {
x += rnd.nextGaussian() / 50; x += rnd.nextGaussian() / 50;
z += rnd.nextGaussian() / 50; z += rnd.nextGaussian() / 50;
} }
super.doRender(entity, x, y, z, entityYaw, partialTicks); super.render(entity, x, y, z, entityYaw, partialTicks);
} }
@Override @Override
public ResourceLocation getEyeTexture() { public Identifier getEyeTexture() {
return EYES; return EYES;
} }
} }

View file

@ -2,74 +2,80 @@ package com.minelittlepony.client.render.entities;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import com.minelittlepony.client.mixin.IResizeable;
import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.model.entities.ModelSeapony; import com.minelittlepony.client.model.entities.ModelGuardianPony;
import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.client.render.RenderPonyMob.Proxy;
import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.RenderGuardian; import net.minecraft.client.render.entity.GuardianEntityRenderer;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntitySize;
import net.minecraft.entity.monster.EntityElderGuardian; import net.minecraft.entity.mob.ElderGuardianEntity;
import net.minecraft.entity.monster.EntityGuardian; import net.minecraft.entity.mob.GuardianEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
public class RenderPonyGuardian extends RenderGuardian { public class RenderPonyGuardian extends GuardianEntityRenderer {
public static final ResourceLocation SEAPONY = new ResourceLocation("minelittlepony", "textures/entity/seapony.png"); public static final Identifier SEAPONY = new Identifier("minelittlepony", "textures/entity/seapony.png");
private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelSeapony()); private final Proxy<GuardianEntity, ModelGuardianPony> ponyRenderer;
private RenderPonyMob.Proxy<EntityGuardian> ponyRenderer; public RenderPonyGuardian(EntityRenderDispatcher manager) {
public RenderPonyGuardian(RenderManager manager) {
super(manager); super(manager);
mainModel = MODEL_WRAPPER.getBody();
ponyRenderer = new RenderPonyMob.Proxy<EntityGuardian>(layerRenderers, manager, MODEL_WRAPPER) { features.clear();
ponyRenderer = new Proxy<GuardianEntity, ModelGuardianPony>(features, manager, new ModelWrapper<>(new ModelGuardianPony())) {
@Override @Override
public ResourceLocation getTexture(EntityGuardian entity) { public Identifier findTexture(GuardianEntity entity) {
return RenderPonyGuardian.this.getTexture(entity); return SEAPONY;
}
@Override
protected LayerHeldPonyItem<GuardianEntity, ModelGuardianPony> createItemHoldingLayer() {
return new LayerHeldPonyItemMagical<>(this);
} }
}; };
model = ponyRenderer.getModel();
} }
@Override @Override
@Nonnull @Nonnull
protected final ResourceLocation getEntityTexture(EntityGuardian entity) { protected final Identifier getTexture(GuardianEntity entity) {
return ponyRenderer.getTextureFor(entity); return ponyRenderer.getTextureFor(entity);
} }
@Override @Override
protected void preRenderCallback(EntityGuardian entity, float ticks) { protected void scale(GuardianEntity entity, float ticks) {
ponyRenderer.preRenderCallback(entity, ticks); ponyRenderer.scale(entity, ticks);
} }
@Override @Override
public void doRender(EntityGuardian entity, double x, double y, double z, float entityYaw, float partialTicks) { public void render(GuardianEntity entity, double x, double y, double z, float entityYaw, float partialTicks) {
float origin = entity.height; IResizeable resize = (IResizeable)entity;
EntitySize origin = resize.getCurrentSize();
// aligns the beam to their horns // aligns the beam to their horns
entity.height = entity instanceof EntityElderGuardian ? 6 : 3; resize.setCurrentSize(EntitySize.resizeable(origin.width, entity instanceof ElderGuardianEntity ? 6 : 3));
super.doRender(entity, x, y, z, entityYaw, partialTicks);
super.render(entity, x, y, z, entityYaw, partialTicks);
// The beams in RenderGuardian leave lighting disabled, so we need to change it back. #MojangPls // The beams in RenderGuardian leave lighting disabled, so we need to change it back. #MojangPls
GlStateManager.enableLighting(); GlStateManager.enableLighting();
entity.height = origin; resize.setCurrentSize(origin);
}
protected ResourceLocation getTexture(EntityGuardian entity) {
return SEAPONY;
} }
public static class Elder extends RenderPonyGuardian { public static class Elder extends RenderPonyGuardian {
public Elder(RenderManager manager) { public Elder(EntityRenderDispatcher manager) {
super(manager); super(manager);
} }
@Override @Override
protected void preRenderCallback(EntityGuardian entity, float ticks) { protected void scale(GuardianEntity entity, float ticks) {
super.preRenderCallback(entity, ticks); super.scale(entity, ticks);
GlStateManager.scalef(2.35F, 2.35F, 2.35F); GlStateManager.scalef(2.35F, 2.35F, 2.35F);
} }
} }

View file

@ -5,96 +5,94 @@ import com.minelittlepony.client.model.entities.ModelIllagerPony;
import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.client.render.RenderPonyMob;
import com.minelittlepony.client.render.layer.LayerHeldItemIllager; import com.minelittlepony.client.render.layer.LayerHeldItemIllager;
import com.minelittlepony.client.render.layer.LayerHeldPonyItem; import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.mob.EvokerEntity;
import net.minecraft.entity.monster.AbstractIllager; import net.minecraft.entity.mob.IllagerEntity;
import net.minecraft.entity.monster.EntityEvoker; import net.minecraft.entity.mob.IllusionerEntity;
import net.minecraft.entity.monster.EntityIllusionIllager; import net.minecraft.entity.mob.VindicatorEntity;
import net.minecraft.entity.monster.EntityVindicator; import net.minecraft.util.Identifier;
import net.minecraft.util.ResourceLocation;
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 abstract class RenderPonyIllager<T extends AbstractIllager> extends RenderPonyMob<T> { public abstract class RenderPonyIllager<T extends IllagerEntity> extends RenderPonyMob<T, ModelIllagerPony<T>> {
public static final ResourceLocation ILLUSIONIST = new ResourceLocation("minelittlepony", "textures/entity/illager/illusionist_pony.png"); public static final Identifier ILLUSIONIST = new Identifier("minelittlepony", "textures/entity/illager/illusionist_pony.png");
public static final ResourceLocation EVOKER = new ResourceLocation("minelittlepony", "textures/entity/illager/evoker_pony.png"); public static final Identifier EVOKER = new Identifier("minelittlepony", "textures/entity/illager/evoker_pony.png");
public static final ResourceLocation VINDICATOR = new ResourceLocation("minelittlepony", "textures/entity/illager/vindicator_pony.png"); public static final Identifier VINDICATOR = new Identifier("minelittlepony", "textures/entity/illager/vindicator_pony.png");
private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelIllagerPony()); public RenderPonyIllager(EntityRenderDispatcher manager) {
super(manager, new ModelWrapper<>(new ModelIllagerPony<>()));
public RenderPonyIllager(RenderManager manager) {
super(manager, MODEL_WRAPPER);
} }
@Override @Override
protected LayerHeldPonyItem<T> createItemHoldingLayer() { protected LayerHeldPonyItem<T, ModelIllagerPony<T>> createItemHoldingLayer() {
return new LayerHeldItemIllager<>(this); return new LayerHeldItemIllager<>(this);
} }
@Override @Override
public void preRenderCallback(T entity, float ticks) { public void scale(T entity, float ticks) {
super.preRenderCallback(entity, ticks); super.scale(entity, ticks);
GlStateManager.scalef(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE); GlStateManager.scalef(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE);
} }
public static class Vindicator extends RenderPonyIllager<EntityVindicator> { public static class Vindicator extends RenderPonyIllager<VindicatorEntity> {
public Vindicator(RenderManager manager) { public Vindicator(EntityRenderDispatcher manager) {
super(manager); super(manager);
} }
@Override @Override
public ResourceLocation getTexture(EntityVindicator entity) { public Identifier findTexture(VindicatorEntity entity) {
return VINDICATOR; return VINDICATOR;
} }
} }
public static class Evoker extends RenderPonyIllager<EntityEvoker> { public static class Evoker extends RenderPonyIllager<EvokerEntity> {
public Evoker(RenderManager manager) { public Evoker(EntityRenderDispatcher manager) {
super(manager); super(manager);
} }
@Override @Override
public ResourceLocation getTexture(EntityEvoker entity) { public Identifier findTexture(EvokerEntity entity) {
return EVOKER; return EVOKER;
} }
} }
public static class Illusionist extends RenderPonyIllager<EntityIllusionIllager> { public static class Illusionist extends RenderPonyIllager<IllusionerEntity> {
public Illusionist(RenderManager manager) { public Illusionist(EntityRenderDispatcher manager) {
super(manager); super(manager);
} }
@Override @Override
public ResourceLocation getTexture(EntityIllusionIllager entity) { public Identifier findTexture(IllusionerEntity entity) {
return ILLUSIONIST; return ILLUSIONIST;
} }
@Override @Override
public void doRender(EntityIllusionIllager entity, double x, double y, double z, float yaw, float ticks) { public void render(IllusionerEntity entity, double x, double y, double z, float yaw, float ticks) {
if (entity.isInvisible()) { if (entity.isInvisible()) {
Vec3d[] clones = entity.getRenderLocations(ticks); Vec3d[] clones = entity.method_7065(ticks);
float rotation = handleRotationFloat(entity, ticks); float rotation = getAge(entity, ticks);
for (int i = 0; i < clones.length; ++i) { for (int i = 0; i < clones.length; ++i) {
super.doRender(entity, super.render(entity,
x + clones[i].x + MathHelper.cos(i + rotation * 0.5F) * 0.025D, x + clones[i].x + MathHelper.cos(i + rotation * 0.5F) * 0.025D,
y + clones[i].y + MathHelper.cos(i + rotation * 0.75F) * 0.0125D, y + clones[i].y + MathHelper.cos(i + rotation * 0.75F) * 0.0125D,
z + clones[i].z + MathHelper.cos(i + rotation * 0.7F) * 0.025D, z + clones[i].z + MathHelper.cos(i + rotation * 0.7F) * 0.025D,
yaw, ticks); yaw, ticks);
} }
} else { } else {
super.doRender(entity, x, y, z, yaw, ticks); super.render(entity, x, y, z, yaw, ticks);
} }
} }
@Override @Override
protected boolean isVisible(EntityIllusionIllager entity) { protected boolean method_4056(IllusionerEntity entity) {
return true; return true;
} }
} }

View file

@ -3,59 +3,64 @@ package com.minelittlepony.client.render.entities;
import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.model.entities.ModelSkeletonPony; import com.minelittlepony.client.model.entities.ModelSkeletonPony;
import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.client.render.RenderPonyMob;
import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
import com.minelittlepony.client.render.layer.LayerPonyStrayOverlay; import com.minelittlepony.client.render.layer.LayerPonyStrayOverlay;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.mob.AbstractSkeletonEntity;
import net.minecraft.entity.monster.AbstractSkeleton; import net.minecraft.entity.mob.StrayEntity;
import net.minecraft.entity.monster.EntityStray; import net.minecraft.entity.mob.WitherSkeletonEntity;
import net.minecraft.entity.monster.EntityWitherSkeleton; import net.minecraft.util.Identifier;
import net.minecraft.util.ResourceLocation;
public class RenderPonySkeleton<Skeleton extends AbstractSkeleton> extends RenderPonyMob<Skeleton> { public class RenderPonySkeleton<Skeleton extends AbstractSkeletonEntity> extends RenderPonyMob<Skeleton, ModelSkeletonPony<Skeleton>> {
public static final ResourceLocation SKELETON = new ResourceLocation("minelittlepony", "textures/entity/skeleton/skeleton_pony.png"); public static final Identifier SKELETON = new Identifier("minelittlepony", "textures/entity/skeleton/skeleton_pony.png");
public static final ResourceLocation WITHER = new ResourceLocation("minelittlepony", "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 ResourceLocation STRAY = new ResourceLocation("minelittlepony", "textures/entity/skeleton/stray_pony.png"); public static final Identifier STRAY = new Identifier("minelittlepony", "textures/entity/skeleton/stray_pony.png");
private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelSkeletonPony()); public RenderPonySkeleton(EntityRenderDispatcher manager) {
super(manager, new ModelWrapper<>(new ModelSkeletonPony<>()));
public RenderPonySkeleton(RenderManager manager) {
super(manager, MODEL_WRAPPER);
} }
@Override @Override
public ResourceLocation getTexture(Skeleton entity) { public Identifier findTexture(Skeleton entity) {
return SKELETON; return SKELETON;
} }
public static class Stray extends RenderPonySkeleton<EntityStray> { @Override
protected LayerHeldPonyItem<Skeleton, ModelSkeletonPony<Skeleton>> createItemHoldingLayer() {
return new LayerHeldPonyItemMagical<>(this);
}
public Stray(RenderManager rm) { public static class Stray extends RenderPonySkeleton<StrayEntity> {
public Stray(EntityRenderDispatcher rm) {
super(rm); super(rm);
addLayer(new LayerPonyStrayOverlay(this)); addFeature(new LayerPonyStrayOverlay<>(this));
} }
@Override @Override
public ResourceLocation getTexture(EntityStray entity) { public Identifier findTexture(StrayEntity entity) {
return STRAY; return STRAY;
} }
} }
public static class Wither extends RenderPonySkeleton<EntityWitherSkeleton> { public static class Wither extends RenderPonySkeleton<WitherSkeletonEntity> {
public Wither(RenderManager rm) { public Wither(EntityRenderDispatcher rm) {
super(rm); super(rm);
} }
@Override @Override
public ResourceLocation getTexture(EntityWitherSkeleton entity) { public Identifier findTexture(WitherSkeletonEntity entity) {
return WITHER; return WITHER;
} }
@Override @Override
public void preRenderCallback(EntityWitherSkeleton skeleton, float ticks) { public void scale(WitherSkeletonEntity skeleton, float ticks) {
super.preRenderCallback(skeleton, ticks); super.scale(skeleton, ticks);
GlStateManager.scalef(1.2F, 1.2F, 1.2F); GlStateManager.scalef(1.2F, 1.2F, 1.2F);
} }

View file

@ -1,32 +1,32 @@
package com.minelittlepony.client.render.entities; package com.minelittlepony.client.render.entities;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.render.entity.BipedEntityRenderer;
import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.mob.VexEntity;
import net.minecraft.entity.monster.EntityVex; import net.minecraft.util.Identifier;
import net.minecraft.util.ResourceLocation;
import com.minelittlepony.client.model.entities.ModelBreezie; import com.minelittlepony.client.model.entities.ModelBreezie;
import com.mojang.blaze3d.platform.GlStateManager;
/** /**
* AKA a breezie :D * AKA a breezie :D
*/ */
public class RenderPonyVex extends RenderBiped<EntityVex> { public class RenderPonyVex extends BipedEntityRenderer<VexEntity, ModelBreezie<VexEntity>> {
private static final ResourceLocation VEX = new ResourceLocation("minelittlepony", "textures/entity/illager/vex_pony.png"); private static final Identifier VEX = new Identifier("minelittlepony", "textures/entity/illager/vex_pony.png");
private static final ResourceLocation VEX_CHARGING = new ResourceLocation("minelittlepony", "textures/entity/illager/vex_charging_pony.png"); private static final Identifier VEX_CHARGING = new Identifier("minelittlepony", "textures/entity/illager/vex_charging_pony.png");
public RenderPonyVex(RenderManager manager) { public RenderPonyVex(EntityRenderDispatcher manager) {
super(manager, new ModelBreezie(), 0.3F); super(manager, new ModelBreezie<>(), 0.3F);
} }
@Override @Override
protected void preRenderCallback(EntityVex entity, float ticks) { protected void scale(VexEntity entity, float ticks) {
GlStateManager.scalef(0.4F, 0.4F, 0.4F); GlStateManager.scalef(0.4F, 0.4F, 0.4F);
} }
@Override @Override
protected ResourceLocation getEntityTexture(EntityVex entity) { protected Identifier getTexture(VexEntity entity) {
return entity.isCharging() ? VEX_CHARGING : VEX; return entity.isCharging() ? VEX_CHARGING : VEX;
} }

View file

@ -5,52 +5,43 @@ import com.minelittlepony.client.model.entities.ModelVillagerPony;
import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.client.render.RenderPonyMob;
import com.minelittlepony.util.resources.FormattedTextureSupplier; import com.minelittlepony.util.resources.FormattedTextureSupplier;
import com.minelittlepony.util.resources.ITextureSupplier; import com.minelittlepony.util.resources.ITextureSupplier;
import com.minelittlepony.util.resources.IntStringMapper; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.entity.passive.EntityVillager; import net.minecraft.util.Identifier;
import net.minecraft.util.ResourceLocation; import net.minecraft.village.VillagerData;
public class RenderPonyVillager extends RenderPonyMob<EntityVillager> { public class RenderPonyVillager extends RenderPonyMob.Caster<VillagerEntity, ModelVillagerPony<VillagerEntity>> {
/**
* Key mapping from a villager profession id to a human readable name
*/
public static final IntStringMapper MAPPER = new IntStringMapper("farmer", "librarian", "priest", "smith", "butcher", "villager");
private static final ITextureSupplier<String> FORMATTER = new FormattedTextureSupplier("minelittlepony", "textures/entity/villager/%s_pony.png"); private static final ITextureSupplier<String> FORMATTER = new FormattedTextureSupplier("minelittlepony", "textures/entity/villager/%s_pony.png");
private static final ResourceLocation DEFAULT = FORMATTER.supplyTexture("villager"); private static final Identifier DEFAULT = FORMATTER.supplyTexture("villager");
private static final ResourceLocation EGG = FORMATTER.supplyTexture("silly"); private static final Identifier EGG = FORMATTER.supplyTexture("silly");
private static final ResourceLocation EGG_2 = FORMATTER.supplyTexture("tiny_silly"); private static final Identifier EGG_2 = FORMATTER.supplyTexture("tiny_silly");
private static final ITextureSupplier<Integer> PROFESSIONS = new VillagerProfessionTextureCache(FORMATTER, MAPPER, DEFAULT); private static final ITextureSupplier<VillagerData> PROFESSIONS = new VillagerProfessionTextureCache(FORMATTER, DEFAULT);
private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelVillagerPony()); public RenderPonyVillager(EntityRenderDispatcher manager) {
super(manager, new ModelWrapper<>(new ModelVillagerPony<>()));
public RenderPonyVillager(RenderManager manager) {
super(manager, MODEL_WRAPPER);
} }
@Override @Override
public void preRenderCallback(EntityVillager villager, float ticks) { public void scale(VillagerEntity villager, float ticks) {
super.preRenderCallback(villager, ticks); super.scale(villager, ticks);
GlStateManager.scalef(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE); GlStateManager.scalef(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE);
} }
@SuppressWarnings("deprecation") // let me use getProfession in peace. I don't care that forge has their own one.
@Override @Override
public ResourceLocation getTexture(EntityVillager entity) { public Identifier findTexture(VillagerEntity entity) {
String name = entity.getCustomName().getUnformattedComponentText(); String name = entity.getCustomName().getString();
if ("Derpy".equals(name) || (entity.isChild() && "Dinky".equals(name))) { if ("Derpy".equals(name) || (entity.isBaby() && "Dinky".equals(name))) {
if (entity.isChild()) { if (entity.isBaby()) {
return EGG_2; return EGG_2;
} }
return EGG; return EGG;
} }
return PROFESSIONS.supplyTexture(entity.getProfession()); return PROFESSIONS.supplyTexture(entity.getVillagerData());
} }
} }

View file

@ -4,31 +4,28 @@ import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.model.entities.ModelWitchPony; import com.minelittlepony.client.model.entities.ModelWitchPony;
import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.client.render.RenderPonyMob;
import com.minelittlepony.client.render.layer.LayerHeldPonyItem; import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.mob.WitchEntity;
import net.minecraft.entity.monster.EntityWitch;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHandSide; import net.minecraft.util.AbsoluteHand;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
@SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it. public class RenderPonyWitch extends RenderPonyMob<WitchEntity, ModelWitchPony> {
public class RenderPonyWitch extends RenderPonyMob<EntityWitch> {
private static final ResourceLocation WITCH_TEXTURES = new ResourceLocation("minelittlepony", "textures/entity/witch_pony.png"); private static final Identifier WITCH_TEXTURES = new Identifier("minelittlepony", "textures/entity/witch_pony.png");
private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelWitchPony()); public RenderPonyWitch(EntityRenderDispatcher manager) {
super(manager, new ModelWrapper<>(new ModelWitchPony()));
public RenderPonyWitch(RenderManager manager) {
super(manager, MODEL_WRAPPER);
} }
@Override @Override
protected LayerHeldPonyItem<EntityWitch> createItemHoldingLayer() { protected LayerHeldPonyItem<WitchEntity, ModelWitchPony> createItemHoldingLayer() {
return new LayerHeldPonyItem<EntityWitch>(this) { return new LayerHeldPonyItem<WitchEntity, ModelWitchPony>(this) {
@Override @Override
protected void preItemRender(EntityWitch entity, ItemStack drop, TransformType transform, EnumHandSide hand) { protected void preItemRender(WitchEntity entity, ItemStack drop, ModelTransformation.Type transform, AbsoluteHand hand) {
GlStateManager.translatef(0, -0.3F, -0.8F); GlStateManager.translatef(0, -0.3F, -0.8F);
GlStateManager.rotatef(10, 1, 0, 0); GlStateManager.rotatef(10, 1, 0, 0);
} }
@ -36,13 +33,13 @@ public class RenderPonyWitch extends RenderPonyMob<EntityWitch> {
} }
@Override @Override
public void preRenderCallback(EntityWitch entity, float ticks) { public void scale(WitchEntity entity, float ticks) {
super.preRenderCallback(entity, ticks); super.scale(entity, ticks);
GlStateManager.scalef(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE); GlStateManager.scalef(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE);
} }
@Override @Override
public ResourceLocation getTexture(EntityWitch entity) { public Identifier findTexture(WitchEntity entity) {
return WITCH_TEXTURES; return WITCH_TEXTURES;
} }
} }

View file

@ -3,77 +3,75 @@ package com.minelittlepony.client.render.entities;
import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.model.entities.ModelZombiePony; import com.minelittlepony.client.model.entities.ModelZombiePony;
import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.client.render.RenderPonyMob;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.mob.GiantEntity;
import net.minecraft.entity.monster.EntityGiantZombie; import net.minecraft.entity.mob.HuskEntity;
import net.minecraft.entity.monster.EntityHusk; import net.minecraft.entity.mob.ZombieEntity;
import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.mob.ZombiePigmanEntity;
import net.minecraft.entity.monster.EntityZombie; import net.minecraft.util.Identifier;
import net.minecraft.util.ResourceLocation;
public class RenderPonyZombie<Zombie extends EntityZombie> extends RenderPonyMob<Zombie> { public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob.Caster<Zombie, ModelZombiePony<Zombie>> {
public static final ResourceLocation ZOMBIE = new ResourceLocation("minelittlepony", "textures/entity/zombie/zombie_pony.png"); public static final Identifier ZOMBIE = new Identifier("minelittlepony", "textures/entity/zombie/zombie_pony.png");
public static final ResourceLocation HUSK = new ResourceLocation("minelittlepony", "textures/entity/zombie/husk_pony.png"); public static final Identifier HUSK = new Identifier("minelittlepony", "textures/entity/zombie/husk_pony.png");
public static final ResourceLocation PIGMAN = new ResourceLocation("minelittlepony", "textures/entity/zombie/zombie_pigman_pony.png"); public static final Identifier PIGMAN = new Identifier("minelittlepony", "textures/entity/zombie/zombie_pigman_pony.png");
private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelZombiePony()); public RenderPonyZombie(EntityRenderDispatcher manager) {
super(manager, new ModelWrapper<>(new ModelZombiePony<>()));
public RenderPonyZombie(RenderManager manager) {
super(manager, MODEL_WRAPPER);
} }
@Override @Override
public ResourceLocation getTexture(Zombie entity) { public Identifier findTexture(Zombie entity) {
return ZOMBIE; return ZOMBIE;
} }
public static class Pigman extends RenderPonyZombie<EntityPigZombie> { public static class Pigman extends RenderPonyZombie<ZombiePigmanEntity> {
public Pigman(RenderManager manager) { public Pigman(EntityRenderDispatcher manager) {
super(manager); super(manager);
} }
@Override @Override
public ResourceLocation getTexture(EntityPigZombie entity) { public Identifier findTexture(ZombiePigmanEntity entity) {
return PIGMAN; return PIGMAN;
} }
} }
public static class Husk extends RenderPonyZombie<EntityHusk> { public static class Husk extends RenderPonyZombie<HuskEntity> {
public Husk(RenderManager manager) { public Husk(EntityRenderDispatcher manager) {
super(manager); super(manager);
} }
@Override @Override
public void preRenderCallback(EntityHusk entity, float ticks) { public void scale(HuskEntity entity, float ticks) {
super.preRenderCallback(entity, ticks); super.scale(entity, ticks);
GlStateManager.scalef(1.0625F, 1.0625F, 1.0625F); GlStateManager.scalef(1.0625F, 1.0625F, 1.0625F);
} }
@Override @Override
public ResourceLocation getTexture(EntityHusk entity) { public Identifier findTexture(HuskEntity entity) {
return HUSK; return HUSK;
} }
} }
public static class Giant extends RenderPonyMob<EntityGiantZombie> { public static class Giant extends RenderPonyMob.Caster<GiantEntity, ModelZombiePony<GiantEntity>> {
public Giant(RenderManager manager) { public Giant(EntityRenderDispatcher manager) {
super(manager, MODEL_WRAPPER); super(manager, new ModelWrapper<>(new ModelZombiePony<>()));
} }
@Override @Override
public void preRenderCallback(EntityGiantZombie entity, float ticks) { public void scale(GiantEntity entity, float ticks) {
super.preRenderCallback(entity, ticks); super.scale(entity, ticks);
GlStateManager.scalef(3, 3, 3); GlStateManager.scalef(3, 3, 3);
} }
@Override @Override
public ResourceLocation getTexture(EntityGiantZombie entity) { public Identifier findTexture(GiantEntity entity) {
return ZOMBIE; return ZOMBIE;
} }
} }

View file

@ -5,54 +5,45 @@ import com.minelittlepony.client.model.entities.ModelZombieVillagerPony;
import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.client.render.RenderPonyMob;
import com.minelittlepony.util.resources.FormattedTextureSupplier; import com.minelittlepony.util.resources.FormattedTextureSupplier;
import com.minelittlepony.util.resources.ITextureSupplier; import com.minelittlepony.util.resources.ITextureSupplier;
import com.minelittlepony.util.resources.IntStringMapper;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.entity.mob.ZombieVillagerEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import net.minecraft.village.VillagerData;
public class RenderPonyZombieVillager extends RenderPonyMob<EntityZombieVillager> { public class RenderPonyZombieVillager extends RenderPonyMob.Caster<ZombieVillagerEntity, ModelZombieVillagerPony> {
/**
* Ditto.
* @see RenderPonyVillager.MAPPER
*/
public static final IntStringMapper MAPPER = new IntStringMapper("farmer", "librarian", "priest", "smith", "butcher", "villager");
private static final ITextureSupplier<String> FORMATTER = new FormattedTextureSupplier("minelittlepony", "textures/entity/zombie_villager/zombie_%s_pony.png"); private static final ITextureSupplier<String> FORMATTER = new FormattedTextureSupplier("minelittlepony", "textures/entity/zombie_villager/zombie_%s_pony.png");
private static final ResourceLocation DEFAULT = FORMATTER.supplyTexture("villager"); private static final Identifier DEFAULT = FORMATTER.supplyTexture("villager");
private static final ResourceLocation EGG = FORMATTER.supplyTexture("silly"); private static final Identifier EGG = FORMATTER.supplyTexture("silly");
private static final ResourceLocation EGG_2 = FORMATTER.supplyTexture("tiny_silly"); private static final Identifier EGG_2 = FORMATTER.supplyTexture("tiny_silly");
private static final ITextureSupplier<Integer> PROFESSIONS = new VillagerProfessionTextureCache(FORMATTER, MAPPER, DEFAULT); private static final ITextureSupplier<VillagerData> PROFESSIONS = new VillagerProfessionTextureCache(FORMATTER, DEFAULT);
private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelZombieVillagerPony()); public RenderPonyZombieVillager(EntityRenderDispatcher manager) {
super(manager, new ModelWrapper<>(new ModelZombieVillagerPony()));
public RenderPonyZombieVillager(RenderManager manager) {
super(manager, MODEL_WRAPPER);
} }
@SuppressWarnings("deprecation") // let me use getProfession in peace. I don't care that forge has their own one.
@Override @Override
public ResourceLocation getTexture(EntityZombieVillager entity) { public Identifier findTexture(ZombieVillagerEntity entity) {
String name = entity.getCustomName().getUnformattedComponentText(); String name = entity.getCustomName().getString();
if ("Derpy".equals(name) || (entity.isChild() && "Dinky".equals(name))) { if ("Derpy".equals(name) || (entity.isBaby() && "Dinky".equals(name))) {
if (entity.isChild()) { if (entity.isBaby()) {
return EGG_2; return EGG_2;
} }
return EGG; return EGG;
} }
return PROFESSIONS.supplyTexture(entity.getProfession()); return PROFESSIONS.supplyTexture(entity.getVillagerData());
} }
@Override @Override
protected void applyRotations(EntityZombieVillager entity, float move, float rotationYaw, float ticks) { protected void setupTransforms(ZombieVillagerEntity entity, float move, float rotationYaw, float ticks) {
if (entity.isConverting()) { if (entity.isConverting()) {
rotationYaw += (float) (Math.cos(entity.ticksExisted * 3.25D) * (Math.PI / 4)); rotationYaw += (float) (Math.cos(entity.age * 3.25D) * (Math.PI / 4));
} }
super.applyRotations(entity, move, rotationYaw, ticks); super.setupTransforms(entity, move, rotationYaw, ticks);
} }
} }

View file

@ -1,10 +1,12 @@
package com.minelittlepony.client.render.entities; package com.minelittlepony.client.render.entities;
import net.minecraft.client.Minecraft; import net.minecraft.client.MinecraftClient;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.Identifier;
import net.minecraft.village.VillagerData;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.util.resources.ITextureSupplier; import com.minelittlepony.util.resources.ITextureSupplier;
import com.minelittlepony.util.resources.ProfessionStringMapper;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -14,15 +16,15 @@ import java.util.function.Function;
/** /**
* Cached pool of villager textures. * Cached pool of villager textures.
*/ */
class VillagerProfessionTextureCache implements ITextureSupplier<Integer> { class VillagerProfessionTextureCache implements ITextureSupplier<VillagerData> {
private final ITextureSupplier<String> formatter; private final ITextureSupplier<String> formatter;
private final Function<Integer, String> keyMapper; private final Function<VillagerData, String> keyMapper = new ProfessionStringMapper();
private final ResourceLocation fallback; private final Identifier fallback;
private final Map<Integer, ResourceLocation> cache = new HashMap<>(); private final Map<String, Identifier> cache = new HashMap<>();
/** /**
* Creates a new profession cache * Creates a new profession cache
@ -31,22 +33,21 @@ class VillagerProfessionTextureCache implements ITextureSupplier<Integer> {
* @param keyMapper Mapper to convert integer ids into a string value for format insertion * @param keyMapper Mapper to convert integer ids into a string value for format insertion
* @param fallback The default if any generated textures fail to load. This is stored in place of failing textures. * @param fallback The default if any generated textures fail to load. This is stored in place of failing textures.
*/ */
public VillagerProfessionTextureCache(ITextureSupplier<String> formatter, Function<Integer, String> keyMapper, ResourceLocation fallback) { public VillagerProfessionTextureCache(ITextureSupplier<String> formatter, Identifier fallback) {
this.formatter = formatter; this.formatter = formatter;
this.fallback = fallback; this.fallback = fallback;
this.keyMapper = keyMapper;
} }
@Override @Override
public ResourceLocation supplyTexture(Integer profession) { public Identifier supplyTexture(VillagerData data) {
return cache.computeIfAbsent(profession, this::getModProfessionResource); return cache.computeIfAbsent(keyMapper.apply(data), this::getModProfessionResource);
} }
private ResourceLocation getModProfessionResource(int professionId) { private Identifier getModProfessionResource(String professionId) {
ResourceLocation generated = formatter.supplyTexture(keyMapper.apply(professionId)); Identifier generated = formatter.supplyTexture(professionId);
try { try {
Minecraft.getInstance().getResourceManager().getResource(generated); MinecraftClient.getInstance().getResourceManager().getResource(generated);
} catch (IOException e) { } catch (IOException e) {
MineLittlePony.logger.error("Error loading villager texture `" + generated + "`.", e); MineLittlePony.logger.error("Error loading villager texture `" + generated + "`.", e);

View file

@ -1,7 +1,4 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
package com.minelittlepony.client.render.entities; package com.minelittlepony.client.render.entities;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,9 +1,10 @@
package com.minelittlepony.client.render.entities.player; package com.minelittlepony.client.render.entities.player;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.ducks.IRenderPony; import com.minelittlepony.client.model.ClientPonyModel;
import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.render.DebugBoundingBoxRenderer; import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
import com.minelittlepony.client.render.IPonyRender;
import com.minelittlepony.client.render.RenderPony; import com.minelittlepony.client.render.RenderPony;
import com.minelittlepony.client.render.layer.LayerDJPon3Head; import com.minelittlepony.client.render.layer.LayerDJPon3Head;
import com.minelittlepony.client.render.layer.LayerEntityOnPonyShoulder; import com.minelittlepony.client.render.layer.LayerEntityOnPonyShoulder;
@ -14,127 +15,135 @@ import com.minelittlepony.client.render.layer.LayerPonyCape;
import com.minelittlepony.client.render.layer.LayerPonyCustomHead; import com.minelittlepony.client.render.layer.LayerPonyCustomHead;
import com.minelittlepony.client.render.layer.LayerPonyElytra; import com.minelittlepony.client.render.layer.LayerPonyElytra;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.block.BlockBed; import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.block.BedBlock;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.renderer.culling.ICamera; import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.render.VisibleRegion;
import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.layers.LayerArrow; import net.minecraft.client.render.entity.PlayerEntityRenderer;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.EnumHandSide; import net.minecraft.entity.LivingEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.AbsoluteHand;
import net.minecraft.util.Identifier;
public class RenderPonyPlayer extends RenderPlayer implements IRenderPony<AbstractClientPlayer> { public class RenderPonyPlayer extends PlayerEntityRenderer implements IPonyRender<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> {
protected final RenderPony<AbstractClientPlayer> renderPony = new RenderPony<>(this); protected final RenderPony<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> renderPony = new RenderPony<>(this);
public RenderPonyPlayer(RenderManager manager, boolean useSmallArms, ModelWrapper model) { public RenderPonyPlayer(EntityRenderDispatcher manager, boolean useSmallArms, ModelWrapper<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> model) {
super(manager, useSmallArms); super(manager, useSmallArms);
mainModel = renderPony.setPonyModel(model); this.model = renderPony.setPonyModel(model);
addLayers(); addLayers();
} }
protected void addLayers() { protected void addLayers() {
layerRenderers.clear(); features.clear();
addLayer(new LayerDJPon3Head(this)); addLayer(new LayerDJPon3Head<>(this));
addLayer(new LayerPonyArmor<>(this)); addLayer(new LayerPonyArmor<>(this));
addLayer(new LayerArrow(this)); addFeature(new StuckArrowsFeatureRenderer<>(this));
addLayer(new LayerPonyCustomHead<>(this)); addLayer(new LayerPonyCustomHead<>(this));
addLayer(new LayerPonyElytra<>(this)); addLayer(new LayerPonyElytra<>(this));
addLayer(new LayerHeldPonyItemMagical<>(this)); addLayer(new LayerHeldPonyItemMagical<>(this));
addLayer(new LayerPonyCape(this)); addLayer(new LayerPonyCape<>(this));
addLayer(new LayerEntityOnPonyShoulder(renderManager, this)); addLayer(new LayerEntityOnPonyShoulder<>(renderManager, this));
addLayer(new LayerGear<>(this)); addLayer(new LayerGear<>(this));
} }
@Override @SuppressWarnings({"unchecked", "rawtypes"})
public float prepareScale(AbstractClientPlayer player, float ticks) { protected boolean addLayer(FeatureRenderer<AbstractClientPlayerEntity, ? extends ClientPonyModel<AbstractClientPlayerEntity>> feature) {
return ((List)features).add(feature);
}
if (!player.isPassenger() && !player.isPlayerSleeping()) { @Override
float x = player.width/2; public float scaleAndTranslate(AbstractClientPlayerEntity player, float ticks) {
if (!player.hasVehicle() && !player.isSleeping()) {
float x = player.getWidth() / 2;
float y = 0; float y = 0;
if (player.isSneaking()) { if (player.isSneaking()) {
// Sneaking makes the player 1/15th shorter. // Sneaking makes the player 1/15th shorter.
// This should be compatible with height-changing mods. // This should be compatible with height-changing mods.
y += player.height / 15; y += player.getHeight() / 15;
} }
super.doRenderShadowAndFire(player, 0, y, x, 0, ticks); super.postRender(player, 0, y, x, 0, ticks);
} }
return super.prepareScale(player, ticks); return super.scaleAndTranslate(player, ticks);
} }
@Override @Override
protected void preRenderCallback(AbstractClientPlayer player, float ticks) { protected void scale(AbstractClientPlayerEntity player, float ticks) {
renderPony.preRenderCallback(player, ticks); renderPony.preRenderCallback(player, ticks);
shadowSize = renderPony.getShadowScale(); field_4673 = renderPony.getShadowScale();
if (player.isPassenger()) { if (player.hasVehicle()) {
GlStateManager.translated(0, player.getYOffset(), 0); GlStateManager.translated(0, player.getHeightOffset(), 0);
} }
} }
@Override @Override
public void doRender(AbstractClientPlayer entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) { public void render(AbstractClientPlayerEntity entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) {
super.doRender(entity, xPosition, yPosition, zPosition, yaw, ticks); super.render(entity, xPosition, yPosition, zPosition, yaw, ticks);
DebugBoundingBoxRenderer.instance.render(renderPony.getPony(entity), entity, ticks); DebugBoundingBoxRenderer.instance.render(renderPony.getPony(entity), entity, ticks);
} }
@Override @Override
public boolean shouldRender(AbstractClientPlayer entity, ICamera camera, double camX, double camY, double camZ) { public boolean isVisible(AbstractClientPlayerEntity entity, VisibleRegion camera, double camX, double camY, double camZ) {
if (entity.isPlayerSleeping() && entity == Minecraft.getInstance().player) { if (entity.isSleeping() && entity == MinecraftClient.getInstance().player) {
return true; return true;
} }
return super.shouldRender(entity, renderPony.getFrustrum(entity, camera), camX, camY, camZ); return super.isVisible(entity, renderPony.getFrustrum(entity, camera), camX, camY, camZ);
} }
@Override @Override
protected void renderLivingLabel(AbstractClientPlayer entity, String name, double x, double y, double z, int maxDistance) { protected void renderLabel(AbstractClientPlayerEntity entity, String name, double x, double y, double z, int maxDistance) {
if (entity.isPlayerSleeping()) { if (entity.isSleeping()) {
if (entity.bedLocation != null && entity.getEntityWorld().getBlockState(entity.bedLocation).getBlock() instanceof BlockBed) { if (entity.getSleepingPosition().isPresent() && entity.getEntityWorld().getBlockState(entity.getSleepingPosition().get()).getBlock() instanceof BedBlock) {
double bedRad = Math.toRadians(entity.getBedOrientationInDegrees()); double bedRad = Math.toRadians(entity.getSleepingDirection().asRotation());
x += Math.cos(bedRad); x += Math.cos(bedRad);
z -= Math.sin(bedRad); z -= Math.sin(bedRad);
} }
} }
super.renderLivingLabel(entity, name, x, renderPony.getNamePlateYOffset(entity, y), z, maxDistance); super.renderLabel(entity, name, x, renderPony.getNamePlateYOffset(entity, y), z, maxDistance);
} }
@Override @Override
public void doRenderShadowAndFire(Entity player, double x, double y, double z, float yaw, float ticks) { public void postRender(Entity player, double x, double y, double z, float yaw, float ticks) {
if (player.isPassenger() && ((AbstractClientPlayer)player).isPlayerSleeping()) { if (player.hasVehicle() && ((LivingEntity)player).isSleeping()) {
super.doRenderShadowAndFire(player, x, y, z, yaw, ticks); super.postRender(player, x, y, z, yaw, ticks);
} }
} }
@Override @Override
public final void renderRightArm(AbstractClientPlayer player) { public final void renderRightArm(AbstractClientPlayerEntity player) {
renderArm(player, EnumHandSide.RIGHT); renderArm(player, AbsoluteHand.RIGHT);
} }
@Override @Override
public final void renderLeftArm(AbstractClientPlayer player) { public final void renderLeftArm(AbstractClientPlayerEntity player) {
renderArm(player, EnumHandSide.LEFT); renderArm(player, AbsoluteHand.LEFT);
} }
protected void renderArm(AbstractClientPlayer player, EnumHandSide side) { protected void renderArm(AbstractClientPlayerEntity player, AbsoluteHand side) {
renderPony.updateModel(player); renderPony.updateModel(player);
bindEntityTexture(player); bindEntityTexture(player);
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translatef(side == EnumHandSide.LEFT ? 0.35F : -0.35F, -0.6F, 0); GlStateManager.translatef(side == AbsoluteHand.LEFT ? 0.35F : -0.35F, -0.6F, 0);
GlStateManager.rotatef(side == EnumHandSide.LEFT ? -90 : 90, 0, 1, 0); GlStateManager.rotatef(side == AbsoluteHand.LEFT ? -90 : 90, 0, 1, 0);
if (side == EnumHandSide.LEFT) { if (side == AbsoluteHand.LEFT) {
super.renderLeftArm(player); super.renderLeftArm(player);
} else { } else {
super.renderRightArm(player); super.renderRightArm(player);
@ -144,36 +153,36 @@ public class RenderPonyPlayer extends RenderPlayer implements IRenderPony<Abstra
} }
@Override @Override
protected void applyRotations(AbstractClientPlayer player, float age, float yaw, float ticks) { protected void setupTransforms(AbstractClientPlayerEntity player, float age, float yaw, float ticks) {
yaw = renderPony.getRenderYaw(player, yaw, ticks); yaw = renderPony.getRenderYaw(player, yaw, ticks);
super.applyRotations(player, age, yaw, ticks); super.setupTransforms(player, age, yaw, ticks);
renderPony.applyPostureTransform(player, yaw, ticks); renderPony.applyPostureTransform(player, yaw, ticks);
} }
@Override @Override
public ResourceLocation getEntityTexture(AbstractClientPlayer player) { public Identifier getTexture(AbstractClientPlayerEntity player) {
return renderPony.getPony(player).getTexture(); return renderPony.getPony(player).getTexture();
} }
@Override @Override
public ResourceLocation getTexture(AbstractClientPlayer entity) { public ModelWrapper<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> getModelWrapper() {
return getEntityTexture(entity);
}
@Override
public ModelWrapper getModelWrapper() {
return renderPony.playerModel; return renderPony.playerModel;
} }
@Override @Override
public IPony getEntityPony(AbstractClientPlayer player) { public IPony getEntityPony(AbstractClientPlayerEntity player) {
return MineLittlePony.getInstance().getManager().getPony(player); return MineLittlePony.getInstance().getManager().getPony(player);
} }
@Override @Override
public RenderPony<AbstractClientPlayer> getInternalRenderer() { public RenderPony<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> getInternalRenderer() {
return renderPony; return renderPony;
} }
@Override
public Identifier findTexture(AbstractClientPlayerEntity entity) {
return getTexture(entity);
}
} }

Some files were not shown because too many files have changed in this diff Show more