Remove leash if leashable is false in entities

This commit is contained in:
fullwall 2013-07-10 00:08:19 +08:00
parent c7057656a3
commit fd51c577ce
30 changed files with 90 additions and 1 deletions

View File

@ -69,11 +69,15 @@ public class BatController extends MobEntityController {
@Override @Override
public boolean bH() { public boolean bH() {
if (npc == null) if (npc == null) {
return super.bH(); return super.bH();
}
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -63,6 +63,9 @@ public class BlazeController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -71,6 +71,9 @@ public class CaveSpiderController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -70,6 +70,9 @@ public class ChickenController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -71,6 +71,9 @@ public class CowController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -78,6 +78,9 @@ public class CreeperController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -63,6 +63,9 @@ public class EnderDragonController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -70,6 +70,9 @@ public class EndermanController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -49,6 +49,9 @@ public class GhastController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -49,6 +49,9 @@ public class GiantController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -49,6 +49,9 @@ public class HorseController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -56,6 +56,9 @@ public class IronGolemController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -57,6 +57,9 @@ public class MagmaCubeController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -57,6 +57,9 @@ public class MushroomCowController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -57,6 +57,9 @@ public class OcelotController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -63,6 +63,9 @@ public class PigController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -57,6 +57,9 @@ public class PigZombieController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -57,6 +57,9 @@ public class SheepController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -56,6 +56,9 @@ public class SilverfishController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -56,6 +56,9 @@ public class SkeletonController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -58,6 +58,9 @@ public class SlimeController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -56,6 +56,9 @@ public class SnowmanController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -56,6 +56,9 @@ public class SpiderController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -49,6 +49,9 @@ public class SquidController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -64,6 +64,9 @@ public class VillagerController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -56,6 +56,9 @@ public class WitchController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -57,6 +57,9 @@ public class WitherController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -57,6 +57,9 @@ public class WolfController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -57,6 +57,9 @@ public class ZombieController extends MobEntityController {
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
return super.bH(); return super.bH();
if (super.bH()) {
a(true, false); // clearLeash with client update
}
return false; // shouldLeash return false; // shouldLeash
} }

View File

@ -396,6 +396,7 @@ public class NMS {
} }
private static final float DEFAULT_SPEED = 1F; private static final float DEFAULT_SPEED = 1F;
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT; private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
private static final Map<Class<?>, Constructor<?>> ENTITY_CONSTRUCTOR_CACHE = new WeakHashMap<Class<?>, Constructor<?>>(); private static final Map<Class<?>, Constructor<?>> ENTITY_CONSTRUCTOR_CACHE = new WeakHashMap<Class<?>, Constructor<?>>();
private static Map<Integer, Class<?>> ENTITY_INT_TO_CLASS; private static Map<Integer, Class<?>> ENTITY_INT_TO_CLASS;