Bonjour,
J'aimerais savoir comment faire pour faire despawn un NPC.
Ma classe NPCManager :
Merci
J'aimerais savoir comment faire pour faire despawn un NPC.
Ma classe NPCManager :
Code:
package net.cheatwarn.utils;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import com.mojang.authlib.GameProfile;
import net.cheatwarn.cheats.combat.ForceFieldAndCommand;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.MinecraftServer;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_11_R1.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_11_R1.PlayerConnection;
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
import net.minecraft.server.v1_11_R1.WorldServer;
import net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
public class NpcManager {
public static void createNPC(Player player, String npcname) {
Location location = ForceFieldAndCommand.location;
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer world = ((CraftWorld) player.getWorld()).getHandle();
GameProfile gameprofile = new GameProfile(UUID.fromString("13e54afa-88dc-11e7-bb31-be2e44b06b34"), player.getName().toString());
EntityPlayer npc = new EntityPlayer(server, world, gameprofile,new PlayerInteractManager(world));
Player npcPlayer = npc.getBukkitEntity().getPlayer();
npcPlayer.setDisplayName("");
npc.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, npc));
a
}
}
Merci