From 7c00af18febf6c0b833c7633b4fb60a9a1bb93af Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 16 Oct 2021 15:50:41 -0400 Subject: Code Clean Up (#2) * intellij code clean up * optimize imports * format * intellij suggestions * fix empty catch issues --- .../miscfeatures/FishingHelper.java | 228 +++++++++++---------- 1 file changed, 115 insertions(+), 113 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java index de7ffe5e..8e712012 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java @@ -6,7 +6,6 @@ import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.PositionedSound; -import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.SoundCategory; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.GlStateManager; @@ -54,6 +53,7 @@ public class FishingHelper { FISH_INCOMING, FISH_HOOKED } + public PlayerWarningState warningState = PlayerWarningState.NOTHING; private int hookedWarningStateTicks = 0; @@ -66,11 +66,14 @@ public class FishingHelper { private int buildupSoundDelay = 0; private static final ResourceLocation FISHING_WARNING_EXCLAM = new ResourceLocation("notenoughupdates:fishing_warning_exclam.png"); + public void onRenderBobber(EntityFishHook hook) { - if(Minecraft.getMinecraft().thePlayer.fishEntity == hook && warningState != PlayerWarningState.NOTHING) { + if (Minecraft.getMinecraft().thePlayer.fishEntity == hook && warningState != PlayerWarningState.NOTHING) { - if(!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning && warningState == PlayerWarningState.FISH_INCOMING) return; - if(!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR && warningState == PlayerWarningState.FISH_HOOKED) return; + if (!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning && warningState == PlayerWarningState.FISH_INCOMING) + return; + if (!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR && warningState == PlayerWarningState.FISH_HOOKED) + return; GlStateManager.disableCull(); GlStateManager.disableLighting(); @@ -79,9 +82,9 @@ public class FishingHelper { float offset = warningState == PlayerWarningState.FISH_HOOKED ? 0.5f : 0f; - float centerOffset = 0.5f/8f; + float centerOffset = 0.5f / 8f; Minecraft.getMinecraft().getTextureManager().bindTexture(FISHING_WARNING_EXCLAM); - Utils.drawTexturedRect(centerOffset - 4f/8f, -20/8f, 1f, 2f, 0+offset, 0.5f+offset, 0, 1, GL11.GL_NEAREST); + Utils.drawTexturedRect(centerOffset - 4f / 8f, -20 / 8f, 1f, 2f, 0 + offset, 0.5f + offset, 0, 1, GL11.GL_NEAREST); GlStateManager.scale(1, -1, 1); GL11.glDepthFunc(GL11.GL_LEQUAL); @@ -91,15 +94,15 @@ public class FishingHelper { } public void addEntity(int entityId, Entity entity) { - if(entity instanceof EntityFishHook) { + if (entity instanceof EntityFishHook) { hookEntities.put(entityId, (EntityFishHook) entity); - if(((EntityFishHook) entity).angler == Minecraft.getMinecraft().thePlayer) { + if (((EntityFishHook) entity).angler == Minecraft.getMinecraft().thePlayer) { long currentTime = System.currentTimeMillis(); long delay = currentTime - lastCastRodMillis; - if(delay > 0 && delay < 500) { - if(delay > 300) delay = 300; - pingDelayList.add(0, (int)delay); + if (delay > 0 && delay < 500) { + if (delay > 300) delay = 300; + pingDelayList.add(0, (int) delay); } } } @@ -117,14 +120,14 @@ public class FishingHelper { @SubscribeEvent public void onPlayerInteract(PlayerInteractEvent event) { - if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR && - event.entityPlayer == Minecraft.getMinecraft().thePlayer) { + if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR && + event.entityPlayer == Minecraft.getMinecraft().thePlayer) { ItemStack heldItem = event.entityPlayer.getHeldItem(); - if(heldItem != null && heldItem.getItem() == Items.fishing_rod) { + if (heldItem != null && heldItem.getItem() == Items.fishing_rod) { long currentTime = System.currentTimeMillis(); - if(currentTime - lastCastRodMillis > 500) { + if (currentTime - lastCastRodMillis > 500) { lastCastRodMillis = currentTime; } } @@ -133,35 +136,36 @@ public class FishingHelper { } private int tickCounter = 0; + @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { - if(Minecraft.getMinecraft().thePlayer != null && event.phase == TickEvent.Phase.END) { - if(buildupSoundDelay > 0) buildupSoundDelay--; + if (Minecraft.getMinecraft().thePlayer != null && event.phase == TickEvent.Phase.END) { + if (buildupSoundDelay > 0) buildupSoundDelay--; - if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning || NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { - if(Minecraft.getMinecraft().thePlayer.fishEntity != null) { - if(!pingDelayList.isEmpty()) { - while(pingDelayList.size() > 5) pingDelayList.remove(pingDelayList.size()-1); + if (NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning || NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { + if (Minecraft.getMinecraft().thePlayer.fishEntity != null) { + if (!pingDelayList.isEmpty()) { + while (pingDelayList.size() > 5) pingDelayList.remove(pingDelayList.size() - 1); int totalMS = 0; - for(int delay : pingDelayList) { + for (int delay : pingDelayList) { totalMS += delay; } int averageMS = totalMS / pingDelayList.size(); - pingDelayTicks = (int)Math.floor(averageMS/50f); + pingDelayTicks = (int) Math.floor(averageMS / 50f); } } - if(hookedWarningStateTicks > 0) { + if (hookedWarningStateTicks > 0) { hookedWarningStateTicks--; warningState = PlayerWarningState.FISH_HOOKED; } else { warningState = PlayerWarningState.NOTHING; - if(Minecraft.getMinecraft().thePlayer.fishEntity != null) { + if (Minecraft.getMinecraft().thePlayer.fishEntity != null) { int fishEntityId = Minecraft.getMinecraft().thePlayer.fishEntity.getEntityId(); - for(Map.Entry> entry : chains.entrySet()) { - if(entry.getKey().particleNum >= 3 && entry.getValue().contains(fishEntityId)) { + for (Map.Entry> entry : chains.entrySet()) { + if (entry.getKey().particleNum >= 3 && entry.getValue().contains(fishEntityId)) { warningState = PlayerWarningState.FISH_INCOMING; break; } @@ -170,21 +174,21 @@ public class FishingHelper { } } - if(tickCounter++ >= 20) { + if (tickCounter++ >= 20) { long currentTime = System.currentTimeMillis(); tickCounter = 0; Set toRemoveEnt = new HashSet<>(); - for(Map.Entry entry : hookEntities.entrySet()) { - if(entry.getValue().isDead) { + for (Map.Entry entry : hookEntities.entrySet()) { + if (entry.getValue().isDead) { toRemoveEnt.add(entry.getKey()); } } hookEntities.keySet().removeAll(toRemoveEnt); Set toRemoveChain = new HashSet<>(); - for(Map.Entry> entry : chains.entrySet()) { - if(currentTime - entry.getKey().lastUpdate > 200 || + for (Map.Entry> entry : chains.entrySet()) { + if (currentTime - entry.getKey().lastUpdate > 200 || entry.getValue().isEmpty() || Collections.disjoint(entry.getValue(), hookEntities.keySet())) { toRemoveChain.add(entry.getKey()); @@ -199,28 +203,28 @@ public class FishingHelper { double angleX = Math.toDegrees(Math.acos(xOffset / 0.04f)); double angleZ = Math.toDegrees(Math.asin(zOffset / 0.04f)); - if(xOffset < 0) { + if (xOffset < 0) { angleZ = 180 - angleZ; } - if(zOffset < 0) { + if (zOffset < 0) { angleX = 360 - angleX; } angleX %= 360; angleZ %= 360; - if(angleX < 0) angleX += 360; - if(angleZ < 0) angleZ += 360; + if (angleX < 0) angleX += 360; + if (angleZ < 0) angleZ += 360; double dist = angleX - angleZ; - if(dist < -180) dist += 360; - if(dist > 180) dist -= 360; + if (dist < -180) dist += 360; + if (dist > 180) dist -= 360; - return angleZ + dist/2; + return angleZ + dist / 2; } private boolean checkAngleWithinRange(double angle1, double angle2, double range) { double dist = Math.abs(angle1 - angle2); - if(dist > 180) dist = 360 - dist; + if (dist > 180) dist = 360 - dist; return dist <= range; } @@ -234,25 +238,25 @@ public class FishingHelper { private HookPossibleRet isHookPossible(EntityFishHook hook, double particleX, double particleY, double particleZ, double angle1, double angle2) { double dY = particleY - hook.posY; - if(Math.abs(dY) > 0.5f) { + if (Math.abs(dY) > 0.5f) { return HookPossibleRet.NOT_POSSIBLE; } double dX = particleX - hook.posX; double dZ = particleZ - hook.posZ; - double dist = Math.sqrt(dX*dX + dZ*dZ); + double dist = Math.sqrt(dX * dX + dZ * dZ); - if(dist < 0.2) { + if (dist < 0.2) { return HookPossibleRet.EITHER; } else { - float angleAllowance = (float)Math.toDegrees(Math.atan2(0.03125f, dist))*1.5f; + float angleAllowance = (float) Math.toDegrees(Math.atan2(0.03125f, dist)) * 1.5f; float angleHook = (float) Math.toDegrees(Math.atan2(dX, dZ)); angleHook %= 360; - if(angleHook < 0) angleHook += 360; + if (angleHook < 0) angleHook += 360; - if(checkAngleWithinRange(angle1, angleHook, angleAllowance)) { + if (checkAngleWithinRange(angle1, angleHook, angleAllowance)) { return HookPossibleRet.ANGLE1; - } else if(checkAngleWithinRange(angle2, angleHook, angleAllowance)) { + } else if (checkAngleWithinRange(angle2, angleHook, angleAllowance)) { return HookPossibleRet.ANGLE2; } } @@ -264,101 +268,100 @@ public class FishingHelper { private static final float ZERO_PITCH = 1.0f; private static final float MAX_PITCH = 0.1f; private static final float MAX_DISTANCE = 5f; + private float calculatePitchFromDistance(float d) { - if(d < 0.1f) d = 0.1f; - if(d > MAX_DISTANCE) d = MAX_DISTANCE; + if (d < 0.1f) d = 0.1f; + if (d > MAX_DISTANCE) d = MAX_DISTANCE; - return 1/(d + (1/(ZERO_PITCH-MAX_PITCH))) * (1 - d/MAX_DISTANCE) + MAX_PITCH; + return 1 / (d + (1 / (ZERO_PITCH - MAX_PITCH))) * (1 - d / MAX_DISTANCE) + MAX_PITCH; } public boolean onSpawnParticle(EnumParticleTypes particleType, double x, double y, double z, double xOffset, double yOffset, double zOffset) { - if(!NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll && + if (!NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll && !NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles && !NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning && !NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { return false; } - if(hookEntities.isEmpty()) { + if (hookEntities.isEmpty()) { return false; } - - if((particleType == EnumParticleTypes.WATER_WAKE|| particleType == EnumParticleTypes.SMOKE_NORMAL) && Math.abs(yOffset - 0.01f) < 0.001f) { + if ((particleType == EnumParticleTypes.WATER_WAKE || particleType == EnumParticleTypes.SMOKE_NORMAL) && Math.abs(yOffset - 0.01f) < 0.001f) { double angle1 = calculateAngleFromOffsets(xOffset, -zOffset); double angle2 = calculateAngleFromOffsets(-xOffset, zOffset); - final List possibleHooks1 = new ArrayList<>(); final List possibleHooks2 = new ArrayList<>(); - for(EntityFishHook hook : hookEntities.values()) { - if(hook.isDead) continue; - if(possibleHooks1.contains(hook.getEntityId())) continue; - if(possibleHooks2.contains(hook.getEntityId())) continue; + for (EntityFishHook hook : hookEntities.values()) { + if (hook.isDead) continue; + if (possibleHooks1.contains(hook.getEntityId())) continue; + if (possibleHooks2.contains(hook.getEntityId())) continue; HookPossibleRet ret = isHookPossible(hook, x, y, z, angle1, angle2); - if(ret == HookPossibleRet.ANGLE1) { + if (ret == HookPossibleRet.ANGLE1) { possibleHooks1.add(hook.getEntityId()); - } else if(ret == HookPossibleRet.ANGLE2) { + } else if (ret == HookPossibleRet.ANGLE2) { possibleHooks2.add(hook.getEntityId()); - } else if(ret == HookPossibleRet.EITHER) { + } else if (ret == HookPossibleRet.EITHER) { possibleHooks1.add(hook.getEntityId()); possibleHooks2.add(hook.getEntityId()); } } - if(!possibleHooks1.isEmpty() || !possibleHooks2.isEmpty()) { + if (!possibleHooks1.isEmpty() || !possibleHooks2.isEmpty()) { long currentTime = System.currentTimeMillis(); boolean isMainPlayer = false; boolean foundChain = false; - for(Map.Entry> entry : chains.entrySet()) { + for (Map.Entry> entry : chains.entrySet()) { WakeChain chain = entry.getKey(); - if(currentTime - chain.lastUpdate > 200) continue; + if (currentTime - chain.lastUpdate > 200) continue; double updateAngle; List possibleHooks; - if(checkAngleWithinRange(chain.currentAngle, angle1, 16)) { + if (checkAngleWithinRange(chain.currentAngle, angle1, 16)) { possibleHooks = possibleHooks1; updateAngle = angle1; - } else if(checkAngleWithinRange(chain.currentAngle, angle2, 16)) { + } else if (checkAngleWithinRange(chain.currentAngle, angle2, 16)) { possibleHooks = possibleHooks2; updateAngle = angle2; } else { continue; } - if(!Collections.disjoint(entry.getValue(), possibleHooks)) { + if (!Collections.disjoint(entry.getValue(), possibleHooks)) { HashSet newHooks = new HashSet<>(); - for(int hookEntityId : possibleHooks) { - if(entry.getValue().contains(hookEntityId) && chain.distances.containsKey(hookEntityId)) { + for (int hookEntityId : possibleHooks) { + if (entry.getValue().contains(hookEntityId) && chain.distances.containsKey(hookEntityId)) { EntityFishHook entity = hookEntities.get(hookEntityId); - if(entity != null && !entity.isDead) { + if (entity != null && !entity.isDead) { double oldDistance = chain.distances.get(hookEntityId); double dX = entity.posX - x; double dZ = entity.posZ - z; - double newDistance = Math.sqrt(dX*dX + dZ*dZ); + double newDistance = Math.sqrt(dX * dX + dZ * dZ); double delta = oldDistance - newDistance; - if(newDistance < 0.2 || (delta > -0.1 && delta < 0.3)) { - if((NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning || NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) && + if (newDistance < 0.2 || (delta > -0.1 && delta < 0.3)) { + if ((NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning || NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) && Minecraft.getMinecraft().thePlayer.fishEntity != null && Minecraft.getMinecraft().thePlayer.fishEntity.getEntityId() == hookEntityId && chain.particleNum > 3) { - if(newDistance <= 0.2f + 0.1f*pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { - if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSounds && + if (newDistance <= 0.2f + 0.1f * pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { + if (NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSounds && hookedWarningStateTicks <= 0) { - float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSoundsVol/100f; - if(vol > 0) { - if(vol > 1) vol = 1; + float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSoundsVol / 100f; + if (vol > 0) { + if (vol > 1) vol = 1; final float volF = vol; ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{ @@ -377,17 +380,17 @@ public class FishingHelper { } hookedWarningStateTicks = 12; - } else if(newDistance >= 0.4f + 0.1f*pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning) { - if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSounds && + } else if (newDistance >= 0.4f + 0.1f * pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning) { + if (NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSounds && buildupSoundDelay <= 0) { - float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSoundsVol/100f; - if(vol > 0) { - if(vol > 1) vol = 1; + float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSoundsVol / 100f; + if (vol > 0) { + if (vol > 1) vol = 1; final float volF = vol; ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{ volume = volF; - pitch = calculatePitchFromDistance((float)newDistance - (0.3f+0.1f*pingDelayTicks)); + pitch = calculatePitchFromDistance((float) newDistance - (0.3f + 0.1f * pingDelayTicks)); repeat = false; repeatDelay = 0; attenuationType = ISound.AttenuationType.NONE; @@ -410,16 +413,16 @@ public class FishingHelper { } } - if(newHooks.isEmpty()) { + if (newHooks.isEmpty()) { continue; } entry.getValue().retainAll(newHooks); chain.distances.keySet().retainAll(newHooks); - for(int i : entry.getValue()) { + for (int i : entry.getValue()) { EntityFishHook hook = hookEntities.get(i); - if(hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) { + if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) { isMainPlayer = true; break; } @@ -433,47 +436,46 @@ public class FishingHelper { } } - - if(!foundChain) { + if (!foundChain) { possibleHooks1.removeAll(possibleHooks2); - if(!possibleHooks1.isEmpty()) { - for(int i : possibleHooks1) { + if (!possibleHooks1.isEmpty()) { + for (int i : possibleHooks1) { EntityFishHook hook = hookEntities.get(i); - if(hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) { + if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) { isMainPlayer = true; break; } } WakeChain chain = new WakeChain(currentTime, angle1, x, z); - for(int hookEntityId : possibleHooks1) { + for (int hookEntityId : possibleHooks1) { EntityFishHook entity = hookEntities.get(hookEntityId); - if(entity != null && !entity.isDead) { + if (entity != null && !entity.isDead) { double dX = entity.posX - x; double dZ = entity.posZ - z; - double newDistance = Math.sqrt(dX*dX + dZ*dZ); + double newDistance = Math.sqrt(dX * dX + dZ * dZ); chain.distances.put(hookEntityId, newDistance); } } chains.put(chain, possibleHooks1); - } else if(!possibleHooks2.isEmpty()) { - for(int i : possibleHooks2) { + } else if (!possibleHooks2.isEmpty()) { + for (int i : possibleHooks2) { EntityFishHook hook = hookEntities.get(i); - if(hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) { + if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) { isMainPlayer = true; break; } } WakeChain chain = new WakeChain(currentTime, angle2, x, z); - for(int hookEntityId : possibleHooks2) { + for (int hookEntityId : possibleHooks2) { EntityFishHook entity = hookEntities.get(hookEntityId); - if(entity != null && !entity.isDead) { + if (entity != null && !entity.isDead) { double dX = entity.posX - x; double dZ = entity.posZ - z; - double newDistance = Math.sqrt(dX*dX + dZ*dZ); + double newDistance = Math.sqrt(dX * dX + dZ * dZ); chain.distances.put(hookEntityId, newDistance); } } @@ -483,25 +485,25 @@ public class FishingHelper { int particleTypeI; String particleCustomColour; - if(isMainPlayer) { + if (isMainPlayer) { particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleType; particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleColour; - } else if(NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll) { + } else if (NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll) { return true; } else { particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.otherParticleType; particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.otherParticleColour; } - if(!NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles) { + if (!NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles) { return false; } int argb = SpecialColour.specialToChromaRGB(particleCustomColour); - if(particleTypeI == 0) { + if (particleTypeI == 0) { return false; - } else if(particleTypeI == 1) { + } else if (particleTypeI == 1) { return true; } @@ -512,20 +514,20 @@ public class FishingHelper { return true; } - if(i >= 2) { + if (i >= 2) { return true; } double xDist = Minecraft.getMinecraft().getRenderViewEntity().posX - x; double yDist = Minecraft.getMinecraft().getRenderViewEntity().posY - y; double zDist = Minecraft.getMinecraft().getRenderViewEntity().posZ - z; - double distSq = xDist*xDist + yDist*yDist + zDist*zDist; + double distSq = xDist * xDist + yDist * yDist + zDist * zDist; - if(distSq < 32*32) { + if (distSq < 32 * 32) { boolean customColour = false; double yVel = 0; - switch(particleTypeI) { + switch (particleTypeI) { case 2: particleType = EnumParticleTypes.FIREWORKS_SPARK; customColour = true; @@ -553,7 +555,7 @@ public class FishingHelper { break; } - if(customColour && (((argb >> 24) & 0xFF) < 10)) { + if (customColour && (((argb >> 24) & 0xFF) < 10)) { return true; } @@ -563,7 +565,7 @@ public class FishingHelper { fx.motionY = yVel; fx.motionZ = Math.random() * 0.02 - 0.01; - if(customColour) { + if (customColour) { float red = ((argb >> 16) & 0xFF) / 255f; float green = ((argb >> 8) & 0xFF) / 255f; float blue = (argb & 0xFF) / 255f; -- cgit From 9475677afdb86078f3c014b52ef1b0a414f3c5e5 Mon Sep 17 00:00:00 2001 From: nopothegamer <40329022+nopothegamer@users.noreply.github.com> Date: Fri, 10 Dec 2021 22:54:22 +1100 Subject: Slayer overlay (#28) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * idk where im commiting to * idk where im commiting to * made tita overlay and waypoints work with dwarven overlay off "fixed" divan rarity in neuah made eitherwarp block overlay turn off able * Added change notes * i stopped being pepega and worked out how neu config works * Added mining skill overlay * fixed mining overlay * add option to hide Mining waypoints in Dwarven mines when at location * better check location * Make cata xp in /pv be calculated on how many runs you have * Added master cata xp rates * Make gitignore not show as changed * Added warnings to some things in /neu * maybe fix hiding waypoints * Added a fishing skill overlay its kinda scuffed because of the interp stuff * Hopefully fix Rampart's quarry (for real now) * Moul said i could no one leak in general or smth * Cache itemstacks in miningoverlay and crystalhollows overlay (untested) * Fix preinit crash due to manager not existing yet * Make tab do the same as down button while in tab completion mode * remove debug print * Added pitch to farming overlay * Changed the panoramas back to the old one because ery is scuffed * isnt finished but should work for ery * Made it so if ur mining 60 it just says maxed level instead of b u g * Made skills not show int limit when at max level in skill overlays * wh :omegalul: made neu * sad you cant type that long in search bar * Hello don't mind me just improving your workflow * æ * Oh also this * Added the cata xp scaling(idk if m3 and 4 values are right) * Added Expertise Progress * Fix farming overlay * Added cult/crops to next cult level * Go to the other end of the tab-completion List when hitting the end * remove debug prints * added combat skill overlay and some changes to the others (combat doesnt work rn could someone look into it :prayge:) * Added cooldown to god pot showing in todo overlay * comment * Added option to remove enchant glint in storage gui * Added option to remove enchant glint in storage gui * please fix * please fix * Fixed the placement of help.png * Added fairy soul waypoints to misc * unclear not clear * Added dg partner cape * fix space cape * Fix space cape * Make it so you can hold down keys in sign GUIs * Added a button in storage menu to open the settings Added an option to change the click names for /pv to /ah * Made it so ur config doesnt reset * Added bhop (shhh dont tell anyone) * Added a help menu to /neuec * changed fisgifis overlay button no work * make working fishing tiemr * jani can you test this out for us * Added a gui locations tab * very important feature * Fixed wart hoe overlay if not alch 50 * Make it so the ding time is customizable * Added coins/m to farming overlay * Basic mining tab in pv * Just for jani * Just for jani v2 * works ig * my balls * hotm pv is mostly done missing some perks * hotm pv done * message goes here * push so i can pr jani * Final hotm pv texture + fix m3 and m4 cata xp * edit: didnt work * fixed up stuff dokm said * added image for hotm pv * Fixed previews for furf and dg capes * removed combat overlay from location gui menu in /neu * Start of a custom pv page * Removed custom pv because -2 people would use it Removed neubhop (found out bhop is bannable) * update build gradle * - Made it so treecap shows foraging xp instead of farming xp on the farming overlay - Made it so a jungle axe with cult will show the "farming" overlay * Added entrance + made blur limit at 100 * Added blocking clicks back to the enchanting minigames * update patch notes * Fixed rounding issue * let you use screenshot in et overlay * Added /neurepomode to toggle item editing and dev mode * Changed "NEUAH is DISABLED! Enable in /neusettings." to /neu * Changed misc overlays tab to todo overlays * Added config option for npc retexture (idk if it works i dont have a pack to test it with) * update patch note * Fixed api key autofill with dg copy chat feature * Fixed api key autofill with dg copy chat feature v2 * Made missing enchants not show on an item if its not missing any enchants * remove todo because pepega * Added a config option for dirt wand overlay Added a config option for hoe of tilling * patch notes * Fix pet getlorereplacements crash (im guessing) (#21) * Added an option to use short numbers (1.5mil) for price tooltips * Added warning to slotlocking + short prices default to off * make it not dungeon map * Fixed pet overlay not updating when going into /pets * Dokm after not making his own patch notes * Fixed capital letter * Refactor miscoverlays to todooverlays * idk man make the short number prices use like 5 less lines * Added an option to show next click in chronomatron * added bz price to farming overlay coins/m (only wart rn) * added bz price to farming overlay coins/m * me when cactus price was divided by 1296 :pepela: * unrefactor todo overlay because it resets the config * Fixed fetchur for the 765754465th time * Fixed time that experiment table resets + Made prevent missclicks off by default * Added slayer overlay * fixed quickforge level 20 because it goes up +0.5% every level... and randomly the last level gives + 10.5% * ery wanted to texture himself so i made a hidden toggle for it * made it so if your modlist is under 15 and you do /neustats modlist it will just show /neustats * Finished slayer overlay * Auto turn off search mode after 2 minutes * i forgor bout patch notes * Added setting jani wanted * removed hide incompatible enchants because no workie * i forgor to make it build :skull: * Added max enchant book to /neuec - Dokm * Fixed the slayer overlay when ping * edit: didnt work * Made a lil error if you have new tab list off * Fixed fishing overlay for lava fishing * Fix spelling + comments * Added bingo profile icon to /pv * comments * istg people are pepega * ery made good texture for pv bingo * making the pr fricked me (please build) * Fixed pet overlay not resetting pet when making new profile * Fixed pet overlay not resetting pet when making new profile * i forgor to add to LocationEdit neu page + last commit was added combat overlay * Fix comments because either me or intellij was on crack * comments stuff * ok de duimon no0b Co-authored-by: Lulonaut Co-authored-by: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Co-authored-by: DoKM Co-authored-by: TymanWasTaken Co-authored-by: MicrocontrollersDev Co-authored-by: jani270 Co-authored-by: DoKM <54663875+DoKM@users.noreply.github.com> Co-authored-by: IRONM00N <64110067+IRONM00N@users.noreply.github.com> --- .../moulberry/notenoughupdates/miscfeatures/FishingHelper.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java index 8e712012..94e308a1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java @@ -355,8 +355,13 @@ public class FishingHelper { Minecraft.getMinecraft().thePlayer.fishEntity != null && Minecraft.getMinecraft().thePlayer.fishEntity.getEntityId() == hookEntityId && chain.particleNum > 3) { - - if (newDistance <= 0.2f + 0.1f * pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { + float lavaOffset = 0.1f; + if (particleType == EnumParticleTypes.SMOKE_NORMAL) { + lavaOffset = 0.03f; + } else if (particleType == EnumParticleTypes.WATER_WAKE) { + lavaOffset = 0.1f; + } + if (newDistance <= 0.2f + lavaOffset * pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { if (NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSounds && hookedWarningStateTicks <= 0) { float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSoundsVol / 100f; -- cgit From ea3ec354ba3bb5b4ac64b8032816b8e4c407f099 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Tue, 28 Dec 2021 00:49:28 -0500 Subject: more code clean up (#38) --- .../github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java index 94e308a1..fdd3d704 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java @@ -24,7 +24,6 @@ import org.lwjgl.opengl.GL11; import java.util.*; public class FishingHelper { - private static final FishingHelper INSTANCE = new FishingHelper(); public static FishingHelper getInstance() { @@ -131,7 +130,6 @@ public class FishingHelper { lastCastRodMillis = currentTime; } } - } } @@ -587,5 +585,4 @@ public class FishingHelper { return false; } - } -- cgit From b09f774d422263ce15b97d6d0804beddf856176d Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 27 Feb 2022 11:53:57 -0500 Subject: feat: improve formating :) --- .../miscfeatures/FishingHelper.java | 1164 ++++++++++---------- 1 file changed, 603 insertions(+), 561 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java index fdd3d704..34e849d0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java @@ -24,565 +24,607 @@ import org.lwjgl.opengl.GL11; import java.util.*; public class FishingHelper { - private static final FishingHelper INSTANCE = new FishingHelper(); - - public static FishingHelper getInstance() { - return INSTANCE; - } - - public static class WakeChain { - public int particleNum = 0; - public long lastUpdate; - public double currentAngle; - public double currentX; - public double currentZ; - - public final HashMap distances = new HashMap<>(); - - public WakeChain(long lastUpdate, double currentAngle, double currentX, double currentZ) { - this.lastUpdate = lastUpdate; - this.currentAngle = currentAngle; - this.currentX = currentX; - this.currentZ = currentZ; - } - } - - public enum PlayerWarningState { - NOTHING, - FISH_INCOMING, - FISH_HOOKED - } - - public PlayerWarningState warningState = PlayerWarningState.NOTHING; - private int hookedWarningStateTicks = 0; - - public final HashMap hookEntities = new HashMap<>(); - public final HashMap> chains = new HashMap<>(); - - private long lastCastRodMillis = 0; - private int pingDelayTicks = 0; - private final List pingDelayList = new ArrayList<>(); - private int buildupSoundDelay = 0; - - private static final ResourceLocation FISHING_WARNING_EXCLAM = new ResourceLocation("notenoughupdates:fishing_warning_exclam.png"); - - public void onRenderBobber(EntityFishHook hook) { - if (Minecraft.getMinecraft().thePlayer.fishEntity == hook && warningState != PlayerWarningState.NOTHING) { - - if (!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning && warningState == PlayerWarningState.FISH_INCOMING) - return; - if (!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR && warningState == PlayerWarningState.FISH_HOOKED) - return; - - GlStateManager.disableCull(); - GlStateManager.disableLighting(); - GL11.glDepthFunc(GL11.GL_ALWAYS); - GlStateManager.scale(1, -1, 1); - - float offset = warningState == PlayerWarningState.FISH_HOOKED ? 0.5f : 0f; - - float centerOffset = 0.5f / 8f; - Minecraft.getMinecraft().getTextureManager().bindTexture(FISHING_WARNING_EXCLAM); - Utils.drawTexturedRect(centerOffset - 4f / 8f, -20 / 8f, 1f, 2f, 0 + offset, 0.5f + offset, 0, 1, GL11.GL_NEAREST); - - GlStateManager.scale(1, -1, 1); - GL11.glDepthFunc(GL11.GL_LEQUAL); - GlStateManager.enableLighting(); - GlStateManager.enableCull(); - } - } - - public void addEntity(int entityId, Entity entity) { - if (entity instanceof EntityFishHook) { - hookEntities.put(entityId, (EntityFishHook) entity); - - if (((EntityFishHook) entity).angler == Minecraft.getMinecraft().thePlayer) { - long currentTime = System.currentTimeMillis(); - long delay = currentTime - lastCastRodMillis; - if (delay > 0 && delay < 500) { - if (delay > 300) delay = 300; - pingDelayList.add(0, (int) delay); - } - } - } - } - - public void removeEntity(int entityId) { - hookEntities.remove(entityId); - } - - @SubscribeEvent - public void onWorldUnload(WorldEvent.Unload event) { - hookEntities.clear(); - chains.clear(); - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) { - if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR && - event.entityPlayer == Minecraft.getMinecraft().thePlayer) { - - ItemStack heldItem = event.entityPlayer.getHeldItem(); - - if (heldItem != null && heldItem.getItem() == Items.fishing_rod) { - long currentTime = System.currentTimeMillis(); - if (currentTime - lastCastRodMillis > 500) { - lastCastRodMillis = currentTime; - } - } - } - } - - private int tickCounter = 0; - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent event) { - if (Minecraft.getMinecraft().thePlayer != null && event.phase == TickEvent.Phase.END) { - if (buildupSoundDelay > 0) buildupSoundDelay--; - - if (NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning || NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { - if (Minecraft.getMinecraft().thePlayer.fishEntity != null) { - if (!pingDelayList.isEmpty()) { - while (pingDelayList.size() > 5) pingDelayList.remove(pingDelayList.size() - 1); - - int totalMS = 0; - for (int delay : pingDelayList) { - totalMS += delay; - } - - int averageMS = totalMS / pingDelayList.size(); - pingDelayTicks = (int) Math.floor(averageMS / 50f); - } - } - - if (hookedWarningStateTicks > 0) { - hookedWarningStateTicks--; - warningState = PlayerWarningState.FISH_HOOKED; - } else { - warningState = PlayerWarningState.NOTHING; - if (Minecraft.getMinecraft().thePlayer.fishEntity != null) { - int fishEntityId = Minecraft.getMinecraft().thePlayer.fishEntity.getEntityId(); - for (Map.Entry> entry : chains.entrySet()) { - if (entry.getKey().particleNum >= 3 && entry.getValue().contains(fishEntityId)) { - warningState = PlayerWarningState.FISH_INCOMING; - break; - } - } - } - } - } - - if (tickCounter++ >= 20) { - long currentTime = System.currentTimeMillis(); - tickCounter = 0; - - Set toRemoveEnt = new HashSet<>(); - for (Map.Entry entry : hookEntities.entrySet()) { - if (entry.getValue().isDead) { - toRemoveEnt.add(entry.getKey()); - } - } - hookEntities.keySet().removeAll(toRemoveEnt); - - Set toRemoveChain = new HashSet<>(); - for (Map.Entry> entry : chains.entrySet()) { - if (currentTime - entry.getKey().lastUpdate > 200 || - entry.getValue().isEmpty() || - Collections.disjoint(entry.getValue(), hookEntities.keySet())) { - toRemoveChain.add(entry.getKey()); - } - } - chains.keySet().removeAll(toRemoveChain); - } - } - } - - private double calculateAngleFromOffsets(double xOffset, double zOffset) { - double angleX = Math.toDegrees(Math.acos(xOffset / 0.04f)); - double angleZ = Math.toDegrees(Math.asin(zOffset / 0.04f)); - - if (xOffset < 0) { - angleZ = 180 - angleZ; - } - if (zOffset < 0) { - angleX = 360 - angleX; - } - - angleX %= 360; - angleZ %= 360; - if (angleX < 0) angleX += 360; - if (angleZ < 0) angleZ += 360; - - double dist = angleX - angleZ; - if (dist < -180) dist += 360; - if (dist > 180) dist -= 360; - - return angleZ + dist / 2; - } - - private boolean checkAngleWithinRange(double angle1, double angle2, double range) { - double dist = Math.abs(angle1 - angle2); - if (dist > 180) dist = 360 - dist; - - return dist <= range; - } - - private enum HookPossibleRet { - NOT_POSSIBLE, - EITHER, - ANGLE1, - ANGLE2 - } - - private HookPossibleRet isHookPossible(EntityFishHook hook, double particleX, double particleY, double particleZ, double angle1, double angle2) { - double dY = particleY - hook.posY; - if (Math.abs(dY) > 0.5f) { - return HookPossibleRet.NOT_POSSIBLE; - } - - double dX = particleX - hook.posX; - double dZ = particleZ - hook.posZ; - double dist = Math.sqrt(dX * dX + dZ * dZ); - - if (dist < 0.2) { - return HookPossibleRet.EITHER; - } else { - float angleAllowance = (float) Math.toDegrees(Math.atan2(0.03125f, dist)) * 1.5f; - float angleHook = (float) Math.toDegrees(Math.atan2(dX, dZ)); - angleHook %= 360; - if (angleHook < 0) angleHook += 360; - - if (checkAngleWithinRange(angle1, angleHook, angleAllowance)) { - return HookPossibleRet.ANGLE1; - } else if (checkAngleWithinRange(angle2, angleHook, angleAllowance)) { - return HookPossibleRet.ANGLE2; - } - } - return HookPossibleRet.NOT_POSSIBLE; - } - - public static EnumParticleTypes type = EnumParticleTypes.BARRIER; - - private static final float ZERO_PITCH = 1.0f; - private static final float MAX_PITCH = 0.1f; - private static final float MAX_DISTANCE = 5f; - - private float calculatePitchFromDistance(float d) { - if (d < 0.1f) d = 0.1f; - if (d > MAX_DISTANCE) d = MAX_DISTANCE; - - return 1 / (d + (1 / (ZERO_PITCH - MAX_PITCH))) * (1 - d / MAX_DISTANCE) + MAX_PITCH; - } - - public boolean onSpawnParticle(EnumParticleTypes particleType, double x, double y, double z, double xOffset, double yOffset, double zOffset) { - - if (!NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll && - !NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles && - !NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning && - !NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { - return false; - } - if (hookEntities.isEmpty()) { - return false; - } - - if ((particleType == EnumParticleTypes.WATER_WAKE || particleType == EnumParticleTypes.SMOKE_NORMAL) && Math.abs(yOffset - 0.01f) < 0.001f) { - double angle1 = calculateAngleFromOffsets(xOffset, -zOffset); - double angle2 = calculateAngleFromOffsets(-xOffset, zOffset); - - final List possibleHooks1 = new ArrayList<>(); - final List possibleHooks2 = new ArrayList<>(); - - for (EntityFishHook hook : hookEntities.values()) { - if (hook.isDead) continue; - if (possibleHooks1.contains(hook.getEntityId())) continue; - if (possibleHooks2.contains(hook.getEntityId())) continue; - - HookPossibleRet ret = isHookPossible(hook, x, y, z, angle1, angle2); - if (ret == HookPossibleRet.ANGLE1) { - possibleHooks1.add(hook.getEntityId()); - } else if (ret == HookPossibleRet.ANGLE2) { - possibleHooks2.add(hook.getEntityId()); - } else if (ret == HookPossibleRet.EITHER) { - possibleHooks1.add(hook.getEntityId()); - possibleHooks2.add(hook.getEntityId()); - } - } - - if (!possibleHooks1.isEmpty() || !possibleHooks2.isEmpty()) { - long currentTime = System.currentTimeMillis(); - - boolean isMainPlayer = false; - - boolean foundChain = false; - for (Map.Entry> entry : chains.entrySet()) { - WakeChain chain = entry.getKey(); - - if (currentTime - chain.lastUpdate > 200) continue; - - double updateAngle; - List possibleHooks; - if (checkAngleWithinRange(chain.currentAngle, angle1, 16)) { - possibleHooks = possibleHooks1; - updateAngle = angle1; - } else if (checkAngleWithinRange(chain.currentAngle, angle2, 16)) { - possibleHooks = possibleHooks2; - updateAngle = angle2; - } else { - continue; - } - - if (!Collections.disjoint(entry.getValue(), possibleHooks)) { - HashSet newHooks = new HashSet<>(); - - for (int hookEntityId : possibleHooks) { - if (entry.getValue().contains(hookEntityId) && chain.distances.containsKey(hookEntityId)) { - EntityFishHook entity = hookEntities.get(hookEntityId); - - if (entity != null && !entity.isDead) { - double oldDistance = chain.distances.get(hookEntityId); - - double dX = entity.posX - x; - double dZ = entity.posZ - z; - double newDistance = Math.sqrt(dX * dX + dZ * dZ); - - double delta = oldDistance - newDistance; - - if (newDistance < 0.2 || (delta > -0.1 && delta < 0.3)) { - if ((NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning || NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) && - Minecraft.getMinecraft().thePlayer.fishEntity != null && - Minecraft.getMinecraft().thePlayer.fishEntity.getEntityId() == hookEntityId && - chain.particleNum > 3) { - float lavaOffset = 0.1f; - if (particleType == EnumParticleTypes.SMOKE_NORMAL) { - lavaOffset = 0.03f; - } else if (particleType == EnumParticleTypes.WATER_WAKE) { - lavaOffset = 0.1f; - } - if (newDistance <= 0.2f + lavaOffset * pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) { - if (NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSounds && - hookedWarningStateTicks <= 0) { - float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSoundsVol / 100f; - if (vol > 0) { - if (vol > 1) vol = 1; - final float volF = vol; - - ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{ - volume = volF; - pitch = 2f; - repeat = false; - repeatDelay = 0; - attenuationType = ISound.AttenuationType.NONE; - }}; - - float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS); - Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1); - Minecraft.getMinecraft().getSoundHandler().playSound(sound); - Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel); - } - } - - hookedWarningStateTicks = 12; - } else if (newDistance >= 0.4f + 0.1f * pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning) { - if (NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSounds && - buildupSoundDelay <= 0) { - float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSoundsVol / 100f; - if (vol > 0) { - if (vol > 1) vol = 1; - final float volF = vol; - - ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{ - volume = volF; - pitch = calculatePitchFromDistance((float) newDistance - (0.3f + 0.1f * pingDelayTicks)); - repeat = false; - repeatDelay = 0; - attenuationType = ISound.AttenuationType.NONE; - }}; - - float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS); - Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1); - Minecraft.getMinecraft().getSoundHandler().playSound(sound); - Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel); - buildupSoundDelay = 4; - } - } - } - } - - chain.distances.put(hookEntityId, newDistance); - newHooks.add(hookEntityId); - } - } - - } - } - if (newHooks.isEmpty()) { - continue; - } - - entry.getValue().retainAll(newHooks); - chain.distances.keySet().retainAll(newHooks); - - for (int i : entry.getValue()) { - EntityFishHook hook = hookEntities.get(i); - if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) { - isMainPlayer = true; - break; - } - } - - chain.lastUpdate = currentTime; - chain.particleNum++; - chain.currentAngle = updateAngle; - - foundChain = true; - } - } - - if (!foundChain) { - possibleHooks1.removeAll(possibleHooks2); - if (!possibleHooks1.isEmpty()) { - for (int i : possibleHooks1) { - EntityFishHook hook = hookEntities.get(i); - if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) { - isMainPlayer = true; - break; - } - } - - WakeChain chain = new WakeChain(currentTime, angle1, x, z); - for (int hookEntityId : possibleHooks1) { - EntityFishHook entity = hookEntities.get(hookEntityId); - - if (entity != null && !entity.isDead) { - double dX = entity.posX - x; - double dZ = entity.posZ - z; - double newDistance = Math.sqrt(dX * dX + dZ * dZ); - chain.distances.put(hookEntityId, newDistance); - } - } - chains.put(chain, possibleHooks1); - } else if (!possibleHooks2.isEmpty()) { - for (int i : possibleHooks2) { - EntityFishHook hook = hookEntities.get(i); - if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) { - isMainPlayer = true; - break; - } - } - - WakeChain chain = new WakeChain(currentTime, angle2, x, z); - for (int hookEntityId : possibleHooks2) { - EntityFishHook entity = hookEntities.get(hookEntityId); - - if (entity != null && !entity.isDead) { - double dX = entity.posX - x; - double dZ = entity.posZ - z; - double newDistance = Math.sqrt(dX * dX + dZ * dZ); - chain.distances.put(hookEntityId, newDistance); - } - } - chains.put(chain, possibleHooks2); - } - } - - int particleTypeI; - String particleCustomColour; - if (isMainPlayer) { - particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleType; - particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleColour; - } else if (NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll) { - return true; - } else { - particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.otherParticleType; - particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.otherParticleColour; - } - - if (!NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles) { -