use of com.minecolonies.api.colony.IColony in project minecolonies by Minecolonies.
the class WindowTownHall method updateAllies.
/**
* Clears and resets all allies.
*/
private void updateAllies() {
allies.clear();
final ColonyView colony = building.getColony();
for (final Player player : colony.getPermissions().getPlayersByRank(Rank.OFFICER)) {
final IColony col = ColonyManager.getIColonyByOwner(Minecraft.getMinecraft().world, player.getID());
if (col instanceof ColonyView) {
for (final Player owner : colony.getPermissions().getPlayersByRank(Rank.OWNER)) {
if (col.getPermissions().getRank(owner.getID()) == Rank.OFFICER) {
allies.add((ColonyView) col);
}
}
}
}
}
use of com.minecolonies.api.colony.IColony in project minecolonies by Minecolonies.
the class EventHandler method onDebugOverlay.
/**
* Event when the debug screen is opened. Event gets called by displayed
* text on the screen, we only need it when f3 is clicked.
*
* @param event {@link net.minecraftforge.client.event.RenderGameOverlayEvent.Text}
*/
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onDebugOverlay(final RenderGameOverlayEvent.Text event) {
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.gameSettings.showDebugInfo) {
final WorldClient world = mc.world;
final EntityPlayerSP player = mc.player;
IColony colony = ColonyManager.getIColony(world, player.getPosition());
if (colony == null) {
if (!ColonyManager.isTooCloseToColony(world, player.getPosition())) {
event.getLeft().add(LanguageHandler.format("com.minecolonies.coremod.gui.debugScreen.noCloseColony"));
return;
}
colony = ColonyManager.getClosestIColony(world, player.getPosition());
if (colony == null) {
return;
}
event.getLeft().add(LanguageHandler.format("com.minecolonies.coremod.gui.debugScreen.nextColony", (int) Math.sqrt(colony.getDistanceSquared(player.getPosition())), ColonyManager.getMinimumDistanceBetweenTownHalls()));
return;
}
event.getLeft().add(colony.getName() + " : " + LanguageHandler.format("com.minecolonies.coremod.gui.debugScreen.blocksFromCenter", (int) Math.sqrt(colony.getDistanceSquared(player.getPosition()))));
}
}
}
use of com.minecolonies.api.colony.IColony in project minecolonies by Minecolonies.
the class EventHandler method onPlayerInteract.
/**
* Event when a player right clicks a block, or right clicks with an item.
* Event gets cancelled when player has no permission. Event gets cancelled
* when the player has no permission to place a hut, and tried it.
*
* @param event {@link PlayerInteractEvent.RightClickBlock}
*/
@SubscribeEvent
public void onPlayerInteract(@NotNull final PlayerInteractEvent.RightClickBlock event) {
final EntityPlayer player = event.getEntityPlayer();
final World world = event.getWorld();
// Only execute for the main hand our colony events.
if (event.getHand() == EnumHand.MAIN_HAND && !(event.getWorld().isRemote)) {
// and uses that return value, but I didn't want to call it twice
if (playerRightClickInteract(player, world, event.getPos()) && world.getBlockState(event.getPos()).getBlock() instanceof AbstractBlockHut) {
final IColony colony = ColonyManager.getIColony(world, event.getPos());
if (colony != null && !colony.getPermissions().hasPermission(player, Action.ACCESS_HUTS)) {
event.setCanceled(true);
}
return;
} else if ("pmardle".equalsIgnoreCase(event.getEntityPlayer().getName()) && Block.getBlockFromItem(event.getItemStack().getItem()) instanceof BlockSilverfish) {
LanguageHandler.sendPlayerMessage(event.getEntityPlayer(), "Stop that you twat!!!");
event.setCanceled(true);
}
if (player.getHeldItemMainhand() == null || player.getHeldItemMainhand().getItem() == null) {
return;
}
handleEventCancellation(event, player);
}
}
use of com.minecolonies.api.colony.IColony in project minecolonies by Minecolonies.
the class WindowTownHall method updateFeuds.
/**
* Clears and resets all feuds.
*/
private void updateFeuds() {
feuds.clear();
final ColonyView colony = building.getColony();
for (final Player player : colony.getPermissions().getPlayersByRank(Rank.HOSTILE)) {
final IColony col = ColonyManager.getIColonyByOwner(Minecraft.getMinecraft().world, player.getID());
if (col instanceof ColonyView) {
for (final Player owner : colony.getPermissions().getPlayersByRank(Rank.OWNER)) {
if (col.getPermissions().getRank(owner.getID()) == Rank.HOSTILE) {
feuds.add((ColonyView) col);
}
}
}
}
}
use of com.minecolonies.api.colony.IColony in project minecolonies by Minecolonies.
the class EventHandler method onTownHallPlaced.
protected static boolean onTownHallPlaced(@NotNull final World world, @NotNull final EntityPlayer player, final BlockPos pos) {
IColony colony = ColonyManager.getIColonyByOwner(world, player);
if (colony != null) {
return canOwnerPlaceTownHallHere(world, player, colony, pos);
}
colony = ColonyManager.getClosestIColony(world, pos);
if (colony == null) {
return true;
}
// Town Halls must be far enough apart
return canPlayerPlaceTownHallHere(world, player, pos, colony);
}
Aggregations