Skip to content

Commit

Permalink
Allow negative values for dropChanceIncrease
Browse files Browse the repository at this point in the history
(cherry picked from commit 6ff5ffc)
  • Loading branch information
ljfa-ag committed May 23, 2015
1 parent e8fe937 commit ded6019
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main/java/ljfa/tntutils/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public static void loadConfig(File file) {
public static void loadValues() {
explosionCommand = conf.get(CAT_GENERAL, "addExplosionCommand", true, "Adds the \"/explosion\" command").setRequiresMcRestart(true).getBoolean();
sizeMultiplier = (float)conf.get(CAT_GENERAL, "sizeMultiplier", 1.0, "Multiplies the size of all explosions by this", 0.0, 50.0).getDouble();
dropChanceModifier = (float)conf.get(CAT_GENERAL, "dropChanceIncrease", 0.0, "Increases the chance that explosions will drop destroyed blocks as items\n"
+ "0 = Vanilla behavior, 1 = always drop items.\n"
+ "Only affects explosions of size <= 10 since a large number of dropped items can cause lag.", 0.0, 1.0).getDouble();
dropChanceModifier = (float)conf.get(CAT_GENERAL, "dropChanceIncrease", 0.0, "Modifies the chance that explosions will drop destroyed blocks as items\n"
+ "-1 = never drop anything, 0 = Vanilla behavior, 1 = always drop items.\n"
+ "Increasing will only affect explosions of size <= 10 since a large number of dropped items can cause lag.", -1.0, 1.0).getDouble();
disableExplosions = conf.get(CAT_GENERAL, "disableExplosions", false, "Entirely disables all effects from explosions").getBoolean();
preventChainExpl = conf.get(CAT_GENERAL, "preventChainExplosions", false, "Prevents explosions from triggering TNT and thus disables chain explosions").setRequiresMcRestart(true).getBoolean();
disableTNT = conf.get(CAT_GENERAL, "disableTNT", false, "Disables TNT explosions").setRequiresMcRestart(true).getBoolean();
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/ljfa/tntutils/asm/HooksExplosion.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ public class HooksExplosion {

public static float getDropChance(Explosion expl) {
float baseChance = 1.0f / expl.explosionSize;
if(expl.explosionSize <= alwaysDropThreshold)
return baseChance + Config.dropChanceModifier * (1.0f - baseChance);
else
if(Config.dropChanceModifier == 0.0f)
return baseChance;
else if(Config.dropChanceModifier > 0.0f) {
if(expl.explosionSize <= alwaysDropThreshold)
return baseChance + Config.dropChanceModifier * (1.0f - baseChance);
else
return baseChance;
} else
return (1.0f + Config.dropChanceModifier) * baseChance;
}
}

0 comments on commit ded6019

Please sign in to comment.