Lang sendStatus

This commit is contained in:
simibubi 2022-07-10 15:14:58 +02:00
parent d59e748c01
commit 560042d781
5 changed files with 46 additions and 34 deletions

View file

@ -115,7 +115,9 @@ public class SuperGlueSelectionHandler {
}
if (firstPos != null && !firstPos.closerThan(hovered, 24)) {
Lang.sendStatus(player, FAIL, "super_glue.too_far");
Lang.translate("super_glue.too_far")
.color(FAIL)
.sendStatus(player);
return;
}
@ -131,15 +133,23 @@ public class SuperGlueSelectionHandler {
if (currentCluster != null) {
boolean canReach = currentCluster.contains(hovered);
boolean canAfford = SuperGlueSelectionHelper.collectGlueFromInventory(player, glueRequired, true);
int color = HIGHLIGHT;
String key = "super_glue.click_to_confirm";
if (!canReach)
Lang.sendStatus(player, FAIL, "super_glue.cannot_reach");
else if (!canAfford)
Lang.sendStatus(player, FAIL, "super_glue.not_enough");
else if (cancel)
Lang.sendStatus(player, FAIL, "super_glue.click_to_discard");
else
Lang.sendStatus(player, HIGHLIGHT, "super_glue.click_to_confirm");
if (!canReach) {
color = FAIL;
key = "super_glue.cannot_reach";
} else if (!canAfford) {
color = FAIL;
key = "super_glue.not_enough";
} else if (cancel) {
color = FAIL;
key = "super_glue.click_to_discard";
}
Lang.translate(key)
.color(color)
.sendStatus(player);
if (currentSelectionBox != null)
CreateClient.OUTLINER.showAABB(bbOutlineSlot, currentSelectionBox)
@ -223,7 +233,8 @@ public class SuperGlueSelectionHandler {
firstPos = hoveredPos;
if (face != null)
SuperGlueItem.spawnParticles(level, firstPos, face, true);
Lang.sendStatus(player, "super_glue.first_pos");
Lang.translate("super_glue.first_pos")
.sendStatus(player);
AllSoundEvents.SLIME_ADDED.playAt(level, firstPos, 0.5F, 0.85F, false);
level.playSound(player, firstPos, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.BLOCKS, 0.75f, 1);
return true;
@ -233,7 +244,8 @@ public class SuperGlueSelectionHandler {
LocalPlayer player = Minecraft.getInstance().player;
currentCluster = null;
firstPos = null;
Lang.sendStatus(player, "super_glue.abort");
Lang.translate("super_glue.abort")
.sendStatus(player);
clusterCooldown = 0;
}
@ -251,7 +263,8 @@ public class SuperGlueSelectionHandler {
.lineWidth(1 / 24f);
discard();
Lang.sendStatus(player, "super_glue.sucess");
Lang.translate("super_glue.success")
.sendStatus(player);
clusterCooldown = 40;
}

View file

@ -49,7 +49,8 @@ public class CartAssemblerBlockItem extends BlockItem {
if (player == null)
return false;
if (!(block instanceof BaseRailBlock)) {
Lang.sendStatus(player, "block.cart_assembler.invalid");
Lang.translate("block.cart_assembler.invalid")
.sendStatus(player);
return false;
}
@ -81,7 +82,7 @@ public class CartAssemblerBlockItem extends BlockItem {
if (!player.isCreative())
context.getItemInHand()
.shrink(1);
AdvancementBehaviour.setPlacedBy(world, pos, player);
return true;
}

View file

@ -196,9 +196,10 @@ public class LinkedControllerClientHandler {
LinkBehaviour linkBehaviour = TileEntityBehaviour.get(mc.level, selectedLocation, LinkBehaviour.TYPE);
if (linkBehaviour != null) {
AllPackets.channel.sendToServer(new LinkedControllerBindPacket(integer, selectedLocation));
Lang.sendStatus(mc.player, "linked_controller.key_bound", controls.get(integer)
Lang.translate("linked_controller.key_bound", controls.get(integer)
.getTranslatedKeyMessage()
.getString());
.getString())
.sendStatus(mc.player);
}
MODE = Mode.IDLE;
break;

View file

@ -90,8 +90,10 @@ public class SchematicAndQuillHandler {
firstPos = new BlockPos(bb.minX, bb.minY, bb.minZ);
secondPos = new BlockPos(bb.maxX, bb.maxY, bb.maxZ);
Lang.sendStatus(Minecraft.getInstance().player, "schematicAndQuill.dimensions", (int) bb.getXsize() + 1,
(int) bb.getYsize() + 1, (int) bb.getZsize() + 1);
LocalPlayer player = Minecraft.getInstance().player;
Lang.translate("schematicAndQuill.dimensions", (int) bb.getXsize() + 1, (int) bb.getYsize() + 1,
(int) bb.getZsize() + 1)
.sendStatus(player);
return true;
}
@ -115,25 +117,29 @@ public class SchematicAndQuillHandler {
}
if (selectedPos == null) {
Lang.sendStatus(player, "schematicAndQuill.noTarget");
Lang.translate("schematicAndQuill.noTarget")
.sendStatus(player);
return;
}
if (firstPos != null) {
secondPos = selectedPos;
Lang.sendStatus(player, "schematicAndQuill.secondPos");
Lang.translate("schematicAndQuill.secondPos")
.sendStatus(player);
return;
}
firstPos = selectedPos;
Lang.sendStatus(player, "schematicAndQuill.firstPos");
Lang.translate("schematicAndQuill.firstPos")
.sendStatus(player);
}
public void discard() {
LocalPlayer player = Minecraft.getInstance().player;
firstPos = null;
secondPos = null;
Lang.sendStatus(player, "schematicAndQuill.abort");
Lang.translate("schematicAndQuill.abort")
.sendStatus(player);
}
public void tick() {
@ -239,7 +245,9 @@ public class SchematicAndQuillHandler {
}
firstPos = null;
secondPos = null;
Lang.sendStatus(Minecraft.getInstance().player, "schematicAndQuill.saved", filepath);
LocalPlayer player = Minecraft.getInstance().player;
Lang.translate("schematicAndQuill.saved", filepath)
.sendStatus(player);
if (!convertImmediately)
return;

View file

@ -9,7 +9,6 @@ import com.simibubi.create.Create;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.fluids.FluidStack;
@ -27,16 +26,6 @@ public class Lang {
return new TranslatableComponent(Create.ID + "." + key, resolveBuilders(args));
}
@Deprecated // use Lang.translate(...).sendStatus(player)
public static void sendStatus(Player player, String key, Object... args) {
translate(key, args).sendStatus(player);
}
@Deprecated // use Lang.translate(...).color(color).sendStatus(player)
public static void sendStatus(Player player, int color, String key, Object... args) {
translate(key, args).color(color).sendStatus(player);
}
public static String asId(String name) {
return name.toLowerCase(Locale.ROOT);
}