aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java
blob: 8499f98525b398f19c431c4aaf83280b31fcae43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package gtPlusPlus.core.handler;

import java.lang.reflect.Field;

import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
import net.minecraft.stats.AchievementList;
import net.minecraftforge.event.entity.player.AchievementEvent;

public class StopAnnoyingFuckingAchievements {

	/**
	 * Stops me getting fireworks every fucking time I open my inventory upon first loading a dev client.
	 * @param event
	 */
	@SubscribeEvent(priority=EventPriority.HIGHEST)
	public void FUCK_OFF(AchievementEvent event)	{
		if (Utils.isClient()) {
			doClientStuff();
		}
		if (event.achievement.equals(AchievementList.openInventory)) {
			event.setCanceled(true);
		}
	}

	@SideOnly(Side.CLIENT)
	private final void doClientStuff() {
		Class aMC = ReflectionUtils.getClass("net.minecraft.client.Minecraft");
		if (aMC != null) {
			Field aInstanceMC = ReflectionUtils.getField(aMC, "theMinecraft");
			Object aMcObj = ReflectionUtils.getFieldValue(null, aInstanceMC);
			Class aClazz2 = aMcObj.getClass();
			if (aClazz2 != null) {
				Field aGameSettings = ReflectionUtils.getField(aClazz2, "gameSettings");
				Object aGameSettingsObj = ReflectionUtils.getFieldValue(aInstanceMC, aGameSettings);
				Class aClazz3 = aGameSettingsObj.getClass();
				if (aClazz3 != null) {
					Field ainvHint = ReflectionUtils.getField(aClazz3, "showInventoryAchievementHint");
					ReflectionUtils.setField(aGameSettingsObj, ainvHint, false);
				}
			}
		}
	}

}