MC百科社群
标题:
原版耐久附魔判定机制存在tick超时的可能性
[打印本页]
作者:
lycc193
时间:
2024-1-24 15:17
标题:
原版耐久附魔判定机制存在tick超时的可能性
身穿含有耐久附魔的护甲时,受到极高伤害,会导致1tick时间超过60秒触发看门狗
目前测试,受到2e10的伤害 即可在服务端稳定触发看门狗(1 tick 超过60秒)
发现途径
无尽贪婪官方更新的1.18.2版本 -> Avaritia-1.18.2-4.0.1.6-universal.jar
这个版本修改了寰宇支配之剑的伤害计算方式,由原有的setHealth(0)改为了hurt(3e34),导致出现了这个问题
[spoiler=核心算法]
<blockquote><div style="line-height: 19px;"><div>public boolean hurt(int damage, RandomSource random, ServerPlayer player) {</div><div> if (!this.isDamageableItem()) { return false; } </div><div> else {</div><div> if (damage > 0) {</div><div> int i = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.UNBREAKING, this);</div><div> int j = 0;</div><div> for(int k = 0; i > 0 && k < damage; ++k) {</div><div> if (DigDurabilityEnchantment.shouldIgnoreDurabilityDrop(this, i, random)) {</div><div> ++j;</div><div> }</div><div> }</div><div> //...</div><div> }</div><div> // ...</div><div> }</div><div> // ...</div><div>}</div></div>
复制代码
[/spoiler]
[spoiler=调用栈]1.7.10
net.minecraft.item.ItemStack#attemptDamageItem
net.minecraft.item.ItemStack#damageItem
net.minecraftforge.common.ISpecialArmor.ArmorProperties#ApplyArmor
net.minecraft.entity.player.EntityPlayer#damageEntity
net.minecraft.entity.EntityLivingBase#attackEntityFrom
net.minecraft.entity.player.EntityPlayer#attackEntityFrom
net.minecraft.entity.player.EntityPlayerMP#attackEntityFrom
复制代码
1.18.2
net.minecraft.world.item.ItemStack#hurt
net.minecraft.world.item.ItemStack#hurtAndBreak
net.minecraft.world.entity.player.Inventory#hurtArmor
net.minecraft.world.entity.player.Player#hurtArmor
net.minecraft.world.entity.LivingEntity#getDamageAfterArmorAbsorb
net.minecraft.world.entity.player.Player#actuallyHurt
net.minecraft.world.entity.LivingEntity#hurt
net.minecraft.world.entity.player.Player#hurt
net.minecraft.server.level.ServerPlayer#hurt
复制代码
1.20.2
net.minecraft.world.item.ItemStack#hurt
net.minecraft.world.item.ItemStack#hurtAndBreak
net.minecraft.world.entity.player.Inventory#hurtArmor
net.minecraft.world.entity.player.Player#hurtArmor
net.minecraft.world.entity.LivingEntity#getDamageAfterArmorAbsorb
net.minecraft.world.entity.player.Player#actuallyHurt
net.minecraft.world.entity.LivingEntity#hurt
net.minecraft.world.entity.player.Player#hurt
net.minecraft.server.level.ServerPlayer#hurt
复制代码
[/spoiler]
[spoiler=复现方式]1.18.2
player.hurt(new EntityDamageSource("",player),2e10f);
复制代码
1.20.2
player.hurt(level.damageSources().playerAttack(player), 2e10f);
复制代码
[/spoiler]
作者:
lycc193
时间:
2024-1-24 15:21
核心算法是下面这个(什么辣鸡编辑器
[spoiler=算法]
public boolean hurt(int damage, RandomSource random, ServerPlayer player) {
if (!this.isDamageableItem()) { return false; }
else {
if (damage > 0) {
复制代码
[/spoiler]
作者:
lycc193
时间:
2024-1-24 15:22
lycc193 发表于 2024-1-24 15:21
核心算法是下面这个(什么辣鸡编辑器
?我东西呢
欢迎光临 MC百科社群 (https://bbs.mcmod.cn/)
MC百科
|最大的MineCraft中文模组百科