Skip to content

Commit

Permalink
Merge pull request #74 from telvarost/73-implement-new-configuration-…
Browse files Browse the repository at this point in the history
…toggles-and-fix-flint-and-steel-being-consumed-when-fire-is-relit

73 implement new configuration toggles and fix flint and steel being consumed when fire is relit
  • Loading branch information
telvarost authored Feb 3, 2024
2 parents 08f20b3 + 18eb9f0 commit f4d2c58
Show file tree
Hide file tree
Showing 11 changed files with 444 additions and 151 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The aim of this mod is to fix (major) annoyances or backport useful features tha
- Flowing lava now disappears when lava source block is removed
- Chicken bounding box was increased to modern Minecraft bounding box size
- Water spring propagation has been fixed: https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/1283147-water-spring-propagation-fix
- Also: most fixes are toggleable!
- Also: almost all fixes are toggleable!

To use pick block: Look at something and click your scroll wheel. If it's in your inventory, it will automatically be selected.

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=b1.7.3-build.2
loader_version=0.14.24-babric.1

# Mod Properties
mod_version=2.1.2
mod_version=2.2.0
maven_group=com.github.telvarost
archives_base_name=AnnoyanceFix

Expand Down
123 changes: 120 additions & 3 deletions src/main/java/com/github/telvarost/annoyancefix/Config.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,134 @@
package com.github.telvarost.annoyancefix;

import blue.endless.jankson.Comment;
import net.glasslauncher.mods.api.gcapi.api.ConfigCategory;
import net.glasslauncher.mods.api.gcapi.api.ConfigName;
import net.glasslauncher.mods.api.gcapi.api.GConfig;
import net.glasslauncher.mods.api.gcapi.api.MaxLength;

