Allow Players to have "attack effect"

This commit is contained in:
Stephen Seo 2024-11-01 13:11:02 +09:00
parent 6625a495ca
commit 676955503c
3 changed files with 55 additions and 42 deletions

View file

@ -519,6 +519,7 @@ public class ClientProxy extends CommonProxy {
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF))); value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
}
option = Component.literal("AE"); option = Component.literal("AE");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect")) option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect"))
@ -536,6 +537,7 @@ public class ClientProxy extends CommonProxy {
option.getSiblings().add(value); option.getSiblings().add(value);
text.getSiblings().add(option); text.getSiblings().add(option);
if (pkt.getEntityInfo().playerName.isEmpty()) {
option = Component.literal("DD"); option = Component.literal("DD");
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage")) option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage"))
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamage")))); .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("DefenseDamage"))));

View file

@ -897,6 +897,13 @@ public class Battle {
((Player) nextEntity).attack(targetEntity); ((Player) nextEntity).attack(targetEntity);
TurnBasedMinecraftMod.proxy.setAttackingEntity(null); TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), TurnBasedMinecraftMod.proxy.getAttackingDamage()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), TurnBasedMinecraftMod.proxy.getAttackingDamage());
// Attack effect
if (next.entityInfo != null && next.entityInfo.attackEffect != EntityInfo.Effect.UNKNOWN && next.entityInfo.attackEffectProbability > 0) {
if (random.nextInt(100) < next.entityInfo.attackEffectProbability) {
next.entityInfo.attackEffect.applyEffectToEntity((LivingEntity)targetEntity);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.WAS_AFFECTED, nextEntity.getId(), targetEntity.getId(), 0, next.entityInfo.attackEffect.getAffectedString());
}
}
if (defenseDamageTriggered) { if (defenseDamageTriggered) {
// defense damage // defense damage
DamageSource defenseDamageSource = targetEntity.damageSources().mobAttack((LivingEntity) targetEntity); DamageSource defenseDamageSource = targetEntity.damageSources().mobAttack((LivingEntity) targetEntity);

View file

@ -565,7 +565,6 @@ public class Config
eInfo.attackProbability = 30; eInfo.attackProbability = 30;
} }
if (eInfo.playerName.isEmpty()) {
try { try {
eInfo.attackEffect = EntityInfo.Effect.fromString(nestedConf.get("attack_effect")); eInfo.attackEffect = EntityInfo.Effect.fromString(nestedConf.get("attack_effect"));
if(eInfo.attackEffect != EntityInfo.Effect.UNKNOWN) { if(eInfo.attackEffect != EntityInfo.Effect.UNKNOWN) {
@ -594,6 +593,7 @@ public class Config
logEntityMissingOptionalValue("attack_effect", name, "unknown"); logEntityMissingOptionalValue("attack_effect", name, "unknown");
} }
if (eInfo.playerName.isEmpty()) {
try { try {
eInfo.attackVariance = nestedConf.getInt("attack_variance"); eInfo.attackVariance = nestedConf.getInt("attack_variance");
if (eInfo.attackVariance < 0) { if (eInfo.attackVariance < 0) {
@ -909,6 +909,8 @@ public class Config
break; break;
} else if (!eInfo.playerName.isEmpty() && playerName != null && playerName.equals(eInfo.playerName)) { } else if (!eInfo.playerName.isEmpty() && playerName != null && playerName.equals(eInfo.playerName)) {
entity.set("attack_probability", eInfo.attackProbability); entity.set("attack_probability", eInfo.attackProbability);
entity.set("attack_effect", eInfo.attackEffect.toString());
entity.set("attack_effect_probability", eInfo.attackEffectProbability);
entity.set("evasion", eInfo.evasion); entity.set("evasion", eInfo.evasion);
entity.set("speed", eInfo.speed); entity.set("speed", eInfo.speed);
entity.set("haste_speed", eInfo.hasteSpeed); entity.set("haste_speed", eInfo.hasteSpeed);
@ -937,8 +939,10 @@ public class Config
newEntry.set("attack_probability", eInfo.attackProbability); newEntry.set("attack_probability", eInfo.attackProbability);
if (eInfo.playerName.isEmpty()) { if (eInfo.playerName.isEmpty()) {
newEntry.set("attack_variance", eInfo.attackVariance); newEntry.set("attack_variance", eInfo.attackVariance);
}
newEntry.set("attack_effect", eInfo.attackEffect.toString()); newEntry.set("attack_effect", eInfo.attackEffect.toString());
newEntry.set("attack_effect_probability", eInfo.attackEffectProbability); newEntry.set("attack_effect_probability", eInfo.attackEffectProbability);
if (eInfo.playerName.isEmpty()) {
newEntry.set("defense_damage", eInfo.defenseDamage); newEntry.set("defense_damage", eInfo.defenseDamage);
newEntry.set("defense_damage_probability", eInfo.defenseDamageProbability); newEntry.set("defense_damage_probability", eInfo.defenseDamageProbability);
} }