use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.
the class ItemScepterPermission method onItemUse.
/**
* Used when clicking on block in world.
*
* @param playerIn the player
* @param worldIn the world
* @param pos the position
* @param hand the hand
* @param facing the facing hit
* @param hitX the x coordinate
* @param hitY the y coordinate
* @param hitZ the z coordinate
* @return the result
*/
@Override
@NotNull
public EnumActionResult onItemUse(final EntityPlayer playerIn, final World worldIn, final BlockPos pos, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) {
if (!worldIn.isRemote) {
return EnumActionResult.SUCCESS;
}
final ItemStack scepter = playerIn.getHeldItem(hand);
if (!scepter.hasTagCompound()) {
scepter.setTagCompound(new NBTTagCompound());
}
final ColonyView colonyView = ColonyManager.getClosestColonyView(worldIn, pos);
if (colonyView == null) {
return EnumActionResult.FAIL;
}
final NBTTagCompound compound = scepter.getTagCompound();
return handleItemAction(compound, playerIn, worldIn, pos, colonyView);
}
use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.
the class RenderUtils method calculateColonyBorder.
/**
* Calculate the colony border.
* @param theWorld in the world.
* @param thePlayer with the player.
* @param colonyBorder the border.
*/
private static void calculateColonyBorder(final WorldClient theWorld, final EntityPlayerSP thePlayer, final List<BlockPos> colonyBorder) {
final ColonyView colonyView = ColonyManager.getClosestColonyView(theWorld, thePlayer.getPosition());
if (colonyView == null) {
return;
}
final BlockPos center = colonyView.getCenter();
final int radius = Configurations.workingRangeTownHall;
for (double degrees = 0; degrees < WHOLE_CIRCLE; degrees += 1) {
final double rads = degrees / HALF_A_CIRCLE * Math.PI;
final double x = Math.round(center.getX() + radius * Math.sin(rads));
final double z = Math.round(center.getZ() + radius * Math.cos(rads));
colonyBorder.add(BlockPosUtil.getFloor(new BlockPos(x, center.getY(), z), theWorld).up());
}
}
use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.
the class WindowTownHall method teleportToColony.
/**
* On Button click teleport to the colony..
*
* @param button the clicked button.
*/
private void teleportToColony(@NotNull final Button button) {
final int row = alliesList.getListElementIndexByPane(button);
final ColonyView ally = allies.get(row);
final ITextComponent teleport = new TextComponentString(LanguageHandler.format(DO_REALLY_WANNA_TP, ally.getName())).setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, TELEPORT_COMMAND + ally.getID())));
Minecraft.getMinecraft().player.sendMessage(teleport);
}
use of com.minecolonies.coremod.colony.ColonyView 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.coremod.colony.ColonyView in project minecolonies by Minecolonies.
the class ClientEventHandler method renderWorldLastEvent.
/**
* Used to catch the renderWorldLastEvent in order to draw the debug nodes for pathfinding.
*
* @param event the catched event.
*/
@SubscribeEvent
public void renderWorldLastEvent(@NotNull final RenderWorldLastEvent event) {
Pathfinding.debugDraw(event.getPartialTicks());
final Structure structure = Settings.instance.getActiveStructure();
final WorldClient world = Minecraft.getMinecraft().world;
final EntityPlayer player = Minecraft.getMinecraft().player;
if (structure != null) {
final BlockPos position = Settings.instance.getPosition();
if (Settings.instance.getStructureName().contains(AbstractEntityAIStructure.WAYPOINT_STRING)) {
RenderUtils.renderWayPoints(position, world, event.getPartialTicks());
} else {
RenderUtils.renderColonyBorder(position, world, event.getPartialTicks(), player, colonyBorder);
}
return;
} else {
if (citizen != null) {
final Entity entityCitizen = world.getEntityByID(citizen.getEntityId());
if (entityCitizen instanceof EntityCitizen) {
RenderUtils.renderSigns(world, event.getPartialTicks(), citizen, player, entityCitizen.getPosition());
ticksPassed += event.getPartialTicks();
if (ticksPassed > Constants.TICKS_SECOND * SECONDS_TO_SHOW) {
ticksPassed = 0;
citizen = null;
}
} else {
citizen = null;
ticksPassed = 0;
}
return;
}
final ColonyView colony = ColonyManager.getClosestColonyView(world, player.getPosition());
if (colony != null && player != null && colony.getPermissions().hasPermission(player, Action.ACCESS_HUTS)) {
for (final CitizenDataView citizenDataView : new ArrayList<CitizenDataView>(colony.getCitizens().values())) {
final Entity entityCitizen = world.getEntityByID(citizenDataView.getEntityId());
if (entityCitizen instanceof EntityCitizen && entityCitizen.getPosition().distanceSq(player.getPosition()) <= 2) {
RenderUtils.renderSigns(world, event.getPartialTicks(), citizenDataView, player, entityCitizen.getPosition());
citizen = citizenDataView;
return;
}
}
}
}
colonyBorder.clear();
}
Aggregations