Skip to content

Commit

Permalink
fix scenario display
Browse files Browse the repository at this point in the history
  • Loading branch information
khjxiaogu committed Jan 25, 2025
1 parent 3084776 commit f386dce
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/teammoeg/chorda/io/CodecUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public <T> DataResult<Pair<byte[], T>> decode(DynamicOps<T> ops, T input) {
};
public static final Codec<ItemStack> ITEMSTACK_CODEC = RecordCodecBuilder.create(t -> t.group(
CodecUtil.registryCodec(()->BuiltInRegistries.ITEM).fieldOf("id").forGetter(ItemStack::getItem),
Codec.INT.fieldOf("Count").forGetter(ItemStack::getCount),
Codec.INT.optionalFieldOf("Count",1).forGetter(ItemStack::getCount),
CompoundTag.CODEC.optionalFieldOf("tag").forGetter(i->Optional.ofNullable(i.getTag())))/*,
CompoundTag.CODEC.optionalFieldOf("ForgeCaps").forGetter(ItemStack::serializeCaps)*/
.apply(t, (id,cnt,tag)->{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public class FHIcons {
private static final TypedCodecRegistry<FHIcon> serializers = new TypedCodecRegistry<>();
public static final Codec<FHIcon> CODEC = new AlternativeCodecBuilder<FHIcon>(FHIcon.class)
.addSaveOnly(FHNopIcon.class, FHNopIcon.CODEC.codec())
.add(FHItemIcon.class, FHItemIcon.ICON_CODEC)
.add(serializers.codec())
.add(FHItemIcon.class, FHItemIcon.ICON_CODEC)
.addSaveOnly(FHIcon.class, FHNopIcon.CODEC.codec())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private EditUtils() {

public static void editResearch(Widget p, Research r) {
if (r != null) {
FHResearch.load(r);
r=FHResearch.load(r);
}
new ResearchEditorDialog(p, r, r.getCategory()).open();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.teammoeg.chorda.lang.Components;
import com.teammoeg.frostedheart.content.research.FHResearch;
import com.teammoeg.frostedheart.content.research.ResearchUtils;
import com.teammoeg.frostedheart.content.research.gui.FHIcons.IconEditor;
import com.teammoeg.frostedheart.content.research.gui.editor.*;
import com.teammoeg.frostedheart.content.research.research.clues.ClueEditor;
Expand Down Expand Up @@ -161,9 +162,11 @@ public void onClose() {
}

EditUtils.saveResearch(r);

FHResearch.load(r);
}
FHResearch.reindex();
ResearchUtils.refreshResearchGui();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import blusunrize.immersiveengineering.api.ManualHelper;
import blusunrize.immersiveengineering.api.multiblocks.MultiblockHandler;
import blusunrize.immersiveengineering.api.multiblocks.MultiblockHandler.IMultiblock;
import blusunrize.immersiveengineering.api.multiblocks.TemplateMultiblock;
import blusunrize.immersiveengineering.common.blocks.multiblocks.IETemplateMultiblock;
import blusunrize.immersiveengineering.common.register.IEItems;
import blusunrize.lib.manual.ManualEntry;
Expand Down Expand Up @@ -81,7 +82,9 @@ public String getBrief() {

@Override
public FHIcon getDefaultIcon() {
return FHIcons.getIcon(IEItems.Tools.HAMMER);
if(multiblock instanceof IETemplateMultiblock mb)
return FHIcons.getIcon(mb.getBlock());
return FHIcons.getIcon(IEItems.Tools.HAMMER.get());
}

@Override
Expand All @@ -92,11 +95,7 @@ public MutableComponent getDefaultName() {
@Override
public List<Component> getDefaultTooltip() {
ArrayList<Component> ar = new ArrayList<>();
String raw = multiblock.getUniqueName().toString();
String namespace = raw.substring(0, raw.indexOf(':'));
String multiblock = raw.substring(raw.indexOf('/') + 1);
String key = "block." + namespace + "." + multiblock;
ar.add(Lang.translateKey(key));
ar.add(multiblock.getDisplayName());
return ar;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
import com.teammoeg.frostedheart.content.scenario.client.gui.layered.java2d.GraphicsTextContent;
import com.teammoeg.frostedheart.util.client.Lang;
import com.teammoeg.chorda.client.ClientUtils;
import com.teammoeg.chorda.client.MultipleItemHoverEvent;
import com.teammoeg.chorda.client.ui.Point;
import com.teammoeg.chorda.client.ui.Rect;
import com.teammoeg.chorda.io.nbtbuilder.ArrayNBTBuilder;
import com.teammoeg.chorda.io.nbtbuilder.CompoundNBTBuilder;
import com.teammoeg.chorda.lang.Components;

import dev.ftb.mods.ftblibrary.icon.Color4I;
Expand All @@ -49,13 +52,16 @@
import dev.ftb.mods.ftbquests.quest.task.ItemTask;
import dev.ftb.mods.ftbquests.quest.task.KillTask;
import dev.ftb.mods.ftbquests.quest.task.Task;
import dev.latvian.mods.itemfilters.api.ItemFiltersAPI;
import net.minecraft.sounds.Music;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.client.resources.sounds.SoundInstance.Attenuation;
import net.minecraft.nbt.ListTag;
import net.minecraft.ChatFormatting;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
Expand All @@ -77,8 +83,28 @@ public void showTask(IClientScene runner,@Param("q")String q,@Param("t")int t) {
Task tsk=quest.getTasksAsList().get(t);
Component itt;
if(tsk instanceof ItemTask itmtask) {

MutableComponent cmp=tsk.getTitle().copy().withStyle(Style.EMPTY.withColor(ChatFormatting.YELLOW).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM,new HoverEvent.ItemStackInfo(itmtask.getItemStack()))));
ItemStack stack=itmtask.getItemStack();
HoverEvent.ItemStackInfo ev;
if(ItemFiltersAPI.isFilter(stack)) {
List<ItemStack> toshow=new ArrayList<>();
ItemFiltersAPI.getDisplayItemStacks(stack, toshow);

CompoundNBTBuilder<Void> disp=CompoundNBTBuilder.create();
var b=disp.array("Lore");
b.addString(Component.Serializer.toJson(Lang.translateTooltip("suitable_items")));

for(ItemStack is:toshow) {
b.addString(Component.Serializer.toJson(Lang.builder().text("- ").add(is.getDisplayName()).component()));
}
for(ItemStack is:toshow) {
is.addTagElement("display", disp.build());
}
ev=new MultipleItemHoverEvent(toshow);
}else {
ev=new HoverEvent.ItemStackInfo(itmtask.getItemStack());
}

MutableComponent cmp=tsk.getTitle().copy().withStyle(Style.EMPTY.withColor(ChatFormatting.YELLOW).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM,ev)));
itt= Lang.translateMessage("item_task",cmp);

}else if(tsk instanceof KillTask) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"tooltip.frostedheart.temp.plant.snow_resistant": "Resistant to Snow",
"tooltip.frostedheart.temp.plant.blizzard_vulnerable": "Vulnerable to Blizzard",
"tooltip.frostedheart.temp.plant.blizzard_resistant": "Resistant to Blizzard",
"tooltip.frostedheart.suitable_items":"Accepted Items:",
"ftbquests.reward.frostedheart.insight": "Insight",
"ftbquests.reward.frostedheart.temperature_difficulty": "Temperature Difficulty",
"ftbquests.reward.frostedheart.temperature_difficulty.temperature_difficulty": "Temperature Difficulty",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@
"tooltip.frostedheart.pressure.max_output": "最多产生气压值",
"tooltip.frostedheart.pressure.average_intake": "平均消耗气压值",
"tooltip.frostedheart.pressure.average_output": "平均产生气压值",
"tooltip.frostedheart.suitable_items":"接受物品:",
"gui.frostedheart.creative_heater.heat": "产生的气压值",
"tips.frostedheart.empty.title": "哎呀,这里什么都没有",
"tips.frostedheart.error.desc": "请检查整合包是否正确安装,或向我们报告这个bug",
Expand Down

0 comments on commit f386dce

Please sign in to comment.