fix rosehip syrup crash (#47)

Co-authored-by: Maya <10861407+serenibyss@users.noreply.github.com>
This commit is contained in:
giantcavespiderandMaya authored and GitHub committed 2025-04-02 15:21:30 +00:00
1 parent ed5f46fc21
commit 6df8683a0c
5 files changed
+34 -22

No files matched your search

Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -3
View File
@@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -206,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.31'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.37'
}
@@ -17,6 +17,9 @@ import thaumcraft.common.config.ConfigItems;
public class ItemRosehipSyrup extends Item {
public final static int REMOVE_EFFECT = 1;
public final static int REDUCE_EFFECT = 2;
public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player) {
player.setItemInUse(stack, getMaxItemUseDuration(stack));
return stack;
@@ -44,10 +47,12 @@ public class ItemRosehipSyrup extends Item {
Collection<PotionEffect> c = player.getActivePotionEffects();
Iterator<PotionEffect> $i = c.iterator();
ArrayList<Integer> removeEffects = new ArrayList<Integer>();
ArrayList<PotionEffect> reduceEffects = new ArrayList<PotionEffect>();
while ($i.hasNext()) {
PotionEffect effect = $i.next();
int i = processPotion(player, effect);
if (i != -1) removeEffects.add(i);
int i = processPotion(effect);
if (i == REMOVE_EFFECT) removeEffects.add(effect.getPotionID());
else if (i == REDUCE_EFFECT) reduceEffects.add(effect);
}
for (int i = 0; i < removeEffects.size(); ++i) {
@@ -58,29 +63,36 @@ public class ItemRosehipSyrup extends Item {
}
}
}
for (int i = 0; i < reduceEffects.size(); ++i) {
PotionEffect j = reduceEffects.get(i);
if (j != null) {
int k = j.getPotionID();
if (k != -1 && k < Potion.potionTypes.length
&& player.getActivePotionEffect(Potion.potionTypes[k]) != null) {
reflectPotionEffect(player, j);
}
}
}
}
return stack.stackSize <= 0 ? new ItemStack(ConfigItems.itemEssence, 1, 0) : stack;
}
public static int processPotion(EntityPlayer p, PotionEffect effect) {
public static int processPotion(PotionEffect effect) {
if (effect != null && effect.getPotionID() < Potion.potionTypes.length
&& Potion.potionTypes[effect.getPotionID()] != null) {
if (isBadEffect(Potion.potionTypes[effect.getPotionID()])) return effect.getPotionID();
if (canRemoveEffect(Potion.potionTypes[effect.getPotionID()])) return REMOVE_EFFECT;
if (canDecreaseLevel(Potion.potionTypes[effect.getPotionID()])) {
if (effect.getAmplifier() == 0) return effect.getPotionID();
else {
reflectPotionEffect(p, effect);
return -1;
}
if (canDecreaseLevel(effect.getPotionID())) {
if (effect.getAmplifier() == 0) return REMOVE_EFFECT;
else return REDUCE_EFFECT;
}
}
return -1;
return 0;
}
public static boolean isBadEffect(Potion p) {
public static boolean canRemoveEffect(Potion p) {
return p != null && (p == Potion.blindness || p == Potion.confusion
|| p == Potion.digSlowdown
|| p == Potion.hunger
@@ -90,13 +102,12 @@ public class ItemRosehipSyrup extends Item {
|| p == Potion.wither);
}
public static boolean canDecreaseLevel(Potion p) {
int id = p.getId();
return p != null && (id == Config.potionBlurredID || id == Config.potionInfVisExhaustID
public static boolean canDecreaseLevel(int id) {
return id == Config.potionBlurredID || id == Config.potionInfVisExhaustID
|| id == Config.potionTaintPoisonID
|| id == Config.potionThaumarhiaID
|| id == Config.potionUnHungerID
|| id == Config.potionVisExhaustID);
|| id == Config.potionVisExhaustID;
}
public static void reflectPotionEffect(EntityPlayer p, PotionEffect effect) {
@@ -104,7 +115,9 @@ public class ItemRosehipSyrup extends Item {
int id = effect.getPotionID();
int dur = effect.getDuration();
boolean transparent = effect.getIsAmbient();
PotionEffect neweffect = new PotionEffect(id, dur, amp, transparent);
neweffect.setCurativeItems(effect.getCurativeItems());
p.removePotionEffect(effect.getPotionID());
p.addPotionEffect(new PotionEffect(id, dur, amp, transparent));
p.addPotionEffect(neweffect);
}
}