fix player skins not showing properly
This commit is contained in:
1 parent
cd37140b85
commit
08c5c3db31
3 files changed
+21
-14
No files matched your search
@@ -293,13 +293,10 @@ public class PlayerCommand
|
|||||||
Messenger.m(source, "rb Player " + playerName + " cannot be placed outside of the world");
|
Messenger.m(source, "rb Player " + playerName + " cannot be placed outside of the world");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Player player = EntityPlayerMPFake.createFake(playerName, source.getServer(), pos, facing.y, facing.x, dimType, mode, flying);
|
EntityPlayerMPFake.createFake(playerName, source.getServer(), pos, facing.y, facing.x, dimType, mode, flying, () -> {
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
Messenger.m(source, "rb Player " + playerName + " doesn't exist and cannot spawn in online mode. " +
|
Messenger.m(source, "rb Player " + playerName + " doesn't exist and cannot spawn in online mode. " +
|
||||||
"Turn the server offline to spawn non-existing players");
|
"Turn the server offline to spawn non-existing players");
|
||||||
return 0;
|
});
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import carpet.fakes.ServerPlayerInterface;
|
import carpet.fakes.ServerPlayerInterface;
|
||||||
import carpet.utils.Messenger;
|
import carpet.utils.Messenger;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@SuppressWarnings("EntityConstructor")
|
@SuppressWarnings("EntityConstructor")
|
||||||
public class EntityPlayerMPFake extends ServerPlayer
|
public class EntityPlayerMPFake extends ServerPlayer
|
||||||
@@ -39,7 +40,7 @@ public class EntityPlayerMPFake extends ServerPlayer
|
|||||||
public Runnable fixStartingPosition = () -> {};
|
public Runnable fixStartingPosition = () -> {};
|
||||||
public boolean isAShadow;
|
public boolean isAShadow;
|
||||||
|
|
||||||
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, Vec3 pos, double yaw, double pitch, ResourceKey<Level> dimensionId, GameType gamemode, boolean flying)
|
public static void createFake(String username, MinecraftServer server, Vec3 pos, double yaw, double pitch, ResourceKey<Level> dimensionId, GameType gamemode, boolean flying, Runnable onError)
|
||||||
{
|
{
|
||||||
//prolly half of that crap is not necessary, but it works
|
//prolly half of that crap is not necessary, but it works
|
||||||
ServerLevel worldIn = server.getLevel(dimensionId);
|
ServerLevel worldIn = server.getLevel(dimensionId);
|
||||||
@@ -55,18 +56,20 @@ public class EntityPlayerMPFake extends ServerPlayer
|
|||||||
{
|
{
|
||||||
if (!CarpetSettings.allowSpawningOfflinePlayers)
|
if (!CarpetSettings.allowSpawningOfflinePlayers)
|
||||||
{
|
{
|
||||||
return null;
|
onError.run();
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
gameprofile = new GameProfile(UUIDUtil.createOfflinePlayerUUID(username), username);
|
gameprofile = new GameProfile(UUIDUtil.createOfflinePlayerUUID(username), username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gameprofile.getProperties().containsKey("textures"))
|
GameProfile finalGP = gameprofile;
|
||||||
|
fetchGameProfile(gameprofile.getName()).thenAccept(p -> {
|
||||||
|
GameProfile current = finalGP;
|
||||||
|
if (p.isPresent())
|
||||||
{
|
{
|
||||||
AtomicReference<GameProfile> result = new AtomicReference<>();
|
current = p.get();
|
||||||
//SkullBlockEntity.updateGameprofile(gameprofile, result::set);
|
|
||||||
//gameprofile = result.get();
|
|
||||||
}
|
}
|
||||||
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, false);
|
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, current, false);
|
||||||
instance.fixStartingPosition = () -> instance.moveTo(pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
instance.fixStartingPosition = () -> instance.moveTo(pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
||||||
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance, 0);
|
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance, 0);
|
||||||
instance.teleportTo(worldIn, pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
instance.teleportTo(worldIn, pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
||||||
@@ -79,7 +82,11 @@ public class EntityPlayerMPFake extends ServerPlayer
|
|||||||
//instance.world.getChunkManager(). updatePosition(instance);
|
//instance.world.getChunkManager(). updatePosition(instance);
|
||||||
instance.entityData.set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0x7f); // show all model layers (incl. capes)
|
instance.entityData.set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0x7f); // show all model layers (incl. capes)
|
||||||
instance.getAbilities().flying = flying;
|
instance.getAbilities().flying = flying;
|
||||||
return instance;
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CompletableFuture<Optional<GameProfile>> fetchGameProfile(final String name) {
|
||||||
|
return SkullBlockEntity.fetchGameProfile(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlayer player)
|
public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlayer player)
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ accessible class net/minecraft/server/MinecraftServer$ReloadableResources
|
|||||||
accessible class net/minecraft/world/level/biome/Biome$ClimateSettings
|
accessible class net/minecraft/world/level/biome/Biome$ClimateSettings
|
||||||
accessible class net/minecraft/world/level/block/entity/SculkSensorBlockEntity$VibrationUser
|
accessible class net/minecraft/world/level/block/entity/SculkSensorBlockEntity$VibrationUser
|
||||||
|
|
||||||
|
#TODO fields and methods should be fetched via interfaces unless there is a good reason not to
|
||||||
accessible method net/minecraft/world/level/border/WorldBorder getListeners ()Ljava/util/List;
|
accessible method net/minecraft/world/level/border/WorldBorder getListeners ()Ljava/util/List;
|
||||||
|
|
||||||
accessible method net/minecraft/server/level/DistanceManager purgeStaleTickets ()V
|
accessible method net/minecraft/server/level/DistanceManager purgeStaleTickets ()V
|
||||||
|
#cause I don't want to deal with the interfaces until stuff is stable
|
||||||
|
accessible method net/minecraft/world/level/block/entity/SkullBlockEntity fetchGameProfile (Ljava/lang/String;)Ljava/util/concurrent/CompletableFuture;
|
||||||
|
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour UPDATE_SHAPE_ORDER [Lnet/minecraft/core/Direction;
|
accessible field net/minecraft/world/level/block/state/BlockBehaviour UPDATE_SHAPE_ORDER [Lnet/minecraft/core/Direction;
|
||||||
Reference in new issue
Block a user