Compare commits

..
4 Commits
Author SHA1 Message Date
Eldrinn Elantey d829ae466b Localize and unify missing block messages in autoplace (#70)
StructureLib built the missing block name on the server, where only
en_US is loaded, so players on dedicated servers saw English names in
chat. Send the item's lang key and let the client translate it. Stacks
whose name is not a plain key, GT meta items among them, keep the old
server side name.

Players also saw two shapes of the same message: a bracketed name with
rarity color and an item tooltip from two of the survivalPlaceBlocks
branches, a bare yellow name from the stack list branch. All three now
build the name the same way.
2026-09-09 09:21:27 +08:00
Martin Robertz 137f651486 update deps 2026-07-03 19:22:22 +02:00
attempt0andgithub-actions[bot] ff88cbf2d7 Read channel in getBlocksToPlace (#68)
## Summary
This causes inconsistency in the API and should be addressed. The
primary consumer of the API is NEI preview and the preview does show
wrong block with glass tier set, not sure if this is the cause
<img width="1088" height="491" alt="image"
src="https://github.com/user-attachments/assets/fff146d8-6d8e-44d9-842e-1677691271d2"
/>

## Checklist
- [ ] I have tested this PR in DevEnv
- [ ] I have tested this PR in Fullpack
- [x] This PR is in compliance with the [GTNH AI
Policy](https://github.com/GTNewHorizons/GTNH-Dev-Doc/blob/master/AI_POLICY.md)
- [ ] This PR requires another PR in order to merge

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-07-03 23:33:08 +08:00
DylanTaylor1 4922760b46 Change subchannel color to match tooltips (#67)
Changes subchannel color from orange to aqua to match tooltips from the
Construction Tooltips Overhaul
(https://github.com/GTNewHorizons/GT5-Unofficial/pull/7299)
2026-07-02 21:12:20 -04:00
5 changed files with 34 additions and 14 deletions

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
// Add your dependencies here
dependencies {
api("com.github.GTNewHorizons:GTNHLib:0.11.18:dev")
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.104-GTNH:dev")
api("com.github.GTNewHorizons:GTNHLib:0.11.21:dev")
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.110-GTNH:dev")
testImplementation(platform('org.junit:junit-bom:5.9.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
@@ -30,6 +30,7 @@ import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.event.HoverEvent;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
@@ -38,10 +39,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -317,6 +317,25 @@ public class StructureUtility {
return survivalPlaceBlock(block, meta, world, x, y, z, s, (EntityPlayer) actor, chatter);
}
/**
* Build a chat component naming the given stack, so that the receiving client localizes it.
* <p>
* Falls back to the server side display name for stacks whose name is not a plain translation key, e.g. items that
* assemble their name in {@link Item#getItemStackDisplayName(ItemStack)}.
*/
private static IChatComponent getStackChatName(ItemStack stack) {
String key = stack.getUnlocalizedName() + ".name";
if (!StatCollector.canTranslate(key)) return stack.func_151000_E();
IChatComponent name = new ChatComponentText("[").appendSibling(new ChatComponentTranslation(key))
.appendText("]");
NBTTagCompound tag = new NBTTagCompound();
stack.writeToNBT(tag);
name.getChatStyle()
.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ChatComponentText(tag.toString())))
.setColor(stack.getRarity().rarityColor);
return name;
}
/**
* This is a helper method for implementing
* {@link IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, Consumer)}
@@ -341,7 +360,7 @@ public class StructureUtility {
ItemStack stack = new ItemStack(itemBlock, 1, itemMeta);
if (!s.takeOne(stack, true)) {
if (chatter != null) chatter.accept(
new ChatComponentTranslation("structurelib.autoplace.missing_block", stack.func_151000_E()));
new ChatComponentTranslation("structurelib.autoplace.missing_block", getStackChatName(stack)));
return PlaceResult.REJECT;
}
if (block instanceof ICustomBlockSetting blockCustom) {
@@ -447,7 +466,7 @@ public class StructureUtility {
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) return PlaceResult.REJECT;
if (!assumeStackPresent && !s.takeOne(stack, true)) {
if (chatter != null) chatter.accept(
new ChatComponentTranslation("structurelib.autoplace.missing_block", stack.func_151000_E()));
new ChatComponentTranslation("structurelib.autoplace.missing_block", getStackChatName(stack)));
return PlaceResult.REJECT;
}
if (!stack.copy().tryPlaceItemIntoWorld(actor, world, x, y, z, ForgeDirection.UP.ordinal(), 0.5f, 0.5f, 0.5f))
@@ -1484,10 +1503,10 @@ public class StructureUtility {
}
for (ItemStack stack : e.getStacks()) {
if (!source.takeOne(stack, true)) {
IChatComponent name = new ChatComponentText(stack.getDisplayName());
name.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW));
env.getChatter()
.accept(new ChatComponentTranslation("structurelib.autoplace.missing_block", name));
env.getChatter().accept(
new ChatComponentTranslation(
"structurelib.autoplace.missing_block",
getStackChatName(stack)));
continue;
}
return StructureUtility.survivalPlaceBlock(
@@ -3013,7 +3032,8 @@ public class StructureUtility {
@Override
public BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger,
AutoPlaceEnvironment env) {
return backing.getBlocksToPlace(t, world, x, y, z, trigger, env);
return backing
.getBlocksToPlace(t, world, x, y, z, ChannelDataAccessor.withChannel(trigger, channel), env);
}
@Deprecated
@@ -43,7 +43,7 @@ item.structurelib.constructableTrigger.gui.info=Many multiblocks support some de
channels.structurelib.show_errors=When set, will highlight parts of the multiblock that is definitely wrong
structurelib.tooltip.channelvalue=§7Indicates value §6%d§r§7 for sub channel §6%s
structurelib.tooltip.channelvalue=§7Value §b%d§r§7 for subchannel §b%s
structurelib.tooltip.indicator_dnd=Drop into GUI to select this value for this channel
structurelib.autoplace.built_stat=Built %s blocks
@@ -43,7 +43,7 @@ item.structurelib.constructableTrigger.gui.info=Многие мультибло
channels.structurelib.show_errors=Если включено, подсвечивает элементы мультиблока с явными ошибками
structurelib.tooltip.channelvalue=§7Указывает значение §6%d§r§7 для подканала §6%s
structurelib.tooltip.channelvalue=§7Указывает значение §b%d§r§7 для подканала §b%s
structurelib.tooltip.indicator_dnd=Перейдите в GUI, чтобы выбрать это значение для этого канала.
structurelib.autoplace.built_stat=Построено %s блоков
@@ -42,7 +42,7 @@ item.structurelib.constructableTrigger.gui.info=许多多方块的结构都是
channels.structurelib.show_errors=添加后,在投影时会高亮标出必然错误的部分
structurelib.tooltip.channelvalue=§7表示子信道 §6%2$s§r§7 为 §6%d§r
structurelib.tooltip.channelvalue=§7表示子信道 §b%2$s§r§7 为 §b%d§r
structurelib.tooltip.indicator_dnd=拖入GUI中来选择该值
structurelib.autoplace.built_stat=已放置 %s 个方块