Skip to content

Commit

Permalink
Reduce memory allocations (#24)
Browse files Browse the repository at this point in the history
* update bs+dep

* reduce allocations by a ton

* stop sending rain packet every tick

* small cleanup

* these will never be null at this point

* chill with the enum[] allocations
  • Loading branch information
Lyfts authored Oct 16, 2024
1 parent 12a9203 commit fb340fa
Show file tree
Hide file tree
Showing 27 changed files with 410 additions and 332 deletions.
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
dependencies {
api('com.github.GTNewHorizons:LunatriusCore:1.2.0-GTNH:dev')

compileOnly('com.github.GTNewHorizons:BloodMagic:1.6.2:dev')
compileOnly('com.github.GTNewHorizons:BloodMagic:1.6.6:dev')
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('curse.maven:cofh-lib-220333:2388748')
compileOnly('curse.maven:simply-jetpacks-79325:2267185')
compileOnly('curse.maven:tfcraft-302973:2627990')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.49.56:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.50.42:dev')
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ developmentEnvironmentUserName = Developer

# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = false
enableModernJavaSyntax = true

# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
enableGenericInjection = true

# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.26'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.27'
}


34 changes: 12 additions & 22 deletions src/main/java/com/github/lunatrius/ingameinfo/Alignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,23 @@ public static Alignment parse(String str) {
}

public int getX(int screenwidth, int textwidth) {
switch (this.alignment & MASK_X) {
case LEFT:
return this.x;
return switch (this.alignment & MASK_X) {
case LEFT -> this.x;
case CENTER -> this.x + (screenwidth - textwidth) / 2;
case RIGHT -> this.x + screenwidth - textwidth;
default -> 0;
};

case CENTER:
return this.x + (screenwidth - textwidth) / 2;

case RIGHT:
return this.x + screenwidth - textwidth;
}

return 0;
}

public int getY(int screenheight, int textheight) {
switch (this.alignment & MASK_Y) {
case TOP:
return this.y;

case MIDDLE:
return this.y + (screenheight - textheight) / 2;

case BOTTOM:
return this.y + screenheight - textheight;
}
return switch (this.alignment & MASK_Y) {
case TOP -> this.y;
case MIDDLE -> this.y + (screenheight - textheight) / 2;
case BOTTOM -> this.y + screenheight - textheight;
default -> 0;
};

return 0;
}

public String getDefaultXY() {
Expand Down
Loading

0 comments on commit fb340fa

Please sign in to comment.