Skip to content

Commit

Permalink
Fix #268
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo56958 committed Feb 12, 2024
1 parent b7cca3f commit 6e5b215
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ public void onArrowHit(@NotNull final ProjectileHitEvent event) {

ItemStack tool = player.getInventory().getItemInMainHand();

if (event.getHitBlock() == null && !ToolType.FISHINGROD.contains(tool.getType())) return;
// Give fishing rods exp here instead of on launch as there is a durability cost on hit
if (ToolType.FISHINGROD.contains(tool.getType()))
modManager.addExp(player, tool, MineTinker.getPlugin().getConfig().getInt("ExpPerArrowShot"), true);

if (event.getEntity() instanceof Trident || event.getEntity() instanceof Arrow) {
List<MetadataValue> tools = event.getEntity().getMetadata(MineTinker.getPlugin().getName() + "item");
Expand Down Expand Up @@ -202,21 +204,20 @@ public void onProjectileLaunch(@NotNull final ProjectileLaunchEvent event) {

if (!modManager.durabilityCheck(event, player, tool)) return;

modManager.addExp(player, tool, MineTinker.getPlugin().getConfig().getInt("ExpPerArrowShot"), true);
if (!ToolType.FISHINGROD.contains(tool.getType())) // Disable Exp for spam clicking
modManager.addExp(player, tool, MineTinker.getPlugin().getConfig().getInt("ExpPerArrowShot"), true);

// add item reference to arrow
if(!event.getEntity().hasMetadata(MineTinker.getPlugin().getName() + "item")) {
if(!event.getEntity().hasMetadata(MineTinker.getPlugin().getName() + "item"))
event.getEntity().setMetadata(MineTinker.getPlugin().getName() + "item",
new FixedMetadataValue(MineTinker.getPlugin(), tool));
}

Bukkit.getPluginManager().callEvent(new MTProjectileLaunchEvent(player, tool, event));

// Trident#setItem only creates a NMScopy so this update step is necessary for every change to the ItemStack
if (event.getEntity() instanceof Trident trident) trident.setItem(tool);

/*
Self-Repair and Experienced will no longer trigger on bowfire
*/
// Self-Repair and Experienced will no longer trigger on bowfire
}

@EventHandler(ignoreCancelled = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void onShoot(final MTProjectileLaunchEvent event) {
arrow.setGravity(false);
//arrow.setGlowing(true);

final Vector velocity = arrow.getVelocity().multiply(this.multiplierArrowSpeed).clone();
final Vector velocity = arrow.getVelocity().multiply(this.multiplierArrowSpeed);
arrow.setVelocity(velocity.clone());
arrow.setDamage(arrow.getDamage() * Math.pow(this.multiplierDamagePerLevel, modLevel));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ public void onShoot(final MTProjectileLaunchEvent event) {
if (ToolType.CROSSBOW.contains(tool.getType()) && getConfig().getBoolean("UseEnchantOnCrossbow")) return;
if (!modManager.isToolViable(tool)) return;

int modLevel = modManager.getModLevel(tool, this);
final int modLevel = modManager.getModLevel(tool, this);
if (modLevel <= 0) return;

Vector vel = arrow.getVelocity().clone();
Location loc = arrow.getLocation().clone();
final Vector vel = arrow.getVelocity();
final Location loc = arrow.getLocation();

ChatWriter.logModifier(player, event, this, tool);

Expand Down

0 comments on commit 6e5b215

Please sign in to comment.