From ecbe2ba88479ee442f83f24bc1d258c588a47d60 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 4 Aug 2014 10:47:45 +0200 Subject: [PATCH] Add a config option to make all non-tinker tools unusable. >:) --- .../iguanatweakstconstruct/lang/en_US.lang | 2 + .../harvestlevels/VanillaToolTipHandler.java | 7 ++- .../reference/Config.java | 4 ++ .../tweaks/IguanaTweaks.java | 5 ++ .../handler/VanillaToolNerfHandler.java | 49 +++++++++++++++++++ 5 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/main/java/iguanaman/iguanatweakstconstruct/tweaks/handler/VanillaToolNerfHandler.java diff --git a/resources/assets/iguanatweakstconstruct/lang/en_US.lang b/resources/assets/iguanatweakstconstruct/lang/en_US.lang index 1c8aaf1..0b7e46b 100644 --- a/resources/assets/iguanatweakstconstruct/lang/en_US.lang +++ b/resources/assets/iguanatweakstconstruct/lang/en_US.lang @@ -67,6 +67,8 @@ tooltip.level.skill.5=Expert tooltip.level.skill.6=Master tooltip.mobhead.level=Applicable up to: %s +tooltip.uselessTool=This tool cannot mine anything! +tooltip.uselessTool2=It can only be used for crafting item.iguana.tcon.clayBucket.name=Clay Bucket item.iguana.tcon.clayBucketUnfired.name=Unfired Clay Bucket diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/harvestlevels/VanillaToolTipHandler.java b/src/main/java/iguanaman/iguanatweakstconstruct/harvestlevels/VanillaToolTipHandler.java index c452f85..3965484 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/harvestlevels/VanillaToolTipHandler.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/harvestlevels/VanillaToolTipHandler.java @@ -2,10 +2,10 @@ package iguanaman.iguanatweakstconstruct.harvestlevels; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import iguanaman.iguanatweakstconstruct.leveling.LevelingTooltips; -import net.minecraft.item.ItemPickaxe; +import iguanaman.iguanatweakstconstruct.reference.Config; +import iguanaman.iguanatweakstconstruct.tweaks.handler.VanillaToolNerfHandler; import net.minecraft.item.ItemTool; import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import tconstruct.library.tools.ToolCore; public class VanillaToolTipHandler { @@ -17,6 +17,9 @@ public class VanillaToolTipHandler { if(!(event.itemStack.getItem() instanceof ItemTool)) return; + if(Config.nerfVanillaTools && VanillaToolNerfHandler.isUselessTool(event.itemStack.getItem())) + return; + // we're only interested in stuff that's basically a pickaxe int hlvl = event.itemStack.getItem().getHarvestLevel(event.itemStack, "pickaxe"); if (hlvl >= 0) diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java b/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java index d197e33..c060e7d 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/reference/Config.java @@ -52,6 +52,7 @@ public class Config { public static int beheadingHeadDropChance; // tweaks + public static boolean nerfVanillaTools; public static boolean removeFlintDrop; public static boolean addFlintRecipe; public static int recipeGravelPerFlint; @@ -143,12 +144,15 @@ public class Config { /** Vanilla/TConstruct Tweaks **/ configfile.setCategoryComment(CATEGORY_Tweaks, "Tweak Module: Tweaks to vanilla Minecraft and Tinker's Construct"); + nerfVanillaTools = configfile.getBoolean("ohNoYouAreNOTgoingToUseThatTool", CATEGORY_Tweaks, true, "Makes all non-TConstruct tools mine nothing"); + // gravel/flint tweaks removeFlintDrop = configfile.getBoolean("removeFlintDrop", CATEGORY_Tweaks, true, "Removes the random chance of getting flint from gravel"); addFlintRecipe = configfile.getBoolean("addFlintRecipe", CATEGORY_Tweaks, true, "Adds a shapeless recipe to get flint from gravel"); recipeGravelPerFlint = configfile.getInt("gravelPerFlint", CATEGORY_Tweaks, 4, 1, 9, "How many gravel are required to craft one Flint"); // ticon tweaks + // todo: implement? disableStoneTools = configfile.getBoolean("disablestoneTools", CATEGORY_Tweaks, true, "Stone Tools can only be used to create casts, but no tools"); // stuff diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java index 2175f9d..3b0a7c5 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/IguanaTweaks.java @@ -5,6 +5,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import iguanaman.iguanatweakstconstruct.reference.Config; import iguanaman.iguanatweakstconstruct.reference.Reference; import iguanaman.iguanatweakstconstruct.tweaks.handler.FlintHandler; +import iguanaman.iguanatweakstconstruct.tweaks.handler.VanillaToolNerfHandler; import iguanaman.iguanatweakstconstruct.util.Log; import iguanaman.iguanatweakstconstruct.util.RecipeRemover; import mantle.pulsar.pulse.Handler; @@ -29,6 +30,10 @@ public class IguanaTweaks { // flint recipes n stuff FlintTweaks(); + // because diamond pickaxe is hax + if(Config.nerfVanillaTools) + MinecraftForge.EVENT_BUS.register(new VanillaToolNerfHandler()); + // stonetorches if(Config.removeStoneTorchRecipe) { diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/handler/VanillaToolNerfHandler.java b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/handler/VanillaToolNerfHandler.java new file mode 100644 index 0000000..16793f6 --- /dev/null +++ b/src/main/java/iguanaman/iguanatweakstconstruct/tweaks/handler/VanillaToolNerfHandler.java @@ -0,0 +1,49 @@ +package iguanaman.iguanatweakstconstruct.tweaks.handler; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemTool; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; + +public class VanillaToolNerfHandler { + @SubscribeEvent + public void breakSpeed(PlayerEvent.BreakSpeed event) + { + event.newSpeed = event.originalSpeed*10; + if(event.entityPlayer == null) + return; + + ItemStack itemStack = event.entityPlayer.getCurrentEquippedItem(); + if(itemStack == null) + return; + + if(isUselessTool(itemStack.getItem())) + event.newSpeed = 0; + } + + @SubscribeEvent + public void onItemToolTip(ItemTooltipEvent event) { + if (event.entityPlayer == null) + return; + + if(isUselessTool(event.itemStack.getItem())) { + event.toolTip.add(EnumChatFormatting.DARK_RED + StatCollector.translateToLocal("tooltip.uselessTool")); + event.toolTip.add(EnumChatFormatting.DARK_RED + StatCollector.translateToLocal("tooltip.uselessTool2")); + } + } + + public static boolean isUselessTool(Item item) + { + if(item == null) + return false; + + if(item instanceof ItemTool) + return true; + + return false; + } +}