Minecraftのいつかのバージョンから、ゾンビや腐豚が落ちているアイテムを拾い、それを装備するようになりました。
これの装備をする機能をメソッドとして再現します。
まず作る前にバニラの機能をおさらいします。
![a][2]
(GIFでかいですね)
まず、MOBは一番いいものを装備します。
import org.bukkit.potion.PotionEffect; | |
import org.bukkit.potion.PotionEffectType; | |
public class DefaultPotion { | |
private static PotionEffect[][][] effect = { | |
{ | |
{ | |
null, | |
null, | |
null, |
import java.lang.reflect.Constructor; | |
import java.lang.reflect.Method; | |
import org.bukkit.Bukkit; | |
import org.bukkit.block.Block; | |
public class ChestLockReflect { | |
private static String version; | |
private static boolean v1_8 = false; | |
static { |
public static int getNextLevelExp(Player player) { | |
int max = player.getExpToLevel(); | |
return max - Math.round((float)max * player.getExp()); | |
} |
Location getTouchLocation(PlayerInteractEvent event) { | |
Action action = event.getAction(); | |
if(!(action.equals(Action.LEFT_CLICK_BLOCK) || action.equals(Action.RIGHT_CLICK_BLOCK))) return null; | |
Location O = event.getPlayer().getEyeLocation(); | |
Block block = event.getClickedBlock(); | |
Location P = block.getLocation().subtract(O); | |
double Yaw = (double)O.getYaw(); | |
if(Yaw > 0) Yaw -= 360; | |
double AngY = Math.toRadians(Math.abs(Yaw)); | |
double AngP = Math.toRadians(O.getPitch()*-1d); |
![][01]
![][02]
![][03]
![][04]
![][05]
![][06]
![][07]
![][08]
![][09]
![][10]
import java.lang.reflect.Method; | |
import org.bukkit.Bukkit; | |
import org.bukkit.Location; | |
import org.bukkit.World; | |
import org.bukkit.block.Block; | |
import org.bukkit.block.Sign; | |
import org.bukkit.entity.Player; | |
public class SignInterface { |