use of simplepets.brainsynder.nms.v1_13_R1.entities.impossamobs.EntityShulkerPet in project SimplePets by brainsynder-Dev.
the class EntityPet method glowHandler.
private void glowHandler(boolean glow) {
try {
if (this instanceof IEntityControllerPet) {
org.bukkit.entity.Entity ent = ((IEntityControllerPet) this).getVisibleEntity().getEntity();
Entity handle = ((CraftEntity) ent).getHandle();
if (handle instanceof EntityArmorStandPet) {
EntityArmorStandPet pet = (EntityArmorStandPet) handle;
DataWatcher toCloneDataWatcher = pet.getDataWatcher();
DataWatcher newDataWatcher = new DataWatcher(pet);
Map<Integer, DataWatcher.Item<?>> currentMap = (Map<Integer, DataWatcher.Item<?>>) FieldUtils.readDeclaredField(toCloneDataWatcher, "d", true);
Map<Integer, DataWatcher.Item<?>> newMap = Maps.newHashMap();
for (Integer integer : currentMap.keySet()) {
newMap.put(integer, currentMap.get(integer).d());
}
DataWatcher.Item item = newMap.get(0);
byte initialBitMask = (Byte) item.b();
byte bitMaskIndex = (byte) 6;
isGlowing = glow;
if (glow) {
item.a((byte) (initialBitMask | 1 << bitMaskIndex));
} else {
item.a((byte) (initialBitMask & ~(1 << bitMaskIndex)));
}
FieldUtils.writeDeclaredField(newDataWatcher, "d", newMap, true);
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(pet.getId(), newDataWatcher, true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(metadataPacket);
} else if (handle instanceof EntityShulkerPet) {
EntityShulkerPet pet = (EntityShulkerPet) handle;
DataWatcher toCloneDataWatcher = pet.getDataWatcher();
DataWatcher newDataWatcher = new DataWatcher(pet);
Map<Integer, DataWatcher.Item<?>> currentMap = (Map<Integer, DataWatcher.Item<?>>) FieldUtils.readDeclaredField(toCloneDataWatcher, "d", true);
Map<Integer, DataWatcher.Item<?>> newMap = Maps.newHashMap();
for (Integer integer : currentMap.keySet()) {
newMap.put(integer, currentMap.get(integer).d());
}
DataWatcher.Item item = newMap.get(0);
byte initialBitMask = (Byte) item.b();
byte bitMaskIndex = (byte) 6;
isGlowing = glow;
if (glow) {
item.a((byte) (initialBitMask | 1 << bitMaskIndex));
} else {
item.a((byte) (initialBitMask & ~(1 << bitMaskIndex)));
}
FieldUtils.writeDeclaredField(newDataWatcher, "d", newMap, true);
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(pet.getId(), newDataWatcher, true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(metadataPacket);
} else {
EntityPet pet = this;
DataWatcher toCloneDataWatcher = pet.getDataWatcher();
DataWatcher newDataWatcher = new DataWatcher(pet);
Map<Integer, DataWatcher.Item<?>> currentMap = (Map<Integer, DataWatcher.Item<?>>) FieldUtils.readDeclaredField(toCloneDataWatcher, "d", true);
Map<Integer, DataWatcher.Item<?>> newMap = Maps.newHashMap();
for (Integer integer : currentMap.keySet()) {
newMap.put(integer, currentMap.get(integer).d());
}
DataWatcher.Item item = newMap.get(0);
byte initialBitMask = (Byte) item.b();
byte bitMaskIndex = (byte) 6;
isGlowing = glow;
if (glow) {
item.a((byte) (initialBitMask | 1 << bitMaskIndex));
} else {
item.a((byte) (initialBitMask & ~(1 << bitMaskIndex)));
}
FieldUtils.writeDeclaredField(newDataWatcher, "d", newMap, true);
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(pet.getId(), newDataWatcher, true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(metadataPacket);
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
use of simplepets.brainsynder.nms.v1_13_R1.entities.impossamobs.EntityShulkerPet in project SimplePets by brainsynder-Dev.
the class EntityPet method glowHandler.
private void glowHandler(boolean glow) {
try {
if (this instanceof IEntityControllerPet) {
org.bukkit.entity.Entity ent = ((IEntityControllerPet) this).getVisibleEntity().getEntity();
Entity handle = ((CraftEntity) ent).getHandle();
if (handle instanceof EntityArmorStandPet) {
EntityArmorStandPet pet = (EntityArmorStandPet) handle;
DataWatcher toCloneDataWatcher = pet.getDataWatcher();
DataWatcher newDataWatcher = new DataWatcher(pet);
Map<Integer, DataWatcher.Item<?>> currentMap = (Map<Integer, DataWatcher.Item<?>>) FieldUtils.readDeclaredField(toCloneDataWatcher, "d", true);
Map<Integer, DataWatcher.Item<?>> newMap = Maps.newHashMap();
for (Integer integer : currentMap.keySet()) {
newMap.put(integer, currentMap.get(integer).d());
}
DataWatcher.Item item = newMap.get(0);
byte initialBitMask = (Byte) item.b();
byte bitMaskIndex = (byte) 6;
isGlowing = glow;
if (glow) {
item.a((byte) (initialBitMask | 1 << bitMaskIndex));
} else {
item.a((byte) (initialBitMask & ~(1 << bitMaskIndex)));
}
FieldUtils.writeDeclaredField(newDataWatcher, "d", newMap, true);
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(pet.getId(), newDataWatcher, true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(metadataPacket);
} else if (handle instanceof EntityShulkerPet) {
EntityShulkerPet pet = (EntityShulkerPet) handle;
DataWatcher toCloneDataWatcher = pet.getDataWatcher();
DataWatcher newDataWatcher = new DataWatcher(pet);
Map<Integer, DataWatcher.Item<?>> currentMap = (Map<Integer, DataWatcher.Item<?>>) FieldUtils.readDeclaredField(toCloneDataWatcher, "d", true);
Map<Integer, DataWatcher.Item<?>> newMap = Maps.newHashMap();
for (Integer integer : currentMap.keySet()) {
newMap.put(integer, currentMap.get(integer).d());
}
DataWatcher.Item item = newMap.get(0);
byte initialBitMask = (Byte) item.b();
byte bitMaskIndex = (byte) 6;
isGlowing = glow;
if (glow) {
item.a((byte) (initialBitMask | 1 << bitMaskIndex));
} else {
item.a((byte) (initialBitMask & ~(1 << bitMaskIndex)));
}
FieldUtils.writeDeclaredField(newDataWatcher, "d", newMap, true);
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(pet.getId(), newDataWatcher, true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(metadataPacket);
} else {
EntityPet pet = this;
DataWatcher toCloneDataWatcher = pet.getDataWatcher();
DataWatcher newDataWatcher = new DataWatcher(pet);
Map<Integer, DataWatcher.Item<?>> currentMap = (Map<Integer, DataWatcher.Item<?>>) FieldUtils.readDeclaredField(toCloneDataWatcher, "d", true);
Map<Integer, DataWatcher.Item<?>> newMap = Maps.newHashMap();
for (Integer integer : currentMap.keySet()) {
newMap.put(integer, currentMap.get(integer).d());
}
DataWatcher.Item item = newMap.get(0);
byte initialBitMask = (Byte) item.b();
byte bitMaskIndex = (byte) 6;
isGlowing = glow;
if (glow) {
item.a((byte) (initialBitMask | 1 << bitMaskIndex));
} else {
item.a((byte) (initialBitMask & ~(1 << bitMaskIndex)));
}
FieldUtils.writeDeclaredField(newDataWatcher, "d", newMap, true);
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(pet.getId(), newDataWatcher, true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(metadataPacket);
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
use of simplepets.brainsynder.nms.v1_13_R1.entities.impossamobs.EntityShulkerPet in project SimplePets by brainsynder-Dev.
the class EntityPet method glowHandler.
private void glowHandler(boolean glow) {
try {
if (this instanceof IEntityControllerPet) {
org.bukkit.entity.Entity ent = ((IEntityControllerPet) this).getVisibleEntity().getEntity();
Entity handle = ((CraftEntity) ent).getHandle();
if (handle instanceof EntityArmorStandPet) {
EntityArmorStandPet pet = (EntityArmorStandPet) handle;
DataWatcher toCloneDataWatcher = pet.getDataWatcher();
DataWatcher newDataWatcher = new DataWatcher(pet);
Map<Integer, DataWatcher.Item<?>> currentMap = (Map<Integer, DataWatcher.Item<?>>) FieldUtils.readDeclaredField(toCloneDataWatcher, "d", true);
Map<Integer, DataWatcher.Item<?>> newMap = Maps.newHashMap();
for (Integer integer : currentMap.keySet()) {
newMap.put(integer, currentMap.get(integer).d());
}
DataWatcher.Item item = newMap.get(0);
byte initialBitMask = (Byte) item.b();
byte bitMaskIndex = (byte) 6;
isGlowing = glow;
if (glow) {
item.a((byte) (initialBitMask | 1 << bitMaskIndex));
} else {
item.a((byte) (initialBitMask & ~(1 << bitMaskIndex)));
}
FieldUtils.writeDeclaredField(newDataWatcher, "d", newMap, true);
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(pet.getId(), newDataWatcher, true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(metadataPacket);
} else if (handle instanceof EntityShulkerPet) {
EntityShulkerPet pet = (EntityShulkerPet) handle;
DataWatcher toCloneDataWatcher = pet.getDataWatcher();
DataWatcher newDataWatcher = new DataWatcher(pet);
Map<Integer, DataWatcher.Item<?>> currentMap = (Map<Integer, DataWatcher.Item<?>>) FieldUtils.readDeclaredField(toCloneDataWatcher, "d", true);
Map<Integer, DataWatcher.Item<?>> newMap = Maps.newHashMap();
for (Integer integer : currentMap.keySet()) {
newMap.put(integer, currentMap.get(integer).d());
}
DataWatcher.Item item = newMap.get(0);
byte initialBitMask = (Byte) item.b();
byte bitMaskIndex = (byte) 6;
isGlowing = glow;
if (glow) {
item.a((byte) (initialBitMask | 1 << bitMaskIndex));
} else {
item.a((byte) (initialBitMask & ~(1 << bitMaskIndex)));
}
FieldUtils.writeDeclaredField(newDataWatcher, "d", newMap, true);
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(pet.getId(), newDataWatcher, true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(metadataPacket);
} else {
EntityPet pet = this;
DataWatcher toCloneDataWatcher = pet.getDataWatcher();
DataWatcher newDataWatcher = new DataWatcher(pet);
Map<Integer, DataWatcher.Item<?>> currentMap = (Map<Integer, DataWatcher.Item<?>>) FieldUtils.readDeclaredField(toCloneDataWatcher, "d", true);
Map<Integer, DataWatcher.Item<?>> newMap = Maps.newHashMap();
for (Integer integer : currentMap.keySet()) {
newMap.put(integer, currentMap.get(integer).d());
}
DataWatcher.Item item = newMap.get(0);
byte initialBitMask = (Byte) item.b();
byte bitMaskIndex = (byte) 6;
isGlowing = glow;
if (glow) {
item.a((byte) (initialBitMask | 1 << bitMaskIndex));
} else {
item.a((byte) (initialBitMask & ~(1 << bitMaskIndex)));
}
FieldUtils.writeDeclaredField(newDataWatcher, "d", newMap, true);
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(pet.getId(), newDataWatcher, true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(metadataPacket);
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
Aggregations