Skip to content

Commit

Permalink
cache compensated inventory & packet entity replication getters
Browse files Browse the repository at this point in the history
  • Loading branch information
AoElite committed Jan 1, 2024
1 parent b183c6a commit ea11ec9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/main/java/ac/grim/grimac/manager/CheckManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,24 @@ public <T extends PacketCheck> T getPrePredictionCheck(Class<T> check) {
return (T) prePredictionChecks.get(check);
}

private PacketEntityReplication packetEntityReplication = null;

public PacketEntityReplication getEntityReplication() {
return getPacketCheck(PacketEntityReplication.class);
if (packetEntityReplication == null) packetEntityReplication = getPacketCheck(PacketEntityReplication.class);
return packetEntityReplication;
}

public NoFallA getNoFall() {
return getPacketCheck(NoFallA.class);
}

private CompensatedInventory inventory = null;

public CompensatedInventory getInventory() {
if (inventory == null) inventory = getPacketCheck(CompensatedInventory.class);
return inventory;
}

public KnockbackHandler getKnockbackHandler() {
return getPostPredictionCheck(KnockbackHandler.class);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ac/grim/grimac/player/GrimPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ public boolean canThePlayerBeCloseToZeroMovement(int ticks) {
}

public CompensatedInventory getInventory() {
return checkManager.getPacketCheck(CompensatedInventory.class);
return checkManager.getInventory();
}

public List<Double> getPossibleEyeHeights() { // We don't return sleeping eye height
Expand Down

0 comments on commit ea11ec9

Please sign in to comment.