盾でガードに成功したことを検知したい

Minecraft Java -ver 1.19.3 skript -ver 2.6.4 [やりたいこと] 盾でガードに成功したことを検知する方法を知りたい。 final damageを0にして検知とかも試したのですが盾で吸収した分もfinal damageに入っていてうまく検知できなかったのでお力を貸していただきたいです。記載漏れがございましたらすみません。
6 Replies
何か
何か2y ago
盾の耐久値とかで判定してみれば forge 1.19.3から盾の処理を見てみると
if (p_21017_ > 0.0F && this.isDamageSourceBlocked(p_21016_)) {
net.minecraftforge.event.entity.living.ShieldBlockEvent ev = net.minecraftforge.common.ForgeHooks.onShieldBlock(this, p_21016_, p_21017_);
if(!ev.isCanceled()) {
if(ev.shieldTakesDamage()) this.hurtCurrentlyUsedShield(p_21017_);
f1 = ev.getBlockedDamage();
p_21017_ -= ev.getBlockedDamage();
if (!p_21016_.isProjectile()) {
Entity entity = p_21016_.getDirectEntity();
if (entity instanceof LivingEntity) {
LivingEntity livingentity = (LivingEntity)entity;
this.blockUsingShield(livingentity);
}
}

flag = true;
}
}

public boolean isDamageSourceBlocked(DamageSource p_21276_) {
Entity entity = p_21276_.getDirectEntity();
boolean flag = false;
if (entity instanceof AbstractArrow abstractarrow) {
if (abstractarrow.getPierceLevel() > 0) {
flag = true;
}
}

if (!p_21276_.isBypassArmor() && this.isBlocking() && !flag) {
Vec3 vec32 = p_21276_.getSourcePosition();
if (vec32 != null) {
Vec3 vec3 = this.getViewVector(1.0F);
Vec3 vec31 = vec32.vectorTo(this.position()).normalize();
vec31 = new Vec3(vec31.x, 0.0D, vec31.z);
if (vec31.dot(vec3) < 0.0D) {
return true;
}
}
}

return false;
}
if (p_21017_ > 0.0F && this.isDamageSourceBlocked(p_21016_)) {
net.minecraftforge.event.entity.living.ShieldBlockEvent ev = net.minecraftforge.common.ForgeHooks.onShieldBlock(this, p_21016_, p_21017_);
if(!ev.isCanceled()) {
if(ev.shieldTakesDamage()) this.hurtCurrentlyUsedShield(p_21017_);
f1 = ev.getBlockedDamage();
p_21017_ -= ev.getBlockedDamage();
if (!p_21016_.isProjectile()) {
Entity entity = p_21016_.getDirectEntity();
if (entity instanceof LivingEntity) {
LivingEntity livingentity = (LivingEntity)entity;
this.blockUsingShield(livingentity);
}
}

flag = true;
}
}

public boolean isDamageSourceBlocked(DamageSource p_21276_) {
Entity entity = p_21276_.getDirectEntity();
boolean flag = false;
if (entity instanceof AbstractArrow abstractarrow) {
if (abstractarrow.getPierceLevel() > 0) {
flag = true;
}
}

if (!p_21276_.isBypassArmor() && this.isBlocking() && !flag) {
Vec3 vec32 = p_21276_.getSourcePosition();
if (vec32 != null) {
Vec3 vec3 = this.getViewVector(1.0F);
Vec3 vec31 = vec32.vectorTo(this.position()).normalize();
vec31 = new Vec3(vec31.x, 0.0D, vec31.z);
if (vec31.dot(vec3) < 0.0D) {
return true;
}
}
}

return false;
}
視点のベクトルとポジションの差からドット積を使って
何か
何か2y ago
何か
何か2y ago
90度までは失敗 それ以上は成功ってことにしてるので 同じようにskriptで実装すればいけると思います
on damage:
set {_attacker} to attacker
if projectile is set:
set {_attacker} to projectile
if victim is blocking:
set {_lv} to vector from yaw yaw of victim and pitch pitch of victim
set {_v} to (vector between {_attacker} and victim normalized) ** vector(1, 0, 1)

if {_lv} dot {_v} < 0.0:
set {_blocked} to true
else if pitch of victim is 90: #負の0もブロック判定
set {_blocked} to true
else:
set {_blocked} to false

if {_blocked} is true:
broadcast "block"
else:
broadcast "hit"
on damage:
set {_attacker} to attacker
if projectile is set:
set {_attacker} to projectile
if victim is blocking:
set {_lv} to vector from yaw yaw of victim and pitch pitch of victim
set {_v} to (vector between {_attacker} and victim normalized) ** vector(1, 0, 1)

if {_lv} dot {_v} < 0.0:
set {_blocked} to true
else if pitch of victim is 90: #負の0もブロック判定
set {_blocked} to true
else:
set {_blocked} to false

if {_blocked} is true:
broadcast "block"
else:
broadcast "hit"
skript only
tanoKun
tanoKun2y ago
化け物
tomo_25
tomo_252y ago
こわい
はるまき
はるまき2y ago
やりたいことができるようになりました。本当にありがとうございます。
Want results from more Discord servers?
Add your server
More Posts
アイテムにコマンドを付けるskアイテムにコマンドを付けるsk(https://pastebin.com/XLuBahgX )を作っているのですが、これだとこういうことが起きます ・wait {wait} secondsが動かない TCTプラグインでゲーム開始前に弓を撃てるようにしたいhttps://gyazo.com/ea0e7e6fe12f566bc68c46d0a7ffea0f ⇧GIF PRでTCTプラグインを使っています。 ゲーム開始待機中、プラグインの仕様で弓や雪玉がリスト変数の中に~が含まれているかを調べたい良さそうな方法ありますか...?リードの結び目をクリックしたときのイベント名が知りたい・リードを繋いだ結び目を保護(リードを破壊するイベントをキャンセル)するスクリプトを書きたいです ・フェンスに結び付けられたリードの結び目をクリックして壊そうとしたときのイベント名または判定式が知りたモブをスクリプトで実装Skriptでモブを作ろうと思います。 が、モブの攻撃対象を 固定/切り替え することは出来ますか? Mm性のモブだと誰を狙うかが半ばランダム状態になっていて、ゲームにおける戦略性が絶望的です。if player has ~ of ~を含めた時だけリロードが終わらないon rightclick on sign: if player has 96 of coal: remove 96 coal from player give格納しているリスト変数の内容から逆算して変数の番号を割り出したいこんにちは。どなたかご回答頂ければ助かります。 額縁保護を作っています。保護する額縁の座標を以下のようにリストに代入しています。 `set {frameprotect.%player's uuid%:二つの点がどれくらい離れてるかわかる方法ありますかたすけてonbreakが動かないon break: cancel event というのを書いたのですが、動きません(多分on breakの方) マインクラフトは1.12.2、skriptの方は2.6.3ですクリエ飛行を利用した二段ジャンプの不具合```on flight toggle: if player's gamemode is not creative: if player's flight mode is tr