protected void doAttack() { if (this.attackTarget != null && this.attackTarget.removed) { this.attackTarget = null; } if (this.attackTarget == null) { float sqDistance = OpenClassic.getClient().getPlayer().getPosition().distanceSquared(mob.pos); if (sqDistance < 256) { this.attackTarget = ((ClientPlayer) OpenClassic.getClient().getPlayer()).getHandle(); } } if (this.attackTarget != null) { float xDistance = OpenClassic.getClient().getPlayer().getPosition().getX() - mob.pos.getX(); float yDistance = OpenClassic.getClient().getPlayer().getPosition().getY() - mob.pos.getY(); float zDistance = OpenClassic.getClient().getPlayer().getPosition().getZ() - mob.pos.getZ(); float sqDistance = xDistance * xDistance + yDistance * yDistance + zDistance * zDistance; if (sqDistance > 1024 && this.random.nextInt(100) == 0) { this.attackTarget = null; } if (this.attackTarget != null) { float distance = (float) Math.sqrt(sqDistance); this.mob.pos.setYaw( (float) (Math.atan2(zDistance, xDistance) * MathHelper.DRAD_TO_DEG) - 90); this.mob.pos.setPitch( -((float) (Math.atan2(yDistance, (float) Math.sqrt(distance)) * MathHelper.DRAD_TO_DEG))); if ((float) Math.sqrt(sqDistance) < 2 && this.attackDelay == 0) { this.attack(this.attackTarget); } } } }
@Override public void handle(ClassicSession session, Player player, LevelPropertyMessage message) { if (message.getType().equals("sky")) { OpenClassic.getClient().getLevel().setSkyColor(message.getValue()); } else if (message.getType().equals("fog")) { OpenClassic.getClient().getLevel().setFogColor(message.getValue()); } else if (message.getType().equals("cloud")) { OpenClassic.getClient().getLevel().setCloudColor(message.getValue()); } else if (message.getType().equals("raining")) { OpenClassic.getClient().getLevel().setRaining(message.getValue() == 1 ? true : false); } }
@Override public void handle(ClassicSession session, Player player, IdentificationMessage message) { if (session.getState() == State.IDENTIFYING) { PlayerLoginEvent event = EventManager.callEvent( new PlayerLoginEvent(OpenClassic.getClient().getPlayer(), session.getAddress())); if (event.getResult() != Result.ALLOWED) { OpenClassic.getClient().exitGameSession(); OpenClassic.getClient() .setActiveComponent( new ErrorScreen( OpenClassic.getGame().getTranslator().translate("disconnect.plugin-disallow"), event.getKickMessage())); return; } } if (message.getVerificationKeyOrMotd().contains("-hax")) { ((ClassicClient) OpenClassic.getClient()).setHacks(false); } OpenClassic.getClient().setActiveComponent(null); OpenClassic.getClient().getProgressBar().setVisible(true); OpenClassic.getClient().getProgressBar().setSubtitleScaled(false); OpenClassic.getClient() .getProgressBar() .setTitle(OpenClassic.getGame().getTranslator().translate("progress-bar.multiplayer")); OpenClassic.getClient().getProgressBar().setSubtitle(message.getUsernameOrServerName()); OpenClassic.getClient().getProgressBar().setText(message.getVerificationKeyOrMotd()); byte op = message.getOpOrPadding(); if (op == InternalConstants.OP) { player.setCanBreakUnbreakables(true); } else if (op == InternalConstants.NOT_OP) { player.setCanBreakUnbreakables(false); } if (session.getState() == State.IDENTIFYING) { EventManager.callEvent(new PlayerJoinEvent(OpenClassic.getClient().getPlayer(), "Joined")); } session.setState(State.PREPARING); }