use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class AddOfficerCommand method execute.
@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final ActionMenu actionMenu) throws CommandException {
final Colony colony = actionMenu.getColonyForArgument("colony");
final EntityPlayer player = actionMenu.getPlayerForArgument("player");
executeShared(server, sender, colony, player.getName());
}
use of com.minecolonies.coremod.colony.Colony 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.Colony in project minecolonies by Minecolonies.
the class BlockHutTownHall method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(@NotNull final World worldIn, @NotNull final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack stack) {
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
if (worldIn.isRemote) {
return;
}
if (placer.getActiveHand().equals(EnumHand.MAIN_HAND)) {
final Colony colony = ColonyManager.getClosestColony(worldIn, pos);
String style = Constants.DEFAULT_STYLE;
final TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity instanceof TileEntityColonyBuilding && !((TileEntityColonyBuilding) tileEntity).getStyle().isEmpty()) {
style = ((TileEntityColonyBuilding) tileEntity).getStyle();
}
if (colony == null || !ColonyManager.isTooCloseToColony(worldIn, pos)) {
ColonyManager.createColony(worldIn, pos, (EntityPlayer) placer, style);
} else {
colony.setStyle(style);
}
}
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
}
use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class BlockMinecoloniesRack method onBlockActivated.
@Override
public boolean onBlockActivated(final World worldIn, final BlockPos pos, final IBlockState state, final EntityPlayer playerIn, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) {
final Colony colony = ColonyManager.getColony(worldIn, pos);
final TileEntity tileEntity = worldIn.getTileEntity(pos);
if ((colony == null || colony.getPermissions().hasPermission(playerIn, Action.ACCESS_HUTS)) && tileEntity instanceof TileEntityRack) {
if (!worldIn.isRemote) {
playerIn.openGui(MineColonies.instance, 0, worldIn, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
return false;
}
use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class AbstractBlockHut method onBlockPlacedBy.
/**
* Event-Handler for placement of this block.
* <p>
* Override for custom logic.
*
* @param worldIn the word we are in.
* @param pos the position where the block was placed.
* @param state the state the placed block is in.
* @param placer the player placing the block.
* @param stack the itemstack from where the block was placed.
* @see Block#onBlockPlacedBy(World, BlockPos, IBlockState,
* EntityLivingBase, ItemStack)
*/
@Override
public void onBlockPlacedBy(@NotNull final World worldIn, @NotNull final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack stack) {
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
/*
Only work on server side
*/
if (worldIn.isRemote) {
return;
}
final TileEntity tileEntity = worldIn.getTileEntity(pos);
if (placer instanceof EntityPlayer && tileEntity instanceof TileEntityColonyBuilding) {
@NotNull final TileEntityColonyBuilding hut = (TileEntityColonyBuilding) tileEntity;
@Nullable final Colony colony = ColonyManager.getColony(worldIn, hut.getPosition());
if (colony != null) {
colony.getBuildingManager().addNewBuilding(hut, worldIn);
}
}
}
Aggregations