Permalink
Browse files

Fix Morph State save/load issue. Fix Selector scrolling when opened. …

…Last build before beta release.
  • Loading branch information...
iChun committed Aug 8, 2013
1 parent 7f5d3b9 commit 17ea6ddc4db7060afd3262924ffe970a605baff3
@@ -30,6 +30,7 @@
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.player.EntityPlayer;
@@ -284,6 +285,71 @@ else if(info.morphProgress > 70)
if(info.nextState.entInstance != mc.thePlayer)
{
info.nextState.entInstance.onUpdate();
// ObfHelper.forceUpdateEntityActionState(info.nextState.entInstance.getClass(), info.nextState.entInstance);
}
}
if(info.player != null)
{
if(info.prevState.entInstance == null)
{
info.prevState.entInstance = info.player;
}
if(info.prevState.entInstance != null && info.nextState.entInstance != null)
{
info.player.ignoreFrustumCheck = true;
info.prevState.entInstance.prevRotationYawHead = info.nextState.entInstance.prevRotationYawHead = info.player.prevRotationYawHead;
info.prevState.entInstance.prevRotationYaw = info.nextState.entInstance.prevRotationYaw = info.player.prevRotationYaw;
info.prevState.entInstance.prevRotationPitch = info.nextState.entInstance.prevRotationPitch = info.player.prevRotationPitch;
info.prevState.entInstance.prevRenderYawOffset = info.nextState.entInstance.prevRenderYawOffset = info.player.prevRenderYawOffset;
info.prevState.entInstance.prevLimbYaw = info.nextState.entInstance.prevLimbYaw = info.player.prevLimbYaw;
info.prevState.entInstance.prevSwingProgress = info.nextState.entInstance.prevSwingProgress = info.player.prevSwingProgress;
info.prevState.entInstance.prevPosX = info.nextState.entInstance.prevPosX = info.player.prevPosX;
info.prevState.entInstance.prevPosY = info.nextState.entInstance.prevPosY = info.player.prevPosY;
info.prevState.entInstance.prevPosZ = info.nextState.entInstance.prevPosZ = info.player.prevPosZ;
info.prevState.entInstance.rotationYawHead = info.nextState.entInstance.rotationYawHead = info.player.rotationYawHead;
info.prevState.entInstance.rotationYaw = info.nextState.entInstance.rotationYaw = info.player.rotationYaw;
info.prevState.entInstance.rotationPitch = info.nextState.entInstance.rotationPitch = info.player.rotationPitch;
info.prevState.entInstance.renderYawOffset = info.nextState.entInstance.renderYawOffset = info.player.renderYawOffset;
info.prevState.entInstance.limbYaw = info.nextState.entInstance.limbYaw = info.player.limbYaw;
info.prevState.entInstance.swingProgress = info.nextState.entInstance.swingProgress = info.player.swingProgress;
info.prevState.entInstance.limbSwing = info.nextState.entInstance.limbSwing = info.player.limbSwing;
info.prevState.entInstance.posX = info.nextState.entInstance.posX = info.player.posX;
info.prevState.entInstance.posY = info.nextState.entInstance.posY = info.player.posY;
info.prevState.entInstance.posZ = info.nextState.entInstance.posZ = info.player.posZ;
info.prevState.entInstance.motionX = info.nextState.entInstance.motionX = info.player.motionX;
info.prevState.entInstance.motionY = info.nextState.entInstance.motionY = info.player.motionY;
info.prevState.entInstance.motionZ = info.nextState.entInstance.motionZ = info.player.motionZ;
info.prevState.entInstance.ticksExisted = info.nextState.entInstance.ticksExisted = info.player.ticksExisted;
info.prevState.entInstance.onGround = info.nextState.entInstance.onGround = info.player.onGround;
info.prevState.entInstance.isAirBorne = info.nextState.entInstance.isAirBorne = info.player.isAirBorne;
info.prevState.entInstance.moveStrafing = info.nextState.entInstance.moveStrafing = info.player.moveStrafing;
info.prevState.entInstance.moveForward = info.nextState.entInstance.moveForward = info.player.moveForward;
info.prevState.entInstance.dimension = info.nextState.entInstance.dimension = info.player.dimension;
info.prevState.entInstance.worldObj = info.nextState.entInstance.worldObj = info.player.worldObj;
info.prevState.entInstance.ridingEntity = info.nextState.entInstance.ridingEntity = info.player.ridingEntity;
info.prevState.entInstance.hurtTime = info.nextState.entInstance.hurtTime = info.player.hurtTime;
info.prevState.entInstance.deathTime = info.nextState.entInstance.deathTime = info.player.deathTime;
info.prevState.entInstance.setSneaking(info.player.isSneaking());
info.nextState.entInstance.setSneaking(info.player.isSneaking());
info.prevState.entInstance.setSprinting(info.player.isSprinting());
info.nextState.entInstance.setSprinting(info.player.isSprinting());
info.prevState.entInstance.setInvisible(info.player.isInvisible());
info.nextState.entInstance.setInvisible(info.player.isInvisible());
for(int i = 0; i < 5; i++)
{
if(info.nextState.entInstance.getCurrentItemOrArmor(i) == null && info.player.getCurrentItemOrArmor(i) != null ||
info.nextState.entInstance.getCurrentItemOrArmor(i) != null && info.player.getCurrentItemOrArmor(i) == null ||
info.nextState.entInstance.getCurrentItemOrArmor(i) != null && info.player.getCurrentItemOrArmor(i) != null &&
!info.nextState.entInstance.getCurrentItemOrArmor(i).isItemEqual(info.player.getCurrentItemOrArmor(i)))
{
info.nextState.entInstance.setCurrentItemOrArmor(i, info.player.getCurrentItemOrArmor(i) != null ? info.player.getCurrentItemOrArmor(i).copy() : null);
}
}
}
}
}
@@ -292,6 +358,7 @@ else if(info.morphProgress > 70)
{
if(!selectorShow)
{
Mouse.getDWheel();
selectorShow = true;
selectorTimer = selectorShowTime - selectorTimer;
@@ -326,6 +393,7 @@ else if(info.morphProgress > 70)
{
if(!selectorShow)
{
Mouse.getDWheel();
selectorShow = true;
selectorTimer = selectorShowTime - selectorTimer;
@@ -461,77 +529,10 @@ public void preRenderTick(Minecraft mc, World world, float renderTick)
}
for(Entry<String, MorphInfoClient> e : playerMorphInfo.entrySet())
{
MorphInfoClient info = e.getValue();
if(info.player != null)
{
if(info.prevState.entInstance == null)
{
info.prevState.entInstance = info.player;
}
if(info.prevState.entInstance != null && info.nextState.entInstance != null)
{
info.player.ignoreFrustumCheck = true;
info.prevState.entInstance.prevRotationYawHead = info.nextState.entInstance.prevRotationYawHead = info.player.prevRotationYawHead;
info.prevState.entInstance.prevRotationYaw = info.nextState.entInstance.prevRotationYaw = info.player.prevRotationYaw;
info.prevState.entInstance.prevRotationPitch = info.nextState.entInstance.prevRotationPitch = info.player.prevRotationPitch;
info.prevState.entInstance.prevRenderYawOffset = info.nextState.entInstance.prevRenderYawOffset = info.player.prevRenderYawOffset;
info.prevState.entInstance.prevLimbYaw = info.nextState.entInstance.prevLimbYaw = info.player.prevLimbYaw;
info.prevState.entInstance.prevSwingProgress = info.nextState.entInstance.prevSwingProgress = info.player.prevSwingProgress;
info.prevState.entInstance.prevPosX = info.nextState.entInstance.prevPosX = info.player.prevPosX;
info.prevState.entInstance.prevPosY = info.nextState.entInstance.prevPosY = info.player.prevPosY;
info.prevState.entInstance.prevPosZ = info.nextState.entInstance.prevPosZ = info.player.prevPosZ;
info.prevState.entInstance.rotationYawHead = info.nextState.entInstance.rotationYawHead = info.player.rotationYawHead;
info.prevState.entInstance.rotationYaw = info.nextState.entInstance.rotationYaw = info.player.rotationYaw;
info.prevState.entInstance.rotationPitch = info.nextState.entInstance.rotationPitch = info.player.rotationPitch;
info.prevState.entInstance.renderYawOffset = info.nextState.entInstance.renderYawOffset = info.player.renderYawOffset;
info.prevState.entInstance.limbYaw = info.nextState.entInstance.limbYaw = info.player.limbYaw;
info.prevState.entInstance.swingProgress = info.nextState.entInstance.swingProgress = info.player.swingProgress;
info.prevState.entInstance.limbSwing = info.nextState.entInstance.limbSwing = info.player.limbSwing;
info.prevState.entInstance.posX = info.nextState.entInstance.posX = info.player.posX;
info.prevState.entInstance.posY = info.nextState.entInstance.posY = info.player.posY;
info.prevState.entInstance.posZ = info.nextState.entInstance.posZ = info.player.posZ;
info.prevState.entInstance.motionX = info.nextState.entInstance.motionX = info.player.motionX;
info.prevState.entInstance.motionY = info.nextState.entInstance.motionY = info.player.motionY;
info.prevState.entInstance.motionZ = info.nextState.entInstance.motionZ = info.player.motionZ;
info.prevState.entInstance.ticksExisted = info.nextState.entInstance.ticksExisted = info.player.ticksExisted;
info.prevState.entInstance.onGround = info.nextState.entInstance.onGround = info.player.onGround;
info.prevState.entInstance.isAirBorne = info.nextState.entInstance.isAirBorne = info.player.isAirBorne;
info.prevState.entInstance.moveStrafing = info.nextState.entInstance.moveStrafing = info.player.moveStrafing;
info.prevState.entInstance.moveForward = info.nextState.entInstance.moveForward = info.player.moveForward;
info.prevState.entInstance.dimension = info.nextState.entInstance.dimension = info.player.dimension;
info.prevState.entInstance.worldObj = info.nextState.entInstance.worldObj = info.player.worldObj;
info.prevState.entInstance.ridingEntity = info.nextState.entInstance.ridingEntity = info.player.ridingEntity;
info.prevState.entInstance.hurtTime = info.nextState.entInstance.hurtTime = info.player.hurtTime;
info.prevState.entInstance.deathTime = info.nextState.entInstance.deathTime = info.player.deathTime;
info.prevState.entInstance.setSneaking(info.player.isSneaking());
info.nextState.entInstance.setSneaking(info.player.isSneaking());
info.prevState.entInstance.setSprinting(info.player.isSprinting());
info.nextState.entInstance.setSprinting(info.player.isSprinting());
info.prevState.entInstance.setInvisible(info.player.isInvisible());
info.nextState.entInstance.setInvisible(info.player.isInvisible());
// System.out.println(info.prevState.identifier);
// System.out.println(info.nextState.identifier);
for(int i = 0; i < 5; i++)
{
if(info.nextState.entInstance.getCurrentItemOrArmor(i) == null && info.player.getCurrentItemOrArmor(i) != null ||
info.nextState.entInstance.getCurrentItemOrArmor(i) != null && info.player.getCurrentItemOrArmor(i) == null ||
info.nextState.entInstance.getCurrentItemOrArmor(i) != null && info.player.getCurrentItemOrArmor(i) != null &&
!info.nextState.entInstance.getCurrentItemOrArmor(i).isItemEqual(info.player.getCurrentItemOrArmor(i)))
{
info.nextState.entInstance.setCurrentItemOrArmor(i, info.player.getCurrentItemOrArmor(i) != null ? info.player.getCurrentItemOrArmor(i).copy() : null);
}
}
}
}
}
// for(Entry<String, MorphInfoClient> e : playerMorphInfo.entrySet())
// {
// MorphInfoClient info = e.getValue();
// }
}
@@ -4,7 +4,6 @@
import java.util.ArrayList;
import java.util.Random;
import morph.common.Morph;
import morph.common.core.ObfHelper;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
@@ -82,10 +82,14 @@ public void onPlayerLogin(EntityPlayer player)
if(Morph.proxy.tickHandlerServer.saveData != null)
{
NBTTagCompound tag = Morph.proxy.tickHandlerServer.saveData;
list.clear();
list.add(0, new MorphState(player.worldObj, player.username, player.username, null, player.worldObj.isRemote));
int count = tag.getInteger(player.username + "_morphStatesCount");
if(count > 0)
{
list.clear();
for(int i = 0; i < count; i++)
{
@@ -97,6 +101,15 @@ public void onPlayerLogin(EntityPlayer player)
}
}
}
NBTTagCompound tag1 = tag.getCompoundTag(player.username + "_morphData");
if(tag1.hasKey("playerName"))
{
MorphInfo info = new MorphInfo();
info.readNBT(tag1);
Morph.proxy.tickHandlerServer.playerMorphInfo.put(info.playerName, info);
MorphHandler.addOrGetMorphState(list, info.nextState);
}
}
MorphHandler.updatePlayerOfMorphStates((EntityPlayerMP)player, null, true);
@@ -704,23 +704,6 @@ public void onWorldLoad(WorldEvent.Load event)
Morph.console("Failed to read save data!", true);
return;
}
NBTTagCompound tag = Morph.proxy.tickHandlerServer.saveData;
if(tag != null)
{
//read data
int morphDataCount = tag.getInteger("morphDataCount");
Morph.proxy.tickHandlerServer.playerMorphInfo.clear();
for(int i = 1; i <= morphDataCount; i++)
{
NBTTagCompound tag1 = tag.getCompoundTag("morphData" + i);
MorphInfo info = new MorphInfo();
info.readNBT(tag1);
Morph.proxy.tickHandlerServer.playerMorphInfo.put(info.playerName, info);
MorphHandler.addOrGetMorphState(Morph.proxy.tickHandlerServer.getPlayerMorphs(event.world, info.playerName), info.nextState);
}
}
}
}
@@ -739,24 +722,18 @@ public void onWorldSave(WorldEvent.Save event)
NBTTagCompound tag = Morph.proxy.tickHandlerServer.saveData;
int morphDataCount = Morph.proxy.tickHandlerServer.playerMorphInfo.size();
tag.setInteger("morphDataCount", morphDataCount);
int count = 0;
for(Entry<String, MorphInfo> e : Morph.proxy.tickHandlerServer.playerMorphInfo.entrySet())
{
count++;
NBTTagCompound tag1 = new NBTTagCompound();
e.getValue().writeNBT(tag1);
tag.setCompoundTag("morphData" + count, tag1);
tag.setCompoundTag(e.getKey() + "_morphData", tag1);
}
for(Entry<String, ArrayList<MorphState>> e : Morph.proxy.tickHandlerServer.playerMorphs.entrySet())
{
String name = e.getKey();
ArrayList<MorphState> states = e.getValue();
tag.setInteger(name + "_morphStatesCount", states.size());
System.out.println(name + "_morphStatesCount");
for(int i = 0; i < states.size(); i++)
{
tag.setCompoundTag(name + "_morphState" + i, states.get(i).getTag());
@@ -11,6 +11,7 @@
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.relauncher.Side;
@@ -29,28 +30,29 @@
public static final String[] cameraZoom = new String[] { "Y", "field_78503_V", "cameraZoom" }; //EntityRenderer
public static final String[] modelBipedMain = new String[] { "f", "field_77109_a", "modelBipedMain" }; //RenderPlayer
public static final String setSizeObf = "func_70105_a"; //func_70105_a
public static final String setSizeObf = "func_70105_a";
public static final String setSizeDeobf = "setSize";
public static final String updateEntityActionStateObf = "func_70626_be"; //func_70626_be
public static final String updateEntityActionStateObf = "func_70626_be";
public static final String updateEntityActionStateDeobf = "updateEntityActionState";
public static final String getEntityTextureObf = "func_110775_a"; //func_110775_a
public static final String getEntityTextureObf = "func_110775_a";
public static final String preRenderCallbackObf = "func_77041_b"; //func_77041_b
public static final String preRenderCallbackObf = "func_77041_b";
public static final String preRenderCallbackDeobf = "preRenderCallback";
public static final String pushOutOfBlocksObf = "func_70048_i"; //func_70048_i
public static final String pushOutOfBlocksObf = "func_70048_i";
public static final String pushOutOfBlocksDeobf = "pushOutOfBlocks";
public static final String getHurtSoundObf = "func_70621_aR"; //func_70621_aR
public static final String getHurtSoundObf = "func_70621_aR";
public static final String getHurtSoundDeobf = "getHurtSound";
public static final String renderHandObf = "func_78476_b";
public static final String renderHandDeobf = "renderHand";
public static final String alterSquishAmountObf = "func_70808_l";
public static Method setSizeMethod;
public static Method updateEntityActionStateMethod;
public static Method pushOutOfBlocksMethod;
public static void obfWarning()
@@ -112,32 +114,25 @@ public static void forceSetSize(Entity ent, float width, float height)
}
}
public static void forceUpdateEntityActionState(EntityLivingBase ent)
public static void forceUpdateEntityActionState(Class clz, EntityLivingBase ent)
{
if(updateEntityActionStateMethod == null)
try
{
try
{
Method m = EntityLivingBase.class.getDeclaredMethod(ObfHelper.obfuscation ? ObfHelper.updateEntityActionStateObf : ObfHelper.updateEntityActionStateDeobf);
updateEntityActionStateMethod = m;
}
catch(Exception e)
{
e.printStackTrace();
}
Method m = clz.getDeclaredMethod(ObfHelper.obfuscation ? ObfHelper.updateEntityActionStateObf : ObfHelper.updateEntityActionStateDeobf);
m.setAccessible(true);
m.invoke(ent);
}
if(updateEntityActionStateMethod != null)
catch(NoSuchMethodException e)
{
try
{
updateEntityActionStateMethod.setAccessible(true);
updateEntityActionStateMethod.invoke(ent);
}
catch(Exception e)
if(clz != EntityLivingBase.class)
{
e.printStackTrace();
forceUpdateEntityActionState(clz.getSuperclass(), ent);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void forcePushOutOfBlocks(EntityPlayer ent, double d, double d1, double d2)
@@ -256,4 +251,25 @@ public static void invokeRenderHand(EntityRenderer renderer, float renderTick)
e.printStackTrace();
}
}
public static void forceResquish(Class clz, EntitySlime slime)
{
try
{
Method m = clz.getDeclaredMethod(ObfHelper.alterSquishAmountObf);
m.setAccessible(true);
m.invoke(slime);
}
catch(NoSuchMethodException e)
{
if(clz != EntitySlime.class)
{
forceUpdateEntityActionState(clz.getSuperclass(), slime);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
@@ -198,7 +198,7 @@ public MorphState getSelfState(World world, String name)
{
list = new ArrayList<MorphState>();
playerMorphs.put(name, list);
list.add(new MorphState(world, name, name, null, world.isRemote));
list.add(0, new MorphState(world, name, name, null, world.isRemote));
}
return list;
}

0 comments on commit 17ea6dd

Please sign in to comment.