Skip to content

Commit

Permalink
Change sendMessageQueue to an Deque for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Feb 28, 2021
1 parent 2d5f29e commit 29976c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/main/java/skytils/skytilsmod/Skytils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import skytils.skytilsmod.utils.Utils;

import java.io.File;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Map;

Expand All @@ -47,10 +48,10 @@ public class Skytils {

public static int ticks = 0;

public static ArrayList<String> sendMessageQueue = new ArrayList<>();
public static ArrayDeque<String> sendMessageQueue = new ArrayDeque<>();
private static long lastChatMessage = 0;
public static boolean usingNEU = false;
public static boolean usingLabymod = false;
public static boolean usingNEU = false;

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
Expand Down Expand Up @@ -106,6 +107,7 @@ public void init(FMLInitializationEvent event) {
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
usingLabymod = Loader.isModLoaded("labymod");
usingNEU = Loader.isModLoaded("notenoughupdates");

if(!ClientCommandHandler.instance.getCommands().containsKey("reparty")) {
ClientCommandHandler.instance.registerCommand(new RepartyCommand());
Expand All @@ -125,7 +127,6 @@ public void postInit(FMLPostInitializationEvent event) {
}
}
}
if (Loader.isModLoaded("notenoughupdates")) usingNEU = true;
}

@SubscribeEvent
Expand All @@ -135,7 +136,7 @@ public void onTick(TickEvent.ClientTickEvent event) {
ScreenRenderer.refresh();

if (mc.thePlayer != null && sendMessageQueue.size() > 0 && System.currentTimeMillis() - lastChatMessage > 200) {
mc.thePlayer.sendChatMessage(sendMessageQueue.remove(0));
mc.thePlayer.sendChatMessage(sendMessageQueue.pollFirst());
}

if (ticks % 20 == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void onReceivePacket(ReceivePacketEvent event) {
double y = packet.getYCoordinate();
double z = packet.getZCoordinate();

BlockPos pos = new BlockPos((int)x, (int)y, (int)z).down();
BlockPos pos = new BlockPos(x, y, z).down();

boolean footstepFilter = type == EnumParticleTypes.FOOTSTEP && count == 1 && speed == 0.0f && xOffset == 0.05f && yOffset == 0.0f && zOffset == 0.05f;
boolean enchantFilter = type == EnumParticleTypes.ENCHANTMENT_TABLE && count == 5 && speed == 0.05f && xOffset == 0.5f && yOffset == 0.4f && zOffset == 0.5f;
Expand Down

0 comments on commit 29976c4

Please sign in to comment.