Fix NPE in FakePlayers when they are created in a purely client side environment. To remove in 1.7 as FakePlayers should be used for server side interaction with the world on a player's behalf, not for client rendering.
This commit is contained in:
parent
77c5caffd5
commit
45cc0bd87c
|
@ -1,12 +1,15 @@
|
||||||
package net.minecraftforge.common;
|
package net.minecraftforge.common;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemInWorldManager;
|
import net.minecraft.item.ItemInWorldManager;
|
||||||
|
import net.minecraft.network.packet.Packet204ClientInfo;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.stats.StatBase;
|
import net.minecraft.stats.StatBase;
|
||||||
import net.minecraft.util.ChatMessageComponent;
|
import net.minecraft.util.ChatMessageComponent;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
import net.minecraft.util.ChunkCoordinates;
|
||||||
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
//Preliminary, simple Fake Player class
|
//Preliminary, simple Fake Player class
|
||||||
|
@ -30,4 +33,16 @@ public class FakePlayer extends EntityPlayerMP
|
||||||
public void addStat(StatBase par1StatBase, int par2){}
|
public void addStat(StatBase par1StatBase, int par2){}
|
||||||
@Override
|
@Override
|
||||||
public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){}
|
public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){}
|
||||||
|
@Override
|
||||||
|
public boolean isEntityInvulnerable(){ return true; }
|
||||||
|
@Override
|
||||||
|
public boolean canAttackPlayer(EntityPlayer player){ return false; }
|
||||||
|
@Override
|
||||||
|
public void onDeath(DamageSource source){ return; }
|
||||||
|
@Override
|
||||||
|
public void onUpdate(){ return; }
|
||||||
|
@Override
|
||||||
|
public void travelToDimension(int dim){ return; }
|
||||||
|
@Override
|
||||||
|
public void updateClientInfo(Packet204ClientInfo pkt){ return; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,16 @@
|
||||||
public class EntityPlayerMP extends EntityPlayer implements ICrafting
|
public class EntityPlayerMP extends EntityPlayer implements ICrafting
|
||||||
{
|
{
|
||||||
private String translator = "en_US";
|
private String translator = "en_US";
|
||||||
@@ -165,18 +171,10 @@
|
@@ -164,19 +170,14 @@
|
||||||
|
super(par2World, par3Str);
|
||||||
par4ItemInWorldManager.thisPlayerMP = this;
|
par4ItemInWorldManager.thisPlayerMP = this;
|
||||||
this.theItemInWorldManager = par4ItemInWorldManager;
|
this.theItemInWorldManager = par4ItemInWorldManager;
|
||||||
this.renderDistance = par1MinecraftServer.getConfigurationManager().getViewDistance();
|
- this.renderDistance = par1MinecraftServer.getConfigurationManager().getViewDistance();
|
||||||
- ChunkCoordinates chunkcoordinates = par2World.getSpawnPoint();
|
- ChunkCoordinates chunkcoordinates = par2World.getSpawnPoint();
|
||||||
|
+ if (par1MinecraftServer == null) //ToDo: Remove this in 1.7, Fake players shouldn't be used purely client side.
|
||||||
|
+ this.renderDistance = 0;
|
||||||
|
+ else
|
||||||
|
+ this.renderDistance = par1MinecraftServer.getConfigurationManager().getViewDistance();
|
||||||
+ ChunkCoordinates chunkcoordinates = par2World.provider.getRandomizedSpawnPoint();
|
+ ChunkCoordinates chunkcoordinates = par2World.provider.getRandomizedSpawnPoint();
|
||||||
int i = chunkcoordinates.posX;
|
int i = chunkcoordinates.posX;
|
||||||
int j = chunkcoordinates.posZ;
|
int j = chunkcoordinates.posZ;
|
||||||
|
@ -33,7 +38,7 @@
|
||||||
|
|
||||||
this.mcServer = par1MinecraftServer;
|
this.mcServer = par1MinecraftServer;
|
||||||
this.stepHeight = 0.0F;
|
this.stepHeight = 0.0F;
|
||||||
@@ -240,11 +238,6 @@
|
@@ -240,11 +241,6 @@
|
||||||
this.yOffset = 0.0F;
|
this.yOffset = 0.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +50,7 @@
|
||||||
/**
|
/**
|
||||||
* Called to update the entity's position/logic.
|
* Called to update the entity's position/logic.
|
||||||
*/
|
*/
|
||||||
@@ -254,7 +247,7 @@
|
@@ -254,7 +250,7 @@
|
||||||
--this.initialInvulnerability;
|
--this.initialInvulnerability;
|
||||||
this.openContainer.detectAndSendChanges();
|
this.openContainer.detectAndSendChanges();
|
||||||
|
|
||||||
|
@ -54,7 +59,7 @@
|
||||||
{
|
{
|
||||||
this.closeScreen();
|
this.closeScreen();
|
||||||
this.openContainer = this.inventoryContainer;
|
this.openContainer = this.inventoryContainer;
|
||||||
@@ -290,7 +283,10 @@
|
@@ -290,7 +286,10 @@
|
||||||
if (chunkcoordintpair != null && this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4))
|
if (chunkcoordintpair != null && this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4))
|
||||||
{
|
{
|
||||||
arraylist.add(this.worldObj.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos));
|
arraylist.add(this.worldObj.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos));
|
||||||
|
@ -66,7 +71,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +307,7 @@
|
@@ -311,6 +310,7 @@
|
||||||
{
|
{
|
||||||
Chunk chunk = (Chunk)iterator2.next();
|
Chunk chunk = (Chunk)iterator2.next();
|
||||||
this.getServerForPlayer().getEntityTracker().func_85172_a(this, chunk);
|
this.getServerForPlayer().getEntityTracker().func_85172_a(this, chunk);
|
||||||
|
@ -74,7 +79,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,11 +380,25 @@
|
@@ -383,11 +383,25 @@
|
||||||
*/
|
*/
|
||||||
public void onDeath(DamageSource par1DamageSource)
|
public void onDeath(DamageSource par1DamageSource)
|
||||||
{
|
{
|
||||||
|
@ -100,7 +105,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection collection = this.worldObj.getScoreboard().func_96520_a(ScoreObjectiveCriteria.deathCount);
|
Collection collection = this.worldObj.getScoreboard().func_96520_a(ScoreObjectiveCriteria.deathCount);
|
||||||
@@ -1054,4 +1065,16 @@
|
@@ -1054,4 +1068,16 @@
|
||||||
{
|
{
|
||||||
this.field_143005_bX = MinecraftServer.getSystemTimeMillis();
|
this.field_143005_bX = MinecraftServer.getSystemTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue