Skip to content

Commit

Permalink
Magical Blessing Again
Browse files Browse the repository at this point in the history
Crash / error fix for Magical Blessing when no available potions are found.
Locale safety for potion lowercase
Added some debug messages
Config typo Fix
Bump Version
  • Loading branch information
Charles445 committed Jun 21, 2021
1 parent fbedd87 commit 35d8fef
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "0.5.1"
version = "0.5.2"
group = "com.Shultrea.Rin" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "SoManyEnchantments"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,19 @@ public void HandleEnchant(LivingHurtEvent fEvent)

if(EnchantmentsUtility.RANDOM.nextBoolean()){
Potion negaPotion = EnchantmentsUtility.getNonInstantNegativePotion();
fEvent.getEntityLiving().addPotionEffect(new PotionEffect(negaPotion, (MathHelper.clamp(EnchantmentsUtility.RANDOM.nextInt(6), 0, Integer.MAX_VALUE) + 1) * 20 * level, MathHelper.clamp(EnchantmentsUtility.RANDOM.nextInt(level) - 1, 0, Integer.MAX_VALUE)));
if(negaPotion != null)
fEvent.getEntityLiving().addPotionEffect(new PotionEffect(negaPotion, (MathHelper.clamp(EnchantmentsUtility.RANDOM.nextInt(6), 0, Integer.MAX_VALUE) + 1) * 20 * level, MathHelper.clamp(EnchantmentsUtility.RANDOM.nextInt(level) - 1, 0, Integer.MAX_VALUE)));
}

else {
Potion negaIPotion = EnchantmentsUtility.getInstantNegativePotion();
if(negaIPotion == MobEffects.INSTANT_DAMAGE && fEvent.getEntityLiving().isEntityUndead())
negaIPotion = MobEffects.INSTANT_HEALTH;

fEvent.getEntityLiving().addPotionEffect(new PotionEffect(negaIPotion, 1, MathHelper.clamp(EnchantmentsUtility.RANDOM.nextInt(level) - 1, 0, Integer.MAX_VALUE)));
if(negaIPotion != null)
{
if(negaIPotion == MobEffects.INSTANT_DAMAGE && fEvent.getEntityLiving().isEntityUndead())
negaIPotion = MobEffects.INSTANT_HEALTH;

fEvent.getEntityLiving().addPotionEffect(new PotionEffect(negaIPotion, 1, MathHelper.clamp(EnchantmentsUtility.RANDOM.nextInt(level) - 1, 0, Integer.MAX_VALUE)));
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/Shultrea/Rin/Main_Sector/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static class MiscellaneousConfig
public String[] potionBlacklist = new String[]{"examplemod:registryname"};

@Config.Comment("Whether the blacklist should be treated as a whitelist")
@Config.Name("Potin Blacklist as Whitelist")
@Config.Name("Potion Blacklist as Whitelist")
@Config.RequiresMcRestart
public boolean potionBlacklistAsWhitelist = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class somanyenchantments {
// Mod Info
public static final String MODID = "somanyenchantments";
public static final String NAME = "Rin's So Many Enchantments?";
public static final String VERSION = "0.5.1";
public static final String VERSION = "0.5.2";
// Mod Info End

//Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.util.Map;
import java.util.Random;

import javax.annotation.Nullable;

import com.Shultrea.Rin.Enchantments_Sector.Smc_030;
import com.Shultrea.Rin.Main_Sector.ModConfig;
import com.Shultrea.Rin.Main_Sector.somanyenchantments;
Expand Down Expand Up @@ -693,31 +695,50 @@ public static float getDamageAfterMagicAbsorb(float damage, float enchantModifie
return damage * (1.0F - f / 80.0F);
}


public static Potion getNonInstantNegativePotion(){
@Nullable
public static Potion getNonInstantNegativePotion()
{

if(PotionLister.debuff_ids.size() == 0)
return null;

int cycles = RANDOM.nextInt(PotionLister.debuff_ids.size());

return Potion.getPotionById(PotionLister.debuff_ids.get(cycles));

}

@Nullable
public static Potion getInstantNegativePotion(){

if(PotionLister.debuff_instant_ids.size() == 0)
return null;

int cycles = RANDOM.nextInt(PotionLister.debuff_instant_ids.size());

return Potion.getPotionById(PotionLister.debuff_instant_ids.get(cycles));

}
public static Potion getNonInstantPositivePotion(){

@Nullable
public static Potion getNonInstantPositivePotion()
{
if(PotionLister.buff_ids.size() == 0)
return null;

int cycles = RANDOM.nextInt(PotionLister.buff_ids.size());

return Potion.getPotionById(PotionLister.buff_ids.get(cycles));

}
public static Potion getInstantPositivePotion(){

@Nullable
public static Potion getInstantPositivePotion()
{

if(PotionLister.buff_instant_ids.size() == 0)
return null;

int cycles = RANDOM.nextInt(PotionLister.buff_instant_ids.size());

return Potion.getPotionById(PotionLister.buff_instant_ids.get(cycles));
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/Shultrea/Rin/Utility_Sector/PotionLister.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import com.Shultrea.Rin.Main_Sector.ModConfig;

Expand Down Expand Up @@ -33,7 +34,7 @@ public static void Cycle()
potionBlacklist.clear();
for(String str : ModConfig.miscellaneous.potionBlacklist)
{
potionBlacklist.add(str.toLowerCase());
potionBlacklist.add(str.toLowerCase(Locale.ENGLISH));
}

//Config Support in future
Expand All @@ -43,7 +44,7 @@ public static void Cycle()
//if(potentialPotion == null)
// continue;

String potionName = p.getRegistryName().toString().toLowerCase();
String potionName = p.getRegistryName().toString().toLowerCase(Locale.ENGLISH);
boolean listMatch = potionBlacklist.contains(potionName);

//If there is a match and using a whitelist
Expand Down Expand Up @@ -83,12 +84,19 @@ public static void Cycle()
break;

}

SMElogM.logger.debug("PotionLister accepting potion : "+potionName);
}
else
{
//Potion was skipped
SMElogM.logger.debug("PotionLister skipping potion : "+potionName);
}
}

SMElogM.logger.debug("PotionLister Instant Debuffs: "+debuff_instant_ids.size());
SMElogM.logger.debug("PotionLister Debuffs: "+debuff_ids.size());


}
}

0 comments on commit 35d8fef

Please sign in to comment.