-
Notifications
You must be signed in to change notification settings - Fork 21
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
0b357f3
commit e8a7bfd
Showing
12 changed files
with
191 additions
and
14 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
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
42 changes: 42 additions & 0 deletions
42
src/main/java/io/github/itzispyder/clickcrystals/modules/modules/AnchorSearch.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,42 @@ | ||
package io.github.itzispyder.clickcrystals.modules.modules; | ||
|
||
import io.github.itzispyder.clickcrystals.events.EventHandler; | ||
import io.github.itzispyder.clickcrystals.events.Listener; | ||
import io.github.itzispyder.clickcrystals.events.events.PacketSendEvent; | ||
import io.github.itzispyder.clickcrystals.modules.Module; | ||
import io.github.itzispyder.clickcrystals.util.BlockUtils; | ||
import io.github.itzispyder.clickcrystals.util.HotbarUtils; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
public class AnchorSearch extends Module implements Listener { | ||
|
||
public AnchorSearch() { | ||
super("AnchorSearch","Searches your hotbar for anchors when you right click an end crystal on a non-crystallable block."); | ||
} | ||
|
||
@Override | ||
protected void onEnable() { | ||
system.addListener(this); | ||
} | ||
|
||
@Override | ||
protected void onDisable() { | ||
system.removeListener(this); | ||
} | ||
|
||
@EventHandler | ||
private void onClickBlock(PacketSendEvent e) { | ||
if (e.getPacket() instanceof PlayerInteractBlockC2SPacket packet) { | ||
BlockPos pos = packet.getBlockHitResult().getBlockPos(); | ||
if (BlockUtils.isCrystallabe(pos)) return; | ||
if (!HotbarUtils.nameContains("crystal")) return; | ||
if (!HotbarUtils.has(Items.RESPAWN_ANCHOR)) return; | ||
e.setCancelled(true); | ||
HotbarUtils.search(Items.RESPAWN_ANCHOR); | ||
BlockUtils.interact(packet.getBlockHitResult()); | ||
HotbarUtils.search(Items.GLOWSTONE); | ||
} | ||
} | ||
} |
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
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
70 changes: 70 additions & 0 deletions
70
src/main/java/io/github/itzispyder/clickcrystals/modules/modules/ToolSwitcher.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,70 @@ | ||
package io.github.itzispyder.clickcrystals.modules.modules; | ||
|
||
import io.github.itzispyder.clickcrystals.events.EventHandler; | ||
import io.github.itzispyder.clickcrystals.events.Listener; | ||
import io.github.itzispyder.clickcrystals.events.events.PacketSendEvent; | ||
import io.github.itzispyder.clickcrystals.modules.Module; | ||
import io.github.itzispyder.clickcrystals.util.BlockUtils; | ||
import io.github.itzispyder.clickcrystals.util.HotbarUtils; | ||
import io.github.itzispyder.clickcrystals.util.NbtUtils; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.enchantment.Enchantments; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
import java.util.Comparator; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* ToolSwitcher module | ||
*/ | ||
public class ToolSwitcher extends Module implements Listener { | ||
|
||
public ToolSwitcher() { | ||
super("ToolSwitcher","Auto switches to the efficient tool when you try to break a block."); | ||
} | ||
|
||
|
||
@Override | ||
protected void onEnable() { | ||
system.addListener(this); | ||
} | ||
|
||
@Override | ||
protected void onDisable() { | ||
system.removeListener(this); | ||
} | ||
|
||
@EventHandler | ||
private void onPacketSend(PacketSendEvent e) { | ||
if (e.getPacket() instanceof PlayerActionC2SPacket packet) { | ||
if (packet.getAction() == PlayerActionC2SPacket.Action.START_DESTROY_BLOCK) { | ||
BlockPos pos = packet.getPos(); | ||
BlockState state = mc.player.getWorld().getBlockState(pos); | ||
if (BlockUtils.isCrystallabe(pos)) return; | ||
if (HotbarUtils.nameContains("sword") || HotbarUtils.nameContains("totem") || HotbarUtils.nameContains("crystal") || HotbarUtils.nameContains("anchor")) return; | ||
|
||
Map<Integer,Float> entries = new HashMap<>(); | ||
HotbarUtils.forEachItem((slot,item) -> { | ||
entries.put(slot,calcWantedLvl(item,state)); | ||
}); | ||
int slot = entries.keySet() | ||
.stream() | ||
.max(Comparator.comparing(entries::get)) | ||
.get(); | ||
if (entries.get(slot) != 1) mc.player.getInventory().selectedSlot = slot; | ||
} | ||
} | ||
} | ||
|
||
private float calcWantedLvl(ItemStack item, BlockState state) { | ||
float lvl = 0; | ||
lvl += item.getMiningSpeedMultiplier(state); | ||
lvl += NbtUtils.getEnchantLvL(item,Enchantments.EFFICIENCY); | ||
lvl += NbtUtils.getEnchantLvL(item,Enchantments.UNBREAKING); | ||
lvl += NbtUtils.getEnchantLvL(item,Enchantments.MENDING); | ||
return lvl; | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
src/main/java/io/github/itzispyder/clickcrystals/util/NbtUtils.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,27 @@ | ||
package io.github.itzispyder.clickcrystals.util; | ||
|
||
import net.minecraft.enchantment.Enchantment; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.nbt.NbtList; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.util.Identifier; | ||
|
||
public abstract class NbtUtils { | ||
|
||
public static int getEnchantLvL(ItemStack stack, Enchantment enchant) { | ||
NbtList list = stack.getEnchantments(); | ||
for (int i = 0; i < list.size(); i++) { | ||
try { | ||
NbtCompound nbt = list.getCompound(i); | ||
Identifier id = Identifier.tryParse(nbt.getString("id")); | ||
Identifier id2 = Registries.ENCHANTMENT.getId(enchant); | ||
if (id.toTranslationKey().equalsIgnoreCase(id2.toTranslationKey())) { | ||
return nbt.getInt("lvl"); | ||
} | ||
} | ||
catch (Exception ignore) {} | ||
} | ||
return 0; | ||
} | ||
} |