Skip to content

Commit

Permalink
RocketMan - Added riptide charge time bypass.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTas committed Apr 10, 2024
1 parent 3a9c646 commit e9e20c9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 38 deletions.
34 changes: 34 additions & 0 deletions src/main/java/dev/stardust/mixin/TridentItemMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dev.stardust.mixin;

import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraft.item.ItemStack;
import net.minecraft.item.TridentItem;
import dev.stardust.modules.RocketMan;
import org.spongepowered.asm.mixin.Mixin;
import net.minecraft.entity.LivingEntity;
import com.llamalad7.mixinextras.sugar.Local;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef;
import meteordevelopment.meteorclient.systems.modules.Modules;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;


/**
* @author Tas [0xTas] <[email protected]>
**/
@Mixin(TridentItem.class)
public abstract class TridentItemMixin extends Item {
public TridentItemMixin(Settings settings) {
super(settings);
}

// See RocketMan.java
@Inject(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/TridentItem;getMaxUseTime(Lnet/minecraft/item/ItemStack;)I", shift = At.Shift.AFTER))
private void bypassTridentChargeTime(ItemStack stack, World world, LivingEntity user, int remainingUseTicks, CallbackInfo ci, @Local(ordinal = 0)LocalIntRef i) {
RocketMan rm = Modules.get().get(RocketMan.class);
if (!rm.isActive() || !rm.tridentBoost.get()) return;
i.set(69420);
}
}
42 changes: 4 additions & 38 deletions src/main/java/dev/stardust/modules/RocketMan.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ public RocketMan() {
private int timer = 0;
private int ticksBusy = 0;
private int ticksSinceUsed = 0;
private int tridentHoldTicks = 0;
private int ticksSinceWarned = 0;
private int ticksSinceNotified = 0;
private int tridentThrowGracePeriod = 0;
Expand All @@ -289,7 +288,7 @@ private boolean equippedTrident() {

private void useTrident() {
chargingTrident = true;
mc.options.useKey.setPressed(true);
mc.interactionManager.interactItem(mc.player, Hand.MAIN_HAND);
}

private void useFireworkRocket() {
Expand Down Expand Up @@ -454,11 +453,9 @@ public boolean shouldMuteElytra() {
return muteElytra.get() && mc.player.isFallFlying();
}


@Override
public void onActivate() {
timer = 0;
tridentHoldTicks = 0;
if (mc.player == null) return;
boolean isWearingElytra = mc.player.getEquippedStack(EquipmentSlot.CHEST).getItem() == Items.ELYTRA;

Expand Down Expand Up @@ -507,10 +504,8 @@ public void onActivate() {
@Override
public void onDeactivate() {
if (chargingTrident) {
tridentHoldTicks = 0;
chargingTrident = false;
mc.options.useKey.setPressed(false);
if (mc.currentScreen != null) mc.interactionManager.stopUsingItem(mc.player);
mc.interactionManager.stopUsingItem(mc.player);
}
}

Expand All @@ -519,27 +514,8 @@ private void onTick(TickEvent.Pre event) {
if (mc.player == null || mc.interactionManager == null) return;

if (chargingTrident) {
if (!mc.player.isFallFlying()) {
tridentHoldTicks = 0;
chargingTrident = false;
mc.options.useKey.setPressed(false);
if (mc.currentScreen != null) mc.interactionManager.stopUsingItem(mc.player);
} else {
++tridentHoldTicks;
if (tridentHoldTicks > 10) {
tridentHoldTicks = 0;
chargingTrident = false;
mc.options.useKey.setPressed(false);
if (mc.currentScreen != null) mc.interactionManager.stopUsingItem(mc.player);
} else {
++timer;
++ticksSinceWarned;
++ticksSinceNotified;
mc.options.useKey.setPressed(true);
if (!mc.player.isUsingItem()) Utils.rightClick();
return;
}
}
chargingTrident = false;
mc.interactionManager.stopUsingItem(mc.player);
}

Item activeItem = mc.player.getActiveItem().getItem();
Expand Down Expand Up @@ -605,7 +581,6 @@ private void onTick(TickEvent.Pre event) {
@EventHandler
private void onReceivePacket(PacketEvent.Receive event) {
if (!(event.packet instanceof PlaySoundS2CPacket packet)) return;

if (packet.getSound().value() == SoundEvents.ENTITY_FIREWORK_ROCKET_LAUNCH) {
if (muteRockets.get()) event.cancel();
}
Expand All @@ -620,14 +595,5 @@ private void onSentPacket(PacketEvent.Sent event) {
if (usageMode.get().equals("Auto Use")) {
timer = usageTickRate.get();
} else timer = usageCooldown.get();

tridentHoldTicks = 0;
if (usageMode.get().equals("Auto Use")) {
((IChatHud) mc.inGameHud.getChatHud()).meteor$add(
Text.of("§8<"+ StardustUtil.rCC()+"§o✨§r§8> §c§oVelocity was reset by server§7§o.. §a§oResetting cooldown in response§7§o!"),
"rocketmanTridentReset".hashCode()
);
}
useTrident();
}
}
1 change: 1 addition & 0 deletions src/main/resources/stardust.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"mixins": [
"WorldMixin",
"DoorBlockMixin",
"TridentItemMixin",
"GoatHornItemMixin",
"TridentBoostMixin",
"AnvilScreenHandlerAccessor"
Expand Down

0 comments on commit e9e20c9

Please sign in to comment.