Skip to content

Commit

Permalink
Release v3.12.1
Browse files Browse the repository at this point in the history
- Fixed a bug related to the INIT_POST Screen event. The event wasn't always firing properly.
  • Loading branch information
TheCSDev committed Jul 11, 2024
1 parent 0a46368 commit 37d2dab
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tcdcommons-3-fabric-1.20.5/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ org.gradle.jvmargs=-Xmx1G
mod_name = TCD Commons API
mod_description = My personal API library for my mods. It aims to improve performance by avoiding rewriting the same code, and to speed up the mod development process.
mod_author = TheCSDev
mod_version = 3.12+fabric-1.20.6
mod_version = 3.12.1+fabric-1.20.6

# Here you link the source code repository links:
mod_contact_homepage = https://github.com/TheCSDev
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.github.thecsdev.tcdcommons.api.util.integrity;

import java.io.File;
import java.util.Locale;
import java.util.Objects;

import org.jetbrains.annotations.Nullable;

/**
* Utility methods for mods looking to test their own codebase's integrity.
*/
public final class IntegrityUtils
{
// ==================================================
private IntegrityUtils() {}
// ==================================================
/**
* Retrieves the name of the JAR {@link File} that contains a given {@link Class}.
* Will return {@code null} if a JAR file is not present or applicable in a given
* context, like for example if a {@link Class} is dynamically loaded from a
* directory or a non-JAR source.
* @param containingClass The {@link Class} whose JAR file name is to be retrieved.
*/
public static final @Nullable String getJarFileName(Class<?> containingClass)
throws NullPointerException, SecurityException
{
//validate arguments
Objects.requireNonNull(containingClass);

//obtain the jar file path and ensure
//it contains forward slashes and ends with ".jar"
final var path = containingClass.getProtectionDomain()
.getCodeSource().getLocation()
.getPath().replace('\\', '/');
if(!path.contains("/") || !path.toLowerCase(Locale.ENGLISH).endsWith(".jar"))
return null;

//get the last part after the last '/' instance, and return it
return path.substring(path.lastIndexOf('/'));
}
// ==================================================
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ private void onInitPost(MinecraftClient client, int width, int height, CallbackI
{
ScreenEvent.INIT_POST.invoker().invoke((Screen)(Object)this);
}

@Inject(method = "clearAndInit", at = @At("RETURN"))
private void onClearAndInit(CallbackInfo callback)
{
ScreenEvent.INIT_POST.invoker().invoke((Screen)(Object)this);
}
}
2 changes: 1 addition & 1 deletion tcdcommons-3-fabric-1.21/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ org.gradle.jvmargs=-Xmx1G
mod_name = TCD Commons API
mod_description = My personal API library for my mods. It aims to improve performance by avoiding rewriting the same code, and to speed up the mod development process.
mod_author = TheCSDev
mod_version = 3.12+fabric-1.21
mod_version = 3.12.1+fabric-1.21

# Here you link the source code repository links:
mod_contact_homepage = https://github.com/TheCSDev
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.github.thecsdev.tcdcommons.api.util.integrity;

import java.io.File;
import java.util.Locale;
import java.util.Objects;

import org.jetbrains.annotations.Nullable;

/**
* Utility methods for mods looking to test their own codebase's integrity.
*/
public final class IntegrityUtils
{
// ==================================================
private IntegrityUtils() {}
// ==================================================
/**
* Retrieves the name of the JAR {@link File} that contains a given {@link Class}.
* Will return {@code null} if a JAR file is not present or applicable in a given
* context, like for example if a {@link Class} is dynamically loaded from a
* directory or a non-JAR source.
* @param containingClass The {@link Class} whose JAR file name is to be retrieved.
*/
public static final @Nullable String getJarFileName(Class<?> containingClass)
throws NullPointerException, SecurityException
{
//validate arguments
Objects.requireNonNull(containingClass);

//obtain the jar file path and ensure
//it contains forward slashes and ends with ".jar"
final var path = containingClass.getProtectionDomain()
.getCodeSource().getLocation()
.getPath().replace('\\', '/');
if(!path.contains("/") || !path.toLowerCase(Locale.ENGLISH).endsWith(".jar"))
return null;

//get the last part after the last '/' instance, and return it
return path.substring(path.lastIndexOf('/'));
}
// ==================================================
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ private void onInitPost(MinecraftClient client, int width, int height, CallbackI
{
ScreenEvent.INIT_POST.invoker().invoke((Screen)(Object)this);
}

@Inject(method = "clearAndInit", at = @At("RETURN"))
private void onClearAndInit(CallbackInfo callback)
{
ScreenEvent.INIT_POST.invoker().invoke((Screen)(Object)this);
}
}

0 comments on commit 37d2dab

Please sign in to comment.