#1913 Improved in-game documentation via tooltips for both machines & upgrades and solar panel exception fix (#1917)
* Overclocker and energy storage tooltip added * Add default constructor to fix NoSuchMethodException java.lang.NoSuchMethodException when loading world with existing solar panels * Base Upgrade tooltips (Might move to reborn core) * Migrated to tooltip callback and added most machine infos * Optimize imports of stuff previously touched * Added more informationtips and cleanup * Revert itemUpgrade formatting * Final touches * Readd easter eggs, multi-line tips and translation updates Easter egg tooltips are now restricted to only ctrl-hover
This commit is contained in:
parent
34074d7a8a
commit
3dbc7feb62
11 changed files with 229 additions and 28 deletions
|
@ -40,12 +40,17 @@ import net.minecraft.text.Text;
|
|||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.common.BaseBlockEntityProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import team.reborn.energy.Energy;
|
||||
import team.reborn.energy.EnergyHolder;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.items.ItemUpgrade;
|
||||
import techreborn.utils.DocumentAssistUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -58,6 +63,24 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
|||
@Override
|
||||
public void getTooltip(ItemStack stack, TooltipContext tooltipContext, List<Text> components) {
|
||||
Item item = stack.getItem();
|
||||
|
||||
|
||||
// Machine info and upgrades helper section
|
||||
Block block = Block.getBlockFromItem(item);
|
||||
|
||||
if(block instanceof BaseBlockEntityProvider){
|
||||
DocumentAssistUtils.addInfo(item.getTranslationKey(), components);
|
||||
}
|
||||
|
||||
if(item instanceof ItemUpgrade){
|
||||
ItemUpgrade upgrade = (ItemUpgrade)item;
|
||||
|
||||
DocumentAssistUtils.addInfo(item.getTranslationKey(), components, false);
|
||||
components.addAll(DocumentAssistUtils.getUpgradeStats(TRContent.Upgrades.valueOf(upgrade.name.toUpperCase()), stack.getCount(), Screen.hasShiftDown()));
|
||||
}
|
||||
|
||||
|
||||
// Other section
|
||||
if (item instanceof IListInfoProvider) {
|
||||
((IListInfoProvider) item).addInfo(components, false, false);
|
||||
} else if (stack.getItem() instanceof EnergyHolder) {
|
||||
|
@ -79,8 +102,7 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
|||
}
|
||||
} else {
|
||||
try {
|
||||
Block block = Block.getBlockFromItem(item);
|
||||
if (block != null && (block instanceof BlockWithEntity || block instanceof BlockEntityProvider) && Registry.BLOCK.getId(block).getNamespace().contains("techreborn")) {
|
||||
if ((block instanceof BlockEntityProvider) && Registry.BLOCK.getId(block).getNamespace().contains("techreborn")) {
|
||||
BlockEntity blockEntity = ((BlockEntityProvider) block).createBlockEntity(MinecraftClient.getInstance().world);
|
||||
boolean hasData = false;
|
||||
if (stack.hasTag() && stack.getTag().contains("blockEntity_data")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue