Cleanup to the /player command (#1690)
* Small cleanup to `/player` command There should be no changes to users * Use extracted `source` variable * Inline another single-use small function * Inline another trivial helper * Import inner classes of the ActionPack * Rename `literalargumentbuilder` variable * Compact unnecessary three lines into one * Inline `source.getServer` and pass `Vec3` to `createFake` This gets outside of "just" the command, but it's fine * Unpick name length constant * Pass `Vec3` directly to `BlockPos.containing`
This commit is contained in:
1 parent
5fcfc7aa8d
commit
431b0e68de
2 files changed
+80
-120
No files matched your search
@@ -26,6 +26,7 @@ import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import carpet.fakes.ServerPlayerInterface;
|
||||
import carpet.utils.Messenger;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class EntityPlayerMPFake extends ServerPlayer
|
||||
public Runnable fixStartingPosition = () -> {};
|
||||
public boolean isAShadow;
|
||||
|
||||
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)
|
||||
public static EntityPlayerMPFake createFake(String username, MinecraftServer server, Vec3 pos, 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);
|
||||
@@ -65,9 +66,9 @@ public class EntityPlayerMPFake extends ServerPlayer
|
||||
gameprofile = result.get();
|
||||
}
|
||||
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, false);
|
||||
instance.fixStartingPosition = () -> instance.moveTo(d0, d1, d2, (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);
|
||||
instance.teleportTo(worldIn, d0, d1, d2, (float)yaw, (float)pitch);
|
||||
instance.teleportTo(worldIn, pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
||||
instance.setHealth(20.0F);
|
||||
instance.unsetRemoved();
|
||||
instance.setMaxUpStep(0.6F);
|
||||
|
||||
Reference in new issue
Block a user