mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 16:09:24 +00:00
Changed teleportation
This commit is contained in:
@@ -134,24 +134,36 @@ public class AttackListeners implements Listener {
|
|||||||
if (IllusionerManager.OPTIONS.getGameplayOptions().isTeleport()) {
|
if (IllusionerManager.OPTIONS.getGameplayOptions().isTeleport()) {
|
||||||
if (NumberUtils.randFloat(0, 100) < IllusionerManager.OPTIONS.getGameplayOptions().getTeleportChance()) {
|
if (NumberUtils.randFloat(0, 100) < IllusionerManager.OPTIONS.getGameplayOptions().getTeleportChance()) {
|
||||||
int range = IllusionerManager.OPTIONS.getGameplayOptions().getTeleportRange();
|
int range = IllusionerManager.OPTIONS.getGameplayOptions().getTeleportRange();
|
||||||
|
List<Location> valid = new ArrayList<>();
|
||||||
for (int x = -range; x <= range; x++) {
|
for (int x = -range; x <= range; x++) {
|
||||||
for (int y = -range; y <= range; y++) {
|
for (int y = -range; y <= range; y++) {
|
||||||
for (int z = -range; z <= range; z++) {
|
for (int z = -range; z <= range; z++) {
|
||||||
Location location = event.getEntity().getLocation().clone();
|
Location location = event.getEntity().getLocation().clone();
|
||||||
location.setX(x);
|
location.setX(location.getX() + x);
|
||||||
location.setY(y);
|
location.setY(location.getY() + y);
|
||||||
location.setZ(z);
|
location.setZ(location.getZ() + z);
|
||||||
|
|
||||||
Block block = location.getBlock();
|
Block block = location.getBlock();
|
||||||
|
|
||||||
if (block.getType() == Material.AIR && block.getRelative(BlockFace.UP).getType() == Material.AIR) {
|
if (block.getType() == Material.AIR
|
||||||
event.getEntity().teleport(location);
|
&& block.getRelative(BlockFace.UP).getType() == Material.AIR
|
||||||
OptionedSound optionedSound = IllusionerManager.OPTIONS.getGameplayOptions().getTeleportSound();
|
&& !(block.getRelative(BlockFace.DOWN).isLiquid() || block.getRelative(BlockFace.DOWN).getType() == Material.AIR)) {
|
||||||
location.getWorld().playSound(location, optionedSound.getSound(), optionedSound.getVolume(), optionedSound.getPitch());
|
valid.add(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (valid.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.shuffle(valid);
|
||||||
|
Location location = valid.get(0);
|
||||||
|
|
||||||
|
event.getEntity().teleport(location);
|
||||||
|
OptionedSound optionedSound = IllusionerManager.OPTIONS.getGameplayOptions().getTeleportSound();
|
||||||
|
location.getWorld().playSound(location, optionedSound.getSound(), optionedSound.getVolume(), optionedSound.getPitch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class GameplayOptions extends PluginDependent {
|
|||||||
|
|
||||||
teleport = this.getPlugin().getConfigYml().getBool("teleport-on-damage.enabled");
|
teleport = this.getPlugin().getConfigYml().getBool("teleport-on-damage.enabled");
|
||||||
teleportRange = this.getPlugin().getConfigYml().getInt("teleport-on-damage.range");
|
teleportRange = this.getPlugin().getConfigYml().getInt("teleport-on-damage.range");
|
||||||
teleportChance = this.getPlugin().getConfigYml().getInt("teleport-on-damage.chance");
|
teleportChance = this.getPlugin().getConfigYml().getDouble("teleport-on-damage.chance");
|
||||||
|
|
||||||
Sound sound = Sound.valueOf(IllusionerConfigs.SOUNDS.getString("teleport.sound"));
|
Sound sound = Sound.valueOf(IllusionerConfigs.SOUNDS.getString("teleport.sound"));
|
||||||
float volume = (float) IllusionerConfigs.SOUNDS.getDouble("teleport.volume");
|
float volume = (float) IllusionerConfigs.SOUNDS.getDouble("teleport.volume");
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ ignore-suffocation-damage: true
|
|||||||
|
|
||||||
teleport-on-damage:
|
teleport-on-damage:
|
||||||
enabled: true
|
enabled: true
|
||||||
range: 10
|
range: 7
|
||||||
chance: 15 # As a percentage
|
chance: 15 # As a percentage
|
||||||
|
|
||||||
spawn:
|
spawn:
|
||||||
|
|||||||
Reference in New Issue
Block a user