use of com.minecolonies.coremod.colony.buildings.BuildingTownHall in project minecolonies by Minecolonies.
the class TeleportToColony method teleportPlayer.
/**
* Method used to teleport the player.
*
* @param colID the senders colony ID.
* @param playerToTeleport the player which shall be teleported.
*/
private static void teleportPlayer(final EntityPlayer playerToTeleport, final int colID, final ICommandSender sender) {
final Colony colony = ColonyManager.getColony(colID);
final BuildingTownHall townHall = colony.getBuildingManager().getTownHall();
if (townHall == null) {
sender.sendMessage(new TextComponentString(NO_TOWNHALL));
return;
}
playerToTeleport.sendMessage(new TextComponentString("We got places to go, kid..."));
final BlockPos position = townHall.getLocation();
final int dimension = playerToTeleport.getEntityWorld().provider.getDimension();
final int colonyDimension = townHall.getColony().getDimension();
if (colID < MIN_COLONY_ID) {
playerToTeleport.sendMessage(new TextComponentString(CANT_FIND_COLONY));
return;
}
final EntityPlayerMP entityPlayerMP = (EntityPlayerMP) sender;
if (dimension != colonyDimension) {
playerToTeleport.sendMessage(new TextComponentString("Buckle up buttercup, this ain't no joy ride!!!"));
final MinecraftServer server = sender.getEntityWorld().getMinecraftServer();
final WorldServer worldServer = server.getWorld(colonyDimension);
// Vanilla does that as well.
entityPlayerMP.connection.sendPacket(new SPacketEffect(SOUND_TYPE, BlockPos.ORIGIN, 0, false));
entityPlayerMP.addExperience(0);
entityPlayerMP.setPlayerHealthUpdated();
playerToTeleport.sendMessage(new TextComponentString("Hold onto your pants, we're going Inter-Dimensional!"));
worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, colonyDimension, new Teleporter(worldServer));
if (dimension == 1) {
worldServer.spawnEntity(playerToTeleport);
worldServer.updateEntityWithOptionalForce(playerToTeleport, false);
}
}
entityPlayerMP.connection.setPlayerLocation(position.getX(), position.getY() + 2.0, position.getZ(), entityPlayerMP.rotationYaw, entityPlayerMP.rotationPitch);
}
use of com.minecolonies.coremod.colony.buildings.BuildingTownHall in project minecolonies by Minecolonies.
the class RecallTownhallMessage method messageOnServerThread.
@Override
public void messageOnServerThread(final RecallTownhallMessage message, final EntityPlayerMP player) {
final Colony colony = ColonyManager.getColony(message.colonyId);
if (colony != null) {
// Verify player has permission to change this huts settings
if (!colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)) {
return;
}
@Nullable final BuildingTownHall building = colony.getBuildingManager().getTownHall();
if (building != null) {
final BlockPos location = building.getLocation();
final World world = colony.getWorld();
for (final CitizenData citizenData : colony.getCitizenManager().getCitizens()) {
Optional<EntityCitizen> optionalEntityCitizen = citizenData.getCitizenEntity();
if (!optionalEntityCitizen.isPresent()) {
Log.getLogger().warn(String.format("Citizen #%d:%d has gone AWOL, respawning them!", colony.getID(), citizenData.getId()));
citizenData.updateCitizenEntityIfNecessary();
optionalEntityCitizen = citizenData.getCitizenEntity();
}
if (optionalEntityCitizen.isPresent() && !TeleportHelper.teleportCitizen(optionalEntityCitizen.get(), world, location)) {
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.workerHuts.recallFail");
}
}
}
}
}
Aggregations