diff --git a/README.md b/README.md index 8521110..9a81d71 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 版本 0.0.3.5 提前介绍c[最终版本对于0.0.4] 【注意:本解釋簡繁混寫,因爲趕時間,所以並不怎麽規範,請諒解】 +# 版本 0.0.3.6 提前介绍c[最终版本对于0.0.4] 【注意:本解釋簡繁混寫,因爲趕時間,所以並不怎麽規範,請諒解】 ## 简介 现在开始你可以用拴绳拴住玩家,也可以拴住自己了,不如尝试拴住彼此来通关我的世界吧( diff --git a/gradle.properties b/gradle.properties index 2aee10d..a49fc9f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -32,7 +32,7 @@ mod_name=Leashed Player # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=MIT # The mod version. See https://semver.org/ -mod_version=0.0.3.5 +mod_version=0.0.3.6 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/r3944realms/leashedplayer/mixin/both/MixinLivingEntity.java b/src/main/java/com/r3944realms/leashedplayer/mixin/both/MixinLivingEntity.java new file mode 100644 index 0000000..00fbae5 --- /dev/null +++ b/src/main/java/com/r3944realms/leashedplayer/mixin/both/MixinLivingEntity.java @@ -0,0 +1,48 @@ +package com.r3944realms.leashedplayer.mixin.both; + +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +//OpenJDK21 JIT 激进的优化将TickHeadTurnAssign优化成死循环了 + +/** + * 保证 while 循环的条件永远不成立的 + * @author ustc-zzzz + */ +@Mixin(LivingEntity.class) +public abstract class MixinLivingEntity extends Entity { + @Shadow + public float yBodyRot; + @Shadow + public float yBodyRotO; + + @Shadow + public float yHeadRot; + @Shadow + public float yHeadRotO; + + public MixinLivingEntity(EntityType type, Level level) { + super(type, level); + } + + @Inject( + method = "tick()V", + at = @At(value = "INVOKE_ASSIGN", target = "tickHeadTurn(FF)F") + ) + public void onTickHeadTurnAssign(CallbackInfo ignored) { + var yRot = this.getYRot(); + this.yRotO = yRot - Mth.wrapDegrees(yRot - this.yRotO); + this.yBodyRotO = this.yBodyRot - Mth.wrapDegrees(this.yBodyRot - this.yBodyRotO); + var xRot = this.getXRot(); + this.xRotO = xRot - Mth.wrapDegrees(xRot - this.xRotO); + this.yHeadRotO = this.yHeadRot - Mth.wrapDegrees(this.yHeadRot - this.yHeadRotO); + } +} diff --git a/src/main/resources/leashedplayer.mixins.json b/src/main/resources/leashedplayer.mixins.json index a1e1bc8..4021e04 100644 --- a/src/main/resources/leashedplayer.mixins.json +++ b/src/main/resources/leashedplayer.mixins.json @@ -2,6 +2,7 @@ "package": "com.r3944realms.leashedplayer.mixin", "mixins": [ "both.MixinEntity", + "both.MixinLivingEntity", "both.MixinPlayer", "item.MixinLeadItem", "server.MixinServerGamePacketListenerImpl"