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 also disable vanilla Swords and Bows. Who woul…
Browse files Browse the repository at this point in the history
…d be this evil?
  • Loading branch information
bonii-xx committed Aug 11, 2014
1 parent e12a0af commit e92923e
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 9 deletions.
2 changes: 2 additions & 0 deletions resources/assets/iguanatweakstconstruct/lang/en_US.lang
Expand Up @@ -71,6 +71,8 @@ tooltip.mobhead.level=Applicable up to: %s
tooltip.uselessTool1=This tool cannot mine anything!
tooltip.uselessTool2=It can only be used for crafting
tooltip.uselessHoe1=This hoe cannot hoe anything!
tooltip.uselessWeapon1=This weapon hits like a wet noodle!
tooltip.uselessBow1=This bows bowstring snapped!

tooltip.part.replaceable=Parts can be replaced
tooltip.part.needsmodifier1=Cannot be replaced once added,
Expand Down
Expand Up @@ -21,7 +21,7 @@

public class LevelingToolTipHandler {
// the prefix used for "+ X attack damage". Thanks Tic Tooltips ;)
private static String plusPrefix = "\u00A79+";
public static String plusPrefix = "\u00A79+";

@SubscribeEvent(priority = EventPriority.HIGH) // insert before tic-tooltips
public void onItemToolTip(ItemTooltipEvent event) {
Expand Down
Expand Up @@ -54,6 +54,8 @@ public class Config {
// tweaks
public static boolean nerfVanillaTools;
public static boolean nerfVanillaHoes;
public static boolean nerfVanillaSwords;
public static boolean nerfVanillaBows;
public static boolean removeFlintDrop;
public static boolean addFlintRecipe;
public static int recipeGravelPerFlint;
Expand Down Expand Up @@ -168,8 +170,10 @@ 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");
nerfVanillaHoes = configfile.getBoolean("disableHoes", CATEGORY_Tweaks, false, "Makes all non-TConstruct hoes to not be able to hoe ground. Use the Mattock.");
nerfVanillaTools = configfile.getBoolean("disableRegularTools", CATEGORY_Tweaks, true, "Makes all non-TConstruct tools mine nothing");
nerfVanillaHoes = configfile.getBoolean("disableRegularHoes", CATEGORY_Tweaks, false, "Makes all non-TConstruct hoes to not be able to hoe ground. Use the Mattock.");
nerfVanillaSwords = configfile.getBoolean("disableRegularSwords", CATEGORY_Tweaks, false, "Makes all non-TConstruct swords useless. Like whacking enemies with a stick.");
nerfVanillaBows = configfile.getBoolean("disableRegularBows", CATEGORY_Tweaks, false, "Makes all non-TConstruct bows useless. You suddenly forgot how to use a bow.");

// gravel/flint tweaks
removeFlintDrop = configfile.getBoolean("removeFlintDrop", CATEGORY_Tweaks, true, "Removes the random chance of getting flint from gravel");
Expand All @@ -193,17 +197,21 @@ public void sync()
//repairAmountMultiplier = configfile.getFloat("repairAmountMultiplier", CATEGORY_Tweaks, 1.0f, 0.01f, 9.99f, "A factor that is multiplied onto the amount a tool is repaired. (0.5 = half durability restored per repair, 2.0 = twice as much durability restored per repair)");

/** Allowed tools for nerfed vanilla tools **/
configfile.setCategoryComment(CATEGORY_AllowedTools, "Tweak Module: This category allows you to specify which tools ARE STILL USABLE if the option to disable non-TConstsruct tools is enabled.");
configfile.setCategoryComment(CATEGORY_AllowedTools, "Tweak Module: This category allows you to specify which tools ARE STILL USABLE if the option to disable non-TConstsruct tools is enabled.\nYou can use * as a wildcard if you want to enable all items of a mod. For example minecraft:* would enable all vanilla tools.");
{
String[] picks = configfile.getStringList("pickaxes", CATEGORY_AllowedTools, new String[0], "Pickaxes that shall remain useful");
String[] axes = configfile.getStringList("axes", CATEGORY_AllowedTools, new String[0], "Axes that shall remain useful");
String[] picks = configfile.getStringList("pickaxes", CATEGORY_AllowedTools, new String[0], "Pickaxes that shall remain useful");
String[] shovels = configfile.getStringList("shovels", CATEGORY_AllowedTools, new String[0], "Shovels that shall remain useful");
String[] swords = configfile.getStringList("swords", CATEGORY_AllowedTools, new String[0], "Swords that shall remain useful");
String[] bows = configfile.getStringList("bows", CATEGORY_AllowedTools, new String[0], "bows that shall remain useful");
String[] hoes = configfile.getStringList("hoes", CATEGORY_AllowedTools, new String[0], "Hoes that shall remain useful");
String[] other = configfile.getStringList("unspecified", CATEGORY_AllowedTools, new String[0], "Other tools. I'll be honest, the category doesn't matter, they're just for readability :P");

allowedTools.addAll(Arrays.asList(picks));
allowedTools.addAll(Arrays.asList(axes));
allowedTools.addAll(Arrays.asList(shovels));
allowedTools.addAll(Arrays.asList(swords));
allowedTools.addAll(Arrays.asList(bows));
allowedTools.addAll(Arrays.asList(hoes));
allowedTools.addAll(Arrays.asList(other));
}
Expand Down
Expand Up @@ -4,10 +4,7 @@
import cpw.mods.fml.common.registry.GameRegistry;
import iguanaman.iguanatweakstconstruct.reference.Config;
import iguanaman.iguanatweakstconstruct.reference.Reference;
import iguanaman.iguanatweakstconstruct.tweaks.handlers.FlintHandler;
import iguanaman.iguanatweakstconstruct.tweaks.handlers.StoneToolHandler;
import iguanaman.iguanatweakstconstruct.tweaks.handlers.VanillaHoeNerfHandler;
import iguanaman.iguanatweakstconstruct.tweaks.handlers.VanillaToolNerfHandler;
import iguanaman.iguanatweakstconstruct.tweaks.handlers.*;
import iguanaman.iguanatweakstconstruct.tweaks.modifiers.ModFluxExpensive;
import iguanaman.iguanatweakstconstruct.tweaks.modifiers.ModLimitedToolRepair;
import iguanaman.iguanatweakstconstruct.util.Log;
Expand Down Expand Up @@ -100,6 +97,12 @@ public void postInit(FMLPostInitializationEvent event)
if(Config.nerfVanillaHoes)
MinecraftForge.EVENT_BUS.register(new VanillaHoeNerfHandler());

if(Config.nerfVanillaSwords)
MinecraftForge.EVENT_BUS.register(new VanillaSwordNerfHandler());

if(Config.nerfVanillaBows)
MinecraftForge.EVENT_BUS.register(new VanillaBowNerfHandler());

// stonetorches
if(Config.removeStoneTorchRecipe)
{
Expand Down
@@ -0,0 +1,57 @@
package iguanaman.iguanatweakstconstruct.tweaks.handlers;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import iguanaman.iguanatweakstconstruct.leveling.handlers.LevelingToolTipHandler;
import iguanaman.iguanatweakstconstruct.tweaks.IguanaTweaks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.ArrowNockEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;

import java.util.ListIterator;

public class VanillaBowNerfHandler {
@SubscribeEvent
public void onArrowNock(ArrowNockEvent event)
{
if(event.entityPlayer == null)
return;

if(event.result == null)
return;

if(isUselessBow(event.result.getItem()))
event.setCanceled(true);
}

@SubscribeEvent
public void onItemToolTip(ItemTooltipEvent event) {
if (event.entityPlayer == null)
return;

if(isUselessBow(event.itemStack.getItem())) {
event.toolTip.add(EnumChatFormatting.DARK_RED + StatCollector.translateToLocal("tooltip.uselessBow1"));
event.toolTip.add(EnumChatFormatting.DARK_RED + StatCollector.translateToLocal("tooltip.uselessTool2"));
}
}

public static boolean isUselessBow(Item item)
{
if(item == null)
return false;

if(IguanaTweaks.toolWhitelist.contains(item))
return false;

if(item instanceof ItemBow)
return true;

return false;
}
}
@@ -0,0 +1,72 @@
package iguanaman.iguanatweakstconstruct.tweaks.handlers;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import iguanaman.iguanatweakstconstruct.leveling.handlers.LevelingToolTipHandler;
import iguanaman.iguanatweakstconstruct.tweaks.IguanaTweaks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;

import java.util.ListIterator;

public class VanillaSwordNerfHandler {
@SubscribeEvent
public void onHurt(LivingHurtEvent event)
{
if (!(event.source.damageType.equals("player")))
return;

// only players
if (!(event.source.getEntity() instanceof EntityPlayer))
return;
EntityPlayer player = (EntityPlayer) event.source.getEntity();

// the tool
ItemStack stack = player.getCurrentEquippedItem();
if(stack == null)
return;

if(isUselessWeapon(stack.getItem()))
event.setCanceled(true);
}

@SubscribeEvent
public void onItemToolTip(ItemTooltipEvent event) {
if (event.entityPlayer == null)
return;

if(isUselessWeapon(event.itemStack.getItem())) {
// remove +dmg stuff
ListIterator<String> iter = event.toolTip.listIterator();
while(iter.hasNext())
{
if(iter.next().startsWith(LevelingToolTipHandler.plusPrefix))
iter.remove();
}
event.toolTip.add(EnumChatFormatting.DARK_RED + StatCollector.translateToLocal("tooltip.uselessWeapon1"));
event.toolTip.add(EnumChatFormatting.DARK_RED + StatCollector.translateToLocal("tooltip.uselessTool2"));
}
}

public static boolean isUselessWeapon(Item item)
{
if(item == null)
return false;

if(IguanaTweaks.toolWhitelist.contains(item))
return false;

if(item instanceof ItemSword)
return true;

return false;
}
}

0 comments on commit e92923e

Please sign in to comment.