Custom Entity

Discussion in 'Plugin Development' started by MCJoshua345, Mar 30, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    Hello. I'm making a command that spawns a custom entity. (Class code below)
    package com.infinity.lobby.misc;
    import org.bukkit.ChatColor;
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Guardian;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    public class CustomGuardian implements Listener, CommandExecutor{
        public void damageDetector(EntityDamageByEntityEvent e){
            Entity victim = e.getEntity();
            if(victim instanceof Guardian){
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            if(!(sender instanceof Player)){
                sender.sendMessage(ChatColor.WHITE + "Unknown command. Type \"/help\" for help.");
                return true;
            Player p = (Player) sender;
                    World world = Bukkit.getServer().getWorld("world");
                    Location ploc = p.getLocation();
                }else if(!p.hasPermission("lobby.owner")){
                    sender.sendMessage(ChatColor.WHITE + "Unknown command. Type \"/help\" for help.");
                    return true;
            return false;
    It spawns at the players location, doesn't move, and has a custom name. I can do all of this (except maybe the no move thing, I was just thinking about giving it a slowness potion effect that the time and power is Integer.MAX_VALUE), if I can just put the entity spawned into a variable so that I can modify it's name etc. Thank you for your help!

    Keep Blocking,
    - xXInfinityXx (Formerly MCJoshua345)
  2. Offline


    @MCJoshua345 you can keep it as a class variable, I am a little confused, I don't get what the problem is.
    Also to prevent it from moving,clear its pathfinder goals or at least the ones not needed such as the ones involved with movement.
  3. Offline


    I wanted to make a entity variable so I could modify some of it's minor properties.
    So basically I should just make another class that extends EntityGuardian and define the properties needed? Sounds good, not going to mark it solved 'till it's achived, but thanks.
  4. Entity e = world.spawnCreature(...);
  5. Offline


    Ha! I knew it was that, I just wasn't sure. Thank you so much!
  6. You're welcome :p
  7. Offline


    Oh, also, does It (the entity) spawn automatically?
  8. world.spawnCreature spawns the Entity and returns a Entity
  9. Offline


    I know that, but I mean when you make the variable, how do you spawn it? return (entity variable);? Just a guess.
  10. The mehod already spawns the entity.
Thread Status:
Not open for further replies.

Share This Page