1.8.8 MobEffect Not Working

Discussion in 'Spigot Plugin Development' started by Jacrispys, Feb 26, 2021.

  1. I am creating custom withers (miniwithers) for part of a minigame plugin I am making and I don't want them to move so rather than spending 20 minutes finding and removing all pathfinders with NMS I took the lazy route and created a new MobEffect for slowness... After applying it to the Withers nothing happens, and when I print the list of effects it is blank here is my code...

    Code (Java):
    CraftPlayer CraftP = (CraftPlayer) p;

                                EntityWither GameWithers = new EntityWither(CraftP.getHandle().getWorld());
                                net.minecraft.server.v1_8_R3.Entity nmsEntity = (GameWithers.getBukkitEntity().getHandle());

                                NBTTagCompound size = new NBTTagCompound();
                                MobEffect Slowness = new MobEffect(2, Integer.MAX_VALUE, 255, true, false);

                                nmsEntity.c(size);
                                size.setInt("Invul", 600);
                                GameWithers.a(size);
                                Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new BukkitRunnable() {
                                    @Override
                                    public void run() {
                                        GameWithers.a(size);
                                    }
                                }, 1, 1);
                                ConfigurationSection Witherlocations = plugin.getConfig().getConfigurationSection("MiniWalls.Worlds.1.Wither-Locations." + i);
                                double x = Double.parseDouble(plugin.getConfig().getConfigurationSection("MiniWalls.Worlds.1.Wither-Locations." + i).getString("x"));
                                double y = Double.parseDouble(plugin.getConfig().getConfigurationSection("MiniWalls.Worlds.1.Wither-Locations." + i).getString("y"));
                                double z = Double.parseDouble(plugin.getConfig().getConfigurationSection("MiniWalls.Worlds.1.Wither-Locations." + i).getString("z"));
                                Location loc = new Location(p.getWorld(), x, y, z, 0F, 0F);
                                GameWithers.addEffect(Slowness);
                                p.sendMessage(GameWithers.getEffects().toString());
                                GameWithers.teleportTo(loc, false);
                                p.sendMessage("Wither teleported to " + Witherlocations.getString("Color") + " Coordinates: " + loc.toString());
     
  2. Well, why are you even using NMS, for instance?
     
  3. Have you tried
    - removing the ai(will completly shut the wither off)
    - setting base movement speed to 0
    - runnable teleporting him back
     
  4. I can't remove the AI as I need it to Attack any team that is not yours, A runnable is to jittery and I don't want to cause lag, but I haven't tried setting base movement speed to 0 I'll try that.
     
  5. I tried this code:
    Code (Java):
    GameWithers.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0);
    and the Wither didn't move at first but when I spawned a cow its just dipped.
     
  6. It'd honestly be super quick to just make a NMS entity. better performance too.
     
  7. What do you mean by an NMS entity isnt that what this is?

    Code (Java):
    EntityWither GameWithers = new EntityWither(CraftP.getHandle().getWorld());
    net.minecraft.server.v1_8_R3.Entity nmsEntity = (GameWithers.getBukkitEntity().getHandle());
     
  8. Yes thats a nms entity,however he is mostly refering to create a custom one and set its behaviour(aka the pathfinder you try to avoid)
     
  9. Oh ok, I think I referenced that in my initial post but was to lazy, if I were to remove all pathfinders that would stop its movement but would that also remove its targetting? Also im not entirely sure how to remove path finders as NMS is hard to find documentation on :p
     
  10. Well the pathfinders are bit tricky i tgink there are multiple ones both for targeting and moving but we have plenty of guides about it though
     
  11. Oh cool, could you direct me to one of those guides?
     
  12. Just look into the EntityWither class and the goalselectors that are setup for it (In the constructor). Override the move method and do nothing.

    For anyone else:

    1.8.8 R3:

    • Does not collide.
    • Does not take damage.
    • Does not move.
    • Baby wither
    Code (Java):
    public final class Wither extends EntityWither {

        public Wither(World world) {
            super(world);
            Bukkit.getScheduler().runTaskTimer(plugin, () -> {
                r(600);
            }, 0L, 1L);
        }

        @Override
        public void collide(Entity entity) {

        }

        @Override
        public boolean damageEntity(DamageSource damagesource, float f) {
            return false;
        }

        @Override
        public void move(double d0, double d1, double d2) {

        }
     
    #13 Sean0402, Feb 26, 2021
    Last edited: Feb 26, 2021