mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 20:25:13 +00:00
Added another mixin necessary for rendering model rotations for players in MP.
This commit is contained in:
1 parent
ef01b700da
commit
c9426682c0
3 files changed
+69
-53
No files matched your search
@@ -60,68 +60,16 @@ public class ClientEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public void setInterpolatedAngles(PlayerModelData modelData) {
|
||||
float pi = (float) Math.PI * (modelData.fullAngles ? 2 : 1);
|
||||
if (!modelData.animate) {
|
||||
modelData.modelRotations[0] = modelData.rotationX * pi;
|
||||
modelData.modelRotations[1] = modelData.rotationY * pi;
|
||||
modelData.modelRotations[2] = modelData.rotationZ * pi;
|
||||
} else if (modelData.modelRotPartialTicks != ClientEventHandler.partialRenderTick) {
|
||||
modelData.modelRotPartialTicks = ClientEventHandler.partialRenderTick;
|
||||
if (modelData.rotationX - modelData.modelRotations[0] != 0 && modelData.rotationEnabledX) {
|
||||
modelData.modelRotations[0] = (modelData.rotationX - modelData.modelRotations[0]) * modelData.animRate / 10f + modelData.modelRotations[0];
|
||||
} else {
|
||||
modelData.modelRotations[0] = modelData.rotationX;
|
||||
}
|
||||
|
||||
if (modelData.rotationY - modelData.modelRotations[1] != 0 && modelData.rotationEnabledY) {
|
||||
modelData.modelRotations[1] = (modelData.rotationY - modelData.modelRotations[1]) * modelData.animRate / 10f + modelData.modelRotations[1];
|
||||
} else {
|
||||
modelData.modelRotations[1] = modelData.rotationY;
|
||||
}
|
||||
|
||||
if (modelData.rotationZ - modelData.modelRotations[2] != 0 && modelData.rotationEnabledZ) {
|
||||
modelData.modelRotations[2] = (modelData.rotationZ - modelData.modelRotations[2]) * modelData.animRate /10f + modelData.modelRotations[2];
|
||||
} else {
|
||||
modelData.modelRotations[2] = modelData.rotationZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderPlayer(RenderPlayerEvent.Pre event) {
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
ClientEventHandler.renderingPlayer = player;
|
||||
ClientEventHandler.renderingPlayer = event.entityPlayer;
|
||||
ClientEventHandler.renderer = event.renderer;
|
||||
ClientEventHandler.partialRenderTick = event.partialRenderTick;
|
||||
|
||||
if (Client.playerModelData.containsKey(player.getUniqueID())) {
|
||||
PlayerModelData data = Client.playerModelData.get(player.getUniqueID());
|
||||
if (data.enabled()) {
|
||||
GL11.glPushMatrix();
|
||||
this.setInterpolatedAngles(data);
|
||||
if (data.rotationEnabledX) {
|
||||
GL11.glRotatef(data.modelRotations[0], 1, 0, 0);
|
||||
}
|
||||
if (data.rotationEnabledY) {
|
||||
GL11.glRotatef(data.modelRotations[1], 0, 1, 0);
|
||||
}
|
||||
if (data.rotationEnabledZ) {
|
||||
GL11.glRotatef(data.modelRotations[2], 0, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderPlayer(RenderPlayerEvent.Post event) {
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
if (Client.playerModelData.containsKey(player.getUniqueID())) {
|
||||
PlayerModelData data = Client.playerModelData.get(player.getUniqueID());
|
||||
if (data.enabled()) {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
ClientEventHandler.renderingPlayer = null;
|
||||
|
||||
if (hasOverlays(player)) {
|
||||
|
||||
@@ -37,6 +37,7 @@ public class CustomNPCsMixinPlugin implements IMixinConfigPlugin {
|
||||
mixins.add("MixinEntityRenderer");
|
||||
}
|
||||
mixins.add("MixinModelRenderer");
|
||||
mixins.add("MixinRenderPlayer");
|
||||
return mixins;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package noppes.npcs.mixin;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.ClientEventHandler;
|
||||
import noppes.npcs.controllers.data.PlayerModelData;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = RenderPlayer.class)
|
||||
public class MixinRenderPlayer {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Inject(method = "renderLivingAt", at = @At(value = "TAIL"))
|
||||
protected void modelDataRotations(AbstractClientPlayer p_77039_1_, double p_77039_2_, double p_77039_4_, double p_77039_6_, CallbackInfo callbackInfo)
|
||||
{
|
||||
if (Client.playerModelData.containsKey(p_77039_1_.getUniqueID())) {
|
||||
PlayerModelData data = Client.playerModelData.get(p_77039_1_.getUniqueID());
|
||||
if (data.enabled()) {
|
||||
this.setInterpolatedAngles(data);
|
||||
if (data.rotationEnabledX) {
|
||||
GL11.glRotatef(data.modelRotations[0], 1, 0, 0);
|
||||
}
|
||||
if (data.rotationEnabledY) {
|
||||
GL11.glRotatef(data.modelRotations[1], 0, 1, 0);
|
||||
}
|
||||
if (data.rotationEnabledZ) {
|
||||
GL11.glRotatef(data.modelRotations[2], 0, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setInterpolatedAngles(PlayerModelData modelData) {
|
||||
float pi = (float) Math.PI * (modelData.fullAngles ? 2 : 1);
|
||||
if (!modelData.animate) {
|
||||
modelData.modelRotations[0] = modelData.rotationX * pi;
|
||||
modelData.modelRotations[1] = modelData.rotationY * pi;
|
||||
modelData.modelRotations[2] = modelData.rotationZ * pi;
|
||||
} else if (modelData.modelRotPartialTicks != ClientEventHandler.partialRenderTick) {
|
||||
modelData.modelRotPartialTicks = ClientEventHandler.partialRenderTick;
|
||||
if (modelData.rotationX - modelData.modelRotations[0] != 0 && modelData.rotationEnabledX) {
|
||||
modelData.modelRotations[0] = (modelData.rotationX - modelData.modelRotations[0]) * modelData.animRate / 10f + modelData.modelRotations[0];
|
||||
} else {
|
||||
modelData.modelRotations[0] = modelData.rotationX;
|
||||
}
|
||||
|
||||
if (modelData.rotationY - modelData.modelRotations[1] != 0 && modelData.rotationEnabledY) {
|
||||
modelData.modelRotations[1] = (modelData.rotationY - modelData.modelRotations[1]) * modelData.animRate / 10f + modelData.modelRotations[1];
|
||||
} else {
|
||||
modelData.modelRotations[1] = modelData.rotationY;
|
||||
}
|
||||
|
||||
if (modelData.rotationZ - modelData.modelRotations[2] != 0 && modelData.rotationEnabledZ) {
|
||||
modelData.modelRotations[2] = (modelData.rotationZ - modelData.modelRotations[2]) * modelData.animRate /10f + modelData.modelRotations[2];
|
||||
} else {
|
||||
modelData.modelRotations[2] = modelData.rotationZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user