Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/main/java/serverutils/command/tp/CmdRTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE
}
ServerUtilitiesPlayerData data = ServerUtilitiesPlayerData.get(CommandUtils.getForgePlayer(player));
data.checkTeleportCooldown(sender, TeleportType.RTP);
TeleporterDimPos pos = findBlockPos(
player.mcServer.worldServerForDimension(ServerUtilitiesConfig.world.spawn_dimension),
player,
0);

World world = player.mcServer.worldServerForDimension(ServerUtilitiesConfig.world.spawn_dimension);
boolean prevFindingSpawnPoint = world.findingSpawnPoint;
world.findingSpawnPoint = true;

TeleporterDimPos pos = findBlockPos(world, player, 0);
data.teleport(pos, TeleportType.RTP, null);

world.findingSpawnPoint = prevFindingSpawnPoint;
}

private TeleporterDimPos findBlockPos(World world, EntityPlayerMP player, int depth) {
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/serverutils/lib/math/TeleporterDimPos.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.server.S1FPacketSetExperience;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;

import serverutils.ServerUtilities;
Expand Down Expand Up @@ -42,7 +41,7 @@ public BlockDimPos block() {
return new BlockDimPos(posX, posY, posZ, dim);
}

public void placeEntity(World world, Entity entity, float yaw) {
public void placeEntity(Entity entity, float yaw) {
entity.motionX = entity.motionY = entity.motionZ = 0D;
entity.fallDistance = 0F;

Expand All @@ -51,6 +50,8 @@ public void placeEntity(World world, Entity entity, float yaw) {
} else {
entity.setLocationAndAngles(posX, posY, posZ, yaw, entity.rotationPitch);
}

entity.worldObj.updateEntityWithOptionalForce(entity, false);
}

@Nullable
Expand All @@ -61,15 +62,12 @@ public Entity teleport(@Nullable Entity entity) {

if (ServerUtilitiesConfig.debugging.log_teleport) {
ServerUtilities.LOGGER.info(
"Teleporting '" + entity.getCommandSenderName()
+ "' to ["
+ posX
+ ','
+ posY
+ ','
+ posZ
+ "] in "
+ ServerUtils.getDimensionName(dim).getUnformattedText());
"Teleporting '{}' to [{},{},{}] in {}",
entity.getCommandSenderName(),
posX,
posY,
posZ,
ServerUtils.getDimensionName(dim).getUnformattedText());
}

if (dim != entity.dimension) {
Expand All @@ -96,7 +94,7 @@ public Entity teleport(@Nullable Entity entity) {
}
}

placeEntity(entity.worldObj, entity, entity.rotationYaw);
placeEntity(entity, entity.rotationYaw);
return entity;
}
}
10 changes: 10 additions & 0 deletions src/main/java/serverutils/task/TeleportTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public void execute(Universe universe) {
} else if (secondsLeft <= 1) {
Entity mount = player.ridingEntity;
player.mountEntity(null);

boolean prevFindingSpawnPoint = player.worldObj.findingSpawnPoint;
if (TeleportType.RTP.equals(teleportType)) {
player.worldObj.findingSpawnPoint = true;
}

if (mount != null) {
teleporter.teleport(mount);
}
Expand All @@ -72,6 +78,10 @@ public void execute(Universe universe) {
if (extraTask != null) {
extraTask.execute(universe);
}

if (TeleportType.RTP.equals(teleportType)) {
player.worldObj.findingSpawnPoint = prevFindingSpawnPoint;
}
} else {
secondsLeft -= 1;
setNextTime(System.currentTimeMillis() + Ticks.SECOND.millis());
Expand Down