Skip to content

Commit

Permalink
Handle Unbreakable TCon Tool achievement via code (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
glowredman authored Dec 12, 2023
1 parent 76d46c0 commit 598309d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
import cpw.mods.fml.relauncher.Side;
import fox.spiteful.avaritia.items.LudicrousItems;
import tconstruct.library.tools.ToolCore;

public class AchievementHandler {

Expand All @@ -32,6 +34,7 @@ public class AchievementHandler {
public static StatBase eternityBeaconAchievement;
private static StatBase allEffects;
private static StatBase hearts;
private static StatBase unbreakableTool;
private static int numberPotions = 0;

public static void init() {
Expand All @@ -41,6 +44,7 @@ public static void init() {
eternityBeaconAchievement = StatList.func_151177_a("eternity_beacon");
allEffects = StatList.func_151177_a("all_effects");
hearts = StatList.func_151177_a("100_hearts");
unbreakableTool = StatList.func_151177_a("unbreakable_tconstruct_tool");

for (Potion potion : Potion.potionTypes) {
if (potion != null && !potion.isInstant()) {
Expand Down Expand Up @@ -124,6 +128,15 @@ public void onLivingHurt(LivingAttackEvent event) {

}

@SubscribeEvent
public void onItemPickup(ItemPickupEvent event) {
ItemStack stack = event.pickedUp.getEntityItem();
if (stack.getItem() instanceof ToolCore && stack.hasTagCompound()
&& stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Unbreaking") >= 10) {
event.player.triggerAchievement(unbreakableTool);
}
}

private static boolean hasArmor(ItemStack[] armor, Item helmet, Item chestplate, Item leggins, Item boots) {
ItemStack equippedHelmet = armor[3];
ItemStack equippedChestplate = armor[2];
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/dreammaster/main/MainRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,10 @@ public void CompleteLoad(FMLLoadCompleteEvent event) {
BW_RadHatchMaterial.runRadHatchAdder();
}
if (Thaumcraft.isModLoaded()) TCLoader.checkRecipeProblems();
if (Loader.isModLoaded("amazingtrophies") && BloodMagic.isModLoaded() && Avaritia.isModLoaded()) {
if (Loader.isModLoaded("amazingtrophies") && BloodMagic.isModLoaded()
&& Avaritia.isModLoaded()
&& SGCraft.isModLoaded()
&& TinkerConstruct.isModLoaded()) {
AchievementHandler.init();
AchievementHandler handler = new AchievementHandler();
MinecraftForge.EVENT_BUS.register(handler);
Expand Down

0 comments on commit 598309d

Please sign in to comment.