Skip to content

Commit

Permalink
fixed bug with entity_in_range command, added post_tick and pre_tick
Browse files Browse the repository at this point in the history
  • Loading branch information
ItziSpyder committed Aug 7, 2024
1 parent 441982f commit b457087
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,23 @@ Version: 1.2.7

Tweaks:
- change clickcrystals script on tick to pretick so it doesnt flag post
- rewrite potion hud # i no one
- rewrite armor hud # i no one

Add:
- pull and merge PR from I-No-One
- Teams module # i no one
- added Teams module # i no one
- added FreeLook Module # i no one
- added AutoDisconnect Module # i no one

Scripting:
- add script command if entity pos
- increased the range for entity selection from 32 to 128
- add on post_tick
- add on pre_tick

Patches:
- entity_in_range not working
- block ID selections with commas not working properly
```
![demo](https://cdn.modrinth.com/data/YDYPZdGj/images/d4ad4320aaf5d8589829e3d1691ec5755422a778.png)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ public static Predicate<BlockState> parseBlockPredicate(String arg) {
}
else if (section.startsWith(":")) {
String subArg = section.substring(1);

if (defaultedBlockPredicates.containsKey(subArg)) {
return defaultedBlockPredicates.get(subArg);
list.add(defaultedBlockPredicates.get(subArg));
continue;
}

Identifier id = Identifier.of("minecraft", subArg);
return block -> block.getBlock() == Registries.BLOCK.get(id);
list.add(block -> block.getBlock() == Registries.BLOCK.get(id));
}
else {
list.add(block -> false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.github.itzispyder.clickcrystals.client.clickscript.ClickScript;
import io.github.itzispyder.clickcrystals.client.networking.EntityStatusType;
import io.github.itzispyder.clickcrystals.data.Config;
import io.github.itzispyder.clickcrystals.events.Event;
import io.github.itzispyder.clickcrystals.events.EventHandler;
import io.github.itzispyder.clickcrystals.events.events.client.*;
import io.github.itzispyder.clickcrystals.events.events.networking.GameJoinEvent;
Expand Down Expand Up @@ -33,7 +34,9 @@ public class ScriptedModule extends ListenerModule {
public final List<ClickListener> clickListeners = new ArrayList<>();
public final List<KeyListener> keyListeners = new ArrayList<>();
public final List<MoveListener> moveListeners = new ArrayList<>();
public final List<TickListener> preTickListeners = new ArrayList<>();
public final List<TickListener> tickListeners = new ArrayList<>();
public final List<TickListener> postTickListeners = new ArrayList<>();
public final List<BlockPlaceListener> blockPlaceListeners = new ArrayList<>();
public final List<BlockBreakListener> blockBreakListeners = new ArrayList<>();
public final List<BlockPunchListener> blockPunchListeners = new ArrayList<>();
Expand Down Expand Up @@ -74,7 +77,9 @@ public void clearListeners() {
clickListeners.clear();
keyListeners.clear();
moveListeners.clear();
preTickListeners.clear();
tickListeners.clear();
postTickListeners.clear();

totemPopListeners.clear();
moduleEnableListeners.clear();
Expand Down Expand Up @@ -105,11 +110,21 @@ public void onMouseClick(MouseClickEvent e) {

@EventHandler
public void onTick(ClientTickStartEvent e) {
for (TickListener l : preTickListeners) {
l.pass(e);
}
for (TickListener l : tickListeners) {
l.pass(e);
}
}

@EventHandler
public void onPostTick(ClientTickEndEvent e) {
for (TickListener l : postTickListeners) {
l.pass(e);
}
}

@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
for (BlockPlaceListener l : blockPlaceListeners) {
Expand Down Expand Up @@ -225,7 +240,7 @@ public interface ClickListener {

@FunctionalInterface
public interface TickListener {
void pass(ClientTickStartEvent e);
void pass(Event e);
}

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public void onCommand(ScriptCommand command, String line, ScriptArgs args) {
case MOVE_LOOK, MOVE_POS -> passMove(args, type);
case CHAT_SEND, CHAT_RECEIVE -> passChat(args, type);

case PRE_TICK -> ModuleCmd.runOnCurrentScriptModule(m -> m.preTickListeners.add(event -> exc(args, 1)));
case TICK -> ModuleCmd.runOnCurrentScriptModule(m -> m.tickListeners.add(event -> exc(args, 1)));
case POST_TICK -> ModuleCmd.runOnCurrentScriptModule(m -> m.postTickListeners.add(event -> exc(args, 1)));
case ITEM_USE -> ModuleCmd.runOnCurrentScriptModule(m -> m.itemUseListeners.add(event -> exc(args, 1)));
case ITEM_CONSUME -> ModuleCmd.runOnCurrentScriptModule(m -> m.itemConsumeListeners.add(event -> exc(args, 1)));
case MODULE_ENABLE -> ModuleCmd.runOnCurrentScriptModule(m -> m.moduleEnableListeners.add(() -> exc(args, 1)));
Expand Down Expand Up @@ -277,7 +279,9 @@ public enum EventType {
BREAK_BLOCK,
PUNCH_BLOCK,
INTERACT_BLOCK,
PRE_TICK,
TICK,
POST_TICK,
ITEM_USE,
ITEM_CONSUME,
TOTEM_POP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private static HitResult ensureTargetInRange(HitResult hitResult, Vec3d cameraPo
public static Entity getNearestEntity(Entity ref, double range, Predicate<Entity> filter) {
Vec3d at = ref.getPos();
List<Entity> candidates = ref.getWorld()
.getOtherEntities(PlayerUtils.player(), Box.from(at).expand(range), ent -> ent != ref && filter.test(ref)).stream()
.getOtherEntities(PlayerUtils.player(), Box.from(at).expand(range), ent -> ent != ref && filter.test(ent)).stream()
.sorted(Comparator.comparing(entity -> entity.getPos().distanceTo(at)))
.toList();

Expand Down

0 comments on commit b457087

Please sign in to comment.