Merge pull request #11 from 3944Realms/1.21

2024-09-19
This commit is contained in:
3944Realms 2024-09-19 12:47:03 +08:00 committed by GitHub
commit 2ed7ef6673
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 51 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# 版本 0.0.3.5 提前介绍c[最终版本对于0.0.4] 【注意:本解釋簡繁混寫,因爲趕時間,所以並不怎麽規範,請諒解】
# 版本 0.0.3.6 提前介绍c[最终版本对于0.0.4] 【注意:本解釋簡繁混寫,因爲趕時間,所以並不怎麽規範,請諒解】
## 简介
现在开始你可以用拴绳拴住玩家,也可以拴住自己了,不如尝试拴住彼此来通关我的世界吧(

View File

@ -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

View File

@ -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);
}
}

View File

@ -2,6 +2,7 @@
"package": "com.r3944realms.leashedplayer.mixin",
"mixins": [
"both.MixinEntity",
"both.MixinLivingEntity",
"both.MixinPlayer",
"item.MixinLeadItem",
"server.MixinServerGamePacketListenerImpl"