Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
test 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pan4ur committed Jul 30, 2024
1 parent ab05a5c commit 02cacbc
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 6 deletions.
16 changes: 16 additions & 0 deletions src/main/java/thunder/hack/events/impl/EventEntitySpawnPost.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package thunder.hack.events.impl;

import net.minecraft.entity.Entity;
import thunder.hack.events.Event;

public class EventEntitySpawnPost extends Event {
private final Entity entity;

public EventEntitySpawnPost(Entity entity) {
this.entity = entity;
}

public Entity getEntity() {
return this.entity;
}
}
13 changes: 12 additions & 1 deletion src/main/java/thunder/hack/injection/MixinClientWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import thunder.hack.core.impl.ModuleManager;
import thunder.hack.events.impl.EventEntityRemoved;
import thunder.hack.events.impl.EventEntitySpawn;
import thunder.hack.events.impl.EventEntitySpawnPost;
import thunder.hack.modules.Module;
import thunder.hack.modules.render.WorldTweaks;
import thunder.hack.setting.impl.ColorSetting;
Expand All @@ -24,7 +25,7 @@

@Mixin(ClientWorld.class)
public class MixinClientWorld {
@Inject(method = "addEntity", at = @At("RETURN"), cancellable = true)
@Inject(method = "addEntity", at = @At("HEAD"), cancellable = true)
public void addEntityHook(Entity entity, CallbackInfo ci) {
if(Module.fullNullCheck()) return;
EventEntitySpawn ees = new EventEntitySpawn(entity);
Expand All @@ -34,6 +35,16 @@ public void addEntityHook(Entity entity, CallbackInfo ci) {
}
}

@Inject(method = "addEntity", at = @At("RETURN"), cancellable = true)
public void addEntityHookPost(Entity entity, CallbackInfo ci) {
if(Module.fullNullCheck()) return;
EventEntitySpawnPost ees = new EventEntitySpawnPost(entity);
ThunderHack.EVENT_BUS.post(ees);
if (ees.isCancelled()) {
ci.cancel();
}
}

@Inject(method = "removeEntity", at = @At("HEAD"))
public void removeEntityHook(int entityId, Entity.RemovalReason removalReason, CallbackInfo ci) {
if(Module.fullNullCheck()) return;
Expand Down
30 changes: 25 additions & 5 deletions src/main/java/thunder/hack/modules/combat/AutoCrystal.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
public class AutoCrystal extends Module {



/* MAIN */
private static final Setting<Pages> page = new Setting<>("Page", Pages.Main);
private final Setting<Boolean> await = new Setting<>("Await", true, v -> page.getValue() == Pages.Main);
private final Setting<Timing> timing = new Setting<>("Timing", Timing.NORMAL, v -> page.getValue() == Pages.Main);
private final Setting<Sequential> sequential = new Setting<>("Sequential", Sequential.Strong, v -> page.getValue() == Pages.Main);
private final Setting<InstantBreak> instantBreak = new Setting<>("InstantBreak", InstantBreak.OnSpawn, v -> page.is(Pages.Main) && sequential.is(Sequential.Strong));
private final Setting<Rotation> rotate = new Setting<>("Rotate", Rotation.CC, v -> page.getValue() == Pages.Main);
private final Setting<BooleanSettingGroup> yawStep = new Setting<>("YawStep", new BooleanSettingGroup(false), v -> !rotate.is(Rotation.OFF) && page.getValue() == Pages.Main);
private final Setting<Float> yawAngle = new Setting<>("YawAngle", 180.0f, 1.0f, 180.0f, v -> !rotate.is(Rotation.OFF) && page.getValue() == Pages.Main).addToGroup(yawStep);
Expand Down Expand Up @@ -312,11 +312,30 @@ public String getDisplayInfo() {
return info.length() < 4 ? info.toString() : info.substring(0, info.length() - 3);
}

@EventHandler
public void onCrystalSpawn(@NotNull EventEntitySpawnPost e) {
if (e.getEntity() instanceof EndCrystalEntity cr && crystalAge.is(0) && instantBreak.is(InstantBreak.OnSpawn)) {
HashMap<BlockPos, Long> cache = new HashMap<>(placedCrystals);

for (BlockPos bp : cache.keySet())
if (cr.squaredDistanceTo(bp.toCenterPos()) < 0.3) {
confirmTime = System.currentTimeMillis() - cache.get(bp);
placedCrystals.remove(bp);
if (breakTimer.passedTicks(facePlacing ? lowBreakDelay.getValue() : breakDelay.getValue())) {
ThunderHack.asyncManager.run(() -> handleSpawn(cr));
if (sequential.is(Sequential.Strong) && placeTimer.passedTicks(facePlacing ? lowPlaceDelay.getValue() : placeDelay.getValue()))
placeSyncTimer.reset();
}
}
}
}


@EventHandler
public void onPacketReceive(PacketEvent.Receive e) {
if (mc.player == null || mc.world == null) return;

if (e.getPacket() instanceof EntitySpawnS2CPacket spawn && spawn.getEntityType() == EntityType.END_CRYSTAL && crystalAge.is(0)) {
if (e.getPacket() instanceof EntitySpawnS2CPacket spawn && spawn.getEntityType() == EntityType.END_CRYSTAL && crystalAge.is(0) && instantBreak.is(InstantBreak.OnPacket)) {
HashMap<BlockPos, Long> cache = new HashMap<>(placedCrystals);

EndCrystalEntity cr = new EndCrystalEntity(mc.world, spawn.getX(), spawn.getY(), spawn.getZ());
Expand Down Expand Up @@ -544,7 +563,8 @@ public boolean rotationMarkedDirty() {
}

public void attackCrystal(EndCrystalEntity crystal) {
if (mc.player == null || mc.world == null || mc.interactionManager == null || crystal == null || (deadManager.isDead(crystal.getId()) && inhibit.getValue())) return;
if (mc.player == null || mc.world == null || mc.interactionManager == null || crystal == null || (deadManager.isDead(crystal.getId()) && inhibit.getValue()))
return;

if (shouldPause() || target == null)
return;
Expand Down Expand Up @@ -1162,8 +1182,8 @@ public enum Render {
Fade, Slide, Default
}

public enum OnBreakBlock {
PlaceOn, Smart, None
public enum InstantBreak {
OnPacket, OnSpawn
}

public enum Rotation {
Expand Down

0 comments on commit 02cacbc

Please sign in to comment.