Increase JVM memory pool in gradle script

Allow debug card to insert huge amounts of items, e.g. to fill infinity chest
This commit is contained in:
repo_alt 2021-12-28 11:50:29 +03:00
parent 9e869814d4
commit 72793aff25
3 changed files with 19 additions and 4 deletions

2
gradlew vendored
View File

@ -44,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
DEFAULT_JVM_OPTS='"-Xmx2G" "-Xms128m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

2
gradlew.bat vendored
View File

@ -30,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
set DEFAULT_JVM_OPTS="-Xmx2G" "-Xms128m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View File

@ -619,7 +619,7 @@ object DebugCard {
if (item == null) {
throw new IllegalArgumentException("invalid item id")
}
val count = args.checkInteger(1)
var count = args.checkInteger(1)
val damage = args.checkInteger(2)
val tagJson = args.optString(3, "")
val tag = if (Strings.isNullOrEmpty(tagJson)) null else JsonToNBT.func_150315_a(tagJson).asInstanceOf[NBTTagCompound]
@ -629,7 +629,22 @@ object DebugCard {
case Some(inventory) =>
val stack = new ItemStack(item, count, damage)
stack.setTagCompound(tag)
result(InventoryUtils.insertIntoInventory(stack, inventory, Option(side)))
val res = InventoryUtils.insertIntoInventory(stack, inventory, Option(side), count)
if (!res)
result(res)
else {
var stored = count - stack.stackSize
while (stored > 0 && stack.stackSize > 0) {
count = stack.stackSize
// InventoryUtils.insertIntoInventory honors max stack size for the stack,
// but debug card may ignore that e.g. for infinity chest
// so we try to insert the rest until we fail
if (!InventoryUtils.insertIntoInventory(stack, inventory, Option(side), count))
return result(true)
stored = count - stack.stackSize
}
result(true)
}
case _ => result(Unit, "no inventory")
}
}