From 3ad3309e43383da068e1a52bae16dc45d512a4d9 Mon Sep 17 00:00:00 2001 From: asofold Date: Tue, 22 Jan 2013 19:56:07 +0100 Subject: [PATCH] Correct block break time penalties for under-water and off-ground. Also adds API to get and set those. --- .../utilities/BlockProperties.java | 55 ++++++++++++++++--- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java b/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java index bce8d052..95f4a909 100644 --- a/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java +++ b/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java @@ -271,6 +271,11 @@ public class BlockProperties { public static final int F_HEIGHT100 = 0x100; /** Climbable like ladder and vine (allow to land on without taking damage). */ public static final int F_CLIMBABLE = 0x200; + + /** Penalty factor for block break duration if under water. */ + protected static float breakPenaltyInWater = 4f; + /** Penalty factor for block break duration if not on ground. */ + protected static float breakPenaltyOffGround = 4f; public static void init(final MCAccess mcAccess) { blockCache = mcAccess.getBlockCache(null); @@ -740,10 +745,10 @@ public class BlockProperties { // (sword vs web already counted) if (isValidTool || blockProps.tool.toolType == ToolType.NONE){ - long mult = 1; - if (inWater && !aquaAffinity) mult *= 5; - if (!onGround) mult *= 5; - duration *= mult; + float mult = 1f; + if (inWater && !aquaAffinity) mult *= breakPenaltyInWater; + if (!onGround) mult *= breakPenaltyOffGround; + duration = (long) (mult * duration); // Efficiency level. if (efficiency > 0) { @@ -752,15 +757,15 @@ public class BlockProperties { // Heck [Cleanup pending]... switch (efficiency) { case 1: - return 1500 * mult; + return (long) (mult * 1500); case 2: - return 750 * mult; + return (long) (mult * 750); case 3: - return 450 * mult; + return (long) (mult * 450); case 4: - return 250 * mult; + return (long) (mult * 250); case 5: - return 150 * mult; + return (long) (mult * 150); } } // This seems roughly correct. @@ -1370,4 +1375,36 @@ public class BlockProperties { } return flags; } + + /** + * Penalty factor for block break duration if under water. + * @return + */ + public static float getBreakPenaltyInWater() { + return breakPenaltyInWater; + } + + /** + * Penalty factor for block break duration if under water. + * @param breakPenaltyInWater + */ + public static void setBreakPenaltyInWater(float breakPenaltyInWater) { + BlockProperties.breakPenaltyInWater = breakPenaltyInWater; + } + + /** + * Penalty factor for block break duration if not on ground. + * @return + */ + public static float getBreakPenaltyOffGround() { + return breakPenaltyOffGround; + } + + /** + * Penalty factor for block break duration if not on ground. + * @param breakPenaltyOffGround + */ + public static void setBreakPenaltyOffGround(float breakPenaltyOffGround) { + BlockProperties.breakPenaltyOffGround = breakPenaltyOffGround; + } }