Created
January 9, 2017 02:17
-
-
Save DenWav/0c2bdcbaac00a896bce5a75ca53c4002 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.demonwav.slimes; | |
import org.bukkit.Chunk; | |
import org.bukkit.entity.Player; | |
import org.bukkit.plugin.java.JavaPlugin; | |
import java.util.Random; | |
public final class Slimes extends JavaPlugin { | |
@Override | |
public void onEnable() { | |
getCommand("checkslimechunk").setExecutor((sender, command, label, args) -> { | |
if (!(sender instanceof Player)) { | |
sender.sendMessage("You must be a player to use this command."); | |
return true; | |
} | |
final Player player = (Player) sender; | |
final Chunk chunk = player.getWorld().getChunkAt(player.getLocation()); | |
final int x = chunk.getX(); | |
final int z = chunk.getZ(); | |
final long seed = player.getWorld().getSeed(); | |
final Random rand = new Random(seed + (long) (x * x * 0x4c1906) + (long) (x * 0x5ac0db) + (long) (z * z) * 0x4307a7L + (long) (z * 0x5f24f) ^ 0x3ad8025f); | |
if (rand.nextInt(10) == 0) { | |
player.sendMessage("You are in a slime chunk."); | |
} else { | |
player.sendMessage("You are not in a slime chunk."); | |
} | |
return true; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment