This repository has been archived by the owner on Mar 10, 2021. It is now read-only.
forked from iguanaman/IguanaTweaksTConstruct
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a config option to also disable vanilla Swords and Bows. Who woul…
…d be this evil?
- Loading branch information
Showing
6 changed files
with
151 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/iguanaman/iguanatweakstconstruct/tweaks/handlers/VanillaBowNerfHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/main/java/iguanaman/iguanatweakstconstruct/tweaks/handlers/VanillaSwordNerfHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |