Skip to content

Commit

Permalink
优化了部分实现流程
Browse files Browse the repository at this point in the history
  • Loading branch information
TiyaAnlite committed Dec 14, 2022
1 parent 770bb98 commit 4ab865a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ loader_version=0.14.11
# carpet_core_version=1.18-1.4.56+v211130

# Mod Properties
mod_version = 1.3.2
mod_version = 1.3.3
maven_group = cn.focot.codelab
archives_base_name = MineCodeCraftMod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;

import java.text.SimpleDateFormat;
import java.util.*;

public class PlayerHelper extends AbstractHelper {
Expand Down Expand Up @@ -54,20 +53,20 @@ public static void tpPlayer(ServerPlayerEntity player, ServerWorld world, Vec3d
Thread.sleep(1000);
sec++;
}
ChunkPos chunkPos = new ChunkPos(new BlockPos(targetPos.getX(), targetPos.getY(), targetPos.getZ()));
world.getChunkManager().addTicket(ChunkTicketType.POST_TELEPORT, chunkPos, 1, player.getId());
//Single player
//serverOverworld.playSound(targetPos.x, targetPos.y, targetPos.z, new SoundEvent(teleportSound), SoundCategory.PLAYERS, 1.0F, 1.0F, true);
player.stopRiding();
if (player.isSleeping()) {
player.wakeUp(true, true);
}
if (player.isDead()) {
player.sendMessage(Text.of("§4玩家死亡,传送计划被取消§r"), false);
return;
}
player.stopRiding();
if (player.isSleeping()) {
player.wakeUp(true, true);
}
// History
StatusHelper.updatePlayerPosHistory(player);
ChunkPos chunkPos = new ChunkPos(new BlockPos(targetPos.getX(), targetPos.getY(), targetPos.getZ()));
world.getChunkManager().addTicket(ChunkTicketType.POST_TELEPORT, chunkPos, 1, player.getId());
player.teleport(world, targetPos.getX(), targetPos.getY(), targetPos.getZ(), f, g);
if (!world.equals(playerWorld)) {
// Fix experience bar when change world
Expand All @@ -80,7 +79,9 @@ public static void tpPlayer(ServerPlayerEntity player, ServerWorld world, Vec3d
List<ServerPlayerEntity> serverPlayers = world.getPlayers();
PlaySoundS2CPacket packet = new PlaySoundS2CPacket(teleportSound, SoundCategory.PLAYERS, targetPos.getX(), targetPos.getY(), targetPos.getZ(), 1.0F, 1.0F, 1);
for (ServerPlayerEntity p : serverPlayers) {
p.networkHandler.sendPacket(packet);
if (world.equals(p.getWorld())) {
p.networkHandler.sendPacket(packet);
}
}
} catch (InterruptedException e) {
LOGGER.error("At tpPlayer", e);
Expand Down Expand Up @@ -130,7 +131,7 @@ public static void here(ServerPlayerEntity player) {
public static void whereRequest(ServerPlayerEntity targetPlayer, ServerPlayerEntity requestPlayer) {
targetPlayer.sendMessage(Text.of("§3%s§a请求你广播当前位置,同意请在§6%d秒§a内输入§6/here".formatted(requestPlayer.getName().getString(), config.getConfigBean().playerWhereRequestExpire)));
StatusHelper.addPlayerWhereRequest(targetPlayer, requestPlayer);
targetPlayer.sendMessage(Text.of("位置共享请求已发送"));
requestPlayer.sendMessage(Text.of("位置共享请求已发送"));
}

public static boolean isTeleportPlayer(String name) {
Expand Down

0 comments on commit 4ab865a

Please sign in to comment.