diff --git a/build.gradle b/build.gradle index d744bcf3..dbeb95aa 100644 --- a/build.gradle +++ b/build.gradle @@ -1,30 +1,36 @@ +// Frabric build script +// 24/05/2019 +// https://github.com/FabricMC/fabric-example-mod/blob/master/build.gradle + buildscript { - repositories { - jcenter() - maven { - name 'forge' - url 'http://files.minecraftforge.net/maven' - } -// maven { -// name = 'sponge' -// url = 'https://repo.spongepowered.org/maven' -// } - } + repositories { + jcenter() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + gradlePluginPortal() + } dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true - classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' + classpath 'fabric-loom:fabric-loom.gradle.plugin:0.2.2-SNAPSHOT' + classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' classpath 'org.ajoberstar.grgit:grgit-gradle:3.1.1' } } -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'eclipse' +repositories { + maven { + name = 'Jit' + url = 'https://jitpack.io' + } +} + +apply plugin: 'fabric-loom' apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'org.ajoberstar.grgit' -// From the forge MDK: Need this here so eclipse task generates correctly. -targetCompatibility = compileJava.targetCompatibility = 1.8 -sourceCompatibility = compileJava.sourceCompatibility = 1.8 +targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_1_8 ext { revision = grgit.log().size() @@ -49,77 +55,59 @@ group = project.group description = project.displayname 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 { + main {} client { // Client-only code compileClasspath += main.compileClasspath compileClasspath += main.output } - - fml { - compileClasspath += main.compileClasspath - compileClasspath += main.output - compileClasspath += client.output - } } -minecraft { - mappings channel: project.mappings_channel, version: project.mappings_version + "-" + project.minecraft_version +processResources { + inputs.property "version", project.version - runs { - client { - workingDirectory project.file('run') + from(sourceSets.main.resources.srcDirs) { + include "fabric.mod.json" + expand "version": project.version + } - property 'forge.logging.markers', 'SCAN' - property 'forge.logging.console.level', 'debug' - - 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 - }) + from(sourceSets.main.resources.srcDirs) { + exclude "fabric.mod.json" + } } tasks.withType(JavaCompile) { - it.options.compilerArgs += '-proc:none' + options.encoding = "UTF-8" } -manifest { - attributes( - "Implementation-Version": "${version} (git-${project.hash})", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ) + + +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = "sources" + from sourceSets.main.allSource + from sourceSets.client.allSource } jar { from sourceSets.main.output from sourceSets.client.output - from sourceSets.fml.output + from "LICENSE" } // diff --git a/gradle.properties b/gradle.properties index 94662dcc..0e67c3e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,22 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -group=com.minelittlepony -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 -minecraft_version=1.13.2 -forge_version=25.0.107 -mappings_channel=snapshot -mappings_version=20190324 + +# Fabric Properties + # check these on https://fabricmc.net/use + minecraft_version=1.14.1 + yarn_mappings=1.14.1+build.5 + loader_version=0.4.7+build.147 + +# Mod Properties + group=com.minelittlepony + 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 \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index ae9f33fd..66cf9de3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1 @@ rootProject.name = 'MineLittlePony' -// Checkout to parent dir to dev both -//includeBuild '../HDSkins' diff --git a/src/fml/java/com/minelittlepony/client/Config.java b/src/client/java/com/minelittlepony/client/Config.java similarity index 100% rename from src/fml/java/com/minelittlepony/client/Config.java rename to src/client/java/com/minelittlepony/client/Config.java diff --git a/src/client/java/com/minelittlepony/client/FabMod.java b/src/client/java/com/minelittlepony/client/FabMod.java new file mode 100644 index 00000000..ba482ed4 --- /dev/null +++ b/src/client/java/com/minelittlepony/client/FabMod.java @@ -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 void addRenderer(Class type, BlockEntityRenderer renderer) { + } + + @Override + public void addRenderer(Class type, Function> 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"); + } +} \ No newline at end of file diff --git a/src/client/java/com/minelittlepony/client/ForgeProxy.java b/src/client/java/com/minelittlepony/client/ForgeProxy.java index 515cd6ed..7af26738 100644 --- a/src/client/java/com/minelittlepony/client/ForgeProxy.java +++ b/src/client/java/com/minelittlepony/client/ForgeProxy.java @@ -1,11 +1,10 @@ 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.EntityLivingBase; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; -import net.minecraftforge.client.ForgeHooksClient; import javax.annotation.Nullable; @@ -24,9 +23,9 @@ public class ForgeProxy { * @param type unknown * @return */ - public static String getArmorTexture(Entity entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) { - if (MineLPClient.getInstance().getModUtilities().hasFml()) - return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type); + public static String getArmorTexture(Entity entity, ItemStack item, String def, EquipmentSlot slot, @Nullable String type) { + /*if (MineLPClient.getInstance().getModUtilities().hasFml()) + return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type);*/ return def; } @@ -38,10 +37,10 @@ public class ForgeProxy { * @param slot The slot this armour piece is place in. * @param def Default return value if no mods present */ - public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) { - if (MineLPClient.getInstance().getModUtilities().hasFml()) { + public static BipedEntityModel getArmorModel(T entity, ItemStack item, EquipmentSlot slot, BipedEntityModel def) { + /*if (MineLPClient.getInstance().getModUtilities().hasFml()) { return ForgeHooksClient.getArmorModel(entity, item, slot, def); - } + }*/ return def; } } diff --git a/src/client/java/com/minelittlepony/client/IModUtilities.java b/src/client/java/com/minelittlepony/client/IModUtilities.java index 17267e7a..e2c1239a 100644 --- a/src/client/java/com/minelittlepony/client/IModUtilities.java +++ b/src/client/java/com/minelittlepony/client/IModUtilities.java @@ -1,16 +1,26 @@ package com.minelittlepony.client; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.block.entity.BlockEntity; +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.tileentity.TileEntity; + +import java.nio.file.Path; +import java.util.function.Function; public interface IModUtilities { - void addRenderer(Class type, TileEntityRenderer renderer); + void addRenderer(Class type, BlockEntityRenderer renderer); - void addRenderer(Class type, Render renderer); + void addRenderer(Class type, Function> renderer); - boolean hasFml(); + default boolean hasFml() { + return false; + } float getRenderPartialTicks(); + + Path getConfigDirectory(); + + Path getAssetsDirectory(); } diff --git a/src/client/java/com/minelittlepony/client/MineLPClient.java b/src/client/java/com/minelittlepony/client/MineLPClient.java index 41f32784..e277a254 100644 --- a/src/client/java/com/minelittlepony/client/MineLPClient.java +++ b/src/client/java/com/minelittlepony/client/MineLPClient.java @@ -12,16 +12,16 @@ import com.minelittlepony.hdskins.net.SkinServer; import com.minelittlepony.hdskins.net.ValhallaSkinServer; import com.minelittlepony.settings.PonyConfig; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.resources.IReloadableResourceManager; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.client.util.InputMappings; -import net.minecraft.util.Util; -import net.minecraft.util.text.Style; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.ChatFormat; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.options.KeyBinding; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.util.InputUtil; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.resource.ReloadableResourceManager; +import net.minecraft.util.SystemUtil; import org.lwjgl.glfw.GLFW; @@ -58,8 +58,8 @@ public class MineLPClient extends MineLittlePony { config = newConfig; ponyManager = new PonyManager(config); - IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getInstance().getResourceManager(); - irrm.addReloadListener(ponyManager); + ReloadableResourceManager irrm = (ReloadableResourceManager) MinecraftClient.getInstance().getResourceManager(); + irrm.registerListener(ponyManager); // This also makes it the default gateway server. 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. */ - void postInit(Minecraft minecraft) { + void postInit(MinecraftClient minecraft) { HDSkins manager = HDSkins.getInstance(); // manager.setSkinUrl(SKIN_SERVER_URL); @@ -81,27 +81,27 @@ public class MineLPClient extends MineLittlePony { manager.setSkinsGui(GuiSkinsMineLP::new); - RenderManager rm = minecraft.getRenderManager(); + EntityRenderDispatcher rm = minecraft.getEntityRenderManager(); - renderManager.initialisePlayerRenderers(rm); - renderManager.initializeMobRenderers(rm, config); + renderManager.initialiseRenderers(rm); } - void onTick(Minecraft minecraft, boolean inGame) { + void onTick(MinecraftClient minecraft, boolean inGame) { if (inGame && minecraft.currentScreen == null) { if (SETTINGS_GUI.isPressed()) { - minecraft.displayGuiScreen(new GuiHost(new GuiPonySettings())); + minecraft.disconnect(new GuiHost(new GuiPonySettings())); } else { + long handle = minecraft.window.getHandle(); - if ((Util.milliTime() % 10) == 0) { - if (InputMappings.isKeyDown(GLFW.GLFW_KEY_F3) && InputMappings.isKeyDown(GLFW.GLFW_KEY_M)) { + if ((SystemUtil.getMeasuringTimeMs() % 10) == 0) { + if (InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_F3) && InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_M)) { if (!reloadingModels) { - minecraft.ingameGUI.getChatGUI().printChatMessage( - (new TextComponentString("")).appendSibling( - new TextComponentTranslation("debug.prefix") - .setStyle(new Style().setColor(TextFormatting.YELLOW).setBold(true))) - .appendText(" ") - .appendSibling(new TextComponentTranslation("minelp.debug.reload_models.message"))); + minecraft.inGameHud.getChatHud().addMessage( + (new TextComponent("")).append( + new TranslatableComponent("debug.prefix") + .setStyle(new Style().setColor(ChatFormat.YELLOW).setBold(true))) + .append(" ") + .append(new TranslatableComponent("minelp.debug.reload_models.message"))); reloadingModels = true; modelUpdateCounter++; diff --git a/src/client/java/com/minelittlepony/client/PonyRenderManager.java b/src/client/java/com/minelittlepony/client/PonyRenderManager.java index 8da20037..9f85c18f 100644 --- a/src/client/java/com/minelittlepony/client/PonyRenderManager.java +++ b/src/client/java/com/minelittlepony/client/PonyRenderManager.java @@ -1,26 +1,28 @@ package com.minelittlepony.client; import java.util.Map; +import java.util.function.Function; 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.RenderPonyModel; import com.minelittlepony.client.mixin.MixinRenderManager; import com.minelittlepony.client.model.races.PlayerModels; 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.player.RenderPonyPlayer; -import com.minelittlepony.settings.PonyConfig; +import com.minelittlepony.model.IPonyModel; import javax.annotation.Nullable; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.EntityRenderer; +import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.client.render.entity.model.EntityModel; 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. @@ -40,62 +42,54 @@ public class PonyRenderManager { private LevitatingItemRenderer magicRenderer = new LevitatingItemRenderer(); - private final Map, Render> renderMap = Maps.newHashMap(); + private final Map, EntityRenderer> renderMap = Maps.newHashMap(); /** * 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 - MineLPClient.getInstance().getModUtilities().addRenderer(EntityPonyModel.class, new RenderPonyModel(manager)); + MineLPClient.getInstance().getModUtilities().addRenderer(EntityPonyModel.class, RenderPonyModel::new); PlayerModels[] models = PlayerModels.values(); for (int i = 1; i < models.length; 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, 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); ((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. * * @param state True if we want ponies (the original will be stored) - * @param manager The render manager * @param type The type to replace * @param renderer The replacement value * @param The entity type */ @SuppressWarnings("unchecked") - public void switchRenderer(boolean state, RenderManager manager, Class type, Render renderer) { + public void switchRenderer(boolean state, Class type, Function> func) { if (state) { if (!renderMap.containsKey(type)) { - renderMap.put(type, manager.getEntityClassRenderObject(type)); + renderMap.put(type, MinecraftClient.getInstance().getEntityRenderManager().getRenderer(type)); } - MineLPClient.getInstance().getModUtilities().addRenderer((Class)type, renderer); + MineLPClient.getInstance().getModUtilities().addRenderer((Class)type, func); } else { if (renderMap.containsKey(type)) { - MineLPClient.getInstance().getModUtilities().addRenderer(type, (Render)renderMap.get(type)); + MineLPClient.getInstance().getModUtilities().addRenderer(type, m -> (EntityRenderer)renderMap.get(type)); } } } @@ -106,14 +100,14 @@ public class PonyRenderManager { @SuppressWarnings("unchecked") @Nullable - public & IRenderPony> R getPonyRenderer(@Nullable Entity entity) { - if (entity == null || !(entity instanceof EntityLivingBase)) { + public & IPonyModel, R extends LivingEntityRenderer & IPonyRender> R getPonyRenderer(@Nullable Entity entity) { + if (entity == null || !(entity instanceof LivingEntity)) { return null; } - Render renderer = Minecraft.getInstance().getRenderManager().getEntityRenderObject(entity); + EntityRenderer renderer = MinecraftClient.getInstance().getEntityRenderManager().getRenderer(entity); - if (renderer instanceof RenderLivingBase && renderer instanceof IRenderPony) { + if (renderer instanceof IPonyRender) { return (R)(Object)renderer; } diff --git a/src/client/java/com/minelittlepony/client/PonySkinParser.java b/src/client/java/com/minelittlepony/client/PonySkinParser.java index b9fd0536..5bbbdde4 100644 --- a/src/client/java/com/minelittlepony/client/PonySkinParser.java +++ b/src/client/java/com/minelittlepony/client/PonySkinParser.java @@ -7,14 +7,14 @@ import com.minelittlepony.hdskins.VanillaModels; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import java.util.Map; public class PonySkinParser implements ISkinParser { @Override - public void parse(GameProfile profile, MinecraftProfileTexture.Type type, ResourceLocation resource, + public void parse(GameProfile profile, MinecraftProfileTexture.Type type, Identifier resource, Map metadata) { if (type == MinecraftProfileTexture.Type.SKIN) { boolean slim = VanillaModels.isSlim(metadata.get("model")); diff --git a/src/client/java/com/minelittlepony/client/ducks/IBufferedTexture.java b/src/client/java/com/minelittlepony/client/ducks/IBufferedTexture.java index be8f9b47..2fc2c112 100644 --- a/src/client/java/com/minelittlepony/client/ducks/IBufferedTexture.java +++ b/src/client/java/com/minelittlepony/client/ducks/IBufferedTexture.java @@ -1,6 +1,6 @@ package com.minelittlepony.client.ducks; -import net.minecraft.client.renderer.texture.NativeImage; +import net.minecraft.client.texture.NativeImage; public interface IBufferedTexture { NativeImage getBufferedImage(); diff --git a/src/client/java/com/minelittlepony/client/ducks/IRenderPony.java b/src/client/java/com/minelittlepony/client/ducks/IRenderPony.java deleted file mode 100644 index 0b79ddf6..00000000 --- a/src/client/java/com/minelittlepony/client/ducks/IRenderPony.java +++ /dev/null @@ -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 extends PonyModelConstants { - - /** - * Gets the wrapped pony model for this renderer. - */ - ModelWrapper getModelWrapper(); - - IPony getEntityPony(T entity); - - RenderPony 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); - } - } -} diff --git a/src/client/java/com/minelittlepony/client/ducks/package-info.java b/src/client/java/com/minelittlepony/client/ducks/package-info.java index 90f115b8..faeec5f9 100644 --- a/src/client/java/com/minelittlepony/client/ducks/package-info.java +++ b/src/client/java/com/minelittlepony/client/ducks/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.ducks; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/gui/GuiPonySettings.java b/src/client/java/com/minelittlepony/client/gui/GuiPonySettings.java index 676500d6..2d3ff3c3 100644 --- a/src/client/java/com/minelittlepony/client/gui/GuiPonySettings.java +++ b/src/client/java/com/minelittlepony/client/gui/GuiPonySettings.java @@ -1,7 +1,7 @@ package com.minelittlepony.client.gui; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.resources.I18n; +import net.minecraft.client.gui.Screen; +import net.minecraft.client.resource.language.I18n; import com.minelittlepony.MineLittlePony; import com.minelittlepony.client.render.entities.MobRenderers; @@ -50,16 +50,16 @@ public class GuiPonySettings implements IGuiGuest { config.setPonyLevel(level); 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 Slider(LEFT, row += 15, 0.1F, 3, config.getGlobalScaleFactor()) .onChange(v -> { config.setGlobalScaleFactor(v); 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; @@ -86,26 +86,26 @@ public class GuiPonySettings implements IGuiGuest { public String describeCurrentScale(float value) { if (value >= 3) { - return I18n.format("minelp.debug.scale.meg"); + return I18n.translate("minelp.debug.scale.meg"); } if (value == 2) { - return I18n.format("minelp.debug.scale.max"); + return I18n.translate("minelp.debug.scale.max"); } if (value == 1) { - return I18n.format("minelp.debug.scale.mid"); + return I18n.translate("minelp.debug.scale.mid"); } if (value == 0.9F) { - return I18n.format("minelp.debug.scale.sa"); + return I18n.translate("minelp.debug.scale.sa"); } if (value <= 0.1F) { - return I18n.format("minelp.debug.scale.min"); + return I18n.translate("minelp.debug.scale.min"); } return String.format("%f", value); } @Override public boolean render(GuiHost host, int mouseX, int mouseY, float partialTicks) { - host.drawDefaultBackground(); + host.renderBackground(); return true; } diff --git a/src/client/java/com/minelittlepony/client/gui/hdskins/EntityPonyModel.java b/src/client/java/com/minelittlepony/client/gui/hdskins/EntityPonyModel.java index 1ee047ef..2f476513 100644 --- a/src/client/java/com/minelittlepony/client/gui/hdskins/EntityPonyModel.java +++ b/src/client/java/com/minelittlepony/client/gui/hdskins/EntityPonyModel.java @@ -4,15 +4,15 @@ import com.minelittlepony.hdskins.gui.EntityPlayerModel; import com.mojang.authlib.GameProfile; 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. */ public class EntityPonyModel extends EntityPlayerModel { - public static final ResourceLocation NO_SKIN_PONY = new ResourceLocation("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_PONY = new Identifier("minelittlepony", "textures/mob/noskin.png"); + public static final Identifier NO_SKIN_SEAPONY = new Identifier("minelittlepony", "textures/mob/noskin_seapony.png"); public boolean wet = false; @@ -21,7 +21,7 @@ public class EntityPonyModel extends EntityPlayerModel { } @Override - public ResourceLocation getBlankSkin(Type type) { + public Identifier getBlankSkin(Type type) { if (type == Type.SKIN) { return wet ? NO_SKIN_SEAPONY : NO_SKIN_PONY; } diff --git a/src/client/java/com/minelittlepony/client/gui/hdskins/GuiSkinsMineLP.java b/src/client/java/com/minelittlepony/client/gui/hdskins/GuiSkinsMineLP.java index fa7dcd65..84a34e10 100644 --- a/src/client/java/com/minelittlepony/client/gui/hdskins/GuiSkinsMineLP.java +++ b/src/client/java/com/minelittlepony/client/gui/hdskins/GuiSkinsMineLP.java @@ -11,10 +11,10 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; -import net.minecraft.init.Items; -import net.minecraft.init.SoundEvents; +import net.minecraft.item.Items; +import net.minecraft.sound.SoundEvents; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import java.util.List; @@ -43,8 +43,8 @@ public class GuiSkinsMineLP extends GuiSkins { } @Override - public void initGui() { - super.initGui(); + public void init() { + super.init(); addButton(new IconicToggle(width - 25, 142)) .setStyles( @@ -56,10 +56,10 @@ public class GuiSkinsMineLP extends GuiSkins { } @Override - protected ResourceLocation getBackground() { + protected Identifier getBackground() { int i = (int)Math.floor(Math.random() * panoramas.length); - return new ResourceLocation(panoramas[i]); + return new Identifier(panoramas[i]); } protected int setWet(int wet) { @@ -85,7 +85,7 @@ public class GuiSkinsMineLP extends GuiSkins { } @Override - public void onSetRemoteSkin(Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) { + public void onSetRemoteSkin(Type type, Identifier location, MinecraftProfileTexture profileTexture) { super.onSetRemoteSkin(type, location, profileTexture); MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin"); diff --git a/src/client/java/com/minelittlepony/client/gui/hdskins/RenderPonyModel.java b/src/client/java/com/minelittlepony/client/gui/hdskins/RenderPonyModel.java index 7b496f57..8d4277e6 100644 --- a/src/client/java/com/minelittlepony/client/gui/hdskins/RenderPonyModel.java +++ b/src/client/java/com/minelittlepony/client/gui/hdskins/RenderPonyModel.java @@ -1,10 +1,11 @@ package com.minelittlepony.client.gui.hdskins; 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.races.PlayerModels; import com.minelittlepony.client.pony.Pony; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.client.render.RenderPony; import com.minelittlepony.client.render.layer.LayerGear; 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.meta.Race; 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.renderer.entity.model.ModelElytra; -import net.minecraft.client.renderer.entity.model.ModelPlayer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.feature.FeatureRenderer; +import net.minecraft.client.render.entity.model.ElytraEntityModel; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.util.Identifier; /** * Renderer used for the dummy pony model when selecting a skin. */ -public class RenderPonyModel extends RenderPlayerModel implements IRenderPony { +public class RenderPonyModel extends RenderPlayerModel> implements IPonyRender> { boolean renderingAsHuman = false; - protected final RenderPony renderPony = new RenderPony<>(this); + protected final RenderPony> renderPony = new RenderPony<>(this); - public RenderPonyModel(RenderManager manager) { + public RenderPonyModel(EntityRenderDispatcher manager) { super(manager); - addLayer(new LayerGear<>(this)); + addFeature(new LayerGear<>(this)); } - private ModelWrapper playerModel; + private ModelWrapper> playerModel; @Override - public ModelWrapper getModelWrapper() { + public ModelWrapper> getModelWrapper() { return playerModel; } @Override public IPony getEntityPony(EntityPonyModel entity) { - return MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity)); + return MineLittlePony.getInstance().getManager().getPony(getTexture(entity)); } @Override - protected void preRenderCallback(EntityPonyModel entity, float ticks) { + protected void scale(EntityPonyModel entity, float ticks) { if (renderingAsHuman) { - super.preRenderCallback(entity, ticks); + super.scale(entity, ticks); } else { 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 - public ModelPlayer getEntityModel(EntityPonyModel playermodel) { + public ClientPonyModel getEntityModel(EntityPonyModel playermodel) { renderingAsHuman = true; - ResourceLocation loc = getEntityTexture(playermodel); + Identifier loc = getTexture(playermodel); if (loc == null || Pony.getBufferedImage(loc) == null) { return super.getEntityModel(playermodel); } @@ -91,9 +91,9 @@ public class RenderPonyModel extends RenderPlayerModel implemen } @Override - protected LayerRenderer getElytraLayer() { - return new LayerPonyElytra(this) { - private final ModelElytra modelElytra = new ModelElytra(); + protected FeatureRenderer> getElytraLayer() { + return new LayerPonyElytra>(this) { + private final ElytraEntityModel modelElytra = new ElytraEntityModel<>(); @Override protected void preRenderCallback() { @@ -103,24 +103,24 @@ public class RenderPonyModel extends RenderPlayerModel implemen } @Override - protected ModelBase getElytraModel() { + protected EntityModel getElytraModel() { return renderingAsHuman ? modelElytra : super.getElytraModel(); } @Override - protected ResourceLocation getElytraTexture(EntityPonyModel entity) { + protected Identifier getElytraTexture(EntityPonyModel entity) { return entity.getLocal(Type.ELYTRA).getTexture(); } }; } @Override - public RenderPony getInternalRenderer() { + public RenderPony> getInternalRenderer() { return renderPony; } @Override - public ResourceLocation getTexture(EntityPonyModel entity) { - return getEntityTexture(entity); + public Identifier findTexture(EntityPonyModel entity) { + return getTexture(entity); } } diff --git a/src/client/java/com/minelittlepony/client/gui/hdskins/package-info.java b/src/client/java/com/minelittlepony/client/gui/hdskins/package-info.java index 6d929f54..bf94b801 100644 --- a/src/client/java/com/minelittlepony/client/gui/hdskins/package-info.java +++ b/src/client/java/com/minelittlepony/client/gui/hdskins/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.gui.hdskins; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/gui/package-info.java b/src/client/java/com/minelittlepony/client/gui/package-info.java index b5c83539..13eee0ea 100644 --- a/src/client/java/com/minelittlepony/client/gui/package-info.java +++ b/src/client/java/com/minelittlepony/client/gui/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.gui; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/mixin/IResizeable.java b/src/client/java/com/minelittlepony/client/mixin/IResizeable.java new file mode 100644 index 00000000..f0c89469 --- /dev/null +++ b/src/client/java/com/minelittlepony/client/mixin/IResizeable.java @@ -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); +} diff --git a/src/client/java/com/minelittlepony/client/mixin/MixinDefaultPlayerSkin.java b/src/client/java/com/minelittlepony/client/mixin/MixinDefaultPlayerSkin.java index 1581a369..0767cf21 100644 --- a/src/client/java/com/minelittlepony/client/mixin/MixinDefaultPlayerSkin.java +++ b/src/client/java/com/minelittlepony/client/mixin/MixinDefaultPlayerSkin.java @@ -5,8 +5,8 @@ import com.minelittlepony.client.model.races.PlayerModels; import com.minelittlepony.pony.IPonyManager; import com.minelittlepony.settings.PonyLevel; -import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.util.DefaultSkinHelper; +import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -14,24 +14,30 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.UUID; -@Mixin(DefaultPlayerSkin.class) +@Mixin(DefaultSkinHelper.class) public abstract class MixinDefaultPlayerSkin { - @Inject(method = "getDefaultSkinLegacy", at = @At("HEAD"), cancellable = true) - private static void legacySkin(CallbackInfoReturnable cir) { + @Inject(method = "getTexture", + at = @At("HEAD"), + cancellable = true) + private static void legacySkin(CallbackInfoReturnable cir) { if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) { cir.setReturnValue(IPonyManager.STEVE); } } - @Inject(method = "getDefaultSkin", at = @At("HEAD"), cancellable = true) - private static void defaultSkin(UUID uuid, CallbackInfoReturnable cir) { + @Inject(method = "getTexture", + at = @At("HEAD"), + cancellable = true) + private static void defaultSkin(UUID uuid, CallbackInfoReturnable cir) { if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) { 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 cir) { if (MineLittlePony.getInstance().getConfig().getPonyLevel() == PonyLevel.PONIES) { diff --git a/src/client/java/com/minelittlepony/client/mixin/MixinFirstPersonRenderer.java b/src/client/java/com/minelittlepony/client/mixin/MixinFirstPersonRenderer.java index a51df940..3bb34940 100644 --- a/src/client/java/com/minelittlepony/client/mixin/MixinFirstPersonRenderer.java +++ b/src/client/java/com/minelittlepony/client/mixin/MixinFirstPersonRenderer.java @@ -6,27 +6,27 @@ import org.spongepowered.asm.mixin.injection.Redirect; import com.minelittlepony.client.PonyRenderManager; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.FirstPersonRenderer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.FirstPersonRenderer; +import net.minecraft.client.render.item.ItemRenderer; +import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; @SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it. @Mixin(FirstPersonRenderer.class) public class MixinFirstPersonRenderer { - @Redirect(method = "renderItemInFirstPerson(" + @Redirect(method = "renderFirstPersonItem(" + "Lnet/minecraft/client/entity/AbstractClientPlayer;FF" - + "Lnet/minecraft/util/EnumHand;F" + + "Lnet/minecraft/util/Hand;F" + "Lnet/minecraft/item/ItemStack;F)V", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/renderer/FirstPersonRenderer;renderItemSide(" - + "Lnet/minecraft/entity/EntityLivingBase;" + target = "Lnet/minecraft/client/render/FirstPersonRenderer;renderItemFromSide(" + + "Lnet/minecraft/entity/LivingEntity;" + "Lnet/minecraft/item/ItemStack;" - + "Lnet/minecraft/client/renderer/model/ItemCameraTransforms$TransformType;Z)V")) - private void redirectRenderItemSide(ItemRenderer self, EntityLivingBase entity, ItemStack stack, TransformType transform, boolean left) { - PonyRenderManager.getInstance().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayer)entity, stack, transform, left); + + "Lnet/minecraft/client/render/model/json/ModelTransformation$Type;Z)V")) + private void redirectRenderItemSide(ItemRenderer self, LivingEntity entity, ItemStack stack, ModelTransformation.Type transform, boolean left) { + PonyRenderManager.getInstance().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayerEntity)entity, stack, transform, left); } } diff --git a/src/client/java/com/minelittlepony/client/mixin/MixinGlStateManager.java b/src/client/java/com/minelittlepony/client/mixin/MixinGlStateManager.java index 2e4d27de..0599aab0 100644 --- a/src/client/java/com/minelittlepony/client/mixin/MixinGlStateManager.java +++ b/src/client/java/com/minelittlepony/client/mixin/MixinGlStateManager.java @@ -8,14 +8,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.minelittlepony.client.render.LevitatingItemRenderer; import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer; -import net.minecraft.client.renderer.GlStateManager; +import com.mojang.blaze3d.platform.GlStateManager; @Mixin(GlStateManager.class) public abstract class MixinGlStateManager { - @Inject(method = "enableBlendProfile(Lnet/minecraft/client/renderer/GlStateManager$Profile;)V", at = @At("HEAD"), cancellable = true) - private static void enableBlendProfile(GlStateManager.Profile profile, CallbackInfo info) { - if (profile == GlStateManager.Profile.PLAYER_SKIN && PonySkullRenderer.ponyInstance.usesTransparency()) { + @Inject(method = "setProfile(" + + "Lcom/mojang/blaze3d/platform/GlStateManager$RenderMode;)V", + 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(); info.cancel(); } diff --git a/src/client/java/com/minelittlepony/client/mixin/MixinItemRenderer.java b/src/client/java/com/minelittlepony/client/mixin/MixinItemRenderer.java index 342afcc8..a2c62749 100644 --- a/src/client/java/com/minelittlepony/client/mixin/MixinItemRenderer.java +++ b/src/client/java/com/minelittlepony/client/mixin/MixinItemRenderer.java @@ -3,10 +3,10 @@ package com.minelittlepony.client.mixin; import com.minelittlepony.client.ducks.IRenderItem; import com.minelittlepony.client.render.LevitatingItemRenderer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.resources.IResourceManagerReloadListener; +import net.minecraft.client.render.item.ItemRenderer; +import net.minecraft.client.render.model.BakedModel; import net.minecraft.item.ItemStack; +import net.minecraft.resource.SynchronousResourceReloadListener; import org.spongepowered.asm.mixin.Mixin; 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.callback.CallbackInfo; -@SuppressWarnings("deprecation") // IResourceManagerReloadListener is deprecated by forge but it's part of the signature. We can't remove it. @Mixin(ItemRenderer.class) -public abstract class MixinItemRenderer implements IResourceManagerReloadListener, IRenderItem { +public abstract class MixinItemRenderer implements SynchronousResourceReloadListener, IRenderItem { private boolean transparency; @@ -25,23 +24,34 @@ public abstract class MixinItemRenderer implements IResourceManagerReloadListene this.transparency = transparency; } - @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/renderer/block/model/IBakedModel;)V", at = @At("HEAD")) - private void onRenderItem(ItemStack stack, IBakedModel model, CallbackInfo info) { + @Inject(method = "renderItemAndGlow(" + + "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) { 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", - 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) private int modifyItemRenderTint(int color) { return transparency ? -1 : color; } - @Inject(method = "renderEffect(Lnet/minecraft/client/renderer/block/model/IBakedModel;)V", at = @At("HEAD"), cancellable = true) - private void renderEffect(IBakedModel model, CallbackInfo info) { + @Inject(method = "renderEffect(" + + "Lnet/minecraft/client/render/model/BakedModel;)V", + at = @At("HEAD"), + cancellable = true) + private void renderEffect(BakedModel model, CallbackInfo info) { if (transparency) { info.cancel(); } diff --git a/src/client/java/com/minelittlepony/client/mixin/MixinRenderManager.java b/src/client/java/com/minelittlepony/client/mixin/MixinRenderManager.java index b5e2e198..34caf1cf 100644 --- a/src/client/java/com/minelittlepony/client/mixin/MixinRenderManager.java +++ b/src/client/java/com/minelittlepony/client/mixin/MixinRenderManager.java @@ -5,12 +5,11 @@ import java.util.Map; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.PlayerEntityRenderer; -@Mixin(RenderManager.class) +@Mixin(EntityRenderDispatcher.class) public interface MixinRenderManager { - // There is a method to get it, but it's made immutable my Forge. - @Accessor("skinMap") - Map getMutableSkinMap(); + @Accessor("modelRenderers") + Map getMutableSkinMap(); } diff --git a/src/client/java/com/minelittlepony/client/mixin/MixinThreadDownloadImageData.java b/src/client/java/com/minelittlepony/client/mixin/MixinThreadDownloadImageData.java index a28827b5..2f9716c5 100644 --- a/src/client/java/com/minelittlepony/client/mixin/MixinThreadDownloadImageData.java +++ b/src/client/java/com/minelittlepony/client/mixin/MixinThreadDownloadImageData.java @@ -1,8 +1,8 @@ package com.minelittlepony.client.mixin; -import net.minecraft.client.renderer.texture.ThreadDownloadImageData; -import net.minecraft.client.renderer.texture.NativeImage; -import net.minecraft.client.renderer.texture.SimpleTexture; +import net.minecraft.client.texture.NativeImage; +import net.minecraft.client.texture.PlayerSkinTexture; +import net.minecraft.client.texture.ResourceTexture; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -10,19 +10,20 @@ import org.spongepowered.asm.mixin.injection.Inject; import com.minelittlepony.client.ducks.IBufferedTexture; -@Mixin(ThreadDownloadImageData.class) -public abstract class MixinThreadDownloadImageData extends SimpleTexture implements IBufferedTexture { +@Mixin(PlayerSkinTexture.class) +public abstract class MixinThreadDownloadImageData extends ResourceTexture implements IBufferedTexture { MixinThreadDownloadImageData() {super(null);} private NativeImage cachedImage; - + @Override public NativeImage getBufferedImage() { 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")) private void onSetImage(NativeImage nativeImageIn) { cachedImage = nativeImageIn; diff --git a/src/client/java/com/minelittlepony/client/mixin/package-info.java b/src/client/java/com/minelittlepony/client/mixin/package-info.java index 90e22dda..7aff3b4b 100644 --- a/src/client/java/com/minelittlepony/client/mixin/package-info.java +++ b/src/client/java/com/minelittlepony/client/mixin/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.mixin; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/model/AbstractPonyModel.java b/src/client/java/com/minelittlepony/client/model/AbstractPonyModel.java index 5f294cfa..f754f8db 100644 --- a/src/client/java/com/minelittlepony/client/model/AbstractPonyModel.java +++ b/src/client/java/com/minelittlepony/client/model/AbstractPonyModel.java @@ -11,31 +11,28 @@ import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.IPart; -import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPonyData; import com.minelittlepony.pony.meta.Size; import com.minelittlepony.util.math.MathUtil; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.entity.model.ModelPlayer; -import net.minecraft.client.renderer.entity.model.ModelRenderer; -import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.model.Cuboid; +import net.minecraft.client.render.entity.model.BipedEntityModel; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.EnumHandSide; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.AbsoluteHand; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; -import java.util.Random; 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. */ -public abstract class AbstractPonyModel extends ModelPlayer implements IClientModel, PonyModelConstants { +public abstract class AbstractPonyModel extends ClientPonyModel { public boolean isSleeping; public boolean isFlying; @@ -76,14 +73,15 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo @Override 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. */ - private void checkRainboom(Entity entity, float swing) { - double zMotion = Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ); + private void checkRainboom(T entity, float swing) { + Vec3d motion = entity.getVelocity(); + double zMotion = Math.sqrt(motion.x * motion.x + motion.z * motion.z); rainboom = (isFlying() && canFly()) || isElytraFlying(); rainboom &= zMotion > 0.4F; @@ -91,17 +89,17 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo motionLerp = MathUtil.clampLimit(zMotion * 30, 1); } - public void updateLivingState(EntityLivingBase entity, IPony pony) { - isChild = entity.isChild(); - isSneak = entity.isSneaking(); + public void updateLivingState(T entity, IPony pony) { + isChild = entity.isBaby(); + isSneaking = entity.isSneaking(); isCrouching = pony.isCrouching(entity); - isSleeping = entity.isPlayerSleeping(); + isSleeping = entity.isSleeping(); isFlying = pony.isFlying(entity); - isElytraFlying = entity.isElytraFlying(); + isElytraFlying = entity.isFallFlying(); isSwimming = pony.isSwimming(entity); headGear = pony.isWearingHeadgear(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. */ @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); - 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; headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch))); @@ -144,8 +142,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo } else { adjustBody(BODY_ROT_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK); - bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; - bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; + rightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; + leftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; swingArms(ticks); setHead(0, 0, 0); } @@ -162,11 +160,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo @Override public float getWobbleAmount() { - if (swingProgress <= 0) { + if (getSwingAmount() <= 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); setHead(0, 6, -2); - bipedRightArm.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ; - bipedLeftArm.rotateAngleX -= LEG_ROT_X_SNEAK_ADJ; + rightArm.pitch -= LEG_ROT_X_SNEAK_ADJ; + leftArm.pitch -= LEG_ROT_X_SNEAK_ADJ; - bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; - bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; + leftLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; + rightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK; } protected void ponySleep() { - bipedRightArm.rotateAngleX = ROTATE_270; - bipedLeftArm.rotateAngleX = ROTATE_270; + rightArm.pitch = ROTATE_270; + leftArm.pitch = ROTATE_270; - bipedRightLeg.rotateAngleX = ROTATE_90; - bipedLeftLeg.rotateAngleX = ROTATE_90; + rightLeg.pitch = 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(bipedLeftArm, 0, 2, 6); - AbstractRenderer.shiftRotationPoint(bipedRightLeg, 0, 2, -8); - AbstractRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8); + AbstractRenderer.shiftRotationPoint(rightArm, 0, 2, 6); + AbstractRenderer.shiftRotationPoint(leftArm, 0, 2, 6); + AbstractRenderer.shiftRotationPoint(rightLeg, 0, 2, -8); + AbstractRenderer.shiftRotationPoint(leftLeg, 0, 2, -8); } protected void ponyRide() { @@ -209,37 +207,37 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo setHead(0, 0, 0); } - bipedLeftLeg.rotationPointZ = 15; - bipedLeftLeg.rotationPointY = 9; - bipedLeftLeg.rotateAngleX = -PI / 4; - bipedLeftLeg.rotateAngleY = -PI / 5; + leftLeg.rotationPointZ = 15; + leftLeg.rotationPointY = 9; + leftLeg.pitch = -PI / 4; + leftLeg.yaw = -PI / 5; - bipedRightLeg.rotationPointZ = 15; - bipedRightLeg.rotationPointY = 9; - bipedRightLeg.rotateAngleX = -PI / 4; - bipedRightLeg.rotateAngleY = PI / 5; + rightLeg.rotationPointZ = 15; + rightLeg.rotationPointY = 9; + rightLeg.pitch = -PI / 4; + rightLeg.yaw = PI / 5; - bipedLeftArm.rotateAngleZ = -PI * 0.06f; - bipedRightArm.rotateAngleZ = PI * 0.06f; + leftArm.roll = -PI * 0.06f; + rightArm.roll = PI * 0.06f; if (isRidingInteractive) { - bipedLeftLeg.rotateAngleY = PI / 15; - bipedLeftLeg.rotateAngleX = PI / 9; + leftLeg.yaw = PI / 15; + leftLeg.pitch = PI / 9; - bipedLeftLeg.rotationPointZ = 10; - bipedLeftLeg.rotationPointY = 7; + leftLeg.rotationPointZ = 10; + leftLeg.rotationPointY = 7; - bipedRightLeg.rotateAngleY = -PI / 15; - bipedRightLeg.rotateAngleX = PI / 9; + rightLeg.yaw = -PI / 15; + rightLeg.pitch = PI / 9; - bipedRightLeg.rotationPointZ = 10; - bipedRightLeg.rotationPointY = 7; + rightLeg.rotationPointZ = 10; + rightLeg.rotationPointY = 7; - bipedLeftArm.rotateAngleX = PI / 6; - bipedRightArm.rotateAngleX = PI / 6; + leftArm.pitch = PI / 6; + rightArm.pitch = PI / 6; - bipedLeftArm.rotateAngleZ *= 2; - bipedRightArm.rotateAngleZ *= 2; + leftArm.roll *= 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) { tail.setRotationAndAngles(isSwimming() || rainboom, interpolatorId, move, swing, bodySwing * 5, ticks); - upperTorso.rotateAngleY = bodySwing; - bipedBody.rotateAngleY = bodySwing; - neck.rotateAngleY = bodySwing; + upperTorso.yaw = bodySwing; + body.yaw = bodySwing; + neck.yaw = bodySwing; } private void animateWears() { - copyModelAngles(bipedLeftArm, bipedLeftArmwear); - copyModelAngles(bipedRightArm, bipedRightArmwear); - copyModelAngles(bipedLeftLeg, bipedLeftLegwear); - copyModelAngles(bipedRightLeg, bipedRightLegwear); - copyModelAngles(bipedBody, bipedBodyWear); + leftArmOverlay.copyRotation(leftArm); + rightArmOverlay.copyRotation(rightArm); + leftLegOverlay.copyRotation(leftLeg); + rightLegOverlay.copyRotation(rightLeg); + bodyOverlay.copyRotation(body); } @Override - public ModelRenderer getHead() { - return bipedHead; + public Cuboid getHead() { + return head; } @Override @@ -286,8 +284,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo * Sets the head rotation point. */ protected void setHead(float posX, float posY, float posZ) { - bipedHead.setRotationPoint(posX, posY, posZ); - bipedHeadwear.setRotationPoint(posX, posY, posZ); + head.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 */ protected void updateHeadRotation(float x, float y) { - bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = y; - bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = x; + headwear.yaw = head.yaw = y; + 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} * */ - protected void rotateLegs(float move, float swing, float ticks, Entity entity) { + protected void rotateLegs(float move, float swing, float ticks, T entity) { if (isSwimming()) { rotateLegsSwimming(move, swing, ticks, entity); } else if (isGoingFast()) { @@ -317,29 +315,29 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo rotateLegsOnGround(move, swing, ticks, entity); } - float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; - float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; + float sin = MathHelper.sin(body.yaw) * 5; + float cos = MathHelper.cos(body.yaw) * 5; float spread = getLegSpread(); - bipedRightArm.rotationPointZ = spread + sin; - bipedLeftArm.rotationPointZ = spread - sin; + rightArm.rotationPointZ = spread + sin; + leftArm.rotationPointZ = spread - sin; 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; - bipedRightLeg.rotationPointX = -legRPX; + rightArm.rotationPointX = -legRPX; + rightLeg.rotationPointX = -legRPX; - bipedLeftArm.rotationPointX = legRPX; - bipedLeftLeg.rotationPointX = legRPX; + leftArm.rotationPointX = legRPX; + leftLeg.rotationPointX = legRPX; - bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; - bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; + rightArm.yaw += body.yaw; + leftArm.yaw += body.yaw; - bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8; - bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; + rightArm.rotationPointY = leftArm.rotationPointY = 8; + 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. * */ - 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 left = (ROTATE_90 + MathHelper.sin((move / 3) + 2 * PI) / 2) * (float)motionLerp; float right = (ROTATE_90 + MathHelper.sin(move / 3) / 2) * (float)motionLerp; - bipedLeftArm.rotateAngleX = -left; - bipedLeftArm.rotateAngleY = -left/2; - bipedLeftArm.rotateAngleZ = left/2; + leftArm.pitch = -left; + leftArm.yaw = -left/2; + leftArm.roll = left/2; - bipedRightArm.rotateAngleX = -right; - bipedRightArm.rotateAngleY = right/2; - bipedRightArm.rotateAngleZ = -right/2; + rightArm.pitch = -right; + rightArm.yaw = right/2; + rightArm.roll = -right/2; - bipedLeftLeg.rotateAngleX = legLeft; - bipedRightLeg.rotateAngleX = right; + leftLeg.pitch = legLeft; + rightLeg.pitch = right; - bipedLeftLeg.rotateAngleY = 0; - bipedRightLeg.rotateAngleY = 0; + leftLeg.yaw = 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 legX = rainboom ? ROTATE_90 : MathHelper.sin(swing / 2); - bipedLeftArm.rotateAngleX = armX; - bipedRightArm.rotateAngleX = armX; + leftArm.pitch = armX; + rightArm.pitch = armX; - bipedLeftLeg.rotateAngleX = legX; - bipedRightLeg.rotateAngleX = legX; + leftLeg.pitch = legX; + rightLeg.pitch = legX; - bipedLeftArm.rotateAngleY = -0.2F; - bipedLeftLeg.rotateAngleY = 0.2F; + leftArm.yaw = -0.2F; + leftLeg.yaw = 0.2F; - bipedRightArm.rotateAngleY = 0.2F; - bipedRightLeg.rotateAngleY = -0.2F; + rightArm.yaw = 0.2F; + rightLeg.yaw = -0.2F; - bipedRightArm.rotateAngleZ = 0; - bipedLeftArm.rotateAngleZ = 0; + rightArm.roll = 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. * */ - 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 baseRotation = move * 0.6662F; // magic number ahoy float scale = swing / 4; - bipedLeftArm.rotateAngleX = MathHelper.cos(baseRotation + angle) * scale; - bipedRightArm.rotateAngleX = MathHelper.cos(baseRotation + PI + angle / 2) * scale; + leftArm.pitch = MathHelper.cos(baseRotation + angle) * scale; + rightArm.pitch = MathHelper.cos(baseRotation + PI + angle / 2) * scale; - bipedLeftLeg.rotateAngleX = MathHelper.cos(baseRotation + PI - (angle * 0.4f)) * scale; - bipedRightLeg.rotateAngleX = MathHelper.cos(baseRotation + angle / 5) * scale; + leftLeg.pitch = MathHelper.cos(baseRotation + PI - (angle * 0.4f)) * scale; + rightLeg.pitch = MathHelper.cos(baseRotation + angle / 5) * scale; - bipedLeftArm.rotateAngleY = 0; - bipedRightArm.rotateAngleY = 0; + leftArm.yaw = 0; + rightArm.yaw = 0; - bipedLeftLeg.rotateAngleY = 0; - bipedRightLeg.rotateAngleY = 0; + leftLeg.yaw = 0; + rightLeg.yaw = 0; - bipedRightArm.rotateAngleZ = 0; - bipedLeftArm.rotateAngleZ = 0; + rightArm.roll = 0; + leftArm.roll = 0; } protected float getLegOutset() { @@ -457,19 +455,19 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo protected void holdItem(float swing) { boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; - alignArmForAction(bipedLeftArm, leftArmPose, rightArmPose, both, swing, 1); - alignArmForAction(bipedRightArm, rightArmPose, leftArmPose, both, swing, -1); + alignArmForAction(leftArm, leftArmPose, rightArmPose, both, swing, 1); + alignArmForAction(rightArm, rightArmPose, leftArmPose, both, swing, -1); } @Override - public ModelRenderer getBodyPart(BodyPart part) { + public Cuboid getBodyPart(BodyPart part) { switch (part) { default: - case HEAD: return bipedHead; + case HEAD: return head; case NECK: return neck; case TAIL: 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 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) { case ITEM: float swag = 1; @@ -489,19 +487,19 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo swag -= (float)Math.pow(swing, 2); } float mult = 1 - swag/2; - arm.rotateAngleX = arm.rotateAngleX * mult - (PI / 10) * swag; - arm.rotateAngleZ = -reflect * (PI / 15); + arm.pitch = arm.pitch * mult - (PI / 10) * swag; + arm.roll = -reflect * (PI / 15); if (isCrouching()) { arm.rotationPointX -= reflect * 2; } case EMPTY: - arm.rotateAngleY = 0; + arm.yaw = 0; break; case BLOCK: - arm.rotateAngleX = (arm.rotateAngleX / 2 - 0.9424779F) - 0.3F; - arm.rotateAngleY = reflect * PI / 9; + arm.pitch = (arm.pitch / 2 - 0.9424779F) - 0.3F; + arm.yaw = reflect * PI / 9; if (complement == pose) { - arm.rotateAngleY -= reflect * PI / 18; + arm.yaw -= reflect * PI / 18; } arm.rotationPointX += reflect; arm.rotationPointZ += 3; @@ -516,12 +514,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo } } - protected void aimBow(ModelRenderer arm, float ticks) { - arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX + (MathHelper.sin(ticks * 0.067F) * 0.05F); - arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; - arm.rotateAngleZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; + protected void aimBow(Cuboid arm, float ticks) { + arm.pitch = ROTATE_270 + head.pitch + (MathHelper.sin(ticks * 0.067F) * 0.05F); + arm.yaw = head.yaw - 0.06F; + arm.roll = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; - if (isSneak) { + if (isSneaking) { arm.rotationPointY += 4; } } @@ -532,11 +530,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo * * @param entity The entity we are being called for. */ - protected void swingItem(Entity entity) { - if (swingProgress > 0 && !isSleeping()) { - EnumHandSide mainSide = getMainHand(entity); + protected void swingItem(T entity) { + if (getSwingAmount() > 0 && !isSleeping()) { + 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 */ - protected void swingArm(ModelRenderer arm) { - float swing = 1 - (float)Math.pow(1 - swingProgress, 3); + protected void swingArm(Cuboid arm) { + float swing = 1 - (float)Math.pow(1 - getSwingAmount(), 3); 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.rotateAngleY += bipedBody.rotateAngleY * 2; - arm.rotateAngleZ = -deltaZ * 0.4F; + arm.pitch -= deltaAim + deltaX * 1.2F; + arm.yaw += body.yaw * 2; + 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; if (rightArmPose != ArmPose.EMPTY) { - bipedRightArm.rotateAngleZ += cos; - bipedRightArm.rotateAngleX += sin; + rightArm.roll += cos; + rightArm.pitch += sin; } if (leftArmPose != ArmPose.EMPTY) { - bipedLeftArm.rotateAngleZ += cos; - bipedLeftArm.rotateAngleX += sin; + leftArm.roll += cos; + leftArm.pitch += sin; } } @@ -588,11 +586,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo } protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) { - bipedBody.rotateAngleX = rotateAngleX; - bipedBody.rotationPointY = rotationPointY; - bipedBody.rotationPointZ = rotationPointZ; + body.pitch = rotateAngleX; + body.rotationPointY = rotationPointY; + body.rotationPointZ = rotationPointZ; - upperTorso.rotateAngleX = rotateAngleX; + upperTorso.pitch = rotateAngleX; upperTorso.rotationPointY = rotationPointY; upperTorso.rotationPointZ = rotationPointZ; } @@ -603,7 +601,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo @Override public void init(float yOffset, float stretch) { - boxList.clear(); + cuboidList.clear(); initHead(yOffset, stretch); initBody(yOffset, stretch); @@ -612,13 +610,13 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo } 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) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) .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) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) .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) { 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) .box(-4, 4, -2, 8, 8, 4, stretch); - bipedBodyWear.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F); - bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); + bodyOverlay.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F); + bodyOverlay.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); upperTorso = new PlaneRenderer(this, 24, 0); 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() { - bipedLeftArm = new ModelRenderer(this, 32, 48); - bipedRightArm = new ModelRenderer(this, 40, 16); + leftArm = new Cuboid(this, 32, 48); + rightArm = new Cuboid(this, 40, 16); - bipedLeftLeg = new ModelRenderer(this, 16, 48); - bipedRightLeg = new ModelRenderer(this, 0, 16); + leftLeg = new Cuboid(this, 16, 48); + rightLeg = new Cuboid(this, 0, 16); } protected void preInitLegwear() { - bipedLeftArmwear = new ModelRenderer(this, 48, 48); - bipedRightArmwear = new ModelRenderer(this, 40, 32); + leftArmOverlay.boxes.clear(); + cuboidList.add(leftArmOverlay); - bipedLeftLegwear = new ModelRenderer(this, 0, 48); - bipedRightLegwear = new ModelRenderer(this, 0, 32); + rightArmOverlay.boxes.clear(); + 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) { @@ -714,29 +721,29 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo float armY = THIRDP_ARM_CENTRE_Y; float armZ = BODY_CENTRE_Z / 2 - 1 - armDepth; - bipedLeftArm .addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch); - bipedRightArm.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch); + leftArm .addBox(armX, 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); - bipedRightLeg.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch); + leftLeg .addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch); + rightLeg.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch); - bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); - bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); + leftArm .setRotationPoint( rarmX, yOffset + rarmY, 0); + rightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0); - bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0); - bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0); + leftLeg .setRotationPoint( rarmX, yOffset, 0); + rightLeg.setRotationPoint(-rarmX, yOffset, 0); - bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); - bipedLeftArmwear.setRotationPoint(rarmX, yOffset + rarmY, 0); + leftArmOverlay.addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); + leftArmOverlay.setRotationPoint(rarmX, yOffset + rarmY, 0); - bipedRightArmwear.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); - bipedRightArmwear.setRotationPoint(-rarmX, yOffset + rarmY, 0); + rightArmOverlay.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); + rightArmOverlay.setRotationPoint(-rarmX, yOffset + rarmY, 0); - bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); - bipedRightLegwear.setRotationPoint(rarmX, yOffset, 0); + leftArmOverlay.addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); + rightLegOverlay.setRotationPoint(rarmX, yOffset, 0); - bipedRightLegwear.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); - bipedRightLegwear.setRotationPoint(-rarmX, yOffset, 0); + rightLegOverlay.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch + 0.25f); + rightLegOverlay.setRotationPoint(-rarmX, yOffset, 0); } protected int getArmWidth() { @@ -759,8 +766,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo return 8; } - public ArmPose getArmPoseForSide(EnumHandSide side) { - return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose; + public ArmPose getArmPoseForSide(AbsoluteHand side) { + return side == AbsoluteHand.RIGHT ? rightArmPose : leftArmPose; } @Override @@ -825,7 +832,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo @Override public float getSwingAmount() { - return swingProgress; + return handSwingProgress; } @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}. */ @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(); transform(BodyPart.HEAD); @@ -892,14 +899,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo * 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) { - bipedHead.render(scale); - bipedHeadwear.render(scale); - bipedHead.postRender(scale); + protected void renderHead(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + head.render(scale); + headwear.render(scale); + head.applyTransform(scale); } protected void renderNeck(float scale) { - GlStateManager.scalef(0.9F, 0.9F, 0.9F); + scalef(0.9F, 0.9F, 0.9F); neck.render(scale); } @@ -910,29 +917,29 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo * 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) { - bipedBody.render(scale); + protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + body.render(scale); if (textureHeight == 64) { - bipedBodyWear.render(scale); + bodyOverlay.render(scale); } upperTorso.render(scale); - bipedBody.postRender(scale); - tail.renderPart(scale, entity.getUniqueID()); + body.applyTransform(scale); + tail.renderPart(scale, entity.getUuid()); } protected void renderLegs(float scale) { - if (!isSneak) bipedBody.postRender(scale); + if (!isSneaking) body.applyTransform(scale); - bipedLeftArm.render(scale); - bipedRightArm.render(scale); - bipedLeftLeg.render(scale); - bipedRightLeg.render(scale); + leftArm.render(scale); + rightArm.render(scale); + leftLeg.render(scale); + rightLeg.render(scale); if (textureHeight == 64) { - bipedLeftArmwear.render(scale); - bipedRightArmwear.render(scale); - bipedLeftLegwear.render(scale); - bipedRightLegwear.render(scale); + leftArmOverlay.render(scale); + rightArmOverlay.render(scale); + leftLegOverlay.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. */ @Override - public void setModelAttributes(ModelBase model) { - super.setModelAttributes(model); + public void setAttributes(BipedEntityModel model) { + super.setAttributes(model); + if (model instanceof AbstractPonyModel) { - AbstractPonyModel pony = (AbstractPonyModel) model; + AbstractPonyModel pony = (AbstractPonyModel) model; isFlying = pony.isFlying; isCrouching = pony.isCrouching; isElytraFlying = pony.isElytraFlying; @@ -969,31 +977,4 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IClientMo 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; - } } diff --git a/src/client/java/com/minelittlepony/client/model/ClientPonyModel.java b/src/client/java/com/minelittlepony/client/model/ClientPonyModel.java new file mode 100644 index 00000000..91d095e3 --- /dev/null +++ b/src/client/java/com/minelittlepony/client/model/ClientPonyModel.java @@ -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 extends PlayerEntityModel implements IPonyModel { + + 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; + } +} diff --git a/src/client/java/com/minelittlepony/client/model/IClientModel.java b/src/client/java/com/minelittlepony/client/model/IClientModel.java deleted file mode 100644 index 48b625b1..00000000 --- a/src/client/java/com/minelittlepony/client/model/IClientModel.java +++ /dev/null @@ -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 getBodyPart(BodyPart part); -} diff --git a/src/client/java/com/minelittlepony/client/model/ModelMobPony.java b/src/client/java/com/minelittlepony/client/model/ModelMobPony.java index 35712457..9f0c2239 100644 --- a/src/client/java/com/minelittlepony/client/model/ModelMobPony.java +++ b/src/client/java/com/minelittlepony/client/model/ModelMobPony.java @@ -1,6 +1,7 @@ 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 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. * */ -public abstract class ModelMobPony extends ModelAlicorn { +public abstract class ModelMobPony extends ModelAlicorn { public ModelMobPony() { super(false); @@ -23,18 +24,18 @@ public abstract class ModelMobPony extends ModelAlicorn { * @param swingProgress How far we are through the current swing * @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 roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PI); float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; float sin = MathHelper.sin(ticks * 0.067F) / 10; - arm.rotateAngleX = -1.5707964F; - arm.rotateAngleX -= swing * 1.2F - roll * 0.4F; - arm.rotateAngleX += sin; + arm.pitch = -1.5707964F; + arm.pitch -= swing * 1.2F - roll * 0.4F; + arm.pitch += sin; - arm.rotateAngleY = direction * (0.1F - swing * 0.6F); - arm.rotateAngleZ = cos; + arm.yaw = direction * (0.1F - swing * 0.6F); + arm.roll = cos; } } diff --git a/src/client/java/com/minelittlepony/client/model/ModelWrapper.java b/src/client/java/com/minelittlepony/client/model/ModelWrapper.java index 3f57c4ba..c876ae31 100644 --- a/src/client/java/com/minelittlepony/client/model/ModelWrapper.java +++ b/src/client/java/com/minelittlepony/client/model/ModelWrapper.java @@ -1,6 +1,10 @@ package com.minelittlepony.client.model; +import net.minecraft.entity.LivingEntity; + 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.capabilities.IModelWrapper; 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. */ -public class ModelWrapper implements IModelWrapper { +public class ModelWrapper implements IModelWrapper { - private final AbstractPonyModel body; + private final M body; private final IEquestrianArmour armor; @@ -19,7 +23,7 @@ public class ModelWrapper implements IModelWrapper { /** * Creates a new model wrapper to contain the given pony. */ - public ModelWrapper(AbstractPonyModel model) { + public ModelWrapper(M model) { body = model; armor = model.createArmour(); armor.apply(model.getMetadata()); @@ -31,15 +35,16 @@ public class ModelWrapper implements IModelWrapper { } } - public AbstractPonyModel getBody() { + public M getBody() { return body; } /** * Returns the contained armour model. */ - public IEquestrianArmour getArmor() { - return armor; + @SuppressWarnings("unchecked") + public IEquestrianArmour getArmor() { + return (IEquestrianArmour)armor; } @Override diff --git a/src/client/java/com/minelittlepony/client/model/armour/DefaultPonyArmorTextureResolver.java b/src/client/java/com/minelittlepony/client/model/armour/DefaultPonyArmorTextureResolver.java index 0db785d3..3c6d35e8 100644 --- a/src/client/java/com/minelittlepony/client/model/armour/DefaultPonyArmorTextureResolver.java +++ b/src/client/java/com/minelittlepony/client/model/armour/DefaultPonyArmorTextureResolver.java @@ -1,13 +1,14 @@ package com.minelittlepony.client.model.armour; -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.ResourcePackInfoClient; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.ItemArmor; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.resource.ClientResourcePackContainer; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.item.ArmorItem; import net.minecraft.item.ItemStack; -import net.minecraft.resources.ResourcePackType; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resource.ResourcePack; +import net.minecraft.resource.ResourceType; +import net.minecraft.util.Identifier; import com.google.common.collect.Maps; import com.minelittlepony.client.ForgeProxy; @@ -19,15 +20,15 @@ import javax.annotation.Nullable; import java.io.IOException; import java.util.Map; -public class DefaultPonyArmorTextureResolver implements IArmourTextureResolver { +public class DefaultPonyArmorTextureResolver implements IArmourTextureResolver { - private final Map HUMAN_ARMOUR = Maps.newHashMap(); - private final Map PONY_ARMOUR = Maps.newHashMap(); + private final Map HUMAN_ARMOUR = Maps.newHashMap(); + private final Map PONY_ARMOUR = Maps.newHashMap(); @Override - public ResourceLocation getArmourTexture(T entity, ItemStack itemstack, EntityEquipmentSlot slot, ArmourLayer layer, @Nullable String type) { - ItemArmor item = (ItemArmor) itemstack.getItem(); - String texture = item.getArmorMaterial().getName(); + public Identifier getArmourTexture(T entity, ItemStack itemstack, EquipmentSlot slot, ArmourLayer layer, @Nullable String type) { + ArmorItem item = (ArmorItem) itemstack.getItem(); + String texture = item.getMaterial().getName(); String domain = "minecraft"; @@ -42,20 +43,21 @@ public class DefaultPonyArmorTextureResolver impleme 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); - ResourceLocation human = getArmorTexture(entity, itemstack, ponyRes, slot, type); - ResourceLocation pony = ponifyResource(human); + Identifier human = getArmorTexture(entity, itemstack, ponyRes, slot, type); + Identifier pony = ponifyResource(human); - ResourceLocation oldHuman = getArmorTexture(entity, itemstack, oldPonyRes, slot, type); - ResourceLocation oldPony = ponifyResource(oldHuman); + Identifier oldHuman = getArmorTexture(entity, itemstack, oldPonyRes, slot, type); + Identifier oldPony = ponifyResource(oldHuman); return resolve(pony, oldPony, oldHuman, human); } - private ResourceLocation resolve(ResourceLocation... resources) { + private Identifier resolve(Identifier... resources) { // check resource packs for either texture. - for (ResourcePackInfoClient entry : Minecraft.getInstance().getResourcePackList().getAllPacks()) { - for (ResourceLocation candidate : resources) { - if (entry.getResourcePack().resourceExists(ResourcePackType.CLIENT_RESOURCES, candidate)) { + for (ClientResourcePackContainer entry : MinecraftClient.getInstance().getResourcePackContainerManager().getEnabledContainers()) { + ResourcePack pack = entry.createResourcePack(); + for (Identifier candidate : resources) { + if (pack.contains(ResourceType.CLIENT_RESOURCES, candidate)) { // ponies are more important return candidate; } @@ -63,9 +65,9 @@ public class DefaultPonyArmorTextureResolver impleme } // the default pack - for (ResourceLocation candidate : resources) { + for (Identifier candidate : resources) { try { - Minecraft.getInstance().getResourceManager().getResource(candidate); + MinecraftClient.getInstance().getResourceManager().getResource(candidate); return candidate; } catch (IOException e) { } } @@ -73,19 +75,19 @@ public class DefaultPonyArmorTextureResolver impleme return resources[resources.length - 1]; } - private ResourceLocation ponifyResource(ResourceLocation human) { + private Identifier ponifyResource(Identifier human) { return PONY_ARMOUR.computeIfAbsent(human, key -> { String domain = human.getNamespace(); if ("minecraft".equals(domain)) { 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) { - return HUMAN_ARMOUR.computeIfAbsent(ForgeProxy.getArmorTexture(entity, item, def, slot, type), ResourceLocation::new); + 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), Identifier::new); } } diff --git a/src/client/java/com/minelittlepony/client/model/armour/ModelPonyArmor.java b/src/client/java/com/minelittlepony/client/model/armour/ModelPonyArmor.java index fbb9ff7e..a42ee6d4 100644 --- a/src/client/java/com/minelittlepony/client/model/armour/ModelPonyArmor.java +++ b/src/client/java/com/minelittlepony/client/model/armour/ModelPonyArmor.java @@ -1,14 +1,14 @@ package com.minelittlepony.client.model.armour; -import net.minecraft.client.renderer.entity.model.ModelBiped; -import net.minecraft.entity.Entity; +import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.entity.LivingEntity; import com.minelittlepony.client.model.AbstractPonyModel; import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.model.IModel; import com.minelittlepony.model.armour.IArmour; -public class ModelPonyArmor extends AbstractPonyModel implements IArmour { +public class ModelPonyArmor extends AbstractPonyModel implements IArmour { public PonyRenderer chestPiece; @@ -21,26 +21,27 @@ public class ModelPonyArmor extends AbstractPonyModel implements IArmour { protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) { super.adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ); - chestPiece.rotateAngleX = rotateAngleX; + chestPiece.pitch = rotateAngleX; chestPiece.rotationPointY = rotationPointY; chestPiece.rotationPointZ = rotationPointZ; } @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); } @Override public void synchroniseLegs(IModel model) { - if (model instanceof ModelBiped) { - ModelBiped mainModel = (ModelBiped)model; - copyModelAngles(mainModel.bipedBody, bipedBody); - copyModelAngles(mainModel.bipedRightArm, bipedRightArm); - copyModelAngles(mainModel.bipedLeftArm, bipedLeftArm); - copyModelAngles(mainModel.bipedRightLeg, bipedRightLeg); - copyModelAngles(mainModel.bipedLeftLeg, bipedLeftLeg); + if (model instanceof BipedEntityModel) { + @SuppressWarnings("unchecked") + BipedEntityModel mainModel = (BipedEntityModel)model; + body.copyRotation(mainModel.body); + rightArm.copyRotation(mainModel.rightArm); + leftArm.copyRotation(mainModel.leftArm); + rightLeg.copyRotation(mainModel.rightLeg); + leftLeg.copyRotation(mainModel.leftLeg); } } @@ -62,31 +63,31 @@ public class ModelPonyArmor extends AbstractPonyModel implements IArmour { @Override protected void preInitLegs() { - bipedLeftArm = new PonyRenderer(this, 0, 16).flip(); - bipedRightArm = new PonyRenderer(this, 0, 16); + leftArm = new PonyRenderer(this, 0, 16).flip(); + rightArm = new PonyRenderer(this, 0, 16); - bipedLeftLeg = new PonyRenderer(this, 48, 8).flip(); - bipedRightLeg = new PonyRenderer(this, 48, 8); + leftLeg = new PonyRenderer(this, 48, 8).flip(); + rightLeg = new PonyRenderer(this, 48, 8); } @Override public void setInVisible() { setVisible(false); - bipedBody.showModel = true; - chestPiece.showModel = false; - bipedHead.showModel = false; - neck.showModel = false; + body.visible = true; + chestPiece.visible = false; + head.visible = false; + neck.visible = false; tail.setVisible(false); - upperTorso.isHidden = true; + upperTorso.field_3664 = true; snout.isHidden = true; } @Override public void showBoots() { - bipedRightArm.showModel = true; - bipedLeftArm.showModel = true; - bipedRightLeg.showModel = true; - bipedLeftLeg.showModel = true; + rightArm.visible = true; + leftArm.visible = true; + rightLeg.visible = true; + leftLeg.visible = true; } @Override @@ -96,18 +97,18 @@ public class ModelPonyArmor extends AbstractPonyModel implements IArmour { @Override public void showChestplate() { - chestPiece.showModel = true; - neck.showModel = true; + chestPiece.visible = true; + neck.visible = true; } @Override public void showSaddle() { - chestPiece.showModel = true; - neck.showModel = true; + chestPiece.visible = true; + neck.visible = true; } @Override public void showHelmet() { - bipedHead.showModel = true; + head.visible = true; } } diff --git a/src/client/java/com/minelittlepony/client/model/armour/PonyArmor.java b/src/client/java/com/minelittlepony/client/model/armour/PonyArmor.java index 4ea2926c..96962f1c 100644 --- a/src/client/java/com/minelittlepony/client/model/armour/PonyArmor.java +++ b/src/client/java/com/minelittlepony/client/model/armour/PonyArmor.java @@ -1,15 +1,17 @@ package com.minelittlepony.client.model.armour; +import net.minecraft.entity.LivingEntity; + import com.minelittlepony.model.armour.ArmourLayer; import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.pony.IPonyData; -public class PonyArmor implements IEquestrianArmour { +public class PonyArmor implements IEquestrianArmour> { - private final ModelPonyArmor outerLayer; - private final ModelPonyArmor innerLayer; + private final ModelPonyArmor outerLayer; + private final ModelPonyArmor innerLayer; - public PonyArmor(ModelPonyArmor outer, ModelPonyArmor inner) { + public PonyArmor(ModelPonyArmor outer, ModelPonyArmor inner) { outerLayer = outer; innerLayer = inner; } @@ -27,7 +29,7 @@ public class PonyArmor implements IEquestrianArmour { } @Override - public ModelPonyArmor getArmorForLayer(ArmourLayer layer) { + public ModelPonyArmor getArmorForLayer(ArmourLayer layer) { if (layer == ArmourLayer.INNER) { return innerLayer; diff --git a/src/client/java/com/minelittlepony/client/model/armour/package-info.java b/src/client/java/com/minelittlepony/client/model/armour/package-info.java index f8eaa580..719ffa43 100644 --- a/src/client/java/com/minelittlepony/client/model/armour/package-info.java +++ b/src/client/java/com/minelittlepony/client/model/armour/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.model.armour; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/model/components/BatWings.java b/src/client/java/com/minelittlepony/client/model/components/BatWings.java index 424f85fa..9e4ce451 100644 --- a/src/client/java/com/minelittlepony/client/model/components/BatWings.java +++ b/src/client/java/com/minelittlepony/client/model/components/BatWings.java @@ -1,14 +1,15 @@ 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.model.IPegasus; +import com.mojang.blaze3d.platform.GlStateManager; + import java.util.UUID; -public class BatWings extends PegasusWings { +public class BatWings extends PegasusWings { public BatWings(T model, float yOffset, float stretch) { super(model, yOffset, stretch); @@ -48,7 +49,7 @@ public class BatWings extends PegasusWin .tex(56, 16).box(x, 5, 6, 1, 7, 1, scale) .box(x, 5, 5, 1, 6, 1, scale) .tex(56, 16).box(x * 0.9F, 5, 7, 1, 7, 1, scale) - .rotateAngleX = ROTATE_90; + .pitch = ROTATE_90; } @Override @@ -57,7 +58,7 @@ public class BatWings extends PegasusWin extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY - 1, EXT_WING_RP_Z - 3) .mirror(right) - .rotateAngleY = r * 3; + .yaw = r * 3; extended.child().tex(60, 16) .mirror(right) // children are unaware of their parents being mirrored, sadly @@ -85,7 +86,7 @@ public class BatWings extends PegasusWin @Override public void rotateWalking(float swing) { - folded.rotateAngleY = swing * 0.05F; + folded.yaw = swing * 0.05F; } } } diff --git a/src/client/java/com/minelittlepony/client/model/components/BugWings.java b/src/client/java/com/minelittlepony/client/model/components/BugWings.java index 6fcb364c..fcbe3d7b 100644 --- a/src/client/java/com/minelittlepony/client/model/components/BugWings.java +++ b/src/client/java/com/minelittlepony/client/model/components/BugWings.java @@ -1,10 +1,11 @@ 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.model.IPegasus; -public class BugWings extends PegasusWings { +public class BugWings extends PegasusWings { public BugWings(T model, float yOffset, float stretch) { super(model, yOffset, stretch); @@ -34,7 +35,7 @@ public class BugWings extends PegasusWin extended.around((r * (EXT_WING_RP_X - 2)), EXT_WING_RP_Y + rotationPointY, EXT_WING_RP_Z - 2) .mirror(right) - .rotateAngleY = r * 3; + .yaw = r * 3; PlaneRenderer primary = new PlaneRenderer(pegasus) .tex(56, 16) diff --git a/src/client/java/com/minelittlepony/client/model/components/ModelDeadMau5Ears.java b/src/client/java/com/minelittlepony/client/model/components/ModelDeadMau5Ears.java index b6fc9697..228146e7 100644 --- a/src/client/java/com/minelittlepony/client/model/components/ModelDeadMau5Ears.java +++ b/src/client/java/com/minelittlepony/client/model/components/ModelDeadMau5Ears.java @@ -1,18 +1,17 @@ package com.minelittlepony.client.model.components; -import net.minecraft.client.renderer.entity.model.ModelRenderer; -import net.minecraft.client.renderer.entity.model.ModelSkeletonHead; +import net.minecraft.client.render.entity.model.SkullEntityModel; -public class ModelDeadMau5Ears extends ModelSkeletonHead { +public class ModelDeadMau5Ears extends SkullEntityModel { public ModelDeadMau5Ears() { - super(); - skeletonHead = new ModelRenderer(this, 24, 0); - skeletonHead.addBox(-9, -13, -1, 6, 6, 1, 0); - skeletonHead.addBox(3, -13, -1, 6, 6, 1, 0); + super(24, 0, 64, 64); + field_3564.boxes.clear(); + field_3564.addBox(-9, -13, -1, 6, 6, 1, 0); + field_3564.addBox(3, -13, -1, 6, 6, 1, 0); } public void setVisible(boolean show) { - skeletonHead.isHidden = !show; + field_3564.field_3664 = !show; } } diff --git a/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java b/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java index 6ae72146..1787a58b 100644 --- a/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java +++ b/src/client/java/com/minelittlepony/client/model/components/ModelPonyHead.java @@ -5,11 +5,10 @@ import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.model.ICapitated; import com.minelittlepony.pony.IPonyData; -import net.minecraft.client.renderer.entity.model.ModelHumanoidHead; -import net.minecraft.client.renderer.entity.model.ModelRenderer; -import net.minecraft.entity.Entity; +import net.minecraft.client.model.Cuboid; +import net.minecraft.client.render.entity.model.SkullOverlayEntityModel; -public class ModelPonyHead extends ModelHumanoidHead implements ICapitated { +public class ModelPonyHead extends SkullOverlayEntityModel implements ICapitated { private PonySnout snout; @@ -32,12 +31,12 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated implements IPart, PonyModelConstants { +public class PegasusWings implements IPart, PonyModelConstants { protected final T pegasus; @@ -110,20 +110,20 @@ public class PegasusWings implements IPa .box(x, 5, 2, 2, 6, 2, scale) .box(x, 5, 4, 2, 8, 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) { float r = right ? -1 : 1; 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(1, l, -1, -0.3F, 8, scale + 0.1F) .rotateAngleX = -0.85F; - addFeather(2, l, 1.8F, 1.3F, 8, scale - 0.1F) .rotateAngleX = -0.75F; - addFeather(3, l, 5, 2, 8, scale) .rotateAngleX = -0.5F; + addFeather(1, l, -1, -0.3F, 8, scale + 0.1F) .pitch = -0.85F; + addFeather(2, l, 1.8F, 1.3F, 8, scale - 0.1F) .pitch = -0.75F; + addFeather(3, l, 5, 2, 8, scale) .pitch = -0.5F; 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) { @@ -131,11 +131,11 @@ public class PegasusWings implements IPa } public void rotateWalking(float swing) { - folded.rotateAngleY = swing * 0.15F; + folded.yaw = swing * 0.15F; } public void rotateFlying(float angle) { - extended.rotateAngleZ = angle; + extended.roll = angle; } public void render(float scale) { diff --git a/src/client/java/com/minelittlepony/client/model/components/PonyElytra.java b/src/client/java/com/minelittlepony/client/model/components/PonyElytra.java index 378e9130..18779f18 100644 --- a/src/client/java/com/minelittlepony/client/model/components/PonyElytra.java +++ b/src/client/java/com/minelittlepony/client/model/components/PonyElytra.java @@ -1,21 +1,20 @@ package com.minelittlepony.client.model.components; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.entity.LivingEntity; import net.minecraft.util.math.Vec3d; import com.minelittlepony.client.model.AbstractPonyModel; import com.minelittlepony.client.util.render.PonyRenderer; +import com.mojang.blaze3d.platform.GlStateManager; import static com.minelittlepony.model.PonyModelConstants.*; /** * Modified from ModelElytra. */ -public class PonyElytra extends ModelBase { +public class PonyElytra extends EntityModel { public boolean isSneaking; @@ -33,7 +32,7 @@ public class PonyElytra extends ModelBase { * See {@link AbstractPonyModel.render} for an explanation of the various parameters. */ @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.disableCull(); leftWing.render(scale); @@ -46,8 +45,8 @@ public class PonyElytra extends ModelBase { * See {@link AbstractPonyModel.setRotationAngles} for an explanation of the various parameters. */ @Override - public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); float rotateX = PI / 2; float rotateY = PI / 8; @@ -55,12 +54,12 @@ public class PonyElytra extends ModelBase { float rpY = BODY_RP_Y_NOTSNEAK; - if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) { + if (entity.isFallFlying()) { float velY = 1; - if (entity.motionY < 0) { - Vec3d motion = new Vec3d(entity.motionX, entity.motionY, entity.motionZ).normalize(); - velY = 1 - (float) Math.pow(-motion.y, 1.5); + Vec3d motion = entity.getVelocity(); + if (motion.y < 0) { + velY = 1 - (float) Math.pow(-motion.normalize().y, 1.5); } rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX; @@ -75,27 +74,27 @@ public class PonyElytra extends ModelBase { leftWing.rotationPointX = 5; leftWing.rotationPointY = rpY; - if (entity instanceof AbstractClientPlayer) { - AbstractClientPlayer player = (AbstractClientPlayer) entity; + if (entity instanceof AbstractClientPlayerEntity) { + AbstractClientPlayerEntity player = (AbstractClientPlayerEntity) entity; - player.rotateElytraX += (rotateX - player.rotateElytraX) / 10; - player.rotateElytraY += (rotateY - player.rotateElytraY) / 10; - player.rotateElytraZ += (rotateZ - player.rotateElytraZ) / 10; + player.elytraPitch += (rotateX - player.elytraPitch) / 10; + player.elytraYaw += (rotateY - player.elytraYaw) / 10; + player.elytraRoll += (rotateZ - player.elytraRoll) / 10; - leftWing.rotateAngleX = player.rotateElytraX; - leftWing.rotateAngleY = player.rotateElytraY; - leftWing.rotateAngleZ = player.rotateElytraZ; + leftWing.pitch = player.elytraPitch; + leftWing.yaw = player.elytraYaw; + leftWing.roll = player.elytraRoll; } else { - leftWing.rotateAngleX = rotateX; - leftWing.rotateAngleZ = rotateZ; - leftWing.rotateAngleY = rotateY; + leftWing.pitch = rotateX; + leftWing.yaw = rotateZ; + leftWing.roll = rotateY; } rightWing.rotationPointX = -leftWing.rotationPointX; rightWing.rotationPointY = leftWing.rotationPointY; - rightWing.rotateAngleX = leftWing.rotateAngleX; - rightWing.rotateAngleY = -leftWing.rotateAngleY; - rightWing.rotateAngleZ = -leftWing.rotateAngleZ; + rightWing.pitch = leftWing.pitch; + rightWing.yaw = -leftWing.yaw; + rightWing.roll = -leftWing.roll; } } diff --git a/src/client/java/com/minelittlepony/client/model/components/PonySnout.java b/src/client/java/com/minelittlepony/client/model/components/PonySnout.java index f6122f97..d5751688 100644 --- a/src/client/java/com/minelittlepony/client/model/components/PonySnout.java +++ b/src/client/java/com/minelittlepony/client/model/components/PonySnout.java @@ -1,7 +1,7 @@ package com.minelittlepony.client.model.components; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.entity.model.ModelRenderer; +import net.minecraft.client.model.Cuboid; +import net.minecraft.client.model.Model; import com.minelittlepony.MineLittlePony; import com.minelittlepony.client.util.render.plane.PlaneRenderer; @@ -17,13 +17,13 @@ public class PonySnout { private PlaneRenderer mare; private PlaneRenderer stallion; - private final ICapitated head; + private final ICapitated head; - public > PonySnout(T pony) { + public > PonySnout(T pony) { this(pony, 0, 0, 0); } - public > PonySnout(T pony, int x, int y, int z) { + public > PonySnout(T pony, int x, int y, int z) { head = pony; 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) { boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getInstance().getConfig().snuzzles; - mare.isHidden = !(show && gender.isMare()); - stallion.isHidden = !(show && gender.isStallion()); + mare.field_3664 = !(show && gender.isMare()); + stallion.field_3664 = !(show && gender.isStallion()); } } diff --git a/src/client/java/com/minelittlepony/client/model/components/PonyTail.java b/src/client/java/com/minelittlepony/client/model/components/PonyTail.java index e6e1e615..ee9c2da7 100644 --- a/src/client/java/com/minelittlepony/client/model/components/PonyTail.java +++ b/src/client/java/com/minelittlepony/client/model/components/PonyTail.java @@ -1,6 +1,6 @@ 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 com.minelittlepony.client.model.AbstractPonyModel; @@ -9,17 +9,15 @@ import com.minelittlepony.model.IPart; import java.util.UUID; -import static com.minelittlepony.model.PonyModelConstants.*; - public class PonyTail extends PlaneRenderer implements IPart { private static final int SEGMENTS = 4; - private final AbstractPonyModel theModel; + private final AbstractPonyModel theModel; private int tailStop = 0; - public PonyTail(AbstractPonyModel model) { + public PonyTail(AbstractPonyModel model) { super(model); theModel = model; } @@ -33,21 +31,21 @@ public class PonyTail extends PlaneRenderer implements IPart { @Override 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; - rotateAngleY = bodySwing; + roll = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing; + yaw = bodySwing; if (theModel.isCrouching() && !rainboom) { rotateSneak(); } else if (theModel.isRiding()) { rotationPointZ = TAIL_RP_Z_RIDING; rotationPointY = TAIL_RP_Y_RIDING; - rotateAngleX = PI / 5; + pitch = PI / 5; } else { setRotationPoint(TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK); if (rainboom) { - rotateAngleX = ROTATE_90 + MathHelper.sin(move) / 10; + pitch = ROTATE_90 + MathHelper.sin(move) / 10; } else { - rotateAngleX = swing / 2; + pitch = swing / 2; swingX(ticks); } @@ -63,18 +61,18 @@ public class PonyTail extends PlaneRenderer implements IPart { private void swingX(float ticks) { float sinTickFactor = MathHelper.sin(ticks * 0.067f) * 0.05f; - rotateAngleX += sinTickFactor; - rotateAngleY += sinTickFactor; + pitch += sinTickFactor; + yaw += sinTickFactor; } private void rotateSneak() { 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 public void setVisible(boolean visible) { - isHidden = !visible; + field_3664 = !visible; } @Override @@ -86,11 +84,11 @@ public class PonyTail extends PlaneRenderer implements IPart { 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); this.index = index; - offsetY = ((float)index)/4 + 0.063f; + y = ((float)index)/4 + 0.063f; init(yOffset, stretch); } diff --git a/src/client/java/com/minelittlepony/client/model/components/SeaponyTail.java b/src/client/java/com/minelittlepony/client/model/components/SeaponyTail.java index 44878ca6..415b0cab 100644 --- a/src/client/java/com/minelittlepony/client/model/components/SeaponyTail.java +++ b/src/client/java/com/minelittlepony/client/model/components/SeaponyTail.java @@ -1,16 +1,14 @@ package com.minelittlepony.client.model.components; 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.plane.PlaneRenderer; import com.minelittlepony.model.IPart; +import com.minelittlepony.model.IPonyModel; +import com.mojang.blaze3d.platform.GlStateManager; import java.util.UUID; -import static com.minelittlepony.model.PonyModelConstants.*; - -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.math.MathHelper; import org.lwjgl.opengl.GL11; @@ -24,9 +22,9 @@ public class SeaponyTail implements IPart { private PlaneRenderer tailTip; private PlaneRenderer tailFins; - private IClientModel model; + private IPonyModel model; - public SeaponyTail(AbstractPonyModel model) { + public SeaponyTail(AbstractPonyModel model) { this.model = model; 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) { float rotation = model.isSleeping() ? 0 : MathHelper.sin(ticks * 0.536f) / 4; - tailBase.rotateAngleX = TAIL_ROTX + rotation; - tailTip.rotateAngleX = rotation; - tailFins.rotateAngleX = rotation - TAIL_ROTX; + tailBase.pitch = TAIL_ROTX + rotation; + tailTip.pitch = rotation; + tailFins.pitch = rotation - TAIL_ROTX; } @Override diff --git a/src/client/java/com/minelittlepony/client/model/components/UnicornHorn.java b/src/client/java/com/minelittlepony/client/model/components/UnicornHorn.java index 313be559..d3bc5423 100644 --- a/src/client/java/com/minelittlepony/client/model/components/UnicornHorn.java +++ b/src/client/java/com/minelittlepony/client/model/components/UnicornHorn.java @@ -1,19 +1,20 @@ 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.PonyRenderer; import com.minelittlepony.model.ICapitated; import com.minelittlepony.model.IPart; +import javax.annotation.Nullable; + import java.util.UUID; -import static com.minelittlepony.model.PonyModelConstants.*; - -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.entity.model.ModelRenderer; +import static com.mojang.blaze3d.platform.GlStateManager.*; import static org.lwjgl.opengl.GL11.*; -import static net.minecraft.client.renderer.GlStateManager.*; public class UnicornHorn implements IPart { @@ -22,18 +23,18 @@ public class UnicornHorn implements IPart { protected boolean isVisible = true; - public > UnicornHorn(T pony, float yOffset, float stretch) { + public > UnicornHorn(T pony, float yOffset, float stretch) { this(pony, yOffset, stretch, 0, 0, 0); } - public > UnicornHorn(T pony, float yOffset, float stretch, int x, int y, int z) { + public > UnicornHorn(T pony, float yOffset, float stretch, int x, int y, int z) { horn = new PonyRenderer(pony, 0, 3); glow = new GlowRenderer(pony, 0, 3); horn.offset(HORN_X + x, HORN_Y + y, HORN_Z + z) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) .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) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z) @@ -42,7 +43,7 @@ public class UnicornHorn implements IPart { } @Override - public void renderPart(float scale, UUID interpolatorId) { + public void renderPart(float scale, @Nullable UUID interpolatorId) { if (isVisible) { horn.render(scale); } @@ -51,15 +52,15 @@ public class UnicornHorn implements IPart { public void renderMagic(int tint, float scale) { if (isVisible) { glPushAttrib(24577); - disableTexture2D(); + disableTexture(); disableLighting(); enableBlend(); blendFunc(GL_SRC_ALPHA, GL_ONE); - horn.postRender(scale); + horn.applyTransform(scale); glow.setTint(tint).render(scale); - enableTexture2D(); + enableTexture(); enableLighting(); disableBlend(); glPopAttrib(); diff --git a/src/client/java/com/minelittlepony/client/model/components/package-info.java b/src/client/java/com/minelittlepony/client/model/components/package-info.java index 5e9811f5..229429d4 100644 --- a/src/client/java/com/minelittlepony/client/model/components/package-info.java +++ b/src/client/java/com/minelittlepony/client/model/components/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.model.components; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/model/entities/ModelBreezie.java b/src/client/java/com/minelittlepony/client/model/entities/ModelBreezie.java index e9034d32..2d812415 100644 --- a/src/client/java/com/minelittlepony/client/model/entities/ModelBreezie.java +++ b/src/client/java/com/minelittlepony/client/model/entities/ModelBreezie.java @@ -1,16 +1,16 @@ package com.minelittlepony.client.model.entities; -import net.minecraft.client.renderer.entity.model.ModelBiped; -import net.minecraft.client.renderer.entity.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.util.EnumHandSide; +import net.minecraft.client.model.Cuboid; +import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.AbsoluteHand; import net.minecraft.util.math.MathHelper; import com.minelittlepony.client.util.render.PonyRenderer; import static com.minelittlepony.model.PonyModelConstants.PI; -public class ModelBreezie extends ModelBiped { +public class ModelBreezie extends BipedEntityModel { PonyRenderer neck; PonyRenderer tail; @@ -23,8 +23,8 @@ public class ModelBreezie extends ModelBiped { textureWidth = 64; textureHeight = 64; - bipedHeadwear.showModel = false; - bipedHead = new PonyRenderer(this) + headwear.visible = false; + head = new PonyRenderer(this) .child(new PonyRenderer(this) .addBox(-3, -6, -3, 6, 6, 6).around(0, 0, -4) .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) .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); - bipedLeftArm = 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); - bipedLeftLeg = 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); + leftArm = new PonyRenderer(this, 28, 12).addBox(0, 0, 0, 2, 12, 2).around( 1, 8, -5); + rightArm = new PonyRenderer(this, 36, 12).addBox(0, 0, 0, 2, 12, 2).around(-3, 8, -5); + leftLeg = new PonyRenderer(this, 8, 12) .addBox(0, 0, 0, 2, 12, 2).around( 1, 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) .addBox(0, 0, 0, 2, 5, 2) @@ -66,7 +66,7 @@ public class ModelBreezie extends ModelBiped { } @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); neck.render(scale); tailStub.render(scale); @@ -77,46 +77,46 @@ public class ModelBreezie extends ModelBiped { @SuppressWarnings("incomplete-switch") @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; - bipedHead.rotateAngleX = headPitch * 0.017453292F; + head.yaw = headYaw * 0.017453292F; + head.pitch = headPitch * 0.017453292F; - bipedLeftArm.rotateAngleX = MathHelper.cos(move * 0.6662F) * swing; - bipedLeftArm.rotateAngleZ = 0; + leftArm.pitch = MathHelper.cos(move * 0.6662F) * swing; + leftArm.roll = 0; - ((PonyRenderer)bipedRightArm).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)bipedRightLeg).rotate(swing * MathHelper.cos(move * 0.6662F) * 1.4F, 0, 0); + ((PonyRenderer)rightArm).rotate(swing * MathHelper.cos(move * 0.6662F + PI), 0, 0); + ((PonyRenderer)leftLeg) .rotate(swing * MathHelper.cos(move * 0.6662F + PI) * 1.4F, 0, 0); + ((PonyRenderer)rightLeg).rotate(swing * MathHelper.cos(move * 0.6662F) * 1.4F, 0, 0); if (isRiding) { - bipedLeftArm.rotateAngleX += -PI / 5; - bipedRightArm.rotateAngleX += -PI / 5; + leftArm.pitch += -PI / 5; + rightArm.pitch += -PI / 5; - rotateLegRiding(((PonyRenderer)bipedLeftLeg), -1); - rotateLegRiding(((PonyRenderer)bipedRightLeg), 1); + rotateLegRiding(((PonyRenderer)leftLeg), -1); + rotateLegRiding(((PonyRenderer)rightLeg), 1); } - rotateArm(bipedLeftArm, leftArmPose, 1); - rotateArm(bipedRightArm, rightArmPose, 1); + rotateArm(leftArm, leftArmPose, 1); + rotateArm(rightArm, rightArmPose, 1); - if (swingProgress > 0) { - swingArms(getMainHand(entity)); + if (handSwingProgress > 0) { + swingArms(getPreferedHand(entity)); } float rotX = MathHelper.sin(ticks * 0.067F) * 0.05F; float rotZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; - bipedLeftArm.rotateAngleX -= rotX; - bipedLeftArm.rotateAngleZ -= rotZ; + leftArm.pitch -= rotX; + leftArm.roll -= rotZ; - bipedRightArm.rotateAngleX += rotX; - bipedRightArm.rotateAngleZ += rotZ; + rightArm.pitch += rotX; + rightArm.roll += rotZ; - if (rightArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { - raiseArm(bipedRightArm, bipedLeftArm, -1); - } else if (leftArmPose == ModelBiped.ArmPose.BOW_AND_ARROW) { - raiseArm(bipedLeftArm, bipedRightArm, 1); + if (rightArmPose == ArmPose.BOW_AND_ARROW) { + raiseArm(rightArm, leftArm, -1); + } else if (leftArmPose == ArmPose.BOW_AND_ARROW) { + raiseArm(leftArm, rightArm, 1); } } @@ -124,57 +124,57 @@ public class ModelBreezie extends ModelBiped { leg.rotate(-1.4137167F, factor * PI / 10, factor * 0.07853982F); } - protected void swingArms(EnumHandSide mainHand) { - bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) / 5; + protected void swingArms(AbsoluteHand mainHand) { + body.yaw = MathHelper.sin(MathHelper.sqrt(handSwingProgress) * PI * 2) / 5; - if (mainHand == EnumHandSide.LEFT) { - bipedBody.rotateAngleY *= -1; + if (mainHand == AbsoluteHand.LEFT) { + body.yaw *= -1; } - float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; - float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; + float sin = MathHelper.sin(body.yaw) * 5; + float cos = MathHelper.cos(body.yaw) * 5; - bipedLeftArm.rotateAngleX += bipedBody.rotateAngleY; - bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY; - bipedLeftArm.rotationPointX = cos; - bipedLeftArm.rotationPointZ = -sin; + leftArm.pitch += body.yaw; + leftArm.yaw += body.yaw; + leftArm.rotationPointX = cos; + leftArm.rotationPointZ = -sin; - bipedRightArm.rotateAngleY += bipedBody.rotateAngleY; - bipedRightArm.rotationPointX = -cos; - bipedRightArm.rotationPointZ = sin; + rightArm.yaw += body.yaw; + rightArm.rotationPointX = -cos; + 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 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); - mainArm.rotateAngleX -= swingFactorX * 1.2F + swingX; - mainArm.rotateAngleY += bipedBody.rotateAngleY * 2; - mainArm.rotateAngleZ -= MathHelper.sin(swingProgress * PI) * 0.4F; + Cuboid mainArm = getArm(mainHand); + mainArm.pitch -= swingFactorX * 1.2F + swingX; + mainArm.yaw += body.yaw * 2; + 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) { case EMPTY: - arm.rotateAngleY = 0; + arm.yaw = 0; break; case ITEM: - arm.rotateAngleX = arm.rotateAngleX / 2 - (PI / 10); - arm.rotateAngleY = 0; + arm.pitch = arm.pitch / 2 - (PI / 10); + arm.yaw = 0; case BLOCK: - arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F; - arm.rotateAngleY = factor * 0.5235988F; + arm.pitch = arm.pitch / 2 - 0.9424779F; + arm.yaw = factor * 0.5235988F; break; default: } } - protected void raiseArm(ModelRenderer up, ModelRenderer down, float factor) { - up.rotateAngleY = bipedHead.rotateAngleY + (factor / 10); - up.rotateAngleX = bipedHead.rotateAngleX - (PI / 2); + protected void raiseArm(Cuboid up, Cuboid down, float factor) { + up.yaw = head.yaw + (factor / 10); + up.pitch = head.pitch - (PI / 2); - down.rotateAngleY = bipedHead.rotateAngleY - (factor / 2); - down.rotateAngleX = bipedHead.rotateAngleX - (PI / 2); + down.yaw = head.yaw - (factor / 2); + down.pitch = head.pitch - (PI / 2); } } diff --git a/src/client/java/com/minelittlepony/client/model/entities/ModelEnderStallion.java b/src/client/java/com/minelittlepony/client/model/entities/ModelEnderStallion.java index 08fa8c59..e073ee16 100644 --- a/src/client/java/com/minelittlepony/client/model/entities/ModelEnderStallion.java +++ b/src/client/java/com/minelittlepony/client/model/entities/ModelEnderStallion.java @@ -1,15 +1,15 @@ package com.minelittlepony.client.model.entities; -import net.minecraft.client.renderer.entity.model.ModelRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.client.model.Cuboid; +import net.minecraft.entity.mob.EndermanEntity; import net.minecraft.util.math.MathHelper; import com.minelittlepony.client.model.components.PonySnout; import com.minelittlepony.client.util.render.PonyRenderer; -public class ModelEnderStallion extends ModelSkeletonPony { +import com.mojang.blaze3d.platform.GlStateManager; + +public class ModelEnderStallion extends ModelSkeletonPony { public boolean isCarrying; public boolean isAttacking; @@ -21,27 +21,27 @@ public class ModelEnderStallion extends ModelSkeletonPony { private PonyRenderer rightHorn; @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; leftArmPose = rightArmPose; isUnicorn = true; - isAlicorn = entity.getUniqueID().getLeastSignificantBits() % 3 == 0; - isBoss = !isAlicorn && entity.getUniqueID().getLeastSignificantBits() % 90 == 0; + isAlicorn = entity.getUuid().getLeastSignificantBits() % 3 == 0; + isBoss = !isAlicorn && entity.getUuid().getLeastSignificantBits() % 90 == 0; - leftHorn.isHidden = rightHorn.isHidden = !isBoss; + leftHorn.field_3664 = rightHorn.field_3664 = !isBoss; horn.setVisible(!isBoss); tail.setVisible(false); snout.isHidden = true; - bipedLeftArmwear.isHidden = true; - bipedRightArmwear.isHidden = true; + leftArmOverlay.field_3664 = true; + rightArmOverlay.field_3664 = true; - bipedLeftLegwear.isHidden = true; - bipedRightLegwear.isHidden = true; + leftLegOverlay.field_3664 = true; + rightLegOverlay.field_3664 = true; - leftHorn.rotateAngleX = 0.5F; - rightHorn.rotateAngleX = 0.5F; + leftHorn.pitch = 0.5F; + rightHorn.pitch = 0.5F; } @Override @@ -51,17 +51,16 @@ public class ModelEnderStallion extends ModelSkeletonPony { } @Override - public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + public void setAngles(EndermanEntity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); if (isAttacking) { - bipedHead.rotationPointY -= 5; + head.rotationPointY -= 5; } } @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.translatef(0, -1.15F, 0); super.render(entity, move, swing, ticks, headYaw, headPitch, scale); @@ -75,14 +74,14 @@ public class ModelEnderStallion extends ModelSkeletonPony { @Override 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) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) .box(-4, -4, -4, 8, 8, 8, stretch) .tex(12, 16).box(-4, -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) .rotate(0.1F, 0, -0.8F) .offset(-2, -10, -3) @@ -92,7 +91,7 @@ public class ModelEnderStallion extends ModelSkeletonPony { .around(-3.9F, -6, 0.001F) .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) .rotate(0.1F, 0, 0.8F) .offset(0, -10, -3) @@ -102,7 +101,7 @@ public class ModelEnderStallion extends ModelSkeletonPony { .around(3.9F, -6, 0.001F) .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) .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2) .box(-4, -4, -4, 8, 8, 8, stretch - 0.5F); @@ -112,18 +111,18 @@ public class ModelEnderStallion extends ModelSkeletonPony { } @Override - protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float ticks) { - arm.rotateAngleX = -0.3707964F; - arm.rotateAngleX += 0.4F + MathHelper.sin(ticks * 0.067F) / 10; + protected void rotateArmHolding(Cuboid arm, float direction, float swingProgress, float ticks) { + arm.pitch = -0.3707964F; + arm.pitch += 0.4F + MathHelper.sin(ticks * 0.067F) / 10; } @Override protected void preInitLegs() { - bipedLeftArm = new ModelRenderer(this, 0, 20); - bipedRightArm = new ModelRenderer(this, 0, 20); + leftArm = new Cuboid(this, 0, 20); + rightArm = new Cuboid(this, 0, 20); - bipedLeftLeg = new ModelRenderer(this, 0, 20); - bipedRightLeg = new ModelRenderer(this, 0, 20); + leftLeg = new Cuboid(this, 0, 20); + rightLeg = new Cuboid(this, 0, 20); } @Override diff --git a/src/client/java/com/minelittlepony/client/model/entities/ModelGuardianPony.java b/src/client/java/com/minelittlepony/client/model/entities/ModelGuardianPony.java new file mode 100644 index 00000000..f00f5627 --- /dev/null +++ b/src/client/java/com/minelittlepony/client/model/entities/ModelGuardianPony.java @@ -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, PonyRenderer> { + private final ModelSeapony 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 entityModel_1) { + mixin().copyStateTo(entityModel_1); + } + + @Override + public ModelSeapony mixin() { + return mixin; + } +} diff --git a/src/client/java/com/minelittlepony/client/model/entities/ModelIllagerPony.java b/src/client/java/com/minelittlepony/client/model/entities/ModelIllagerPony.java index 6becb5ac..83579a9f 100644 --- a/src/client/java/com/minelittlepony/client/model/entities/ModelIllagerPony.java +++ b/src/client/java/com/minelittlepony/client/model/entities/ModelIllagerPony.java @@ -1,59 +1,56 @@ package com.minelittlepony.client.model.entities; -import net.minecraft.client.renderer.entity.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.monster.AbstractIllager; -import net.minecraft.entity.monster.AbstractIllager.IllagerArmPose; -import net.minecraft.util.EnumHandSide; +import net.minecraft.client.model.Cuboid; +import net.minecraft.entity.mob.IllagerEntity; +import net.minecraft.util.AbsoluteHand; import net.minecraft.util.math.MathHelper; import com.minelittlepony.client.model.ModelMobPony; -public class ModelIllagerPony extends ModelMobPony { +public class ModelIllagerPony extends ModelMobPony { @Override - public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + public void setAngles(T illager, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.setAngles(illager, move, swing, ticks, headYaw, headPitch, scale); - AbstractIllager illager = (AbstractIllager) entity; - IllagerArmPose pose = illager.getArmPose(); + IllagerEntity.State pose = illager.getState(); - boolean rightHanded = illager.getPrimaryHand() == EnumHandSide.RIGHT; + boolean rightHanded = illager.getMainHand() == AbsoluteHand.RIGHT; 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 - float f = MathHelper.sin(swingProgress * (float) Math.PI); - float f1 = MathHelper.sin((1.0F - (1.0F - swingProgress) * (1.0F - swingProgress)) * (float) Math.PI); - + float f = MathHelper.sin(getSwingAmount() * (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 sin = MathHelper.sin(ticks * 0.067F) * 0.05F; - bipedRightArm.rotateAngleZ = cos; - bipedLeftArm.rotateAngleZ = cos; + rightArm.roll = cos; + leftArm.roll = cos; - bipedRightArm.rotateAngleY = 0.15707964F; - bipedLeftArm.rotateAngleY = -0.15707964F; + rightArm.yaw = 0.15707964F; + leftArm.yaw = -0.15707964F; - arm.rotateAngleX = -1.8849558F + MathHelper.cos(ticks * 0.09F) * 0.15F; - arm.rotateAngleX += f * 2.2F - f1 * 0.4F; + arm.pitch = -1.8849558F + MathHelper.cos(ticks * 0.09F) * 0.15F; + arm.pitch += f * 2.2F - f1 * 0.4F; - bipedRightArm.rotateAngleX += sin; - bipedLeftArm.rotateAngleX -= sin; - } else if (pose == IllagerArmPose.SPELLCASTING) { + rightArm.pitch += sin; + leftArm.pitch -= sin; + } else if (pose == IllagerEntity.State.SPELLCASTING) { // waving arms! -// this.bipedRightArm.rotationPointZ = 0; - arm.rotateAngleX = (float) (-.75F * Math.PI); - arm.rotateAngleZ = mult * MathHelper.cos(ticks * 0.6662F) / 4; - arm.rotateAngleY = mult * 1.1F; - } else if (pose == IllagerArmPose.BOW_AND_ARROW) { + // rightArm.rotationPointZ = 0; + arm.pitch = (float) (-.75F * Math.PI); + arm.roll = mult * MathHelper.cos(ticks * 0.6662F) / 4; + arm.yaw = mult * 1.1F; + } else if (pose == IllagerEntity.State.BOW_AND_ARROW) { aimBow(arm, ticks); } } - public ModelRenderer getArm(EnumHandSide side) { - return canCast() ? getUnicornArmForSide(side) : getArmForSide(side); + @Override + public Cuboid getArm(AbsoluteHand side) { + return canCast() ? getUnicornArmForSide(side) : super.getArm(side); } } diff --git a/src/client/java/com/minelittlepony/client/model/entities/ModelSeapony.java b/src/client/java/com/minelittlepony/client/model/entities/ModelSeapony.java index 7c87cfce..eddc8279 100644 --- a/src/client/java/com/minelittlepony/client/model/entities/ModelSeapony.java +++ b/src/client/java/com/minelittlepony/client/model/entities/ModelSeapony.java @@ -9,15 +9,14 @@ import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.pony.IPony; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.LivingEntity; import net.minecraft.util.math.MathHelper; import org.lwjgl.opengl.GL11; -public class ModelSeapony extends ModelUnicorn { +public class ModelSeapony extends ModelUnicorn { PonyRenderer bodyCenter; @@ -32,15 +31,15 @@ public class ModelSeapony extends ModelUnicorn { @Override public IEquestrianArmour createArmour() { - return new PonyArmor(new Armour(), new Armour()); + return new PonyArmor<>(new Armour(), new Armour()); } @Override - public void updateLivingState(EntityLivingBase entity, IPony pony) { + public void updateLivingState(T entity, IPony pony) { super.updateLivingState(entity, pony); // Seaponies can't sneak, silly - isSneak = false; + isSneaking = false; } @Override @@ -57,10 +56,10 @@ public class ModelSeapony extends ModelUnicorn { protected void initLegs(float yOffset, float stretch) { super.initLegs(yOffset, stretch); // hide the back legs - bipedLeftLeg.showModel = false; - bipedRightLeg.showModel = false; - bipedLeftLegwear.showModel = false; - bipedRightLegwear.showModel = false; + leftLeg.visible = false; + rightLeg.visible = false; + leftLegOverlay.visible = false; + rightLegOverlay.visible = false; centerFin = new PlaneRenderer(this, 58, 28) .rotate(PI / 2 - 0.1F, 0, 0).around(0, 6, 9) @@ -90,8 +89,8 @@ public class ModelSeapony extends ModelUnicorn { } @Override - public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); float flapMotion = MathHelper.cos(ticks / 10) / 5; @@ -101,41 +100,41 @@ public class ModelSeapony extends ModelUnicorn { float finAngle = FIN_ROT_Y + flapMotion; - leftFin.rotateAngleY = finAngle; - rightFin.rotateAngleY = -finAngle; + leftFin.yaw = finAngle; + rightFin.yaw = -finAngle; if (!isSleeping()) { - centerFin.rotateAngleZ = flapMotion; + centerFin.roll = flapMotion; } if (!entity.isInWater()) { - bipedLeftArm.rotateAngleX -= 0.5F; - bipedRightArm.rotateAngleX -= 0.5F; + leftArm.pitch -= 0.5F; + rightArm.pitch -= 0.5F; } if (!entity.isInWater() || entity.onGround) { - bipedLeftArm.rotateAngleY -= 0.5F; - bipedRightArm.rotateAngleY += 0.5F; + leftArm.yaw -= 0.5F; + rightArm.yaw += 0.5F; } } @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); - bipedLeftArm.rotateAngleX -= 1.4F; - bipedLeftArm.rotateAngleY -= 0.3F; - bipedRightArm.rotateAngleX -= 1.4F; - bipedRightArm.rotateAngleY += 0.3F; + leftArm.pitch -= 1.4F; + leftArm.yaw -= 0.3F; + rightArm.pitch -= 1.4F; + rightArm.yaw += 0.3F; } @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); } @Override - public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { - setVisible(bipedLeftArmwear.showModel); + public void render(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + setVisible(leftArmOverlay.visible); super.render(entity, move, swing, ticks, headYaw, headPitch, scale); } @@ -148,12 +147,12 @@ public class ModelSeapony extends ModelUnicorn { } @Override - protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { - bipedBody.render(scale); + protected void renderBody(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + body.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); GlStateManager.enableBlend(); @@ -178,30 +177,30 @@ public class ModelSeapony extends ModelUnicorn { super.setVisible(visible); // hide the back legs - bipedLeftLeg.showModel = false; - bipedRightLeg.showModel = false; - bipedLeftLegwear.showModel = false; - bipedRightLegwear.showModel = false; + leftLeg.visible = false; + rightLeg.visible = false; + leftLegOverlay.visible = false; + rightLegOverlay.visible = false; } - class Armour extends ModelPonyArmor { + class Armour extends ModelPonyArmor { @Override public void showBoots() { - bipedRightArm.showModel = true; - bipedLeftArm.showModel = true; + rightArm.visible = true; + leftArm.visible = true; } @Override - public void updateLivingState(EntityLivingBase entity, IPony pony) { + public void updateLivingState(T entity, IPony pony) { super.updateLivingState(entity, pony); // Seaponies can't sneak, silly - isSneak = false; + isSneaking = false; } @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); } diff --git a/src/client/java/com/minelittlepony/client/model/entities/ModelSkeletonPony.java b/src/client/java/com/minelittlepony/client/model/entities/ModelSkeletonPony.java index c06be481..03797b20 100644 --- a/src/client/java/com/minelittlepony/client/model/entities/ModelSkeletonPony.java +++ b/src/client/java/com/minelittlepony/client/model/entities/ModelSkeletonPony.java @@ -1,34 +1,32 @@ package com.minelittlepony.client.model.entities; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.AbstractSkeleton; -import net.minecraft.entity.monster.EntityWitherSkeleton; -import net.minecraft.init.Items; +import net.minecraft.entity.mob.WitherSkeletonEntity; +import net.minecraft.entity.mob.HostileEntity; +import net.minecraft.item.Items; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumHand; -import net.minecraft.util.EnumHandSide; +import net.minecraft.util.AbsoluteHand; +import net.minecraft.util.Hand; import com.minelittlepony.client.model.ModelMobPony; -public class ModelSkeletonPony extends ModelMobPony { +public class ModelSkeletonPony extends ModelMobPony { public boolean isUnicorn; public boolean isWithered; @Override - public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { - isUnicorn = entity.getUniqueID().getLeastSignificantBits() % 3 != 0; - isWithered = entity instanceof EntityWitherSkeleton; + public void animateModel(T entity, float move, float swing, float ticks) { + isUnicorn = entity.getUuid().getLeastSignificantBits() % 3 != 0; + isWithered = entity instanceof WitherSkeletonEntity; rightArmPose = ArmPose.EMPTY; leftArmPose = ArmPose.EMPTY; - ItemStack mainHand = entity.getHeldItem(EnumHand.MAIN_HAND); - ItemStack offHand = entity.getHeldItem(EnumHand.OFF_HAND); + ItemStack mainHand = entity.getStackInHand(Hand.MAIN_HAND); + ItemStack offHand = entity.getStackInHand(Hand.OFF_HAND); - boolean right = entity.getPrimaryHand() == EnumHandSide.RIGHT; + boolean right = entity.getMainHand() == AbsoluteHand.RIGHT; if (!offHand.isEmpty()) { if (right) { @@ -39,7 +37,7 @@ public class ModelSkeletonPony extends ModelMobPony { } 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) { rightArmPose = pose; @@ -49,25 +47,25 @@ public class ModelSkeletonPony extends ModelMobPony { } - super.setLivingAnimations(entity, move, swing, ticks); + super.animateModel(entity, move, swing, ticks); } @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); if (rightArmPose != ArmPose.EMPTY) { if (canCast()) { - rotateArmHolding(unicornArmRight, -1, swingProgress, ticks); + rotateArmHolding(unicornArmRight, -1, getSwingAmount(), ticks); } else { - rotateArmHolding(bipedRightArm, -1, swingProgress, ticks); + rotateArmHolding(rightArm, -1, getSwingAmount(), ticks); } } if (leftArmPose != ArmPose.EMPTY) { if (canCast()) { - rotateArmHolding(unicornArmLeft, -1, swingProgress, ticks); + rotateArmHolding(unicornArmLeft, -1, getSwingAmount(), ticks); } else { - rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); + rotateArmHolding(leftArm, -1, getSwingAmount(), ticks); } } } diff --git a/src/client/java/com/minelittlepony/client/model/entities/ModelVillagerPony.java b/src/client/java/com/minelittlepony/client/model/entities/ModelVillagerPony.java index a8c63d06..71bb0170 100644 --- a/src/client/java/com/minelittlepony/client/model/entities/ModelVillagerPony.java +++ b/src/client/java/com/minelittlepony/client/model/entities/ModelVillagerPony.java @@ -1,20 +1,19 @@ package com.minelittlepony.client.model.entities; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityZombieVillager; -import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.LivingEntity; +import net.minecraft.village.VillagerDataContainer; +import net.minecraft.village.VillagerProfession; import com.minelittlepony.client.model.ModelMobPony; import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.pony.meta.Wearable; -public class ModelVillagerPony extends ModelMobPony { +public class ModelVillagerPony extends ModelMobPony { public PlaneRenderer apron; public PlaneRenderer trinket; - private int profession; + private VillagerProfession profession; public boolean special; public boolean special2; @@ -22,25 +21,25 @@ public class ModelVillagerPony extends ModelMobPony { @Override protected void shakeBody(float move, float swing, float bodySwing, float ticks) { super.shakeBody(move, swing, bodySwing, ticks); - apron.rotateAngleY = bodySwing; - trinket.rotateAngleY = bodySwing; + apron.yaw = bodySwing; + trinket.yaw = bodySwing; } @Override - public void setLivingAnimations(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTickTime) { - profession = getProfession(entity); - special = "Derpy".equals(entity.getCustomName().getUnformattedComponentText()); - special2 = special && entity.getUniqueID().getLeastSignificantBits() % 20 == 0; + public void animateModel(T entity, float limbSwing, float limbSwingAmount, float partialTickTime) { + profession = entity.getVillagerData().getProfession(); + special = "Derpy".equals(entity.getCustomName().getString()); + special2 = special && entity.getUuid().getLeastSignificantBits() % 20 == 0; } @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); - if (!special) { - if (profession == 2) { + if (!special && profession != VillagerProfession.NONE && profession != VillagerProfession.NITWIT) { + if (profession == VillagerProfession.BUTCHER) { trinket.render(scale); - } else if (profession > 2) { + } else { apron.render(scale); } } @@ -54,7 +53,7 @@ public class ModelVillagerPony extends ModelMobPony { @Override public boolean isWearing(Wearable wearable) { if (wearable == Wearable.SADDLE_BAGS) { - return !special && profession > -1 && profession < 2; + return !special && profession != VillagerProfession.NONE && profession == VillagerProfession.NITWIT; } if (wearable == Wearable.MUFFIN) { @@ -64,17 +63,6 @@ public class ModelVillagerPony extends ModelMobPony { 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 public void init(float yOffset, float stretch) { super.init(yOffset, stretch); diff --git a/src/client/java/com/minelittlepony/client/model/entities/ModelWitchPony.java b/src/client/java/com/minelittlepony/client/model/entities/ModelWitchPony.java index 8ff9fd7d..d7032fa5 100644 --- a/src/client/java/com/minelittlepony/client/model/entities/ModelWitchPony.java +++ b/src/client/java/com/minelittlepony/client/model/entities/ModelWitchPony.java @@ -1,38 +1,35 @@ package com.minelittlepony.client.model.entities; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.entity.mob.WitchEntity; import net.minecraft.util.math.MathHelper; import com.minelittlepony.client.model.races.ModelZebra; import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.meta.Wearable; -public class ModelWitchPony extends ModelZebra { +public class ModelWitchPony extends ModelZebra { public ModelWitchPony() { super(false); } @Override - public void updateLivingState(EntityLivingBase entity, IPony pony) { + public void updateLivingState(WitchEntity entity, IPony pony) { super.updateLivingState(entity, pony); - EntityWitch witch = ((EntityWitch) entity); - if ("Filly".equals(entity.getCustomName().getUnformattedComponentText())) { + if ("Filly".equals(entity.getCustomName().getString())) { isChild = true; } leftArmPose = ArmPose.EMPTY; - rightArmPose = witch.getHeldItemMainhand().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM; + rightArmPose = entity.getMainHandStack().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM; } @Override - public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + public void setAngles(WitchEntity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); - if (((EntityWitch)entity).isDrinkingPotion()) { - float noseRot = MathHelper.sin(entity.ticksExisted); + if (entity.isDrinking()) { + float noseRot = MathHelper.sin(entity.age); snout.rotate(noseRot * 4.5F * 0.02F, 0, noseRot * 2.5F * 0.02F); } else { @@ -47,20 +44,20 @@ public class ModelWitchPony extends ModelZebra { float legDrinkingAngle = -1 * PI/3 + rot; - bipedRightArm.rotateAngleX = legDrinkingAngle; - bipedRightArmwear.rotateAngleX = legDrinkingAngle; - bipedRightArm.rotateAngleY = 0.1F; - bipedRightArmwear.rotateAngleY = 0.1F; - bipedRightArm.offsetZ = 0.1f; - bipedRightArmwear.offsetZ = 0.1f; + rightArm.pitch = legDrinkingAngle; + rightArmOverlay.pitch = legDrinkingAngle; + rightArm.yaw = 0.1F; + rightArmOverlay.yaw = 0.1F; + rightArm.z = 0.1f; + rightArmOverlay.z = 0.1f; if (rot > 0) rot = 0; - bipedHead.rotateAngleX = -rot / 2; - bipedHeadwear.rotateAngleX = -rot / 2; + head.pitch = -rot / 2; + headwear.pitch = -rot / 2; } else { - bipedRightArm.offsetZ = 0; - bipedRightArmwear.offsetZ = 0; + rightArm.z = 0; + rightArmOverlay.z = 0; } diff --git a/src/client/java/com/minelittlepony/client/model/entities/ModelZombiePony.java b/src/client/java/com/minelittlepony/client/model/entities/ModelZombiePony.java index aa71dd6f..0d7e378e 100644 --- a/src/client/java/com/minelittlepony/client/model/entities/ModelZombiePony.java +++ b/src/client/java/com/minelittlepony/client/model/entities/ModelZombiePony.java @@ -3,30 +3,29 @@ package com.minelittlepony.client.model.entities; import com.minelittlepony.client.model.ModelMobPony; import com.minelittlepony.client.util.render.AbstractRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.mob.HostileEntity; import net.minecraft.util.math.MathHelper; -public class ModelZombiePony extends ModelMobPony { +public class ModelZombiePony extends ModelMobPony { public boolean isPegasus; @Override - public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { - isPegasus = entity.getUniqueID().getLeastSignificantBits() % 30 == 0; + public void animateModel(Zombie entity, float move, float swing, float ticks) { + isPegasus = entity.getUuid().getLeastSignificantBits() % 30 == 0; } @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); if (rightArmPose != ArmPose.EMPTY) return; if (islookAngleRight(move)) { - rotateArmHolding(bipedRightArm, 1, swingProgress, ticks); - AbstractRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); + rotateArmHolding(rightArm, 1, getSwingAmount(), ticks); + AbstractRenderer.shiftRotationPoint(rightArm, 0.5F, 1.5F, 3); } else { - rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); - AbstractRenderer.shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); + rotateArmHolding(leftArm, -1, getSwingAmount(), ticks); + AbstractRenderer.shiftRotationPoint(leftArm, -0.5F, 1.5F, 3); } } diff --git a/src/client/java/com/minelittlepony/client/model/entities/ModelZombieVillagerPony.java b/src/client/java/com/minelittlepony/client/model/entities/ModelZombieVillagerPony.java index 7e362500..5c805083 100644 --- a/src/client/java/com/minelittlepony/client/model/entities/ModelZombieVillagerPony.java +++ b/src/client/java/com/minelittlepony/client/model/entities/ModelZombieVillagerPony.java @@ -1,23 +1,23 @@ package com.minelittlepony.client.model.entities; -import net.minecraft.entity.Entity; +import net.minecraft.entity.mob.ZombieVillagerEntity; import net.minecraft.util.math.MathHelper; import com.minelittlepony.client.util.render.AbstractRenderer; -public class ModelZombieVillagerPony extends ModelVillagerPony { +public class ModelZombieVillagerPony extends ModelVillagerPony { @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); if (rightArmPose != ArmPose.EMPTY) return; if (islookAngleRight(move)) { - rotateArmHolding(bipedRightArm, 1, swingProgress, ticks); - AbstractRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3); + rotateArmHolding(rightArm, 1, getSwingAmount(), ticks); + AbstractRenderer.shiftRotationPoint(rightArm, 0.5F, 1.5F, 3); } else { - rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks); - AbstractRenderer.shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3); + rotateArmHolding(leftArm, -1, getSwingAmount(), ticks); + AbstractRenderer.shiftRotationPoint(leftArm, -0.5F, 1.5F, 3); } } diff --git a/src/client/java/com/minelittlepony/client/model/entities/package-info.java b/src/client/java/com/minelittlepony/client/model/entities/package-info.java index ce06723a..a1c17c0d 100644 --- a/src/client/java/com/minelittlepony/client/model/entities/package-info.java +++ b/src/client/java/com/minelittlepony/client/model/entities/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.model.entities; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/model/gear/AbstractGear.java b/src/client/java/com/minelittlepony/client/model/gear/AbstractGear.java index e4716f65..1c80c2a7 100644 --- a/src/client/java/com/minelittlepony/client/model/gear/AbstractGear.java +++ b/src/client/java/com/minelittlepony/client/model/gear/AbstractGear.java @@ -1,15 +1,15 @@ package com.minelittlepony.client.model.gear; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.model.Model; +import net.minecraft.client.texture.TextureManager; import net.minecraft.entity.Entity; 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() { textureWidth = 64; @@ -22,10 +22,10 @@ public abstract class AbstractGear extends ModelBase implements IGear, PonyModel public void renderSeparately(Entity entity, float scale) { GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - TextureManager tex = Minecraft.getInstance().getRenderManager().textureManager; + TextureManager tex = MinecraftClient.getInstance().getEntityRenderManager().textureManager; tex.bindTexture(getTexture(entity)); - renderPart(scale, entity.getUniqueID()); + renderPart(scale, entity.getUuid()); GL11.glPopAttrib(); } diff --git a/src/client/java/com/minelittlepony/client/model/gear/ChristmasHat.java b/src/client/java/com/minelittlepony/client/model/gear/ChristmasHat.java index 41e1eb08..3765d35d 100644 --- a/src/client/java/com/minelittlepony/client/model/gear/ChristmasHat.java +++ b/src/client/java/com/minelittlepony/client/model/gear/ChristmasHat.java @@ -1,15 +1,15 @@ package com.minelittlepony.client.model.gear; import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import org.lwjgl.opengl.GL11; -import com.minelittlepony.client.model.IClientModel; import com.minelittlepony.client.util.render.Color; import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.IPonyModel; import com.minelittlepony.pony.meta.Wearable; import java.util.Calendar; @@ -17,7 +17,7 @@ import java.util.UUID; 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 right; @@ -26,7 +26,7 @@ public class ChristmasHat extends AbstractGear { @Override public void init(float yOffset, float stretch) { - this.boxList.clear(); + this.cuboidList.clear(); left = new PonyRenderer(this, 0, 0).size(16, 8) .around(-7, 0.5F, 0.5F) @@ -48,12 +48,12 @@ public class ChristmasHat extends AbstractGear { } @Override - public boolean canRender(IClientModel model, Entity entity) { + public boolean canRender(IPonyModel model, Entity entity) { return isChristmasDay() || model.isWearing(Wearable.ANTLERS); } @Override - public void setLivingAnimations(IClientModel model, Entity entity) { + public void setLivingAnimations(IPonyModel model, Entity entity) { tint = model.getMetadata().getGlowColor(); } @@ -68,8 +68,8 @@ public class ChristmasHat extends AbstractGear { bodySwing += 0.1F; - left.rotateAngleZ = bodySwing; - right.rotateAngleZ = -bodySwing; + left.roll = bodySwing; + right.roll = -bodySwing; } private boolean isChristmasDay() { @@ -84,7 +84,7 @@ public class ChristmasHat extends AbstractGear { } @Override - public ResourceLocation getTexture(Entity entity) { + public Identifier getTexture(Entity entity) { return TEXTURE; } diff --git a/src/client/java/com/minelittlepony/client/model/gear/Muffin.java b/src/client/java/com/minelittlepony/client/model/gear/Muffin.java index c4143f79..d19086c2 100644 --- a/src/client/java/com/minelittlepony/client/model/gear/Muffin.java +++ b/src/client/java/com/minelittlepony/client/model/gear/Muffin.java @@ -1,18 +1,19 @@ package com.minelittlepony.client.model.gear; 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.model.BodyPart; +import com.minelittlepony.model.IPonyModel; +import com.minelittlepony.model.gear.IStackable; import com.minelittlepony.pony.meta.Wearable; import java.util.UUID; 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; @@ -33,7 +34,7 @@ public class Muffin extends AbstractGear implements IStackable { } @Override - public boolean canRender(IClientModel model, Entity entity) { + public boolean canRender(IPonyModel model, Entity entity) { return model.isWearing(Wearable.MUFFIN); } @@ -43,7 +44,7 @@ public class Muffin extends AbstractGear implements IStackable { } @Override - public ResourceLocation getTexture(Entity entity) { + public Identifier getTexture(Entity entity) { return TEXTURE; } diff --git a/src/client/java/com/minelittlepony/client/model/gear/SaddleBags.java b/src/client/java/com/minelittlepony/client/model/gear/SaddleBags.java index 73d5fffe..fd3b0877 100644 --- a/src/client/java/com/minelittlepony/client/model/gear/SaddleBags.java +++ b/src/client/java/com/minelittlepony/client/model/gear/SaddleBags.java @@ -1,16 +1,16 @@ package com.minelittlepony.client.model.gear; -import com.minelittlepony.client.model.IClientModel; import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.IPegasus; +import com.minelittlepony.model.IPonyModel; import com.minelittlepony.pony.meta.Wearable; +import com.mojang.blaze3d.platform.GlStateManager; import java.util.UUID; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; public class SaddleBags extends AbstractGear { @@ -25,7 +25,7 @@ public class SaddleBags extends AbstractGear { float dropAmount = 0; - private IClientModel model; + private IPonyModel model; @Override 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, 0, 0, 1, 3, stretch) // clip into the body .west(-4.0002F, -1, 0, 1, 3, stretch) - .rotateAngleX = ROTATE_270; + .pitch = ROTATE_270; leftBag.offset(x, y, z).around(0, 4, 4) .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) .top(0, 0, -3, 8, 3, stretch) .tex(56, 22).flipZ().bottom(0, 6, -3, 8, 3, stretch) - .rotateAngleY = ROTATE_270; + .yaw = ROTATE_270; x += 3; @@ -69,11 +69,11 @@ public class SaddleBags extends AbstractGear { .child(0).offset(z, y, x).tex(56, 16) .flipZ().top(0, 0, -3, 8, 3, stretch) .tex(56, 22).flipZ().bottom(0, 6, -3, 8, 3, stretch) - .rotateAngleY = ROTATE_270; + .yaw = ROTATE_270; } @Override - public void setLivingAnimations(IClientModel model, Entity entity) { + public void setLivingAnimations(IPonyModel model, Entity entity) { this.model = model; hangLow = false; @@ -92,16 +92,16 @@ public class SaddleBags extends AbstractGear { bodySwing = MathHelper.cos(mve + pi) * srt; - leftBag.rotateAngleX = bodySwing; - rightBag.rotateAngleX = bodySwing; + leftBag.pitch = bodySwing; + rightBag.pitch = bodySwing; if (model instanceof IPegasus && model.isFlying()) { bodySwing = ((IPegasus)model).getWingRotationFactor(ticks) - ROTATE_270; bodySwing /= 10; } - leftBag.rotateAngleZ = bodySwing; - rightBag.rotateAngleZ = -bodySwing; + leftBag.roll = bodySwing; + rightBag.roll = -bodySwing; dropAmount = hangLow ? 0.15F : 0; } @@ -126,7 +126,7 @@ public class SaddleBags extends AbstractGear { } @Override - public boolean canRender(IClientModel model, Entity entity) { + public boolean canRender(IPonyModel model, Entity entity) { return model.isWearing(Wearable.SADDLE_BAGS); } @@ -136,7 +136,7 @@ public class SaddleBags extends AbstractGear { } @Override - public ResourceLocation getTexture(Entity entity) { + public Identifier getTexture(Entity entity) { // use the default return null; } diff --git a/src/client/java/com/minelittlepony/client/model/gear/Stetson.java b/src/client/java/com/minelittlepony/client/model/gear/Stetson.java index cecb665c..c48968cb 100644 --- a/src/client/java/com/minelittlepony/client/model/gear/Stetson.java +++ b/src/client/java/com/minelittlepony/client/model/gear/Stetson.java @@ -1,18 +1,19 @@ package com.minelittlepony.client.model.gear; 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.plane.PlaneRenderer; import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.IPonyModel; +import com.minelittlepony.model.gear.IStackable; import com.minelittlepony.pony.meta.Wearable; import java.util.UUID; 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; @@ -38,7 +39,7 @@ public class Stetson extends AbstractGear implements IStackable { } @Override - public ResourceLocation getTexture(Entity entity) { + public Identifier getTexture(Entity entity) { return TEXTURE; } @@ -48,7 +49,7 @@ public class Stetson extends AbstractGear implements IStackable { } @Override - public boolean canRender(IClientModel model, Entity entity) { + public boolean canRender(IPonyModel model, Entity entity) { return model.isWearing(Wearable.STETSON); } diff --git a/src/client/java/com/minelittlepony/client/model/gear/WitchHat.java b/src/client/java/com/minelittlepony/client/model/gear/WitchHat.java index 31cd1479..f25b1884 100644 --- a/src/client/java/com/minelittlepony/client/model/gear/WitchHat.java +++ b/src/client/java/com/minelittlepony/client/model/gear/WitchHat.java @@ -1,18 +1,19 @@ package com.minelittlepony.client.model.gear; 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.model.BodyPart; +import com.minelittlepony.model.IPonyModel; +import com.minelittlepony.model.gear.IStackable; import com.minelittlepony.pony.meta.Wearable; import java.util.UUID; 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; @@ -39,7 +40,7 @@ public class WitchHat extends AbstractGear implements IStackable { @Override - public boolean canRender(IClientModel model, Entity entity) { + public boolean canRender(IPonyModel model, Entity entity) { return model.isWearing(Wearable.HAT); } @@ -49,7 +50,7 @@ public class WitchHat extends AbstractGear implements IStackable { } @Override - public ResourceLocation getTexture(Entity entity) { + public Identifier getTexture(Entity entity) { return WITCH_TEXTURES; } diff --git a/src/client/java/com/minelittlepony/client/model/gear/package-info.java b/src/client/java/com/minelittlepony/client/model/gear/package-info.java index 7aef826b..191d9195 100644 --- a/src/client/java/com/minelittlepony/client/model/gear/package-info.java +++ b/src/client/java/com/minelittlepony/client/model/gear/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.model.gear; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/model/package-info.java b/src/client/java/com/minelittlepony/client/model/package-info.java index e757659e..a5ea628f 100644 --- a/src/client/java/com/minelittlepony/client/model/package-info.java +++ b/src/client/java/com/minelittlepony/client/model/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.model; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/model/races/ModelAlicorn.java b/src/client/java/com/minelittlepony/client/model/races/ModelAlicorn.java index 596f41b8..551803e9 100644 --- a/src/client/java/com/minelittlepony/client/model/races/ModelAlicorn.java +++ b/src/client/java/com/minelittlepony/client/model/races/ModelAlicorn.java @@ -3,11 +3,11 @@ package com.minelittlepony.client.model.races; import com.minelittlepony.client.model.components.PegasusWings; 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 extends ModelUnicorn implements IPegasus { - public PegasusWings wings; + public PegasusWings> wings; public ModelAlicorn(boolean smallArms) { super(smallArms); @@ -24,19 +24,20 @@ public class ModelAlicorn extends ModelUnicorn implements IPegasus { } @Override - public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); if (canFly()) { - wings.setRotationAndAngles(rainboom, entity.getUniqueID(), move, swing, 0, ticks); + wings.setRotationAndAngles(rainboom, entity.getUuid(), move, swing, 0, ticks); } } @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); + if (canFly()) { - wings.renderPart(scale, entity.getUniqueID()); + wings.renderPart(scale, entity.getUuid()); } } } diff --git a/src/client/java/com/minelittlepony/client/model/races/ModelBatpony.java b/src/client/java/com/minelittlepony/client/model/races/ModelBatpony.java index d2bd7cb3..2dfaae7b 100644 --- a/src/client/java/com/minelittlepony/client/model/races/ModelBatpony.java +++ b/src/client/java/com/minelittlepony/client/model/races/ModelBatpony.java @@ -1,10 +1,12 @@ package com.minelittlepony.client.model.races; +import net.minecraft.entity.LivingEntity; + import com.minelittlepony.client.model.components.BatWings; import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.pony.meta.Wearable; -public class ModelBatpony extends ModelPegasus { +public class ModelBatpony extends ModelPegasus { public ModelBatpony(boolean smallArms) { super(smallArms); diff --git a/src/client/java/com/minelittlepony/client/model/races/ModelChangeling.java b/src/client/java/com/minelittlepony/client/model/races/ModelChangeling.java index c477c89d..16d56c63 100644 --- a/src/client/java/com/minelittlepony/client/model/races/ModelChangeling.java +++ b/src/client/java/com/minelittlepony/client/model/races/ModelChangeling.java @@ -1,11 +1,12 @@ package com.minelittlepony.client.model.races; +import net.minecraft.entity.LivingEntity; import net.minecraft.util.math.MathHelper; import com.minelittlepony.client.model.components.BugWings; import com.minelittlepony.pony.meta.Wearable; -public class ModelChangeling extends ModelAlicorn { +public class ModelChangeling extends ModelAlicorn { public ModelChangeling(boolean smallArms) { super(smallArms); diff --git a/src/client/java/com/minelittlepony/client/model/races/ModelEarthPony.java b/src/client/java/com/minelittlepony/client/model/races/ModelEarthPony.java index cd6e714f..f00026ab 100644 --- a/src/client/java/com/minelittlepony/client/model/races/ModelEarthPony.java +++ b/src/client/java/com/minelittlepony/client/model/races/ModelEarthPony.java @@ -3,9 +3,9 @@ package com.minelittlepony.client.model.races; import com.minelittlepony.client.model.AbstractPonyModel; 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 extends AbstractPonyModel { private final boolean smallArms; @@ -17,11 +17,11 @@ public class ModelEarthPony extends AbstractPonyModel { } @Override - public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); if (bipedCape != null) { - bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; + bipedCape.rotationPointY = isSneaking ? 2 : isRiding ? -4 : 0; } } diff --git a/src/client/java/com/minelittlepony/client/model/races/ModelPegasus.java b/src/client/java/com/minelittlepony/client/model/races/ModelPegasus.java index fbd25102..c371f836 100644 --- a/src/client/java/com/minelittlepony/client/model/races/ModelPegasus.java +++ b/src/client/java/com/minelittlepony/client/model/races/ModelPegasus.java @@ -3,11 +3,11 @@ package com.minelittlepony.client.model.races; import com.minelittlepony.client.model.components.PegasusWings; 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 extends ModelEarthPony implements IPegasus { - public PegasusWings wings; + public PegasusWings> wings; public ModelPegasus(boolean smallArms) { super(smallArms); @@ -24,14 +24,14 @@ public class ModelPegasus extends ModelEarthPony implements IPegasus { } @Override - public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) { - super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); - wings.setRotationAndAngles(rainboom, entity.getUniqueID(), move, swing, 0, ticks); + public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { + super.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); + wings.setRotationAndAngles(rainboom, entity.getUuid(), move, swing, 0, ticks); } @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); - wings.renderPart(scale, entity.getUniqueID()); + wings.renderPart(scale, entity.getUuid()); } } diff --git a/src/client/java/com/minelittlepony/client/model/races/ModelUnicorn.java b/src/client/java/com/minelittlepony/client/model/races/ModelUnicorn.java index 7ba69458..3498548f 100644 --- a/src/client/java/com/minelittlepony/client/model/races/ModelUnicorn.java +++ b/src/client/java/com/minelittlepony/client/model/races/ModelUnicorn.java @@ -4,14 +4,14 @@ import com.minelittlepony.client.model.components.UnicornHorn; import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.model.IUnicorn; -import net.minecraft.entity.Entity; -import net.minecraft.util.EnumHandSide; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.AbsoluteHand; 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. */ -public class ModelUnicorn extends ModelEarthPony implements IUnicorn { +public class ModelUnicorn extends ModelEarthPony implements IUnicorn { public PonyRenderer unicornArmRight; public PonyRenderer unicornArmLeft; @@ -29,11 +29,11 @@ public class ModelUnicorn extends ModelEarthPony implements IUnicorn -9990.0F && !isSleeping()) { + if (getSwingAmount() > -9990 && !isSleeping()) { swingArm(getUnicornArmForSide(mainSide)); } } else { @@ -92,13 +92,13 @@ public class ModelUnicorn extends ModelEarthPony implements IUnicorn extends ModelEarthPony { public PonyRenderer bristles; @@ -18,7 +19,7 @@ public class ModelZebra extends ModelEarthPony { @Override public IEquestrianArmour createArmour() { - return new PonyArmor(new Armour(), new Armour()); + return new PonyArmor<>(new Armour(), new Armour()); } @Override @@ -37,20 +38,20 @@ public class ModelZebra extends ModelEarthPony { super.initHead(yOffset, stretch); bristles = new PonyRenderer(this, 56, 32); - bipedHead.addChild(bristles); + head.addChild(bristles); bristles.offset(-1, -1, -3) .box(0, -10, 2, 2, 6, 2, stretch) .box(0, -10, 4, 2, 8, 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 .box(0, -10, 4, 2, 8, 2, stretch) .box(0, -8, 6, 2, 6, 2, stretch) - .rotateAngleX = -1F; + .pitch = -1F; } - class Armour extends ModelPonyArmor { + class Armour extends ModelPonyArmor { @Override public void transform(BodyPart part) { diff --git a/src/client/java/com/minelittlepony/client/model/races/PlayerModels.java b/src/client/java/com/minelittlepony/client/model/races/PlayerModels.java index d8cef749..11515a09 100644 --- a/src/client/java/com/minelittlepony/client/model/races/PlayerModels.java +++ b/src/client/java/com/minelittlepony/client/model/races/PlayerModels.java @@ -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.RenderSeaponyPlayer; import com.minelittlepony.hdskins.VanillaModels; +import com.minelittlepony.model.IModel; 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; @@ -25,9 +27,9 @@ public enum PlayerModels { ALICORN("alicorn", Race.ALICORN, ModelAlicorn::new), CHANGELING("changeling", Race.CHANGELING, ModelChangeling::new), ZEBRA("zebra", Race.ZEBRA, ModelZebra::new), - SEAPONY("seapony", Race.SEAPONY, a -> new ModelSeapony()) { + SEAPONY("seapony", Race.SEAPONY, a -> new ModelSeapony<>()) { @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)); } }; @@ -42,8 +44,8 @@ public enum PlayerModels { private final ModelResolver resolver; - private ModelWrapper normal; - private ModelWrapper slim; + private ModelWrapper normal; + private ModelWrapper slim; private final String normalKey, slimKey; @@ -62,28 +64,29 @@ public enum PlayerModels { this.race = race; } - public ModelWrapper getModel(boolean isSlim) { + @SuppressWarnings("unchecked") + public ModelWrapper getModel(boolean isSlim) { if (isSlim) { if (slim == null) { - slim = new ModelWrapper(resolver.resolve(isSlim)); + slim = new ModelWrapper<>(resolver.resolve(isSlim)); } - return slim; + return (ModelWrapper)slim; } if (normal == null) { - normal = new ModelWrapper(resolver.resolve(isSlim)); + normal = new ModelWrapper<>(resolver.resolve(isSlim)); } - return normal; + return (ModelWrapper)normal; } public String getId(boolean useSlimArms) { 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)); } @@ -96,6 +99,6 @@ public enum PlayerModels { */ @FunctionalInterface static interface ModelResolver { - AbstractPonyModel resolve(boolean slim); + AbstractPonyModel resolve(boolean slim); } } diff --git a/src/client/java/com/minelittlepony/client/model/races/package-info.java b/src/client/java/com/minelittlepony/client/model/races/package-info.java index d10e7ce3..a2757385 100644 --- a/src/client/java/com/minelittlepony/client/model/races/package-info.java +++ b/src/client/java/com/minelittlepony/client/model/races/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.model.races; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/package-info.java b/src/client/java/com/minelittlepony/client/package-info.java index a25a75c9..c177b8c5 100644 --- a/src/client/java/com/minelittlepony/client/package-info.java +++ b/src/client/java/com/minelittlepony/client/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/pony/Pony.java b/src/client/java/com/minelittlepony/client/pony/Pony.java index ef3ab44d..76b7828e 100644 --- a/src/client/java/com/minelittlepony/client/pony/Pony.java +++ b/src/client/java/com/minelittlepony/client/pony/Pony.java @@ -4,7 +4,7 @@ import com.google.common.base.MoreObjects; import com.minelittlepony.MineLittlePony; import com.minelittlepony.client.PonyRenderManager; 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.hdskins.util.ProfileTextureUtil; import com.minelittlepony.pony.IPony; @@ -13,22 +13,22 @@ import com.minelittlepony.pony.meta.Race; import com.minelittlepony.pony.meta.Size; import com.minelittlepony.util.chron.Touchable; -import net.minecraft.block.material.Material; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.client.renderer.texture.ITextureObject; -import net.minecraft.client.renderer.texture.MissingTextureSprite; -import net.minecraft.client.renderer.texture.NativeImage; -import net.minecraft.resources.IResource; +import net.minecraft.block.Material; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.texture.Texture; +import net.minecraft.client.texture.MissingSprite; +import net.minecraft.client.texture.NativeImage; +import net.minecraft.client.texture.NativeImageBackedTexture; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.Item; -import net.minecraft.item.ItemArmor; +import net.minecraft.item.ArmorItem; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.resource.Resource; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.BoundingBox; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -46,15 +46,15 @@ public class Pony extends Touchable implements IPony { private final int ponyId = ponyCount.getAndIncrement(); - private final ResourceLocation texture; + private final Identifier texture; private final IPonyData metadata; - public Pony(ResourceLocation resource) { + public Pony(Identifier resource) { texture = resource; metadata = checkSkin(texture); } - private IPonyData checkSkin(ResourceLocation resource) { + private IPonyData checkSkin(Identifier resource) { IPonyData data = checkPonyMeta(resource); if (data != null) { return data; @@ -63,25 +63,23 @@ public class Pony extends Touchable implements IPony { NativeImage ponyTexture = getBufferedImage(resource); 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); } @Nullable - private IPonyData checkPonyMeta(ResourceLocation resource) { + private IPonyData checkPonyMeta(Identifier resource) { 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) { - return data; - } + if (data != null) { + return data; } } catch (FileNotFoundException e) { // Ignore uploaded texture @@ -93,20 +91,20 @@ public class Pony extends Touchable implements IPony { } @Nullable - public static NativeImage getBufferedImage(@Nonnull ResourceLocation resource) { + public static NativeImage getBufferedImage(@Nonnull Identifier resource) { try { - IResource skin = Minecraft.getInstance().getResourceManager().getResource(resource); - NativeImage skinImage = NativeImage.read(skin.getInputStream()); + Resource skin = MinecraftClient.getInstance().getResourceManager().getResource(resource); + NativeImage skinImage = NativeImage.fromInputStream(skin.getInputStream()); MineLittlePony.logger.debug("Obtained skin from resource location {}", resource); return skinImage; } catch (IOException ignored) { } - ITextureObject texture = Minecraft.getInstance().getTextureManager().getTexture(resource); + Texture texture = MinecraftClient.getInstance().getTextureManager().getTexture(resource); - if (texture instanceof DynamicTexture) { - return ((DynamicTexture)texture).getTextureData(); + if (texture instanceof NativeImageBackedTexture) { + return ((NativeImageBackedTexture)texture).getImage(); } if (texture instanceof IBufferedTexture) { @@ -122,14 +120,15 @@ public class Pony extends Touchable implements IPony { } @Override - public boolean isPerformingRainboom(EntityLivingBase entity) { - double zMotion = Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ); + public boolean isPerformingRainboom(LivingEntity entity) { + 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 - public boolean isCrouching(EntityLivingBase entity) { + public boolean isCrouching(LivingEntity entity) { boolean isSneak = entity.isSneaking(); boolean isFlying = isFlying(entity); @@ -139,40 +138,40 @@ public class Pony extends Touchable implements IPony { } @Override - public boolean isFlying(EntityLivingBase entity) { + public boolean isFlying(LivingEntity entity) { return !(entity.onGround - || entity.isPassenger() - || (entity.isOnLadder() && !(entity instanceof EntityPlayer && ((EntityPlayer)entity).abilities.isFlying)) + || entity.hasVehicle() + || (entity.isClimbing() && !(entity instanceof PlayerEntity && ((PlayerEntity)entity).abilities.allowFlying)) || entity.isInWater() - || entity.isPlayerSleeping()); + || entity.isSleeping()); } @Override - public boolean isSwimming(EntityLivingBase entity) { - return isFullySubmerged(entity) && !(entity.onGround || entity.isOnLadder()); + public boolean isSwimming(LivingEntity entity) { + return isFullySubmerged(entity) && !(entity.onGround || entity.isClimbing()); } @Override - public boolean isPartiallySubmerged(EntityLivingBase entity) { + public boolean isPartiallySubmerged(LivingEntity entity) { 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 - public boolean isFullySubmerged(EntityLivingBase entity) { + public boolean isFullySubmerged(LivingEntity entity) { return entity.isInWater() && entity.getEntityWorld().getBlockState(new BlockPos(getVisualEyePosition(entity))).getMaterial() == Material.WATER; } - protected Vec3d getVisualEyePosition(EntityLivingBase entity) { - Size size = entity.isChild() ? Size.FOAL : metadata.getSize(); + protected Vec3d getVisualEyePosition(LivingEntity entity) { + 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 - public boolean isWearingHeadgear(EntityLivingBase entity) { - ItemStack stack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); + public boolean isWearingHeadgear(LivingEntity entity) { + ItemStack stack = entity.getEquippedStack(EquipmentSlot.HEAD); if (stack.isEmpty()) { return false; @@ -180,7 +179,7 @@ public class Pony extends Touchable implements IPony { Item item = stack.getItem(); - return !(item instanceof ItemArmor) || ((ItemArmor) item).getEquipmentSlot() != EntityEquipmentSlot.HEAD; + return !(item instanceof ArmorItem) || ((ArmorItem) item).getSlotType() != EquipmentSlot.HEAD; } @Override @@ -189,7 +188,7 @@ public class Pony extends Touchable implements IPony { } @Override - public ResourceLocation getTexture() { + public Identifier getTexture() { return texture; } @@ -199,48 +198,48 @@ public class Pony extends Touchable implements IPony { } @Override - public boolean isRidingInteractive(EntityLivingBase entity) { - return PonyRenderManager.getInstance().getPonyRenderer(entity.getRidingEntity()) != null; + public boolean isRidingInteractive(LivingEntity entity) { + return PonyRenderManager.getInstance().getPonyRenderer(entity.getVehicle()) != null; } @Override - public IPony getMountedPony(EntityLivingBase entity) { - Entity mount = entity.getRidingEntity(); + public IPony getMountedPony(LivingEntity entity) { + Entity mount = entity.getVehicle(); - IRenderPony render = PonyRenderManager.getInstance().getPonyRenderer(mount); + IPonyRender render = PonyRenderManager.getInstance().getPonyRenderer(mount); - return render == null ? null : render.getEntityPony((EntityLivingBase)mount); + return render == null ? null : render.getEntityPony((LivingEntity)mount); } @Override - public Vec3d getAbsoluteRidingOffset(EntityLivingBase entity) { + public Vec3d getAbsoluteRidingOffset(LivingEntity entity) { IPony ridingPony = getMountedPony(entity); if (ridingPony != null) { - EntityLivingBase ridee = (EntityLivingBase)entity.getRidingEntity(); + LivingEntity ridee = (LivingEntity)entity.getVehicle(); Vec3d offset = PonyTransformation.forSize(ridingPony.getMetadata().getSize()).getRiderOffset(); float scale = ridingPony.getMetadata().getSize().getScaleFactor(); 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 - public AxisAlignedBB getComputedBoundingBox(EntityLivingBase entity) { + public BoundingBox getComputedBoundingBox(LivingEntity entity) { float scale = getMetadata().getSize().getScaleFactor() + 0.1F; Vec3d pos = getAbsoluteRidingOffset(entity); - float width = entity.width * scale; + float width = entity.getWidth() * scale; - return new AxisAlignedBB( - - width, (entity.height * scale), -width, + return new BoundingBox( + - width, (entity.getHeight() * scale), -width, width, 0, width).offset(pos); } diff --git a/src/client/java/com/minelittlepony/client/pony/PonyData.java b/src/client/java/com/minelittlepony/client/pony/PonyData.java index e7e36ce3..bef66570 100644 --- a/src/client/java/com/minelittlepony/client/pony/PonyData.java +++ b/src/client/java/com/minelittlepony/client/pony/PonyData.java @@ -1,6 +1,6 @@ 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.gson.annotations.Expose; diff --git a/src/client/java/com/minelittlepony/client/pony/PonyDataSerialiser.java b/src/client/java/com/minelittlepony/client/pony/PonyDataSerialiser.java index 1fced28f..d4b0e465 100644 --- a/src/client/java/com/minelittlepony/client/pony/PonyDataSerialiser.java +++ b/src/client/java/com/minelittlepony/client/pony/PonyDataSerialiser.java @@ -3,21 +3,22 @@ package com.minelittlepony.client.pony; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; -import net.minecraft.resources.data.IMetadataSectionSerializer; -class PonyDataSerialiser implements IMetadataSectionSerializer { +import net.minecraft.resource.metadata.ResourceMetadataReader; + +class PonyDataSerialiser implements ResourceMetadataReader { private static final Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .create(); @Override - public String getSectionName() { + public String getKey() { return "pony"; } @Override - public PonyData deserialize(JsonObject json) { + public PonyData fromJson(JsonObject json) { return gson.fromJson(json, PonyData.class); } } diff --git a/src/client/java/com/minelittlepony/client/pony/PonyManager.java b/src/client/java/com/minelittlepony/client/pony/PonyManager.java index 813ad430..6a62eb14 100644 --- a/src/client/java/com/minelittlepony/client/pony/PonyManager.java +++ b/src/client/java/com/minelittlepony/client/pony/PonyManager.java @@ -15,15 +15,16 @@ import com.minelittlepony.util.math.MathUtil; import javax.annotation.Nullable; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.resources.IResource; -import net.minecraft.resources.IResourceManager; -import net.minecraft.resources.IResourceManagerReloadListener; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.DefaultSkinHelper; +import net.minecraft.resource.Resource; +import net.minecraft.resource.ResourceManager; +import net.minecraft.resource.ResourceReloadListener; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Identifier; +import net.minecraft.util.profiler.Profiler; import java.io.IOException; import java.io.InputStreamReader; @@ -33,36 +34,38 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; 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. * */ -public class PonyManager implements IPonyManager, IResourceManagerReloadListener, ISkinCacheClearListener { +public class PonyManager implements IPonyManager, ResourceReloadListener, ISkinCacheClearListener { private static final Gson GSON = new Gson(); /** * All currently loaded background ponies. */ - private List backgroundPonyList = Lists.newArrayList(); + private List backgroundPonyList = Lists.newArrayList(); private final PonyConfig config; - private final ChronicCache poniesCache = new ChronicCache<>(); + private final ChronicCache poniesCache = new ChronicCache<>(); public PonyManager(PonyConfig config) { this.config = config; } @Override - public IPony getPony(ResourceLocation resource) { + public IPony getPony(Identifier resource) { return poniesCache.retrieve(resource, Pony::new); } @Override - public IPony getPony(EntityPlayer player) { - ResourceLocation skin = getSkin(player); + public IPony getPony(PlayerEntity player) { + Identifier skin = getSkin(player); UUID uuid = player.getGameProfile().getId(); if (Pony.getBufferedImage(skin) == null) { @@ -73,17 +76,17 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener } @Nullable - ResourceLocation getSkin(EntityPlayer player) { - if (player instanceof AbstractClientPlayer) { - return ((AbstractClientPlayer)player).getLocationSkin(); + Identifier getSkin(PlayerEntity player) { + if (player instanceof AbstractClientPlayerEntity) { + return ((AbstractClientPlayerEntity)player).getSkinTexture(); } return null; } - public IPony getPony(NetworkPlayerInfo playerInfo) { - ResourceLocation skin = playerInfo.getLocationSkin(); - UUID uuid = playerInfo.getGameProfile().getId(); + public IPony getPony(PlayerListEntry playerInfo) { + Identifier skin = playerInfo.getSkinTexture(); + UUID uuid = playerInfo.getProfile().getId(); if (Pony.getBufferedImage(skin) == null) { return getDefaultPony(uuid); @@ -93,7 +96,7 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener } @Override - public IPony getPony(ResourceLocation resource, UUID uuid) { + public IPony getPony(Identifier resource, UUID uuid) { IPony pony = getPony(resource); if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) { @@ -106,7 +109,7 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener @Override public IPony getDefaultPony(UUID uuid) { if (config.getPonyLevel() != PonyLevel.PONIES) { - return getPony(DefaultPlayerSkin.getDefaultSkin(uuid)); + return getPony(DefaultSkinHelper.getTexture(uuid)); } return getBackgroundPony(uuid); @@ -124,31 +127,39 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener } 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 - public IPony removePony(ResourceLocation resource) { + public IPony removePony(Identifier resource) { return poniesCache.remove(resource); } @Override - public void onResourceManagerReload(IResourceManager resourceManager) { + public CompletableFuture 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(); backgroundPonyList.clear(); - List collectedPaths = new LinkedList<>(); + List collectedPaths = new LinkedList<>(); List collectedPonies = new LinkedList<>(); Queue processingQueue = new LinkedList<>(); - for (String domain : resourceManager.getResourceNamespaces()) { - processingQueue.addAll(loadBgPonies(resourceManager, new ResourceLocation(domain, BGPONIES_JSON))); + for (String domain : resourceManager.getAllNamespaces()) { + processingQueue.addAll(loadBgPonies(resourceManager, new Identifier(domain, BGPONIES_JSON))); } BackgroundPonies item; while ((item = processingQueue.poll()) != null) { - for (ResourceLocation imp : item.getImports()) { + for (Identifier imp : item.getImports()) { if (!collectedPaths.contains(imp)) { collectedPaths.add(imp); processingQueue.addAll(loadBgPonies(resourceManager, imp)); @@ -171,13 +182,13 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener MineLittlePony.logger.info("Detected {} background ponies installed.", getNumberOfPonies()); } - private Queue loadBgPonies(IResourceManager resourceManager, ResourceLocation location) { + private Queue loadBgPonies(ResourceManager resourceManager, Identifier location) { Queue collectedPonies = new LinkedList<>(); try { 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()))) { BackgroundPonies ponies = GSON.fromJson(reader, BackgroundPonies.class); @@ -186,7 +197,7 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener collectedPonies.add(ponies); } 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) { @@ -211,19 +222,19 @@ public class PonyManager implements IPonyManager, IResourceManagerReloadListener private String domain; private String path; - private ResourceLocation apply(String input) { - return new ResourceLocation(domain, String.format("%s%s.png", path, input)); + private Identifier apply(String input) { + return new Identifier(domain, String.format("%s%s.png", path, input)); } - private ResourceLocation makeImport(String input) { - return new ResourceLocation(domain, String.format("%s%s/bgponies.json", path, input)); + private Identifier makeImport(String input) { + return new Identifier(domain, String.format("%s%s/bgponies.json", path, input)); } - public List getPonies() { + public List getPonies() { return MoreStreams.map(ponies, this::apply); } - public List getImports() { + public List getImports() { return MoreStreams.map(imports, this::makeImport); } } diff --git a/src/client/java/com/minelittlepony/client/pony/package-info.java b/src/client/java/com/minelittlepony/client/pony/package-info.java index 02842e96..44794b26 100644 --- a/src/client/java/com/minelittlepony/client/pony/package-info.java +++ b/src/client/java/com/minelittlepony/client/pony/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.pony; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/render/DebugBoundingBoxRenderer.java b/src/client/java/com/minelittlepony/client/render/DebugBoundingBoxRenderer.java index dd8d156f..df3718cd 100644 --- a/src/client/java/com/minelittlepony/client/render/DebugBoundingBoxRenderer.java +++ b/src/client/java/com/minelittlepony/client/render/DebugBoundingBoxRenderer.java @@ -1,15 +1,14 @@ package com.minelittlepony.client.render; -import net.minecraft.client.Minecraft; - -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.WorldRenderer; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.math.BoundingBox; import com.minelittlepony.pony.IPony; -import static net.minecraft.client.renderer.GlStateManager.*; +import static com.mojang.blaze3d.platform.GlStateManager.*; public class DebugBoundingBoxRenderer { @@ -18,31 +17,31 @@ public class DebugBoundingBoxRenderer { private DebugBoundingBoxRenderer() { } - public void render(IPony pony, EntityLivingBase entity, float ticks) { - Minecraft mc = Minecraft.getInstance(); - EntityPlayer player = mc.player; + public void render(IPony pony, LivingEntity entity, float ticks) { + MinecraftClient mc = MinecraftClient.getInstance(); + PlayerEntity player = mc.player; - if (!mc.getRenderManager().isDebugBoundingBox() || entity.getDistanceSq(player) > 70) { + if (!mc.getEntityRenderManager().shouldRenderHitboxes() || entity.squaredDistanceTo(player) > 70) { return; } - AxisAlignedBB boundingBox = pony.getComputedBoundingBox(entity); + BoundingBox boundingBox = pony.getComputedBoundingBox(entity); - double renderPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)ticks; - double renderPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)ticks; - double renderPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)ticks; + double renderPosX = player.prevX + (player.x - player.prevX) * (double)ticks; + double renderPosY = player.prevY + (player.y - player.prevY) * (double)ticks; + double renderPosZ = player.prevZ + (player.z - player.prevZ) * (double)ticks; enableBlend(); blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); lineWidth(2); - disableTexture2D(); + disableTexture(); 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); - enableTexture2D(); + enableTexture(); disableBlend(); } } diff --git a/src/client/java/com/minelittlepony/client/render/FrustrumCheck.java b/src/client/java/com/minelittlepony/client/render/FrustrumCheck.java index bfb8e8f0..f44ad3e8 100644 --- a/src/client/java/com/minelittlepony/client/render/FrustrumCheck.java +++ b/src/client/java/com/minelittlepony/client/render/FrustrumCheck.java @@ -1,40 +1,40 @@ package com.minelittlepony.client.render; -import net.minecraft.client.renderer.culling.ICamera; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.client.render.VisibleRegion; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.BoundingBox; import com.minelittlepony.pony.IPony; -public class FrustrumCheck implements ICamera { +public class FrustrumCheck implements VisibleRegion { private T entity; - private ICamera vanilla; + private VisibleRegion vanilla; - private final RenderPony renderer; + private final RenderPony renderer; - public FrustrumCheck(RenderPony render) { + public FrustrumCheck(RenderPony render) { renderer = render; } - public ICamera withCamera(T entity, ICamera vanillaFrustrum) { + public VisibleRegion withCamera(T entity, VisibleRegion vanillaFrustrum) { this.entity = entity; vanilla = vanillaFrustrum; return this; } @Override - public boolean isBoundingBoxInFrustum(AxisAlignedBB bounds) { + public boolean intersects(BoundingBox bounds) { IPony pony = renderer.getPony(entity); - AxisAlignedBB boundingBox = pony.getComputedBoundingBox(entity); + BoundingBox boundingBox = pony.getComputedBoundingBox(entity); - return vanilla.isBoundingBoxInFrustum(boundingBox); + return vanilla.intersects(boundingBox); } @Override - public void setPosition(double x, double y, double z) { - vanilla.setPosition(x, y, z); + public void setOrigin(double x, double y, double z) { + vanilla.setOrigin(x, y, z); } } diff --git a/src/client/java/com/minelittlepony/client/render/IPonyRender.java b/src/client/java/com/minelittlepony/client/render/IPonyRender.java new file mode 100644 index 00000000..d1a97658 --- /dev/null +++ b/src/client/java/com/minelittlepony/client/render/IPonyRender.java @@ -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 & IPonyModel> extends PonyModelConstants { + + /** + * Gets the wrapped pony model for this renderer. + */ + ModelWrapper getModelWrapper(); + + IPony getEntityPony(T entity); + + RenderPony 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); + } + } +} diff --git a/src/client/java/com/minelittlepony/client/render/LevitatingItemRenderer.java b/src/client/java/com/minelittlepony/client/render/LevitatingItemRenderer.java index af9f3559..a508ef47 100644 --- a/src/client/java/com/minelittlepony/client/render/LevitatingItemRenderer.java +++ b/src/client/java/com/minelittlepony/client/render/LevitatingItemRenderer.java @@ -9,17 +9,16 @@ import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer; import com.minelittlepony.client.util.render.Color; import com.minelittlepony.pony.IPony; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.GlStateManager.DestFactor; -import net.minecraft.client.renderer.GlStateManager.SourceFactor; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.EnumAction; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.item.ItemRenderer; +import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumHandSide; -import static net.minecraft.client.renderer.GlStateManager.*; +import net.minecraft.util.AbsoluteHand; +import net.minecraft.util.UseAction; + +import static com.mojang.blaze3d.platform.GlStateManager.*; @SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it. public class LevitatingItemRenderer { @@ -27,27 +26,27 @@ public class LevitatingItemRenderer { public static void enableItemGlowRenderProfile() { enableBlend(); 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. */ - 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(); disableLighting(); setColor(glowColor); - ItemRenderer renderItem = Minecraft.getInstance().getItemRenderer(); + ItemRenderer renderItem = MinecraftClient.getInstance().getItemRenderer(); ((IRenderItem) renderItem).useTransparency(true); PonySkullRenderer.ponyInstance.useTransparency(true); scalef(1.1F, 1.1F, 1.1F); 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); - renderItem.renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); + renderItem.renderHeldItem(drop, entity, transform, hand == AbsoluteHand.LEFT); ((IRenderItem) renderItem).useTransparency(false); PonySkullRenderer.ponyInstance.useTransparency(false); @@ -69,7 +68,7 @@ public class LevitatingItemRenderer { /** * 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); pushMatrix(); @@ -80,7 +79,7 @@ public class LevitatingItemRenderer { setupPerspective(renderer, entity, stack, left); } - renderer.renderItem(stack, entity, transform, left); + renderer.renderHeldItem(stack, entity, transform, left); if (doMagic) { disableLighting(); @@ -93,9 +92,9 @@ public class LevitatingItemRenderer { scalef(1.1F, 1.1F, 1.1F); 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); - renderer.renderItem(stack, entity, transform, left); + renderer.renderHeldItem(stack, entity, transform, left); ((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. */ - private void setupPerspective(ItemRenderer renderer, EntityLivingBase entity, ItemStack stack, boolean left) { - EnumAction action = stack.getUseAction(); + private void setupPerspective(ItemRenderer renderer, LivingEntity entity, ItemStack stack, boolean left) { + 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. - 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 driftAmount = (float)Math.cos(ticks / 6) / 40; - boolean handHeldTool = stack.getUseAction() == EnumAction.BOW - || stack.getUseAction() == EnumAction.BLOCK; + boolean handHeldTool = stack.getUseAction() == UseAction.BOW + || stack.getUseAction() == UseAction.BLOCK; 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) { rotatef(-60, 0, 1, 0); rotatef(30, 0, 0, 1); diff --git a/src/client/java/com/minelittlepony/client/render/RenderPony.java b/src/client/java/com/minelittlepony/client/render/RenderPony.java index 5228baaf..720dfc62 100644 --- a/src/client/java/com/minelittlepony/client/render/RenderPony.java +++ b/src/client/java/com/minelittlepony/client/render/RenderPony.java @@ -2,29 +2,30 @@ package com.minelittlepony.client.render; import com.minelittlepony.MineLittlePony; import com.minelittlepony.client.PonyRenderManager; -import com.minelittlepony.client.ducks.IRenderPony; import com.minelittlepony.client.model.AbstractPonyModel; import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.transform.PonyPosture; +import com.minelittlepony.model.IPonyModel; import com.minelittlepony.pony.IPony; import com.minelittlepony.util.math.MathUtil; +import com.mojang.blaze3d.platform.GlStateManager; import javax.annotation.Nullable; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.culling.ICamera; +import net.minecraft.client.render.VisibleRegion; +import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.LivingEntity; -public class RenderPony { +public class RenderPony & IPonyModel> { - public ModelWrapper playerModel; + public ModelWrapper playerModel; - protected AbstractPonyModel ponyModel; + protected AbstractPonyModel ponyModel; private IPony pony; - private IRenderPony renderer; + private IPonyRender renderer; private FrustrumCheck frustrum = new FrustrumCheck<>(this); @@ -38,12 +39,12 @@ public class RenderPony { GlStateManager.disableBlend(); } - public RenderPony(IRenderPony renderer) { + public RenderPony(IPonyRender renderer) { this.renderer = renderer; } - public ICamera getFrustrum(T entity, ICamera vanilla) { - if (entity.isPlayerSleeping() || !MineLittlePony.getInstance().getConfig().frustrum) { + public VisibleRegion getFrustrum(T entity, VisibleRegion vanilla) { + if (entity.isSleeping() || !MineLittlePony.getInstance().getConfig().frustrum) { return vanilla; } return frustrum.withCamera(entity, vanilla); @@ -62,31 +63,31 @@ public class RenderPony { } public float getRenderYaw(T entity, float rotationYaw, float partialTicks) { - if (entity.isPassenger()) { - Entity mount = entity.getRidingEntity(); - if (mount instanceof EntityLivingBase) { - return MathUtil.interpolateDegress(((EntityLivingBase)mount).prevRenderYawOffset, ((EntityLivingBase)mount).renderYawOffset, partialTicks); + if (entity.hasVehicle()) { + Entity mount = entity.getVehicle(); + if (mount instanceof LivingEntity) { + return MathUtil.interpolateDegress(((LivingEntity)mount).field_6220, ((LivingEntity)mount).field_6283, partialTicks); } } return rotationYaw; } - protected void translateRider(EntityLivingBase entity, float ticks) { - if (entity.isPassenger()) { - Entity ridingEntity = entity.getRidingEntity(); + protected void translateRider(LivingEntity entity, float ticks) { + if (entity.hasVehicle()) { + Entity ridingEntity = entity.getVehicle(); - if (ridingEntity instanceof EntityLivingBase) { - IRenderPony renderer = PonyRenderManager.getInstance().getPonyRenderer((EntityLivingBase)ridingEntity); + if (ridingEntity instanceof LivingEntity) { + IPonyRender renderer = PonyRenderManager.getInstance().getPonyRenderer((LivingEntity)ridingEntity); if (renderer != null) { // 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") - 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 { public void applyPostureTransform(T player, float yaw, float ticks) { PonyPosture posture = getPosture(player); if (posture != null && posture.applies(player)) { - double motionX = player.posX - player.prevPosX; - double motionY = player.onGround ? 0 : player.posY - player.prevPosY; - double motionZ = player.posZ - player.prevPosZ; - ((PonyPosture)posture).transform(ponyModel, player, motionX, motionY, motionZ, yaw, ticks); + double motionX = player.x - player.prevX; + double motionY = player.onGround ? 0 : player.y - player.prevY; + double motionZ = player.x - player.prevZ; + ((PonyPosture)posture).transform(ponyModel, player, motionX, motionY, motionZ, yaw, ticks); } } @@ -107,21 +108,21 @@ public class RenderPony { public void applyPostureRiding(T player, float yaw, float ticks) { PonyPosture posture = getPosture(player); if (posture != null && posture.applies(player)) { - double motionX = player.posX - player.prevPosX; - double motionY = player.onGround ? 0 : player.posY - player.prevPosY; - double motionZ = player.posZ - player.prevPosZ; + double motionX = player.x - player.prevX; + double motionY = player.onGround ? 0 : player.y - player.prevY; + double motionZ = player.z - player.prevZ; - ((PonyPosture)posture).transform(ponyModel, player, motionX, -motionY, motionZ, yaw, ticks); + ((PonyPosture)posture).transform(ponyModel, player, motionX, -motionY, motionZ, yaw, ticks); } } @Nullable private PonyPosture getPosture(T entity) { - if (entity.isElytraFlying()) { + if (entity.isFallFlying()) { return PonyPosture.ELYTRA; } - if (entity.isAlive() && entity.isPlayerSleeping()) { + if (entity.isAlive() && entity.isSleeping()) { return null; } @@ -136,11 +137,12 @@ public class RenderPony { return PonyPosture.FALLING; } - public AbstractPonyModel setPonyModel(ModelWrapper model) { + @SuppressWarnings("unchecked") + public M setPonyModel(ModelWrapper model) { playerModel = model; - ponyModel = playerModel.getBody(); + ponyModel = (AbstractPonyModel)playerModel.getBody(); - return ponyModel; + return (M)ponyModel; } public void updateModel(T entity) { @@ -164,7 +166,7 @@ public class RenderPony { public double getNamePlateYOffset(T entity, double initial) { // 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. y += ponyModel.getModelHeight() * getScaleFactor() + 0.25F; @@ -173,11 +175,11 @@ public class RenderPony { y -= 0.25F; } - if (entity.isPassenger()) { - y += entity.getRidingEntity().getEyeHeight(); + if (entity.hasVehicle()) { + y += entity.getVehicle().getEyeHeight(entity.getPose()); } - if (entity.isPlayerSleeping()) { + if (entity.isSleeping()) { y /= 2; } diff --git a/src/client/java/com/minelittlepony/client/render/RenderPonyMob.java b/src/client/java/com/minelittlepony/client/render/RenderPonyMob.java index d294f99a..971360c6 100644 --- a/src/client/java/com/minelittlepony/client/render/RenderPonyMob.java +++ b/src/client/java/com/minelittlepony/client/render/RenderPonyMob.java @@ -1,7 +1,7 @@ package com.minelittlepony.client.render; 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.render.layer.LayerGear; 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.LayerPonyCustomHead; import com.minelittlepony.client.render.layer.LayerPonyElytra; +import com.minelittlepony.client.util.render.PonyRenderer; import com.minelittlepony.hdskins.HDSkins; +import com.minelittlepony.model.IPonyModel; +import com.minelittlepony.model.IUnicorn; import com.minelittlepony.pony.IPony; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.culling.ICamera; -import net.minecraft.client.renderer.entity.RenderLiving; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.layers.LayerArrow; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; -import net.minecraft.entity.EntityLiving; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.VisibleRegion; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.Identifier; import java.util.List; import javax.annotation.Nonnull; -public abstract class RenderPonyMob extends RenderLiving implements IRenderPony { +public abstract class RenderPonyMob & IPonyModel> extends LivingEntityRenderer implements IPonyRender { - protected RenderPony renderPony = new RenderPony(this); + protected RenderPony renderPony = new RenderPony(this); - public RenderPonyMob(RenderManager manager, ModelWrapper model) { + public RenderPonyMob(EntityRenderDispatcher manager, ModelWrapper model) { super(manager, model.getBody(), 0.5F); - mainModel = renderPony.setPonyModel(model); + renderPony.setPonyModel(model); addLayers(); } protected void addLayers() { - addLayer(new LayerPonyArmor<>(this)); - addLayer(createItemHoldingLayer()); - addLayer(new LayerArrow(this)); - addLayer(new LayerPonyCustomHead<>(this)); - addLayer(new LayerPonyElytra<>(this)); - addLayer(new LayerGear<>(this)); + addFeature(new LayerPonyArmor<>(this)); + addFeature(createItemHoldingLayer()); + addFeature(new StuckArrowsFeatureRenderer<>(this)); + addFeature(new LayerPonyCustomHead<>(this)); + addFeature(new LayerPonyElytra<>(this)); + addFeature(new LayerGear<>(this)); } - protected LayerHeldPonyItem createItemHoldingLayer() { - return new LayerHeldPonyItemMagical<>(this); - } + protected abstract LayerHeldPonyItem createItemHoldingLayer(); @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()) { 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); } @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); - super.applyRotations(entity, ageInTicks, rotationYaw, partialTicks); + super.setupTransforms(entity, ageInTicks, rotationYaw, partialTicks); } @Override - public boolean shouldRender(T entity, ICamera camera, double camX, double camY, double camZ) { - return super.shouldRender(entity, renderPony.getFrustrum(entity, camera), camX, camY, camZ); + public boolean isVisible(T entity, VisibleRegion camera, double camX, double camY, double camZ) { + return super.isVisible(entity, renderPony.getFrustrum(entity, camera), camX, camY, camZ); } @Override - public void preRenderCallback(T entity, float ticks) { + public void scale(T entity, float ticks) { renderPony.preRenderCallback(entity, ticks); - shadowSize = renderPony.getShadowScale(); + // shadowRadius + field_4673 = renderPony.getShadowScale(); - if (entity.isChild()) { - shadowSize *= 3; // undo vanilla shadow scaling + if (entity.isBaby()) { + field_4673 *= 3; // undo vanilla shadow scaling } - if (!entity.isPassenger()) { - GlStateManager.translatef(0, 0, -entity.width / 2); // move us to the center of the shadow + if (!entity.hasVehicle()) { + GlStateManager.translatef(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow } else { - GlStateManager.translated(0, entity.getYOffset(), 0); + GlStateManager.translated(0, entity.getHeightOffset(), 0); } } @Override - public ModelWrapper getModelWrapper() { + public ModelWrapper getModelWrapper() { return renderPony.playerModel; } @Override public IPony getEntityPony(T entity) { - return MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity)); + return MineLittlePony.getInstance().getManager().getPony(findTexture(entity)); } @Override - protected void renderLivingLabel(T entity, String name, double x, double y, double z, int maxDistance) { - super.renderLivingLabel(entity, name, x, renderPony.getNamePlateYOffset(entity, y), z, maxDistance); + protected void renderLabel(T entity, String name, double x, double y, double z, int maxDistance) { + super.renderLabel(entity, name, x, renderPony.getNamePlateYOffset(entity, y), z, maxDistance); } + @Deprecated @Override @Nonnull - protected final ResourceLocation getEntityTexture(T entity) { - return HDSkins.getInstance().getConvertedSkin(getTexture(entity)); + public final Identifier getTexture(T entity) { + return HDSkins.getInstance().getConvertedSkin(findTexture(entity)); } @Override - public RenderPony getInternalRenderer() { + public RenderPony getInternalRenderer() { return renderPony; } - public abstract static class Proxy extends RenderPonyMob { + public abstract static class Caster & IUnicorn> extends RenderPonyMob { - public Proxy(List> exportedLayers, RenderManager manager, ModelWrapper model) { + public Caster(EntityRenderDispatcher manager, ModelWrapper model) { + super(manager, model); + } + + @Override + protected LayerHeldPonyItem createItemHoldingLayer() { + return new LayerHeldPonyItemMagical<>(this); + } + } + + public abstract static class Proxy & IPonyModel> extends RenderPonyMob { + + @SuppressWarnings({"rawtypes", "unchecked"}) + public Proxy(List exportedLayers, EntityRenderDispatcher manager, ModelWrapper model) { super(manager, model); - exportedLayers.addAll(layerRenderers); + exportedLayers.addAll(features); } @Override protected void addLayers() { - layerRenderers.clear(); + features.clear(); super.addLayers(); } - public final ResourceLocation getTextureFor(T entity) { - return super.getEntityTexture(entity); + public final Identifier getTextureFor(T entity) { + return super.getTexture(entity); } } } diff --git a/src/client/java/com/minelittlepony/client/render/entities/MobRenderers.java b/src/client/java/com/minelittlepony/client/render/entities/MobRenderers.java index c0abd8a0..7a954576 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/MobRenderers.java +++ b/src/client/java/com/minelittlepony/client/render/entities/MobRenderers.java @@ -1,12 +1,13 @@ package com.minelittlepony.client.render.entities; +import com.google.common.collect.Lists; import com.minelittlepony.MineLittlePony; import com.minelittlepony.client.PonyRenderManager; import com.minelittlepony.common.SensibleConfig.Setting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.monster.*; +import java.util.List; + +import net.minecraft.entity.mob.*; import net.minecraft.entity.passive.*; /** @@ -17,66 +18,68 @@ import net.minecraft.entity.passive.*; public enum MobRenderers implements Setting { VILLAGERS { @Override - public void register(boolean state, PonyRenderManager pony, RenderManager manager) { - pony.switchRenderer(state, manager, EntityVillager.class, new RenderPonyVillager(manager)); - pony.switchRenderer(state, manager, EntityWitch.class, new RenderPonyWitch(manager)); - pony.switchRenderer(state, manager, EntityZombieVillager.class, new RenderPonyZombieVillager(manager)); + void register(boolean state, PonyRenderManager pony) { + pony.switchRenderer(state, VillagerEntity.class, RenderPonyVillager::new); + pony.switchRenderer(state, WitchEntity.class, RenderPonyWitch::new); + pony.switchRenderer(state, ZombieVillagerEntity.class, RenderPonyZombieVillager::new); } }, ZOMBIES { @Override - public void register(boolean state, PonyRenderManager pony, RenderManager manager) { - pony.switchRenderer(state, manager, EntityZombie.class, new RenderPonyZombie<>(manager)); - pony.switchRenderer(state, manager, EntityHusk.class, new RenderPonyZombie.Husk(manager)); - pony.switchRenderer(state, manager, EntityGiantZombie.class, new RenderPonyZombie.Giant(manager)); + void register(boolean state, PonyRenderManager pony) { + pony.switchRenderer(state, ZombieEntity.class, RenderPonyZombie::new); + pony.switchRenderer(state, HuskEntity.class, RenderPonyZombie.Husk::new); + pony.switchRenderer(state, GiantEntity.class, RenderPonyZombie.Giant::new); } }, PIGZOMBIES { @Override - public void register(boolean state, PonyRenderManager pony, RenderManager manager) { - pony.switchRenderer(state, manager, EntityPigZombie.class, new RenderPonyZombie.Pigman(manager)); + void register(boolean state, PonyRenderManager pony) { + pony.switchRenderer(state, ZombiePigmanEntity.class, RenderPonyZombie.Pigman::new); } }, SKELETONS { @Override - public void register(boolean state, PonyRenderManager pony, RenderManager manager) { - pony.switchRenderer(state, manager, EntitySkeleton.class, new RenderPonySkeleton<>(manager)); - pony.switchRenderer(state, manager, EntityStray.class, new RenderPonySkeleton.Stray(manager)); - pony.switchRenderer(state, manager, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(manager)); + void register(boolean state, PonyRenderManager pony) { + pony.switchRenderer(state, SkeletonEntity.class, RenderPonySkeleton::new); + pony.switchRenderer(state, StrayEntity.class, RenderPonySkeleton.Stray::new); + pony.switchRenderer(state, WitherSkeletonEntity.class, RenderPonySkeleton.Wither::new); } }, ILLAGERS { @Override - public void register(boolean state, PonyRenderManager pony, RenderManager manager) { - pony.switchRenderer(state, manager, EntityVex.class, new RenderPonyVex(manager)); - pony.switchRenderer(state, manager, EntityEvoker.class, new RenderPonyIllager.Evoker(manager)); - pony.switchRenderer(state, manager, EntityVindicator.class, new RenderPonyIllager.Vindicator(manager)); - pony.switchRenderer(state, manager, EntityIllusionIllager.class, new RenderPonyIllager.Illusionist(manager)); + void register(boolean state, PonyRenderManager pony) { + pony.switchRenderer(state, VexEntity.class, RenderPonyVex::new); + pony.switchRenderer(state, EvokerEntity.class, RenderPonyIllager.Evoker::new); + pony.switchRenderer(state, VindicatorEntity.class, RenderPonyIllager.Vindicator::new); + pony.switchRenderer(state, IllusionerEntity.class, RenderPonyIllager.Illusionist::new); } }, GUARDIANS { @Override - public void register(boolean state, PonyRenderManager pony, RenderManager manager) { - pony.switchRenderer(state, manager, EntityGuardian.class, new RenderPonyGuardian(manager)); - pony.switchRenderer(state, manager, EntityElderGuardian.class, new RenderPonyGuardian.Elder(manager)); + void register(boolean state, PonyRenderManager pony) { + pony.switchRenderer(state, GuardianEntity.class, RenderPonyGuardian::new); + pony.switchRenderer(state, ElderGuardianEntity.class, RenderPonyGuardian::new); } }, ENDERMEN { @Override - public void register(boolean state, PonyRenderManager pony, RenderManager manager) { - pony.switchRenderer(state, manager, EntityEnderman.class, new RenderEnderStallion(manager)); + void register(boolean state, PonyRenderManager pony) { + pony.switchRenderer(state, EndermanEntity.class, RenderEnderStallion::new); } }; + public static final List registry = Lists.newArrayList(values()); + @Override public void set(boolean 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(); - register(state, pony, manager); + register(state, pony); if (state) { MineLittlePony.logger.info(name() + " are now ponies."); } 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); } \ No newline at end of file diff --git a/src/client/java/com/minelittlepony/client/render/entities/RenderEnderStallion.java b/src/client/java/com/minelittlepony/client/render/entities/RenderEnderStallion.java index b5908819..73618a25 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/RenderEnderStallion.java +++ b/src/client/java/com/minelittlepony/client/render/entities/RenderEnderStallion.java @@ -8,41 +8,41 @@ import com.minelittlepony.client.render.layer.LayerHeldPonyItem; import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical; import com.minelittlepony.client.render.layer.LayerEyeGlow.IGlowingRenderer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.layers.LayerArrow; -import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.block.BlockState; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer; +import net.minecraft.entity.mob.EndermanEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import java.util.Random; -public class RenderEnderStallion extends RenderPonyMob implements IGlowingRenderer { +public class RenderEnderStallion extends RenderPonyMob implements IGlowingRenderer { - public static final ResourceLocation ENDERMAN = new ResourceLocation("minelittlepony", "textures/entity/enderman/enderman_pony.png"); - private static final ResourceLocation EYES = new ResourceLocation("minelittlepony", "textures/entity/enderman/enderman_pony_eyes.png"); + public static final Identifier ENDERMAN = new Identifier("minelittlepony", "textures/entity/enderman/enderman_pony.png"); + private static final Identifier EYES = new Identifier("minelittlepony", "textures/entity/enderman/enderman_pony_eyes.png"); private final Random rnd = new Random(); - private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelEnderStallion()); + private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper<>(new ModelEnderStallion()); - public RenderEnderStallion(RenderManager manager) { + public RenderEnderStallion(EntityRenderDispatcher manager) { super(manager, MODEL_WRAPPER); } @Override protected void addLayers() { - addLayer(createItemHoldingLayer()); - addLayer(new LayerArrow(this)); - addLayer(new LayerEyeGlow<>(this)); + addFeature(createItemHoldingLayer()); + addFeature(new StuckArrowsFeatureRenderer<>(this)); + addFeature(new LayerEyeGlow<>(this)); } @Override - protected LayerHeldPonyItem createItemHoldingLayer() { - return new LayerHeldPonyItemMagical(this) { + protected LayerHeldPonyItem createItemHoldingLayer() { + return new LayerHeldPonyItemMagical(this) { @Override - protected ItemStack getRightItem(EntityEnderman entity) { - IBlockState state = entity.getHeldBlockState(); + protected ItemStack getRightItem(EndermanEntity entity) { + BlockState state = entity.getCarriedBlock(); if (state == null) { return ItemStack.EMPTY; } @@ -53,27 +53,27 @@ public class RenderEnderStallion extends RenderPonyMob implement } @Override - public ResourceLocation getTexture(EntityEnderman entity) { + public Identifier findTexture(EndermanEntity entity) { return ENDERMAN; } @Override - public void doRender(EntityEnderman entity, double x, double y, double z, float entityYaw, float partialTicks) { - ModelEnderStallion modelenderman = (ModelEnderStallion)getMainModel(); + public void render(EndermanEntity entity, double x, double y, double z, float entityYaw, float partialTicks) { + ModelEnderStallion modelenderman = getModel(); - modelenderman.isCarrying = entity.getHeldBlockState() != null; - modelenderman.isAttacking = entity.isScreaming(); + modelenderman.isCarrying = entity.getCarriedBlock() != null; + modelenderman.isAttacking = entity.isAngry(); - if (entity.isScreaming()) { + if (entity.isAngry()) { x += rnd.nextGaussian() / 50; z += rnd.nextGaussian() / 50; } - super.doRender(entity, x, y, z, entityYaw, partialTicks); + super.render(entity, x, y, z, entityYaw, partialTicks); } @Override - public ResourceLocation getEyeTexture() { + public Identifier getEyeTexture() { return EYES; } } diff --git a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyGuardian.java b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyGuardian.java index 3763fdde..2e499d5d 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyGuardian.java +++ b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyGuardian.java @@ -2,74 +2,80 @@ package com.minelittlepony.client.render.entities; import javax.annotation.Nonnull; +import com.minelittlepony.client.mixin.IResizeable; import com.minelittlepony.client.model.ModelWrapper; -import com.minelittlepony.client.model.entities.ModelSeapony; -import com.minelittlepony.client.render.RenderPonyMob; +import com.minelittlepony.client.model.entities.ModelGuardianPony; +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.renderer.entity.RenderGuardian; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.monster.EntityElderGuardian; -import net.minecraft.entity.monster.EntityGuardian; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.GuardianEntityRenderer; +import net.minecraft.entity.EntitySize; +import net.minecraft.entity.mob.ElderGuardianEntity; +import net.minecraft.entity.mob.GuardianEntity; +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 ponyRenderer; - private RenderPonyMob.Proxy ponyRenderer; - - public RenderPonyGuardian(RenderManager manager) { + public RenderPonyGuardian(EntityRenderDispatcher manager) { super(manager); - mainModel = MODEL_WRAPPER.getBody(); - ponyRenderer = new RenderPonyMob.Proxy(layerRenderers, manager, MODEL_WRAPPER) { + features.clear(); + ponyRenderer = new Proxy(features, manager, new ModelWrapper<>(new ModelGuardianPony())) { @Override - public ResourceLocation getTexture(EntityGuardian entity) { - return RenderPonyGuardian.this.getTexture(entity); + public Identifier findTexture(GuardianEntity entity) { + return SEAPONY; + } + + @Override + protected LayerHeldPonyItem createItemHoldingLayer() { + return new LayerHeldPonyItemMagical<>(this); } }; + model = ponyRenderer.getModel(); } @Override @Nonnull - protected final ResourceLocation getEntityTexture(EntityGuardian entity) { + protected final Identifier getTexture(GuardianEntity entity) { return ponyRenderer.getTextureFor(entity); } @Override - protected void preRenderCallback(EntityGuardian entity, float ticks) { - ponyRenderer.preRenderCallback(entity, ticks); + protected void scale(GuardianEntity entity, float ticks) { + ponyRenderer.scale(entity, ticks); } @Override - public void doRender(EntityGuardian entity, double x, double y, double z, float entityYaw, float partialTicks) { - float origin = entity.height; + public void render(GuardianEntity entity, double x, double y, double z, float entityYaw, float partialTicks) { + IResizeable resize = (IResizeable)entity; + EntitySize origin = resize.getCurrentSize(); // aligns the beam to their horns - entity.height = entity instanceof EntityElderGuardian ? 6 : 3; - super.doRender(entity, x, y, z, entityYaw, partialTicks); + resize.setCurrentSize(EntitySize.resizeable(origin.width, entity instanceof ElderGuardianEntity ? 6 : 3)); + + super.render(entity, x, y, z, entityYaw, partialTicks); // The beams in RenderGuardian leave lighting disabled, so we need to change it back. #MojangPls GlStateManager.enableLighting(); - entity.height = origin; - } - - protected ResourceLocation getTexture(EntityGuardian entity) { - return SEAPONY; + resize.setCurrentSize(origin); } public static class Elder extends RenderPonyGuardian { - public Elder(RenderManager manager) { + public Elder(EntityRenderDispatcher manager) { super(manager); } @Override - protected void preRenderCallback(EntityGuardian entity, float ticks) { - super.preRenderCallback(entity, ticks); + protected void scale(GuardianEntity entity, float ticks) { + super.scale(entity, ticks); GlStateManager.scalef(2.35F, 2.35F, 2.35F); } } diff --git a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyIllager.java b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyIllager.java index 5a244ad7..c8e8f2c9 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyIllager.java +++ b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyIllager.java @@ -5,96 +5,94 @@ import com.minelittlepony.client.model.entities.ModelIllagerPony; import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.client.render.layer.LayerHeldItemIllager; import com.minelittlepony.client.render.layer.LayerHeldPonyItem; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.monster.AbstractIllager; -import net.minecraft.entity.monster.EntityEvoker; -import net.minecraft.entity.monster.EntityIllusionIllager; -import net.minecraft.entity.monster.EntityVindicator; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.entity.mob.EvokerEntity; +import net.minecraft.entity.mob.IllagerEntity; +import net.minecraft.entity.mob.IllusionerEntity; +import net.minecraft.entity.mob.VindicatorEntity; +import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -public abstract class RenderPonyIllager extends RenderPonyMob { +public abstract class RenderPonyIllager extends RenderPonyMob> { - public static final ResourceLocation ILLUSIONIST = new ResourceLocation("minelittlepony", "textures/entity/illager/illusionist_pony.png"); - public static final ResourceLocation EVOKER = new ResourceLocation("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 ILLUSIONIST = new Identifier("minelittlepony", "textures/entity/illager/illusionist_pony.png"); + public static final Identifier EVOKER = new Identifier("minelittlepony", "textures/entity/illager/evoker_pony.png"); + public static final Identifier VINDICATOR = new Identifier("minelittlepony", "textures/entity/illager/vindicator_pony.png"); - private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelIllagerPony()); - - public RenderPonyIllager(RenderManager manager) { - super(manager, MODEL_WRAPPER); + public RenderPonyIllager(EntityRenderDispatcher manager) { + super(manager, new ModelWrapper<>(new ModelIllagerPony<>())); } @Override - protected LayerHeldPonyItem createItemHoldingLayer() { + protected LayerHeldPonyItem> createItemHoldingLayer() { return new LayerHeldItemIllager<>(this); } @Override - public void preRenderCallback(T entity, float ticks) { - super.preRenderCallback(entity, ticks); + public void scale(T entity, float ticks) { + super.scale(entity, ticks); GlStateManager.scalef(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE); } - public static class Vindicator extends RenderPonyIllager { + public static class Vindicator extends RenderPonyIllager { - public Vindicator(RenderManager manager) { + public Vindicator(EntityRenderDispatcher manager) { super(manager); } @Override - public ResourceLocation getTexture(EntityVindicator entity) { + public Identifier findTexture(VindicatorEntity entity) { return VINDICATOR; } } - public static class Evoker extends RenderPonyIllager { + public static class Evoker extends RenderPonyIllager { - public Evoker(RenderManager manager) { + public Evoker(EntityRenderDispatcher manager) { super(manager); } @Override - public ResourceLocation getTexture(EntityEvoker entity) { + public Identifier findTexture(EvokerEntity entity) { return EVOKER; } } - public static class Illusionist extends RenderPonyIllager { + public static class Illusionist extends RenderPonyIllager { - public Illusionist(RenderManager manager) { + public Illusionist(EntityRenderDispatcher manager) { super(manager); } @Override - public ResourceLocation getTexture(EntityIllusionIllager entity) { + public Identifier findTexture(IllusionerEntity entity) { return ILLUSIONIST; } @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()) { - Vec3d[] clones = entity.getRenderLocations(ticks); - float rotation = handleRotationFloat(entity, ticks); + Vec3d[] clones = entity.method_7065(ticks); + float rotation = getAge(entity, ticks); 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, y + clones[i].y + MathHelper.cos(i + rotation * 0.75F) * 0.0125D, z + clones[i].z + MathHelper.cos(i + rotation * 0.7F) * 0.025D, yaw, ticks); } } else { - super.doRender(entity, x, y, z, yaw, ticks); + super.render(entity, x, y, z, yaw, ticks); } } @Override - protected boolean isVisible(EntityIllusionIllager entity) { + protected boolean method_4056(IllusionerEntity entity) { return true; } } diff --git a/src/client/java/com/minelittlepony/client/render/entities/RenderPonySkeleton.java b/src/client/java/com/minelittlepony/client/render/entities/RenderPonySkeleton.java index 18a2a43a..d9af0deb 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/RenderPonySkeleton.java +++ b/src/client/java/com/minelittlepony/client/render/entities/RenderPonySkeleton.java @@ -3,59 +3,64 @@ package com.minelittlepony.client.render.entities; import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.entities.ModelSkeletonPony; 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.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.monster.AbstractSkeleton; -import net.minecraft.entity.monster.EntityStray; -import net.minecraft.entity.monster.EntityWitherSkeleton; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.entity.mob.AbstractSkeletonEntity; +import net.minecraft.entity.mob.StrayEntity; +import net.minecraft.entity.mob.WitherSkeletonEntity; +import net.minecraft.util.Identifier; -public class RenderPonySkeleton extends RenderPonyMob { +public class RenderPonySkeleton extends RenderPonyMob> { - public static final ResourceLocation SKELETON = new ResourceLocation("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 ResourceLocation STRAY = new ResourceLocation("minelittlepony", "textures/entity/skeleton/stray_pony.png"); + public static final Identifier SKELETON = new Identifier("minelittlepony", "textures/entity/skeleton/skeleton_pony.png"); + public static final Identifier WITHER = new Identifier("minelittlepony", "textures/entity/skeleton/skeleton_wither_pony.png"); + public static final Identifier STRAY = new Identifier("minelittlepony", "textures/entity/skeleton/stray_pony.png"); - private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelSkeletonPony()); - - public RenderPonySkeleton(RenderManager manager) { - super(manager, MODEL_WRAPPER); + public RenderPonySkeleton(EntityRenderDispatcher manager) { + super(manager, new ModelWrapper<>(new ModelSkeletonPony<>())); } @Override - public ResourceLocation getTexture(Skeleton entity) { + public Identifier findTexture(Skeleton entity) { return SKELETON; } - public static class Stray extends RenderPonySkeleton { + @Override + protected LayerHeldPonyItem> createItemHoldingLayer() { + return new LayerHeldPonyItemMagical<>(this); + } - public Stray(RenderManager rm) { + public static class Stray extends RenderPonySkeleton { + + public Stray(EntityRenderDispatcher rm) { super(rm); - addLayer(new LayerPonyStrayOverlay(this)); + addFeature(new LayerPonyStrayOverlay<>(this)); } @Override - public ResourceLocation getTexture(EntityStray entity) { + public Identifier findTexture(StrayEntity entity) { return STRAY; } } - public static class Wither extends RenderPonySkeleton { + public static class Wither extends RenderPonySkeleton { - public Wither(RenderManager rm) { + public Wither(EntityRenderDispatcher rm) { super(rm); } @Override - public ResourceLocation getTexture(EntityWitherSkeleton entity) { + public Identifier findTexture(WitherSkeletonEntity entity) { return WITHER; } @Override - public void preRenderCallback(EntityWitherSkeleton skeleton, float ticks) { - super.preRenderCallback(skeleton, ticks); + public void scale(WitherSkeletonEntity skeleton, float ticks) { + super.scale(skeleton, ticks); GlStateManager.scalef(1.2F, 1.2F, 1.2F); } diff --git a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyVex.java b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyVex.java index 5c2cbd22..b9bd045c 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyVex.java +++ b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyVex.java @@ -1,32 +1,32 @@ package com.minelittlepony.client.render.entities; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderBiped; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.monster.EntityVex; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.BipedEntityRenderer; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.entity.mob.VexEntity; +import net.minecraft.util.Identifier; import com.minelittlepony.client.model.entities.ModelBreezie; +import com.mojang.blaze3d.platform.GlStateManager; /** * AKA a breezie :D */ -public class RenderPonyVex extends RenderBiped { +public class RenderPonyVex extends BipedEntityRenderer> { - private static final ResourceLocation VEX = new ResourceLocation("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 = new Identifier("minelittlepony", "textures/entity/illager/vex_pony.png"); + private static final Identifier VEX_CHARGING = new Identifier("minelittlepony", "textures/entity/illager/vex_charging_pony.png"); - public RenderPonyVex(RenderManager manager) { - super(manager, new ModelBreezie(), 0.3F); + public RenderPonyVex(EntityRenderDispatcher manager) { + super(manager, new ModelBreezie<>(), 0.3F); } @Override - protected void preRenderCallback(EntityVex entity, float ticks) { + protected void scale(VexEntity entity, float ticks) { GlStateManager.scalef(0.4F, 0.4F, 0.4F); } @Override - protected ResourceLocation getEntityTexture(EntityVex entity) { + protected Identifier getTexture(VexEntity entity) { return entity.isCharging() ? VEX_CHARGING : VEX; } diff --git a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyVillager.java b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyVillager.java index 269f0bb9..565ef682 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyVillager.java +++ b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyVillager.java @@ -5,52 +5,43 @@ import com.minelittlepony.client.model.entities.ModelVillagerPony; import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.util.resources.FormattedTextureSupplier; 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.renderer.entity.RenderManager; -import net.minecraft.entity.passive.EntityVillager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.entity.passive.VillagerEntity; +import net.minecraft.util.Identifier; +import net.minecraft.village.VillagerData; -public class RenderPonyVillager extends RenderPonyMob { - - /** - * 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"); +public class RenderPonyVillager extends RenderPonyMob.Caster> { private static final ITextureSupplier FORMATTER = new FormattedTextureSupplier("minelittlepony", "textures/entity/villager/%s_pony.png"); - private static final ResourceLocation DEFAULT = FORMATTER.supplyTexture("villager"); - private static final ResourceLocation EGG = FORMATTER.supplyTexture("silly"); - private static final ResourceLocation EGG_2 = FORMATTER.supplyTexture("tiny_silly"); + private static final Identifier DEFAULT = FORMATTER.supplyTexture("villager"); + private static final Identifier EGG = FORMATTER.supplyTexture("silly"); + private static final Identifier EGG_2 = FORMATTER.supplyTexture("tiny_silly"); - private static final ITextureSupplier PROFESSIONS = new VillagerProfessionTextureCache(FORMATTER, MAPPER, DEFAULT); + private static final ITextureSupplier PROFESSIONS = new VillagerProfessionTextureCache(FORMATTER, DEFAULT); - private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelVillagerPony()); - - public RenderPonyVillager(RenderManager manager) { - super(manager, MODEL_WRAPPER); + public RenderPonyVillager(EntityRenderDispatcher manager) { + super(manager, new ModelWrapper<>(new ModelVillagerPony<>())); } @Override - public void preRenderCallback(EntityVillager villager, float ticks) { - super.preRenderCallback(villager, ticks); + public void scale(VillagerEntity villager, float ticks) { + super.scale(villager, ticks); 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 - public ResourceLocation getTexture(EntityVillager entity) { - String name = entity.getCustomName().getUnformattedComponentText(); - if ("Derpy".equals(name) || (entity.isChild() && "Dinky".equals(name))) { - if (entity.isChild()) { + public Identifier findTexture(VillagerEntity entity) { + String name = entity.getCustomName().getString(); + if ("Derpy".equals(name) || (entity.isBaby() && "Dinky".equals(name))) { + if (entity.isBaby()) { return EGG_2; } return EGG; } - return PROFESSIONS.supplyTexture(entity.getProfession()); + return PROFESSIONS.supplyTexture(entity.getVillagerData()); } } diff --git a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyWitch.java b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyWitch.java index 4d6d0cc2..9ea27b22 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyWitch.java +++ b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyWitch.java @@ -4,31 +4,28 @@ import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.entities.ModelWitchPony; import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.client.render.layer.LayerHeldPonyItem; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.entity.mob.WitchEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumHandSide; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.AbsoluteHand; +import net.minecraft.util.Identifier; -@SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it. -public class RenderPonyWitch extends RenderPonyMob { +public class RenderPonyWitch extends RenderPonyMob { - 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(RenderManager manager) { - super(manager, MODEL_WRAPPER); + public RenderPonyWitch(EntityRenderDispatcher manager) { + super(manager, new ModelWrapper<>(new ModelWitchPony())); } @Override - protected LayerHeldPonyItem createItemHoldingLayer() { - return new LayerHeldPonyItem(this) { + protected LayerHeldPonyItem createItemHoldingLayer() { + return new LayerHeldPonyItem(this) { @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.rotatef(10, 1, 0, 0); } @@ -36,13 +33,13 @@ public class RenderPonyWitch extends RenderPonyMob { } @Override - public void preRenderCallback(EntityWitch entity, float ticks) { - super.preRenderCallback(entity, ticks); + public void scale(WitchEntity entity, float ticks) { + super.scale(entity, ticks); GlStateManager.scalef(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE); } @Override - public ResourceLocation getTexture(EntityWitch entity) { + public Identifier findTexture(WitchEntity entity) { return WITCH_TEXTURES; } } diff --git a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyZombie.java b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyZombie.java index 2fa68775..5a9e655b 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyZombie.java +++ b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyZombie.java @@ -3,77 +3,75 @@ package com.minelittlepony.client.render.entities; import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.entities.ModelZombiePony; import com.minelittlepony.client.render.RenderPonyMob; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.monster.EntityGiantZombie; -import net.minecraft.entity.monster.EntityHusk; -import net.minecraft.entity.monster.EntityPigZombie; -import net.minecraft.entity.monster.EntityZombie; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.entity.mob.GiantEntity; +import net.minecraft.entity.mob.HuskEntity; +import net.minecraft.entity.mob.ZombieEntity; +import net.minecraft.entity.mob.ZombiePigmanEntity; +import net.minecraft.util.Identifier; -public class RenderPonyZombie extends RenderPonyMob { +public class RenderPonyZombie extends RenderPonyMob.Caster> { - public static final ResourceLocation ZOMBIE = new ResourceLocation("minelittlepony", "textures/entity/zombie/zombie_pony.png"); - public static final ResourceLocation HUSK = new ResourceLocation("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 ZOMBIE = new Identifier("minelittlepony", "textures/entity/zombie/zombie_pony.png"); + public static final Identifier HUSK = new Identifier("minelittlepony", "textures/entity/zombie/husk_pony.png"); + public static final Identifier PIGMAN = new Identifier("minelittlepony", "textures/entity/zombie/zombie_pigman_pony.png"); - private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelZombiePony()); - - public RenderPonyZombie(RenderManager manager) { - super(manager, MODEL_WRAPPER); + public RenderPonyZombie(EntityRenderDispatcher manager) { + super(manager, new ModelWrapper<>(new ModelZombiePony<>())); } @Override - public ResourceLocation getTexture(Zombie entity) { + public Identifier findTexture(Zombie entity) { return ZOMBIE; } - public static class Pigman extends RenderPonyZombie { + public static class Pigman extends RenderPonyZombie { - public Pigman(RenderManager manager) { + public Pigman(EntityRenderDispatcher manager) { super(manager); } @Override - public ResourceLocation getTexture(EntityPigZombie entity) { + public Identifier findTexture(ZombiePigmanEntity entity) { return PIGMAN; } } - public static class Husk extends RenderPonyZombie { + public static class Husk extends RenderPonyZombie { - public Husk(RenderManager manager) { + public Husk(EntityRenderDispatcher manager) { super(manager); } @Override - public void preRenderCallback(EntityHusk entity, float ticks) { - super.preRenderCallback(entity, ticks); + public void scale(HuskEntity entity, float ticks) { + super.scale(entity, ticks); GlStateManager.scalef(1.0625F, 1.0625F, 1.0625F); } @Override - public ResourceLocation getTexture(EntityHusk entity) { + public Identifier findTexture(HuskEntity entity) { return HUSK; } } - public static class Giant extends RenderPonyMob { + public static class Giant extends RenderPonyMob.Caster> { - public Giant(RenderManager manager) { - super(manager, MODEL_WRAPPER); + public Giant(EntityRenderDispatcher manager) { + super(manager, new ModelWrapper<>(new ModelZombiePony<>())); } @Override - public void preRenderCallback(EntityGiantZombie entity, float ticks) { - super.preRenderCallback(entity, ticks); + public void scale(GiantEntity entity, float ticks) { + super.scale(entity, ticks); GlStateManager.scalef(3, 3, 3); } @Override - public ResourceLocation getTexture(EntityGiantZombie entity) { + public Identifier findTexture(GiantEntity entity) { return ZOMBIE; } } diff --git a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyZombieVillager.java b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyZombieVillager.java index cda2192a..d686d2fb 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/RenderPonyZombieVillager.java +++ b/src/client/java/com/minelittlepony/client/render/entities/RenderPonyZombieVillager.java @@ -5,54 +5,45 @@ import com.minelittlepony.client.model.entities.ModelZombieVillagerPony; import com.minelittlepony.client.render.RenderPonyMob; import com.minelittlepony.util.resources.FormattedTextureSupplier; import com.minelittlepony.util.resources.ITextureSupplier; -import com.minelittlepony.util.resources.IntStringMapper; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.monster.EntityZombieVillager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.entity.mob.ZombieVillagerEntity; +import net.minecraft.util.Identifier; +import net.minecraft.village.VillagerData; -public class RenderPonyZombieVillager extends RenderPonyMob { - - /** - * Ditto. - * @see RenderPonyVillager.MAPPER - */ - public static final IntStringMapper MAPPER = new IntStringMapper("farmer", "librarian", "priest", "smith", "butcher", "villager"); +public class RenderPonyZombieVillager extends RenderPonyMob.Caster { private static final ITextureSupplier FORMATTER = new FormattedTextureSupplier("minelittlepony", "textures/entity/zombie_villager/zombie_%s_pony.png"); - private static final ResourceLocation DEFAULT = FORMATTER.supplyTexture("villager"); - private static final ResourceLocation EGG = FORMATTER.supplyTexture("silly"); - private static final ResourceLocation EGG_2 = FORMATTER.supplyTexture("tiny_silly"); + private static final Identifier DEFAULT = FORMATTER.supplyTexture("villager"); + private static final Identifier EGG = FORMATTER.supplyTexture("silly"); + private static final Identifier EGG_2 = FORMATTER.supplyTexture("tiny_silly"); - private static final ITextureSupplier PROFESSIONS = new VillagerProfessionTextureCache(FORMATTER, MAPPER, DEFAULT); + private static final ITextureSupplier PROFESSIONS = new VillagerProfessionTextureCache(FORMATTER, DEFAULT); - private static final ModelWrapper MODEL_WRAPPER = new ModelWrapper(new ModelZombieVillagerPony()); - - public RenderPonyZombieVillager(RenderManager manager) { - super(manager, MODEL_WRAPPER); + public RenderPonyZombieVillager(EntityRenderDispatcher manager) { + super(manager, new ModelWrapper<>(new ModelZombieVillagerPony())); } - @SuppressWarnings("deprecation") // let me use getProfession in peace. I don't care that forge has their own one. @Override - public ResourceLocation getTexture(EntityZombieVillager entity) { - String name = entity.getCustomName().getUnformattedComponentText(); - if ("Derpy".equals(name) || (entity.isChild() && "Dinky".equals(name))) { - if (entity.isChild()) { + public Identifier findTexture(ZombieVillagerEntity entity) { + String name = entity.getCustomName().getString(); + if ("Derpy".equals(name) || (entity.isBaby() && "Dinky".equals(name))) { + if (entity.isBaby()) { return EGG_2; } return EGG; } - return PROFESSIONS.supplyTexture(entity.getProfession()); + return PROFESSIONS.supplyTexture(entity.getVillagerData()); } @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()) { - 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); } } diff --git a/src/client/java/com/minelittlepony/client/render/entities/VillagerProfessionTextureCache.java b/src/client/java/com/minelittlepony/client/render/entities/VillagerProfessionTextureCache.java index bd83531f..90dc488a 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/VillagerProfessionTextureCache.java +++ b/src/client/java/com/minelittlepony/client/render/entities/VillagerProfessionTextureCache.java @@ -1,10 +1,12 @@ package com.minelittlepony.client.render.entities; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.MinecraftClient; +import net.minecraft.util.Identifier; +import net.minecraft.village.VillagerData; import com.minelittlepony.MineLittlePony; import com.minelittlepony.util.resources.ITextureSupplier; +import com.minelittlepony.util.resources.ProfessionStringMapper; import java.io.IOException; import java.util.HashMap; @@ -14,15 +16,15 @@ import java.util.function.Function; /** * Cached pool of villager textures. */ -class VillagerProfessionTextureCache implements ITextureSupplier { +class VillagerProfessionTextureCache implements ITextureSupplier { private final ITextureSupplier formatter; - private final Function keyMapper; + private final Function keyMapper = new ProfessionStringMapper(); - private final ResourceLocation fallback; + private final Identifier fallback; - private final Map cache = new HashMap<>(); + private final Map cache = new HashMap<>(); /** * Creates a new profession cache @@ -31,22 +33,21 @@ class VillagerProfessionTextureCache implements ITextureSupplier { * @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. */ - public VillagerProfessionTextureCache(ITextureSupplier formatter, Function keyMapper, ResourceLocation fallback) { + public VillagerProfessionTextureCache(ITextureSupplier formatter, Identifier fallback) { this.formatter = formatter; this.fallback = fallback; - this.keyMapper = keyMapper; } @Override - public ResourceLocation supplyTexture(Integer profession) { - return cache.computeIfAbsent(profession, this::getModProfessionResource); + public Identifier supplyTexture(VillagerData data) { + return cache.computeIfAbsent(keyMapper.apply(data), this::getModProfessionResource); } - private ResourceLocation getModProfessionResource(int professionId) { - ResourceLocation generated = formatter.supplyTexture(keyMapper.apply(professionId)); + private Identifier getModProfessionResource(String professionId) { + Identifier generated = formatter.supplyTexture(professionId); try { - Minecraft.getInstance().getResourceManager().getResource(generated); + MinecraftClient.getInstance().getResourceManager().getResource(generated); } catch (IOException e) { MineLittlePony.logger.error("Error loading villager texture `" + generated + "`.", e); diff --git a/src/client/java/com/minelittlepony/client/render/entities/package-info.java b/src/client/java/com/minelittlepony/client/render/entities/package-info.java index 588ac2fa..cf134897 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/package-info.java +++ b/src/client/java/com/minelittlepony/client/render/entities/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.render.entities; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/render/entities/player/RenderPonyPlayer.java b/src/client/java/com/minelittlepony/client/render/entities/player/RenderPonyPlayer.java index c83bfd15..17f4e25a 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/player/RenderPonyPlayer.java +++ b/src/client/java/com/minelittlepony/client/render/entities/player/RenderPonyPlayer.java @@ -1,9 +1,10 @@ package com.minelittlepony.client.render.entities.player; 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.render.DebugBoundingBoxRenderer; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.client.render.RenderPony; import com.minelittlepony.client.render.layer.LayerDJPon3Head; 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.LayerPonyElytra; import com.minelittlepony.pony.IPony; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.block.BlockBed; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.culling.ICamera; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.client.renderer.entity.layers.LayerArrow; +import java.util.List; + +import net.minecraft.block.BedBlock; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.VisibleRegion; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +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.util.EnumHandSide; -import net.minecraft.util.ResourceLocation; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.AbsoluteHand; +import net.minecraft.util.Identifier; -public class RenderPonyPlayer extends RenderPlayer implements IRenderPony { +public class RenderPonyPlayer extends PlayerEntityRenderer implements IPonyRender> { - protected final RenderPony renderPony = new RenderPony<>(this); + protected final RenderPony> renderPony = new RenderPony<>(this); - public RenderPonyPlayer(RenderManager manager, boolean useSmallArms, ModelWrapper model) { + public RenderPonyPlayer(EntityRenderDispatcher manager, boolean useSmallArms, ModelWrapper> model) { super(manager, useSmallArms); - mainModel = renderPony.setPonyModel(model); + this.model = renderPony.setPonyModel(model); addLayers(); } protected void addLayers() { - layerRenderers.clear(); + features.clear(); - addLayer(new LayerDJPon3Head(this)); + addLayer(new LayerDJPon3Head<>(this)); addLayer(new LayerPonyArmor<>(this)); - addLayer(new LayerArrow(this)); + addFeature(new StuckArrowsFeatureRenderer<>(this)); addLayer(new LayerPonyCustomHead<>(this)); addLayer(new LayerPonyElytra<>(this)); addLayer(new LayerHeldPonyItemMagical<>(this)); - addLayer(new LayerPonyCape(this)); - addLayer(new LayerEntityOnPonyShoulder(renderManager, this)); + addLayer(new LayerPonyCape<>(this)); + addLayer(new LayerEntityOnPonyShoulder<>(renderManager, this)); addLayer(new LayerGear<>(this)); } - @Override - public float prepareScale(AbstractClientPlayer player, float ticks) { + @SuppressWarnings({"unchecked", "rawtypes"}) + protected boolean addLayer(FeatureRenderer> feature) { + return ((List)features).add(feature); + } - if (!player.isPassenger() && !player.isPlayerSleeping()) { - float x = player.width/2; + @Override + public float scaleAndTranslate(AbstractClientPlayerEntity player, float ticks) { + if (!player.hasVehicle() && !player.isSleeping()) { + float x = player.getWidth() / 2; float y = 0; if (player.isSneaking()) { // Sneaking makes the player 1/15th shorter. // 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 - protected void preRenderCallback(AbstractClientPlayer player, float ticks) { + protected void scale(AbstractClientPlayerEntity player, float ticks) { renderPony.preRenderCallback(player, ticks); - shadowSize = renderPony.getShadowScale(); + field_4673 = renderPony.getShadowScale(); - if (player.isPassenger()) { - GlStateManager.translated(0, player.getYOffset(), 0); + if (player.hasVehicle()) { + GlStateManager.translated(0, player.getHeightOffset(), 0); } } @Override - public void doRender(AbstractClientPlayer entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) { - super.doRender(entity, xPosition, yPosition, zPosition, yaw, ticks); + public void render(AbstractClientPlayerEntity entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) { + super.render(entity, xPosition, yPosition, zPosition, yaw, ticks); DebugBoundingBoxRenderer.instance.render(renderPony.getPony(entity), entity, ticks); } @Override - public boolean shouldRender(AbstractClientPlayer entity, ICamera camera, double camX, double camY, double camZ) { - if (entity.isPlayerSleeping() && entity == Minecraft.getInstance().player) { + public boolean isVisible(AbstractClientPlayerEntity entity, VisibleRegion camera, double camX, double camY, double camZ) { + if (entity.isSleeping() && entity == MinecraftClient.getInstance().player) { 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 - protected void renderLivingLabel(AbstractClientPlayer entity, String name, double x, double y, double z, int maxDistance) { - if (entity.isPlayerSleeping()) { - if (entity.bedLocation != null && entity.getEntityWorld().getBlockState(entity.bedLocation).getBlock() instanceof BlockBed) { - double bedRad = Math.toRadians(entity.getBedOrientationInDegrees()); + protected void renderLabel(AbstractClientPlayerEntity entity, String name, double x, double y, double z, int maxDistance) { + if (entity.isSleeping()) { + if (entity.getSleepingPosition().isPresent() && entity.getEntityWorld().getBlockState(entity.getSleepingPosition().get()).getBlock() instanceof BedBlock) { + double bedRad = Math.toRadians(entity.getSleepingDirection().asRotation()); x += Math.cos(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 - public void doRenderShadowAndFire(Entity player, double x, double y, double z, float yaw, float ticks) { - if (player.isPassenger() && ((AbstractClientPlayer)player).isPlayerSleeping()) { - super.doRenderShadowAndFire(player, x, y, z, yaw, ticks); + public void postRender(Entity player, double x, double y, double z, float yaw, float ticks) { + if (player.hasVehicle() && ((LivingEntity)player).isSleeping()) { + super.postRender(player, x, y, z, yaw, ticks); } } @Override - public final void renderRightArm(AbstractClientPlayer player) { - renderArm(player, EnumHandSide.RIGHT); + public final void renderRightArm(AbstractClientPlayerEntity player) { + renderArm(player, AbsoluteHand.RIGHT); } @Override - public final void renderLeftArm(AbstractClientPlayer player) { - renderArm(player, EnumHandSide.LEFT); + public final void renderLeftArm(AbstractClientPlayerEntity player) { + renderArm(player, AbsoluteHand.LEFT); } - protected void renderArm(AbstractClientPlayer player, EnumHandSide side) { + protected void renderArm(AbstractClientPlayerEntity player, AbsoluteHand side) { renderPony.updateModel(player); bindEntityTexture(player); GlStateManager.pushMatrix(); - GlStateManager.translatef(side == EnumHandSide.LEFT ? 0.35F : -0.35F, -0.6F, 0); - GlStateManager.rotatef(side == EnumHandSide.LEFT ? -90 : 90, 0, 1, 0); + GlStateManager.translatef(side == AbsoluteHand.LEFT ? 0.35F : -0.35F, -0.6F, 0); + GlStateManager.rotatef(side == AbsoluteHand.LEFT ? -90 : 90, 0, 1, 0); - if (side == EnumHandSide.LEFT) { + if (side == AbsoluteHand.LEFT) { super.renderLeftArm(player); } else { super.renderRightArm(player); @@ -144,36 +153,36 @@ public class RenderPonyPlayer extends RenderPlayer implements IRenderPony> getModelWrapper() { return renderPony.playerModel; } @Override - public IPony getEntityPony(AbstractClientPlayer player) { + public IPony getEntityPony(AbstractClientPlayerEntity player) { return MineLittlePony.getInstance().getManager().getPony(player); } @Override - public RenderPony getInternalRenderer() { + public RenderPony> getInternalRenderer() { return renderPony; } + @Override + public Identifier findTexture(AbstractClientPlayerEntity entity) { + return getTexture(entity); + } + } diff --git a/src/client/java/com/minelittlepony/client/render/entities/player/RenderSeaponyPlayer.java b/src/client/java/com/minelittlepony/client/render/entities/player/RenderSeaponyPlayer.java index a9f8e7f1..cf341f84 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/player/RenderSeaponyPlayer.java +++ b/src/client/java/com/minelittlepony/client/render/entities/player/RenderSeaponyPlayer.java @@ -1,19 +1,22 @@ package com.minelittlepony.client.render.entities.player; +import com.minelittlepony.client.model.ClientPonyModel; import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.pony.IPony; import com.minelittlepony.util.math.MathUtil; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.init.Particles; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.particle.ParticleTypes; public class RenderSeaponyPlayer extends RenderPonyPlayer { - protected ModelWrapper seapony; - protected ModelWrapper normalPony; + protected ModelWrapper> seapony; + protected ModelWrapper> normalPony; - public RenderSeaponyPlayer(RenderManager manager, boolean useSmallArms, ModelWrapper model, ModelWrapper alternate) { + public RenderSeaponyPlayer(EntityRenderDispatcher manager, boolean useSmallArms, + ModelWrapper> model, + ModelWrapper> alternate) { super(manager, useSmallArms, model); seapony = alternate; @@ -21,22 +24,22 @@ public class RenderSeaponyPlayer extends RenderPonyPlayer { } @Override - public IPony getEntityPony(AbstractClientPlayer player) { + public IPony getEntityPony(AbstractClientPlayerEntity player) { IPony pony = super.getEntityPony(player); boolean wet = pony.isPartiallySubmerged(player); - mainModel = renderPony.setPonyModel(wet ? seapony : normalPony); + model = renderPony.setPonyModel(wet ? seapony : normalPony); float state = wet ? 100 : 0; - float interpolated = pony.getMetadata().getInterpolator(player.getUniqueID()).interpolate("seapony_state", state, 5); + float interpolated = pony.getMetadata().getInterpolator(player.getUuid()).interpolate("seapony_state", state, 5); if (!MathUtil.compareFloats(interpolated, state)) { - double x = player.posX + (player.getEntityWorld().rand.nextFloat() * 2) - 1; - double y = player.posY + (player.getEntityWorld().rand.nextFloat() * 2); - double z = player.posZ + (player.getEntityWorld().rand.nextFloat() * 2) - 1; + double x = player.x + (player.getEntityWorld().getRandom().nextFloat() * 2) - 1; + double y = player.y + (player.getEntityWorld().getRandom().nextFloat() * 2); + double z = player.z + (player.getEntityWorld().getRandom().nextFloat() * 2) - 1; - player.getEntityWorld().addParticle(Particles.END_ROD, x, y, z, 0, 0, 0); + player.getEntityWorld().addParticle(ParticleTypes.END_ROD, x, y, z, 0, 0, 0); } return pony; diff --git a/src/client/java/com/minelittlepony/client/render/entities/player/package-info.java b/src/client/java/com/minelittlepony/client/render/entities/player/package-info.java index c5350cee..c2e79dc5 100644 --- a/src/client/java/com/minelittlepony/client/render/entities/player/package-info.java +++ b/src/client/java/com/minelittlepony/client/render/entities/player/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.render.entities.player; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/render/layer/AbstractPonyLayer.java b/src/client/java/com/minelittlepony/client/render/layer/AbstractPonyLayer.java index 04016aa4..f0b93d29 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/AbstractPonyLayer.java +++ b/src/client/java/com/minelittlepony/client/render/layer/AbstractPonyLayer.java @@ -1,20 +1,21 @@ package com.minelittlepony.client.render.layer; -import com.minelittlepony.client.ducks.IRenderPony; -import com.minelittlepony.client.model.AbstractPonyModel; -import com.minelittlepony.model.IModel; +import com.minelittlepony.client.render.IPonyRender; +import com.minelittlepony.model.IPonyModel; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.client.render.entity.feature.FeatureRenderer; +import net.minecraft.client.render.entity.feature.FeatureRendererContext; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.entity.LivingEntity; -public abstract class AbstractPonyLayer implements LayerRenderer { +public abstract class AbstractPonyLayer & IPonyModel> extends FeatureRenderer { - private final RenderLivingBase renderer; + private final IPonyRender context; - public AbstractPonyLayer(RenderLivingBase renderer) { - this.renderer = renderer; + @SuppressWarnings("unchecked") + public AbstractPonyLayer(IPonyRender context) { + super((FeatureRendererContext)context); + this.context = context; } /** @@ -32,31 +33,21 @@ public abstract class AbstractPonyLayer implements L @Override public abstract void render(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale); - protected RenderLivingBase getRenderer() { - return renderer; - } - @SuppressWarnings("unchecked") - protected IRenderPony getPonyRenderer() { - return (IRenderPony)renderer; + protected & FeatureRendererContext> C getContext() { + return (C)context; } - public AbstractPonyModel getPlayerModel() { - return getPonyRenderer().getModelWrapper().getBody(); + public M getPlayerModel() { + return getContext().getModelWrapper().getBody(); } - @SuppressWarnings("unchecked") - public M getPonyModel() { - return (M)getMainModel(); - } - - @SuppressWarnings("unchecked") - public M getMainModel() { - return (M)getRenderer().getMainModel(); + public M getMainModel() { + return getContext().getModel(); } @Override - public boolean shouldCombineTextures() { + public boolean hasHurtOverlay() { return false; } } diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerDJPon3Head.java b/src/client/java/com/minelittlepony/client/render/layer/LayerDJPon3Head.java index 58d2e713..ba25351d 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerDJPon3Head.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerDJPon3Head.java @@ -1,41 +1,43 @@ package com.minelittlepony.client.render.layer; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderLivingBase; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.entity.model.EntityModel; import com.minelittlepony.client.model.components.ModelDeadMau5Ears; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.IPonyModel; +import com.mojang.blaze3d.platform.GlStateManager; -public class LayerDJPon3Head extends AbstractPonyLayer { +public class LayerDJPon3Head & IPonyModel> extends AbstractPonyLayer { private final ModelDeadMau5Ears deadMau5 = new ModelDeadMau5Ears(); - public LayerDJPon3Head(RenderLivingBase entity) { - super(entity); + public LayerDJPon3Head(IPonyRender context) { + super(context); } @Override - public void render(AbstractClientPlayer entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { - if ("deadmau5".equals(entity.getName().getUnformattedComponentText())) { - getRenderer().bindTexture(entity.getLocationSkin()); + public void render(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { + if ("deadmau5".equals(entity.getName().getString())) { + getContext().bindTexture(entity.getSkinTexture()); GlStateManager.pushMatrix(); getPlayerModel().transform(BodyPart.HEAD); - getPlayerModel().bipedHead.postRender(scale); + getPlayerModel().getHead().applyTransform(scale); GlStateManager.scalef(1.3333334F, 1.3333334F, 1.3333334F); GlStateManager.translatef(0, 0.3F, 0); deadMau5.setVisible(true); - deadMau5.render(entity, move, swing, partialTicks, 0, 0, scale); + deadMau5.setRotationAngles(move, swing, partialTicks, 0, 0, scale); GlStateManager.popMatrix(); } } @Override - public boolean shouldCombineTextures() { + public boolean hasHurtOverlay() { return true; } } diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerEntityOnPonyShoulder.java b/src/client/java/com/minelittlepony/client/render/layer/LayerEntityOnPonyShoulder.java index d7ab82c4..b8b84277 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerEntityOnPonyShoulder.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerEntityOnPonyShoulder.java @@ -1,44 +1,44 @@ package com.minelittlepony.client.render.layer; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.entity.EntityType; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.entity.LivingEntity; +import net.minecraft.nbt.CompoundTag; +import com.minelittlepony.client.model.ClientPonyModel; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.model.BodyPart; +import com.mojang.blaze3d.platform.GlStateManager; import javax.annotation.Nullable; -public class LayerEntityOnPonyShoulder extends AbstractPonyLayer { +public class LayerEntityOnPonyShoulder> extends AbstractPonyLayer { - private final RenderManager renderManager; + private final EntityRenderDispatcher renderManager; - private EntityLivingBase leftEntity; - private EntityLivingBase rightEntity; + private LivingEntity leftEntity; + private LivingEntity rightEntity; - public LayerEntityOnPonyShoulder(RenderManager manager, RenderLivingBase renderer) { - super(renderer); + public LayerEntityOnPonyShoulder(EntityRenderDispatcher manager, IPonyRender context) { + super(context); renderManager = manager; } @Override - public void render(AbstractClientPlayer player, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { + public void render(AbstractClientPlayerEntity player, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { GlStateManager.enableRescaleNormal(); GlStateManager.color4f(1, 1, 1, 1); - NBTTagCompound leftTag = player.getLeftShoulderEntity(); + CompoundTag leftTag = player.getShoulderEntityLeft(); if (!leftTag.isEmpty()) { leftEntity = renderShoulderEntity(player, leftEntity, leftTag, headYaw, headPitch, true); } - NBTTagCompound rightTag = player.getRightShoulderEntity(); + CompoundTag rightTag = player.getShoulderEntityRight(); if (!rightTag.isEmpty()) { rightEntity = renderShoulderEntity(player, rightEntity, rightTag, headYaw, headPitch, false); @@ -48,17 +48,17 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer render = renderManager.getEntityRenderObject(entity); + EntityRenderer render = renderManager.getRenderer(entity); if (render == null) { return entity; @@ -66,7 +66,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer extends AbstractPonyLayer { +import static com.mojang.blaze3d.platform.GlStateManager.*; - private final ResourceLocation eyeTexture; +public class LayerEyeGlow & IPonyModel> extends AbstractPonyLayer { - public & IGlowingRenderer> LayerEyeGlow(V renderer) { + private final Identifier eyeTexture; + + public & IGlowingRenderer> LayerEyeGlow(V renderer) { super(renderer); eyeTexture = renderer.getEyeTexture(); } @Override public void render(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { - getRenderer().bindTexture(eyeTexture); + getContext().bindTexture(eyeTexture); enableBlend(); disableAlphaTest(); @@ -27,18 +30,18 @@ public class LayerEyeGlow extends AbstractPonyLayer { disableLighting(); depthMask(!entity.isInvisible()); - OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, 61680, 0); + GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, 61680, 0); enableLighting(); color4f(1, 1, 1, 1); - Minecraft.getInstance().gameRenderer.setupFogColor(true); + MinecraftClient.getInstance().gameRenderer.setFogBlack(true); - getMainModel().render(entity, move, swing, ticks, headYaw, headPitch, scale); + getModel().render(entity, move, swing, ticks, headYaw, headPitch, scale); - Minecraft.getInstance().gameRenderer.setupFogColor(false); + MinecraftClient.getInstance().gameRenderer.setFogBlack(false); - ((RenderLiving)getRenderer()).setLightmap(entity); + getContext().applyLightmapCoordinates(entity); depthMask(true); @@ -48,6 +51,6 @@ public class LayerEyeGlow extends AbstractPonyLayer { } public interface IGlowingRenderer { - ResourceLocation getEyeTexture(); + Identifier getEyeTexture(); } } diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerGear.java b/src/client/java/com/minelittlepony/client/render/layer/LayerGear.java index 655ab2e7..64413039 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerGear.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerGear.java @@ -1,30 +1,29 @@ package com.minelittlepony.client.render.layer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.Identifier; import org.lwjgl.opengl.GL11; import com.google.common.collect.Lists; -import com.minelittlepony.client.ducks.IRenderPony; -import com.minelittlepony.client.model.AbstractPonyModel; -import com.minelittlepony.client.model.IClientModel; import com.minelittlepony.client.model.gear.ChristmasHat; -import com.minelittlepony.client.model.gear.IGear; -import com.minelittlepony.client.model.gear.IStackable; import com.minelittlepony.client.model.gear.Muffin; import com.minelittlepony.client.model.gear.SaddleBags; import com.minelittlepony.client.model.gear.Stetson; import com.minelittlepony.client.model.gear.WitchHat; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.IPonyModel; +import com.minelittlepony.model.gear.IGear; +import com.minelittlepony.model.gear.IStackable; +import com.mojang.blaze3d.platform.GlStateManager; import java.util.HashMap; import java.util.List; import java.util.Map; -public class LayerGear extends AbstractPonyLayer { +public class LayerGear & IPonyModel> extends AbstractPonyLayer { private static List gears = Lists.newArrayList( new SaddleBags(), @@ -34,7 +33,7 @@ public class LayerGear extends AbstractPonyLayer new ChristmasHat() ); - public & IRenderPony> LayerGear(R renderer) { + public LayerGear(IPonyRender renderer) { super(renderer); } @@ -45,7 +44,7 @@ public class LayerGear extends AbstractPonyLayer return; } - AbstractPonyModel model = getPlayerModel(); + M model = getPlayerModel(); Map renderStackingOffsets = new HashMap<>(); @@ -53,17 +52,17 @@ public class LayerGear extends AbstractPonyLayer if (gear.canRender(model, entity)) { GlStateManager.pushMatrix(); model.transform(gear.getGearLocation()); - model.getBodyPart(gear.getGearLocation()).postRender(scale); + model.getBodyPart(gear.getGearLocation()).applyTransform(scale); if (gear instanceof IStackable) { BodyPart part = gear.getGearLocation(); renderStackingOffsets.compute(part, (k, v) -> { float offset = ((IStackable)gear).getStackingOffset(); - if (v != null) { - GlStateManager.translatef(0, -v, 0); - offset += v; - } - return offset; + if (v != null) { + GlStateManager.translatef(0, -v, 0); + offset += v; + } + return offset; }); } @@ -73,19 +72,19 @@ public class LayerGear extends AbstractPonyLayer } } - private void renderGear(IClientModel model, T entity, IGear gear, float move, float swing, float scale, float ticks) { + private void renderGear(M model, T entity, IGear gear, float move, float swing, float scale, float ticks) { GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - ResourceLocation texture = gear.getTexture(entity); + Identifier texture = gear.getTexture(entity); if (texture == null) { - texture = getPonyRenderer().getTexture(entity); + texture = getContext().findTexture(entity); } - getRenderer().bindTexture(texture); + getContext().bindTexture(texture); gear.setLivingAnimations(model, entity); - gear.setRotationAndAngles(model.isGoingFast(), entity.getUniqueID(), move, swing, model.getWobbleAmount(), ticks); - gear.renderPart(scale, entity.getUniqueID()); + gear.setRotationAndAngles(model.isGoingFast(), entity.getUuid(), move, swing, model.getWobbleAmount(), ticks); + gear.renderPart(scale, entity.getUuid()); GL11.glPopAttrib(); } diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerHeldItemIllager.java b/src/client/java/com/minelittlepony/client/render/layer/LayerHeldItemIllager.java index 3faed4db..1a3e0dcf 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerHeldItemIllager.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerHeldItemIllager.java @@ -1,15 +1,14 @@ package com.minelittlepony.client.render.layer; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.entity.monster.AbstractIllager; -import net.minecraft.entity.monster.AbstractIllager.IllagerArmPose; -import net.minecraft.util.EnumHandSide; +import net.minecraft.entity.mob.IllagerEntity; +import net.minecraft.util.AbsoluteHand; import com.minelittlepony.client.model.entities.ModelIllagerPony; +import com.minelittlepony.client.render.IPonyRender; -public class LayerHeldItemIllager extends LayerHeldPonyItem { +public class LayerHeldItemIllager extends LayerHeldPonyItem> { - public LayerHeldItemIllager(RenderLivingBase livingPony) { + public LayerHeldItemIllager(IPonyRender> livingPony) { super(livingPony); } @@ -21,11 +20,11 @@ public class LayerHeldItemIllager extends LayerHeldPo } @Override - protected void renderArm(EnumHandSide side) { - ((ModelIllagerPony)getPonyModel()).getArm(side).postRender(0.0625F); + protected void renderArm(AbsoluteHand side) { + getModel().getArm(side).applyTransform(0.0625F); } public boolean shouldRender(T entity) { - return entity.getArmPose() != IllagerArmPose.CROSSED; + return entity.getState() != IllagerEntity.State.CROSSED; } } diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerHeldPonyItem.java b/src/client/java/com/minelittlepony/client/render/layer/LayerHeldPonyItem.java index c49db1f8..a284db40 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerHeldPonyItem.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerHeldPonyItem.java @@ -1,35 +1,34 @@ package com.minelittlepony.client.render.layer; -import com.minelittlepony.client.model.IClientModel; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.IPonyModel; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.model.ModelBiped; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumHandSide; -import static net.minecraft.client.renderer.GlStateManager.*; +import net.minecraft.util.AbsoluteHand; -@SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it. -public class LayerHeldPonyItem extends AbstractPonyLayer { +import static com.mojang.blaze3d.platform.GlStateManager.*; - public LayerHeldPonyItem(RenderLivingBase livingPony) { +public class LayerHeldPonyItem & IPonyModel> extends AbstractPonyLayer { + + public LayerHeldPonyItem(IPonyRender livingPony) { super(livingPony); } protected ItemStack getLeftItem(T entity) { - boolean main = entity.getPrimaryHand() == EnumHandSide.LEFT; + boolean main = entity.getMainHand() == AbsoluteHand.LEFT; - return main ? entity.getHeldItemMainhand() : entity.getHeldItemOffhand(); + return main ? entity.getMainHandStack() : entity.getOffHandStack(); } protected ItemStack getRightItem(T entity) { - boolean main = entity.getPrimaryHand() == EnumHandSide.RIGHT; + boolean main = entity.getMainHand() == AbsoluteHand.RIGHT; - return main ? entity.getHeldItemMainhand() : entity.getHeldItemOffhand(); + return main ? entity.getMainHandStack() : entity.getOffHandStack(); } @Override @@ -39,62 +38,57 @@ public class LayerHeldPonyItem extends AbstractPonyL ItemStack right = getRightItem(entity); if (!left.isEmpty() || !right.isEmpty()) { - IClientModel model = getMainModel(); + M model = getModel(); pushMatrix(); model.transform(BodyPart.LEGS); - renderHeldItem(entity, right, TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT); - renderHeldItem(entity, left, TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT); + renderHeldItem(entity, right, ModelTransformation.Type.THIRD_PERSON_RIGHT_HAND, AbsoluteHand.RIGHT); + renderHeldItem(entity, left, ModelTransformation.Type.THIRD_PERSON_LEFT_HAND, AbsoluteHand.LEFT); popMatrix(); } } - private void renderHeldItem(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + private void renderHeldItem(T entity, ItemStack drop, ModelTransformation.Type transform, AbsoluteHand hand) { if (!drop.isEmpty()) { - GlStateManager.pushMatrix(); + pushMatrix(); renderArm(hand); if (entity.isSneaking()) { - GlStateManager.translatef(0, 0.2F, 0); + translatef(0, 0.2F, 0); } - float left = hand == EnumHandSide.LEFT ? 1 : -1; + float left = hand == AbsoluteHand.LEFT ? 1 : -1; - if (entity.isPassenger()) { - GlStateManager.translatef(left / 10, -0.2F, -0.5F); + if (entity.hasVehicle()) { + translatef(left / 10, -0.2F, -0.5F); } - GlStateManager.rotatef(-90, 1, 0, 0); - GlStateManager.rotatef(left * 180, 0, 1, 0); - GlStateManager.translatef(left * -0.2F, 0, 0); + rotatef(-90, 1, 0, 0); + rotatef(left * 180, 0, 1, 0); + translatef(left * -0.2F, 0, 0); preItemRender(entity, drop, transform, hand); - Minecraft.getInstance().getItemRenderer().renderItem(drop, entity, transform, hand == EnumHandSide.LEFT); + MinecraftClient.getInstance().getItemRenderer().renderHeldItem(drop, entity, transform, hand == AbsoluteHand.LEFT); postItemRender(entity, drop, transform, hand); - GlStateManager.popMatrix(); + popMatrix(); } } - protected void preItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { - GlStateManager.translatef(0, 0.125F, -1); + protected void preItemRender(T entity, ItemStack drop, ModelTransformation.Type transform, AbsoluteHand hand) { + translatef(0, 0.125F, -1); } - protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + protected void postItemRender(T entity, ItemStack drop, ModelTransformation.Type transform, AbsoluteHand hand) { } /** * Renders the main arm */ - protected void renderArm(EnumHandSide side) { - this.getMainModel().postRenderArm(0.0625F, side); - } - - @Override - public boolean shouldCombineTextures() { - return false; + protected void renderArm(AbsoluteHand side) { + getModel().setArmAngle(0.0625F, side); } } diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerHeldPonyItemMagical.java b/src/client/java/com/minelittlepony/client/render/layer/LayerHeldPonyItemMagical.java index 76b969d6..859886bb 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerHeldPonyItemMagical.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerHeldPonyItemMagical.java @@ -1,47 +1,49 @@ package com.minelittlepony.client.render.layer; import com.minelittlepony.client.PonyRenderManager; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.client.util.render.PonyRenderer; +import com.minelittlepony.model.IPonyModel; import com.minelittlepony.model.IUnicorn; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumHandSide; +import net.minecraft.util.AbsoluteHand; -@SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it. -public class LayerHeldPonyItemMagical extends LayerHeldPonyItem { +public class LayerHeldPonyItemMagical & IPonyModel> extends LayerHeldPonyItem { - public LayerHeldPonyItemMagical(RenderLivingBase livingPony) { - super(livingPony); + public LayerHeldPonyItemMagical(IPonyRender context) { + super(context); } protected boolean isUnicorn() { - return getMainModel() instanceof IUnicorn && this.>getPonyModel().canCast(); + return getModel() instanceof IUnicorn && ((IUnicorn)getModel()).canCast(); } @Override - protected void preItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + protected void preItemRender(T entity, ItemStack drop, ModelTransformation.Type transform, AbsoluteHand hand) { if (isUnicorn()) { - GlStateManager.translatef(hand == EnumHandSide.LEFT ? -0.6F : 0, 0.5F, -0.3F); + GlStateManager.translatef(hand == AbsoluteHand.LEFT ? -0.6F : 0, 0.5F, -0.3F); } else { super.preItemRender(entity, drop, transform, hand); } } @Override - protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) { + protected void postItemRender(T entity, ItemStack drop, ModelTransformation.Type transform, AbsoluteHand hand) { if (isUnicorn()) { - PonyRenderManager.getInstance().getMagicRenderer().renderItemGlow(entity, drop, transform, hand, this.>getPonyModel().getMagicColor()); + PonyRenderManager.getInstance().getMagicRenderer().renderItemGlow(entity, drop, transform, hand, ((IUnicorn)getModel()).getMagicColor()); } } + @SuppressWarnings("unchecked") @Override - protected void renderArm(EnumHandSide side) { + protected void renderArm(AbsoluteHand side) { if (isUnicorn()) { - this.>getPonyModel().getUnicornArmForSide(side).postRender(0.0625F); + ((IUnicorn)getModel()).getUnicornArmForSide(side).applyTransform(0.0625F); } else { super.renderArm(side); } diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerOverlayBase.java b/src/client/java/com/minelittlepony/client/render/layer/LayerOverlayBase.java index abe17515..1637457a 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerOverlayBase.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerOverlayBase.java @@ -1,40 +1,43 @@ package com.minelittlepony.client.render.layer; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; -import net.minecraft.entity.EntityLiving; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.feature.FeatureRenderer; +import net.minecraft.client.render.entity.feature.FeatureRendererContext; +import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.Identifier; + +import com.minelittlepony.model.IModel; // separate class in case I need it later -public abstract class LayerOverlayBase implements LayerRenderer { +public abstract class LayerOverlayBase & IModel> extends FeatureRenderer { - protected final RenderLivingBase renderer; + protected final FeatureRendererContext renderer; - public LayerOverlayBase(RenderLivingBase render) { + public LayerOverlayBase(FeatureRendererContext render) { + super(render); renderer = render; } @Override - public boolean shouldCombineTextures() { - return true; + public boolean hasHurtOverlay() { + return false; } @Override public void render(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { - ModelBase overlayModel = getOverlayModel(); + M overlayModel = getOverlayModel(); - overlayModel.setModelAttributes(renderer.getMainModel()); - overlayModel.setLivingAnimations(entity, move, swing, partialTicks); - overlayModel.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + overlayModel.setAttributes(renderer.getModel()); + overlayModel.animateModel(entity, move, swing, partialTicks); + overlayModel.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); renderer.bindTexture(getOverlayTexture()); overlayModel.render(entity, move, swing, ticks, headYaw, headPitch, scale); } - protected abstract ModelBase getOverlayModel(); + protected abstract M getOverlayModel(); - protected abstract ResourceLocation getOverlayTexture(); + protected abstract Identifier getOverlayTexture(); } \ No newline at end of file diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyArmor.java b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyArmor.java index 282c6a98..808a1631 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyArmor.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyArmor.java @@ -3,94 +3,92 @@ package com.minelittlepony.client.render.layer; import com.minelittlepony.client.ForgeProxy; import com.minelittlepony.client.model.ModelWrapper; import com.minelittlepony.client.model.armour.DefaultPonyArmorTextureResolver; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.client.util.render.Color; +import com.minelittlepony.model.IPonyModel; import com.minelittlepony.model.armour.ArmourLayer; import com.minelittlepony.model.armour.IArmour; import com.minelittlepony.model.armour.IArmourTextureResolver; import com.minelittlepony.model.armour.IEquestrianArmour; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.entity.model.ModelBiped; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.layers.LayerArmorBase; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.inventory.EntityEquipmentSlot.Type; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemArmorDyeable; -import net.minecraft.item.ArmorMaterial; +import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer; +import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ArmorItem; +import net.minecraft.item.ArmorMaterials; +import net.minecraft.item.DyeableArmorItem; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; -public class LayerPonyArmor extends AbstractPonyLayer { +public class LayerPonyArmor & IPonyModel> extends AbstractPonyLayer { - private static final IArmourTextureResolver textures = new DefaultPonyArmorTextureResolver<>(); + private static final IArmourTextureResolver textures = new DefaultPonyArmorTextureResolver<>(); - private ModelWrapper pony; + private ModelWrapper pony; - public LayerPonyArmor(RenderLivingBase renderer) { + public LayerPonyArmor(IPonyRender renderer) { super(renderer); } @Override public void render(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { - pony = getPonyRenderer().getModelWrapper(); + pony = getContext().getModelWrapper(); - for (EntityEquipmentSlot i : EntityEquipmentSlot.values()) { - if (i.getSlotType() == Type.ARMOR) { + for (EquipmentSlot i : EquipmentSlot.values()) { + if (i.getType() == EquipmentSlot.Type.ARMOR) { renderArmor(entity, move, swing, partialTicks, ticks, headYaw, headPitch, scale, i, ArmourLayer.INNER); renderArmor(entity, move, swing, partialTicks, ticks, headYaw, headPitch, scale, i, ArmourLayer.OUTER); } } } - private void renderArmor(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot, ArmourLayer layer) { - ItemStack itemstack = entity.getItemStackFromSlot(armorSlot); + @SuppressWarnings("unchecked") + private & IArmour> void renderArmor(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale, EquipmentSlot armorSlot, ArmourLayer layer) { + ItemStack itemstack = entity.getEquippedStack(armorSlot); - if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) { + if (!itemstack.isEmpty() && itemstack.getItem() instanceof ArmorItem) { - @SuppressWarnings("unchecked") - V armour = getArmorModel(entity, itemstack, armorSlot, layer, (V)pony.getArmor().getArmorForLayer(layer)); + V armour = LayerPonyArmor.getArmorModel(entity, itemstack, armorSlot, layer, pony.getArmor().getArmorForLayer(layer)); if (armour.prepareToRender(armorSlot, layer)) { - - armour.setModelAttributes(pony.getBody()); - armour.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity); + ((BipedEntityModel)pony.getBody()).setAttributes(armour); + armour.setAngles(entity, move, swing, ticks, headYaw, headPitch, scale); armour.synchroniseLegs(pony.getBody()); - @SuppressWarnings("unchecked") IArmourTextureResolver resolver = armour instanceof IArmourTextureResolver ? (IArmourTextureResolver)armour : (IArmourTextureResolver)textures; - ResourceLocation armourTexture = resolver.getArmourTexture(entity, itemstack, armorSlot, layer, null); + Identifier armourTexture = resolver.getArmourTexture(entity, itemstack, armorSlot, layer, null); - getRenderer().bindTexture(armourTexture); + getContext().bindTexture(armourTexture); - ItemArmor itemarmor = (ItemArmor) itemstack.getItem(); + ArmorItem itemarmor = (ArmorItem) itemstack.getItem(); - if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) { - if (itemarmor instanceof ItemArmorDyeable) { - Color.glColor(((ItemArmorDyeable)itemarmor).getColor(itemstack), 1); + if (itemarmor.getMaterial() == ArmorMaterials.LEATHER) { + if (itemarmor instanceof DyeableArmorItem) { + Color.glColor(((DyeableArmorItem)itemarmor).getColor(itemstack), 1); } armour.render(entity, move, swing, ticks, headYaw, headPitch, scale); armourTexture = resolver.getArmourTexture(entity, itemstack, armorSlot, layer, "overlay"); - getRenderer().bindTexture(armourTexture); + getContext().bindTexture(armourTexture); } GlStateManager.color4f(1, 1, 1, 1); armour.render(entity, move, swing, ticks, headYaw, headPitch, scale); - if (itemstack.isEnchanted()) { - LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, armour, move, swing, partialTicks, ticks, headYaw, headPitch, scale); + if (itemstack.hasEnchantmentGlint()) { + ArmorFeatureRenderer.renderEnchantedGlint(this::bindTexture, entity, armour, move, swing, partialTicks, ticks, headYaw, headPitch, scale); } } } } @SuppressWarnings("unchecked") - private static V getArmorModel(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, ArmourLayer layer, V def) { - ModelBase model = ForgeProxy.getArmorModel(entity, itemstack, slot, def); + private static & IArmour> V getArmorModel(T entity, ItemStack itemstack, EquipmentSlot slot, ArmourLayer layer, V def) { + BipedEntityModel model = ForgeProxy.getArmorModel(entity, itemstack, slot, def); if (model instanceof IArmour) { return (V)model; diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCape.java b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCape.java index 1e4ebd3e..014f4a9e 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCape.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCape.java @@ -1,45 +1,51 @@ package com.minelittlepony.client.render.layer; -import com.minelittlepony.client.model.AbstractPonyModel; +import com.minelittlepony.client.model.ClientPonyModel; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.model.BodyPart; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.entity.player.EnumPlayerModelParts; -import net.minecraft.init.Items; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.entity.PlayerModelPart; +import net.minecraft.item.Items; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.util.math.MathHelper; import javax.annotation.Nonnull; import static com.minelittlepony.model.PonyModelConstants.PI; -import static net.minecraft.client.renderer.GlStateManager.*; +import static com.mojang.blaze3d.platform.GlStateManager.*; -public class LayerPonyCape extends AbstractPonyLayer { +public class LayerPonyCape> extends AbstractPonyLayer { - public LayerPonyCape(RenderLivingBase entity) { - super(entity); + public LayerPonyCape(IPonyRender context) { + super(context); } @Override - public void render(@Nonnull AbstractClientPlayer player, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { - AbstractPonyModel model = getPlayerModel(); + public void render(@Nonnull AbstractClientPlayerEntity player, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { + M model = getModel(); - if (player.hasPlayerInfo() && !player.isInvisible() - && player.isWearing(EnumPlayerModelParts.CAPE) && player.getLocationCape() != null - && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() != Items.ELYTRA) { + if (player.hasSkinTexture() && !player.isInvisible() + && player.isSkinOverlayVisible(PlayerModelPart.CAPE) && player.getCapeTexture() != null + && player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) { pushMatrix(); model.transform(BodyPart.BODY); translatef(0, 0.24F, 0); - model.getBodyPart(BodyPart.BODY).postRender(scale); + model.getBodyPart(BodyPart.BODY).applyTransform(scale); - double capeX = player.prevChasingPosX + (player.chasingPosX - player.prevChasingPosX) * scale - (player.prevPosX + (player.posX - player.prevPosX) * scale); - double capeY = player.prevChasingPosY + (player.chasingPosY - player.prevChasingPosY) * scale - (player.prevPosY + (player.posY - player.prevPosY) * scale); - double capeZ = player.prevChasingPosZ + (player.chasingPosZ - player.prevChasingPosZ) * scale - (player.prevPosZ + (player.posZ - player.prevPosZ) * scale); + double capeX = MathHelper.lerp(partialTicks, player.field_7524, player.field_7500) - MathHelper.lerp(partialTicks, player.prevX, player.x); + double capeY = MathHelper.lerp(partialTicks, player.field_7502, player.field_7521) - MathHelper.lerp(partialTicks, player.prevY, player.y); + double capeZ = MathHelper.lerp(partialTicks, player.field_7522, player.field_7499) - MathHelper.lerp(partialTicks, player.prevZ, player.z); - float motionYaw = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * scale; + float motionYaw = player.field_6220 + (player.field_6283 - player.field_6220) * scale; + + //double capeX = player.prevRenderX + (player.x - player.prevRenderX) * scale - (player.prevX + (player.x - player.prevX) * scale); + //double capeY = player.prevRenderY + (player.y - player.prevRenderY) * scale - (player.prevY + (player.y - player.prevY) * scale); + //double capeZ = player.prevRenderZ + (player.z - player.prevRenderZ) * scale - (player.prevZ + (player.z - player.prevZ) * scale); + + //float motionYaw = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * scale; double sin = MathHelper.sin(motionYaw * PI / 180); double cos = (-MathHelper.cos(motionYaw * PI / 180)); @@ -55,23 +61,19 @@ public class LayerPonyCape extends AbstractPonyLayer { if (capeMotionX < 0) capeMotionX = 0; - float camera = player.prevCameraYaw + (player.cameraYaw - player.prevCameraYaw) * scale; - capeMotionY += MathHelper.sin((player.prevDistanceWalkedModified + (player.distanceWalkedModified - player.prevDistanceWalkedModified) * scale) * 6) * 32 * camera; + float camera = MathHelper.lerp(partialTicks, player.field_7505, player.field_7483); + //float camera = player.prevCameraYaw + (player.cameraYaw - player.prevCameraYaw) * scale; + capeMotionY += MathHelper.sin(MathHelper.lerp(partialTicks, player.field_6039, player.field_5973) * 6) * 32 * camera; + //capeMotionY += MathHelper.sin((player.prevDistanceWalkedModified + (player.distanceWalkedModified - player.prevDistanceWalkedModified) * scale) * 6) * 32 * camera; rotatef(2 + capeMotionX / 12 + capeMotionY, 1, 0, 0); rotatef( diagMotion / 2, 0, 0, 1); rotatef(-diagMotion / 2, 0, 1, 0); rotatef(180, 0, 0, 1); rotatef(90, 1, 0, 0); - getRenderer().bindTexture(player.getLocationCape()); + getContext().bindTexture(player.getCapeTexture()); model.renderCape(0.0625F); popMatrix(); } } - - @Override - public boolean shouldCombineTextures() { - return false; - } - } diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCustomHead.java b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCustomHead.java index c06c317f..737b24bf 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCustomHead.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyCustomHead.java @@ -1,54 +1,48 @@ package com.minelittlepony.client.render.layer; -import static net.minecraft.client.renderer.GlStateManager.*; - -import com.minelittlepony.client.ducks.IRenderPony; import com.minelittlepony.client.model.AbstractPonyModel; -import com.minelittlepony.client.model.IClientModel; -import com.minelittlepony.client.model.ModelWrapper; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer; import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.IPonyModel; import com.mojang.authlib.GameProfile; -import net.minecraft.block.BlockAbstractSkull; -import net.minecraft.block.BlockSkull.ISkullType; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; -import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityZombieVillager; -import net.minecraft.entity.passive.EntityVillager; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.block.AbstractSkullBlock; +import net.minecraft.block.SkullBlock.SkullType; +import net.minecraft.block.entity.SkullBlockEntity; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ArmorItem; +import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntitySkull; -import net.minecraft.util.EnumFacing; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.TagHelper; +import net.minecraft.util.math.Direction; +import net.minecraft.village.VillagerDataContainer; -@SuppressWarnings("deprecation") // ItemCameraTransforms is deprecated by forge but we still need it. -public class LayerPonyCustomHead implements LayerRenderer { +import static com.mojang.blaze3d.platform.GlStateManager.*; - private RenderLivingBase renderer; +public class LayerPonyCustomHead & IPonyModel> extends AbstractPonyLayer { - public LayerPonyCustomHead(RenderLivingBase renderPony) { - renderer = renderPony; + public LayerPonyCustomHead(IPonyRender renderPony) { + super(renderPony); } @Override public void render(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) { - ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); + ItemStack itemstack = entity.getEquippedStack(EquipmentSlot.HEAD); if (!itemstack.isEmpty()) { - IClientModel model = getModel().getBody(); + M model = getContext().getModelWrapper().getBody(); Item item = itemstack.getItem(); pushMatrix(); model.transform(BodyPart.HEAD); - model.getHead().postRender(0.0625f); + model.getHead().applyTransform(0.0625f); if (model instanceof AbstractPonyModel) { translatef(0, 0.2F, 0); @@ -58,11 +52,11 @@ public class LayerPonyCustomHead implements LayerRen color4f(1, 1, 1, 1); - if (item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof BlockAbstractSkull) { - boolean isVillager = entity instanceof EntityVillager || entity instanceof EntityZombieVillager; + if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof AbstractSkullBlock) { + boolean isVillager = entity instanceof VillagerDataContainer; renderSkull(itemstack, isVillager, move); - } else if (!(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD) { + } else if (!(item instanceof ArmorItem) || ((ArmorItem)item).getSlotType() != EquipmentSlot.HEAD) { renderBlock(entity, itemstack); } @@ -76,7 +70,7 @@ public class LayerPonyCustomHead implements LayerRen scalef(0.625F, -0.625F, -0.625F); translatef(0, 0.4F, -0.21F); - Minecraft.getInstance().getFirstPersonRenderer().renderItem(entity, itemstack, TransformType.HEAD); + MinecraftClient.getInstance().getFirstPersonRenderer().renderItem(entity, itemstack, ModelTransformation.Type.HEAD); } private void renderSkull(ItemStack itemstack, boolean isVillager, float limbSwing) { @@ -90,29 +84,25 @@ public class LayerPonyCustomHead implements LayerRen GameProfile profile = null; if (itemstack.hasTag()) { - NBTTagCompound nbt = itemstack.getTag(); + CompoundTag nbt = itemstack.getTag(); assert nbt != null; - if (nbt.contains("SkullOwner", 10)) { - profile = NBTUtil.readGameProfile(nbt.getCompound("SkullOwner")); - } else if (nbt.contains("SkullOwner", 8)) { - profile = TileEntitySkull.updateGameProfile(new GameProfile(null, nbt.getString("SkullOwner"))); - nbt.put("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), profile)); + if (nbt.containsKey("SkullOwner", 10)) { + profile = TagHelper.deserializeProfile(nbt.getCompound("SkullOwner")); + } else if (nbt.containsKey("SkullOwner", 8)) { + profile = SkullBlockEntity.loadProperties(new GameProfile(null, nbt.getString("SkullOwner"))); + nbt.put("SkullOwner", TagHelper.serializeProfile(new CompoundTag(), profile)); } } - ISkullType type = ((BlockAbstractSkull) ((ItemBlock) itemstack.getItem()).getBlock()).getSkullType(); + SkullType type = ((AbstractSkullBlock) ((BlockItem) itemstack.getItem()).getBlock()).getSkullType(); - PonySkullRenderer.resolve().render(-0.5F, 0, -0.45F, EnumFacing.UP, 180, type, profile, -1, limbSwing); - } - - private ModelWrapper getModel() { - return ((IRenderPony) renderer).getModelWrapper(); + PonySkullRenderer.resolve().render(-0.5F, 0, -0.45F, Direction.UP, 180, type, profile, -1, limbSwing); } @Override - public boolean shouldCombineTextures() { + public boolean hasHurtOverlay() { return true; } diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyElytra.java b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyElytra.java index 67b68856..55fdb374 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyElytra.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyElytra.java @@ -1,55 +1,56 @@ package com.minelittlepony.client.render.layer; import com.minelittlepony.client.model.components.PonyElytra; +import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.IPonyModel; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.layers.LayerArmorBase; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EnumPlayerModelParts; -import net.minecraft.init.Items; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.entity.PlayerModelPart; +import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.Items; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import javax.annotation.Nonnull; -public class LayerPonyElytra extends AbstractPonyLayer { +public class LayerPonyElytra & IPonyModel> extends AbstractPonyLayer { - private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png"); + private static final Identifier TEXTURE_ELYTRA = new Identifier("textures/entity/elytra.png"); - private final PonyElytra modelElytra = new PonyElytra(); + private final PonyElytra modelElytra = new PonyElytra<>(); - public LayerPonyElytra(RenderLivingBase rp) { + public LayerPonyElytra(IPonyRender rp) { super(rp); } @Override public void render(@Nonnull T entity, float move, float swing, float partialTicks, float ticks, float yaw, float head, float scale) { - ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); + ItemStack itemstack = entity.getEquippedStack(EquipmentSlot.CHEST); if (itemstack.getItem() == Items.ELYTRA) { GlStateManager.color4f(1, 1, 1, 1); - getRenderer().bindTexture(getElytraTexture(entity)); + getContext().bindTexture(getElytraTexture(entity)); GlStateManager.pushMatrix(); preRenderCallback(); - ModelBase elytra = getElytraModel(); + EntityModel elytra = getElytraModel(); if (elytra instanceof PonyElytra) { - ((PonyElytra)elytra).isSneaking = getPonyRenderer().getEntityPony(entity).isCrouching(entity); + ((PonyElytra)elytra).isSneaking = getContext().getEntityPony(entity).isCrouching(entity); } - elytra.setRotationAngles(move, swing, ticks, yaw, head, scale, entity); + elytra.setAngles(entity, move, swing, ticks, yaw, head, scale); elytra.render(entity, move, swing, ticks, yaw, head, scale); - if (itemstack.isEnchanted()) { - LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, elytra, move, swing, partialTicks, ticks, yaw, head, scale); + if (itemstack.hasEnchantmentGlint()) { + ArmorFeatureRenderer.renderEnchantedGlint(this::bindTexture, entity, elytra, move, swing, partialTicks, ticks, yaw, head, scale); } GlStateManager.popMatrix(); @@ -61,24 +62,24 @@ public class LayerPonyElytra extends AbstractPonyLay getPlayerModel().transform(BodyPart.BODY); } - protected ModelBase getElytraModel() { + protected EntityModel getElytraModel() { return modelElytra; } - protected ResourceLocation getElytraTexture(T entity) { - if (entity instanceof AbstractClientPlayer) { - AbstractClientPlayer player = (AbstractClientPlayer) entity; + protected Identifier getElytraTexture(T entity) { + if (entity instanceof AbstractClientPlayerEntity) { + AbstractClientPlayerEntity player = (AbstractClientPlayerEntity) entity; - ResourceLocation result; + Identifier result; - if (player.isPlayerInfoSet()) { - result = player.getLocationElytra(); + if (player.hasSkinTexture()) { + result = player.getElytraTexture(); if (result != null) return result; } - if (player.hasPlayerInfo() && player.isWearing(EnumPlayerModelParts.CAPE)) { - result = player.getLocationCape(); + if (player.hasSkinTexture() && player.isSkinOverlayVisible(PlayerModelPart.CAPE)) { + result = player.getCapeTexture(); if (result != null) return result; } @@ -86,10 +87,4 @@ public class LayerPonyElytra extends AbstractPonyLay return TEXTURE_ELYTRA; } - - @Override - public boolean shouldCombineTextures() { - return false; - } - } diff --git a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyStrayOverlay.java b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyStrayOverlay.java index bee1b7f1..646da218 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/LayerPonyStrayOverlay.java +++ b/src/client/java/com/minelittlepony/client/render/layer/LayerPonyStrayOverlay.java @@ -1,30 +1,29 @@ package com.minelittlepony.client.render.layer; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.entity.monster.EntityStray; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.entity.mob.AbstractSkeletonEntity; +import net.minecraft.util.Identifier; import com.minelittlepony.client.model.entities.ModelSkeletonPony; -public class LayerPonyStrayOverlay extends LayerOverlayBase { +public class LayerPonyStrayOverlay extends LayerOverlayBase> { - public static final ResourceLocation STRAY_SKELETON_OVERLAY = new ResourceLocation("minelittlepony", "textures/entity/skeleton/stray_pony_overlay.png"); + public static final Identifier STRAY_SKELETON_OVERLAY = new Identifier("minelittlepony", "textures/entity/skeleton/stray_pony_overlay.png"); - private final ModelSkeletonPony overlayModel = new ModelSkeletonPony(); + private final ModelSkeletonPony overlayModel = new ModelSkeletonPony<>(); - public LayerPonyStrayOverlay(RenderLivingBase render) { + public LayerPonyStrayOverlay(LivingEntityRenderer> render) { super(render); overlayModel.init(0, 0.25F); } @Override - protected ModelBase getOverlayModel() { + protected ModelSkeletonPony getOverlayModel() { return overlayModel; } @Override - protected ResourceLocation getOverlayTexture() { + protected Identifier getOverlayTexture() { return STRAY_SKELETON_OVERLAY; } } diff --git a/src/client/java/com/minelittlepony/client/render/layer/package-info.java b/src/client/java/com/minelittlepony/client/render/layer/package-info.java index ed667bf7..3d952696 100644 --- a/src/client/java/com/minelittlepony/client/render/layer/package-info.java +++ b/src/client/java/com/minelittlepony/client/render/layer/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.render.layer; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/render/package-info.java b/src/client/java/com/minelittlepony/client/render/package-info.java index 19921488..4414b602 100644 --- a/src/client/java/com/minelittlepony/client/render/package-info.java +++ b/src/client/java/com/minelittlepony/client/render/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.render; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/render/tileentities/skull/PlayerSkullRenderer.java b/src/client/java/com/minelittlepony/client/render/tileentities/skull/PlayerSkullRenderer.java index aff78018..6c58c68f 100644 --- a/src/client/java/com/minelittlepony/client/render/tileentities/skull/PlayerSkullRenderer.java +++ b/src/client/java/com/minelittlepony/client/render/tileentities/skull/PlayerSkullRenderer.java @@ -8,12 +8,12 @@ import com.minelittlepony.settings.PonyConfig; import com.minelittlepony.settings.PonyLevel; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.util.DefaultSkinHelper; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Identifier; import java.util.Map; import javax.annotation.Nullable; @@ -31,7 +31,7 @@ public class PlayerSkullRenderer extends PonySkull { @Override public void preRender(boolean transparency) { - GlStateManager.enableBlendProfile(GlStateManager.Profile.PLAYER_SKIN); + GlStateManager.setProfile(GlStateManager.RenderMode.PLAYER_SKIN); if (!transparency) { RenderPony.enableModelRenderProfile(); @@ -39,34 +39,35 @@ public class PlayerSkullRenderer extends PonySkull { } @Override - public ResourceLocation getSkinResource(@Nullable GameProfile profile) { + public Identifier getSkinResource(@Nullable GameProfile profile) { deadMau5.setVisible(profile != null && "deadmau5".equals(profile.getName())); if (profile != null) { - ResourceLocation skin = HDSkins.getInstance().getTextures(profile).get(Type.SKIN); + Identifier skin = HDSkins.getInstance().getTextures(profile).get(Type.SKIN); if (skin != null && Pony.getBufferedImage(skin) != null) { return skin; } - Minecraft minecraft = Minecraft.getInstance(); - Map map = minecraft.getSkinManager().loadSkinFromCache(profile); + MinecraftClient minecraft = MinecraftClient.getInstance(); + Map map = minecraft.getSkinProvider().getTextures(profile); if (map.containsKey(Type.SKIN)) { - ResourceLocation loc = minecraft.getSkinManager().loadSkin(map.get(Type.SKIN), Type.SKIN); + Identifier loc = minecraft.getSkinProvider().loadSkin(map.get(Type.SKIN), Type.SKIN); if (Pony.getBufferedImage(loc) != null) { return loc; } } - return DefaultPlayerSkin.getDefaultSkin(EntityPlayer.getUUID(profile)); + return DefaultSkinHelper.getTexture(PlayerEntity.getUuidFromProfile(profile)); } - return DefaultPlayerSkin.getDefaultSkinLegacy(); + return DefaultSkinHelper.getTexture(); } @Override public void render(float animateTicks, float rotation, float scale) { super.render(animateTicks, rotation, scale); - deadMau5.render(null, animateTicks, 0, 0, rotation, 0, scale); + /*render*/ + deadMau5.setRotationAngles(animateTicks, 0, 0, rotation, 0, scale); } } diff --git a/src/client/java/com/minelittlepony/client/render/tileentities/skull/PonySkull.java b/src/client/java/com/minelittlepony/client/render/tileentities/skull/PonySkull.java index ad3bbd45..24bd40e7 100644 --- a/src/client/java/com/minelittlepony/client/render/tileentities/skull/PonySkull.java +++ b/src/client/java/com/minelittlepony/client/render/tileentities/skull/PonySkull.java @@ -1,7 +1,5 @@ package com.minelittlepony.client.render.tileentities.skull; -import net.minecraft.client.Minecraft; - import com.minelittlepony.client.model.components.ModelPonyHead; import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer.ISkull; import com.minelittlepony.pony.IPony; @@ -22,6 +20,6 @@ public abstract class PonySkull implements ISkull { @Override public void render(float animateTicks, float rotation, float scale) { - ponyHead.render(Minecraft.getInstance().player, animateTicks, 0, 0, rotation, 0, scale); + ponyHead.setRotationAngles(animateTicks, 0, 0, rotation, 0, scale); } } \ No newline at end of file diff --git a/src/client/java/com/minelittlepony/client/render/tileentities/skull/PonySkullRenderer.java b/src/client/java/com/minelittlepony/client/render/tileentities/skull/PonySkullRenderer.java index 9b0a3dc2..dde1ed2e 100644 --- a/src/client/java/com/minelittlepony/client/render/tileentities/skull/PonySkullRenderer.java +++ b/src/client/java/com/minelittlepony/client/render/tileentities/skull/PonySkullRenderer.java @@ -6,14 +6,14 @@ import com.minelittlepony.client.ducks.IRenderItem; import com.minelittlepony.pony.IPony; import com.minelittlepony.settings.PonyConfig; import com.mojang.authlib.GameProfile; +import com.mojang.blaze3d.platform.GlStateManager; + +import net.minecraft.block.SkullBlock; +import net.minecraft.block.entity.SkullBlockEntity; +import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.Direction; -import net.minecraft.block.BlockSkull; -import net.minecraft.block.BlockSkull.ISkullType; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; -import net.minecraft.tileentity.TileEntitySkull; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import java.util.HashMap; @@ -23,7 +23,7 @@ import javax.annotation.Nullable; /** * PonySkullRenderer! It renders ponies as skulls, or something... */ -public class PonySkullRenderer extends TileEntitySkullRenderer implements IRenderItem { +public class PonySkullRenderer extends SkullBlockEntityRenderer implements IRenderItem { public static final int SKELETON = 0; public static final int WITHER = 1; @@ -33,15 +33,15 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende public static final int DRAGON = 5; public static PonySkullRenderer ponyInstance = new PonySkullRenderer(); - private static TileEntitySkullRenderer backup = null; + private static SkullBlockEntityRenderer backup = null; - private final Map skullMap = new HashMap<>(); + private final Map skullMap = new HashMap<>(); private PonySkullRenderer() { - skullMap.put(BlockSkull.Types.SKELETON, new SkeletonSkullRenderer()); - skullMap.put(BlockSkull.Types.WITHER_SKELETON, new WitherSkullRenderer()); - skullMap.put(BlockSkull.Types.ZOMBIE, new ZombieSkullRenderer()); - skullMap.put(BlockSkull.Types.PLAYER, new PlayerSkullRenderer()); + skullMap.put(SkullBlock.Type.SKELETON, new SkeletonSkullRenderer()); + skullMap.put(SkullBlock.Type.WITHER_SKELETON, new WitherSkullRenderer()); + skullMap.put(SkullBlock.Type.ZOMBIE, new ZombieSkullRenderer()); + skullMap.put(SkullBlock.Type.PLAYER, new PlayerSkullRenderer()); } /** @@ -50,31 +50,31 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende * * Original/Existing renderer is stored to a backup variable as a fallback in case of mods. */ - public static TileEntitySkullRenderer resolve() { + public static SkullBlockEntityRenderer resolve() { if (MineLittlePony.getInstance().getConfig().ponyskulls) { - if (!(instance instanceof PonySkullRenderer)) { - backup = instance; - MineLPClient.getInstance().getModUtilities().addRenderer(TileEntitySkull.class, ponyInstance); - instance = ponyInstance; + if (!(INSTANCE instanceof PonySkullRenderer)) { + backup = INSTANCE; + MineLPClient.getInstance().getModUtilities().addRenderer(SkullBlockEntity.class, ponyInstance); + INSTANCE = ponyInstance; } } else { - if ((instance instanceof PonySkullRenderer)) { - ponyInstance = (PonySkullRenderer) instance; + if ((INSTANCE instanceof PonySkullRenderer)) { + ponyInstance = (PonySkullRenderer) INSTANCE; if (backup == null) { - backup = new TileEntitySkullRenderer(); + backup = new SkullBlockEntityRenderer(); } - MineLPClient.getInstance().getModUtilities().addRenderer(TileEntitySkull.class, backup); - instance = backup; + MineLPClient.getInstance().getModUtilities().addRenderer(SkullBlockEntity.class, backup); + INSTANCE = backup; } } - return instance; + return INSTANCE; } protected boolean transparency = false; @Override - public void render(float x, float y, float z, EnumFacing facing, float rotation, ISkullType skullType, @Nullable GameProfile profile, int destroyStage, float animateTicks) { + public void render(float x, float y, float z, @Nullable Direction facing, float rotation, SkullBlock.SkullType skullType, @Nullable GameProfile profile, int destroyStage, float animateTicks) { ISkull skull = skullMap.get(skullType); @@ -91,14 +91,14 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende float scale = 0.0625F; if (destroyStage >= 0) { - bindTexture(DESTROY_STAGES[destroyStage]); + bindTexture(DESTROY_STAGE_TEXTURES[destroyStage]); GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.pushMatrix(); GlStateManager.scalef(4, 2, 1); GlStateManager.translatef(scale, scale, scale); GlStateManager.matrixMode(GL11.GL_MODELVIEW); } else { - ResourceLocation skin = skull.getSkinResource(profile); + Identifier skin = skull.getSkinResource(profile); skull.bindPony(MineLittlePony.getInstance().getManager().getPony(skin)); @@ -126,7 +126,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende } } - protected float handleRotation(float x, float y, float z, EnumFacing facing, float rotation) { + protected float handleRotation(float x, float y, float z, @Nullable Direction facing, float rotation) { switch (facing) { case EAST: default: @@ -171,7 +171,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende boolean canRender(PonyConfig config); - ResourceLocation getSkinResource(@Nullable GameProfile profile); + Identifier getSkinResource(@Nullable GameProfile profile); void bindPony(IPony pony); } diff --git a/src/client/java/com/minelittlepony/client/render/tileentities/skull/SkeletonSkullRenderer.java b/src/client/java/com/minelittlepony/client/render/tileentities/skull/SkeletonSkullRenderer.java index 90274fa2..3ac7e9e7 100644 --- a/src/client/java/com/minelittlepony/client/render/tileentities/skull/SkeletonSkullRenderer.java +++ b/src/client/java/com/minelittlepony/client/render/tileentities/skull/SkeletonSkullRenderer.java @@ -3,7 +3,7 @@ package com.minelittlepony.client.render.tileentities.skull; import com.minelittlepony.client.render.entities.RenderPonySkeleton; import com.minelittlepony.settings.PonyConfig; import com.mojang.authlib.GameProfile; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import javax.annotation.Nullable; @@ -15,7 +15,7 @@ public class SkeletonSkullRenderer extends PonySkull { } @Override - public ResourceLocation getSkinResource(@Nullable GameProfile profile) { + public Identifier getSkinResource(@Nullable GameProfile profile) { return RenderPonySkeleton.SKELETON; } } diff --git a/src/client/java/com/minelittlepony/client/render/tileentities/skull/WitherSkullRenderer.java b/src/client/java/com/minelittlepony/client/render/tileentities/skull/WitherSkullRenderer.java index 330892d9..dbee4d3b 100644 --- a/src/client/java/com/minelittlepony/client/render/tileentities/skull/WitherSkullRenderer.java +++ b/src/client/java/com/minelittlepony/client/render/tileentities/skull/WitherSkullRenderer.java @@ -3,7 +3,7 @@ package com.minelittlepony.client.render.tileentities.skull; import com.minelittlepony.client.render.entities.RenderPonySkeleton; import com.minelittlepony.settings.PonyConfig; import com.mojang.authlib.GameProfile; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import javax.annotation.Nullable; @@ -15,7 +15,7 @@ public class WitherSkullRenderer extends PonySkull { } @Override - public ResourceLocation getSkinResource(@Nullable GameProfile profile) { + public Identifier getSkinResource(@Nullable GameProfile profile) { return RenderPonySkeleton.WITHER; } } diff --git a/src/client/java/com/minelittlepony/client/render/tileentities/skull/ZombieSkullRenderer.java b/src/client/java/com/minelittlepony/client/render/tileentities/skull/ZombieSkullRenderer.java index 95116790..7e4d008e 100644 --- a/src/client/java/com/minelittlepony/client/render/tileentities/skull/ZombieSkullRenderer.java +++ b/src/client/java/com/minelittlepony/client/render/tileentities/skull/ZombieSkullRenderer.java @@ -3,7 +3,7 @@ package com.minelittlepony.client.render.tileentities.skull; import com.minelittlepony.client.render.entities.RenderPonyZombie; import com.minelittlepony.settings.PonyConfig; import com.mojang.authlib.GameProfile; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import javax.annotation.Nullable; @@ -15,7 +15,7 @@ public class ZombieSkullRenderer extends PonySkull { } @Override - public ResourceLocation getSkinResource(@Nullable GameProfile profile) { + public Identifier getSkinResource(@Nullable GameProfile profile) { return RenderPonyZombie.ZOMBIE; } } diff --git a/src/client/java/com/minelittlepony/client/render/tileentities/skull/package-info.java b/src/client/java/com/minelittlepony/client/render/tileentities/skull/package-info.java index 52827962..15070b06 100644 --- a/src/client/java/com/minelittlepony/client/render/tileentities/skull/package-info.java +++ b/src/client/java/com/minelittlepony/client/render/tileentities/skull/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.render.tileentities.skull; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/settings/package-info.java b/src/client/java/com/minelittlepony/client/settings/package-info.java index d3e9023d..a2026d44 100644 --- a/src/client/java/com/minelittlepony/client/settings/package-info.java +++ b/src/client/java/com/minelittlepony/client/settings/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.settings; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/transform/PonyPosture.java b/src/client/java/com/minelittlepony/client/transform/PonyPosture.java index 09fcae72..013ee88c 100644 --- a/src/client/java/com/minelittlepony/client/transform/PonyPosture.java +++ b/src/client/java/com/minelittlepony/client/transform/PonyPosture.java @@ -1,18 +1,19 @@ package com.minelittlepony.client.transform; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; -import com.minelittlepony.client.model.IClientModel; +import com.minelittlepony.client.model.ClientPonyModel; -public interface PonyPosture { - PonyPosture ELYTRA = new PostureElytra(); - PonyPosture FLIGHT = new PostureFlight(); - PonyPosture SWIMMING = new PostureSwimming(); - PonyPosture FALLING = new PostureFalling(); +public interface PonyPosture { + PonyPosture ELYTRA = new PostureElytra(); + PonyPosture FLIGHT = new PostureFlight(); + PonyPosture SWIMMING = new PostureSwimming(); + PonyPosture FALLING = new PostureFalling(); - default boolean applies(EntityLivingBase entity) { + default boolean applies(LivingEntity entity) { return true; } - void transform(IClientModel model, T entity, double motionX, double motionY, double motionZ, float yaw, float ticks); + void transform(ClientPonyModel model, T entity, double motionX, double motionY, double motionZ, float yaw, float ticks); } diff --git a/src/client/java/com/minelittlepony/client/transform/PonyTransformation.java b/src/client/java/com/minelittlepony/client/transform/PonyTransformation.java index d9a5229e..c9c0bfbc 100644 --- a/src/client/java/com/minelittlepony/client/transform/PonyTransformation.java +++ b/src/client/java/com/minelittlepony/client/transform/PonyTransformation.java @@ -1,12 +1,12 @@ package com.minelittlepony.client.transform; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.math.Vec3d; import com.google.common.collect.Maps; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.IModel; import com.minelittlepony.pony.meta.Size; +import com.mojang.blaze3d.platform.GlStateManager; import java.util.Map; diff --git a/src/client/java/com/minelittlepony/client/transform/PostureElytra.java b/src/client/java/com/minelittlepony/client/transform/PostureElytra.java index 92bf2c67..b4c0a2ae 100644 --- a/src/client/java/com/minelittlepony/client/transform/PostureElytra.java +++ b/src/client/java/com/minelittlepony/client/transform/PostureElytra.java @@ -1,13 +1,13 @@ package com.minelittlepony.client.transform; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.LivingEntity; -import com.minelittlepony.client.model.IClientModel; +import com.minelittlepony.client.model.ClientPonyModel; +import com.mojang.blaze3d.platform.GlStateManager; -public class PostureElytra implements PonyPosture { +public class PostureElytra implements PonyPosture { @Override - public void transform(IClientModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float yaw, float ticks) { + public void transform(ClientPonyModel model, LivingEntity entity, double motionX, double motionY, double motionZ, float yaw, float ticks) { GlStateManager.rotatef(90, 1, 0, 0); GlStateManager.translatef(0, entity.isSneaking() ? 0.2F : -1, 0); } diff --git a/src/client/java/com/minelittlepony/client/transform/PostureFalling.java b/src/client/java/com/minelittlepony/client/transform/PostureFalling.java index 1c9b293f..204dfae7 100644 --- a/src/client/java/com/minelittlepony/client/transform/PostureFalling.java +++ b/src/client/java/com/minelittlepony/client/transform/PostureFalling.java @@ -1,12 +1,12 @@ package com.minelittlepony.client.transform; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.LivingEntity; -import com.minelittlepony.client.model.IClientModel; +import com.minelittlepony.client.model.ClientPonyModel; -public class PostureFalling implements PonyPosture { +public class PostureFalling implements PonyPosture { @Override - public void transform(IClientModel model, EntityLivingBase entity, double motionX, double motionY, double motionZ, float yaw, float ticks) { + public void transform(ClientPonyModel model, LivingEntity entity, double motionX, double motionY, double motionZ, float yaw, float ticks) { model.setPitch(0); } } diff --git a/src/client/java/com/minelittlepony/client/transform/PostureFlight.java b/src/client/java/com/minelittlepony/client/transform/PostureFlight.java index e5f10cb5..2881fa3d 100644 --- a/src/client/java/com/minelittlepony/client/transform/PostureFlight.java +++ b/src/client/java/com/minelittlepony/client/transform/PostureFlight.java @@ -1,27 +1,27 @@ package com.minelittlepony.client.transform; -import com.minelittlepony.client.model.IClientModel; +import com.minelittlepony.client.model.ClientPonyModel; import com.minelittlepony.util.transform.MotionCompositor; +import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.LivingEntity; -public class PostureFlight extends MotionCompositor implements PonyPosture { +public class PostureFlight extends MotionCompositor implements PonyPosture { @Override - public boolean applies(EntityLivingBase entity) { - return entity instanceof AbstractClientPlayer; + public boolean applies(LivingEntity entity) { + return entity instanceof PlayerEntity; } @Override - public void transform(IClientModel model, AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float ticks) { + public void transform(ClientPonyModel model, PlayerEntity player, double motionX, double motionY, double motionZ, float yaw, float ticks) { model.setPitch((float) calculateIncline(player, motionX, motionY, motionZ)); GlStateManager.rotatef(model.getPitch(), 1, 0, 0); float roll = (float)calculateRoll(player, motionX, motionY, motionZ); - roll = model.getMetadata().getInterpolator(player.getUniqueID()).interpolate("pegasusRoll", roll, 10); + roll = model.getMetadata().getInterpolator(player.getUuid()).interpolate("pegasusRoll", roll, 10); GlStateManager.rotatef((float)roll, 0, 0, 1); } diff --git a/src/client/java/com/minelittlepony/client/transform/PostureSwimming.java b/src/client/java/com/minelittlepony/client/transform/PostureSwimming.java index 472cd081..35017aae 100644 --- a/src/client/java/com/minelittlepony/client/transform/PostureSwimming.java +++ b/src/client/java/com/minelittlepony/client/transform/PostureSwimming.java @@ -1,13 +1,13 @@ package com.minelittlepony.client.transform; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import com.minelittlepony.util.math.MathUtil; public class PostureSwimming extends PostureFlight { @Override - protected double calculateRoll(EntityPlayer player, double motionX, double motionY, double motionZ) { + protected double calculateRoll(PlayerEntity player, double motionX, double motionY, double motionZ) { motionX *= 2; motionZ *= 2; @@ -15,7 +15,7 @@ public class PostureSwimming extends PostureFlight { } @Override - protected double calculateIncline(EntityPlayer player, double motionX, double motionY, double motionZ) { + protected double calculateIncline(PlayerEntity player, double motionX, double motionY, double motionZ) { double motionLerp = MathUtil.clampLimit(Math.sqrt(motionX * motionX + motionZ * motionZ) * 30, 1); return super.calculateIncline(player, motionX, motionY, motionZ) * motionLerp; diff --git a/src/client/java/com/minelittlepony/client/transform/package-info.java b/src/client/java/com/minelittlepony/client/transform/package-info.java index 32c1b848..4c04e3b7 100644 --- a/src/client/java/com/minelittlepony/client/transform/package-info.java +++ b/src/client/java/com/minelittlepony/client/transform/package-info.java @@ -1,8 +1,5 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.transform; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/util/render/AbstractRenderer.java b/src/client/java/com/minelittlepony/client/util/render/AbstractRenderer.java index da4b72b0..320d2202 100644 --- a/src/client/java/com/minelittlepony/client/util/render/AbstractRenderer.java +++ b/src/client/java/com/minelittlepony/client/util/render/AbstractRenderer.java @@ -1,14 +1,12 @@ package com.minelittlepony.client.util.render; -import net.minecraft.client.renderer.entity.model.ModelBase; -import net.minecraft.client.renderer.entity.model.ModelBox; -import net.minecraft.client.renderer.entity.model.ModelRenderer; -import net.minecraft.client.renderer.entity.model.TextureOffset; +import net.minecraft.client.model.Cuboid; +import net.minecraft.client.model.Model; @SuppressWarnings("unchecked") -public abstract class AbstractRenderer> extends ModelRenderer { +public abstract class AbstractRenderer> extends Cuboid { - protected final ModelBase baseModel; + protected final Model baseModel; protected int textureOffsetX; protected int textureOffsetY; @@ -17,12 +15,12 @@ public abstract class AbstractRenderer> extends Mo protected float modelOffsetY; protected float modelOffsetZ; - public AbstractRenderer(ModelBase model) { + public AbstractRenderer(Model model) { super(model); baseModel = model; } - public AbstractRenderer(ModelBase model, int texX, int texY) { + public AbstractRenderer(Model model, int texX, int texY) { super(model, texX, texY); baseModel = model; } @@ -86,7 +84,7 @@ public abstract class AbstractRenderer> extends Mo /** * Adjusts the rotation center of the given renderer by the given amounts in each direction. */ - public static void shiftRotationPoint(ModelRenderer renderer, float x, float y, float z) { + public static void shiftRotationPoint(Cuboid renderer, float x, float y, float z) { renderer.rotationPointX += x; renderer.rotationPointY += y; renderer.rotationPointZ += z; @@ -96,9 +94,9 @@ public abstract class AbstractRenderer> extends Mo * Sets this renderer's rotation angles. */ public T rotate(float x, float y, float z) { - rotateAngleX = x; - rotateAngleY = y; - rotateAngleZ = z; + pitch = x; + yaw = y; + roll = z; return (T) this; } @@ -106,24 +104,24 @@ public abstract class AbstractRenderer> extends Mo * Positions a given model in space by setting its offset values divided * by 16 to account for scaling applied inside the model. */ - public static T at(T renderer, float x, float y, float z) { - renderer.offsetX = x / 16; - renderer.offsetY = y / 16; - renderer.offsetZ = z / 16; + public static T at(T renderer, float x, float y, float z) { + renderer.x = x / 16; + renderer.y = y / 16; + renderer.z = z / 16; return renderer; } /** * Rotates this model to align itself with the angles of another. */ - public void rotateTo(ModelRenderer other) { - rotate(other.rotateAngleX, other.rotateAngleY, other.rotateAngleZ); + public void rotateTo(Cuboid other) { + rotate(other.pitch, other.yaw, other.roll); } /** * Shifts this model to align its center with the center of another. */ - public T rotateAt(ModelRenderer other) { + public T rotateAt(Cuboid other) { return around(other.rotationPointX, other.rotationPointY, other.rotationPointZ); } @@ -140,10 +138,10 @@ public abstract class AbstractRenderer> extends Mo * New children will be of the same type and inherit the same textures and offsets of the original. */ public T child(int index) { - if (childModels == null || index >= childModels.size()) { + if (children == null || index >= children.size()) { return child(); } - return (T)childModels.get(index); + return (T)children.get(index); } /** @@ -160,19 +158,18 @@ public abstract class AbstractRenderer> extends Mo /** * Adds a new child renderer and returns itself for chaining. */ - public T child(K child) { + public T child(K child) { addChild(child); return (T)this; } @Override - public T addBox(String partName, float offX, float offY, float offZ, int width, int height, int depth) { - partName = boxName + "." + partName; + public T addBox(String partName, float offX, float offY, float offZ, int width, int height, int depth, float unknown, int texX, int texY) { + partName = name + "." + partName; - TextureOffset tex = baseModel.getTextureOffset(partName); - - setTextureOffset(tex.textureOffsetX, tex.textureOffsetY).addBox(offX, offY, offZ, width, height, depth); - cubeList.get(cubeList.size() - 1).setBoxName(partName); + setTextureOffset(texX, texY); + addBox(offX, offY, offZ, width, height, depth); + boxes.get(boxes.size() - 1).setName(partName); return (T) this; } @@ -209,6 +206,6 @@ public abstract class AbstractRenderer> extends Mo } protected void createBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor, boolean mirrored) { - cubeList.add(new ModelBox(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, mirrored)); + boxes.add(new Box<>(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, mirrored)); } } diff --git a/src/client/java/com/minelittlepony/client/util/render/Box.java b/src/client/java/com/minelittlepony/client/util/render/Box.java index f4416ab4..27a000df 100644 --- a/src/client/java/com/minelittlepony/client/util/render/Box.java +++ b/src/client/java/com/minelittlepony/client/util/render/Box.java @@ -1,9 +1,8 @@ package com.minelittlepony.client.util.render; -import net.minecraft.client.renderer.entity.model.ModelBox; -import net.minecraft.client.renderer.entity.model.ModelRenderer; +import net.minecraft.client.model.Cuboid; -public abstract class Box extends ModelBox { +public class Box extends net.minecraft.client.model.Box { protected final T parent; diff --git a/src/client/java/com/minelittlepony/client/util/render/Color.java b/src/client/java/com/minelittlepony/client/util/render/Color.java index 93a112b3..92b1d43e 100644 --- a/src/client/java/com/minelittlepony/client/util/render/Color.java +++ b/src/client/java/com/minelittlepony/client/util/render/Color.java @@ -1,6 +1,6 @@ package com.minelittlepony.client.util.render; -import net.minecraft.client.renderer.GlStateManager; +import com.mojang.blaze3d.platform.GlStateManager; /** * Colouration Utilities diff --git a/src/client/java/com/minelittlepony/client/util/render/GlowRenderer.java b/src/client/java/com/minelittlepony/client/util/render/GlowRenderer.java index 6612cab7..94b91077 100644 --- a/src/client/java/com/minelittlepony/client/util/render/GlowRenderer.java +++ b/src/client/java/com/minelittlepony/client/util/render/GlowRenderer.java @@ -1,7 +1,7 @@ package com.minelittlepony.client.util.render; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.model.ModelBase; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.model.Model; import org.lwjgl.opengl.GL11; @@ -10,7 +10,7 @@ public class GlowRenderer extends AbstractRenderer { int tint; float alpha = 1; - public GlowRenderer(ModelBase model, int x, int y) { + public GlowRenderer(Model model, int x, int y) { super(model, x, y); } @@ -32,13 +32,13 @@ public class GlowRenderer extends AbstractRenderer { @Override public void createBox(float offX, float offY, float offZ, int width, int height, int depth, float scaleFactor, boolean mirrored) { - cubeList.add(new HornGlow(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, alpha)); + boxes.add(new HornGlow(this, textureOffsetX, textureOffsetY, offX, offY, offZ, width, height, depth, scaleFactor, alpha)); } @Override public void render(float scale) { GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - Minecraft.getInstance().gameRenderer.disableLightmap(); + MinecraftClient.getInstance().gameRenderer.disableLightmap(); super.render(scale); GL11.glPopAttrib(); } diff --git a/src/client/java/com/minelittlepony/client/util/render/HornGlow.java b/src/client/java/com/minelittlepony/client/util/render/HornGlow.java index 3ab95085..fa797a3d 100644 --- a/src/client/java/com/minelittlepony/client/util/render/HornGlow.java +++ b/src/client/java/com/minelittlepony/client/util/render/HornGlow.java @@ -1,6 +1,6 @@ package com.minelittlepony.client.util.render; -import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.render.BufferBuilder; /** * Like a normal box, but with the top narrowed a bit. @@ -58,7 +58,7 @@ public class HornGlow extends Box { if (renderer.mirror) { for (Quad i : quadList) { - i.flipFace(); + i.flip(); } } } @@ -68,7 +68,7 @@ public class HornGlow extends Box { parent.applyTint(alpha); for (Quad i : quadList) { - i.draw(buffer, scale); + i.render(buffer, scale); } } } diff --git a/src/client/java/com/minelittlepony/client/util/render/PonyRenderer.java b/src/client/java/com/minelittlepony/client/util/render/PonyRenderer.java index 7e07349f..d30a6e78 100644 --- a/src/client/java/com/minelittlepony/client/util/render/PonyRenderer.java +++ b/src/client/java/com/minelittlepony/client/util/render/PonyRenderer.java @@ -1,14 +1,14 @@ package com.minelittlepony.client.util.render; -import net.minecraft.client.renderer.entity.model.ModelBase; +import net.minecraft.client.model.Model; public class PonyRenderer extends AbstractRenderer { - public PonyRenderer(ModelBase model) { + public PonyRenderer(Model model) { super(model); } - public PonyRenderer(ModelBase model, int texX, int texY) { + public PonyRenderer(Model model, int texX, int texY) { super(model, texX, texY); } diff --git a/src/client/java/com/minelittlepony/client/util/render/Quad.java b/src/client/java/com/minelittlepony/client/util/render/Quad.java index 9fd947d3..83471a90 100644 --- a/src/client/java/com/minelittlepony/client/util/render/Quad.java +++ b/src/client/java/com/minelittlepony/client/util/render/Quad.java @@ -1,8 +1,6 @@ package com.minelittlepony.client.util.render; -import net.minecraft.client.renderer.entity.model.TexturedQuad; - -public class Quad extends TexturedQuad { +public class Quad extends net.minecraft.client.model.Quad { Quad(Vertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) { super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight); @@ -31,7 +29,7 @@ public class Quad extends TexturedQuad { * */ @Override - public void flipFace() { - super.flipFace(); + public void flip() { + super.flip(); } } \ No newline at end of file diff --git a/src/client/java/com/minelittlepony/client/util/render/Vertex.java b/src/client/java/com/minelittlepony/client/util/render/Vertex.java index 63021cfe..176a57e6 100644 --- a/src/client/java/com/minelittlepony/client/util/render/Vertex.java +++ b/src/client/java/com/minelittlepony/client/util/render/Vertex.java @@ -1,8 +1,6 @@ package com.minelittlepony.client.util.render; -import net.minecraft.client.renderer.entity.model.PositionTextureVertex; - -public class Vertex extends PositionTextureVertex { +public class Vertex extends net.minecraft.client.model.Vertex { public Vertex(float x, float y, float z, float texX, float texY) { super(x, y, z, texX, texY); @@ -15,7 +13,7 @@ public class Vertex extends PositionTextureVertex { // The MCP name is misleading. // This is meant to return a COPY with the given texture position @Override - public Vertex setTexturePosition(float texX, float texY) { + public Vertex remap(float texX, float texY) { return new Vertex(this, texX, texY); } } diff --git a/src/client/java/com/minelittlepony/client/util/render/package-info.java b/src/client/java/com/minelittlepony/client/util/render/package-info.java index 906e6df7..4b1036d0 100644 --- a/src/client/java/com/minelittlepony/client/util/render/package-info.java +++ b/src/client/java/com/minelittlepony/client/util/render/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.util.render; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/util/render/plane/ModelPlane.java b/src/client/java/com/minelittlepony/client/util/render/plane/ModelPlane.java index 2924b26b..fc370b73 100644 --- a/src/client/java/com/minelittlepony/client/util/render/plane/ModelPlane.java +++ b/src/client/java/com/minelittlepony/client/util/render/plane/ModelPlane.java @@ -1,6 +1,6 @@ package com.minelittlepony.client.util.render.plane; -import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.render.BufferBuilder; import com.minelittlepony.client.util.render.Box; import com.minelittlepony.client.util.render.Quad; @@ -73,12 +73,14 @@ public class ModelPlane extends Box { } if (renderer.mirror || renderer.mirrory || renderer.mirrorz) { - quad.flipFace(); + quad.flip(); } } @Override public void render(@Nonnull BufferBuilder buffer, float scale) { - if (!hidden) quad.draw(buffer, scale); + if (!hidden) { + quad.render(buffer, scale); + } } } diff --git a/src/client/java/com/minelittlepony/client/util/render/plane/PlaneRenderer.java b/src/client/java/com/minelittlepony/client/util/render/plane/PlaneRenderer.java index d22f3ba3..4552b7a3 100644 --- a/src/client/java/com/minelittlepony/client/util/render/plane/PlaneRenderer.java +++ b/src/client/java/com/minelittlepony/client/util/render/plane/PlaneRenderer.java @@ -1,6 +1,6 @@ package com.minelittlepony.client.util.render.plane; -import net.minecraft.client.renderer.entity.model.ModelBase; +import net.minecraft.client.model.Model; import com.minelittlepony.client.util.render.AbstractRenderer; @@ -8,11 +8,11 @@ public class PlaneRenderer extends AbstractRenderer { public boolean mirrory, mirrorz; - public PlaneRenderer(ModelBase model) { + public PlaneRenderer(Model model) { super(model); } - public PlaneRenderer(ModelBase model, int x, int y) { + public PlaneRenderer(Model model, int x, int y) { super(model, x, y); } @@ -24,7 +24,6 @@ public class PlaneRenderer extends AbstractRenderer { return this; } - /** * Flips the Y bit. Any calls to add a plane will be mirrored until this is called again. */ @@ -39,7 +38,7 @@ public class PlaneRenderer extends AbstractRenderer { } private PlaneRenderer addPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale, Plane face) { - cubeList.add(new ModelPlane(this, textureOffsetX, textureOffsetY, modelOffsetX + offX, modelOffsetY + offY, modelOffsetZ + offZ, width, height, depth, scale, face)); + boxes.add(new ModelPlane(this, textureOffsetX, textureOffsetY, modelOffsetX + offX, modelOffsetY + offY, modelOffsetZ + offZ, width, height, depth, scale, face)); return this; } diff --git a/src/client/java/com/minelittlepony/client/util/render/plane/package-info.java b/src/client/java/com/minelittlepony/client/util/render/plane/package-info.java index 5c5766a7..7b1cafa4 100644 --- a/src/client/java/com/minelittlepony/client/util/render/plane/package-info.java +++ b/src/client/java/com/minelittlepony/client/util/render/plane/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.client.util.render.plane; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/fml/java/com/minelittlepony/PonyMod.java b/src/fml/java/com/minelittlepony/PonyMod.java deleted file mode 100644 index 6eeb9323..00000000 --- a/src/fml/java/com/minelittlepony/PonyMod.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.minelittlepony; - -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; - -import com.minelittlepony.client.ForgeModMineLittlePony; - -/** - * Proxy MineLP so it doesn't run on the server. - * - * We do allow it to be installed on the server, but it won't do anything. - * Only reason you would need it on that side is as a library for other mods. - */ -@Mod("minelittlepony") -public class PonyMod { - public PonyMod() { - FMLJavaModLoadingContext.get().getModEventBus().register(this); - } - - @SubscribeEvent - public void initOnClient(FMLClientSetupEvent event) { - new ForgeModMineLittlePony(event.getMinecraftSupplier().get()); - } -} diff --git a/src/fml/java/com/minelittlepony/client/ForgeModMineLittlePony.java b/src/fml/java/com/minelittlepony/client/ForgeModMineLittlePony.java deleted file mode 100644 index a5b034b3..00000000 --- a/src/fml/java/com/minelittlepony/client/ForgeModMineLittlePony.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.minelittlepony.client; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.client.registry.ClientRegistry; -import net.minecraftforge.fml.client.registry.RenderingRegistry; -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fml.loading.FMLPaths; - -public class ForgeModMineLittlePony implements IModUtilities { - - private final MineLPClient mlp = new MineLPClient(this); - - public ForgeModMineLittlePony(Minecraft mc) { - FMLJavaModLoadingContext.get().getModEventBus().register(this); - MinecraftForge.EVENT_BUS.register(this); - - mlp.init(Config.of(FMLPaths.CONFIGDIR.get().resolve("minelittlepony.json"))); - mlp.postInit(mc); - } - - @SubscribeEvent - public void onClientTick(ClientTickEvent event) { - mlp.onTick(Minecraft.getInstance(), Minecraft.getInstance().world != null); - } - - @Override - public void addRenderer(Class type, TileEntityRenderer renderer) { - ClientRegistry.bindTileEntitySpecialRenderer(type, renderer); - } - - @Override - public void addRenderer(Class type, Render renderer) { - RenderingRegistry.registerEntityRenderingHandler(type, rm -> renderer); - } - - @Override - public boolean hasFml() { - return true; - } - - @Override - public float getRenderPartialTicks() { - return Minecraft.getInstance().getRenderPartialTicks(); - } -} diff --git a/src/main/java/com/minelittlepony/model/ICompartmented.java b/src/main/java/com/minelittlepony/model/ICompartmented.java new file mode 100644 index 00000000..11cf47a6 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/ICompartmented.java @@ -0,0 +1,5 @@ +package com.minelittlepony.model; + +public interface ICompartmented { + Part getBodyPart(BodyPart part); +} diff --git a/src/main/java/com/minelittlepony/model/IModel.java b/src/main/java/com/minelittlepony/model/IModel.java index 3cef5621..a157b7ad 100644 --- a/src/main/java/com/minelittlepony/model/IModel.java +++ b/src/main/java/com/minelittlepony/model/IModel.java @@ -1,12 +1,14 @@ package com.minelittlepony.model; +import net.minecraft.client.render.entity.model.ModelWithArms; + import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.pony.IPonyData; import com.minelittlepony.pony.meta.Size; import com.minelittlepony.pony.meta.Wearable; -public interface IModel { +public interface IModel extends ModelWithArms { /** * Sets up this model's initial values, like a constructor... diff --git a/src/main/java/com/minelittlepony/model/IPart.java b/src/main/java/com/minelittlepony/model/IPart.java index ff61ef9e..7fed7545 100644 --- a/src/main/java/com/minelittlepony/model/IPart.java +++ b/src/main/java/com/minelittlepony/model/IPart.java @@ -2,7 +2,7 @@ package com.minelittlepony.model; import java.util.UUID; -public interface IPart { +public interface IPart extends PonyModelConstants { /** * Initialises all of the boxes in this modelpart. * @param yOffset diff --git a/src/main/java/com/minelittlepony/model/IPonyMixinModel.java b/src/main/java/com/minelittlepony/model/IPonyMixinModel.java new file mode 100644 index 00000000..1f922c05 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/IPonyMixinModel.java @@ -0,0 +1,147 @@ +package com.minelittlepony.model; + +import net.minecraft.client.model.Cuboid; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.AbsoluteHand; + +import com.minelittlepony.model.armour.IEquestrianArmour; +import com.minelittlepony.pony.IPonyData; +import com.minelittlepony.pony.meta.Size; + +public interface IPonyMixinModel> extends IPonyModel { + + M mixin(); + + @Override + default void init(float yOffset, float stretch) { + mixin().init(yOffset, stretch); + } + + @Override + default void transform(BodyPart part) { + mixin().transform(part); + } + + @Override + default void setPitch(float pitch) { + mixin().setPitch(pitch); + } + + @Override + default float getPitch() { + return mixin().getPitch(); + } + + @Override + default Size getSize() { + return mixin().getSize(); + } + + @Override + default IEquestrianArmour createArmour() { + return mixin().createArmour(); + } + + @Override + default IPonyData getMetadata() { + return mixin().getMetadata(); + } + + @Override + default void apply(IPonyData meta) { + mixin().apply(meta); + } + + @Override + default boolean isCrouching() { + return mixin().isCrouching(); + } + + @Override + default boolean isFlying() { + return mixin().isFlying(); + } + + @Override + default boolean isElytraFlying() { + return mixin().isElytraFlying(); + } + + @Override + default boolean isSleeping() { + return mixin().isSleeping(); + } + + @Override + default boolean isSwimming() { + return mixin().isSwimming(); + } + + @Override + default boolean isRiding() { + return mixin().isRiding(); + } + + @Override + default boolean isGoingFast() { + return mixin().isGoingFast(); + } + + @Override + default boolean isChild() { + return mixin().isChild(); + } + + @Override + default float getSwingAmount() { + return mixin().getSwingAmount(); + } + + @Override + default float getWobbleAmount() { + return mixin().getWobbleAmount(); + } + + @Override + default float getRiderYOffset() { + return mixin().getRiderYOffset(); + } + + @Override + default float getModelHeight() { + return mixin().getModelHeight(); + } + + @Override + default void setArmAngle(float var1, AbsoluteHand var2) { + mixin().setArmAngle(var1, var2); + } + + @Override + default Cuboid getHead() { + return mixin().getHead(); + } + + @Override + default boolean hasHeadGear() { + return mixin().hasHeadGear(); + } + + @Override + default Cuboid getBodyPart(BodyPart part) { + return mixin().getBodyPart(part); + } + + interface Caster & IUnicorn, Arm> extends IPonyMixinModel, IUnicorn { + + @Override + default Arm getUnicornArmForSide(AbsoluteHand side) { + return mixin().getUnicornArmForSide(side); + } + + @Override + default boolean isCasting() { + return mixin().isCasting(); + } + } +} diff --git a/src/main/java/com/minelittlepony/model/IPonyModel.java b/src/main/java/com/minelittlepony/model/IPonyModel.java new file mode 100644 index 00000000..01a3165c --- /dev/null +++ b/src/main/java/com/minelittlepony/model/IPonyModel.java @@ -0,0 +1,8 @@ +package com.minelittlepony.model; + +import net.minecraft.client.model.Cuboid; +import net.minecraft.entity.LivingEntity; + +public interface IPonyModel extends PonyModelConstants, IModel, ICapitated, ICompartmented { + +} diff --git a/src/main/java/com/minelittlepony/model/IUnicorn.java b/src/main/java/com/minelittlepony/model/IUnicorn.java index f0db94a8..c8cf708b 100644 --- a/src/main/java/com/minelittlepony/model/IUnicorn.java +++ b/src/main/java/com/minelittlepony/model/IUnicorn.java @@ -1,12 +1,12 @@ package com.minelittlepony.model; -import net.minecraft.util.EnumHandSide; +import net.minecraft.util.AbsoluteHand; public interface IUnicorn extends IModel { /** * Gets the arm used for holding items in their magic. */ - Arm getUnicornArmForSide(EnumHandSide side); + Arm getUnicornArmForSide(AbsoluteHand side); /** * Returns true if this model is being applied to a race that can use magic. diff --git a/src/main/java/com/minelittlepony/model/armour/IArmour.java b/src/main/java/com/minelittlepony/model/armour/IArmour.java index 51bb5492..2b95e361 100644 --- a/src/main/java/com/minelittlepony/model/armour/IArmour.java +++ b/src/main/java/com/minelittlepony/model/armour/IArmour.java @@ -1,6 +1,6 @@ package com.minelittlepony.model.armour; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.EquipmentSlot; import com.minelittlepony.model.IModel; @@ -25,7 +25,7 @@ public interface IArmour { * * @return false to skip this render pass. */ - default boolean prepareToRender(EntityEquipmentSlot slot, ArmourLayer layer) { + default boolean prepareToRender(EquipmentSlot slot, ArmourLayer layer) { setInVisible(); switch (layer) { diff --git a/src/main/java/com/minelittlepony/model/armour/IArmourTextureResolver.java b/src/main/java/com/minelittlepony/model/armour/IArmourTextureResolver.java index 800a1be9..2afab3cd 100644 --- a/src/main/java/com/minelittlepony/model/armour/IArmourTextureResolver.java +++ b/src/main/java/com/minelittlepony/model/armour/IArmourTextureResolver.java @@ -1,16 +1,16 @@ package com.minelittlepony.model.armour; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import javax.annotation.Nullable; -public interface IArmourTextureResolver { +public interface IArmourTextureResolver { /** * Gets the armour texture to be used for the given entity, armour piece, slot, and render layer. */ - ResourceLocation getArmourTexture(T entity, ItemStack itemstack, EntityEquipmentSlot slot, ArmourLayer layer, @Nullable String type); + Identifier getArmourTexture(T entity, ItemStack itemstack, EquipmentSlot slot, ArmourLayer layer, @Nullable String type); } diff --git a/src/main/java/com/minelittlepony/model/armour/package-info.java b/src/main/java/com/minelittlepony/model/armour/package-info.java index ce1fed56..27bfae36 100644 --- a/src/main/java/com/minelittlepony/model/armour/package-info.java +++ b/src/main/java/com/minelittlepony/model/armour/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.model.armour; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/model/capabilities/package-info.java b/src/main/java/com/minelittlepony/model/capabilities/package-info.java index 85345172..d1b0bb02 100644 --- a/src/main/java/com/minelittlepony/model/capabilities/package-info.java +++ b/src/main/java/com/minelittlepony/model/capabilities/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.model.capabilities; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/client/java/com/minelittlepony/client/model/gear/IGear.java b/src/main/java/com/minelittlepony/model/gear/IGear.java similarity index 73% rename from src/client/java/com/minelittlepony/client/model/gear/IGear.java rename to src/main/java/com/minelittlepony/model/gear/IGear.java index 31d414cf..fe29e3dd 100644 --- a/src/client/java/com/minelittlepony/client/model/gear/IGear.java +++ b/src/main/java/com/minelittlepony/model/gear/IGear.java @@ -1,11 +1,11 @@ -package com.minelittlepony.client.model.gear; +package com.minelittlepony.model.gear; import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; -import com.minelittlepony.client.model.IClientModel; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.IPart; +import com.minelittlepony.model.IPonyModel; import javax.annotation.Nullable; @@ -19,7 +19,7 @@ public interface IGear extends IPart { * * @return True to render this wearable */ - boolean canRender(IClientModel model, Entity entity); + boolean canRender(IPonyModel model, Entity entity); /** * Gets the body location that this wearable appears on. @@ -31,12 +31,12 @@ public interface IGear extends IPart { * Return null to use the same as the primary model. */ @Nullable - ResourceLocation getTexture(Entity entity); + Identifier getTexture(Entity entity); /** * Orients this wearable. */ - default void setLivingAnimations(IClientModel model, Entity entity) { + default void setLivingAnimations(IPonyModel model, Entity entity) { } diff --git a/src/client/java/com/minelittlepony/client/model/gear/IStackable.java b/src/main/java/com/minelittlepony/model/gear/IStackable.java similarity index 58% rename from src/client/java/com/minelittlepony/client/model/gear/IStackable.java rename to src/main/java/com/minelittlepony/model/gear/IStackable.java index beb01503..8d6e913f 100644 --- a/src/client/java/com/minelittlepony/client/model/gear/IStackable.java +++ b/src/main/java/com/minelittlepony/model/gear/IStackable.java @@ -1,4 +1,4 @@ -package com.minelittlepony.client.model.gear; +package com.minelittlepony.model.gear; public interface IStackable { float getStackingOffset(); diff --git a/src/main/java/com/minelittlepony/model/gear/package-info.java b/src/main/java/com/minelittlepony/model/gear/package-info.java new file mode 100644 index 00000000..73947b89 --- /dev/null +++ b/src/main/java/com/minelittlepony/model/gear/package-info.java @@ -0,0 +1,4 @@ +@ParametersAreNonnullByDefault +package com.minelittlepony.model.gear; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/model/package-info.java b/src/main/java/com/minelittlepony/model/package-info.java index 6dc6a541..7c3428bf 100644 --- a/src/main/java/com/minelittlepony/model/package-info.java +++ b/src/main/java/com/minelittlepony/model/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.model; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/package-info.java b/src/main/java/com/minelittlepony/package-info.java index a1d3fc42..771b00df 100644 --- a/src/main/java/com/minelittlepony/package-info.java +++ b/src/main/java/com/minelittlepony/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/pony/IPony.java b/src/main/java/com/minelittlepony/pony/IPony.java index d588d6cd..63f83ad1 100644 --- a/src/main/java/com/minelittlepony/pony/IPony.java +++ b/src/main/java/com/minelittlepony/pony/IPony.java @@ -1,8 +1,8 @@ package com.minelittlepony.pony; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.BoundingBox; import net.minecraft.util.math.Vec3d; import com.minelittlepony.MineLittlePony; @@ -14,7 +14,7 @@ public interface IPony { * Gets or creates a new pony associated with the provided resource location. * The results of this method should not be cached. */ - static IPony forResource(ResourceLocation texture) { + static IPony forResource(Identifier texture) { return MineLittlePony.getInstance().getManager().getPony(texture); } @@ -28,7 +28,7 @@ public interface IPony { /** * Checks the required conditions for whether the given entity can perform a sonic rainboom. */ - boolean isPerformingRainboom(EntityLivingBase entity); + boolean isPerformingRainboom(LivingEntity entity); /** * Unlike sneaking, crouching is a more specific animation parameter that controls whether the player is visible @@ -36,7 +36,7 @@ public interface IPony { * * You cannot crouch whilst flying or swimming. */ - boolean isCrouching(EntityLivingBase entity); + boolean isCrouching(LivingEntity entity); /** * Returns true if the provided entity is flying like a pegasus. @@ -45,24 +45,24 @@ public interface IPony { * * Entities that are riding, climbing a ladder, or swimming are not flying. */ - boolean isFlying(EntityLivingBase entity); + boolean isFlying(LivingEntity entity); /** * Returns true if the provided entity is actively swimming. * That is, it should be fully submerged (isFullySubmerged returns true) * and is not standing on the (river) bed or riding a ladder or any other entity. */ - boolean isSwimming(EntityLivingBase entity); + boolean isSwimming(LivingEntity entity); /** * Returns true if the provided entity is fully submerged with water reaching the entity's eyeheight or above. */ - boolean isFullySubmerged(EntityLivingBase entity); + boolean isFullySubmerged(LivingEntity entity); /** * Returns true if the provided entity is partially submerged. That is if any part of it is in contact with water. */ - boolean isPartiallySubmerged(EntityLivingBase entity); + boolean isPartiallySubmerged(LivingEntity entity); /** * Returns true if an entity is wearing any headgear. This is used to hide things like the snout when wearing items @@ -70,7 +70,7 @@ public interface IPony { * * In this case the helmet does not count as headgear because those generally don't interfere with snuzzle rendering. */ - boolean isWearingHeadgear(EntityLivingBase entity); + boolean isWearingHeadgear(LivingEntity entity); /** * Gets the race associated with this pony. @@ -84,17 +84,17 @@ public interface IPony { * * Boats do not count. */ - boolean isRidingInteractive(EntityLivingBase entity); + boolean isRidingInteractive(LivingEntity entity); /** * Returns the pony this entity is currently riding if any. */ - IPony getMountedPony(EntityLivingBase entity); + IPony getMountedPony(LivingEntity entity); /** * Gets the texture used for rendering this pony. */ - ResourceLocation getTexture(); + Identifier getTexture(); /** * Gets the metadata associated with this pony's model texture. @@ -104,10 +104,10 @@ public interface IPony { /** * Gets the riding offset of this entity relative to its lowermost mount. */ - Vec3d getAbsoluteRidingOffset(EntityLivingBase entity); + Vec3d getAbsoluteRidingOffset(LivingEntity entity); /** * Gets the actual bounding box of this entity as a pony. */ - AxisAlignedBB getComputedBoundingBox(EntityLivingBase entity); + BoundingBox getComputedBoundingBox(LivingEntity entity); } diff --git a/src/main/java/com/minelittlepony/pony/IPonyManager.java b/src/main/java/com/minelittlepony/pony/IPonyManager.java index 51258f1f..b52dfe60 100644 --- a/src/main/java/com/minelittlepony/pony/IPonyManager.java +++ b/src/main/java/com/minelittlepony/pony/IPonyManager.java @@ -1,7 +1,7 @@ package com.minelittlepony.pony; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Identifier; import java.util.UUID; @@ -11,8 +11,8 @@ import java.util.UUID; */ public interface IPonyManager { - public static final ResourceLocation STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png"); - public static final ResourceLocation ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png"); + public static final Identifier STEVE = new Identifier("minelittlepony", "textures/entity/steve_pony.png"); + public static final Identifier ALEX = new Identifier("minelittlepony", "textures/entity/alex_pony.png"); public static final String BGPONIES_JSON = "textures/entity/pony/bgponies.json"; @@ -22,14 +22,14 @@ public interface IPonyManager { * * @param player the player */ - public IPony getPony(EntityPlayer player); + public IPony getPony(PlayerEntity player); /** * Gets or creates a pony for the given skin resource and vanilla model type. * * @param resource A texture resource */ - public IPony getPony(ResourceLocation resource); + public IPony getPony(Identifier resource); /** * Gets or creates a pony for the given skin resource and entity id. @@ -41,7 +41,7 @@ public interface IPonyManager { * @param resource A texture resource * @param uuid id of a player or entity */ - IPony getPony(ResourceLocation resource, UUID uuid); + IPony getPony(Identifier resource, UUID uuid); /** * Gets the default pony. Either STEVE/ALEX, or a background pony based on client settings. @@ -62,9 +62,9 @@ public interface IPonyManager { /** * De-registers a pony from the cache. */ - IPony removePony(ResourceLocation resource); + IPony removePony(Identifier resource); - public static ResourceLocation getDefaultSkin(UUID uuid) { + public static Identifier getDefaultSkin(UUID uuid) { return isSlimSkin(uuid) ? ALEX : STEVE; } diff --git a/src/main/java/com/minelittlepony/pony/meta/TriggerPixels.java b/src/main/java/com/minelittlepony/pony/meta/TriggerPixels.java index 310ca3c2..027714b4 100644 --- a/src/main/java/com/minelittlepony/pony/meta/TriggerPixels.java +++ b/src/main/java/com/minelittlepony/pony/meta/TriggerPixels.java @@ -1,6 +1,6 @@ package com.minelittlepony.pony.meta; -import net.minecraft.client.renderer.texture.NativeImage; +import net.minecraft.client.texture.NativeImage; import com.minelittlepony.pony.ITriggerPixelMapped; diff --git a/src/main/java/com/minelittlepony/pony/meta/package-info.java b/src/main/java/com/minelittlepony/pony/meta/package-info.java index 8e62106e..09fddcc4 100644 --- a/src/main/java/com/minelittlepony/pony/meta/package-info.java +++ b/src/main/java/com/minelittlepony/pony/meta/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.pony.meta; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/pony/package-info.java b/src/main/java/com/minelittlepony/pony/package-info.java index d971405b..29d2d648 100644 --- a/src/main/java/com/minelittlepony/pony/package-info.java +++ b/src/main/java/com/minelittlepony/pony/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.pony; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/settings/package-info.java b/src/main/java/com/minelittlepony/settings/package-info.java index 644ea348..f4dfe2cc 100644 --- a/src/main/java/com/minelittlepony/settings/package-info.java +++ b/src/main/java/com/minelittlepony/settings/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.settings; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/util/animation/package-info.java b/src/main/java/com/minelittlepony/util/animation/package-info.java index 6251f69b..73d99850 100644 --- a/src/main/java/com/minelittlepony/util/animation/package-info.java +++ b/src/main/java/com/minelittlepony/util/animation/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.util.animation; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/util/chron/package-info.java b/src/main/java/com/minelittlepony/util/chron/package-info.java index d3f32e34..24755cdc 100644 --- a/src/main/java/com/minelittlepony/util/chron/package-info.java +++ b/src/main/java/com/minelittlepony/util/chron/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.util.chron; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/util/math/package-info.java b/src/main/java/com/minelittlepony/util/math/package-info.java index 5d02780c..78630895 100644 --- a/src/main/java/com/minelittlepony/util/math/package-info.java +++ b/src/main/java/com/minelittlepony/util/math/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.util.math; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/util/resources/FormattedTextureSupplier.java b/src/main/java/com/minelittlepony/util/resources/FormattedTextureSupplier.java index 90f79c4e..0f7236a6 100644 --- a/src/main/java/com/minelittlepony/util/resources/FormattedTextureSupplier.java +++ b/src/main/java/com/minelittlepony/util/resources/FormattedTextureSupplier.java @@ -1,6 +1,6 @@ package com.minelittlepony.util.resources; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; /** * Supplies new resource locations based on a pre-defined domain and formatted path. @@ -16,8 +16,7 @@ public class FormattedTextureSupplier implements ITextureSupplier { } @Override - public ResourceLocation supplyTexture(String key) { - return new ResourceLocation(domain, String.format(path, key)); + public Identifier supplyTexture(String key) { + return new Identifier(domain, String.format(path, key)); } - } diff --git a/src/main/java/com/minelittlepony/util/resources/ITextureSupplier.java b/src/main/java/com/minelittlepony/util/resources/ITextureSupplier.java index 1a66a904..6a520e3e 100644 --- a/src/main/java/com/minelittlepony/util/resources/ITextureSupplier.java +++ b/src/main/java/com/minelittlepony/util/resources/ITextureSupplier.java @@ -1,6 +1,6 @@ package com.minelittlepony.util.resources; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; /** * A texture pool for generating multiple associated textures. @@ -10,5 +10,5 @@ public interface ITextureSupplier { /** * Supplies a new texture. May be generated for returned from a pool indexed by the given key. */ - ResourceLocation supplyTexture(T key); + Identifier supplyTexture(T key); } diff --git a/src/main/java/com/minelittlepony/util/resources/ProfessionStringMapper.java b/src/main/java/com/minelittlepony/util/resources/ProfessionStringMapper.java new file mode 100644 index 00000000..3e1b4ad2 --- /dev/null +++ b/src/main/java/com/minelittlepony/util/resources/ProfessionStringMapper.java @@ -0,0 +1,14 @@ +package com.minelittlepony.util.resources; + +import net.minecraft.village.VillagerData; + +import java.util.function.Function; + +public class ProfessionStringMapper implements Function { + + @Override + public String apply(VillagerData t) { + return String.format("level_%d_%s", t.getLevel(), t.getProfession().toString()); + } + +} diff --git a/src/main/java/com/minelittlepony/util/resources/package-info.java b/src/main/java/com/minelittlepony/util/resources/package-info.java index 14d0aaa2..a91af5f3 100644 --- a/src/main/java/com/minelittlepony/util/resources/package-info.java +++ b/src/main/java/com/minelittlepony/util/resources/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.util.resources; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/util/transform/MotionCompositor.java b/src/main/java/com/minelittlepony/util/transform/MotionCompositor.java index 347d3fb7..b639a161 100644 --- a/src/main/java/com/minelittlepony/util/transform/MotionCompositor.java +++ b/src/main/java/com/minelittlepony/util/transform/MotionCompositor.java @@ -1,6 +1,6 @@ package com.minelittlepony.util.transform; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.MathHelper; import com.minelittlepony.util.math.MathUtil; @@ -12,12 +12,12 @@ import com.minelittlepony.util.math.MathUtil; */ public abstract class MotionCompositor { - protected double calculateRoll(EntityPlayer player, double motionX, double motionY, double motionZ) { + protected double calculateRoll(PlayerEntity player, double motionX, double motionY, double motionZ) { // since model roll should probably be calculated from model rotation rather than entity rotation... - double roll = MathUtil.sensibleAngle(player.prevRenderYawOffset - player.renderYawOffset); + double roll = MathUtil.sensibleAngle(player.field_6220 - player.field_6283); double horMotion = Math.sqrt(motionX * motionX + motionZ * motionZ); - float modelYaw = MathUtil.sensibleAngle(player.renderYawOffset); + float modelYaw = MathUtil.sensibleAngle(player.field_6283); // detecting that we're flying backwards and roll must be inverted if (Math.abs(MathUtil.sensibleAngle((float) Math.toDegrees(Math.atan2(motionX, motionZ)) + modelYaw)) > 90) { @@ -36,11 +36,11 @@ public abstract class MotionCompositor { return MathHelper.clamp(roll, -54, 54); } - protected double calculateIncline(EntityPlayer player, double motionX, double motionY, double motionZ) { + protected double calculateIncline(PlayerEntity player, double motionX, double motionY, double motionZ) { double dist = Math.sqrt(motionX * motionX + motionZ * motionZ); double angle = Math.atan2(motionY, dist); - if (!player.abilities.isFlying) { + if (!player.abilities.allowFlying) { angle /= 2; } diff --git a/src/main/java/com/minelittlepony/util/transform/package-info.java b/src/main/java/com/minelittlepony/util/transform/package-info.java index 34c49157..ed460b48 100644 --- a/src/main/java/com/minelittlepony/util/transform/package-info.java +++ b/src/main/java/com/minelittlepony/util/transform/package-info.java @@ -1,7 +1,4 @@ -@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault package com.minelittlepony.util.transform; -import mcp.MethodsReturnNonnullByDefault; - import javax.annotation.ParametersAreNonnullByDefault;