88import net .minecraft .world .entity .decoration .ArmorStand ;
99import net .minecraft .world .level .Level ;
1010import net .minecraft .world .phys .Vec3 ;
11+ import net .minecraft .core .BlockPos ;
12+ import net .minecraft .core .Direction ;
13+ import net .minecraft .world .level .block .state .BlockState ;
1114import org .spongepowered .asm .mixin .Mixin ;
15+ import org .spongepowered .asm .mixin .Unique ;
1216import org .spongepowered .asm .mixin .injection .At ;
1317import org .spongepowered .asm .mixin .injection .Inject ;
1418import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
@@ -20,23 +24,32 @@ public ArmorStandMixin(final EntityType<?> entityType, final Level level) {
2024 super (entityType , level );
2125 }
2226
27+ @ Unique
28+ private int sable$lastAttachedTick ;
29+
2330 @ Inject (method = "tick" , at = @ At ("TAIL" ))
2431 private void sable$postTick (final CallbackInfo ci ) {
2532 if (this .level ().isClientSide ) return ;
2633
2734 final SubLevel containingSubLevel = Sable .HELPER .getContaining (this );
2835
2936 if (containingSubLevel != null ) {
30- if (!this .onGround ()) {
37+ if (this . tickCount - this . sable$lastAttachedTick > 1 && !this .onGround ()) {
3138 EntitySubLevelUtil .kickEntity (containingSubLevel , this );
3239 }
3340 } else if (this .onGround ()) {
3441 final SubLevel landed = Sable .HELPER .getTrackingSubLevel (this );
3542 if (landed != null ) {
3643 final Vec3 shipyardPos = landed .logicalPose ().transformPositionInverse (this .position ());
37- final Vec3 shipyardVel = landed .logicalPose ().transformNormalInverse (this .getDeltaMovement ());
38- this .moveTo (shipyardPos .x , shipyardPos .y , shipyardPos .z );
39- this .setDeltaMovement (shipyardVel );
44+ final BlockPos belowPos = BlockPos .containing (shipyardPos .x , shipyardPos .y - 0.5 , shipyardPos .z );
45+ final BlockState belowState = this .level ().getBlockState (belowPos );
46+ if (belowState .isFaceSturdy (this .level (), belowPos , Direction .UP )
47+ && Math .abs (shipyardPos .y - (belowPos .getY () + 1 )) < 0.1 ) {
48+ final Vec3 shipyardVel = landed .logicalPose ().transformNormalInverse (this .getDeltaMovement ());
49+ this .moveTo (shipyardPos .x , shipyardPos .y , shipyardPos .z );
50+ this .setDeltaMovement (shipyardVel );
51+ this .sable$lastAttachedTick = this .tickCount ;
52+ }
4053 }
4154 }
4255 }
0 commit comments