From cbbf20777bac8c4914e2d7014c8fe4c58a94f4fb Mon Sep 17 00:00:00 2001 From: My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> Date: Mon, 8 Mar 2021 13:32:09 -0500 Subject: [PATCH] Code cleanup --- .../skytilsmod/core/structure/FloatPair.java | 6 ++--- .../skytilsmod/core/structure/GuiElement.java | 7 +++--- .../impl/dungeons/BossHPDisplays.java | 2 +- .../impl/dungeons/solvers/IceFillSolver.java | 18 +++++---------- .../misc/damagesplash/DamageSplashEntity.java | 4 ++-- .../skytilsmod/gui/LocationEditGui.java | 5 +++-- .../elements/ScrollingCommandAliasesList.java | 12 +++++----- .../skytils/skytilsmod/mixins/MixinWorld.java | 2 +- .../skytils/skytilsmod/utils/EnumUtil.java | 2 +- .../skytils/skytilsmod/utils/ItemRarity.java | 2 +- .../utils/graphics/SmartFontRenderer.java | 2 +- .../utils/toasts/BlessingToast.java | 22 +++++++++---------- .../skytilsmod/utils/toasts/IToast.java | 14 ++++++------ .../skytilsmod/utils/toasts/KeyToast.java | 8 +++---- .../utils/toasts/SuperboomToast.java | 6 ++--- 15 files changed, 52 insertions(+), 60 deletions(-) diff --git a/src/main/java/skytils/skytilsmod/core/structure/FloatPair.java b/src/main/java/skytils/skytilsmod/core/structure/FloatPair.java index a25983baa..49a645226 100644 --- a/src/main/java/skytils/skytilsmod/core/structure/FloatPair.java +++ b/src/main/java/skytils/skytilsmod/core/structure/FloatPair.java @@ -12,10 +12,10 @@ * @author BiscuitDevelopment */ public class FloatPair { - private static ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + private static final ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - private MutableFloat x; - private MutableFloat y; + private final MutableFloat x; + private final MutableFloat y; public FloatPair(int x, int y) { this(x / (float) sr.getScaledHeight(), y / (float) sr.getScaledHeight()); diff --git a/src/main/java/skytils/skytilsmod/core/structure/GuiElement.java b/src/main/java/skytils/skytilsmod/core/structure/GuiElement.java index 29c73e350..eb2cb1821 100644 --- a/src/main/java/skytils/skytilsmod/core/structure/GuiElement.java +++ b/src/main/java/skytils/skytilsmod/core/structure/GuiElement.java @@ -3,9 +3,10 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import skytils.skytilsmod.Skytils; +import skytils.skytilsmod.core.GuiManager; public abstract class GuiElement { - private static ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + private static final ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); String name; float scale; FloatPair pos; @@ -21,8 +22,8 @@ public GuiElement (String name, FloatPair fp) { public GuiElement(String name, float scale, FloatPair fp) { this.name = name; this.scale = scale; - if (Skytils.GUIMANAGER.GUIPOSITIONS.containsKey(name)) { - this.pos = Skytils.GUIMANAGER.GUIPOSITIONS.get(name); + if (GuiManager.GUIPOSITIONS.containsKey(name)) { + this.pos = GuiManager.GUIPOSITIONS.get(name); } else { this.pos = fp; } diff --git a/src/main/java/skytils/skytilsmod/features/impl/dungeons/BossHPDisplays.java b/src/main/java/skytils/skytilsmod/features/impl/dungeons/BossHPDisplays.java index 0e4ef4f59..8f5575851 100644 --- a/src/main/java/skytils/skytilsmod/features/impl/dungeons/BossHPDisplays.java +++ b/src/main/java/skytils/skytilsmod/features/impl/dungeons/BossHPDisplays.java @@ -81,7 +81,7 @@ public void render() { return true; } else if (Arrays.stream(GIANT_NAMES).anyMatch(name::contains)) { return true; - } else if (name.contains("Giant") && Objects.equals(DungeonsFeatures.dungeonFloor, "F7")) return true; + } else return name.contains("Giant") && Objects.equals(DungeonsFeatures.dungeonFloor, "F7"); } return false; }); diff --git a/src/main/java/skytils/skytilsmod/features/impl/dungeons/solvers/IceFillSolver.java b/src/main/java/skytils/skytilsmod/features/impl/dungeons/solvers/IceFillSolver.java index c48fd5d88..0d283f32c 100644 --- a/src/main/java/skytils/skytilsmod/features/impl/dungeons/solvers/IceFillSolver.java +++ b/src/main/java/skytils/skytilsmod/features/impl/dungeons/solvers/IceFillSolver.java @@ -94,13 +94,9 @@ public void onTick(TickEvent.ClientTickEvent event) { } private boolean checkForStart(World world, BlockPos pos) { - if (world.getBlockState(pos).getBlock() == Blocks.air && - world.getBlockState(pos.offset(roomFacing.rotateY())).getBlock() == Blocks.cobblestone_wall && - world.getBlockState(pos.offset(roomFacing.rotateYCCW())).getBlock() == Blocks.cobblestone_wall) { - return true; - } else { - return false; - } + return world.getBlockState(pos).getBlock() == Blocks.air && + world.getBlockState(pos.offset(roomFacing.rotateY())).getBlock() == Blocks.cobblestone_wall && + world.getBlockState(pos.offset(roomFacing.rotateYCCW())).getBlock() == Blocks.cobblestone_wall; } private List generatePairs(World world, List positions) { @@ -212,7 +208,7 @@ private Vec3 getVec3RelativeToGrid3(int row, int column) { } private class IceFillPuzzle { - private List spaces = new ArrayList<>(); + private final List spaces = new ArrayList<>(); private BlockPos start; public List> paths = new ArrayList<>(); @@ -307,11 +303,7 @@ public boolean equals(Object original, Object other) { Move e = (Move) original; if (e.dest.equals(o.dest) && e.source.equals(o.source)) { return true; - } else if (e.dest.equals(o.source) && e.source.equals(o.dest)) { - return true; - } else { - return false; - } + } else return e.dest.equals(o.source) && e.source.equals(o.dest); } } diff --git a/src/main/java/skytils/skytilsmod/features/impl/misc/damagesplash/DamageSplashEntity.java b/src/main/java/skytils/skytilsmod/features/impl/misc/damagesplash/DamageSplashEntity.java index abbb428f9..7a61f3f33 100644 --- a/src/main/java/skytils/skytilsmod/features/impl/misc/damagesplash/DamageSplashEntity.java +++ b/src/main/java/skytils/skytilsmod/features/impl/misc/damagesplash/DamageSplashEntity.java @@ -88,7 +88,7 @@ public void tick(float partialTicks, Random r, EntityPlayerSP player) { public void render(float partialTicks, RenderGlobal context, RenderManager render) { boolean thirdPerson = render.options.thirdPersonView == 2; - renderer.setRendering(true); + ScreenRenderer.setRendering(true); { { // setting up rotate(-render.playerViewY, 0f, 1f, 0f); // rotates yaw @@ -103,6 +103,6 @@ public void render(float partialTicks, RenderGlobal context, RenderManager rende renderer.drawString(displayText, 0, 0, color/*CommonColors.RAINBOW*/, SmartFontRenderer.TextAlignment.MIDDLE, SmartFontRenderer.TextShadow.NONE); } - renderer.setRendering(false); + ScreenRenderer.setRendering(false); } } diff --git a/src/main/java/skytils/skytilsmod/gui/LocationEditGui.java b/src/main/java/skytils/skytilsmod/gui/LocationEditGui.java index 23a02971c..3eb6551b6 100644 --- a/src/main/java/skytils/skytilsmod/gui/LocationEditGui.java +++ b/src/main/java/skytils/skytilsmod/gui/LocationEditGui.java @@ -6,6 +6,7 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import skytils.skytilsmod.Skytils; +import skytils.skytilsmod.core.GuiManager; import skytils.skytilsmod.core.structure.GuiElement; import skytils.skytilsmod.core.structure.LocationButton; @@ -19,7 +20,7 @@ public class LocationEditGui extends GuiScreen { private float yOffset; private GuiElement dragging; - private Map locationButtons = new HashMap<>(); + private final Map locationButtons = new HashMap<>(); @Override public boolean doesGuiPauseGame() { @@ -99,6 +100,6 @@ protected void mouseReleased(int mouseX, int mouseY, int state) { */ @Override public void onGuiClosed() { - Skytils.GUIMANAGER.saveConfig(); + GuiManager.saveConfig(); } } diff --git a/src/main/java/skytils/skytilsmod/gui/commandaliases/elements/ScrollingCommandAliasesList.java b/src/main/java/skytils/skytilsmod/gui/commandaliases/elements/ScrollingCommandAliasesList.java index cff00fe92..ead671a21 100644 --- a/src/main/java/skytils/skytilsmod/gui/commandaliases/elements/ScrollingCommandAliasesList.java +++ b/src/main/java/skytils/skytilsmod/gui/commandaliases/elements/ScrollingCommandAliasesList.java @@ -16,8 +16,8 @@ */ public class ScrollingCommandAliasesList extends GuiScrollingList { - private Minecraft mc; - private ArrayList aliases; + private final Minecraft mc; + private final ArrayList aliases; public ScrollingCommandAliasesList(Minecraft mc, int width, int height, int top, int bottom, int left, int entryHeight, int screenWidth, int screenHeight) { @@ -116,10 +116,10 @@ protected void drawGradientRect(int left, int top, int right, int bottom, int co public class AliasListEntry { - private GuiTextField key; - private GuiTextField message; - private GuiButton removeButton; - private int id; + private final GuiTextField key; + private final GuiTextField message; + private final GuiButton removeButton; + private final int id; public AliasListEntry(int id, GuiTextField key, GuiTextField message, GuiButton removeButton) { this.id = id; diff --git a/src/main/java/skytils/skytilsmod/mixins/MixinWorld.java b/src/main/java/skytils/skytilsmod/mixins/MixinWorld.java index 7a8a4106e..b7313a934 100644 --- a/src/main/java/skytils/skytilsmod/mixins/MixinWorld.java +++ b/src/main/java/skytils/skytilsmod/mixins/MixinWorld.java @@ -14,4 +14,4 @@ private int lightningSkyColor(World world) { if (Skytils.config.hideLightning && Utils.inSkyblock) return 0; else return world.getLastLightningBolt(); } -}; +} diff --git a/src/main/java/skytils/skytilsmod/utils/EnumUtil.java b/src/main/java/skytils/skytilsmod/utils/EnumUtil.java index 9fa41c06c..700ad874d 100644 --- a/src/main/java/skytils/skytilsmod/utils/EnumUtil.java +++ b/src/main/java/skytils/skytilsmod/utils/EnumUtil.java @@ -9,7 +9,7 @@ public enum AnchorPoint { BOTTOM_RIGHT(3), BOTTOM_MIDDLE(4); - private int id; + private final int id; AnchorPoint(int id) { this.id = id; diff --git a/src/main/java/skytils/skytilsmod/utils/ItemRarity.java b/src/main/java/skytils/skytilsmod/utils/ItemRarity.java index 14c293afa..d1c4a1632 100644 --- a/src/main/java/skytils/skytilsmod/utils/ItemRarity.java +++ b/src/main/java/skytils/skytilsmod/utils/ItemRarity.java @@ -35,7 +35,7 @@ public enum ItemRarity { } } - private ItemRarity(String name, EnumChatFormatting baseColor, Color color) { + ItemRarity(String name, EnumChatFormatting baseColor, Color color) { this.name = name; this.baseColor = baseColor; this.color = color; diff --git a/src/main/java/skytils/skytilsmod/utils/graphics/SmartFontRenderer.java b/src/main/java/skytils/skytilsmod/utils/graphics/SmartFontRenderer.java index c5d299e8a..a8de60298 100644 --- a/src/main/java/skytils/skytilsmod/utils/graphics/SmartFontRenderer.java +++ b/src/main/java/skytils/skytilsmod/utils/graphics/SmartFontRenderer.java @@ -324,7 +324,7 @@ private float renderChar(char ch, boolean italic) { if (ch == 32) { return 4.0F; } else { - int i = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(ch); + int i = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(ch); return i != -1 && !this.getUnicodeFlag() ? this.renderDefaultChar(i, italic) : this.renderUnicodeChar(ch, italic); } } diff --git a/src/main/java/skytils/skytilsmod/utils/toasts/BlessingToast.java b/src/main/java/skytils/skytilsmod/utils/toasts/BlessingToast.java index dfa2f2d77..45487464c 100644 --- a/src/main/java/skytils/skytilsmod/utils/toasts/BlessingToast.java +++ b/src/main/java/skytils/skytilsmod/utils/toasts/BlessingToast.java @@ -15,20 +15,18 @@ public class BlessingToast implements IToast { private static final ResourceLocation TEXTURE = new ResourceLocation("skytils:gui/toast.png"); private final FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16); - private long maxDrawTime; - private Blessing blessing; - private List buffs; + private final long maxDrawTime; + private final Blessing blessing; + private final List buffs; - public BlessingToast(String blessing, List buffs) - { + public BlessingToast(String blessing, List buffs) { this.maxDrawTime = Skytils.config.toastTime; this.blessing = Blessing.fromName(blessing); this.buffs = buffs; } @Override - public IToast.Visibility draw(GuiToast toastGui, long delta) - { + public IToast.Visibility draw(GuiToast toastGui, long delta) { toastGui.mc.getTextureManager().bindTexture(TEXTURE); GlStateManager.color(1.0F, 1.0F, 1.0F); @@ -38,8 +36,8 @@ public IToast.Visibility draw(GuiToast toastGui, long delta) toastGui.mc.fontRendererObj.drawStringWithShadow(this.blessing.getFormattedName(), 30, 7, 16777215); - String buffStats = ""; - for(BlessingBuff buff : this.buffs) { + StringBuilder buffStats = new StringBuilder(); + for (BlessingBuff buff : this.buffs) { String color; switch (buff.symbol) { case "❤": @@ -62,9 +60,9 @@ public IToast.Visibility draw(GuiToast toastGui, long delta) default: color = EnumChatFormatting.GRAY.toString(); } - buffStats += color + buff.amount + buff.symbol + " "; + buffStats.append(color).append(buff.amount).append(buff.symbol).append(" "); } - GuiToast.drawSubline(toastGui, delta, 0L, this.maxDrawTime, this.buffer, buffStats, false); + GuiToast.drawSubline(toastGui, delta, 0L, this.maxDrawTime, this.buffer, buffStats.toString(), false); RenderHelper.enableGUIStandardItemLighting(); RenderUtil.renderTexture(this.blessing.texture, 8, 8); @@ -73,7 +71,7 @@ public IToast.Visibility draw(GuiToast toastGui, long delta) return delta >= this.maxDrawTime ? IToast.Visibility.HIDE : IToast.Visibility.SHOW; } - private enum Blessing { + private enum Blessing { LIFE("life", "skytils:blessings/life.png", "§c§lLIFE BLESSING!"), POWER("power", "skytils:blessings/power.png", "§5§lPOWER BLESSING!"), STONE("stone", "skytils:blessings/stone.png", "§a§lSTONE BLESSING!"), diff --git a/src/main/java/skytils/skytilsmod/utils/toasts/IToast.java b/src/main/java/skytils/skytilsmod/utils/toasts/IToast.java index a4583cc1a..36ecdac4e 100644 --- a/src/main/java/skytils/skytilsmod/utils/toasts/IToast.java +++ b/src/main/java/skytils/skytilsmod/utils/toasts/IToast.java @@ -4,23 +4,23 @@ * Taken from Skyblockcatia under MIT License * Modified * https://github.com/SteveKunG/SkyBlockcatia/blob/1.8.9/LICENSE.md + * * @author SteveKunG */ -public interface IToast -{ +public interface IToast { Object NO_TOKEN = new Object(); + IToast.Visibility draw(GuiToast toastGui, long delta); - default Object getType() - { + default Object getType() { return NO_TOKEN; } - enum Visibility - { + enum Visibility { SHOW(), HIDE(); - Visibility() {} + Visibility() { + } } } \ No newline at end of file diff --git a/src/main/java/skytils/skytilsmod/utils/toasts/KeyToast.java b/src/main/java/skytils/skytilsmod/utils/toasts/KeyToast.java index 5674052b1..fa0c502b0 100644 --- a/src/main/java/skytils/skytilsmod/utils/toasts/KeyToast.java +++ b/src/main/java/skytils/skytilsmod/utils/toasts/KeyToast.java @@ -10,12 +10,12 @@ import java.nio.FloatBuffer; -public class KeyToast implements IToast{ +public class KeyToast implements IToast { private static final ResourceLocation TEXTURE = new ResourceLocation("skytils:gui/toast.png"); private final FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16); - private long maxDrawTime; - private KeyType key; - private String player; + private final long maxDrawTime; + private final KeyType key; + private final String player; public KeyToast(String type, String player) { this.key = KeyType.fromName(type); diff --git a/src/main/java/skytils/skytilsmod/utils/toasts/SuperboomToast.java b/src/main/java/skytils/skytilsmod/utils/toasts/SuperboomToast.java index 65b74abf2..6dca3bd7f 100644 --- a/src/main/java/skytils/skytilsmod/utils/toasts/SuperboomToast.java +++ b/src/main/java/skytils/skytilsmod/utils/toasts/SuperboomToast.java @@ -14,11 +14,11 @@ import java.nio.FloatBuffer; -public class SuperboomToast implements IToast{ +public class SuperboomToast implements IToast { private static final ResourceLocation TEXTURE = new ResourceLocation("skytils:gui/toast.png"); - private static ItemStack superBoom = new ItemStack(Item.getItemFromBlock(Blocks.tnt)); + private static final ItemStack superBoom = new ItemStack(Item.getItemFromBlock(Blocks.tnt)); private final FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16); - private long maxDrawTime; + private final long maxDrawTime; public SuperboomToast() { this.maxDrawTime = Skytils.config.toastTime;