Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
Add a config option to make all non-tinker tools unusable. >:)
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Aug 4, 2014
1 parent 01420ab commit ecbe2ba
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 2 deletions.
2 changes: 2 additions & 0 deletions resources/assets/iguanatweakstconstruct/lang/en_US.lang
Expand Up @@ -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
Expand Down
Expand Up @@ -2,10 +2,10 @@

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 {

Expand All @@ -17,6 +17,9 @@ public void onItemToolTip(ItemTooltipEvent event) {
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)
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -143,12 +144,15 @@ public void sync()
/** 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
Expand Down
Expand Up @@ -5,6 +5,7 @@
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;
Expand All @@ -29,6 +30,10 @@ public void postInit(FMLPostInitializationEvent event)
// flint recipes n stuff
FlintTweaks();

// because diamond pickaxe is hax
if(Config.nerfVanillaTools)
MinecraftForge.EVENT_BUS.register(new VanillaToolNerfHandler());

// stonetorches
if(Config.removeStoneTorchRecipe)
{
Expand Down
@@ -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;
}
}

0 comments on commit ecbe2ba

Please sign in to comment.