public void attractBoundModules(IClickable exception) { for (ClickableModule module : boundModules) { if (module != exception) { MusePoint2D euclideanDistance = module.getPosition().minus(this.getPosition()); MusePoint2D directionVector = euclideanDistance.normalize(); MusePoint2D tangentTarget = directionVector.times(getTargetDistance()).plus(this.getPosition()); MusePoint2D midpointTangent = module.getPosition().midpoint(tangentTarget); module.move(midpointTangent.x(), midpointTangent.y()); } } }
public void unbindFarModules() { Iterator<ClickableModule> iterator = boundModules.iterator(); ClickableModule module; while (iterator.hasNext()) { module = iterator.next(); int maxDistance = getTargetDistance() * 2; double distanceSq = module.getPosition().distanceSq(this.getPosition()); if (distanceSq > maxDistance * maxDistance) { iterator.remove(); } } }
public void toggleModules() { EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; if (player == null) { return; } for (ClickableModule module : boundModules) { String valstring = toggleval ? " on" : " off"; if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { player.sendChatToPlayer("Toggled " + module.getModule().getName() + valstring); } MuseItemUtils.toggleModuleForPlayer(player, module.getModule().getName(), toggleval); MusePacketToggleRequest toggleRequest = new MusePacketToggleRequest((Player) player, module.getModule().getName(), toggleval); player.sendQueue.addToSendQueue(toggleRequest.getPacket250()); } toggleval = !toggleval; }