Skip to content

Commit

Permalink
feat: add toggle speedwalk for villiagers
Browse files Browse the repository at this point in the history
  • Loading branch information
FordFriedel committed Dec 22, 2023
1 parent b39d150 commit 131e6ca
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.oddlama.vane.trifles;

import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerMoveEvent;
import org.oddlama.vane.annotation.config.ConfigBoolean;
import org.oddlama.vane.core.Listener;

import io.papermc.paper.event.entity.EntityMoveEvent;
Expand All @@ -16,6 +18,9 @@ public FastWalkingListener(FastWalkingGroup context) {
super(context);
this.fast_walking = context;
}

@ConfigBoolean(def = true, desc = "wether or not to speed villagers on path blocks.")
public boolean villager_speedwalk;

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void on_player_move(final PlayerMoveEvent event) {
Expand Down Expand Up @@ -45,6 +50,8 @@ public void on_player_move(final PlayerMoveEvent event) {
public void on_entity_move(final EntityMoveEvent event) {
final var entity = event.getEntity();

if(entity.getType() == EntityType.VILLAGER && villager_speedwalk == false) return;

// Inspect block type just a little below
var block = event.getTo().clone().subtract(0.0, 0.1, 0.0).getBlock();
if (!fast_walking.config_materials.contains(block.getType())) {
Expand Down

0 comments on commit 131e6ca

Please sign in to comment.