public class Config {

@GConfig(value = "config", visibleName = "AnnoyanceFix Config")
public static ConfigFields config = new ConfigFields();

public static class AxesConfig {

@ConfigName("Effective On Workbench")
public static Boolean enableAxesEffectiveOnWorkbench = true;

@ConfigName("Effective On Noteblock")
public static Boolean enableAxesEffectiveOnNoteblock = true;

@ConfigName("Effective On Wood Door")
public static Boolean enableAxesEffectiveOnWoodDoor = true;

@ConfigName("Effective On Ladders")
public static Boolean enableAxesEffectiveOnLadders = true;

@ConfigName("Effective On Signs")
public static Boolean enableAxesEffectiveOnSigns = true;

@ConfigName("Effective On Wood Pressure Plate")
public static Boolean enableAxesEffectiveOnWoodPressurePlate = true;

@ConfigName("Effective On Jukebox")
public static Boolean enableAxesEffectiveOnJukebox = true;

@ConfigName("Effective On Wood Stairs")
public static Boolean enableAxesEffectiveOnWoodStairs = true;

@ConfigName("Effective On Fence")
public static Boolean enableAxesEffectiveOnFence = true;

@ConfigName("Effective On Pumpkin")
public static Boolean enableAxesEffectiveOnPumpkin = true;

@ConfigName("Effective On Jack o Lantern")
public static Boolean enableAxesEffectiveOnJackOLantern = true;

@ConfigName("Effective On Trapdoor")
public static Boolean enableAxesEffectiveOnTrapdoor = true;
}

public static class PickaxesConfig {

@ConfigName("Effective On Dispenser")
public static Boolean enablePickaxesEffectiveOnDispenser = true;

@ConfigName("Effective On Normal Rails")
public static Boolean enablePickaxesEffectiveOnNormalRails = true;

@ConfigName("Effective On Detector Rails")
public static Boolean enablePickaxesEffectiveOnDetectorRails = true;

@ConfigName("Effective On Golden Rails")
public static Boolean enablePickaxesEffectiveOnGoldenRails = true;

@ConfigName("Effective On Furnace")
public static Boolean enablePickaxesEffectiveOnFurnace = true;

@ConfigName("Effective On Furnace Lit")
public static Boolean enablePickaxesEffectiveOnFurnaceLit = true;

@ConfigName("Effective On Cobblestone Stairs")
public static Boolean enablePickaxesEffectiveOnCobblestoneStairs = true;

@ConfigName("Effective On Stone Pressure Plate")
public static Boolean enablePickaxesEffectiveOnStonePressurePlate = true;

@ConfigName("Effective On Iron Door")
public static Boolean enablePickaxesEffectiveOnIronDoor = true;

@ConfigName("Effective On Redstone Ore")
public static Boolean enablePickaxesEffectiveOnRedstoneOre = true;

@ConfigName("Effective On Redstone Ore Lit")
public static Boolean enablePickaxesEffectiveOnRedstoneOreLit = true;

@ConfigName("Effective On Stone Button")
public static Boolean enablePickaxesEffectiveOnStoneButton = true;

@ConfigName("Effective On Bricks")
public static Boolean enablePickaxesEffectiveOnBricks = true;

@ConfigName("Effective On Mob Spawner")
public static Boolean enablePickaxesEffectiveOnMobSpawner = true;
}

public static class RecipesConfig {

@ConfigName("Crafting: Repair Armor")
public static Boolean recipesRepairArmorEnabled = true;

@ConfigName("Crafting: Repair Tools")
public static Boolean recipesRepairToolsEnabled = true;

@ConfigName("Furnace: Add More Wood Items As Fuel")
public static Boolean recipesAdditionalWoodFuelsEnabled = true;

}

public static class ConfigFields {

@ConfigName("Boat Fixes Enabled")
public static Boolean boatFixesEnabled = true;
@ConfigCategory("Config: Axes Are Effective Against")
@Comment("Options here require restart to take effect")
public static final AxesConfig AXES_CONFIG = new AxesConfig();

@ConfigCategory("Config: Pickaxes Are Effective Against")
@Comment("Options here require restart to take effect")
public static final PickaxesConfig PICKAXES_CONFIG = new PickaxesConfig();

@ConfigCategory("Config: Recipes/Fuels For Crafting/Furnaces")
@Comment("Options here require restart to take effect")
public static final RecipesConfig RECIPES_CONFIG = new RecipesConfig();

@ConfigName("Boat Drop Fixes Enabled")
public static Boolean boatDropFixesEnabled = true;

@ConfigName("Boat Speed Collision Behavior")
@MaxLength(3)
@Comment("0 = vanilla, 1 = drop boat, 2 = invincible")
public static Integer boatCollisionBehavior = 2;

@ConfigName("Bookshelf Fixes Enabled")
public static Boolean bookshelfFixesEnabled = true;
Expand Down Expand Up @@ -43,7 +160,7 @@ public static class ConfigFields {
@ConfigName("Water Fixes Enabled")
public static Boolean waterFixesEnabled = true;

@ConfigName("Wooden Slab Fixes Enabled (Experimental)")
@ConfigName("Wood Slab Fixes Enabled (Experimental)")
public static Boolean woodenSlabFixesEnabled = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ public static class ModHelperFields {

/** @brief - Special data for remembering block type */
public static BlockTypeEnum blockType = BlockTypeEnum.BLOCK_IS_NOT_A_SLAB;

/** @brief - Special data for flint and steel fixes */
public static Boolean isFireLit = false;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.telvarost.annoyancefix.events;

import com.github.telvarost.annoyancefix.Config;
import net.mine_diver.unsafeevents.listener.EventListener;
import net.modificationstation.stationapi.api.event.container.slot.ItemUsedInCraftingEvent;

Expand All @@ -23,27 +24,30 @@ public void combineDurability(ItemUsedInCraftingEvent event) {
&& (true == event.itemCrafted.hasDurability())
)
{
int craftedItemMaxDurability = event.itemCrafted.getDurability();
int durabilityToAdd = event.itemUsed.getDurability() - event.itemUsed.getDamage();
int newDurability = craftedItemMaxDurability - event.itemCrafted.getDamage();
int damageToSet = 0;

/** - If this is the first item's durability being added, add a 5% repair buff */
if (craftedItemMaxDurability == event.itemCrafted.getDamage())
{
durabilityToAdd = durabilityToAdd + (int)floor((double)craftedItemMaxDurability / 20);
if ( (Config.RecipesConfig.recipesRepairArmorEnabled)
|| (Config.RecipesConfig.recipesRepairToolsEnabled)
) {
int craftedItemMaxDurability = event.itemCrafted.getDurability();
int durabilityToAdd = event.itemUsed.getDurability() - event.itemUsed.getDamage();
int newDurability = craftedItemMaxDurability - event.itemCrafted.getDamage();
int damageToSet = 0;

/** - If this is the first item's durability being added, add a 5% repair buff */
if (craftedItemMaxDurability == event.itemCrafted.getDamage()) {
durabilityToAdd = durabilityToAdd + (int) floor((double) craftedItemMaxDurability / 20);
}

newDurability = newDurability + durabilityToAdd;

/** - Only calculate damage if new durability is below max durability
* Otherwise, new durability is above max durability and damage to set will remain zero
*/
if (craftedItemMaxDurability > newDurability) {
damageToSet = craftedItemMaxDurability - newDurability;
}

event.itemCrafted.setDamage(damageToSet);
}

newDurability = newDurability + durabilityToAdd;

/** - Only calculate damage if new durability is below max durability
* Otherwise, new durability is above max durability and damage to set will remain zero
*/
if (craftedItemMaxDurability > newDurability) {
damageToSet = craftedItemMaxDurability - newDurability;
}

event.itemCrafted.setDamage(damageToSet);
}
}
}
Loading

0 comments on commit f4d2c58

Please sign in to comment.