-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to modify max item stack sizes up to 1 billion items pe…
…r slot. in common.json set `remove_slot_limit` to true, and `default_max_stack_size` to anything between 1 and 1000000000
- Loading branch information
1 parent
eb779b3
commit 2313238
Showing
7 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/dev/latvian/mods/kubejs/core/mixin/ContainerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
package dev.latvian.mods.kubejs.core.mixin; | ||
|
||
import dev.latvian.mods.kubejs.CommonProperties; | ||
import dev.latvian.mods.kubejs.core.ContainerKJS; | ||
import net.minecraft.world.Container; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
|
||
@Mixin(Container.class) | ||
public interface ContainerMixin extends ContainerKJS { | ||
@ModifyConstant(method = "getMaxStackSize()I", constant = @Constant(intValue = 99)) | ||
private int kjs$maxSlotSize(int original) { | ||
return CommonProperties.get().getMaxSlotSize(original); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/dev/latvian/mods/kubejs/core/mixin/DataComponentsMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package dev.latvian.mods.kubejs.core.mixin; | ||
|
||
import dev.latvian.mods.kubejs.CommonProperties; | ||
import net.minecraft.core.component.DataComponents; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
|
||
@Mixin(DataComponents.class) | ||
public class DataComponentsMixin { | ||
@ModifyConstant(method = "lambda$static$1", constant = @Constant(intValue = 99)) | ||
private static int kjs$maxSlotSize(int original) { | ||
return CommonProperties.get().getMaxSlotSize(original); | ||
} | ||
|
||
@ModifyConstant(method = "<clinit>", constant = @Constant(intValue = 64)) | ||
private static int kjs$maxStackSize(int original) { | ||
return CommonProperties.get().getMaxStackSize(original); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/dev/latvian/mods/kubejs/core/mixin/GuiGraphicsMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package dev.latvian.mods.kubejs.core.mixin; | ||
|
||
import dev.latvian.mods.kubejs.CommonProperties; | ||
import dev.latvian.mods.kubejs.client.KubeJSClient; | ||
import net.minecraft.client.gui.Font; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(GuiGraphics.class) | ||
public abstract class GuiGraphicsMixin { | ||
@Unique | ||
private final int[] kjs$itemSize = new int[3]; | ||
|
||
@Inject(method = "renderItemDecorations(Lnet/minecraft/client/gui/Font;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;drawString(Lnet/minecraft/client/gui/Font;Ljava/lang/String;IIIZ)I", shift = At.Shift.BEFORE)) | ||
private void kjs$beforeDrawSize(Font font, ItemStack stack, int x, int y, String text, CallbackInfo ci) { | ||
if (text == null && CommonProperties.get().removeSlotLimit && CommonProperties.get().customStackSizeText && stack.getCount() > 1) { | ||
kjs$itemSize[0] = stack.getCount(); | ||
kjs$itemSize[1] = x; | ||
kjs$itemSize[2] = y; | ||
} else { | ||
kjs$itemSize[0] = 0; | ||
} | ||
} | ||
|
||
@Inject(method = "renderItemDecorations(Lnet/minecraft/client/gui/Font;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;drawString(Lnet/minecraft/client/gui/Font;Ljava/lang/String;IIIZ)I", shift = At.Shift.AFTER)) | ||
private void kjs$afterDrawSize(Font font, ItemStack stack, int x, int y, String text, CallbackInfo ci) { | ||
kjs$itemSize[0] = 0; | ||
} | ||
|
||
@Inject(method = "drawString(Lnet/minecraft/client/gui/Font;Ljava/lang/String;IIIZ)I", at = @At("HEAD"), cancellable = true) | ||
private void kjs$drawString(Font font, String text, int x, int y, int color, boolean dropShadow, CallbackInfoReturnable<Integer> cir) { | ||
if (kjs$itemSize[0] != 0) { | ||
cir.setReturnValue(KubeJSClient.drawStackSize((GuiGraphics) (Object) this, font, kjs$itemSize[0], kjs$itemSize[1], kjs$itemSize[2], color, dropShadow)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters