net.minecraft.block.entity.SkullBlockEntity Java Examples

The following examples show how to use net.minecraft.block.entity.SkullBlockEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityPlayerMPFake.java    From fabric-carpet with MIT License 4 votes vote down vote up
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, DimensionType dimension, GameMode gamemode)
{
    //prolly half of that crap is not necessary, but it works
    ServerWorld worldIn = server.getWorld(dimension);
    ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn);
    GameProfile gameprofile = server.getUserCache().findByName(username);
    if (gameprofile == null)
    {
        return null;
    }
    if (gameprofile.getProperties().containsKey("textures"))
    {
        gameprofile = SkullBlockEntity.loadProperties(gameprofile);
    }
    EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn, false);
    instance.fixStartingPosition = () -> instance.refreshPositionAndAngles(d0, d1, d2, (float) yaw, (float) pitch);
    server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), instance);
    if (instance.dimension != dimension) //player was logged in in a different dimension
    {
        ServerWorld old_world = server.getWorld(instance.dimension);
        instance.dimension = dimension;
        old_world.removePlayer(instance);
        instance.removed = false;
        //worldIn.spawnEntity(instance);
        instance.setWorld(worldIn);
        server.getPlayerManager().sendWorldInfo(instance, worldIn);
        instance.networkHandler.requestTeleport(d0, d1, d2, (float) yaw, (float) pitch);
        instance.interactionManager.setWorld(worldIn);
        worldIn.onPlayerChangeDimension(instance);
    }
    instance.setHealth(20.0F);
    instance.removed = false;
    instance.networkHandler.requestTeleport(d0, d1, d2, (float) yaw, (float) pitch);
    instance.stepHeight = 0.6F;
    interactionManagerIn.setGameMode(gamemode);
    server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), instance.dimension);
    server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), instance.dimension);
    instance.getServerWorld().getChunkManager().updateCameraPosition(instance);
    instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes)
    return instance;
}