More readable check for freezing fake players
And properly freeze entities with fake players riding them
This commit is contained in:
1 parent
dbda1d4482
commit
e1503bae72
1 file changed
+15
-3
@@ -2,6 +2,7 @@ package carpet.mixins;
|
|||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
|
||||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||||
@@ -18,9 +19,20 @@ abstract class TickRateManager_fakePlayersMixin {
|
|||||||
abstract boolean runsNormally();
|
abstract boolean runsNormally();
|
||||||
|
|
||||||
@ModifyReturnValue(method = "isEntityFrozen", at = @At("TAIL"))
|
@ModifyReturnValue(method = "isEntityFrozen", at = @At("TAIL"))
|
||||||
private boolean handler(boolean alreadyFrozen, Entity entity) {
|
private boolean handler(boolean alreadyFrozen, Entity entity)
|
||||||
|
{
|
||||||
if (alreadyFrozen) return true;
|
if (alreadyFrozen) return true;
|
||||||
return !runsNormally() && (entity instanceof EntityPlayerMPFake)
|
if (runsNormally()) return false;
|
||||||
&& !((EntityInterface) entity).cm$getIndirectPassengersStream().anyMatch(e -> e instanceof Player && !(e instanceof EntityPlayerMPFake));
|
|
||||||
|
return !isActualPlayer(entity) && // not carrying players
|
||||||
|
((EntityInterface) entity)
|
||||||
|
.cm$getIndirectPassengersStream()
|
||||||
|
.noneMatch(TickRateManager_fakePlayersMixin::isActualPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private static boolean isActualPlayer(Entity e)
|
||||||
|
{
|
||||||
|
return e instanceof Player && !(e instanceof EntityPlayerMPFake);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user