ActuallyAdditions/src/main/java/ellpeck/actuallyadditions/util/FakePlayerUtil.java

38 lines
1.2 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
* This file ("FakePlayerUtil.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2015-11-02 20:55:19 +01:00
* © 2015 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2015-05-04 17:26:50 +02:00
package ellpeck.actuallyadditions.util;
import com.mojang.authlib.GameProfile;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
import java.util.UUID;
public class FakePlayerUtil{
2015-07-06 23:41:10 +02:00
private static final String fakeName = "EllpecksActuallyAdditionsFakePlayer";
private static GameProfile fakeProfile = new GameProfile(UUID.nameUUIDFromBytes(fakeName.getBytes()), fakeName);
private static FakePlayer theFakePlayer;
2015-05-04 17:26:50 +02:00
public static FakePlayer newFakePlayer(World world){
if(world instanceof WorldServer){
2015-07-06 23:41:10 +02:00
if(theFakePlayer == null){
theFakePlayer = new FakePlayer((WorldServer)world, fakeProfile);
}
return theFakePlayer;
2015-05-04 17:26:50 +02:00
}
2015-10-02 16:48:01 +02:00
else{
return null;
}
2015-05-04 17:26:50 +02:00
}
}