fake players will inherit caller flying status. Fixes #938
This commit is contained in:
1 parent
47bf776d71
commit
a77fc5c2f5
2 files changed
+6
-2
No files matched your search
@@ -265,10 +265,12 @@ public class PlayerCommand
|
||||
() -> source.getWorld().getRegistryKey() // dimension.getType()
|
||||
);
|
||||
GameMode mode = GameMode.CREATIVE;
|
||||
boolean flying = false;
|
||||
try
|
||||
{
|
||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||
mode = player.interactionManager.getGameMode();
|
||||
flying = player.abilities.flying;
|
||||
}
|
||||
catch (CommandSyntaxException ignored) {}
|
||||
String playerName = StringArgumentType.getString(context, "player");
|
||||
@@ -284,7 +286,7 @@ public class PlayerCommand
|
||||
Messenger.m(context.getSource(), "rb Player "+playerName+" cannot be placed outside of the world");
|
||||
return 0;
|
||||
}
|
||||
PlayerEntity player = EntityPlayerMPFake.createFake(playerName, server, pos.x, pos.y, pos.z, facing.y, facing.x, dimType, mode);
|
||||
PlayerEntity player = EntityPlayerMPFake.createFake(playerName, server, pos.x, pos.y, pos.z, facing.y, facing.x, dimType, mode, flying);
|
||||
if (player == null)
|
||||
{
|
||||
Messenger.m(context.getSource(), "rb Player " + StringArgumentType.getString(context, "player") + " doesn't exist " +
|
||||
|
||||
@@ -32,7 +32,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||
public Runnable fixStartingPosition = () -> {};
|
||||
public boolean isAShadow;
|
||||
|
||||
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, RegistryKey<World> dimensionId, GameMode gamemode)
|
||||
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, RegistryKey<World> dimensionId, GameMode gamemode, boolean flying)
|
||||
{
|
||||
//prolly half of that crap is not necessary, but it works
|
||||
ServerWorld worldIn = server.getWorld(dimensionId);
|
||||
@@ -70,6 +70,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||
server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), dimensionId);//instance.dimension);
|
||||
instance.getServerWorld().getChunkManager().updateCameraPosition(instance);
|
||||
instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes)
|
||||
instance.abilities.flying = flying;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -94,6 +95,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(playerShadow, (byte) (player.headYaw * 256 / 360)), playerShadow.world.getRegistryKey());
|
||||
server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, playerShadow));
|
||||
player.getServerWorld().getChunkManager().updateCameraPosition(playerShadow);
|
||||
playerShadow.abilities.flying = player.abilities.flying;
|
||||
return playerShadow;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user