mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 12:32:23 +00:00
Fix #250. Make getPlayer return fake player when missing profile
This commit is contained in:
1 parent
a8583bfbfd
commit
cfd60a9610
2 files changed
+24
-24
No files matched your search
@@ -95,17 +95,6 @@ public class ClientProxyCommon extends ProxyCommon {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer(World world, GameProfile profile) {
|
||||
EntityPlayer player = world.getPlayerEntityByName(profile.getName());
|
||||
if (player != null)
|
||||
return player;
|
||||
else if (world instanceof WorldServer)
|
||||
return FakePlayerFactory.get((WorldServer) world, profile);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBlockReachDistance(EntityPlayer entityplayer) {
|
||||
if (entityplayer instanceof EntityPlayerSP)
|
||||
@@ -230,4 +219,9 @@ public class ClientProxyCommon extends ProxyCommon {
|
||||
public EntityPlayer getPlayer() {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer(World world, GameProfile profile) {
|
||||
return super.getPlayer(world, profile);
|
||||
}
|
||||
}
|
||||
@@ -165,19 +165,6 @@ public class ProxyCommon {
|
||||
return server.getConfigurationManager().func_152596_g(player.getGameProfile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a player for a given World and GameProfile.
|
||||
* If they are not in the World, returns a FakePlayer.
|
||||
* Do not store references to the return value, to prevent worlds staying in memory.
|
||||
*/
|
||||
public EntityPlayer getPlayer(World world, GameProfile profile) {
|
||||
EntityPlayer player = world.getPlayerEntityByName(profile.getName());
|
||||
if (player != null)
|
||||
return player;
|
||||
else
|
||||
return FakePlayerFactory.get((WorldServer)world, profile);
|
||||
}
|
||||
|
||||
public double getBlockReachDistance(EntityPlayer entityplayer) {
|
||||
return 4f;
|
||||
}
|
||||
@@ -313,4 +300,23 @@ public class ProxyCommon {
|
||||
public EntityPlayer getPlayer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a player for a given World and GameProfile.
|
||||
* If they are not in the World, returns a FakePlayer.
|
||||
* Do not store references to the return value, to prevent worlds staying in memory.
|
||||
*/
|
||||
public EntityPlayer getPlayer(World world, GameProfile profile) {
|
||||
if (world == null)
|
||||
throw new IllegalArgumentException("World cannot be null");
|
||||
|
||||
if (profile == null || profile.getName() == null)
|
||||
return FakePlayerFactory.getMinecraft((WorldServer)world);
|
||||
|
||||
EntityPlayer player = world.getPlayerEntityByName(profile.getName());
|
||||
if (player != null)
|
||||
return player;
|
||||
else
|
||||
return FakePlayerFactory.get((WorldServer)world, profile);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user