Added 3 watchers. MiscDisguise now works
This commit is contained in:
parent
67256c118e
commit
0438639955
@ -36,8 +36,19 @@ public class Disguise {
|
||||
|
||||
} else if (getType().isMisc()) {
|
||||
|
||||
int id = 0;
|
||||
if (getType() == DisguiseType.PRIMED_TNT)
|
||||
id = 50;
|
||||
else if (getType() == DisguiseType.ENDER_CRYSTAL)
|
||||
id = 51;
|
||||
else if (getType() == DisguiseType.FALLING_BLOCK)
|
||||
id = 70;
|
||||
Entity entity = getEntity(((CraftPlayer) p).getHandle().world, p.getLocation(), p.getEntityId());
|
||||
spawnPacket = new Packet23VehicleSpawn(entity, 0);
|
||||
if (((MiscDisguise) this).getId() > 0)
|
||||
spawnPacket = new Packet23VehicleSpawn(entity, id, ((MiscDisguise) this).getId()
|
||||
| ((MiscDisguise) this).getData() << 16);
|
||||
else
|
||||
spawnPacket = new Packet23VehicleSpawn(entity, id);
|
||||
|
||||
} else if (getType().isPlayer()) {
|
||||
|
||||
@ -54,13 +65,14 @@ public class Disguise {
|
||||
}
|
||||
|
||||
public Entity getEntity(World world, Location loc, int entityId) {
|
||||
Entity entity = null;
|
||||
if (entity != null)
|
||||
return entity;
|
||||
try {
|
||||
String name = toReadable(disguiseType.name());
|
||||
if (disguiseType == DisguiseType.WITHER_SKELETON) {
|
||||
name = "Skeleton";
|
||||
}
|
||||
if (disguiseType == DisguiseType.TNT_PRIMED) {
|
||||
if (disguiseType == DisguiseType.PRIMED_TNT) {
|
||||
name = "TNTPrimed";
|
||||
}
|
||||
Class entityClass = Class.forName("net.minecraft.server.v1_5_R3.Entity" + name);
|
||||
@ -74,7 +86,6 @@ public class Disguise {
|
||||
}
|
||||
entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
|
||||
entity.id = entityId;
|
||||
this.entity = entity;
|
||||
try {
|
||||
String name;
|
||||
if (getType().isPlayer()) {
|
||||
|
@ -4,10 +4,11 @@ public enum DisguiseType {
|
||||
BAT(EntityType.MOB), BLAZE(EntityType.MOB), CAVE_SPIDER(EntityType.MOB), CHICKEN(EntityType.MOB), COW(EntityType.MOB), CREEPER(
|
||||
EntityType.MOB), ENDER_CRYSTAL(EntityType.MISC), ENDER_DRAGON(EntityType.MOB), ENDERMAN(EntityType.MOB), GHAST(
|
||||
EntityType.MOB), GIANT_ZOMBIE(EntityType.MOB), IRON_GOLEM(EntityType.MOB), MAGMA_CUBE(EntityType.MOB), MUSHROOM_COW(
|
||||
EntityType.MOB), OCELOT(EntityType.MOB), PIG(EntityType.MOB), PIG_ZOMBIE(EntityType.MOB), PLAYER(EntityType.PLAYER), SHEEP(EntityType.MOB), SILVERFISH(EntityType.MOB), SKELETON(EntityType.MOB), SLIME(EntityType.MOB), SNOWMAN(
|
||||
EntityType.MOB), SPIDER(EntityType.MOB), SQUID(EntityType.MOB), TNT_PRIMED(
|
||||
EntityType.MISC), VILLAGER(EntityType.MOB), WITCH(EntityType.MOB), WITHER(
|
||||
EntityType.MOB), WITHER_SKELETON(EntityType.MOB), WOLF(EntityType.MOB), ZOMBIE(EntityType.MOB);
|
||||
EntityType.MOB), OCELOT(EntityType.MOB), PIG(EntityType.MOB), PIG_ZOMBIE(EntityType.MOB), PLAYER(EntityType.PLAYER), SHEEP(
|
||||
EntityType.MOB), SILVERFISH(EntityType.MOB), SKELETON(EntityType.MOB), SLIME(EntityType.MOB), SNOWMAN(EntityType.MOB), SPIDER(
|
||||
EntityType.MOB), SQUID(EntityType.MOB), PRIMED_TNT(EntityType.MISC), VILLAGER(EntityType.MOB), WITCH(EntityType.MOB), WITHER(
|
||||
EntityType.MOB), WITHER_SKELETON(EntityType.MOB), WOLF(EntityType.MOB), ZOMBIE(EntityType.MOB), FALLING_BLOCK(
|
||||
EntityType.MISC);
|
||||
|
||||
public static enum EntityType {
|
||||
MISC, MOB, PLAYER;
|
||||
|
@ -1,9 +1,25 @@
|
||||
package me.libraryaddict.disguise.DisguiseTypes;
|
||||
|
||||
public class MiscDisguise extends Disguise {
|
||||
private int id = 1;
|
||||
private int data = 0;
|
||||
|
||||
public MiscDisguise(DisguiseType disguiseType) {
|
||||
super(disguiseType);
|
||||
}
|
||||
|
||||
public MiscDisguise(DisguiseType disguiseType, int id, int data) {
|
||||
super(disguiseType);
|
||||
this.id = id;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseTypes.FlagWatcher;
|
||||
|
||||
public class BatWatcher extends FlagWatcher {
|
||||
|
||||
protected BatWatcher(int entityId) {
|
||||
super(entityId);
|
||||
setValue(16, (byte) 1);
|
||||
}
|
||||
|
||||
public void setFlying(boolean flying) {
|
||||
if ((Byte) getValue(16) != (flying ? 1 : 0)) {
|
||||
setValue(16, (byte) (flying ? 1 : 0));
|
||||
sendData(16);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFlying() {
|
||||
return (Byte) getValue(16) == 0;
|
||||
}
|
||||
}
|
@ -6,9 +6,28 @@ public class EndermanWatcher extends FlagWatcher {
|
||||
|
||||
public EndermanWatcher(int entityId) {
|
||||
super(entityId);
|
||||
setValue(16, (byte) 0);
|
||||
setValue(17, (byte) 0);
|
||||
setValue(18, (byte) 0);
|
||||
}
|
||||
|
||||
public void setCarriedItem(int id, int dataValue) {
|
||||
if ((Byte) getValue(16) != id || (Byte) getValue(17) != dataValue) {
|
||||
setValue(16, (byte) (id & 255));
|
||||
setValue(17, (byte) (dataValue & 255));
|
||||
sendData(16);
|
||||
sendData(17);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCarriedId() {
|
||||
return (int) ((Byte) getValue(16));
|
||||
}
|
||||
|
||||
public int getCarriedData() {
|
||||
return (int) ((Byte) getValue(17));
|
||||
}
|
||||
|
||||
public boolean isAgressive() {
|
||||
return (Integer) getValue(18) == 1;
|
||||
}
|
||||
|
@ -5,5 +5,4 @@ public class MagmaCubeWatcher extends SlimeWatcher {
|
||||
public MagmaCubeWatcher(int entityId) {
|
||||
super(entityId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseTypes.FlagWatcher;
|
||||
|
||||
public class PrimedTntWatcher extends FlagWatcher {
|
||||
|
||||
public PrimedTntWatcher(int entityId) {
|
||||
super(entityId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
||||
|
||||
public class WitherWatcher extends EnderDragonWatcher {
|
||||
|
||||
public WitherWatcher(int entityId) {
|
||||
super(entityId);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user