Add setNameYModifier to change armorstand height
This commit is contained in:
		| @@ -71,6 +71,8 @@ public class FlagWatcher { | ||||
|     private Float yawLock; | ||||
|     @Getter | ||||
|     private float yModifier; | ||||
|     @Getter | ||||
|     private float nameYModifier; | ||||
|  | ||||
|     public FlagWatcher(Disguise disguise) { | ||||
|         this.disguise = (TargetedDisguise) disguise; | ||||
| @@ -89,13 +91,30 @@ public class FlagWatcher { | ||||
|         setPitchLock(pitchLocked ? 0F : null); | ||||
|     } | ||||
|  | ||||
|     public void setNameYModifier(float yModifier) { | ||||
|         this.nameYModifier = yModifier; | ||||
|  | ||||
|         if (!DisguiseConfig.isMovementPacketsEnabled() && !getDisguise().isDisguiseInUse()) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_TELEPORT, getDisguise().getEntity()) | ||||
|             .createPacket(getDisguise().getEntity()); | ||||
|  | ||||
|         try { | ||||
|             for (Player player : DisguiseUtilities.getPerverts(getDisguise())) { | ||||
|                 ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet); | ||||
|             } | ||||
|         } catch (InvocationTargetException e) { | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void setYModifier(float yModifier) { | ||||
|         if (!DisguiseConfig.isMovementPacketsEnabled()) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         double diff = yModifier - getYModifier(); | ||||
|  | ||||
|         this.yModifier = yModifier; | ||||
|  | ||||
|         if (!getDisguise().isDisguiseInUse()) { | ||||
| @@ -208,6 +227,7 @@ public class FlagWatcher { | ||||
|         cloned.pitchLock = pitchLock; | ||||
|         cloned.yawLock = yawLock; | ||||
|         cloned.yModifier = yModifier; | ||||
|         cloned.nameYModifier = nameYModifier; | ||||
|  | ||||
|         return cloned; | ||||
|     } | ||||
|   | ||||
| @@ -3022,7 +3022,7 @@ public class DisguiseUtilities { | ||||
|         } | ||||
|  | ||||
|         // Don't need to offset with DisguiseUtilities.getYModifier, because that's a visual offset and not an actual location offset | ||||
|         double height = disguise.getHeight() + disguise.getWatcher().getYModifier(); | ||||
|         double height = disguise.getHeight() + disguise.getWatcher().getYModifier() + disguise.getWatcher().getNameYModifier(); | ||||
|  | ||||
|         for (int i = 0; i < newNames.length; i++) { | ||||
|             if (i < internalOldNames.length) { | ||||
|   | ||||
| @@ -50,7 +50,7 @@ public class PacketHandlerMovement implements IPacketHandler { | ||||
|         } | ||||
|  | ||||
|         ArrayList<PacketContainer> toAdd = new ArrayList<>(); | ||||
|         double height = disguise.getHeight(); | ||||
|         double height = disguise.getHeight() + disguise.getWatcher().getNameYModifier(); | ||||
|  | ||||
|         for (PacketContainer packet : packets.getPackets()) { | ||||
|             if (packet.getType() == PacketType.Play.Server.ENTITY_LOOK) { | ||||
|   | ||||
| @@ -391,6 +391,8 @@ public class DisguisePermissions { | ||||
|             if (sender instanceof Player && !sender.isOp() && !DisguiseConfig.isExplicitDisguisePermissions()) { | ||||
|                 storage.permittedOptions.remove("setYModifier"); | ||||
|                 storage.negatedOptions.add("setYModifier"); | ||||
|                 storage.permittedOptions.remove("setNameYModifier"); | ||||
|                 storage.negatedOptions.add("setNameYModifier"); | ||||
|             } | ||||
|  | ||||
|             disguises.add(storage); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user