Skip to content

Commit

Permalink
Add hud message for light level changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenny-Hui committed Mar 18, 2024
1 parent c9e3d70 commit 3dcfc7a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion fabric/src/main/java/com/lx862/jcm/mod/block/LightBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.lx862.jcm.mod.block.base.JCMBlock;
import com.lx862.jcm.mod.data.BlockProperties;
import com.lx862.jcm.mod.util.BlockUtil;
import com.lx862.jcm.mod.util.TextCategory;
import com.lx862.jcm.mod.util.TextUtil;
import org.mtr.mapping.holder.*;
import org.mtr.mapping.tool.HolderBase;

Expand Down Expand Up @@ -52,7 +55,10 @@ public ActionResult onUse2(BlockState state, World world, BlockPos pos, PlayerEn
@Override
public void onServerUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if(player.isHolding(this.asItem2())) {
world.setBlockState(pos, state.cycle(new Property<>(LIGHT_LEVEL.data)));
BlockState newState = state.cycle(new Property<>(LIGHT_LEVEL.data));
world.setBlockState(pos, newState);

player.sendMessage(Text.cast(TextUtil.translatable(TextCategory.HUD, "light_block.success", BlockUtil.getProperty(newState, new Property<>(LIGHT_LEVEL.data)))), true);
}
}

Expand Down
1 change: 1 addition & 0 deletions fabric/src/main/resources/assets/jsblock/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"hud.jsblock.faresaver.fail": "You already have a $%d discount applied on your next journey!",
"hud.jsblock.faresaver.saved": "You have saved $%d.",
"hud.jsblock.faresaver.saved_sarcasm": "You have wasted $%d.",
"hud.jsblock.light_block.success": "Light level: %d",
"hud.jsblock.kcr_name_sign.success": "Direction changed!",
"hud.jsblock.kcr_emg_stop_sign.success": "Direction changed!",
"hud.jsblock.operator_button.fail": "You need a Driver Key to activate!",
Expand Down
3 changes: 2 additions & 1 deletion fabric/src/main/resources/assets/jsblock/lang/it_it.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@
"hud.jsblock.enquiry_machine.success": "Soldi Caricati: $%s",
"hud.jsblock.faresaver.success": "Lo sconto di $%d sarà usato alla prossima uscita da una stazione",
"hud.jsblock.faresaver.success.sarcasm": "Il così chiamato \"Sconto\" sarà usato alla prossima uscita da una stazione.",
"hud.jsblock.faresaver.fail": "Possiedi già uno sconto di $%d per il tuo prossimo viaggio!",
"hud.jsblock.faresaver.saved": "Hai salvato $%d.",
"hud.jsblock.faresaver.saved_sarcasm": "Hai perso $%d.",
"hud.jsblock.faresaver.fail": "Possiedi già uno sconto di $%d per il tuo prossimo viaggio!",
"hud.jsblock.light_block.success": "Livello di luce: %d",
"hud.jsblock.kcr_name_sign.success": "Direzione Cambiata!",
"hud.jsblock.kcr_emg_stop_sign.success": "Direzione Cambiata!",
"hud.jsblock.operator_button.fail": "Hai bisogno della chiave da macchinista per usarlo!",
Expand Down
Binary file removed libs/.fuse_hidden000011c100000045
Binary file not shown.

0 comments on commit 3dcfc7a

Please sign in to comment.