summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/bscv/modules/self/FastInteract.java
blob: e947b5ed2019880948656212428b1928ff10158d (plain) (blame)
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
50
51
52
53
54
55
56
package ftbsc.bscv.modules.self;

import static ftbsc.bscv.BoSCoVicino.log;

import java.lang.reflect.Field;

import com.mojang.brigadier.CommandDispatcher;

import net.minecraft.command.CommandSource;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

import ftbsc.bscv.modules.QuickModule;
import ftbsc.bscv.ICommons;

public class FastInteract extends QuickModule implements ICommons {
   @Override
   public String getName() {
      return "FastInteract";
   }

   @Override
   public Group getGroup() {
      return Group.SELF;
   }

   @Override
   protected int getDefaultKey() {
      return UNBOUND;
   }

   Field delayField;

   @Override
   protected void onEnabled() {
      try {
         delayField = MC.getClass().getDeclaredField("field_71467_ac");
         delayField.setAccessible(true);
      } catch (NoSuchFieldException e) {
         log("! failed accessing delay field");
         this.disable();
      }
   }

   @SubscribeEvent
   public void onTick(TickEvent.ClientTickEvent event) {
      if (MC == null) return;
      try {
         this.delayField.set(MC, 0);
      } catch (IllegalAccessException e) {
         log("! failed accessing delay field");
         this.disable();
      }
   }
}