Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";")

group = "org.example"
version = providers.environmentVariable("VERSION").getOrElse("1.0.0")
version = providers.environmentVariable("VERSION").getOrElse("1.0.1")

labyMod {
defaultPackageName = "com.rappytv.autofisher"
Expand All @@ -16,7 +16,7 @@ labyMod {
displayName = "AutoFisher"
author = "RappyTV"
description = "Completely automate the way your fishing rod works"
minecraftVersion = "1.17.1<1.21.10"
minecraftVersion = "1.17.1<1.21.11"
version = rootProject.version.toString()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected void enable() {

this.registerSettingCategory();
this.registerListener(new FishingListener(this));
this.labyAPI().permissionRegistry().register(PERMISSION, true, true);
this.labyAPI().permissionRegistry().register(PERMISSION, false, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void onFishBite(FishHookBiteEvent event) {

@Subscribe
public void onHookRetract(FishHookRetractEvent event) {
if (!this.isAllowed() || !this.addon.configuration().autoCast().get() || !event.manual()) {
if (!this.isAllowed() || !this.addon.configuration().autoCast().get() || event.manual()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.rappytv.autofisher.v1_21_11;

import com.rappytv.autofisher.FishingController;
import com.rappytv.autofisher.core.AutoFisherAddon;
import javax.inject.Singleton;
import net.labymod.api.models.Implements;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.FishingHook;
import net.minecraft.world.item.FishingRodItem;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@Singleton
@Implements(FishingController.class)
public class VersionedFishingController extends FishingController {

@Override
public void castFishingRod() {
Player player = Minecraft.getInstance().player;
if (player == null) {
return;
}
InteractionHand hand = this.getFishingRodHand(player);
if (hand != null) {
this.useItem(hand);
}
}

@Override
public void retractFishingRod() {
Player player = Minecraft.getInstance().player;
if (player == null) {
return;
}
FishingHook hook = player.fishing;
if (hook == null) {
return;
}

InteractionHand hand = this.getFishingRodHand(player);
if (hand != null) {
AutoFisherAddon.fishingController().setManualRetraction(false);
this.useItem(hand);
}
}

@Nullable
private InteractionHand getFishingRodHand(@NotNull Player player) {
if (player.getMainHandItem().getItem() instanceof FishingRodItem) {
return InteractionHand.MAIN_HAND;
} else if (player.getOffhandItem().getItem() instanceof FishingRodItem) {
return InteractionHand.OFF_HAND;
}

return null;
}

private void useItem(@NotNull InteractionHand hand) {
Player player = Minecraft.getInstance().player;
if (player == null) {
return;
}

MultiPlayerGameMode gameMode = Minecraft.getInstance().gameMode;
if (gameMode == null) {
return;
}

gameMode.useItem(player, hand);
player.swing(hand);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.rappytv.autofisher.v1_21_11.mixins;

import com.rappytv.autofisher.core.AutoFisherAddon;
import com.rappytv.autofisher.event.FishHookBiteEvent;
import com.rappytv.autofisher.event.FishHookRetractEvent;
import net.labymod.api.Laby;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.world.entity.projectile.FishingHook;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(FishingHook.class)
public class MixinFishingHook {

@Shadow
private boolean biting;

@Inject(
method = "onClientRemoval",
at = @At("TAIL")
)
private void onRemove(CallbackInfo ci) {
boolean manual = AutoFisherAddon.fishingController().isManualRetraction();
Laby.fireEvent(new FishHookRetractEvent(manual));
if (!manual) {
AutoFisherAddon.fishingController().setManualRetraction(true);
}
}

@Inject(
method = "onSyncedDataUpdated",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/world/entity/projectile/FishingHook;biting:Z",
opcode = Opcodes.PUTFIELD,
shift = Shift.AFTER
)
)
private void onFishBiting(EntityDataAccessor<?> $$0, CallbackInfo ci) {
if (this.biting) {
Laby.fireEvent(new FishHookBiteEvent());
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
org.gradle.jvmargs=-Xmx4096m
net.labymod.minecraft-versions=1.8.9;1.12.2;1.16.5;1.17.1;1.18.2;1.19.2;1.19.3;1.19.4;1.20.1;1.20.2;1.20.4;1.20.5;1.20.6;1.21;1.21.1;1.21.3;1.21.4;1.21.5;1.21.8;1.21.10
net.labymod.minecraft-versions=1.8.9;1.12.2;1.16.5;1.17.1;1.18.2;1.19.2;1.19.3;1.19.4;1.20.1;1.20.2;1.20.4;1.20.5;1.20.6;1.21;1.21.1;1.21.3;1.21.4;1.21.5;1.21.8;1.21.10;1.21.11