46 lines
1.8 KiB
Java
46 lines
1.8 KiB
Java
package com.kasetoatz.tridenthacks.mixin;
|
|
|
|
import com.kasetoatz.tridenthacks.config.Config;
|
|
import com.kasetoatz.tridenthacks.TridentHacks;
|
|
import net.minecraft.entity.LivingEntity;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import net.minecraft.entity.player.PlayerInventory;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.item.TridentItem;
|
|
import net.minecraft.sound.SoundCategory;
|
|
import net.minecraft.sound.SoundEvents;
|
|
import net.minecraft.world.World;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
|
|
@Mixin(TridentItem.class)
|
|
public class TridentItemMixin
|
|
{
|
|
@Inject(method="onStoppedUsing", at=@At("HEAD"))
|
|
private void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks, CallbackInfoReturnable<Boolean> cir)
|
|
{
|
|
if (Config.toggleRiptide)
|
|
{
|
|
PlayerEntity player = TridentHacks.client.player;
|
|
if (user == player && user.getItemUseTime() > 10)
|
|
{
|
|
if (TridentHacks.noNormalRiptide())
|
|
{
|
|
world.playSoundFromEntity(player, player, SoundEvents.ITEM_TRIDENT_RIPTIDE_3.value(), SoundCategory.PLAYERS, 1.F, 1.F);
|
|
TridentHacks.lastTridentUse = System.currentTimeMillis();
|
|
}
|
|
TridentHacks.onGround = false;
|
|
}
|
|
}
|
|
else if (Config.returnToSameSlot && !TridentHacks.hasRiptide)
|
|
{
|
|
PlayerEntity player = TridentHacks.client.player;
|
|
if (player != null)
|
|
{
|
|
TridentHacks.tridentSlot = (user.getOffHandStack() == stack) ? PlayerInventory.OFF_HAND_SLOT : player.getInventory().getSelectedSlot();
|
|
}
|
|
}
|
|
}
|
|
} |