Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Unbreakable TCon Tool Achievement via Code #776

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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