-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d511aac
commit b98b236
Showing
44 changed files
with
1,720 additions
and
427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/xyz/templecheats/templeclient/event/events/player/JumpEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package xyz.templecheats.templeclient.event.events.player; | ||
|
||
import net.minecraftforge.fml.common.eventhandler.Event; | ||
|
||
public class JumpEvent extends Event { | ||
public final double motionX; | ||
public final double motionZ; | ||
|
||
public JumpEvent(double motionX, double motionZ) { | ||
this.motionX = motionX; | ||
this.motionZ = motionZ; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 110 additions & 66 deletions
176
src/main/java/xyz/templecheats/templeclient/features/module/modules/combat/Offhand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,144 @@ | ||
package xyz.templecheats.templeclient.features.module.modules.combat; | ||
|
||
import net.minecraft.client.gui.inventory.GuiInventory; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.init.Items; | ||
import net.minecraft.inventory.ClickType; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.network.play.client.CPacketPlayer; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.common.gameevent.TickEvent; | ||
import org.lwjgl.input.Keyboard; | ||
import xyz.templecheats.templeclient.features.module.Module; | ||
import xyz.templecheats.templeclient.manager.ModuleManager; | ||
import xyz.templecheats.templeclient.util.setting.impl.DoubleSetting; | ||
import xyz.templecheats.templeclient.util.setting.impl.BooleanSetting; | ||
import xyz.templecheats.templeclient.util.setting.impl.EnumSetting; | ||
import xyz.templecheats.templeclient.util.setting.impl.IntSetting; | ||
|
||
import java.util.Arrays; | ||
import java.util.Map; | ||
|
||
public class Offhand extends Module { | ||
public class Offhand extends Module { | ||
/* | ||
* Settings | ||
*/ | ||
private final DoubleSetting health = new DoubleSetting("Health", this, 0.0d, 36.0d, 14.0d); | ||
private final DoubleSetting defaultHealthVal = new DoubleSetting("DHV", this, 0.0f, 36.0f, 14.0f); | ||
private final EnumSetting < Item > item = new EnumSetting < > ("Item", this, Item.Crystal); | ||
private final IntSetting totemHp = new IntSetting("Totem HP", this, 0, 36, 16); | ||
private final BooleanSetting gappleInHole = new BooleanSetting("Gap In Hole", this, false); | ||
private final IntSetting gappleInHoleHP = new IntSetting("Gap Hole HP", this, 0, 36, 16); | ||
private final BooleanSetting delay = new BooleanSetting("Delay", this, false); | ||
|
||
/* | ||
* Variables | ||
*/ | ||
private boolean switching = false; | ||
private int last_slot; | ||
private Map < String, Item > itemMap; | ||
|
||
public Offhand() { | ||
super("Offhand", "Puts items in you're offhand", Keyboard.KEY_NONE, Category.Combat); | ||
registerSettings(health, defaultHealthVal); | ||
registerSettings(gappleInHole, delay, gappleInHoleHP, totemHp, item); | ||
} | ||
|
||
@Override | ||
public void onUpdate() { | ||
final int slot = slot(); | ||
if (slot != -1) { | ||
swapItem(slot); | ||
} | ||
if (mc.player.getHeldItemOffhand().isEmpty()) { | ||
inventorySlot(Items.END_CRYSTAL); | ||
@SubscribeEvent | ||
public void onTick(TickEvent.ClientTickEvent event) { | ||
|
||
if (mc.player == null) | ||
return; | ||
|
||
if (mc.currentScreen == null || mc.currentScreen instanceof GuiInventory) { | ||
|
||
if (switching) { | ||
swap_items(last_slot, 2); | ||
return; | ||
} | ||
|
||
float hp = mc.player.getHealth() + mc.player.getAbsorptionAmount(); | ||
|
||
if (hp > totemHp.intValue()) { | ||
if (gappleInHole.booleanValue() && hp > gappleInHoleHP.intValue() && is_in_hole()) { | ||
swap_items(get_item_slot(Items.GOLDEN_APPLE), delay.booleanValue() ? 1 : 0); | ||
return; | ||
} | ||
switch (item.value()) { | ||
case Crystal: | ||
swap_items(get_item_slot(Items.END_CRYSTAL), 0); | ||
break; | ||
case Gapple: | ||
swap_items(get_item_slot(Items.GOLDEN_APPLE), delay.booleanValue() ? 1 : 0); | ||
break; | ||
case Totem: | ||
swap_items(get_item_slot(Items.TOTEM_OF_UNDYING), delay.booleanValue() ? 1 : 0); | ||
break; | ||
} | ||
} else { | ||
swap_items(get_item_slot(Items.TOTEM_OF_UNDYING), delay.booleanValue() ? 1 : 0); | ||
return; | ||
} | ||
|
||
if (mc.player.getHeldItemOffhand().getItem() == Items.AIR) { | ||
swap_items(get_item_slot(Items.TOTEM_OF_UNDYING), delay.booleanValue() ? 1 : 0); | ||
} | ||
|
||
} | ||
|
||
} | ||
private int slot() { | ||
if (mc.currentScreen != null) { | ||
return -1; | ||
|
||
public void swap_items(int slot, int step) { | ||
if (slot == -1) | ||
return; | ||
if (step == 0) { | ||
mc.playerController.windowClick(0, slot, 0, ClickType.PICKUP, mc.player); | ||
mc.playerController.windowClick(0, 45, 0, ClickType.PICKUP, mc.player); | ||
mc.playerController.windowClick(0, slot, 0, ClickType.PICKUP, mc.player); | ||
} | ||
final int totem = inventorySlot(Items.TOTEM_OF_UNDYING); | ||
if (totem == -1) { | ||
health.setDoubleValue(0.1f); | ||
} else { | ||
health.setDoubleValue(defaultHealthVal.doubleValue()); | ||
if (step == 1) { | ||
mc.playerController.windowClick(0, slot, 0, ClickType.PICKUP, mc.player); | ||
switching = true; | ||
last_slot = slot; | ||
} | ||
if (mc.player.getHealth() + mc.player.getAbsorptionAmount() <= health.doubleValue()) { | ||
return totem; | ||
if (step == 2) { | ||
mc.playerController.windowClick(0, 45, 0, ClickType.PICKUP, mc.player); | ||
mc.playerController.windowClick(0, slot, 0, ClickType.PICKUP, mc.player); | ||
switching = false; | ||
} | ||
if (mc.player.getHeldItemMainhand().getItem().equals(Items.DIAMOND_SWORD)) { | ||
if (mc.gameSettings.keyBindUseItem.isKeyDown()) { | ||
return inventorySlot(Items.GOLDEN_APPLE); | ||
} | ||
|
||
} | ||
final int crystal = inventorySlot(Items.END_CRYSTAL); | ||
if (crystal != -1) { | ||
return inventorySlot(Items.END_CRYSTAL); | ||
} | ||
return totem; | ||
mc.playerController.updateController(); | ||
} | ||
|
||
private void swapItem(final int i) { | ||
final Item item = mc.player.inventory.getStackInSlot(i).getItem(); | ||
if (!mc.player.getHeldItemOffhand().getItem().equals(item)) { | ||
int slot = i < 9 ? i + 36 : i; | ||
swap(new int[]{slot, 45, slot}); | ||
mc.playerController.updateController(); | ||
} | ||
} | ||
private boolean is_in_hole() { | ||
|
||
private void swap(final int[] slots) { | ||
if (mc.getConnection() != null) { | ||
Arrays.stream(slots).forEach(i -> mc.playerController.windowClick(0, i, 0, ClickType.PICKUP, mc.player)); | ||
mc.getConnection().sendPacket(new CPacketPlayer()); | ||
} | ||
BlockPos player_block = GetLocalPlayerPosFloored(); | ||
|
||
return mc.world.getBlockState(player_block.east()).getBlock() != Blocks.AIR && | ||
mc.world.getBlockState(player_block.west()).getBlock() != Blocks.AIR && | ||
mc.world.getBlockState(player_block.north()).getBlock() != Blocks.AIR && | ||
mc.world.getBlockState(player_block.south()).getBlock() != Blocks.AIR; | ||
} | ||
|
||
public int inventorySlot(final Item item) { | ||
int itemSlot = -1; | ||
for (int i = 45; i > 0; --i) { | ||
final ItemStack stack = mc.player.inventory.getStackInSlot(i); | ||
if (stack.getItem().equals(item)) { | ||
itemSlot = i; | ||
break; | ||
private int get_item_slot(net.minecraft.item.Item input) { | ||
if (input == mc.player.getHeldItemOffhand().getItem()) | ||
return -1; | ||
for (int i = 36; i >= 0; i--) { | ||
final net.minecraft.item.Item item = mc.player.inventory.getStackInSlot(i).getItem(); | ||
if (item == input) { | ||
if (i < 9) { | ||
if (input == Items.GOLDEN_APPLE) { | ||
return -1; | ||
} | ||
i += 36; | ||
} | ||
return i; | ||
} | ||
} | ||
return itemSlot; | ||
return -1; | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
super.onEnable(); | ||
AutoTotem autoTotem = (AutoTotem) ModuleManager.getModuleByName("AutoTotem"); | ||
if (autoTotem.isEnabled()) { | ||
autoTotem.disable(); | ||
} | ||
public BlockPos GetLocalPlayerPosFloored() { | ||
return new BlockPos(Math.floor(mc.player.posX), Math.floor(mc.player.posY), Math.floor(mc.player.posZ)); | ||
} | ||
} | ||
|
||
public enum Item { | ||
Crystal, | ||
Gapple, | ||
Totem | ||
} | ||
} |
Oops, something went wrong.