From 967ba53ab5db4d9499165c3847f1945918d0f41e Mon Sep 17 00:00:00 2001 From: liach <7806504+liach@users.noreply.github.com> Date: Mon, 4 Oct 2021 08:06:44 -0500 Subject: [PATCH] Revamp control to be more accurate (#2513) * Revamp control to be more accurate Fixes stepAngleTowards to be clampAngle, 3 mob entity methods I initially wanted to just map the shulker look control class, turns out the whole look control system has some wrong names. Signed-off-by: liach * Update mappings/net/minecraft/entity/mob/MobEntity.mapping Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com> Co-authored-by: liach Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com> --- .../ai/control/AquaticLookControl.mapping | 7 ---- .../entity/ai/control/BodyControl.mapping | 24 +++++++++---- .../entity/ai/control/LookControl.mapping | 32 +++++++++++------ .../control/YawAdjustingLookControl.mapping | 14 ++++++++ .../minecraft/entity/mob/MobEntity.mapping | 35 +++++++++++++++---- .../entity/mob/ShulkerEntity.mapping | 4 +++ .../entity/passive/AxolotlEntity.mapping | 2 +- .../minecraft/util/math/MathHelper.mapping | 26 +++++++++++--- 8 files changed, 108 insertions(+), 36 deletions(-) delete mode 100644 mappings/net/minecraft/entity/ai/control/AquaticLookControl.mapping create mode 100644 mappings/net/minecraft/entity/ai/control/YawAdjustingLookControl.mapping diff --git a/mappings/net/minecraft/entity/ai/control/AquaticLookControl.mapping b/mappings/net/minecraft/entity/ai/control/AquaticLookControl.mapping deleted file mode 100644 index 0db95bdbbc..0000000000 --- a/mappings/net/minecraft/entity/ai/control/AquaticLookControl.mapping +++ /dev/null @@ -1,7 +0,0 @@ -CLASS net/minecraft/class_1332 net/minecraft/entity/ai/control/AquaticLookControl - FIELD field_30200 ADDED_PITCH I - FIELD field_30201 ADDED_YAW I - FIELD field_6357 maxYawDifference I - METHOD (Lnet/minecraft/class_1308;I)V - ARG 1 entity - ARG 2 maxYawDifference diff --git a/mappings/net/minecraft/entity/ai/control/BodyControl.mapping b/mappings/net/minecraft/entity/ai/control/BodyControl.mapping index 395621bfe1..5b5680c37e 100644 --- a/mappings/net/minecraft/entity/ai/control/BodyControl.mapping +++ b/mappings/net/minecraft/entity/ai/control/BodyControl.mapping @@ -1,15 +1,27 @@ CLASS net/minecraft/class_1330 net/minecraft/entity/ai/control/BodyControl - FIELD field_30194 MAX_HEAD_YAW I - FIELD field_30195 MAX_ACTIVE_TICKS I + COMMENT The body control ensures a mob's head and body yaws are kept up with each other. + FIELD field_30194 BODY_KEEP_UP_THRESHOLD I + FIELD field_30195 ROTATE_BODY_START_TICK I FIELD field_30196 ROTATION_INCREMENTS I FIELD field_6354 lastHeadYaw F - FIELD field_6355 activeTicks I + FIELD field_6355 bodyAdjustTicks I FIELD field_6356 entity Lnet/minecraft/class_1308; METHOD (Lnet/minecraft/class_1308;)V ARG 1 entity - METHOD method_20243 rotateLook ()V - METHOD method_20244 rotateHead ()V - METHOD method_20245 rotateBody ()V + METHOD method_20243 keepUpBody ()V + COMMENT Keeps up the body yaw by ensuring it is within the {@linkplain + COMMENT MobEntity#getMaxHeadRotation max head rotation} from the head yaw. + METHOD method_20244 keepUpHead ()V + COMMENT Keeps up the head yaw by ensuring it is within the {@linkplain + COMMENT MobEntity#getMaxHeadRotation max head rotation} from the body yaw. + METHOD method_20245 slowlyAdjustBody ()V + COMMENT Gradually adjusts the body yaw toward the head yaw, starting after 10 ticks of + COMMENT {@linkplain #bodyAdjustTicks wait} and finishes by the 20th tick. METHOD method_20246 isIndependent ()Z METHOD method_20247 isMoving ()Z METHOD method_6224 tick ()V + COMMENT Ticks the body control. + COMMENT + COMMENT @implSpec If the entity {@linkplain #isMoving() has moved}, its body yaw + COMMENT adjusts to its head yaw. Otherwise, if the entity is {@linkplain + COMMENT #isIndependent() not steered}, its head yaw adjusts to its body yaw. diff --git a/mappings/net/minecraft/entity/ai/control/LookControl.mapping b/mappings/net/minecraft/entity/ai/control/LookControl.mapping index b86d856f0b..e1f546a4d7 100644 --- a/mappings/net/minecraft/entity/ai/control/LookControl.mapping +++ b/mappings/net/minecraft/entity/ai/control/LookControl.mapping @@ -1,11 +1,12 @@ CLASS net/minecraft/class_1333 net/minecraft/entity/ai/control/LookControl - FIELD field_6358 pitchSpeed F - FIELD field_6359 yawSpeed F - FIELD field_6360 active Z + COMMENT The look control adjusts a mob's rotations to look at a target position. + FIELD field_6358 maxPitchChange F + FIELD field_6359 maxYawChange F + FIELD field_6360 pending Z FIELD field_6361 entity Lnet/minecraft/class_1308; - FIELD field_6362 lookZ D - FIELD field_6363 lookY D - FIELD field_6364 lookX D + FIELD field_6362 z D + FIELD field_6363 y D + FIELD field_6364 x D METHOD (Lnet/minecraft/class_1308;)V ARG 1 entity METHOD method_19615 lookAt (Lnet/minecraft/class_243;)V @@ -21,14 +22,23 @@ CLASS net/minecraft/class_1333 net/minecraft/entity/ai/control/LookControl METHOD method_20433 shouldStayHorizontal ()Z METHOD method_35111 lookAt (Lnet/minecraft/class_1297;)V ARG 1 entity + METHOD method_36980 clampHeadYaw ()V + METHOD method_37355 (Ljava/lang/Float;)V + ARG 1 pitch + METHOD method_37356 (Ljava/lang/Float;)V + ARG 1 yaw METHOD method_6225 getLookX ()D METHOD method_6226 lookAt (Lnet/minecraft/class_1297;FF)V ARG 1 entity - ARG 2 yawSpeed - ARG 3 pitchSpeed + ARG 2 maxYawChange + ARG 3 maxPitchChange METHOD method_6227 getLookY ()D METHOD method_6228 getLookZ ()D METHOD method_6229 changeAngle (FFF)F + COMMENT Changes the angle from {@code from} to {@code to}, or by {@code max} degrees + COMMENT if {@code to} is too big a change. + COMMENT + COMMENT

This is the same as {@link MobEntity#changeAngle(float, float, float)}. ARG 1 from ARG 2 to ARG 3 max @@ -36,7 +46,7 @@ CLASS net/minecraft/class_1333 net/minecraft/entity/ai/control/LookControl ARG 1 x ARG 3 y ARG 5 z - ARG 7 yawSpeed - ARG 8 pitchSpeed + ARG 7 maxYawChange + ARG 8 maxPitchChange METHOD method_6231 tick ()V - METHOD method_6232 isActive ()Z + METHOD method_6232 isPending ()Z diff --git a/mappings/net/minecraft/entity/ai/control/YawAdjustingLookControl.mapping b/mappings/net/minecraft/entity/ai/control/YawAdjustingLookControl.mapping new file mode 100644 index 0000000000..a552b51204 --- /dev/null +++ b/mappings/net/minecraft/entity/ai/control/YawAdjustingLookControl.mapping @@ -0,0 +1,14 @@ +CLASS net/minecraft/class_1332 net/minecraft/entity/ai/control/YawAdjustingLookControl + COMMENT The yaw adjusting look control adjusts the entity's body yaw to be close to the + COMMENT head yaw. In vanilla, this is used by entities that cannot rotate their heads + COMMENT easily, such as axolotl and dolphin. + FIELD field_30200 ADDED_PITCH I + FIELD field_30201 ADDED_YAW I + FIELD field_6357 yawAdjustThreshold I + METHOD (Lnet/minecraft/class_1308;I)V + ARG 1 entity + ARG 2 yawAdjustThreshold + METHOD method_37357 (Ljava/lang/Float;)V + ARG 1 pitch + METHOD method_37358 (Ljava/lang/Float;)V + ARG 1 yaw diff --git a/mappings/net/minecraft/entity/mob/MobEntity.mapping b/mappings/net/minecraft/entity/mob/MobEntity.mapping index 2bf9cc1ef7..25344bafc8 100644 --- a/mappings/net/minecraft/entity/mob/MobEntity.mapping +++ b/mappings/net/minecraft/entity/mob/MobEntity.mapping @@ -48,7 +48,12 @@ CLASS net/minecraft/class_1308 net/minecraft/entity/mob/MobEntity ARG 1 id METHOD method_19540 setAttacking (Z)V ARG 1 attacking - METHOD method_20240 getLookYawSpeed ()I + METHOD method_20240 getMaxLookYawChange ()I + COMMENT {@return the maximum degrees which the yaw can change when looking} + COMMENT + COMMENT

This is used by the look control. + COMMENT + COMMENT

The default return value is {@code 10}. METHOD method_20417 updateGoalControls ()V METHOD method_20636 canMobSpawn (Lnet/minecraft/class_1299;Lnet/minecraft/class_1936;Lnet/minecraft/class_3730;Lnet/minecraft/class_2338;Ljava/util/Random;)Z ARG 0 type @@ -163,9 +168,13 @@ CLASS net/minecraft/class_1308 net/minecraft/entity/mob/MobEntity METHOD method_5958 mobTick ()V METHOD method_5959 initGoals ()V METHOD method_5960 changeAngle (FFF)F - ARG 1 oldAngle - ARG 2 newAngle - ARG 3 maxChangeInAngle + COMMENT Changes the angle from {@code from} to {@code to}, or by {@code max} degrees + COMMENT if {@code to} is too big a change. + COMMENT + COMMENT

This is the same as {@link LookControl#changeAngle(float, float, float)}. + ARG 1 from + ARG 2 to + ARG 3 max METHOD method_5961 isLeftHanded ()Z METHOD method_5962 getMoveControl ()Lnet/minecraft/class_1335; METHOD method_5963 createBodyControl ()Lnet/minecraft/class_1330; @@ -187,7 +196,14 @@ CLASS net/minecraft/class_1308 net/minecraft/entity/mob/MobEntity ARG 1 upwardSpeed METHOD method_5977 setAiDisabled (Z)V ARG 1 aiDisabled - METHOD method_5978 getLookPitchSpeed ()I + METHOD method_5978 getMaxLookPitchChange ()I + COMMENT {@return the maximum degrees which the pitch can change when looking} + COMMENT + COMMENT

This is used by the look control. + COMMENT + COMMENT

It can return from {@code 1} for entities that can hardly raise their head, + COMMENT like axolotols or dolphins, or {@code 180} for entities that can freely raise + COMMENT and lower their head, like guardians. The default return value is {@code 40}. METHOD method_5979 canSpawn (Lnet/minecraft/class_1936;Lnet/minecraft/class_3730;)Z ARG 1 world ARG 2 spawnReason @@ -197,7 +213,14 @@ CLASS net/minecraft/class_1308 net/minecraft/entity/mob/MobEntity METHOD method_5984 updateEnchantments (Lnet/minecraft/class_1266;)V ARG 1 difficulty METHOD method_5985 getVisibilityCache ()Lnet/minecraft/class_1413; - METHOD method_5986 getBodyYawSpeed ()I + METHOD method_5986 getMaxHeadRotation ()I + COMMENT {@return the maximum degrees which the head yaw can differ from the body yaw} + COMMENT + COMMENT

This is used by the body control. + COMMENT + COMMENT

It can return from {@code 1} for entities that can hardly rotate their head, + COMMENT like axolotols or dolphins, or {@code 180} for entities that can freely rotate + COMMENT their head, like shulkers. The default return value is {@code 75}. METHOD method_5987 isAiDisabled ()Z METHOD method_5988 getLookControl ()Lnet/minecraft/class_1333; METHOD method_5990 playSpawnEffects ()V diff --git a/mappings/net/minecraft/entity/mob/ShulkerEntity.mapping b/mappings/net/minecraft/entity/mob/ShulkerEntity.mapping index 40dd50f2fa..4701f36b67 100644 --- a/mappings/net/minecraft/entity/mob/ShulkerEntity.mapping +++ b/mappings/net/minecraft/entity/mob/ShulkerEntity.mapping @@ -1,4 +1,5 @@ CLASS net/minecraft/class_1606 net/minecraft/entity/mob/ShulkerEntity + FIELD field_33765 SOUTH_VECTOR Lnet/minecraft/class_1160; FIELD field_7337 openProgress F FIELD field_7339 prevOpenProgress F FIELD field_7340 teleportLerpTimer I @@ -53,3 +54,6 @@ CLASS net/minecraft/class_1606 net/minecraft/entity/mob/ShulkerEntity ARG 2 shulker CLASS class_1611 PeekGoal FIELD field_7352 counter I + CLASS class_6376 ShulkerLookControl + METHOD (Lnet/minecraft/class_1606;Lnet/minecraft/class_1308;)V + ARG 2 entity diff --git a/mappings/net/minecraft/entity/passive/AxolotlEntity.mapping b/mappings/net/minecraft/entity/passive/AxolotlEntity.mapping index c2be94f344..177cd490a1 100644 --- a/mappings/net/minecraft/entity/passive/AxolotlEntity.mapping +++ b/mappings/net/minecraft/entity/passive/AxolotlEntity.mapping @@ -72,7 +72,7 @@ CLASS net/minecraft/class_5762 net/minecraft/entity/passive/AxolotlEntity CLASS class_5764 AxolotlLookControl METHOD (Lnet/minecraft/class_5762;Lnet/minecraft/class_5762;I)V ARG 2 axolotl - ARG 3 maxYawDifference + ARG 3 yawAdjustThreshold CLASS class_5765 AxolotlMoveControl FIELD field_28340 axolotl Lnet/minecraft/class_5762; METHOD (Lnet/minecraft/class_5762;)V diff --git a/mappings/net/minecraft/util/math/MathHelper.mapping b/mappings/net/minecraft/util/math/MathHelper.mapping index 5f224b08ff..11e6c6af52 100644 --- a/mappings/net/minecraft/util/math/MathHelper.mapping +++ b/mappings/net/minecraft/util/math/MathHelper.mapping @@ -240,11 +240,17 @@ CLASS net/minecraft/class_3532 net/minecraft/util/math/MathHelper ARG 2 end METHOD method_17822 sign (D)I ARG 0 value - METHOD method_20306 stepAngleTowards (FFF)F - COMMENT Steps from {@code from} degrees towards {@code to} degrees, changing the value by at most {@code step} degrees. - ARG 0 from - ARG 1 to - ARG 2 step + METHOD method_20306 clampAngle (FFF)F + COMMENT Clamps {@code value}, as an angle, between {@code mean - delta} and {@code + COMMENT mean + delta} degrees. + COMMENT + COMMENT @return the clamped {@code value} + ARG 0 value + COMMENT the value to clamp + ARG 1 mean + COMMENT the mean value of the clamp angle range + ARG 2 delta + COMMENT the maximum difference allowed from the mean, must not be negative METHOD method_20390 approximatelyEquals (DD)Z ARG 0 a ARG 2 b @@ -326,13 +332,23 @@ CLASS net/minecraft/class_3532 net/minecraft/util/math/MathHelper ARG 0 string ARG 1 fallback METHOD method_34948 parseDouble (Ljava/lang/String;DD)D + COMMENT {@return the parsed double; {@code fallback} if {@code string} is not an + COMMENT double; or {@code min} if the parsed double is too small} ARG 0 string + COMMENT the string to parse ARG 1 fallback + COMMENT the fallback for unparsable {@code string} ARG 3 min + COMMENT the minimum if the parsed value is too small METHOD method_34949 parseInt (Ljava/lang/String;II)I + COMMENT {@return the parsed integer; {@code fallback} if {@code string} is not an + COMMENT integer; or {@code min} if the parsed integer is too small} ARG 0 string + COMMENT the string to parse ARG 1 fallback + COMMENT the fallback for unparsable {@code string} ARG 2 min + COMMENT the minimum if the parsed value is too small METHOD method_34951 getCumulativeDistribution ([D)[D ARG 0 values METHOD method_34952 multiplyColors (II)I