mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-29 12:07:54 +01:00
Randomize spawn location of Call of the Wild pets
So that when you’re spawning multiple pets at once, they don’t all spawn at the same spot.
This commit is contained in:
parent
e71eff852c
commit
ebeebbde72
@ -277,6 +277,7 @@ public class TamingManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
location = Misc.getLocationOffset(location, 1);
|
||||
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(location, type);
|
||||
|
||||
FakeEntityTameEvent event = new FakeEntityTameEvent(entity, player);
|
||||
|
@ -144,6 +144,23 @@ public final class Misc {
|
||||
return "UnknownMods";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a random location near the specified location
|
||||
*/
|
||||
public static Location getLocationOffset(Location location, double strength) {
|
||||
double blockX = location.getBlockX();
|
||||
double blockZ = location.getBlockZ();
|
||||
|
||||
double distance;
|
||||
distance = strength * random.nextDouble();
|
||||
blockX = (random.nextBoolean()) ? blockX + (distance) : blockX - (distance);
|
||||
|
||||
distance = strength * random.nextDouble();
|
||||
blockZ = (random.nextBoolean()) ? blockZ + (distance) : blockZ - (distance);
|
||||
|
||||
return new Location(location.getWorld(), blockX, location.getY(), blockZ);
|
||||
}
|
||||
|
||||
public static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user