使其可调试

This commit is contained in:
叁玖领域 2025-03-07 17:00:17 +08:00
parent 2d2cc256cf
commit 98df1edffc
4 changed files with 4 additions and 63 deletions

View File

@ -129,9 +129,9 @@ repositories {
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so. // If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver // See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
// flatDir { flatDir {
// dir 'libs' dir 'libs'
// } }
} }
dependencies { dependencies {
@ -143,13 +143,12 @@ dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
implementation 'org.spongepowered:mixin:0.8.5' implementation 'org.spongepowered:mixin:0.8.5'
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
compileOnly files("libs/modernlife-1.20.1-1.74.jar")
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}") // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}") // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}") // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
implementation fg.deobf("blank:modernlife-1.20.1:1.74")
// Example mod dependency using a mod jar from ./libs with a flat dir repository // Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
// The group id is ignored when searching -- in this case, it is "blank" // The group id is ignored when searching -- in this case, it is "blank"

Binary file not shown.

View File

View File

@ -22,64 +22,6 @@ import java.util.List;
@Mixin(CameraItem.class) @Mixin(CameraItem.class)
public abstract class MixinCamera { public abstract class MixinCamera {
@Unique
private static int modernLifePatch$toInternalRgbFormat(int nativeRgb) {
int r = nativeRgb & 255;
int g = (nativeRgb & '\uff00') >> 8;
int b = (nativeRgb & 16711680) >> 16;
return r << 16 | g << 8 | b;
}
@Inject(method = {"getAverageRgbAt"}, at = @At("HEAD"), remap = false, cancellable = true)
private static void getAverageRgbAt(NativeImage img, int x, int y, float pixelSampleWidth, float pixelSampleHeight, CallbackInfoReturnable<Integer> cir) {
try {
int destX = (int) ((float) x * pixelSampleWidth);
int destY = (int) ((float) y * pixelSampleHeight);
int rSum = 0;
int gSum = 0;
int bSum = 0;
int iterations = 0;
int hStart = (int) (-pixelSampleHeight / 2.0F);
int hEnd = (int) (pixelSampleHeight / 2.0F);
int wStart = (int) (-pixelSampleWidth / 2.0F);
int wEnd = (int) (pixelSampleWidth / 2.0F);
ModernLifePatch.logger.info("[ModernLifePatch.MixinCamera] pixelSampleHeight: {} , pixelSampleWidth: {}", pixelSampleHeight, pixelSampleWidth);
if (hStart == hEnd) {
hStart = 0;
hEnd = 1;
wStart = 0;
wEnd = 1;
}
int h;
int w;
int finalX;
ModernLifePatch.logger.info("[ModernLifePatch.MixinCamera] hEnd: {} , wEnd: {}", hEnd, wEnd);
for (h = hStart; h < hEnd; ++h) {
for (w = wStart; w < wEnd; ++w) {
finalX = destX + w;
int finalY = destY + h;
finalX = Math.max(finalX, 0);
finalY = Math.max(finalY, 0);
finalX = Math.min(finalX, img.getWidth() - 1);
finalY = Math.min(finalY, img.getHeight() - 1);
int rgb = modernLifePatch$toInternalRgbFormat(img.getPixelRGBA(finalX, finalY));
rSum += CanvasData.getRValue(rgb);
gSum += CanvasData.getGValue(rgb);
bSum += CanvasData.getBValue(rgb);
++iterations;
}
}
ModernLifePatch.logger.info("[ModernLifePatch.MixinCamera] rSum: {} , gSum: {}, bSum: {}", rSum, gSum, bSum);
ModernLifePatch.logger.info("[ModernLifePatch.MixinCamera] iterations: {} ", iterations);
h = rSum / iterations;
w = gSum / iterations;
finalX = bSum / iterations;
cir.setReturnValue(h << 16 | w << 8 | finalX);
} catch(ArrayIndexOutOfBoundsException e) {
cir.setReturnValue(0xffffffff);
}
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true) @Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, Level world, List<Component> text, TooltipFlag flag, CallbackInfo ci) { public void appendHoverText(ItemStack itemStack, Level world, List<Component> text, TooltipFlag flag, CallbackInfo ci) {
int photoCount = 0; int photoCount = 0;