Skip to content

Commit

Permalink
feat: add messages for substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed May 5, 2022
1 parent 8bac4f2 commit e3e887e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/sekwah/narutomod/abilities/Ability.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ public SoundEvent castingSound() {
}

public String getTranslationKey() {
return this.getTranslationKey(0);
}

/**
* Mostly for channeled abilities. but in case an ability evolves as its channeled.
* @param ticksActive
* @return
*/
public String getTranslationKey(int ticksActive) {
return this.getRegistryName().toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ public boolean handleCost(Player player, INinjaData ninjaData, int chargeAmount)
return true;
}

@Override
public String getTranslationKey(int ticksActive) {
if(ticksActive <= 1) {
return this.getRegistryName().toString();
} else {
return this.getRegistryName().toString() + ".mark";
}
}

/**
* Due to the nature of this ability all costs and other things will be handled here.
*/
@Override
public void performServer(Player player, INinjaData ninjaData, int ticksActive) {
if(ticksActive == 0) {
player.displayClientMessage(new TranslatableComponent("jutsu.cast.substitution"), false);
// Activate
ninjaData.useSubstitution(1);
Vec3 loc = ninjaData.getSubstitutionLoc();
Expand All @@ -54,14 +62,18 @@ public void performServer(Player player, INinjaData ninjaData, int ticksActive)
}
}
} else {
player.displayClientMessage(new TranslatableComponent("jutsu.cast.substitution_mark"), false);
ninjaData.setSubstitutionLoc(player.position(), player.level.dimension().location());
// Mark
}
}

@Override
public boolean hideChannelMessages() {
return false;
}

@Override
public boolean useChargedMessages() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ public void setCurrentlyChanneledAbility(Player player, Ability ability) {

if(!(ability instanceof Ability.Channeled channeled && channeled.hideChannelMessages())) {
if (ability instanceof Ability.Channeled channeled && channeled.useChargedMessages()) {
player.sendMessage(new TranslatableComponent("jutsu.charge.start", new TranslatableComponent(ability.getTranslationKey()).withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.GREEN), player.getUUID());
player.sendMessage(new TranslatableComponent("jutsu.charge.start", new TranslatableComponent(ability.getTranslationKey(1)).withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.GREEN), player.getUUID());
} else {
player.sendMessage(new TranslatableComponent("jutsu.channel.start", new TranslatableComponent(ability.getTranslationKey()).withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.GREEN), player.getUUID());
player.sendMessage(new TranslatableComponent("jutsu.channel.start", new TranslatableComponent(ability.getTranslationKey(1)).withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.GREEN), player.getUUID());
}
}

Expand All @@ -238,7 +238,7 @@ public void setCurrentlyChanneledAbility(Player player, Ability ability) {
if( currentAbility != null) {
if(!(currentAbility instanceof Ability.Channeled channeled && channeled.hideChannelMessages())) {
if (currentAbility instanceof Ability.Channeled channeled && channeled.useChargedMessages()) {
player.sendMessage(new TranslatableComponent("jutsu.cast", new TranslatableComponent(currentAbility.getTranslationKey()).withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.GREEN), player.getUUID());
player.sendMessage(new TranslatableComponent("jutsu.cast", new TranslatableComponent(currentAbility.getTranslationKey(this.ticksChanneled - 1)).withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.GREEN), player.getUUID());
} else {
player.sendMessage(new TranslatableComponent("jutsu.channel.stop", new TranslatableComponent(currentAbility.getTranslationKey()).withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.RED), player.getUUID());
}
Expand Down Expand Up @@ -299,7 +299,8 @@ public void updateDataServer(Player player) {
}
} else {
if (this.ticksChanneled > 0) {
ability.performServer(player, this, this.ticksChanneled - 1);
int finalTicksChanneled = this.ticksChanneled - 1;
ability.performServer(player, this, finalTicksChanneled);
this.setCurrentlyChanneledAbility(player, null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public static void handle(ServerAbilityChannelPacket msg, Supplier<NetworkEvent.
} else if(msg.status == ChannelStatus.MIN_ACTIVATE) {
if (ability instanceof Ability.Channeled channeled && channeled.canActivateBelowMinCharge()) {
if(ability.handleCost(player, ninjaData, 0)) {
player.sendMessage(new TranslatableComponent("jutsu.cast", new TranslatableComponent(ability.getTranslationKey()).withStyle(ChatFormatting.YELLOW)).withStyle(ChatFormatting.GREEN), player.getUUID());
ability.performServer(player, ninjaData, 0);
}
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/narutomod/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,7 @@
"naruto.keys.key1": "Jutsu Key 1",
"naruto.keys.key2": "Jutsu Key 2",
"naruto.keys.key3": "Jutsu Key 3",
"naruto.keys.leap": "Leap"
"naruto.keys.leap": "Leap",
"narutomod:substitution": "Substitution",
"narutomod:substitution.mark": "Substitution - Location Marked"
}

0 comments on commit e3e887e

Please sign in to comment.