Allow Players to have "attack effect"
This commit is contained in:
parent
f6156bdc50
commit
ecf52cd253
3 changed files with 55 additions and 42 deletions
|
@ -519,6 +519,7 @@ public class ClientProxy extends CommonProxy {
|
|||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||
option.getSiblings().add(value);
|
||||
text.getSiblings().add(option);
|
||||
}
|
||||
|
||||
option = Component.literal("AE");
|
||||
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);
|
||||
text.getSiblings().add(option);
|
||||
|
||||
if (pkt.getEntityInfo().playerName.isEmpty()) {
|
||||
option = Component.literal("DD");
|
||||
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"))));
|
||||
|
|
|
@ -898,6 +898,13 @@ public class Battle {
|
|||
((Player) nextEntity).attack(targetEntity);
|
||||
TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
|
||||
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) {
|
||||
// defense damage
|
||||
DamageSource defenseDamageSource = targetEntity.damageSources().mobAttack((LivingEntity) targetEntity);
|
||||
|
|
|
@ -565,7 +565,6 @@ public class Config
|
|||
eInfo.attackProbability = 30;
|
||||
}
|
||||
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
try {
|
||||
eInfo.attackEffect = EntityInfo.Effect.fromString(nestedConf.get("attack_effect"));
|
||||
if(eInfo.attackEffect != EntityInfo.Effect.UNKNOWN) {
|
||||
|
@ -594,6 +593,7 @@ public class Config
|
|||
logEntityMissingOptionalValue("attack_effect", name, "unknown");
|
||||
}
|
||||
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
try {
|
||||
eInfo.attackVariance = nestedConf.getInt("attack_variance");
|
||||
if (eInfo.attackVariance < 0) {
|
||||
|
@ -909,6 +909,8 @@ public class Config
|
|||
break;
|
||||
} else if (!eInfo.playerName.isEmpty() && playerName != null && playerName.equals(eInfo.playerName)) {
|
||||
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("speed", eInfo.speed);
|
||||
entity.set("haste_speed", eInfo.hasteSpeed);
|
||||
|
@ -937,8 +939,10 @@ public class Config
|
|||
newEntry.set("attack_probability", eInfo.attackProbability);
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
newEntry.set("attack_variance", eInfo.attackVariance);
|
||||
}
|
||||
newEntry.set("attack_effect", eInfo.attackEffect.toString());
|
||||
newEntry.set("attack_effect_probability", eInfo.attackEffectProbability);
|
||||
if (eInfo.playerName.isEmpty()) {
|
||||
newEntry.set("defense_damage", eInfo.defenseDamage);
|
||||
newEntry.set("defense_damage_probability", eInfo.defenseDamageProbability);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue