Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to catch entities with fishing #301

Merged
merged 5 commits into from
Jul 6, 2024

Conversation

ErikSzabo
Copy link
Contributor

This PR adds a new entity loot type for fishing (or it can be added to other loot tables as well, it just didn't really make sense).
The caught entity can be a vanilla entity (typically a mob) or a MythicMobs using the mythicmobs: prefix. Entity health, damage, and level can also be configured.

The vertical and horizontal velocities are also configurable for fishing but already have default values.

Example configuration in fishing.yml:

type: fishing
pools:
  rare:
    base_chance: 100
    selection_priority: 1
    loot:
      - type: entity
        entity: zombie
        name: "&6My Little Zombie"
        weight: 50
        health: 100
        damage: 100
        velocity:
          horizontal: 1.2
          vertical: 1.3
      - type: entity
        entity: mythicmobs:SkeletonKing
        weight: 50
        level: 10

Comment on lines 126 to 135
Location location = event.getHook().getLocation();
Entity entity = loot.getEntity().spawnEntity(plugin, event.getHook().getLocation());

LootDropEvent dropEvent = new LootDropEvent(player, plugin.getUser(player).toApi(), entity, event.getHook().getLocation(), cause);
Bukkit.getPluginManager().callEvent(dropEvent);

if (dropEvent.isCancelled()) {
loot.getEntity().removeEntity(entity);
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be dumb if the event is canceled since the entity will spawn and will be removed immediately. Sadly I don't know any other way without using NMS.

Copy link
Owner

@Archy-X Archy-X left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial formatting review, will need to test in game personally later.

return new EntityProperties(
id.length > 1 ? id[1] : id[0],
config.node("name").getString(),
config.node("level").empty() ? null :config.node("level").getInt(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure space after colon

itemEntity.setItemStack(new ItemStack(Material.AIR));

Float hVelocity = loot.getEntity().getEntityProperties().horizontalVelocity();
if(hVelocity == null) hVelocity = 1.2f;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after if

}

if (getEntityProperties().level() != null) {
entity.setMetadata("aura_skills_level", new FixedMetadataValue(plugin, getEntityProperties().level()));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auraskills should be one word without an underscore

@ErikSzabo
Copy link
Contributor Author

Made those changes. Also enabled auto formatting in Intellij on save for the future :'D

@Archy-X Archy-X merged commit ff5e888 into Archy-X:master Jul 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants