-
Bug
-
Resolution: Invalid
-
Minor
-
None
-
None
-
Windows 10, Eclipse Neon
Hello,
I create a witch with different IA who work very well in 1.10, but after the update in 1.11, he's become invisible (he can push me and I hear it).
The class I use to spawn :
import java.lang.reflect.Field; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_11_R1.CraftWorld; import net.minecraft.server.v1_11_R1.Entity; import net.minecraft.server.v1_11_R1.MinecraftKey; public enum WardenWitchType { WARDENWITCH("Warden Witch", 150, WardenWitch.class, "warden_witch"); private WardenWitchType(String name, int id, Class<? extends Entity> clazz, String name2) { addToMaps(clazz, name, id, name2); } public static void spawnEntity(Entity ent, Location loc) { ent.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); ((CraftWorld) loc.getWorld()).getHandle().addEntity(ent); } //@SuppressWarnings({ "unchecked", "rawtypes" }) private static void addToMaps(Class<? extends Entity> clazz, String name, int id, String name2) { MinecraftKey key = new MinecraftKey(name2); // ((Map) getPrivateField("c", EntityTypes.class, null)).put(name, clazz); // ((Map) getPrivateField("d", EntityTypes.class, null)).put(clazz, name); // ((Map) getPrivateField("f", EntityTypes.class, null)).put(clazz, Integer.valueOf(id)); //comparer cb 1.10 et 1.11 field pour trouver erreur //EntityTypes.b.a(id, key, clazz); //EntityTypes.d.add(key); //((List) getPrivateField("g", EntityTypes.class, null)).add(name2); } public static Object getPrivateField(String fieldName, @SuppressWarnings("rawtypes") Class clazz, Object object) { Field field; Object o = null; try { field = clazz.getDeclaredField(fieldName); field.setAccessible(true); o = field.get(object); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return o; } }
import java.lang.reflect.Field; import java.util.HashSet; import net.minecraft.server.v1_11_R1.EntityHuman; import net.minecraft.server.v1_11_R1.EntityWitch; import net.minecraft.server.v1_11_R1.PathfinderGoalFloat; import net.minecraft.server.v1_11_R1.PathfinderGoalHurtByTarget; import net.minecraft.server.v1_11_R1.PathfinderGoalLookAtPlayer; import net.minecraft.server.v1_11_R1.PathfinderGoalMeleeAttack; import net.minecraft.server.v1_11_R1.PathfinderGoalMoveThroughVillage; import net.minecraft.server.v1_11_R1.PathfinderGoalMoveTowardsRestriction; import net.minecraft.server.v1_11_R1.PathfinderGoalNearestAttackableTarget; import net.minecraft.server.v1_11_R1.PathfinderGoalRandomLookaround; import net.minecraft.server.v1_11_R1.PathfinderGoalRandomStroll; import net.minecraft.server.v1_11_R1.PathfinderGoalSelector; import net.minecraft.server.v1_11_R1.World; public class WardenWitch extends EntityWitch{ @SuppressWarnings("rawtypes") public WardenWitch(World w) { super(w); this.setSize(0.6f, 1.95f); HashSet goalB = (HashSet)getPrivateField("b", PathfinderGoalSelector.class, goalSelector); goalB.clear(); HashSet goalC = (HashSet)getPrivateField("c", PathfinderGoalSelector.class, goalSelector); goalC.clear(); HashSet targetB = (HashSet)getPrivateField("b", PathfinderGoalSelector.class, targetSelector); targetB.clear(); HashSet targetC = (HashSet)getPrivateField("c", PathfinderGoalSelector.class, targetSelector); targetC.clear(); this.goalSelector.a(0, new PathfinderGoalFloat(this)); // this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false)); this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false)); this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true)); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<EntityHuman>(this, EntityHuman.class, true)); } @SuppressWarnings("rawtypes") public static Object getPrivateField(String fieldName, Class clazz, Object object) { Field field; Object o = null; try { field = clazz.getDeclaredField(fieldName); field.setAccessible(true); o = field.get(object); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return o; }
public static void spawnWizard(Location loc){ BukkitTask task = Bukkit.getScheduler().runTask(WardenRevolt.getInstance(), new Runnable() { @Override public void run() { WardenWitch witch = new WardenWitch(((CraftWorld) loc.getWorld()).getHandle()); witch.setCustomName(ChatColor.DARK_GREEN+"Mages"); witch.setInvulnerable(true); WardenWitchType.spawnEntity(witch, loc); } }); }
Here's a video to demonstrate :
youtube