minor fixes

This commit is contained in:
Stachelbeere1248 2024-03-10 12:44:21 +01:00
parent 33ee87f506
commit af67a59000
Signed by: Stachelbeere1248
SSH key fingerprint: SHA256:IozEKdw2dB8TZxkpPdMxcWSoWTIMwoLaCcZJ1AJnY2o
4 changed files with 10 additions and 23 deletions

View file

@ -16,12 +16,11 @@ import org.jetbrains.annotations.NotNull;
public class ZombiesUtils { public class ZombiesUtils {
private static ZombiesUtils instance; private static ZombiesUtils instance;
private final Hotkeys hotkeys; private final Hotkeys hotkeys;
private final Handlers handlers; private Handlers handlers;
private Logger logger; private Logger logger;
public ZombiesUtils() { public ZombiesUtils() {
hotkeys = new Hotkeys(); hotkeys = new Hotkeys();
handlers = new Handlers();
instance = this; instance = this;
} }
@ -41,6 +40,7 @@ public class ZombiesUtils {
@Mod.EventHandler @Mod.EventHandler
public void init(FMLInitializationEvent event) { public void init(FMLInitializationEvent event) {
handlers = new Handlers();
handlers.registerAll(); handlers.registerAll();
CommandRegistry.registerAll(); CommandRegistry.registerAll();
hotkeys.registerAll(); hotkeys.registerAll();

View file

@ -1,18 +1,4 @@
package com.github.stachelbeere1248.zombiesutils.game.enums; package com.github.stachelbeere1248.zombiesutils.game.enums;
import org.jetbrains.annotations.NotNull;
public enum Map { public enum Map {
DEAD_END, BAD_BLOOD, ALIEN_ARCADIUM, PRISON; DEAD_END, BAD_BLOOD, ALIEN_ARCADIUM, PRISON;
@Override
public @NotNull String toString() {
switch (this) {
case DEAD_END: return "Dead End";
case BAD_BLOOD: return "Bad Blood";
case ALIEN_ARCADIUM: return "Alien Arcadium";
case PRISON: return "Prison";
default: throw new IllegalStateException("Unexpected Map value:" + this);
}
}
} }

View file

@ -18,21 +18,22 @@ public class Waves {
@Contract(pure = true) @Contract(pure = true)
public static byte[] get(@NotNull Map map, byte round) { public static byte[] get(@NotNull Map map, byte round) {
byte[] ret = new byte[0]; byte[] ret = new byte[]{ 0 };
try { try {
switch (map) { switch (map) {
case DEAD_END: case DEAD_END:
ret = deadEndWaveTimes[round - 1]; ret = deadEndWaveTimes[round - 1];
break;
case BAD_BLOOD: case BAD_BLOOD:
ret = badBloodWaveTimes[round - 1]; ret = badBloodWaveTimes[round - 1];
break;
case ALIEN_ARCADIUM: case ALIEN_ARCADIUM:
ret = alienArcadiumWaveTimes[round - 1]; ret = alienArcadiumWaveTimes[round - 1];
default: break;
throw new IllegalStateException("Unexpected value: " + map);
} }
} catch (ArrayIndexOutOfBoundsException e) { } catch (ArrayIndexOutOfBoundsException ignored) {
Minecraft.getMinecraft().thePlayer.addChatMessage( Minecraft.getMinecraft().thePlayer.addChatMessage(
new ChatComponentText("Achievement get: Round " + round + map) new ChatComponentText("Achievement get: Round " + round + " " + map)
); );
} }
return ret; return ret;

View file

@ -135,7 +135,7 @@ public class RenderGameOverlayHandler {
} }
} }
public void renderCPS() { public void renderCPS() {
final String cps = String.format("%2.1f", getClicks()); final String cps = String.format("%2d", getClicks());
final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
final int screenWidth = scaledResolution.getScaledWidth(); final int screenWidth = scaledResolution.getScaledWidth();
final int width = fontRenderer.getStringWidth(cps); final int width = fontRenderer.getStringWidth(cps);
@ -148,7 +148,7 @@ public class RenderGameOverlayHandler {
); );
} }
public double getClicks() { public int getClicks() {
int i = 0; int i = 0;
for (boolean tick : clicks) { for (boolean tick : clicks) {
if (tick) i++; if (tick) i++;