Fix for loading Minecart Entities in worlds that were last accessed before Forge was installed.

This commit is contained in:
LexManos 2012-04-23 19:14:08 -07:00
parent 4bdba7400b
commit 33a3f67225
2 changed files with 34 additions and 20 deletions

View File

@ -487,7 +487,7 @@
{ {
NBTTagList var2 = new NBTTagList(); NBTTagList var2 = new NBTTagList();
@@ -865,13 +723,14 @@ @@ -865,13 +723,21 @@
{ {
this.minecartType = par1NBTTagCompound.getInteger("Type"); this.minecartType = par1NBTTagCompound.getInteger("Type");
@ -497,7 +497,14 @@
this.pushX = par1NBTTagCompound.getDouble("PushX"); this.pushX = par1NBTTagCompound.getDouble("PushX");
this.pushZ = par1NBTTagCompound.getDouble("PushZ"); this.pushZ = par1NBTTagCompound.getDouble("PushZ");
- this.fuel = par1NBTTagCompound.getShort("Fuel"); - this.fuel = par1NBTTagCompound.getShort("Fuel");
+ this.fuel = par1NBTTagCompound.getInteger("Fuel"); + try
+ {
+ this.fuel = par1NBTTagCompound.getInteger("Fuel");
+ }
+ catch (ClassCastException e)
+ {
+ this.fuel = par1NBTTagCompound.getShort("Fuel");
+ }
} }
- else if (this.minecartType == 1) - else if (this.minecartType == 1)
+ +
@ -505,7 +512,7 @@
{ {
NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.cargoItems = new ItemStack[this.getSizeInventory()]; this.cargoItems = new ItemStack[this.getSizeInventory()];
@@ -899,11 +758,19 @@ @@ -899,11 +765,19 @@
*/ */
public void applyEntityCollision(Entity par1Entity) public void applyEntityCollision(Entity par1Entity)
{ {
@ -526,7 +533,7 @@
{ {
par1Entity.mountEntity(this); par1Entity.mountEntity(this);
} }
@@ -949,7 +816,7 @@ @@ -949,7 +823,7 @@
double var18 = par1Entity.motionX + this.motionX; double var18 = par1Entity.motionX + this.motionX;
double var20 = par1Entity.motionZ + this.motionZ; double var20 = par1Entity.motionZ + this.motionZ;
@ -535,7 +542,7 @@
{ {
this.motionX *= 0.20000000298023224D; this.motionX *= 0.20000000298023224D;
this.motionZ *= 0.20000000298023224D; this.motionZ *= 0.20000000298023224D;
@@ -957,7 +824,7 @@ @@ -957,7 +831,7 @@
par1Entity.motionX *= 0.949999988079071D; par1Entity.motionX *= 0.949999988079071D;
par1Entity.motionZ *= 0.949999988079071D; par1Entity.motionZ *= 0.949999988079071D;
} }
@ -544,7 +551,7 @@
{ {
par1Entity.motionX *= 0.20000000298023224D; par1Entity.motionX *= 0.20000000298023224D;
par1Entity.motionZ *= 0.20000000298023224D; par1Entity.motionZ *= 0.20000000298023224D;
@@ -992,7 +859,7 @@ @@ -992,7 +866,7 @@
*/ */
public int getSizeInventory() public int getSizeInventory()
{ {
@ -553,7 +560,7 @@
} }
/** /**
@@ -1095,7 +962,12 @@ @@ -1095,7 +969,12 @@
*/ */
public boolean interact(EntityPlayer par1EntityPlayer) public boolean interact(EntityPlayer par1EntityPlayer)
{ {
@ -567,7 +574,7 @@
{ {
if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer) if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer)
{ {
@@ -1107,14 +979,14 @@ @@ -1107,14 +986,14 @@
par1EntityPlayer.mountEntity(this); par1EntityPlayer.mountEntity(this);
} }
} }
@ -584,7 +591,7 @@
{ {
ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem(); ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem();
@@ -1173,7 +1045,7 @@ @@ -1173,7 +1052,7 @@
/** /**
* Is this minecart powered (Fuel > 0) * Is this minecart powered (Fuel > 0)
*/ */
@ -593,7 +600,7 @@
{ {
return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0;
} }
@@ -1226,4 +1098,373 @@ @@ -1226,4 +1105,373 @@
{ {
return this.dataWatcher.getWatchableObjectInt(18); return this.dataWatcher.getWatchableObjectInt(18);
} }

View File

@ -470,7 +470,7 @@
{ {
NBTTagList var2 = new NBTTagList(); NBTTagList var2 = new NBTTagList();
@@ -797,13 +664,13 @@ @@ -797,13 +664,20 @@
{ {
this.minecartType = par1NBTTagCompound.getInteger("Type"); this.minecartType = par1NBTTagCompound.getInteger("Type");
@ -480,14 +480,21 @@
this.pushX = par1NBTTagCompound.getDouble("PushX"); this.pushX = par1NBTTagCompound.getDouble("PushX");
this.pushZ = par1NBTTagCompound.getDouble("PushZ"); this.pushZ = par1NBTTagCompound.getDouble("PushZ");
- this.fuel = par1NBTTagCompound.getShort("Fuel"); - this.fuel = par1NBTTagCompound.getShort("Fuel");
+ this.fuel = par1NBTTagCompound.getInteger("Fuel"); + try
+ {
+ this.fuel = par1NBTTagCompound.getInteger("Fuel");
+ }
+ catch (ClassCastException e)
+ {
+ this.fuel = par1NBTTagCompound.getShort("Fuel");
+ }
} }
- else if (this.minecartType == 1) - else if (this.minecartType == 1)
+ if (getSizeInventory() > 0) + if (getSizeInventory() > 0)
{ {
NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.cargoItems = new ItemStack[this.getSizeInventory()]; this.cargoItems = new ItemStack[this.getSizeInventory()];
@@ -826,11 +693,18 @@ @@ -826,11 +700,18 @@
*/ */
public void applyEntityCollision(Entity par1Entity) public void applyEntityCollision(Entity par1Entity)
{ {
@ -507,7 +514,7 @@
{ {
par1Entity.mountEntity(this); par1Entity.mountEntity(this);
} }
@@ -876,7 +750,7 @@ @@ -876,7 +757,7 @@
double var18 = par1Entity.motionX + this.motionX; double var18 = par1Entity.motionX + this.motionX;
double var20 = par1Entity.motionZ + this.motionZ; double var20 = par1Entity.motionZ + this.motionZ;
@ -516,7 +523,7 @@
{ {
this.motionX *= 0.20000000298023224D; this.motionX *= 0.20000000298023224D;
this.motionZ *= 0.20000000298023224D; this.motionZ *= 0.20000000298023224D;
@@ -884,7 +758,7 @@ @@ -884,7 +765,7 @@
par1Entity.motionX *= 0.949999988079071D; par1Entity.motionX *= 0.949999988079071D;
par1Entity.motionZ *= 0.949999988079071D; par1Entity.motionZ *= 0.949999988079071D;
} }
@ -525,7 +532,7 @@
{ {
par1Entity.motionX *= 0.20000000298023224D; par1Entity.motionX *= 0.20000000298023224D;
par1Entity.motionZ *= 0.20000000298023224D; par1Entity.motionZ *= 0.20000000298023224D;
@@ -919,7 +793,7 @@ @@ -919,7 +800,7 @@
*/ */
public int getSizeInventory() public int getSizeInventory()
{ {
@ -534,7 +541,7 @@
} }
/** /**
@@ -1022,7 +896,12 @@ @@ -1022,7 +903,12 @@
*/ */
public boolean interact(EntityPlayer par1EntityPlayer) public boolean interact(EntityPlayer par1EntityPlayer)
{ {
@ -548,7 +555,7 @@
{ {
if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer) if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer)
{ {
@@ -1034,14 +913,14 @@ @@ -1034,14 +920,14 @@
par1EntityPlayer.mountEntity(this); par1EntityPlayer.mountEntity(this);
} }
} }
@ -565,7 +572,7 @@
{ {
ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem(); ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem();
@@ -1073,7 +952,7 @@ @@ -1073,7 +959,7 @@
/** /**
* Is this minecart powered (Fuel > 0) * Is this minecart powered (Fuel > 0)
*/ */
@ -574,7 +581,7 @@
{ {
return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0;
} }
@@ -1126,4 +1005,373 @@ @@ -1126,4 +1012,373 @@
{ {
return this.dataWatcher.getWatchableObjectInt(18); return this.dataWatcher.getWatchableObjectInt(18);
} }