Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Machine explosion chat messaging #2104

Draft
wants to merge 4 commits into
base: 1.20.1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,7 @@
"config.gtceu.option.hardGlassRecipes": "sǝdıɔǝᴚssɐן⅁pɹɐɥ",
"config.gtceu.option.hardIronRecipes": "sǝdıɔǝᴚuoɹIpɹɐɥ",
"config.gtceu.option.hardMiscRecipes": "sǝdıɔǝᴚɔsıWpɹɐɥ",
"config.gtceu.option.hardMultiRecipes": "sǝdıɔǝᴚıʇןnWpɹɐɥ",
"config.gtceu.option.hardRedstoneRecipes": "sǝdıɔǝᴚǝuoʇspǝᴚpɹɐɥ",
"config.gtceu.option.hardToolArmorRecipes": "sǝdıɔǝᴚɹoɯɹⱯןoo⟘pɹɐɥ",
"config.gtceu.option.hardWoodRecipes": "sǝdıɔǝᴚpooMpɹɐɥ",
Expand Down Expand Up @@ -3063,6 +3064,7 @@
"gtceu.machine.ev_sifter.tooltip": "buıʇɟıs dǝǝʞ puɐ ɯןɐɔ ʎɐʇSㄥ§",
"gtceu.machine.ev_thermal_centrifuge.tooltip": "ʎןǝsıɔǝɹd ǝɹoɯ sǝɹO buıʇɐɹɐdǝSㄥ§",
"gtceu.machine.ev_wiremill.tooltip": "ʎןʇuǝıɔıɟɟǝ ǝɹoɯ sǝɹıM sǝɔnpoɹԀㄥ§",
"gtceu.machine.explosion": "ɹ§%dᄅ§ :Z 'ɹ§%dᄅ§ :ʎ 'ɹ§%dᄅ§ :X ʇɐ pǝpoןdxǝ %s",
"gtceu.machine.extreme_combustion_engine.tooltip": "ɹǝsɐǝןǝᴚ ʎbɹǝuƎ ןɐɔıɯǝɥƆ ǝɯǝɹʇxƎ",
"gtceu.machine.fisher.requirement": "˙ʍoןǝq ʎןʇɔǝɹıp ɹǝʇɐʍ ɟo ǝɹɐnbs pǝɹǝʇuǝɔ %dx%d ɐ sǝɹınbǝᴚ",
"gtceu.machine.fisher.speed": "sʞɔıʇ %d ʎɹǝʌǝ buıɥʇǝɯos sǝɥɔʇɐƆ",
Expand Down
2 changes: 2 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,7 @@
"config.gtceu.option.hardGlassRecipes": "hardGlassRecipes",
"config.gtceu.option.hardIronRecipes": "hardIronRecipes",
"config.gtceu.option.hardMiscRecipes": "hardMiscRecipes",
"config.gtceu.option.hardMultiRecipes": "hardMultiRecipes",
"config.gtceu.option.hardRedstoneRecipes": "hardRedstoneRecipes",
"config.gtceu.option.hardToolArmorRecipes": "hardToolArmorRecipes",
"config.gtceu.option.hardWoodRecipes": "hardWoodRecipes",
Expand Down Expand Up @@ -3063,6 +3064,7 @@
"gtceu.machine.ev_sifter.tooltip": "§7Stay calm and keep sifting",
"gtceu.machine.ev_thermal_centrifuge.tooltip": "§7Separating Ores more precisely",
"gtceu.machine.ev_wiremill.tooltip": "§7Produces Wires more efficiently",
"gtceu.machine.explosion": "%s exploded at X: §2%d§r, Y: §2%d§r, Z: §2%d§r",
"gtceu.machine.extreme_combustion_engine.tooltip": "Extreme Chemical Energy Releaser",
"gtceu.machine.fisher.requirement": "Requires a %dx%d centered square of water directly below.",
"gtceu.machine.fisher.speed": "Catches something every %d ticks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import com.gregtechceu.gtceu.api.GTValues;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.utils.FormattingUtil;
import com.gregtechceu.gtceu.utils.GTUtil;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;

Expand Down Expand Up @@ -57,6 +59,12 @@ default void doExplosion(BlockPos pos, float explosionPower) {
var machine = self();
var level = machine.getLevel();
level.removeBlock(pos, false);
var owner = machine.getHolder().getOwner();
if (owner != null) {
String machineName = FormattingUtil.toEnglishName(machine.getDefinition().getName());
owner.broadcastMessage(
Component.translatable("gtceu.machine.explosion", machineName, pos.getX(), pos.getY(), pos.getZ()));
}
level.explode(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
explosionPower, ConfigHolder.INSTANCE.machines.doesExplosionDamagesTerrain ?
Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ public boolean isPlayerFriendly(Player player) {
return false;
}

@Override
public void broadcastMessage(Component message) {
var members = guild.members();
for (var player : members.allMembers()) {
var serverPlayer = ServerLifecycleHooks.getCurrentServer().getPlayerList()
.getPlayer(player.profile().getId());
if (serverPlayer != null) {
serverPlayer.displayClientMessage(message, false);
}
}
}

@Override
public void displayInfo(List<Component> compList) {
compList.add(Component.translatable("behavior.portable_scanner.machine_ownership", type().getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ public boolean isPlayerFriendly(Player player) {
return false;
}

@Override
public void broadcastMessage(Component message) {
for (var player : team.getMembers()) {
var serverPlayer = ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayer(player);
if (serverPlayer != null) {
serverPlayer.displayClientMessage(message, false);
}
}
}

@Override
public void displayInfo(List<Component> compList) {
compList.add(Component.translatable("behavior.portable_scanner.machine_ownership", type().getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ default CompoundTag write() {

boolean isPlayerFriendly(Player player);

void broadcastMessage(Component message);

enum MachineOwnerType {

PLAYER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ public boolean isPlayerFriendly(Player player) {
return true;
}

@Override
public void broadcastMessage(Component message) {
var serverPlayer = ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayer(playerUUID);
if (serverPlayer != null) {
serverPlayer.displayClientMessage(message, false);
}
}

@Override
public void displayInfo(List<Component> compList) {
compList.add(Component.translatable("behavior.portable_scanner.machine_ownership", type().getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ public static void init(RegistrateLangProvider provider) {
provider.add("gtceu.machine.muffle.off", "Sound Muffling: Disabled");
provider.add("gtceu.machine.perfect_oc", "Does not lose energy efficiency when overclocked.");
provider.add("gtceu.machine.parallel_limit", "Can run up to §b%d§r§7 Recipes at once.");

provider.add("gtceu.machine.explosion", "%s exploded at X: §2%d§r, Y: §2%d§r, Z: §2%d§r");
provider.add("gtceu.machine.multiblock.tank.tooltip",
"Fill and drain through the controller or tank valves.");
provider.add("gtceu.machine.tank_valve.tooltip",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public static void processGemConversion(TagPrefix gemPrefix, Material material,
String.format("gem_to_gem_%s_%s", FormattingUtil.toLowerCaseUnder(prevPrefix.name),
material.getName()),
prevStack,
"h", new UnificationEntry(gemPrefix, material));
'h', new UnificationEntry(gemPrefix, material));

CUTTER_RECIPES
.recipeBuilder("cut_" + material.getName() + "_" + FormattingUtil.toLowerCaseUnder(gemPrefix.name) +
Expand Down
Loading