use of net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket in project hephaestus-engine by unnamed.
the class BoneView_v1_18_R2 method position.
@Override
public void position(Vector3Float position) {
Location rootLocation = view.location();
entity.setPos(rootLocation.getX() + position.x(), rootLocation.getY() + position.y(), rootLocation.getZ() + position.z());
Packets.send(view.viewers(), new ClientboundTeleportEntityPacket(entity));
}
use of net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket in project fabric-carpet by gnembon.
the class EntityPlayerMPFake method createFake.
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, ResourceKey<Level> dimensionId, GameType gamemode, boolean flying) {
// prolly half of that crap is not necessary, but it works
ServerLevel worldIn = server.getLevel(dimensionId);
GameProfileCache.setUsesAuthentication(false);
GameProfile gameprofile;
try {
// findByName .orElse(null)
gameprofile = server.getProfileCache().get(username).orElse(null);
} finally {
GameProfileCache.setUsesAuthentication(server.isDedicatedServer() && server.usesAuthentication());
}
if (gameprofile == null) {
if (!CarpetSettings.allowSpawningOfflinePlayers) {
return null;
} else {
gameprofile = new GameProfile(Player.createPlayerUUID(username), username);
}
}
if (gameprofile.getProperties().containsKey("textures")) {
AtomicReference<GameProfile> result = new AtomicReference<>();
SkullBlockEntity.updateGameprofile(gameprofile, result::set);
gameprofile = result.get();
}
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, false);
instance.fixStartingPosition = () -> instance.moveTo(d0, d1, d2, (float) yaw, (float) pitch);
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance);
instance.teleportTo(worldIn, d0, d1, d2, (float) yaw, (float) pitch);
instance.setHealth(20.0F);
instance.unsetRemoved();
instance.maxUpStep = 0.6F;
instance.gameMode.changeGameModeForPlayer(gamemode);
// instance.dimension);
server.getPlayerList().broadcastAll(new ClientboundRotateHeadPacket(instance, (byte) (instance.yHeadRot * 256 / 360)), dimensionId);
// instance.dimension);
server.getPlayerList().broadcastAll(new ClientboundTeleportEntityPacket(instance), dimensionId);
// instance.world.getChunkManager(). updatePosition(instance);
// show all model layers (incl. capes)
instance.entityData.set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0x7f);
instance.getAbilities().flying = flying;
return instance;
}
Aggregations