Skip to content

Commit 3bad3e8

Browse files
committed
1.9.6
1 parent 598d767 commit 3bad3e8

File tree

13 files changed

+329
-3
lines changed

13 files changed

+329
-3
lines changed

src/main/java/xyz/templecheats/templeclient/TempleClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public class TempleClient {
3434
public static final String MODID = "templeclient";
3535
public static final String NAME = "Temple Client";
36-
public static final String VERSION = "1.9.5";
36+
public static final String VERSION = "1.9.6";
3737
public static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
3838
public static String name = NAME + " " + VERSION;
3939
public static AnnotatedEventManager eventBus;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package xyz.templecheats.templeclient.event.events.entity;
2+
3+
4+
import xyz.templecheats.templeclient.event.EventCancellable;
5+
6+
public class HorseSaddledEvent extends EventCancellable {
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package xyz.templecheats.templeclient.event.events.entity;
2+
3+
4+
import xyz.templecheats.templeclient.event.EventCancellable;
5+
6+
public class SteerEntityEvent extends EventCancellable {
7+
}
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
package xyz.templecheats.templeclient.features.module.modules.combat;
2+
3+
import net.minecraft.block.Block;
4+
import net.minecraft.client.gui.inventory.GuiContainer;
5+
import net.minecraft.init.Items;
6+
import net.minecraft.inventory.ClickType;
7+
import net.minecraft.item.Item;
8+
import net.minecraft.item.ItemBlock;
9+
import net.minecraft.item.ItemStack;
10+
import org.lwjgl.input.Keyboard;
11+
import xyz.templecheats.templeclient.features.module.Module;
12+
import xyz.templecheats.templeclient.manager.InventoryManager;
13+
import xyz.templecheats.templeclient.util.setting.impl.IntSetting;
14+
15+
import java.util.Comparator;
16+
import java.util.List;
17+
import java.util.stream.Collectors;
18+
19+
public class Replenish extends Module {
20+
21+
/****************************************************************
22+
* Settings
23+
****************************************************************/
24+
25+
private final IntSetting threshold = new IntSetting("Threshold", this, 1, 63, 32);
26+
private final IntSetting tickDelay = new IntSetting("Tick Delay", this, 1, 10, 2);
27+
28+
/****************************************************************
29+
* Variables
30+
****************************************************************/
31+
private int delayStep = 0;
32+
33+
public Replenish() {
34+
super("Replenish", "Automatically refills hotbar items", Keyboard.KEY_NONE, Category.Combat);
35+
this.registerSettings(threshold, tickDelay);
36+
}
37+
38+
public void onUpdate() {
39+
40+
if (mc.player == null) {
41+
return;
42+
}
43+
44+
if (mc.currentScreen instanceof GuiContainer) {
45+
return;
46+
}
47+
48+
if (delayStep < tickDelay.intValue()) {
49+
delayStep++;
50+
return;
51+
} else {
52+
delayStep = 0;
53+
}
54+
55+
SlotPair slots = findReplenishableHotbarSlot();
56+
57+
if (slots == null) {
58+
return;
59+
}
60+
61+
int inventorySlot = slots.getInventorySlot();
62+
int hotbarSlot = slots.getHotbarSlot();
63+
mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
64+
mc.playerController.windowClick(0, hotbarSlot + 36, 0, ClickType.PICKUP, mc.player);
65+
mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
66+
}
67+
68+
private SlotPair findReplenishableHotbarSlot() {
69+
List<ItemStack> inventory = mc.player.inventory.mainInventory;
70+
71+
for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++) {
72+
ItemStack stack = inventory.get(hotbarSlot);
73+
74+
if (!stack.isStackable()) {
75+
continue;
76+
}
77+
78+
if (stack.isEmpty() || stack.getItem() == Items.AIR) {
79+
continue;
80+
}
81+
82+
if (stack.getCount() >= stack.getMaxStackSize() || stack.getCount() > threshold.intValue()) {
83+
continue;
84+
}
85+
86+
int inventorySlot = findCompatibleInventorySlot(stack);
87+
88+
if (inventorySlot == -1) {
89+
continue;
90+
}
91+
return new SlotPair(inventorySlot, hotbarSlot);
92+
}
93+
return null;
94+
}
95+
96+
private int findCompatibleInventorySlot(ItemStack hotbarStack) {
97+
List<Integer> potentialSlots;
98+
99+
Item item = hotbarStack.getItem();
100+
if (item instanceof ItemBlock) {
101+
potentialSlots = InventoryManager.findAllBlockSlots(((ItemBlock) item).getBlock().getClass());
102+
} else {
103+
potentialSlots = InventoryManager.findAllItemSlots(item.getClass());
104+
}
105+
106+
potentialSlots = potentialSlots.stream()
107+
.filter(integer -> integer > 8 && integer < 36)
108+
.sorted(Comparator.comparingInt(integer -> -integer))
109+
.collect(Collectors.toList());
110+
111+
for (int slot : potentialSlots) {
112+
if (isCompatibleStacks(hotbarStack, mc.player.inventory.getStackInSlot(slot))) {
113+
return slot;
114+
}
115+
}
116+
return -1;
117+
}
118+
119+
private boolean isCompatibleStacks(ItemStack stack1, ItemStack stack2) {
120+
if (!stack1.getItem().equals(stack2.getItem())) {
121+
return false;
122+
}
123+
if ((stack1.getItem() instanceof ItemBlock) && (stack2.getItem() instanceof ItemBlock)) {
124+
Block block1 = ((ItemBlock) stack1.getItem()).getBlock();
125+
Block block2 = ((ItemBlock) stack2.getItem()).getBlock();
126+
if (!block1.getDefaultState().equals(block2.getDefaultState())) {
127+
return false;
128+
}
129+
}
130+
if (!stack1.getDisplayName().equals(stack2.getDisplayName())) {
131+
return false;
132+
}
133+
if (stack1.getItemDamage() != stack2.getItemDamage()) {
134+
return false;
135+
}
136+
return true;
137+
}
138+
139+
private static class SlotPair {
140+
private final int inventorySlot;
141+
private final int hotbarSlot;
142+
143+
public SlotPair(int inventorySlot, int hotbarSlot) {
144+
this.inventorySlot = inventorySlot;
145+
this.hotbarSlot = hotbarSlot;
146+
}
147+
148+
public int getInventorySlot() {
149+
return inventorySlot;
150+
}
151+
152+
public int getHotbarSlot() {
153+
return hotbarSlot;
154+
}
155+
}
156+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package xyz.templecheats.templeclient.features.module.modules.movement;
2+
3+
import org.lwjgl.input.Keyboard;
4+
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
5+
import xyz.templecheats.templeclient.event.events.entity.HorseSaddledEvent;
6+
import xyz.templecheats.templeclient.event.events.entity.SteerEntityEvent;
7+
import xyz.templecheats.templeclient.features.module.Module;
8+
9+
public class EntityControl extends Module {
10+
11+
public EntityControl() {
12+
super("EntityControl", "Ride entities without saddles and modify their speed", Keyboard.KEY_NONE, Category.Movement);
13+
}
14+
15+
@Listener
16+
public void onSteerEntity(SteerEntityEvent event) {
17+
event.setCanceled(true);
18+
}
19+
20+
@Listener
21+
public void onHorseSaddled(HorseSaddledEvent event) {
22+
event.setCanceled(true);
23+
}
24+
}

src/main/java/xyz/templecheats/templeclient/manager/InventoryManager.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,40 @@ public static boolean getHeldItem(Item item) {
154154
return mc.player.getHeldItemMainhand().getItem().equals(item) || mc.player.getHeldItemOffhand().getItem().equals(item);
155155
}
156156

157+
public static List<Integer> findAllItemSlots(Class<? extends Item> itemToFind) {
158+
List<Integer> slots = new ArrayList<>();
159+
List<ItemStack> mainInventory = mc.player.inventory.mainInventory;
160+
161+
for (int i = 0; i < 36; i++) {
162+
ItemStack stack = mainInventory.get(i);
163+
164+
if (stack == ItemStack.EMPTY || !(itemToFind.isInstance(stack.getItem()))) {
165+
continue;
166+
}
167+
168+
slots.add(i);
169+
}
170+
return slots;
171+
}
172+
173+
public static List<Integer> findAllBlockSlots(Class<? extends Block> blockToFind) {
174+
List<Integer> slots = new ArrayList<>();
175+
List<ItemStack> mainInventory = mc.player.inventory.mainInventory;
176+
177+
for (int i = 0; i < 36; i++) {
178+
ItemStack stack = mainInventory.get(i);
179+
180+
if (stack == ItemStack.EMPTY || !(stack.getItem() instanceof ItemBlock)) {
181+
continue;
182+
}
183+
184+
if (blockToFind.isInstance(((ItemBlock) stack.getItem()).getBlock())) {
185+
slots.add(i);
186+
}
187+
}
188+
return slots;
189+
}
190+
157191
/****************************************************************
158192
* Inventory Enums
159193
****************************************************************/

src/main/java/xyz/templecheats/templeclient/manager/ModuleManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public static void initMods() {
5454

5555
// Combat
5656
addMod(new AutoDisconnect());
57+
addMod(new Replenish());
5758
addMod(new AutoTrap());
5859
addMod(new SelfTrap());
5960
addMod(new TriggerBot());
@@ -94,6 +95,7 @@ public static void initMods() {
9495
addMod(new HUD());
9596

9697
// Movement
98+
addMod(new EntityControl());
9799
addMod(new RotationLock());
98100
addMod(new ReverseStep());
99101
addMod(new GuiWalk());
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package xyz.templecheats.templeclient.mixins.entity;
2+
3+
import net.minecraft.entity.passive.AbstractHorse;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.injection.At;
6+
import org.spongepowered.asm.mixin.injection.Inject;
7+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
8+
import xyz.templecheats.templeclient.TempleClient;
9+
import xyz.templecheats.templeclient.event.events.entity.HorseSaddledEvent;
10+
import xyz.templecheats.templeclient.event.events.entity.SteerEntityEvent;
11+
12+
@Mixin(AbstractHorse.class)
13+
public class MixinAbstractHorse {
14+
@Inject(method = "canBeSteered", at = @At("HEAD"), cancellable = true)
15+
public void canBeSteered(CallbackInfoReturnable<Boolean> cir) {
16+
SteerEntityEvent event = new SteerEntityEvent();
17+
TempleClient.eventBus.dispatchEvent(event);
18+
19+
if (event.isCanceled()) {
20+
cir.cancel();
21+
cir.setReturnValue(true);
22+
}
23+
}
24+
25+
@Inject(method = "isHorseSaddled", at = @At("HEAD"), cancellable = true)
26+
public void isHorseSaddled(CallbackInfoReturnable<Boolean> cir) {
27+
HorseSaddledEvent event = new HorseSaddledEvent();
28+
TempleClient.eventBus.dispatchEvent(event);
29+
30+
if (event.isCanceled()) {
31+
cir.cancel();
32+
cir.setReturnValue(true);
33+
}
34+
}
35+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package xyz.templecheats.templeclient.mixins.entity;
2+
3+
import net.minecraft.entity.passive.EntityLlama;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.injection.At;
6+
import org.spongepowered.asm.mixin.injection.Inject;
7+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
8+
import xyz.templecheats.templeclient.TempleClient;
9+
import xyz.templecheats.templeclient.event.events.entity.SteerEntityEvent;
10+
11+
@Mixin(EntityLlama.class)
12+
public class MixinEntityLlama {
13+
@Inject(method = "canBeSteered", at = @At("HEAD"), cancellable = true)
14+
public void canBeSteered(CallbackInfoReturnable<Boolean> cir) {
15+
SteerEntityEvent event = new SteerEntityEvent();
16+
TempleClient.eventBus.dispatchEvent(event);
17+
18+
if (event.isCanceled()) {
19+
cir.cancel();
20+
cir.setReturnValue(true);
21+
}
22+
}
23+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package xyz.templecheats.templeclient.mixins.entity;
2+
3+
import net.minecraft.entity.passive.EntityPig;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.injection.At;
6+
import org.spongepowered.asm.mixin.injection.Inject;
7+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
8+
import xyz.templecheats.templeclient.TempleClient;
9+
import xyz.templecheats.templeclient.event.events.entity.HorseSaddledEvent;
10+
import xyz.templecheats.templeclient.event.events.entity.SteerEntityEvent;
11+
12+
@Mixin(EntityPig.class)
13+
public class MixinEntityPig {
14+
@Inject(method = "canBeSteered", at = @At("HEAD"), cancellable = true)
15+
public void canBeSteered(CallbackInfoReturnable<Boolean> cir) {
16+
SteerEntityEvent event = new SteerEntityEvent();
17+
TempleClient.eventBus.dispatchEvent(event);
18+
19+
if (event.isCanceled()) {
20+
cir.cancel();
21+
cir.setReturnValue(true);
22+
}
23+
}
24+
25+
@Inject(method = "getSaddled", at = @At("HEAD"), cancellable = true)
26+
public void getSaddled(CallbackInfoReturnable<Boolean> cir) {
27+
HorseSaddledEvent event = new HorseSaddledEvent();
28+
TempleClient.eventBus.dispatchEvent(event);
29+
30+
if (event.isCanceled()) {
31+
cir.cancel();
32+
cir.setReturnValue(true);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)