mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-16 15:38:14 +01:00
Fix item_frame disguise
This commit is contained in:
parent
46773b7b39
commit
bcee5d9677
@ -177,6 +177,7 @@ public abstract class Disguise {
|
|||||||
velocityRunnable = new Runnable() {
|
velocityRunnable = new Runnable() {
|
||||||
private int deadTicks = 0;
|
private int deadTicks = 0;
|
||||||
private int refreshDisguise = 0;
|
private int refreshDisguise = 0;
|
||||||
|
private int blockX, blockY, blockZ, facing;
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
// If entity is no longer valid. Remove it.
|
// If entity is no longer valid. Remove it.
|
||||||
@ -204,9 +205,18 @@ public abstract class Disguise {
|
|||||||
if (refreshDisguise % 40 == 0) {
|
if (refreshDisguise % 40 == 0) {
|
||||||
refreshDisguise = 0;
|
refreshDisguise = 0;
|
||||||
DisguiseUtilities.refreshTrackers(disguise);
|
DisguiseUtilities.refreshTrackers(disguise);
|
||||||
if (getEntity() instanceof Player && isSelfDisguiseVisible()) {
|
}
|
||||||
DisguiseUtilities.sendSelfDisguise((Player) getEntity(), disguise);
|
}
|
||||||
}
|
if (getType() == DisguiseType.ITEM_FRAME) {
|
||||||
|
Location loc = getEntity().getLocation();
|
||||||
|
int newFacing = (((int) loc.getYaw() + 720 + 45) / 90) % 4;
|
||||||
|
if (loc.getBlockX() != blockX || loc.getBlockY() != blockY || loc.getBlockZ() != blockZ
|
||||||
|
|| newFacing != facing) {
|
||||||
|
blockX = loc.getBlockX();
|
||||||
|
blockY = loc.getBlockY();
|
||||||
|
blockZ = loc.getBlockZ();
|
||||||
|
facing = newFacing;
|
||||||
|
DisguiseUtilities.refreshTrackers(disguise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isModifyBoundingBox()) {
|
if (isModifyBoundingBox()) {
|
||||||
|
@ -300,28 +300,20 @@ public class PacketsManager {
|
|||||||
} else if (disguise.getType() == DisguiseType.FISHING_HOOK && data == 0) {
|
} else if (disguise.getType() == DisguiseType.FISHING_HOOK && data == 0) {
|
||||||
// If the MiscDisguise data isn't set. Then no entity id was provided, so default to the owners entity id
|
// If the MiscDisguise data isn't set. Then no entity id was provided, so default to the owners entity id
|
||||||
data = disguisedEntity.getEntityId();
|
data = disguisedEntity.getEntityId();
|
||||||
|
} else if (disguise.getType() == DisguiseType.ITEM_FRAME) {
|
||||||
|
data = (((int) loc.getYaw() + 720 + 45) / 90) % 4;
|
||||||
}
|
}
|
||||||
/* else if (disguise.getType() == DisguiseType.ITEM_FRAME) {
|
|
||||||
data = (int) loc.getYaw();
|
|
||||||
if (data < 0)
|
|
||||||
data = -data;
|
|
||||||
}*/
|
|
||||||
spawnPackets[0] = ProtocolLibrary.getProtocolManager()
|
spawnPackets[0] = ProtocolLibrary.getProtocolManager()
|
||||||
.createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, nmsEntity, id, data)
|
.createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, nmsEntity, id, data)
|
||||||
.createPacket(nmsEntity, id, data);
|
.createPacket(nmsEntity, id, data);
|
||||||
spawnPackets[0].getModifier().write(2, (int) Math.floor(loc.getY() * 32D));
|
spawnPackets[0].getModifier().write(2, (int) Math.floor(loc.getY() * 32D));
|
||||||
spawnPackets[0].getModifier().write(8, yaw);
|
spawnPackets[0].getModifier().write(8, yaw);
|
||||||
|
if (disguise.getType() == DisguiseType.ITEM_FRAME) {
|
||||||
if (disguise.getType() == DisguiseType.PAINTING) {
|
if (data % 2 == 0) {
|
||||||
// Make the teleport packet to make it visible..
|
spawnPackets[0].getModifier().write(3, (int) Math.floor((loc.getZ() + (data == 0 ? -1 : 1)) * 32D));
|
||||||
spawnPackets[1] = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
|
} else {
|
||||||
StructureModifier<Object> mods = spawnPackets[1].getModifier();
|
spawnPackets[0].getModifier().write(1, (int) Math.floor((loc.getX() + (data == 3 ? -1 : 1)) * 32D));
|
||||||
mods.write(0, disguisedEntity.getEntityId());
|
}
|
||||||
mods.write(1, (int) Math.floor(loc.getX() * 32D));
|
|
||||||
mods.write(2, (int) Math.floor(loc.getY() * 32D));
|
|
||||||
mods.write(3, (int) Math.floor(loc.getZ() * 32D));
|
|
||||||
mods.write(4, yaw);
|
|
||||||
mods.write(5, pitch);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (spawnPackets[1] == null) {
|
if (spawnPackets[1] == null) {
|
||||||
@ -398,11 +390,11 @@ public class PacketsManager {
|
|||||||
case WITHER_SKULL:
|
case WITHER_SKULL:
|
||||||
value -= 128;
|
value -= 128;
|
||||||
break;
|
break;
|
||||||
case ITEM_FRAME:
|
|
||||||
case ARROW:
|
case ARROW:
|
||||||
value = (byte) -value;
|
value = (byte) -value;
|
||||||
break;
|
break;
|
||||||
case PAINTING:
|
case PAINTING:
|
||||||
|
case ITEM_FRAME:
|
||||||
value = (byte) -(value + 128);
|
value = (byte) -(value + 128);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -424,11 +416,11 @@ public class PacketsManager {
|
|||||||
case WITHER_SKULL:
|
case WITHER_SKULL:
|
||||||
value += 128;
|
value += 128;
|
||||||
break;
|
break;
|
||||||
case ITEM_FRAME:
|
|
||||||
case ARROW:
|
case ARROW:
|
||||||
value = (byte) -value;
|
value = (byte) -value;
|
||||||
break;
|
break;
|
||||||
case PAINTING:
|
case PAINTING:
|
||||||
|
case ITEM_FRAME:
|
||||||
value = (byte) -(value - 128);
|
value = (byte) -(value - 128);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1305,10 +1297,21 @@ public class PacketsManager {
|
|||||||
byte pitchValue = (Byte) mods.read(5);
|
byte pitchValue = (Byte) mods.read(5);
|
||||||
mods.write(5, getPitch(disguise.getType(), DisguiseType.getType(entity.getType()), pitchValue));
|
mods.write(5, getPitch(disguise.getType(), DisguiseType.getType(entity.getType()), pitchValue));
|
||||||
if (sentPacket.getType() == PacketType.Play.Server.ENTITY_TELEPORT) {
|
if (sentPacket.getType() == PacketType.Play.Server.ENTITY_TELEPORT) {
|
||||||
double y = getYModifier(entity, disguise);
|
if (disguise.getType() == DisguiseType.ITEM_FRAME) {
|
||||||
if (y != 0) {
|
Location loc = entity.getLocation();
|
||||||
y *= 32;
|
int data = (((int) loc.getYaw() + 720 + 45) / 90) % 4;
|
||||||
mods.write(2, (Integer) mods.read(2) + (int) Math.floor(y));
|
if (data % 2 == 0) {
|
||||||
|
if (data % 2 == 0) {
|
||||||
|
mods.write(3, (int) Math.floor((loc.getZ() + (data == 0 ? -1 : 1)) * 32D));
|
||||||
|
} else {
|
||||||
|
mods.write(1, (int) Math.floor((loc.getX() + (data == 3 ? -1 : 1)) * 32D));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double y = getYModifier(entity, disguise);
|
||||||
|
if (y != 0) {
|
||||||
|
y *= 32;
|
||||||
|
mods.write(2, (Integer) mods.read(2) + (int) Math.floor(y));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user