From ed36390f3cfa53bc2bcfa5e113b3f7c6796b1c06 Mon Sep 17 00:00:00 2001 From: Skat <55407440+skykatik@users.noreply.github.com> Date: Sat, 7 Nov 2020 11:37:46 +0300 Subject: [PATCH 1/3] Great cleanup --- core/src/mindustry/ai/Pathfinder.java | 3 +- .../mindustry/ai/formations/Formation.java | 3 - .../FreeSlotAssignmentStrategy.java | 3 +- .../SoftRoleSlotAssignmentStrategy.java | 2 - core/src/mindustry/ai/types/BuilderAI.java | 4 +- core/src/mindustry/ai/types/MinerAI.java | 1 - core/src/mindustry/ai/types/RepairAI.java | 3 +- core/src/mindustry/ai/types/SuicideAI.java | 3 +- core/src/mindustry/content/Fx.java | 87 +++++++------------ core/src/mindustry/core/ContentLoader.java | 4 +- core/src/mindustry/core/Control.java | 9 +- core/src/mindustry/core/Logic.java | 1 - core/src/mindustry/core/NetClient.java | 12 +-- core/src/mindustry/core/NetServer.java | 40 ++++----- core/src/mindustry/core/Renderer.java | 3 +- core/src/mindustry/core/UI.java | 2 +- core/src/mindustry/core/World.java | 1 - .../mindustry/editor/MapGenerateDialog.java | 2 +- core/src/mindustry/entities/Damage.java | 3 +- .../mindustry/entities/EntityCollisions.java | 3 - core/src/mindustry/entities/EntityGroup.java | 3 +- .../abilities/StatusFieldAbility.java | 1 - .../entities/abilities/UnitSpawnAbility.java | 1 - .../mindustry/entities/bullet/BulletType.java | 10 +-- .../entities/bullet/SapBulletType.java | 6 +- .../entities/units/AIController.java | 1 - core/src/mindustry/game/Saves.java | 7 +- core/src/mindustry/game/Teams.java | 8 +- core/src/mindustry/graphics/MenuRenderer.java | 2 +- .../mindustry/graphics/g3d/PlanetGrid.java | 18 ++-- .../graphics/g3d/PlanetRenderer.java | 10 +-- core/src/mindustry/input/DesktopInput.java | 2 - core/src/mindustry/input/InputHandler.java | 8 +- core/src/mindustry/input/MobileInput.java | 1 - core/src/mindustry/input/Placement.java | 1 - core/src/mindustry/io/legacy/LegacyIO.java | 4 +- .../io/legacy/LegacySaveVersion.java | 1 - core/src/mindustry/logic/LCanvas.java | 2 +- core/src/mindustry/logic/LExecutor.java | 25 +++--- core/src/mindustry/logic/LogicOp.java | 4 +- core/src/mindustry/maps/SectorDamage.java | 2 +- core/src/mindustry/mod/Mods.java | 2 +- core/src/mindustry/net/Administration.java | 7 +- core/src/mindustry/net/Net.java | 6 +- core/src/mindustry/type/Item.java | 2 +- 45 files changed, 134 insertions(+), 189 deletions(-) diff --git a/core/src/mindustry/ai/Pathfinder.java b/core/src/mindustry/ai/Pathfinder.java index b7b0cfc907..d36cb32291 100644 --- a/core/src/mindustry/ai/Pathfinder.java +++ b/core/src/mindustry/ai/Pathfinder.java @@ -445,13 +445,12 @@ public class Pathfinder implements Runnable{ public void getPositions(IntSeq out){ out.add(Point2.pack(World.toTile(position.getX()), World.toTile(position.getY()))); } - } /** * Data for a flow field to some set of destinations. * Concrete subclasses must specify a way to fetch costs and destinations. - * */ + */ public static abstract class Flowfield{ /** Refresh rate in milliseconds. Return any number <= 0 to disable. */ protected int refreshRate; diff --git a/core/src/mindustry/ai/formations/Formation.java b/core/src/mindustry/ai/formations/Formation.java index 16db811b2f..db2ce02e14 100644 --- a/core/src/mindustry/ai/formations/Formation.java +++ b/core/src/mindustry/ai/formations/Formation.java @@ -17,10 +17,8 @@ import arc.struct.*; * @author davebaol */ public class Formation{ - /** A list of slots assignments. */ public Seq slotAssignments; - /** The anchor point of this formation. */ public Vec3 anchor; /** The formation pattern */ @@ -138,7 +136,6 @@ public class Formation{ * @return {@code false} if no more slots are available; {@code true} otherwise. */ public boolean addMember(FormationMember member){ - // Check if the pattern supports one more slot if(pattern.supportsSlots(slotAssignments.size + 1)){ // Add a new slot assignment diff --git a/core/src/mindustry/ai/formations/FreeSlotAssignmentStrategy.java b/core/src/mindustry/ai/formations/FreeSlotAssignmentStrategy.java index 35fd74f789..89e51054d2 100644 --- a/core/src/mindustry/ai/formations/FreeSlotAssignmentStrategy.java +++ b/core/src/mindustry/ai/formations/FreeSlotAssignmentStrategy.java @@ -16,8 +16,9 @@ public class FreeSlotAssignmentStrategy implements SlotAssignmentStrategy{ public void updateSlotAssignments(Seq assignments){ // A very simple assignment algorithm: we simply go through // each assignment in the list and assign sequential slot numbers - for(int i = 0; i < assignments.size; i++) + for(int i = 0; i < assignments.size; i++){ assignments.get(i).slotNumber = i; + } } @Override diff --git a/core/src/mindustry/ai/formations/SoftRoleSlotAssignmentStrategy.java b/core/src/mindustry/ai/formations/SoftRoleSlotAssignmentStrategy.java index f3f3c09bed..59c933c205 100644 --- a/core/src/mindustry/ai/formations/SoftRoleSlotAssignmentStrategy.java +++ b/core/src/mindustry/ai/formations/SoftRoleSlotAssignmentStrategy.java @@ -51,7 +51,6 @@ public class SoftRoleSlotAssignmentStrategy extends BoundedSlotAssignmentStrateg @Override public void updateSlotAssignments(Seq assignments){ - // Holds a list of member and slot data for each member. Seq memberData = new Seq<>(); @@ -125,7 +124,6 @@ public class SoftRoleSlotAssignmentStrategy extends BoundedSlotAssignmentStrateg // Some sensible action should be taken, such as reporting to the player. throw new ArcRuntimeException("SoftRoleSlotAssignmentStrategy cannot find valid slot assignment for member " + memberDatum.member); } - } static class CostAndSlot implements Comparable{ diff --git a/core/src/mindustry/ai/types/BuilderAI.java b/core/src/mindustry/ai/types/BuilderAI.java index c3558ca58a..e7d4fdc469 100644 --- a/core/src/mindustry/ai/types/BuilderAI.java +++ b/core/src/mindustry/ai/types/BuilderAI.java @@ -71,7 +71,7 @@ public class BuilderAI extends AIController{ Units.nearby(unit.team, unit.x, unit.y, buildRadius, u -> { if(found) return; - if(u instanceof Builderc b && u != unit && ((Builderc)u).activelyBuilding()){ + if(u instanceof Builderc b && u != unit && b.activelyBuilding()){ BuildPlan plan = b.buildPlan(); Building build = world.build(plan.x, plan.y); @@ -119,7 +119,7 @@ public class BuilderAI extends AIController{ public boolean useFallback(){ return state.rules.waves && unit.team == state.rules.waveTeam && !unit.team.rules().ai; } - + @Override public boolean shouldShoot(){ return !((Builderc)unit).isBuilding(); diff --git a/core/src/mindustry/ai/types/MinerAI.java b/core/src/mindustry/ai/types/MinerAI.java index 1bb808d377..ae18e8085b 100644 --- a/core/src/mindustry/ai/types/MinerAI.java +++ b/core/src/mindustry/ai/types/MinerAI.java @@ -79,5 +79,4 @@ public class MinerAI extends AIController{ @Override protected void updateTargeting(){ } - } diff --git a/core/src/mindustry/ai/types/RepairAI.java b/core/src/mindustry/ai/types/RepairAI.java index 36504f908d..eb066e212c 100644 --- a/core/src/mindustry/ai/types/RepairAI.java +++ b/core/src/mindustry/ai/types/RepairAI.java @@ -36,12 +36,11 @@ public class RepairAI extends AIController{ Building target = Units.findDamagedTile(unit.team, unit.x, unit.y); if(target instanceof ConstructBuild) target = null; - + if(target == null){ super.updateTargeting(); }else{ this.target = target; } } - } diff --git a/core/src/mindustry/ai/types/SuicideAI.java b/core/src/mindustry/ai/types/SuicideAI.java index 0ef3ece228..c006d3ac2f 100644 --- a/core/src/mindustry/ai/types/SuicideAI.java +++ b/core/src/mindustry/ai/types/SuicideAI.java @@ -31,7 +31,7 @@ public class SuicideAI extends GroundAI{ if(!Units.invalidateTarget(target, unit, unit.range()) && unit.hasWeapons()){ rotate = true; shoot = unit.within(target, unit.type.weapons.first().bullet.range() + - (target instanceof Building ? ((Building)target).block.size * Vars.tilesize / 2f : ((Hitboxc)target).hitSize() / 2f)); + (target instanceof Building b ? b.block.size * Vars.tilesize / 2f : ((Hitboxc)target).hitSize() / 2f)); if(unit.type.hasWeapons()){ unit.aimLook(Predict.intercept(unit, target, unit.type.weapons.first().bullet.speed)); @@ -68,7 +68,6 @@ public class SuicideAI extends GroundAI{ unit.moveAt(vec.set(target).sub(unit).limit(unit.type.speed)); } } - } if(!moveToTarget){ diff --git a/core/src/mindustry/content/Fx.java b/core/src/mindustry/content/Fx.java index 1ccabafe6d..ef2973f19e 100644 --- a/core/src/mindustry/content/Fx.java +++ b/core/src/mindustry/content/Fx.java @@ -389,7 +389,6 @@ public class Fx{ float ang = Mathf.angle(x, y); lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f); }); - }), hitBulletBig = new Effect(13, e -> { @@ -400,7 +399,6 @@ public class Fx{ float ang = Mathf.angle(x, y); lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1.5f); }); - }), hitFlameSmall = new Effect(14, e -> { @@ -411,7 +409,6 @@ public class Fx{ float ang = Mathf.angle(x, y); lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f); }); - }), hitLiquid = new Effect(16, e -> { @@ -420,7 +417,6 @@ public class Fx{ randLenVectors(e.id, 5, e.fin() * 15f, e.rotation, 60f, (x, y) -> { Fill.circle(e.x + x, e.y + y, e.fout() * 2f); }); - }), hitLancer = new Effect(12, e -> { @@ -431,7 +427,6 @@ public class Fx{ float ang = Mathf.angle(x, y); lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f); }); - }), hitMeltdown = new Effect(12, e -> { @@ -442,7 +437,6 @@ public class Fx{ float ang = Mathf.angle(x, y); lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f); }); - }), hitMeltHeal = new Effect(12, e -> { @@ -453,7 +447,6 @@ public class Fx{ float ang = Mathf.angle(x, y); lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f); }); - }), instBomb = new Effect(15f, 100f, e -> { @@ -553,8 +546,8 @@ public class Fx{ }), flakExplosion = new Effect(20, e -> { - color(Pal.bulletYellow); + e.scaled(6, i -> { stroke(3f * i.fout()); Lines.circle(e.x, e.y, 3f + i.fin() * 10f); @@ -572,12 +565,11 @@ public class Fx{ randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - }), plasticExplosion = new Effect(24, e -> { - color(Pal.plastaniumFront); + e.scaled(7, i -> { stroke(3f * i.fout()); Lines.circle(e.x, e.y, 3f + i.fin() * 24f); @@ -595,12 +587,11 @@ public class Fx{ randLenVectors(e.id + 1, 4, 1f + 25f * e.finpow(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - }), plasticExplosionFlak = new Effect(28, e -> { - color(Pal.plastaniumFront); + e.scaled(7, i -> { stroke(3f * i.fout()); Lines.circle(e.x, e.y, 3f + i.fin() * 34f); @@ -618,12 +609,11 @@ public class Fx{ randLenVectors(e.id + 1, 4, 1f + 30f * e.finpow(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - }), blastExplosion = new Effect(22, e -> { - color(Pal.missileYellow); + e.scaled(6, i -> { stroke(3f * i.fout()); Lines.circle(e.x, e.y, 3f + i.fin() * 15f); @@ -641,12 +631,11 @@ public class Fx{ randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - }), sapExplosion = new Effect(25, e -> { - color(Pal.sapBullet); + e.scaled(6, i -> { stroke(3f * i.fout()); Lines.circle(e.x, e.y, 3f + i.fin() * 80f); @@ -664,12 +653,11 @@ public class Fx{ randLenVectors(e.id + 1, 8, 1f + 60f * e.finpow(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - }), massiveExplosion = new Effect(30, e -> { - color(Pal.missileYellow); + e.scaled(7, i -> { stroke(3f * i.fout()); Lines.circle(e.x, e.y, 4f + i.fin() * 30f); @@ -687,7 +675,6 @@ public class Fx{ randLenVectors(e.id + 1, 6, 1f + 29f * e.finpow(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 4f); }); - }), artilleryTrail = new Effect(50, e -> { @@ -712,8 +699,8 @@ public class Fx{ }), flakExplosionBig = new Effect(30, e -> { - color(Pal.bulletYellowBack); + e.scaled(6, i -> { stroke(3f * i.fout()); Lines.circle(e.x, e.y, 3f + i.fin() * 25f); @@ -731,7 +718,6 @@ public class Fx{ randLenVectors(e.id + 1, 4, 1f + 23f * e.finpow(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - }), burning = new Effect(35f, e -> { @@ -740,7 +726,6 @@ public class Fx{ randLenVectors(e.id, 3, 2f + e.fin() * 7f, (x, y) -> { Fill.circle(e.x + x, e.y + y, 0.1f + e.fout() * 1.4f); }); - }), fire = new Effect(50f, e -> { @@ -761,7 +746,6 @@ public class Fx{ randLenVectors(e.id, 1, 2f + e.fin() * 7f, (x, y) -> { Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); }); - }), steam = new Effect(35f, e -> { @@ -770,7 +754,6 @@ public class Fx{ randLenVectors(e.id, 2, 2f + e.fin() * 7f, (x, y) -> { Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f); }); - }), fireballsmoke = new Effect(25f, e -> { @@ -779,7 +762,6 @@ public class Fx{ randLenVectors(e.id, 1, 2f + e.fin() * 7f, (x, y) -> { Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f); }); - }), ballfire = new Effect(25f, e -> { @@ -788,7 +770,6 @@ public class Fx{ randLenVectors(e.id, 2, 2f + e.fin() * 7f, (x, y) -> { Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f); }); - }), freezing = new Effect(40f, e -> { @@ -797,7 +778,6 @@ public class Fx{ randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { Fill.circle(e.x + x, e.y + y, e.fout() * 1.2f); }); - }), melting = new Effect(40f, e -> { @@ -806,7 +786,6 @@ public class Fx{ randLenVectors(e.id, 2, 1f + e.fin() * 3f, (x, y) -> { Fill.circle(e.x + x, e.y + y, .2f + e.fout() * 1.2f); }); - }), wet = new Effect(80f, e -> { @@ -815,7 +794,7 @@ public class Fx{ Fill.circle(e.x, e.y, e.fout() * 1f); }), - + muddy = new Effect(80f, e -> { color(Color.valueOf("432722")); alpha(Mathf.clamp(e.fin() * 2f)); @@ -829,7 +808,6 @@ public class Fx{ randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { Fill.square(e.x + x, e.y + y, e.fslope() * 1.1f, 45f); }); - }), sporeSlowed = new Effect(40f, e -> { @@ -844,7 +822,6 @@ public class Fx{ randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { Fill.circle(e.x + x, e.y + y, e.fout() * 1f); }); - }), overdriven = new Effect(20f, e -> { @@ -853,7 +830,6 @@ public class Fx{ randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { Fill.square(e.x + x, e.y + y, e.fout() * 2.3f + 0.5f); }); - }), overclocked = new Effect(50f, e -> { @@ -962,7 +938,6 @@ public class Fx{ randLenVectors(e.id + 1, 9, 1f + 23f * e.finpow(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f); }); - }), blockExplosionSmoke = new Effect(30, e -> { @@ -972,7 +947,6 @@ public class Fx{ Fill.circle(e.x + x, e.y + y, e.fout() * 3f); Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f); }); - }), shootSmall = new Effect(8, e -> { @@ -1002,7 +976,6 @@ public class Fx{ randLenVectors(e.id, 5, e.finpow() * 6f, e.rotation, 20f, (x, y) -> { Fill.circle(e.x + x, e.y + y, e.fout() * 1.5f); }); - }), shootBig = new Effect(9, e -> { @@ -1025,7 +998,6 @@ public class Fx{ randLenVectors(e.id, 8, e.finpow() * 19f, e.rotation, 10f, (x, y) -> { Fill.circle(e.x + x, e.y + y, e.fout() * 2f + 0.2f); }); - }), shootBigSmoke2 = new Effect(18f, e -> { @@ -1034,7 +1006,6 @@ public class Fx{ randLenVectors(e.id, 9, e.finpow() * 23f, e.rotation, 20f, (x, y) -> { Fill.circle(e.x + x, e.y + y, e.fout() * 2.4f + 0.2f); }); - }), shootSmallFlame = new Effect(32f, 80f, e -> { @@ -1043,7 +1014,6 @@ public class Fx{ randLenVectors(e.id, 8, e.finpow() * 60f, e.rotation, 10f, (x, y) -> { Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.5f); }); - }), shootPyraFlame = new Effect(33f, 80f, e -> { @@ -1052,7 +1022,6 @@ public class Fx{ randLenVectors(e.id, 10, e.finpow() * 70f, e.rotation, 10f, (x, y) -> { Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.6f); }); - }), shootLiquid = new Effect(40f, 80f, e -> { @@ -1061,7 +1030,6 @@ public class Fx{ randLenVectors(e.id, 6, e.finpow() * 60f, e.rotation, 11f, (x, y) -> { Fill.circle(e.x + x, e.y + y, 0.5f + e.fout() * 2.5f); }); - }), casing1 = new Effect(30f, e -> { @@ -1197,7 +1165,6 @@ public class Fx{ for(int i : Mathf.signs){ Drawf.tri(e.x, e.y, 4f * e.fout(), 29f, e.rotation + 90f * i); } - }), lancerLaserShootSmoke = new Effect(26f, e -> { @@ -1207,7 +1174,6 @@ public class Fx{ randLenVectors(e.id, 7, length, e.rotation, 0f, (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fout() * 9f); }); - }), lancerLaserCharge = new Effect(38f, e -> { @@ -1216,7 +1182,6 @@ public class Fx{ randLenVectors(e.id, 2, 1f + 20f * e.fout(), e.rotation, 120f, (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fslope() * 3f + 1f); }); - }), lancerLaserChargeBegin = new Effect(60f, e -> { @@ -1233,7 +1198,6 @@ public class Fx{ randLenVectors(e.id, 2, 1f + 20f * e.fout(), e.rotation, 120f, (x, y) -> { Drawf.tri(e.x + x, e.y + y, e.fslope() * 3f + 1, e.fslope() * 3f + 1, Mathf.angle(x, y)); }); - }), sparkShoot = new Effect(12f, e -> { @@ -1243,7 +1207,6 @@ public class Fx{ randLenVectors(e.id, 7, 25f * e.finpow(), e.rotation, 3f, (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fslope() * 5f + 0.5f); }); - }), lightningShoot = new Effect(12f, e -> { @@ -1372,21 +1335,21 @@ public class Fx{ Fill.square(e.x + x, e.y + y, e.fout() * 2.5f + 0.5f, 45); }); }), - + pulverizeSmall = new Effect(30, e -> { randLenVectors(e.id, 3, e.fin() * 5f, (x, y) -> { color(Pal.stoneGray); Fill.square(e.x + x, e.y + y, e.fout() * 1f + 0.5f, 45); }); }), - + pulverizeMedium = new Effect(30, e -> { randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> { color(Pal.stoneGray); Fill.square(e.x + x, e.y + y, e.fout() * 1f + 0.5f, 45); }); }), - + producesmoke = new Effect(12, e -> { randLenVectors(e.id, 8, 4f + e.fin() * 18f, (x, y) -> { color(Color.white, Pal.accent, e.fin()); @@ -1401,21 +1364,21 @@ public class Fx{ Fill.circle(e.x + x, e.y + y, 0.5f + fout * 4f); }); }), - + smeltsmoke = new Effect(15, e -> { randLenVectors(e.id, 6, 4f + e.fin() * 5f, (x, y) -> { color(Color.white, e.color, e.fin()); Fill.square(e.x + x, e.y + y, 0.5f + e.fout() * 2f, 45); }); }), - + formsmoke = new Effect(40, e -> { randLenVectors(e.id, 6, 5f + e.fin() * 8f, (x, y) -> { color(Pal.plasticSmoke, Color.lightGray, e.fin()); Fill.square(e.x + x, e.y + y, 0.2f + e.fout() * 2f, 45); }); }), - + blastsmoke = new Effect(26, e -> { randLenVectors(e.id, 12, 1f + e.fin() * 23f, (x, y) -> { float size = 2f + e.fout() * 6f; @@ -1423,7 +1386,7 @@ public class Fx{ Fill.circle(e.x + x, e.y + y, size/2f); }); }), - + lava = new Effect(18, e -> { randLenVectors(e.id, 3, 1f + e.fin() * 10f, (x, y) -> { float size = e.fslope() * 4f; @@ -1431,50 +1394,58 @@ public class Fx{ Fill.circle(e.x + x, e.y + y, size/2f); }); }), - + dooropen = new Effect(10, e -> { stroke(e.fout() * 1.6f); Lines.square(e.x, e.y, tilesize / 2f + e.fin() * 2f); }), - + doorclose = new Effect(10, e -> { stroke(e.fout() * 1.6f); Lines.square(e.x, e.y, tilesize / 2f + e.fout() * 2f); }), + dooropenlarge = new Effect(10, e -> { stroke(e.fout() * 1.6f); Lines.square(e.x, e.y, tilesize + e.fin() * 2f); }), + doorcloselarge = new Effect(10, e -> { stroke(e.fout() * 1.6f); Lines.square(e.x, e.y, tilesize + e.fout() * 2f); }), + purify = new Effect(10, e -> { color(Color.royal, Color.gray, e.fin()); stroke(2f); Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); }), + purifyoil = new Effect(10, e -> { color(Color.black, Color.gray, e.fin()); stroke(2f); Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); }), + purifystone = new Effect(10, e -> { color(Color.orange, Color.gray, e.fin()); stroke(2f); Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6); }), + generate = new Effect(11, e -> { color(Color.orange, Color.yellow, e.fin()); stroke(1f); Lines.spikes(e.x, e.y, e.fin() * 5f, 2, 8); }), + mine = new Effect(20, e -> { randLenVectors(e.id, 6, 3f + e.fin() * 6f, (x, y) -> { color(e.color, Color.lightGray, e.fin()); Fill.square(e.x + x, e.y + y, e.fout() * 2f, 45); }); }), + mineBig = new Effect(30, e -> { randLenVectors(e.id, 6, 4f + e.fin() * 8f, (x, y) -> { color(e.color, Color.lightGray, e.fin()); @@ -1488,12 +1459,14 @@ public class Fx{ Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.5f, 45); }); }), + smelt = new Effect(20, e -> { randLenVectors(e.id, 6, 2f + e.fin() * 5f, (x, y) -> { color(Color.white, e.color, e.fin()); Fill.square(e.x + x, e.y + y, 0.5f + e.fout() * 2f, 45); }); }), + teleportActivate = new Effect(50, e -> { color(e.color); @@ -1507,8 +1480,8 @@ public class Fx{ randLenVectors(e.id, 30, 4f + 40f * e.fin(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 4f + 1f); }); - }), + teleport = new Effect(60, e -> { color(e.color); stroke(e.fin() * 2f); @@ -1517,8 +1490,8 @@ public class Fx{ randLenVectors(e.id, 20, 6f + 20f * e.fout(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 4f + 1f); }); - }), + teleportOut = new Effect(20, e -> { color(e.color); stroke(e.fout() * 2f); @@ -1527,7 +1500,6 @@ public class Fx{ randLenVectors(e.id, 20, 4f + 20f * e.fin(), (x, y) -> { lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fslope() * 4f + 1f); }); - }), ripple = new Effect(30, e -> { @@ -1611,7 +1583,6 @@ public class Fx{ float radius = unit.hitSize() * 1.3f; - e.scaled(16f, c -> { color(Pal.shield); stroke(c.fout() * 2f + 0.1f); diff --git a/core/src/mindustry/core/ContentLoader.java b/core/src/mindustry/core/ContentLoader.java index 975bc4d1f8..b7c0fbd0e0 100644 --- a/core/src/mindustry/core/ContentLoader.java +++ b/core/src/mindustry/core/ContentLoader.java @@ -160,8 +160,8 @@ public class ContentLoader{ public void removeLast(){ if(lastAdded != null && contentMap[lastAdded.getContentType().ordinal()].peek() == lastAdded){ contentMap[lastAdded.getContentType().ordinal()].pop(); - if(lastAdded instanceof MappableContent){ - contentNameMap[lastAdded.getContentType().ordinal()].remove(((MappableContent)lastAdded).name); + if(lastAdded instanceof MappableContent c){ + contentNameMap[lastAdded.getContentType().ordinal()].remove(c.name); } } } diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index acadd51df7..4a3d1fc675 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -12,6 +12,7 @@ import arc.util.*; import mindustry.audio.*; import mindustry.content.*; import mindustry.core.GameState.*; +import mindustry.ctype.*; import mindustry.entities.*; import mindustry.game.EventType.*; import mindustry.game.*; @@ -185,7 +186,7 @@ public class Control implements ApplicationListener, Loadable{ if(state.isCampaign()){ ui.announce("[accent]" + state.rules.sector.name() + "\n" + (state.rules.sector.info.resources.any() ? "[lightgray]" + bundle.get("sectors.resources") + "[white] " + - state.rules.sector.info.resources.toString(" ", u -> u.emoji()) : ""), 5); + state.rules.sector.info.resources.toString(" ", UnlockableContent::emoji) : ""), 5); } }); }); @@ -290,7 +291,7 @@ public class Control implements ApplicationListener, Loadable{ //reset win wave?? state.rules.winWave = state.rules.attackMode ? -1 : sector.preset != null ? sector.preset.captureWave : 40; - //kill all units, since they should be dead anwyay + //kill all units, since they should be dead anyway Groups.unit.clear(); Groups.fire.clear(); @@ -400,8 +401,8 @@ public class Control implements ApplicationListener, Loadable{ try{ SaveIO.save(control.saves.getCurrent().file); Log.info("Saved on exit."); - }catch(Throwable e){ - e.printStackTrace(); + }catch(Throwable t){ + Log.err(t); } } diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 55df925737..05c9da481b 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -326,5 +326,4 @@ public class Logic implements ApplicationListener{ public boolean isWaitingWave(){ return (state.rules.waitEnemies || (state.wave >= state.rules.winWave && state.rules.winWave > 0)) && state.enemies > 0; } - } diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index 2ca19de419..055b6c71b5 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -32,7 +32,7 @@ import static mindustry.Vars.*; public class NetClient implements ApplicationListener{ private static final float dataTimeout = 60 * 18; private static final float playerSyncTime = 2; - public final static float viewScale = 2f; + public static final float viewScale = 2f; private long ping; private Interval timer = new Interval(5); @@ -234,7 +234,7 @@ public class NetClient implements ApplicationListener{ ui.join.connect(ip, port); } - + @Remote(targets = Loc.client) public static void ping(Player player, long time){ Call.pingResponse(player.con, time); @@ -439,7 +439,7 @@ public class NetClient implements ApplicationListener{ tile.build.readAll(Reads.get(input), tile.build.version()); } }catch(Exception e){ - e.printStackTrace(); + Log.err(e); } } @@ -577,8 +577,8 @@ public class NetClient implements ApplicationListener{ //prevent buffer overflow by checking config length for(int i = 0; i < usedRequests; i++){ BuildPlan plan = player.builder().plans().get(i); - if(plan.config instanceof byte[]){ - int length = ((byte[])plan.config).length; + if(plan.config instanceof byte[] b){ + int length = b.length; totalLength += length; } @@ -604,7 +604,7 @@ public class NetClient implements ApplicationListener{ unit.x, unit.y, player.unit().aimX(), player.unit().aimY(), unit.rotation, - unit instanceof Mechc ? ((Mechc)unit).baseRotation() : 0, + unit instanceof Mechc m ? m.baseRotation() : 0, unit.vel.x, unit.vel.y, player.miner().mineTile(), player.boosting, player.shooting, ui.chatfrag.shown(), control.input.isBuilding, diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index 00f0bc78e8..5f26cebdb7 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -164,7 +164,7 @@ public class NetServer implements ApplicationListener{ info.id = packet.uuid; admins.save(); Call.infoMessage(con, "You are not whitelisted here."); - Log.info("&lcDo &lywhitelist-add @&lc to whitelist the player &lb'@'", packet.uuid, packet.name); + info("&lcDo &lywhitelist-add @&lc to whitelist the player &lb'@'", packet.uuid, packet.name); con.kick(KickReason.whitelist); return; } @@ -226,8 +226,8 @@ public class NetServer implements ApplicationListener{ writeBuffer.reset(); player.write(outputBuffer); }catch(Throwable t){ - t.printStackTrace(); con.kick(KickReason.nameEmpty); + err(t); return; } @@ -248,10 +248,10 @@ public class NetServer implements ApplicationListener{ try{ RemoteReadServer.readPacket(packet.reader(), packet.type, con.player); }catch(ValidateException e){ - Log.debug("Validation failed for '@': @", e.player, e.getMessage()); + debug("Validation failed for '@': @", e.player, e.getMessage()); }catch(RuntimeException e){ if(e.getCause() instanceof ValidateException v){ - Log.debug("Validation failed for '@': @", v.player, v.getMessage()); + debug("Validation failed for '@': @", v.player, v.getMessage()); }else{ throw e; } @@ -305,7 +305,7 @@ public class NetServer implements ApplicationListener{ player.sendMessage("[scarlet]You must be admin to use this command."); return; } - + Groups.player.each(Player::admin, a -> a.sendMessage(args[0], player, "[#" + Pal.adminChat.toString() + "]" + NetClient.colorizeName(player.id, player.name))); }); @@ -418,7 +418,7 @@ public class NetServer implements ApplicationListener{ VoteSession session = new VoteSession(currentlyKicking, found); session.vote(player, 1); - vtime.reset(); + vtime.reset(); currentlyKicking[0] = session; } }else{ @@ -493,7 +493,7 @@ public class NetServer implements ApplicationListener{ data.stream = new ByteArrayInputStream(stream.toByteArray()); player.con.sendStream(data); - Log.debug("Packed @ bytes of world data.", stream.size()); + debug("Packed @ bytes of world data.", stream.size()); } public void addPacketHandler(String type, Cons2 handler){ @@ -505,7 +505,7 @@ public class NetServer implements ApplicationListener{ } public static void onDisconnect(Player player, String reason){ - //singleplayer multiplayer wierdness + //singleplayer multiplayer weirdness if(player.con == null){ player.remove(); return; @@ -519,7 +519,7 @@ public class NetServer implements ApplicationListener{ } String message = Strings.format("&lb@&fi&lk has disconnected. &fi&lk[&lb@&fi&lk] (@)", player.name, player.uuid(), reason); - if(Config.showConnectMessages.bool()) Log.info(message); + if(Config.showConnectMessages.bool()) info(message); } player.remove(); @@ -539,7 +539,7 @@ public class NetServer implements ApplicationListener{ public static void serverPacketUnreliable(Player player, String type, String contents){ serverPacketReliable(player, type, contents); } - + private static boolean invalid(float f){ return Float.isInfinite(f) || Float.isNaN(f); } @@ -702,15 +702,14 @@ public class NetServer implements ApplicationListener{ @Remote(targets = Loc.client, called = Loc.server) public static void adminRequest(Player player, Player other, AdminAction action){ - if(!player.admin){ - Log.warn("ACCESS DENIED: Player @ / @ attempted to perform admin action '@' on '@' without proper security access.", + warn("ACCESS DENIED: Player @ / @ attempted to perform admin action '@' on '@' without proper security access.", player.name, player.con.address, action.name(), other == null ? null : other.name); return; } if(other == null || ((other.admin && !player.isLocal()) && other != player)){ - Log.warn("@ attempted to perform admin action on nonexistant or admin player.", player.name); + warn("@ attempted to perform admin action on nonexistant or admin player.", player.name); return; } @@ -722,10 +721,10 @@ public class NetServer implements ApplicationListener{ netServer.admins.banPlayerIP(other.con.address); netServer.admins.banPlayerID(other.con.uuid); other.kick(KickReason.banned); - Log.info("&lc@ has banned @.", player.name, other.name); + info("&lc@ has banned @.", player.name, other.name); }else if(action == AdminAction.kick){ other.kick(KickReason.kick); - Log.info("&lc@ has kicked @.", player.name, other.name); + info("&lc@ has kicked @.", player.name, other.name); }else if(action == AdminAction.trace){ TraceInfo info = new TraceInfo(other.con.address, other.uuid(), other.con.modclient, other.con.mobile); if(player.con != null){ @@ -733,7 +732,7 @@ public class NetServer implements ApplicationListener{ }else{ NetClient.traceInfo(other, info); } - Log.info("&lc@ has requested trace info of @.", player.name, other.name); + info("&lc@ has requested trace info of @.", player.name, other.name); } } @@ -748,7 +747,7 @@ public class NetServer implements ApplicationListener{ if(Config.showConnectMessages.bool()){ Call.sendMessage("[accent]" + player.name + "[accent] has connected."); String message = Strings.format("&lb@&fi&lk has connected. &fi&lk[&lb@&fi&lk]", player.name, player.uuid()); - Log.info(message); + info(message); } if(!Config.motd.string().equalsIgnoreCase("off")){ @@ -773,7 +772,6 @@ public class NetServer implements ApplicationListener{ @Override public void update(){ - if(!headless && !closing && net.server() && state.isMenu()){ closing = true; ui.loadfrag.show("@server.closing"); @@ -799,7 +797,7 @@ public class NetServer implements ApplicationListener{ net.host(Config.port.num()); info("Opened a server on port @.", Config.port.num()); }catch(BindException e){ - Log.err("Unable to host: Port already in use! Make sure no other servers are running on the same port in your network."); + err("Unable to host: Port already in use! Make sure no other servers are running on the same port in your network."); state.set(State.menu); }catch(IOException e){ err(e); @@ -915,7 +913,6 @@ public class NetServer implements ApplicationListener{ } String checkColor(String str){ - for(int i = 1; i < str.length(); i++){ if(str.charAt(i) == ']'){ String color = str.substring(1, i); @@ -941,7 +938,6 @@ public class NetServer implements ApplicationListener{ } void sync(){ - try{ Groups.player.each(p -> !p.isLocal(), player -> { if(player.con == null || !player.con.isConnected()){ @@ -965,7 +961,7 @@ public class NetServer implements ApplicationListener{ } }catch(IOException e){ - e.printStackTrace(); + Log.err(e); } } diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index 30a6c5db70..bdc9b77601 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -139,9 +139,9 @@ public class Renderer implements ApplicationListener{ } bloom = new Bloom(true); }catch(Throwable e){ - e.printStackTrace(); settings.put("bloom", false); ui.showErrorMessage("@error.bloom"); + Log.err(e); } } @@ -364,5 +364,4 @@ public class Renderer implements ApplicationListener{ buffer.dispose(); } - } diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index 2a8c1925f8..4ce01d4961 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -104,7 +104,7 @@ public class UI implements ApplicationListener, Loadable{ Tooltips.getInstance().textProvider = text -> new Tooltip(t -> t.background(Styles.black5).margin(4f).add(text)); Core.settings.setErrorHandler(e -> { - e.printStackTrace(); + Log.err(e); Core.app.post(() -> showErrorMessage("Failed to access local storage.\nSettings will not be saved.")); }); diff --git a/core/src/mindustry/core/World.java b/core/src/mindustry/core/World.java index b2607aa68e..c4819ed222 100644 --- a/core/src/mindustry/core/World.java +++ b/core/src/mindustry/core/World.java @@ -445,7 +445,6 @@ public class World{ int err = dx - dy; int e2; while(true){ - if(cons.accept(x0, y0)) return true; if(x0 == x1 && y0 == y1) return false; diff --git a/core/src/mindustry/editor/MapGenerateDialog.java b/core/src/mindustry/editor/MapGenerateDialog.java index 55576742c4..f6a87f77b1 100644 --- a/core/src/mindustry/editor/MapGenerateDialog.java +++ b/core/src/mindustry/editor/MapGenerateDialog.java @@ -404,7 +404,7 @@ public class MapGenerateDialog extends BaseDialog{ }); }catch(Exception e){ generating = false; - e.printStackTrace(); + Log.err(e); } world.setGenerating(false); }); diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index cd3777d063..631b6724f6 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -408,8 +408,7 @@ public class Damage{ } @Struct - static - class PropCellStruct{ + static class PropCellStruct{ byte x; byte y; short damage; diff --git a/core/src/mindustry/entities/EntityCollisions.java b/core/src/mindustry/entities/EntityCollisions.java index b4139991a4..3425314810 100644 --- a/core/src/mindustry/entities/EntityCollisions.java +++ b/core/src/mindustry/entities/EntityCollisions.java @@ -115,7 +115,6 @@ public class EntityCollisions{ @SuppressWarnings("unchecked") public void updatePhysics(EntityGroup group){ - QuadTree tree = group.tree(); tree.clear(); @@ -141,7 +140,6 @@ public class EntityCollisions{ } private void checkCollide(Hitboxc a, Hitboxc b){ - a.hitbox(this.r1); b.hitbox(this.r2); @@ -218,7 +216,6 @@ public class EntityCollisions{ @SuppressWarnings("unchecked") public void collide(EntityGroup groupa){ - groupa.each(solid -> { solid.hitbox(r1); r1.x += (solid.lastX() - solid.getX()); diff --git a/core/src/mindustry/entities/EntityGroup.java b/core/src/mindustry/entities/EntityGroup.java index 2135d9d6aa..50e97ccae4 100644 --- a/core/src/mindustry/entities/EntityGroup.java +++ b/core/src/mindustry/entities/EntityGroup.java @@ -183,8 +183,7 @@ public class EntityGroup implements Iterable{ array.each(Entityc::remove); array.clear(); - if(map != null) - map.clear(); + if(map != null) map.clear(); clearing = false; } diff --git a/core/src/mindustry/entities/abilities/StatusFieldAbility.java b/core/src/mindustry/entities/abilities/StatusFieldAbility.java index 857cfde5cf..a1bf47d408 100644 --- a/core/src/mindustry/entities/abilities/StatusFieldAbility.java +++ b/core/src/mindustry/entities/abilities/StatusFieldAbility.java @@ -28,7 +28,6 @@ public class StatusFieldAbility extends Ability{ timer += Time.delta; if(timer >= reload){ - Units.nearby(unit.team, unit.x, unit.y, range, other -> { other.apply(effect, duration); }); diff --git a/core/src/mindustry/entities/abilities/UnitSpawnAbility.java b/core/src/mindustry/entities/abilities/UnitSpawnAbility.java index 95eb3bcf5b..8aeba22a11 100644 --- a/core/src/mindustry/entities/abilities/UnitSpawnAbility.java +++ b/core/src/mindustry/entities/abilities/UnitSpawnAbility.java @@ -34,7 +34,6 @@ public class UnitSpawnAbility extends Ability{ timer += Time.delta; if(timer >= spawnTime && Units.canCreate(unit.team, type)){ - float x = unit.x + Angles.trnsx(unit.rotation, spawnY, spawnX), y = unit.y + Angles.trnsy(unit.rotation, spawnY, spawnX); spawnEffect.at(x, y); Unit u = type.create(unit.team); diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 3f7db0e3ee..720352a5a3 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -165,7 +165,7 @@ public abstract class BulletType extends Content{ if(makeFire && tile.team != b.team){ Fires.create(tile.tile); } - + if(healPercent > 0f && tile.team == b.team && !(tile.block instanceof ConstructBlock)){ Fx.healBlockFull.at(tile.x, tile.y, tile.block.size, Pal.heal); tile.heal(healPercent / 100f * tile.maxHealth()); @@ -213,9 +213,9 @@ public abstract class BulletType extends Content{ if(status != StatusEffects.none){ Damage.status(b.team, x, y, splashDamageRadius, status, statusDuration, collidesAir, collidesGround); } - + if(healPercent > 0f){ - indexer.eachBlock(b.team, x, y, splashDamageRadius, other -> other.damaged(), other -> { + indexer.eachBlock(b.team, x, y, splashDamageRadius, Building::damaged, other -> { Fx.healBlockFull.at(other.x, other.y, other.block.size, Pal.heal); other.heal(healPercent / 100f * other.maxHealth()); }); @@ -253,8 +253,8 @@ public abstract class BulletType extends Content{ public void init(Bullet b){ - if(killShooter && b.owner() instanceof Healthc){ - ((Healthc)b.owner()).kill(); + if(killShooter && b.owner() instanceof Healthc h){ + h.kill(); } if(instantDisappear){ diff --git a/core/src/mindustry/entities/bullet/SapBulletType.java b/core/src/mindustry/entities/bullet/SapBulletType.java index 5eb1d1e294..bbe48017fd 100644 --- a/core/src/mindustry/entities/bullet/SapBulletType.java +++ b/core/src/mindustry/entities/bullet/SapBulletType.java @@ -62,17 +62,15 @@ public class SapBulletType extends BulletType{ if(target != null){ float result = Math.min(target.health(), damage); - if(b.owner instanceof Healthc){ - ((Healthc)b.owner).heal(result * sapStrength); + if(b.owner instanceof Healthc h){ + h.heal(result * sapStrength); } } if(target instanceof Hitboxc hit){ - hit.collision(b, hit.x(), hit.y()); b.collision(hit, hit.x(), hit.y()); }else if(target instanceof Building tile){ - if(tile.collide(b)){ tile.collision(b); hit(b, tile.x, tile.y); diff --git a/core/src/mindustry/entities/units/AIController.java b/core/src/mindustry/entities/units/AIController.java index 5df9db4a60..27c1a9a942 100644 --- a/core/src/mindustry/entities/units/AIController.java +++ b/core/src/mindustry/entities/units/AIController.java @@ -61,7 +61,6 @@ public class AIController implements UnitController{ } protected void updateVisuals(){ - if(unit.isFlying()){ unit.wobble(); diff --git a/core/src/mindustry/game/Saves.java b/core/src/mindustry/game/Saves.java index fcebb28a8f..fb738b49b6 100644 --- a/core/src/mindustry/game/Saves.java +++ b/core/src/mindustry/game/Saves.java @@ -77,7 +77,6 @@ public class Saves{ } public void update(){ - if(current != null && state.isGame() && !(state.isPaused() && Core.scene.hasDialog())){ if(lastTimestamp != 0){ @@ -93,8 +92,8 @@ public class Saves{ try{ current.save(); - }catch(Throwable e){ - e.printStackTrace(); + }catch(Throwable t){ + Log.err(t); } Time.runTask(3f, () -> saving = false); @@ -218,7 +217,7 @@ public class Saves{ previewFile().writePNG(renderer.minimap.getPixmap()); requestedPreview = false; }catch(Throwable t){ - t.printStackTrace(); + Log.err(t); } }); } diff --git a/core/src/mindustry/game/Teams.java b/core/src/mindustry/game/Teams.java index f8968b95e7..da5edfd0db 100644 --- a/core/src/mindustry/game/Teams.java +++ b/core/src/mindustry/game/Teams.java @@ -133,10 +133,10 @@ public class Teams{ private void count(Unit unit){ unit.team.data().updateCount(unit.type, 1); - if(unit instanceof Payloadc){ - ((Payloadc)unit).payloads().each(p -> { - if(p instanceof UnitPayload){ - count(((UnitPayload)p).unit); + if(unit instanceof Payloadc payloadc){ + payloadc.payloads().each(p -> { + if(p instanceof UnitPayload payload){ + count(payload.unit); } }); } diff --git a/core/src/mindustry/graphics/MenuRenderer.java b/core/src/mindustry/graphics/MenuRenderer.java index 87ab169670..1be946cbd7 100644 --- a/core/src/mindustry/graphics/MenuRenderer.java +++ b/core/src/mindustry/graphics/MenuRenderer.java @@ -42,7 +42,7 @@ public class MenuRenderer implements Disposable{ private void generate(){ world.beginMapLoad(); Tiles tiles = world.resize(width, height); - Seq ores = content.blocks().select(b -> b instanceof OreBlock); + Seq ores = content.blocks().select(OreBlock.class::isInstance); shadows = new FrameBuffer(width, height); int offset = Mathf.random(100000); Simplex s1 = new Simplex(offset); diff --git a/core/src/mindustry/graphics/g3d/PlanetGrid.java b/core/src/mindustry/graphics/g3d/PlanetGrid.java index 380f937658..9b72970087 100644 --- a/core/src/mindustry/graphics/g3d/PlanetGrid.java +++ b/core/src/mindustry/graphics/g3d/PlanetGrid.java @@ -188,23 +188,23 @@ public class PlanetGrid{ } static int pos(Ptile t, Ptile n){ - for(int i = 0; i < t.edgeCount; i++) - if(t.tiles[i] == n) - return i; + for(int i = 0; i < t.edgeCount; i++){ + if(t.tiles[i] == n) return i; + } return -1; } static int pos(Ptile t, Corner c){ - for(int i = 0; i < t.edgeCount; i++) - if(t.corners[i] == c) - return i; + for(int i = 0; i < t.edgeCount; i++){ + if(t.corners[i] == c) return i; + } return -1; } static int pos(Corner c, Corner n){ - for(int i = 0; i < 3; i++) - if(c.corners[i] == n) - return i; + for(int i = 0; i < 3; i++){ + if(c.corners[i] == n) return i; + } return -1; } diff --git a/core/src/mindustry/graphics/g3d/PlanetRenderer.java b/core/src/mindustry/graphics/g3d/PlanetRenderer.java index 405d668333..156146f0b2 100644 --- a/core/src/mindustry/graphics/g3d/PlanetRenderer.java +++ b/core/src/mindustry/graphics/g3d/PlanetRenderer.java @@ -18,10 +18,10 @@ import mindustry.type.*; public class PlanetRenderer implements Disposable{ public static final float outlineRad = 1.17f, camLength = 4f; public static final Color - outlineColor = Pal.accent.cpy().a(1f), - hoverColor = Pal.accent.cpy().a(0.5f), - borderColor = Pal.accent.cpy().a(0.3f), - shadowColor = new Color(0, 0, 0, 0.7f); + outlineColor = Pal.accent.cpy().a(1f), + hoverColor = Pal.accent.cpy().a(0.5f), + borderColor = Pal.accent.cpy().a(0.3f), + shadowColor = new Color(0, 0, 0, 0.7f); private static final Seq points = new Seq<>(); @@ -119,7 +119,7 @@ public class PlanetRenderer implements Disposable{ public void renderPlanet(Planet planet){ if(!planet.visible()) return; - + //render planet at offsetted position in the world planet.draw(cam.combined, planet.getTransform(mat)); diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index b6a424f866..d9ebe4bb69 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -47,7 +47,6 @@ public class DesktopInput extends InputHandler{ @Override public void buildUI(Group group){ - group.fill(t -> { t.visible(() -> Core.settings.getBool("hints") && ui.hudfrag.shown && !player.dead() && !player.unit().spawnedByCore() && !(Core.settings.getBool("hints") && lastSchematic != null && !selectRequests.isEmpty())); t.bottom(); @@ -651,7 +650,6 @@ public class DesktopInput extends InputHandler{ //update payload input if(unit instanceof Payloadc){ - if(Core.input.keyTap(Binding.pickupCargo)){ tryPickupPayload(); } diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index f52f6bed59..4a4785b34a 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -128,7 +128,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ !netServer.admins.allowAction(player, ActionType.withdrawItem, tile.tile(), action -> { action.item = item; action.itemAmount = amount; - }))) throw new ValidateException(player, "Player cannot request items."); + }))){ + throw new ValidateException(player, "Player cannot request items."); + } //remove item for every controlling unit player.unit().eachGroup(unit -> { @@ -984,7 +986,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } public @Nullable Unit selectedUnit(){ - Unit unit = Units.closest(player.team(), Core.input.mouseWorld().x, Core.input.mouseWorld().y, 40f, u -> u.isAI()); + Unit unit = Units.closest(player.team(), Core.input.mouseWorld().x, Core.input.mouseWorld().y, 40f, Unitc::isAI); if(unit != null){ unit.hitbox(Tmp.r1); Tmp.r1.grow(6f); @@ -1160,7 +1162,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ if(block instanceof PowerNode){ Seq skip = new Seq<>(); - + for(int i = 1; i < points.size; i++){ int overlaps = 0; Point2 point = points.get(i); diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 87f0eaf851..668cf95afe 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -327,7 +327,6 @@ public class MobileInput extends InputHandler implements GestureListener{ @Override public void drawTop(){ - //draw schematic selection if(mode == schematicSelect){ drawSelection(lineStartX, lineStartY, lastLineX, lastLineY, Vars.maxSchematicSize); diff --git a/core/src/mindustry/input/Placement.java b/core/src/mindustry/input/Placement.java index d2c3eb7d41..1d713f7f75 100644 --- a/core/src/mindustry/input/Placement.java +++ b/core/src/mindustry/input/Placement.java @@ -188,7 +188,6 @@ public class Placement{ * @param maxLength maximum length of area */ public static NormalizeResult normalizeArea(int tilex, int tiley, int endx, int endy, int rotation, boolean snap, int maxLength){ - if(snap){ if(Math.abs(tilex - endx) > Math.abs(tiley - endy)){ endy = tiley; diff --git a/core/src/mindustry/io/legacy/LegacyIO.java b/core/src/mindustry/io/legacy/LegacyIO.java index 15cb756081..9ca0533855 100644 --- a/core/src/mindustry/io/legacy/LegacyIO.java +++ b/core/src/mindustry/io/legacy/LegacyIO.java @@ -2,6 +2,7 @@ package mindustry.io.legacy; import arc.*; import arc.struct.*; +import arc.util.*; import mindustry.*; import mindustry.ctype.*; import mindustry.ui.dialogs.JoinDialog.*; @@ -77,8 +78,7 @@ public class LegacyIO{ } } }catch(Exception e){ - e.printStackTrace(); + Log.err(e); } } - } diff --git a/core/src/mindustry/io/legacy/LegacySaveVersion.java b/core/src/mindustry/io/legacy/LegacySaveVersion.java index f533ebd27d..bb7d7eff11 100644 --- a/core/src/mindustry/io/legacy/LegacySaveVersion.java +++ b/core/src/mindustry/io/legacy/LegacySaveVersion.java @@ -26,7 +26,6 @@ public abstract class LegacySaveVersion extends SaveVersion{ if(!generating) context.begin(); try{ - context.resize(width, height); //read floor and create tiles first diff --git a/core/src/mindustry/logic/LCanvas.java b/core/src/mindustry/logic/LCanvas.java index 056c6f2ca5..6821ac0993 100644 --- a/core/src/mindustry/logic/LCanvas.java +++ b/core/src/mindustry/logic/LCanvas.java @@ -283,7 +283,7 @@ public class LCanvas extends Table{ t.add().growX(); t.button(Icon.copy, Styles.logici, () -> { - }).padRight(6).get().tapped(() -> copy()); + }).padRight(6).get().tapped(this::copy); t.button(Icon.cancel, Styles.logici, () -> { remove(); diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index e207ae99dc..c8bde0900d 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -32,15 +32,15 @@ public class LExecutor{ //special variables public static final int - varCounter = 0, - varTime = 1, - varUnit = 2, - varThis = 3; + varCounter = 0, + varTime = 1, + varUnit = 2, + varThis = 3; public static final int - maxGraphicsBuffer = 256, - maxDisplayBuffer = 1024, - maxTextBuffer = 256; + maxGraphicsBuffer = 256, + maxDisplayBuffer = 1024, + maxTextBuffer = 256; public LInstruction[] instructions = {}; public Var[] vars = {}; @@ -61,8 +61,9 @@ public class LExecutor{ vars[varTime].numval = Time.millis(); //reset to start - if(vars[varCounter].numval >= instructions.length - || vars[varCounter].numval < 0) vars[varCounter].numval = 0; + if(vars[varCounter].numval >= instructions.length || vars[varCounter].numval < 0){ + vars[varCounter].numval = 0; + } if(vars[varCounter].numval < instructions.length){ instructions[(int)(vars[varCounter].numval++)].run(this); @@ -84,9 +85,9 @@ public class LExecutor{ dest.constant = var.constant; - if(var.value instanceof Number){ + if(var.value instanceof Number number){ dest.isobj = false; - dest.numval = ((Number)var.value).doubleValue(); + dest.numval = number.doubleValue(); }else{ dest.isobj = true; dest.objval = var.value; @@ -98,7 +99,7 @@ public class LExecutor{ public @Nullable Building building(int index){ Object o = vars[index].objval; - return vars[index].isobj && o instanceof Building ? (Building)o : null; + return vars[index].isobj && o instanceof Building building ? building : null; } public @Nullable Object obj(int index){ diff --git a/core/src/mindustry/logic/LogicOp.java b/core/src/mindustry/logic/LogicOp.java index 3d7d60a8d9..23f4ee11b3 100644 --- a/core/src/mindustry/logic/LogicOp.java +++ b/core/src/mindustry/logic/LogicOp.java @@ -4,7 +4,7 @@ import arc.math.*; import arc.util.*; public enum LogicOp{ - add("+", (a, b) -> a + b), + add("+", Double::sum), sub("-", (a, b) -> a - b), mul("*", (a, b) -> a * b), div("/", (a, b) -> a / b), @@ -29,7 +29,7 @@ public enum LogicOp{ noise("noise", LExecutor.noise::rawNoise2D), not("not", a -> ~(long)(a)), - abs("abs", a -> Math.abs(a)), + abs("abs", Math::abs), log("log", Math::log), log10("log10", Math::log10), sin("sin", d -> Math.sin(d * 0.017453292519943295D)), diff --git a/core/src/mindustry/maps/SectorDamage.java b/core/src/mindustry/maps/SectorDamage.java index 2ca49967da..651d70a2ac 100644 --- a/core/src/mindustry/maps/SectorDamage.java +++ b/core/src/mindustry/maps/SectorDamage.java @@ -291,7 +291,7 @@ public class SectorDamage{ sumHealth += unit.health*healthMult + unit.shield; sumDps += unit.type.dpsEstimate; - if(unit.abilities.find(a -> a instanceof RepairFieldAbility) instanceof RepairFieldAbility h){ + if(unit.abilities.find(RepairFieldAbility.class::isInstance) instanceof RepairFieldAbility h){ sumRps += h.amount / h.reload * 60f; } }else{ diff --git a/core/src/mindustry/mod/Mods.java b/core/src/mindustry/mod/Mods.java index a596f3e7ae..9720fed59e 100644 --- a/core/src/mindustry/mod/Mods.java +++ b/core/src/mindustry/mod/Mods.java @@ -134,7 +134,7 @@ public class Mods implements Loadable{ }catch(IOException e){ Core.app.post(() -> { Log.err("Error packing images for mod: @", mod.meta.name); - e.printStackTrace(); + Log.err(e); if(!headless) ui.showException(e); }); break; diff --git a/core/src/mindustry/net/Administration.java b/core/src/mindustry/net/Administration.java index 32356ff838..0fccd2bc14 100644 --- a/core/src/mindustry/net/Administration.java +++ b/core/src/mindustry/net/Administration.java @@ -256,8 +256,7 @@ public class Administration{ public boolean unbanPlayerID(String id){ PlayerInfo info = getCreateInfo(id); - if(!info.banned) - return false; + if(!info.banned) return false; info.banned = false; bannedIPs.removeAll(info.ips, false); @@ -551,8 +550,8 @@ public class Administration{ } return info != null || ips != null || whitelist != null || subnet != null; - }catch(Throwable e){ - e.printStackTrace(); + }catch(Throwable t){ + Log.err(t); } return false; } diff --git a/core/src/mindustry/net/Net.java b/core/src/mindustry/net/Net.java index 4d7a2f4ca3..dc7431d0d4 100644 --- a/core/src/mindustry/net/Net.java +++ b/core/src/mindustry/net/Net.java @@ -254,8 +254,9 @@ public class Net{ }else if(clientListeners.get(object.getClass()) != null){ if(clientLoaded || ((object instanceof Packet) && ((Packet)object).isImportant())){ - if(clientListeners.get(object.getClass()) != null) + if(clientListeners.get(object.getClass()) != null){ clientListeners.get(object.getClass()).get(object); + } Pools.free(object); }else if(!((object instanceof Packet) && ((Packet)object).isUnimportant())){ packetQueue.add(object); @@ -273,8 +274,9 @@ public class Net{ public void handleServerReceived(NetConnection connection, Object object){ if(serverListeners.get(object.getClass()) != null){ - if(serverListeners.get(object.getClass()) != null) + if(serverListeners.get(object.getClass()) != null){ serverListeners.get(object.getClass()).get(connection, object); + } Pools.free(object); }else{ Log.err("Unhandled packet type: '@'!", object.getClass()); diff --git a/core/src/mindustry/type/Item.java b/core/src/mindustry/type/Item.java index f52323d655..e4bc580ce6 100644 --- a/core/src/mindustry/type/Item.java +++ b/core/src/mindustry/type/Item.java @@ -53,6 +53,6 @@ public class Item extends UnlockableContent{ /** Allocates a new array containing all items that generate ores. */ public static Seq getAllOres(){ - return content.blocks().select(b -> b instanceof OreBlock).map(b -> ((Floor)b).itemDrop); + return content.blocks().select(OreBlock.class::isInstance).map(b -> ((Floor)b).itemDrop); } } From f8914d0543110ceabe83af7fea035b870dab9c7e Mon Sep 17 00:00:00 2001 From: Skat <55407440+skykatik@users.noreply.github.com> Date: Sat, 7 Nov 2020 13:01:24 +0300 Subject: [PATCH 2/3] Old style --- core/src/mindustry/maps/SectorDamage.java | 2 +- core/src/mindustry/type/Item.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/maps/SectorDamage.java b/core/src/mindustry/maps/SectorDamage.java index 651d70a2ac..2ca49967da 100644 --- a/core/src/mindustry/maps/SectorDamage.java +++ b/core/src/mindustry/maps/SectorDamage.java @@ -291,7 +291,7 @@ public class SectorDamage{ sumHealth += unit.health*healthMult + unit.shield; sumDps += unit.type.dpsEstimate; - if(unit.abilities.find(RepairFieldAbility.class::isInstance) instanceof RepairFieldAbility h){ + if(unit.abilities.find(a -> a instanceof RepairFieldAbility) instanceof RepairFieldAbility h){ sumRps += h.amount / h.reload * 60f; } }else{ diff --git a/core/src/mindustry/type/Item.java b/core/src/mindustry/type/Item.java index e4bc580ce6..f52323d655 100644 --- a/core/src/mindustry/type/Item.java +++ b/core/src/mindustry/type/Item.java @@ -53,6 +53,6 @@ public class Item extends UnlockableContent{ /** Allocates a new array containing all items that generate ores. */ public static Seq getAllOres(){ - return content.blocks().select(OreBlock.class::isInstance).map(b -> ((Floor)b).itemDrop); + return content.blocks().select(b -> b instanceof OreBlock).map(b -> ((Floor)b).itemDrop); } } From 9f979cba0dc2bcbb5e9ed273d9d0bb0676ef336a Mon Sep 17 00:00:00 2001 From: Skat <55407440+skykatik@users.noreply.github.com> Date: Sat, 7 Nov 2020 19:46:37 +0300 Subject: [PATCH 3/3] Rollback --- core/src/mindustry/core/Control.java | 2 +- core/src/mindustry/graphics/MenuRenderer.java | 2 +- core/src/mindustry/logic/LogicOp.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index 4a3d1fc675..cdb6738ebd 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -186,7 +186,7 @@ public class Control implements ApplicationListener, Loadable{ if(state.isCampaign()){ ui.announce("[accent]" + state.rules.sector.name() + "\n" + (state.rules.sector.info.resources.any() ? "[lightgray]" + bundle.get("sectors.resources") + "[white] " + - state.rules.sector.info.resources.toString(" ", UnlockableContent::emoji) : ""), 5); + state.rules.sector.info.resources.toString(" ", u -> u.emoji()) : ""), 5); } }); }); diff --git a/core/src/mindustry/graphics/MenuRenderer.java b/core/src/mindustry/graphics/MenuRenderer.java index 1be946cbd7..87ab169670 100644 --- a/core/src/mindustry/graphics/MenuRenderer.java +++ b/core/src/mindustry/graphics/MenuRenderer.java @@ -42,7 +42,7 @@ public class MenuRenderer implements Disposable{ private void generate(){ world.beginMapLoad(); Tiles tiles = world.resize(width, height); - Seq ores = content.blocks().select(OreBlock.class::isInstance); + Seq ores = content.blocks().select(b -> b instanceof OreBlock); shadows = new FrameBuffer(width, height); int offset = Mathf.random(100000); Simplex s1 = new Simplex(offset); diff --git a/core/src/mindustry/logic/LogicOp.java b/core/src/mindustry/logic/LogicOp.java index 23f4ee11b3..3d7d60a8d9 100644 --- a/core/src/mindustry/logic/LogicOp.java +++ b/core/src/mindustry/logic/LogicOp.java @@ -4,7 +4,7 @@ import arc.math.*; import arc.util.*; public enum LogicOp{ - add("+", Double::sum), + add("+", (a, b) -> a + b), sub("-", (a, b) -> a - b), mul("*", (a, b) -> a * b), div("/", (a, b) -> a / b), @@ -29,7 +29,7 @@ public enum LogicOp{ noise("noise", LExecutor.noise::rawNoise2D), not("not", a -> ~(long)(a)), - abs("abs", Math::abs), + abs("abs", a -> Math.abs(a)), log("log", Math::log), log10("log10", Math::log10), sin("sin", d -> Math.sin(d * 0.017453292519943295D)),