Skip to content

Commit

Permalink
Karkinos sweep
Browse files Browse the repository at this point in the history
Added:
 - Karkinos being spawned from fishing hook. (May need to tweak that velocity)
  • Loading branch information
dragonflame86 committed Feb 5, 2024
1 parent 78e8917 commit 6eabce1
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import dev.hybridlabs.aquatic.access.CustomFishingBobberEntityData;
import dev.hybridlabs.aquatic.enchantment.HybridAquaticEnchantments;
import dev.hybridlabs.aquatic.enchantment.LiveCatchEnchantment;
import dev.hybridlabs.aquatic.entity.HybridAquaticEntityTypes;
import dev.hybridlabs.aquatic.entity.critter.KarkinosEntity;
import dev.hybridlabs.aquatic.item.HybridAquaticItems;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
Expand All @@ -26,6 +28,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
Expand All @@ -44,6 +47,8 @@
public abstract class FishingBobberEntityMixin extends ProjectileEntity implements CustomFishingBobberEntityData {
@Shadow private int waitCountdown;

@Shadow @Nullable public abstract PlayerEntity getPlayerOwner();

public FishingBobberEntityMixin(EntityType<? extends ProjectileEntity> entityType, World world) {
super(entityType, world);
}
Expand Down Expand Up @@ -193,6 +198,35 @@ private boolean changeSpawnEntity(World instance, Entity entity) {
return instance.spawnEntity(entity);
}

// Whenever we may want to replace entities we use this. This will make sure not to spawn any unwanted entities when we reel in the hook.
@Inject(
method = "use",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/loot/LootTable;generateLoot(Lnet/minecraft/loot/context/LootContextParameterSet;)Lit/unimi/dsi/fastutil/objects/ObjectArrayList;"
), cancellable = true
)
private void onHookReelEntity(ItemStack usedItem, CallbackInfoReturnable<Integer> cir) {
if(!lureItemStack.isEmpty()) {
if(lureItemStack.isOf(HybridAquaticItems.INSTANCE.getOMINOUS_HOOK()) && getPlayerOwner() != null) {
var karkinos = HybridAquaticEntityTypes.INSTANCE.getKARKINOS().create(getWorld());
getWorld().spawnEntity(karkinos);
karkinos.setPosition(getPos().subtract(0,1,0));

var playerPos = getPlayerOwner().getPos();
var karkinosPos = karkinos.getPos();

var velocity = playerPos.subtract(karkinosPos);
velocity.multiply(1.015,1.015,1.015); // Tweak these to your hearts content mystic

karkinos.setVelocity(velocity);

this.discard();
cir.cancel();
}
}
}

// Returns lure back on a successful fishing attempt
@Inject(
method = "use",
Expand Down

0 comments on commit 6eabce1

Please sign in to comment.