mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 11:53:29 +01:00
added module tooltips
This commit is contained in:
parent
3409945c77
commit
68933f4b49
4 changed files with 39 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.prettypipes;
|
||||
|
||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||
import de.ellpeck.prettypipes.pipe.extraction.ExtractionModuleContainer;
|
||||
import de.ellpeck.prettypipes.pipe.extraction.ExtractionModuleGui;
|
||||
import de.ellpeck.prettypipes.pipe.extraction.ExtractionModuleItem;
|
||||
|
@ -39,6 +40,7 @@ import javax.annotation.Nullable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Bus.MOD)
|
||||
|
@ -112,10 +114,10 @@ public final class Registry {
|
|||
PacketHandler.setup();
|
||||
}
|
||||
|
||||
private static Item[] createTieredModule(String name, Function<ModuleTier, Item> item) {
|
||||
private static Item[] createTieredModule(String name, BiFunction<String, ModuleTier, ModuleItem> item) {
|
||||
List<Item> items = new ArrayList<>();
|
||||
for (ModuleTier tier : ModuleTier.values())
|
||||
items.add(item.apply(tier).setRegistryName(tier.name().toLowerCase(Locale.ROOT) + "_" + name));
|
||||
items.add(item.apply(name, tier).setRegistryName(tier.name().toLowerCase(Locale.ROOT) + "_" + name));
|
||||
return items.toArray(new Item[0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,46 @@
|
|||
package de.ellpeck.prettypipes.items;
|
||||
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ModuleItem extends Item implements IModule {
|
||||
public ModuleItem() {
|
||||
|
||||
private final String name;
|
||||
|
||||
public ModuleItem(String name) {
|
||||
super(new Properties().group(Registry.GROUP).maxStackSize(16));
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
||||
super.addInformation(stack, worldIn, tooltip, flagIn);
|
||||
if (Screen.hasShiftDown()) {
|
||||
String[] content = I18n.format("info." + PrettyPipes.ID + "." + this.name).split("\n");
|
||||
for (String s : content)
|
||||
tooltip.add(new StringTextComponent(s).setStyle(new Style().setColor(TextFormatting.GRAY)));
|
||||
} else {
|
||||
tooltip.add(new TranslationTextComponent("info." + PrettyPipes.ID + ".shift").setStyle(new Style().setColor(TextFormatting.DARK_GRAY)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,8 @@ public class ExtractionModuleItem extends ModuleItem {
|
|||
private final int speed;
|
||||
public final int filterSlots;
|
||||
|
||||
public ExtractionModuleItem(ModuleTier tier) {
|
||||
public ExtractionModuleItem(String name, ModuleTier tier) {
|
||||
super(name);
|
||||
this.maxExtraction = tier.forTier(1, 8, 64);
|
||||
this.speed = tier.forTier(20, 15, 10);
|
||||
this.filterSlots = tier.forTier(3, 6, 9);
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
"item.prettypipes.low_extraction_module": "Low Extraction Module",
|
||||
"item.prettypipes.medium_extraction_module": "Medium Extraction Module",
|
||||
"item.prettypipes.high_extraction_module": "High Extraction Module",
|
||||
"info.prettypipes.extraction_module": "Pulls items from adjacent inventories\nFilters and pull rates vary by tier",
|
||||
"block.prettypipes.pipe": "Pipe",
|
||||
"itemGroup.prettypipes": "Pretty Pipes",
|
||||
"container.prettypipes.pipe": "Pipe",
|
||||
"info.prettypipes.whitelist": "Allowed",
|
||||
"info.prettypipes.blacklist": "Disallowed"
|
||||
"info.prettypipes.blacklist": "Disallowed",
|
||||
"info.prettypipes.shift": "Hold Shift for info"
|
||||
}
|
Loading…
Reference in a new issue