protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) { if (this.visible) { if (this.field_146155_p) { this.field_146156_o = (float) (mouseX - (this.xPosition + 4)) / (float) (this.width - 8); this.field_146156_o = MathHelper.clamp_float(this.field_146156_o, 0.0F, 1.0F); mc.gameSettings.setSoundLevel(this.field_146153_r, this.field_146156_o); mc.gameSettings.saveOptions(); this.displayString = this.field_146152_s + ": " + GuiScreenOptionsSounds.this.getSoundVolume(this.field_146153_r); } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.drawTexturedModalRect( this.xPosition + (int) (this.field_146156_o * (float) (this.width - 8)), this.yPosition, 0, 66, 4, 20); this.drawTexturedModalRect( this.xPosition + (int) (this.field_146156_o * (float) (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20); } }
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { if (super.mousePressed(mc, mouseX, mouseY)) { this.field_146156_o = (float) (mouseX - (this.xPosition + 4)) / (float) (this.width - 8); this.field_146156_o = MathHelper.clamp_float(this.field_146156_o, 0.0F, 1.0F); mc.gameSettings.setSoundLevel(this.field_146153_r, this.field_146156_o); mc.gameSettings.saveOptions(); this.displayString = this.field_146152_s + ": " + GuiScreenOptionsSounds.this.getSoundVolume(this.field_146153_r); this.field_146155_p = true; return true; } else { return false; } }
/** Updates the task */ public void updateTask() { double var1 = this.entityHost.getDistanceSq( this.attackTarget.posX, this.attackTarget.getEntityBoundingBox().minY, this.attackTarget.posZ); boolean var3 = this.entityHost.getEntitySenses().canSee(this.attackTarget); if (var3) { ++this.field_75318_f; } else { this.field_75318_f = 0; } if (var1 <= (double) this.maxAttackDistance && this.field_75318_f >= 20) { this.entityHost.getNavigator().clearPathEntity(); } else { this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, this.entityMoveSpeed); } this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F); float var4; if (--this.rangedAttackTime == 0) { if (var1 > (double) this.maxAttackDistance || !var3) { return; } var4 = MathHelper.sqrt_double(var1) / this.field_96562_i; float var5 = MathHelper.clamp_float(var4, 0.1F, 1.0F); this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, var5); this.rangedAttackTime = MathHelper.floor_float( var4 * (float) (this.maxRangedAttackTime - this.field_96561_g) + (float) this.field_96561_g); } else if (this.rangedAttackTime < 0) { var4 = MathHelper.sqrt_double(var1) / this.field_96562_i; this.rangedAttackTime = MathHelper.floor_float( var4 * (float) (this.maxRangedAttackTime - this.field_96561_g) + (float) this.field_96561_g); } }