Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Mar 8, 2021
1 parent ec70ee0 commit cbbf207
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Move> generatePairs(World world, List<BlockPos> positions) {
Expand Down Expand Up @@ -212,7 +208,7 @@ private Vec3 getVec3RelativeToGrid3(int row, int column) {
}

private class IceFillPuzzle {
private List<BlockPos> spaces = new ArrayList<>();
private final List<BlockPos> spaces = new ArrayList<>();
private BlockPos start;
public List<List<BlockPos>> paths = new ArrayList<>();

Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
5 changes: 3 additions & 2 deletions src/main/java/skytils/skytilsmod/gui/LocationEditGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -19,7 +20,7 @@ public class LocationEditGui extends GuiScreen {
private float yOffset;

private GuiElement dragging;
private Map<GuiElement, LocationButton> locationButtons = new HashMap<>();
private final Map<GuiElement, LocationButton> locationButtons = new HashMap<>();

@Override
public boolean doesGuiPauseGame() {
Expand Down Expand Up @@ -99,6 +100,6 @@ protected void mouseReleased(int mouseX, int mouseY, int state) {
*/
@Override
public void onGuiClosed() {
Skytils.GUIMANAGER.saveConfig();
GuiManager.saveConfig();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
public class ScrollingCommandAliasesList extends GuiScrollingList {

private Minecraft mc;
private ArrayList<AliasListEntry> aliases;
private final Minecraft mc;
private final ArrayList<AliasListEntry> aliases;

public ScrollingCommandAliasesList(Minecraft mc, int width, int height, int top, int bottom, int left, int entryHeight,
int screenWidth, int screenHeight) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/skytils/skytilsmod/mixins/MixinWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ private int lightningSkyColor(World world) {
if (Skytils.config.hideLightning && Utils.inSkyblock) return 0;
else return world.getLastLightningBolt();
}
};
}
2 changes: 1 addition & 1 deletion src/main/java/skytils/skytilsmod/utils/EnumUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/skytils/skytilsmod/utils/ItemRarity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/skytils/skytilsmod/utils/toasts/BlessingToast.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@
public class BlessingToast implements IToast<BlessingToast> {
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<BlessingBuff> buffs;
private final long maxDrawTime;
private final Blessing blessing;
private final List<BlessingBuff> buffs;

public BlessingToast(String blessing, List<BlessingBuff> buffs)
{
public BlessingToast(String blessing, List<BlessingBuff> 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);
Expand All @@ -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 "❤":
Expand All @@ -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);
Expand All @@ -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!"),
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/skytils/skytilsmod/utils/toasts/IToast.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>
{
public interface IToast<T> {
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() {
}
}
}
8 changes: 4 additions & 4 deletions src/main/java/skytils/skytilsmod/utils/toasts/KeyToast.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

import java.nio.FloatBuffer;

public class KeyToast implements IToast<KeyToast>{
public class KeyToast implements IToast<KeyToast> {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

import java.nio.FloatBuffer;

public class SuperboomToast implements IToast<SuperboomToast>{
public class SuperboomToast implements IToast<SuperboomToast> {
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;
Expand Down

0 comments on commit cbbf207

Please sign in to comment.