mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-11 04:22:00 +01:00
Merge branch 'concealed/remove-sections' into mc1.18/0.5.1
Conflicts: src/main/java/com/simibubi/create/AllBlocks.java
This commit is contained in:
commit
3b4375f002
40 changed files with 550 additions and 875 deletions
|
@ -3,7 +3,6 @@ package com.simibubi.create;
|
|||
import static com.simibubi.create.AllInteractionBehaviours.interactionBehaviour;
|
||||
import static com.simibubi.create.AllMovementBehaviours.movementBehaviour;
|
||||
import static com.simibubi.create.Create.REGISTRATE;
|
||||
import static com.simibubi.create.content.AllSections.SCHEMATICS;
|
||||
import static com.simibubi.create.content.logistics.block.display.AllDisplayBehaviours.assignDataBehaviour;
|
||||
import static com.simibubi.create.foundation.data.BlockStateGen.axisBlock;
|
||||
import static com.simibubi.create.foundation.data.BlockStateGen.simpleCubeAll;
|
||||
|
@ -16,7 +15,6 @@ import static com.simibubi.create.foundation.data.TagGen.tagBlockAndItem;
|
|||
|
||||
import com.simibubi.create.AllTags.AllBlockTags;
|
||||
import com.simibubi.create.AllTags.AllItemTags;
|
||||
import com.simibubi.create.content.AllSections;
|
||||
import com.simibubi.create.content.contraptions.base.CasingBlock;
|
||||
import com.simibubi.create.content.contraptions.components.AssemblyOperatorBlockItem;
|
||||
import com.simibubi.create.content.contraptions.components.actors.BellMovementBehaviour;
|
||||
|
@ -240,7 +238,7 @@ import com.simibubi.create.foundation.data.BuilderTransformers;
|
|||
import com.simibubi.create.foundation.data.CreateRegistrate;
|
||||
import com.simibubi.create.foundation.data.ModelGen;
|
||||
import com.simibubi.create.foundation.data.SharedProperties;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.simibubi.create.foundation.item.ItemTooltipHandler;
|
||||
import com.simibubi.create.foundation.item.UncontainableBlockItem;
|
||||
import com.simibubi.create.foundation.utility.ColorHandlers;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
|
@ -293,10 +291,6 @@ public class AllBlocks {
|
|||
|
||||
// Schematics
|
||||
|
||||
static {
|
||||
REGISTRATE.startSection(SCHEMATICS);
|
||||
}
|
||||
|
||||
public static final BlockEntry<SchematicannonBlock> SCHEMATICANNON =
|
||||
REGISTRATE.block("schematicannon", SchematicannonBlock::new)
|
||||
.initialProperties(() -> Blocks.DISPENSER)
|
||||
|
@ -330,10 +324,6 @@ public class AllBlocks {
|
|||
|
||||
// Kinetics
|
||||
|
||||
static {
|
||||
REGISTRATE.startSection(AllSections.KINETICS);
|
||||
}
|
||||
|
||||
public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(p -> p.color(MaterialColor.METAL))
|
||||
|
@ -583,7 +573,7 @@ public class AllBlocks {
|
|||
.transform(axeOrPickaxe())
|
||||
.transform(BuilderTransformers.cuckooClock())
|
||||
.lang("Cuckoo Clock")
|
||||
.onRegisterAfter(Registry.ITEM_REGISTRY, c -> TooltipHelper.referTo(c, CUCKOO_CLOCK))
|
||||
.onRegisterAfter(Registry.ITEM_REGISTRY, c -> ItemTooltipHandler.referTo(c, CUCKOO_CLOCK))
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<MillstoneBlock> MILLSTONE = REGISTRATE.block("millstone", MillstoneBlock::new)
|
||||
|
@ -1394,7 +1384,7 @@ public class AllBlocks {
|
|||
.unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag))
|
||||
.save(p, Create.asResource("crafting/kinetics/" + c.getName() + "_from_other_seat"));
|
||||
})
|
||||
.onRegisterAfter(Registry.ITEM_REGISTRY, v -> TooltipHelper.referTo(v, "block.create.brown_seat"))
|
||||
.onRegisterAfter(Registry.ITEM_REGISTRY, v -> ItemTooltipHandler.referTo(v, "block.create.brown_seat"))
|
||||
.tag(AllBlockTags.SEATS.tag)
|
||||
.item()
|
||||
.tag(AllItemTags.SEATS.tag)
|
||||
|
@ -1529,10 +1519,6 @@ public class AllBlocks {
|
|||
|
||||
// Logistics
|
||||
|
||||
static {
|
||||
REGISTRATE.startSection(AllSections.LOGISTICS);
|
||||
}
|
||||
|
||||
public static final BlockEntry<ArmBlock> MECHANICAL_ARM = REGISTRATE.block("mechanical_arm", ArmBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.color(MaterialColor.TERRACOTTA_YELLOW))
|
||||
|
@ -1970,10 +1956,6 @@ public class AllBlocks {
|
|||
|
||||
// Curiosities
|
||||
|
||||
static {
|
||||
REGISTRATE.startSection(AllSections.CURIOSITIES);
|
||||
}
|
||||
|
||||
public static final BlockEntry<BacktankBlock> COPPER_BACKTANK =
|
||||
REGISTRATE.block("copper_backtank", BacktankBlock::new)
|
||||
.initialProperties(SharedProperties::copperMetal)
|
||||
|
@ -2025,7 +2007,7 @@ public class AllBlocks {
|
|||
.withExistingParent(colourName + "_toolbox", p.modLoc("block/toolbox/block"))
|
||||
.texture("0", p.modLoc("block/toolbox/" + colourName)));
|
||||
})
|
||||
.onRegisterAfter(Registry.ITEM_REGISTRY, v -> TooltipHelper.referTo(v, "block.create.toolbox"))
|
||||
.onRegisterAfter(Registry.ITEM_REGISTRY, v -> ItemTooltipHandler.referTo(v, "block.create.toolbox"))
|
||||
.tag(AllBlockTags.TOOLBOXES.tag)
|
||||
.item(UncontainableBlockItem::new)
|
||||
.model((c, p) -> p.withExistingParent(colourName + "_toolbox", p.modLoc("block/toolbox/item"))
|
||||
|
@ -2037,10 +2019,6 @@ public class AllBlocks {
|
|||
|
||||
// Materials
|
||||
|
||||
static {
|
||||
REGISTRATE.startSection(AllSections.PALETTES);
|
||||
}
|
||||
|
||||
public static final BlockEntry<Block> ZINC_ORE = REGISTRATE.block("zinc_ore", Block::new)
|
||||
.initialProperties(() -> Blocks.GOLD_ORE)
|
||||
.properties(p -> p.color(MaterialColor.METAL))
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov
|
|||
import com.simibubi.create.content.contraptions.components.structureMovement.interaction.DoorMovingInteraction;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.interaction.LeverMovingInteraction;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.interaction.TrapdoorMovingInteraction;
|
||||
import com.simibubi.create.foundation.utility.CreateRegistry;
|
||||
import com.simibubi.create.foundation.utility.AttachedRegistry;
|
||||
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -18,10 +18,9 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class AllInteractionBehaviours {
|
||||
private static final CreateRegistry<Block, MovingInteractionBehaviour> BLOCK_BEHAVIOURS = new CreateRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final AttachedRegistry<Block, MovingInteractionBehaviour> BLOCK_BEHAVIOURS = new AttachedRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final List<BehaviourProvider> GLOBAL_BEHAVIOURS = new ArrayList<>();
|
||||
|
||||
public static void registerBehaviour(ResourceLocation block, MovingInteractionBehaviour provider) {
|
||||
|
@ -32,11 +31,6 @@ public class AllInteractionBehaviours {
|
|||
BLOCK_BEHAVIOURS.register(block, provider);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void registerBehaviour(IRegistryDelegate<Block> block, MovingInteractionBehaviour provider) {
|
||||
registerBehaviour(block.name(), provider);
|
||||
}
|
||||
|
||||
public static void registerBehaviourProvider(BehaviourProvider provider) {
|
||||
GLOBAL_BEHAVIOURS.add(provider);
|
||||
}
|
||||
|
|
|
@ -5,11 +5,6 @@ import static com.simibubi.create.AllTags.AllItemTags.CREATE_INGOTS;
|
|||
import static com.simibubi.create.AllTags.AllItemTags.CRUSHED_ORES;
|
||||
import static com.simibubi.create.AllTags.AllItemTags.PLATES;
|
||||
import static com.simibubi.create.Create.REGISTRATE;
|
||||
import static com.simibubi.create.content.AllSections.CURIOSITIES;
|
||||
import static com.simibubi.create.content.AllSections.KINETICS;
|
||||
import static com.simibubi.create.content.AllSections.LOGISTICS;
|
||||
import static com.simibubi.create.content.AllSections.MATERIALS;
|
||||
import static com.simibubi.create.content.AllSections.SCHEMATICS;
|
||||
import static com.simibubi.create.foundation.data.recipe.CompatMetals.ALUMINUM;
|
||||
import static com.simibubi.create.foundation.data.recipe.CompatMetals.LEAD;
|
||||
import static com.simibubi.create.foundation.data.recipe.CompatMetals.NICKEL;
|
||||
|
@ -59,8 +54,8 @@ import com.simibubi.create.foundation.data.AssetLookup;
|
|||
import com.simibubi.create.foundation.data.CreateRegistrate;
|
||||
import com.simibubi.create.foundation.data.recipe.CompatMetals;
|
||||
import com.simibubi.create.foundation.item.HiddenIngredientItem;
|
||||
import com.simibubi.create.foundation.item.ItemTooltipHandler;
|
||||
import com.simibubi.create.foundation.item.TagDependentIngredientItem;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.tterrag.registrate.util.entry.ItemEntry;
|
||||
|
||||
import net.minecraft.tags.ItemTags;
|
||||
|
@ -77,11 +72,7 @@ public class AllItems {
|
|||
REGISTRATE.creativeModeTab(() -> Create.BASE_CREATIVE_TAB);
|
||||
}
|
||||
|
||||
// Schematics
|
||||
|
||||
static {
|
||||
REGISTRATE.startSection(MATERIALS);
|
||||
}
|
||||
// Materials
|
||||
|
||||
public static final ItemEntry<Item> WHEAT_FLOUR =
|
||||
taggedIngredient("wheat_flour", forgeItemTag("flour/wheat"), forgeItemTag("flour")),
|
||||
|
@ -202,10 +193,6 @@ public class AllItems {
|
|||
|
||||
// Kinetics
|
||||
|
||||
static {
|
||||
REGISTRATE.startSection(KINETICS);
|
||||
}
|
||||
|
||||
public static final ItemEntry<BeltConnectorItem> BELT_CONNECTOR =
|
||||
REGISTRATE.item("belt_connector", BeltConnectorItem::new)
|
||||
.lang("Mechanical Belt")
|
||||
|
@ -288,7 +275,7 @@ public class AllItems {
|
|||
|
||||
public static final ItemEntry<SandPaperItem> RED_SAND_PAPER = REGISTRATE.item("red_sand_paper", SandPaperItem::new)
|
||||
.tag(AllTags.AllItemTags.SANDPAPER.tag)
|
||||
.onRegister(s -> TooltipHelper.referTo(s, SAND_PAPER))
|
||||
.onRegister(s -> ItemTooltipHandler.referTo(s, SAND_PAPER))
|
||||
.register();
|
||||
|
||||
public static final ItemEntry<WrenchItem> WRENCH = REGISTRATE.item("wrench", WrenchItem::new)
|
||||
|
@ -311,10 +298,6 @@ public class AllItems {
|
|||
|
||||
// Curiosities
|
||||
|
||||
static {
|
||||
REGISTRATE.startSection(CURIOSITIES);
|
||||
}
|
||||
|
||||
public static final ItemEntry<LinkedControllerItem> LINKED_CONTROLLER =
|
||||
REGISTRATE.item("linked_controller", LinkedControllerItem::new)
|
||||
.properties(p -> p.stacksTo(1))
|
||||
|
@ -351,10 +334,6 @@ public class AllItems {
|
|||
|
||||
// Logistics
|
||||
|
||||
static {
|
||||
REGISTRATE.startSection(LOGISTICS);
|
||||
}
|
||||
|
||||
public static final ItemEntry<FilterItem> FILTER = REGISTRATE.item("filter", FilterItem::regular)
|
||||
.model(AssetLookup.existingItemModel())
|
||||
.register();
|
||||
|
@ -370,10 +349,6 @@ public class AllItems {
|
|||
|
||||
// Schematics
|
||||
|
||||
static {
|
||||
REGISTRATE.startSection(SCHEMATICS);
|
||||
}
|
||||
|
||||
public static final ItemEntry<Item> EMPTY_SCHEMATIC = REGISTRATE.item("empty_schematic", Item::new)
|
||||
.properties(p -> p.stacksTo(1))
|
||||
.register();
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.simibubi.create.content.contraptions.components.actors.CampfireMoveme
|
|||
import com.simibubi.create.content.contraptions.components.actors.dispenser.DispenserMovementBehaviour;
|
||||
import com.simibubi.create.content.contraptions.components.actors.dispenser.DropperMovementBehaviour;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
||||
import com.simibubi.create.foundation.utility.CreateRegistry;
|
||||
import com.simibubi.create.foundation.utility.AttachedRegistry;
|
||||
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -18,10 +18,9 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class AllMovementBehaviours {
|
||||
private static final CreateRegistry<Block, MovementBehaviour> BLOCK_BEHAVIOURS = new CreateRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final AttachedRegistry<Block, MovementBehaviour> BLOCK_BEHAVIOURS = new AttachedRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final List<BehaviourProvider> GLOBAL_BEHAVIOURS = new ArrayList<>();
|
||||
|
||||
public static void registerBehaviour(ResourceLocation block, MovementBehaviour behaviour) {
|
||||
|
@ -32,11 +31,6 @@ public class AllMovementBehaviours {
|
|||
BLOCK_BEHAVIOURS.register(block, behaviour);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void registerBehaviour(IRegistryDelegate<Block> block, MovementBehaviour behaviour) {
|
||||
registerBehaviour(block.name(), behaviour);
|
||||
}
|
||||
|
||||
public static void registerBehaviourProvider(BehaviourProvider provider) {
|
||||
GLOBAL_BEHAVIOURS.add(provider);
|
||||
}
|
||||
|
|
|
@ -7,18 +7,13 @@ import static com.simibubi.create.AllTags.NameSpace.TIC;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
import com.simibubi.create.foundation.data.TagGen;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.tterrag.registrate.builders.BlockBuilder;
|
||||
import com.tterrag.registrate.builders.ItemBuilder;
|
||||
import com.tterrag.registrate.util.nullness.NonNullFunction;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -52,27 +47,6 @@ public class AllTags {
|
|||
return forgeTag(ForgeRegistries.FLUIDS, path);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuilder<T, P>> axeOrPickaxe() {
|
||||
return TagGen.axeOrPickaxe();
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuilder<T, P>> axeOnly() {
|
||||
return TagGen.axeOnly();
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuilder<T, P>> pickaxeOnly() {
|
||||
return TagGen.pickaxeOnly();
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, ItemBuilder<BlockItem, BlockBuilder<T, P>>> tagBlockAndItem(
|
||||
String... path) {
|
||||
return TagGen.tagBlockAndItem(path);
|
||||
}
|
||||
|
||||
public enum NameSpace {
|
||||
MOD(Create.ID, false, true),
|
||||
FORGE("forge"),
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.mojang.logging.LogUtils;
|
|||
import com.simibubi.create.api.behaviour.BlockSpoutingBehaviour;
|
||||
import com.simibubi.create.compat.Mods;
|
||||
import com.simibubi.create.compat.curios.Curios;
|
||||
import com.simibubi.create.content.CreateItemGroup;
|
||||
import com.simibubi.create.content.contraptions.TorquePropagator;
|
||||
import com.simibubi.create.content.contraptions.fluids.tank.BoilerHeaters;
|
||||
import com.simibubi.create.content.curiosities.deco.SlidingDoorBlock;
|
||||
|
@ -20,7 +19,7 @@ import com.simibubi.create.content.logistics.block.display.AllDisplayBehaviours;
|
|||
import com.simibubi.create.content.logistics.block.mechanicalArm.AllArmInteractionPointTypes;
|
||||
import com.simibubi.create.content.logistics.trains.GlobalRailwayManager;
|
||||
import com.simibubi.create.content.palettes.AllPaletteBlocks;
|
||||
import com.simibubi.create.content.palettes.PalettesItemGroup;
|
||||
import com.simibubi.create.content.palettes.PalettesCreativeModeTab;
|
||||
import com.simibubi.create.content.schematics.ServerSchematicLoader;
|
||||
import com.simibubi.create.content.schematics.filtering.SchematicInstances;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
|
@ -37,8 +36,9 @@ import com.simibubi.create.foundation.data.recipe.MechanicalCraftingRecipeGen;
|
|||
import com.simibubi.create.foundation.data.recipe.ProcessingRecipeGen;
|
||||
import com.simibubi.create.foundation.data.recipe.SequencedAssemblyRecipeGen;
|
||||
import com.simibubi.create.foundation.data.recipe.StandardRecipeGen;
|
||||
import com.simibubi.create.foundation.item.BaseCreativeModeTab;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.utility.CreateRegistry;
|
||||
import com.simibubi.create.foundation.utility.AttachedRegistry;
|
||||
import com.simibubi.create.foundation.worldgen.AllFeatures;
|
||||
import com.simibubi.create.foundation.worldgen.AllOreFeatureConfigEntries;
|
||||
import com.simibubi.create.foundation.worldgen.AllPlacementModifiers;
|
||||
|
@ -81,8 +81,8 @@ public class Create {
|
|||
|
||||
public static final CreateRegistrate REGISTRATE = CreateRegistrate.create(ID);
|
||||
|
||||
public static final CreativeModeTab BASE_CREATIVE_TAB = new CreateItemGroup();
|
||||
public static final CreativeModeTab PALETTES_CREATIVE_TAB = new PalettesItemGroup();
|
||||
public static final CreativeModeTab BASE_CREATIVE_TAB = new BaseCreativeModeTab();
|
||||
public static final CreativeModeTab PALETTES_CREATIVE_TAB = new PalettesCreativeModeTab();
|
||||
|
||||
public static final ServerSchematicLoader SCHEMATIC_RECEIVER = new ServerSchematicLoader();
|
||||
public static final RedstoneLinkNetworkHandler REDSTONE_LINK_NETWORK_HANDLER = new RedstoneLinkNetworkHandler();
|
||||
|
@ -146,7 +146,7 @@ public class Create {
|
|||
}
|
||||
|
||||
public static void init(final FMLCommonSetupEvent event) {
|
||||
CreateRegistry.unwrapAll();
|
||||
AttachedRegistry.unwrapAll();
|
||||
AllPackets.registerPackets();
|
||||
SchematicInstances.register();
|
||||
BuiltinPotatoProjectileTypes.register();
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
package com.simibubi.create.content;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.item.ItemDescription.Palette;
|
||||
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public enum AllSections {
|
||||
|
||||
/** Create's kinetic mechanisms */
|
||||
KINETICS(Palette.Red),
|
||||
|
||||
/** Item transport and other Utility */
|
||||
LOGISTICS(Palette.Yellow),
|
||||
|
||||
/** Tools for structure movement and replication */
|
||||
SCHEMATICS(Palette.Blue),
|
||||
|
||||
/** Decorative blocks */
|
||||
PALETTES(Palette.Green),
|
||||
|
||||
/** Helpful gadgets and other shenanigans */
|
||||
CURIOSITIES(Palette.Purple),
|
||||
|
||||
/** Base materials, ingredients and tools */
|
||||
MATERIALS(Palette.Green),
|
||||
|
||||
/** Fallback section */
|
||||
UNASSIGNED(Palette.Gray)
|
||||
|
||||
;
|
||||
|
||||
private final Palette tooltipPalette;
|
||||
|
||||
private AllSections(Palette tooltipPalette) {
|
||||
this.tooltipPalette = tooltipPalette;
|
||||
}
|
||||
|
||||
public Palette getTooltipPalette() {
|
||||
return tooltipPalette;
|
||||
}
|
||||
|
||||
public static AllSections of(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof BlockItem)
|
||||
return ofBlock(((BlockItem) item).getBlock());
|
||||
return ofItem(item);
|
||||
}
|
||||
|
||||
static AllSections ofItem(Item item) {
|
||||
return Create.REGISTRATE
|
||||
.getSection(item);
|
||||
}
|
||||
|
||||
static AllSections ofBlock(Block block) {
|
||||
return Create.REGISTRATE
|
||||
.getSection(block);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.simibubi.create.content;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.item.CreateItemGroupBase;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class CreateItemGroup extends CreateItemGroupBase {
|
||||
|
||||
public CreateItemGroup() {
|
||||
super("base");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EnumSet<AllSections> getSections() {
|
||||
return EnumSet.complementOf(EnumSet.of(AllSections.PALETTES));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return AllBlocks.COGWHEEL.asStack();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.base;
|
|||
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.item.ItemDescription;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.LangBuilder;
|
||||
|
||||
|
@ -73,7 +73,7 @@ public interface IRotate extends IWrenchable {
|
|||
|
||||
public static LangBuilder getFormattedSpeedText(float speed, boolean overstressed) {
|
||||
SpeedLevel speedLevel = of(speed);
|
||||
LangBuilder builder = Lang.text(ItemDescription.makeProgressBar(3, speedLevel.ordinal()));
|
||||
LangBuilder builder = Lang.text(TooltipHelper.makeProgressBar(3, speedLevel.ordinal()));
|
||||
|
||||
builder.translate("tooltip.speedRequirement." + Lang.asId(speedLevel.name()))
|
||||
.space()
|
||||
|
@ -133,7 +133,7 @@ public interface IRotate extends IWrenchable {
|
|||
|
||||
public static LangBuilder getFormattedStressText(double stressPercent) {
|
||||
StressImpact stressLevel = of(stressPercent);
|
||||
return Lang.text(ItemDescription.makeProgressBar(3, Math.min(stressLevel.ordinal() + 1, 3)))
|
||||
return Lang.text(TooltipHelper.makeProgressBar(3, Math.min(stressLevel.ordinal() + 1, 3)))
|
||||
.translate("tooltip.stressImpact." + Lang.asId(stressLevel.name()))
|
||||
.text(String.format(" (%s%%) ", (int) (stressPercent * 100)))
|
||||
.style(stressLevel.getRelativeColor());
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.base;
|
|||
|
||||
import com.simibubi.create.foundation.advancement.AdvancementBehaviour;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.item.ItemDescription.Palette;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -17,8 +16,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
|
||||
public abstract class KineticBlock extends Block implements IRotate {
|
||||
|
||||
protected static final Palette color = Palette.Red;
|
||||
|
||||
public KineticBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@ import java.util.UUID;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.foundation.utility.ContraptionData;
|
||||
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
|
@ -38,6 +36,7 @@ import com.simibubi.create.foundation.collision.Matrix3d;
|
|||
import com.simibubi.create.foundation.mixin.accessor.ServerLevelAccessor;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.ContraptionData;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
|
|
@ -4,10 +4,6 @@ import java.util.List;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.foundation.utility.ContraptionData;
|
||||
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import com.simibubi.create.AllItems;
|
||||
|
@ -21,6 +17,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Ori
|
|||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.config.ContraptionMovementSetting;
|
||||
import com.simibubi.create.foundation.utility.ContraptionData;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
|
||||
|
@ -32,6 +29,7 @@ import net.minecraft.core.NonNullList;
|
|||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.core.dispenser.DispenseItemBehavior;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.simibubi.create.AllBlocks;
|
|||
import com.simibubi.create.AllTags.AllBlockTags;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
||||
import com.simibubi.create.foundation.utility.CreateRegistry;
|
||||
import com.simibubi.create.foundation.utility.AttachedRegistry;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -17,10 +17,9 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class BoilerHeaters {
|
||||
private static final CreateRegistry<Block, Heater> BLOCK_HEATERS = new CreateRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final AttachedRegistry<Block, Heater> BLOCK_HEATERS = new AttachedRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final List<HeaterProvider> GLOBAL_HEATERS = new ArrayList<>();
|
||||
|
||||
public static void registerHeater(ResourceLocation block, Heater heater) {
|
||||
|
@ -31,11 +30,6 @@ public class BoilerHeaters {
|
|||
BLOCK_HEATERS.register(block, heater);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void registerHeater(IRegistryDelegate<Block> block, Heater heater) {
|
||||
registerHeater(block.name(), heater);
|
||||
}
|
||||
|
||||
public static void registerHeaterProvider(HeaterProvider provider) {
|
||||
GLOBAL_HEATERS.add(provider);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.world.level.ItemLike;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
|
||||
|
@ -220,29 +221,31 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
|
|||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void addToTooltip(List<Component> toolTip, ItemStack stack) {
|
||||
public static void addToTooltip(ItemTooltipEvent event) {
|
||||
ItemStack stack = event.getItemStack();
|
||||
if (!stack.hasTag() || !stack.getTag()
|
||||
.contains("SequencedAssembly"))
|
||||
return;
|
||||
CompoundTag compound = stack.getTag()
|
||||
.getCompound("SequencedAssembly");
|
||||
ResourceLocation resourceLocation = new ResourceLocation(compound.getString("id"));
|
||||
Optional<? extends Recipe<?>> recipe = Minecraft.getInstance().level.getRecipeManager()
|
||||
Optional<? extends Recipe<?>> optionalRecipe = Minecraft.getInstance().level.getRecipeManager()
|
||||
.byKey(resourceLocation);
|
||||
if (!recipe.isPresent())
|
||||
if (!optionalRecipe.isPresent())
|
||||
return;
|
||||
Recipe<?> iRecipe = recipe.get();
|
||||
if (!(iRecipe instanceof SequencedAssemblyRecipe))
|
||||
Recipe<?> recipe = optionalRecipe.get();
|
||||
if (!(recipe instanceof SequencedAssemblyRecipe))
|
||||
return;
|
||||
|
||||
SequencedAssemblyRecipe sequencedAssemblyRecipe = (SequencedAssemblyRecipe) iRecipe;
|
||||
SequencedAssemblyRecipe sequencedAssemblyRecipe = (SequencedAssemblyRecipe) recipe;
|
||||
int length = sequencedAssemblyRecipe.sequence.size();
|
||||
int step = sequencedAssemblyRecipe.getStep(stack);
|
||||
int total = length * sequencedAssemblyRecipe.loops;
|
||||
toolTip.add(Components.immutableEmpty());
|
||||
toolTip.add(Lang.translateDirect("recipe.sequenced_assembly")
|
||||
List<Component> tooltip = event.getToolTip();
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
tooltip.add(Lang.translateDirect("recipe.sequenced_assembly")
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
toolTip.add(Lang.translateDirect("recipe.assembly.progress", step, total)
|
||||
tooltip.add(Lang.translateDirect("recipe.assembly.progress", step, total)
|
||||
.withStyle(ChatFormatting.DARK_GRAY));
|
||||
|
||||
int remaining = total - step;
|
||||
|
@ -253,10 +256,10 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
|
|||
Component textComponent = sequencedRecipe.getAsAssemblyRecipe()
|
||||
.getDescriptionForAssembly();
|
||||
if (i == 0)
|
||||
toolTip.add(Lang.translateDirect("recipe.assembly.next", textComponent)
|
||||
tooltip.add(Lang.translateDirect("recipe.assembly.next", textComponent)
|
||||
.withStyle(ChatFormatting.AQUA));
|
||||
else
|
||||
toolTip.add(Components.literal("-> ").append(textComponent)
|
||||
tooltip.add(Components.literal("-> ").append(textComponent)
|
||||
.withStyle(ChatFormatting.DARK_AQUA));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
|||
|
||||
import com.simibubi.create.content.contraptions.base.IRotate.StressImpact;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.item.ItemDescription;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.utility.Color;
|
||||
|
@ -86,7 +86,7 @@ public class StressGaugeTileEntity extends GaugeTileEntity {
|
|||
.forGoggles(tooltip);
|
||||
|
||||
if (getTheoreticalSpeed() == 0)
|
||||
Lang.text(ItemDescription.makeProgressBar(3, 0))
|
||||
Lang.text(TooltipHelper.makeProgressBar(3, 0))
|
||||
.translate("gui.stressometer.no_rotation")
|
||||
.style(ChatFormatting.DARK_GRAY)
|
||||
.forGoggles(tooltip);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simibubi.create.content.curiosities.weapons;
|
||||
|
||||
import static com.simibubi.create.content.curiosities.weapons.PotatoProjectileRenderMode.entityRandom;
|
||||
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.simibubi.create.AllSoundEvents;
|
|||
import com.simibubi.create.AllTags.AllBlockTags;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.foundation.item.CustomArmPoseItem;
|
||||
import com.simibubi.create.foundation.item.ItemDescription;
|
||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
|
@ -63,8 +62,7 @@ public abstract class ZapperItem extends Item implements CustomArmPoseItem {
|
|||
.getCompound("BlockUsed"))
|
||||
.getBlock()
|
||||
.getName();
|
||||
ItemDescription.add(tooltip,
|
||||
Lang.translateDirect("terrainzapper.usingBlock",
|
||||
tooltip.add(Lang.translateDirect("terrainzapper.usingBlock",
|
||||
usedBlock.withStyle(ChatFormatting.GRAY))
|
||||
.withStyle(ChatFormatting.DARK_GRAY));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import com.simibubi.create.content.logistics.block.display.source.ScoreboardDisp
|
|||
import com.simibubi.create.content.logistics.block.display.target.DisplayTarget;
|
||||
import com.simibubi.create.content.logistics.block.display.target.LecternDisplayTarget;
|
||||
import com.simibubi.create.content.logistics.block.display.target.SignDisplayTarget;
|
||||
import com.simibubi.create.foundation.utility.CreateRegistry;
|
||||
import com.simibubi.create.foundation.utility.AttachedRegistry;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
||||
|
||||
|
@ -30,16 +30,15 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class AllDisplayBehaviours {
|
||||
public static final Map<ResourceLocation, DisplayBehaviour> GATHERER_BEHAVIOURS = new HashMap<>();
|
||||
|
||||
private static final CreateRegistry<Block, List<DisplaySource>> SOURCES_BY_BLOCK = new CreateRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final CreateRegistry<BlockEntityType<?>, List<DisplaySource>> SOURCES_BY_TILE = new CreateRegistry<>(ForgeRegistries.BLOCK_ENTITIES);
|
||||
private static final AttachedRegistry<Block, List<DisplaySource>> SOURCES_BY_BLOCK = new AttachedRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final AttachedRegistry<BlockEntityType<?>, List<DisplaySource>> SOURCES_BY_TILE = new AttachedRegistry<>(ForgeRegistries.BLOCK_ENTITIES);
|
||||
|
||||
private static final CreateRegistry<Block, DisplayTarget> TARGETS_BY_BLOCK = new CreateRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final CreateRegistry<BlockEntityType<?>, DisplayTarget> TARGETS_BY_TILE = new CreateRegistry<>(ForgeRegistries.BLOCK_ENTITIES);
|
||||
private static final AttachedRegistry<Block, DisplayTarget> TARGETS_BY_BLOCK = new AttachedRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final AttachedRegistry<BlockEntityType<?>, DisplayTarget> TARGETS_BY_TILE = new AttachedRegistry<>(ForgeRegistries.BLOCK_ENTITIES);
|
||||
|
||||
public static DisplayBehaviour register(ResourceLocation id, DisplayBehaviour behaviour) {
|
||||
behaviour.id = id;
|
||||
|
@ -103,16 +102,6 @@ public class AllDisplayBehaviours {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void assignBlock(DisplayBehaviour behaviour, IRegistryDelegate<Block> block) {
|
||||
assignBlock(behaviour, block.name());
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void assignTile(DisplayBehaviour behaviour, IRegistryDelegate<BlockEntityType<?>> teType) {
|
||||
assignTile(behaviour, teType.name());
|
||||
}
|
||||
|
||||
public static <B extends Block> NonNullConsumer<? super B> assignDataBehaviour(DisplayBehaviour behaviour,
|
||||
String... suffix) {
|
||||
return b -> {
|
||||
|
|
|
@ -104,7 +104,7 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
|
|||
button.setToolTip(button.getToolTip()
|
||||
.get(0));
|
||||
button.getToolTip()
|
||||
.add(TooltipHelper.holdShift(Palette.Yellow, hasShiftDown()));
|
||||
.add(TooltipHelper.holdShift(Palette.YELLOW, hasShiftDown()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.simibubi.create.AllItems;
|
|||
import com.simibubi.create.AllKeys;
|
||||
import com.simibubi.create.content.contraptions.processing.EmptyingByBasin;
|
||||
import com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer.WhitelistMode;
|
||||
import com.simibubi.create.foundation.item.ItemDescription;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
|
@ -75,8 +74,8 @@ public class FilterItem extends Item implements MenuProvider {
|
|||
List<Component> makeSummary = makeSummary(stack);
|
||||
if (makeSummary.isEmpty())
|
||||
return;
|
||||
ItemDescription.add(tooltip, Components.literal(" "));
|
||||
ItemDescription.add(tooltip, makeSummary);
|
||||
tooltip.add(Components.literal(" "));
|
||||
tooltip.addAll(makeSummary);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import static com.simibubi.create.foundation.data.WindowGen.woodenWindowPane;
|
|||
|
||||
import com.simibubi.create.AllSpriteShifts;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.AllSections;
|
||||
import com.simibubi.create.foundation.block.connected.HorizontalCTBehaviour;
|
||||
import com.simibubi.create.foundation.block.connected.SimpleCTBehaviour;
|
||||
import com.simibubi.create.foundation.data.BlockStateGen;
|
||||
|
@ -31,9 +30,7 @@ import net.minecraftforge.common.Tags;
|
|||
public class AllPaletteBlocks {
|
||||
|
||||
static {
|
||||
REGISTRATE
|
||||
.creativeModeTab(() -> Create.PALETTES_CREATIVE_TAB)
|
||||
.startSection(AllSections.PALETTES);
|
||||
REGISTRATE.creativeModeTab(() -> Create.PALETTES_CREATIVE_TAB);
|
||||
}
|
||||
|
||||
// Windows and Glass
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.simibubi.create.content.palettes;
|
||||
|
||||
import com.simibubi.create.foundation.item.CreateCreativeModeTab;
|
||||
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class PalettesCreativeModeTab extends CreateCreativeModeTab {
|
||||
public PalettesCreativeModeTab() {
|
||||
super("palettes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItems(NonNullList<ItemStack> items, boolean specialItems) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return AllPaletteBlocks.ORNATE_IRON_WINDOW.asStack();
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.simibubi.create.content.palettes;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.simibubi.create.content.AllSections;
|
||||
import com.simibubi.create.foundation.item.CreateItemGroupBase;
|
||||
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class PalettesItemGroup extends CreateItemGroupBase {
|
||||
|
||||
public PalettesItemGroup() {
|
||||
super("palettes");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EnumSet<AllSections> getSections() {
|
||||
return EnumSet.of(AllSections.PALETTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItems(NonNullList<ItemStack> items, boolean specialItems) {}
|
||||
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return new ItemStack(AllPaletteBlocks.ORNATE_IRON_WINDOW.get());
|
||||
}
|
||||
|
||||
}
|
|
@ -245,7 +245,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
|
|||
button.setToolTip(button.getToolTip()
|
||||
.get(0));
|
||||
button.getToolTip()
|
||||
.add(TooltipHelper.holdShift(Palette.Blue, hasShiftDown()));
|
||||
.add(TooltipHelper.holdShift(Palette.BLUE, hasShiftDown()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package com.simibubi.create.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllFluids;
|
||||
|
@ -10,9 +7,7 @@ import com.simibubi.create.AllItems;
|
|||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.KineticDebugger;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.components.fan.AirCurrent;
|
||||
import com.simibubi.create.content.contraptions.components.steam.SteamEngineBlock;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisRangeDisplay;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.interaction.controls.ControlsHandler;
|
||||
|
@ -49,8 +44,7 @@ import com.simibubi.create.content.logistics.trains.track.TrackPlacement;
|
|||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.config.ui.BaseConfigScreen;
|
||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||
import com.simibubi.create.foundation.item.ItemDescription;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.simibubi.create.foundation.item.ItemTooltipHandler;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.networking.LeftClickPacket;
|
||||
import com.simibubi.create.foundation.ponder.PonderTooltipHandler;
|
||||
|
@ -63,7 +57,6 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal
|
|||
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueRenderer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.CameraAngleAnimationService;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
||||
import com.simibubi.create.foundation.utility.placement.PlacementHelpers;
|
||||
import com.simibubi.create.foundation.utility.worldWrappers.WrappedClientWorld;
|
||||
|
@ -73,8 +66,6 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
@ -105,9 +96,6 @@ import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
|
|||
@EventBusSubscriber(Dist.CLIENT)
|
||||
public class ClientEvents {
|
||||
|
||||
private static final String ITEM_PREFIX = "item." + Create.ID;
|
||||
private static final String BLOCK_PREFIX = "block." + Create.ID;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onTick(ClientTickEvent event) {
|
||||
if (!isGameActive())
|
||||
|
@ -251,35 +239,9 @@ public class ClientEvents {
|
|||
if (event.getPlayer() == null)
|
||||
return;
|
||||
|
||||
ItemStack stack = event.getItemStack();
|
||||
String translationKey = stack.getItem()
|
||||
.getDescriptionId(stack);
|
||||
|
||||
if (translationKey.startsWith(ITEM_PREFIX) || translationKey.startsWith(BLOCK_PREFIX))
|
||||
if (TooltipHelper.hasTooltip(stack, event.getPlayer())) {
|
||||
List<Component> itemTooltip = event.getToolTip();
|
||||
List<Component> toolTip = new ArrayList<>();
|
||||
toolTip.add(itemTooltip.remove(0));
|
||||
TooltipHelper.getTooltip(stack)
|
||||
.addInformation(toolTip);
|
||||
itemTooltip.addAll(0, toolTip);
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof BlockItem) {
|
||||
BlockItem item = (BlockItem) stack.getItem();
|
||||
if (item.getBlock() instanceof IRotate || item.getBlock() instanceof SteamEngineBlock) {
|
||||
List<Component> kineticStats = ItemDescription.getKineticStats(item.getBlock());
|
||||
if (!kineticStats.isEmpty()) {
|
||||
event.getToolTip()
|
||||
.add(Components.immutableEmpty());
|
||||
event.getToolTip()
|
||||
.addAll(kineticStats);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PonderTooltipHandler.addToTooltip(event.getToolTip(), stack);
|
||||
SequencedAssemblyRecipe.addToTooltip(event.getToolTip(), stack);
|
||||
ItemTooltipHandler.addToTooltip(event);
|
||||
PonderTooltipHandler.addToTooltip(event);
|
||||
SequencedAssemblyRecipe.addToTooltip(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -74,6 +74,16 @@ public class BlockStressValues {
|
|||
return BlockStressDefaults.DEFAULT_CAPACITIES.containsKey(blockId);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Couple<Integer> getGeneratedRPM(Block block) {
|
||||
ResourceLocation blockId = RegisteredObjects.getKeyOrThrow(block);
|
||||
IStressValueProvider provider = getProvider(blockId.getNamespace());
|
||||
if (provider != null) {
|
||||
return provider.getGeneratedRPM(block);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface IStressValueProvider {
|
||||
/**
|
||||
* Gets the stress impact of a block.
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.function.Supplier;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.foundation.utility.CreateRegistry;
|
||||
import com.simibubi.create.foundation.utility.AttachedRegistry;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -17,7 +17,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
|||
public enum ContraptionMovementSetting {
|
||||
MOVABLE, NO_PICKUP, UNMOVABLE;
|
||||
|
||||
private static final CreateRegistry<Block, Supplier<ContraptionMovementSetting>> SETTING_SUPPLIERS = new CreateRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final AttachedRegistry<Block, Supplier<ContraptionMovementSetting>> SETTING_SUPPLIERS = new AttachedRegistry<>(ForgeRegistries.BLOCKS);
|
||||
|
||||
public static void register(ResourceLocation block, Supplier<ContraptionMovementSetting> settingSupplier) {
|
||||
SETTING_SUPPLIERS.register(block, settingSupplier);
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.util.function.Supplier;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.AllTags.AllBlockTags;
|
||||
import com.simibubi.create.AllTags.AllItemTags;
|
||||
import com.simibubi.create.Create;
|
||||
|
@ -117,7 +116,7 @@ public class BuilderTransformers {
|
|||
.addLayer(() -> RenderType::translucent)
|
||||
.color(() -> CopycatBlock::wrappedColor)
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.transform(AllTags.axeOrPickaxe());
|
||||
.transform(TagGen.axeOrPickaxe());
|
||||
}
|
||||
|
||||
public static <B extends TrapDoorBlock, P> NonNullUnaryOperator<BlockBuilder<B, P>> trapdoor(boolean orientable) {
|
||||
|
|
|
@ -2,18 +2,12 @@ package com.simibubi.create.foundation.data;
|
|||
|
||||
import static com.simibubi.create.foundation.data.TagGen.pickaxeOnly;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.AllSections;
|
||||
import com.simibubi.create.content.contraptions.fluids.VirtualFluid;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity;
|
||||
import com.simibubi.create.foundation.block.connected.CTModel;
|
||||
|
@ -22,17 +16,13 @@ import com.simibubi.create.foundation.utility.RegisteredObjects;
|
|||
import com.tterrag.registrate.AbstractRegistrate;
|
||||
import com.tterrag.registrate.builders.BlockBuilder;
|
||||
import com.tterrag.registrate.builders.BlockEntityBuilder.BlockEntityFactory;
|
||||
import com.tterrag.registrate.builders.Builder;
|
||||
import com.tterrag.registrate.builders.FluidBuilder;
|
||||
import com.tterrag.registrate.util.entry.RegistryEntry;
|
||||
import com.tterrag.registrate.util.nullness.NonNullBiFunction;
|
||||
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
||||
import com.tterrag.registrate.util.nullness.NonNullFunction;
|
||||
import com.tterrag.registrate.util.nullness.NonNullSupplier;
|
||||
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -49,9 +39,6 @@ import net.minecraftforge.eventbus.api.IEventBus;
|
|||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
||||
protected CreateRegistrate(String modid) {
|
||||
|
@ -62,66 +49,11 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
|||
return new CreateRegistrate(modid);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static NonNullSupplier<CreateRegistrate> lazy(String modid) {
|
||||
return NonNullSupplier
|
||||
.lazy(() -> new CreateRegistrate(modid).registerEventListeners(FMLJavaModLoadingContext.get()
|
||||
.getModEventBus()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateRegistrate registerEventListeners(IEventBus bus) {
|
||||
return super.registerEventListeners(bus);
|
||||
}
|
||||
|
||||
/* Section Tracking */
|
||||
|
||||
protected static final Map<RegistryEntry<?>, AllSections> SECTION_LOOKUP = new IdentityHashMap<>();
|
||||
protected AllSections currentSection;
|
||||
|
||||
public CreateRegistrate startSection(AllSections section) {
|
||||
this.currentSection = section;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AllSections currentSection() {
|
||||
return currentSection;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <R extends IForgeRegistryEntry<R>, T extends R> RegistryEntry<T> accept(String name,
|
||||
ResourceKey<? extends Registry<R>> type, Builder<R, T, ?, ?> builder, NonNullSupplier<? extends T> creator,
|
||||
NonNullFunction<RegistryObject<T>, ? extends RegistryEntry<T>> entryFactory) {
|
||||
RegistryEntry<T> ret = super.accept(name, type, builder, creator, entryFactory);
|
||||
SECTION_LOOKUP.put(ret, currentSection());
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void addToSection(RegistryEntry<?> entry, AllSections section) {
|
||||
SECTION_LOOKUP.put(entry, section);
|
||||
}
|
||||
|
||||
public AllSections getSection(RegistryEntry<?> entry) {
|
||||
return SECTION_LOOKUP.getOrDefault(entry, AllSections.UNASSIGNED);
|
||||
}
|
||||
|
||||
public AllSections getSection(IForgeRegistryEntry<?> entry) {
|
||||
for (Entry<RegistryEntry<?>, AllSections> mapEntry : SECTION_LOOKUP.entrySet()) {
|
||||
if (mapEntry.getKey().get() == entry) {
|
||||
return mapEntry.getValue();
|
||||
}
|
||||
}
|
||||
return AllSections.UNASSIGNED;
|
||||
}
|
||||
|
||||
public <R extends IForgeRegistryEntry<R>> Collection<RegistryEntry<R>> getAll(AllSections section,
|
||||
ResourceKey<? extends Registry<R>> registryType) {
|
||||
return this.getAll(registryType)
|
||||
.stream()
|
||||
.filter(e -> getSection(e) == section)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public <T extends BlockEntity> CreateTileEntityBuilder<T, CreateRegistrate> tileEntity(String name,
|
||||
BlockEntityFactory<T> factory) {
|
||||
return this.tileEntity(this.self(), name, factory);
|
||||
|
|
|
@ -24,10 +24,8 @@ import com.simibubi.create.AllRecipeTypes;
|
|||
import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.AllTags.AllItemTags;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.AllSections;
|
||||
import com.simibubi.create.content.palettes.AllPaletteBlocks;
|
||||
import com.simibubi.create.content.palettes.AllPaletteStoneTypes;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
import com.tterrag.registrate.util.entry.BlockEntry;
|
||||
import com.tterrag.registrate.util.entry.ItemEntry;
|
||||
|
@ -68,7 +66,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
|||
* (Ctrl-o) in Eclipse
|
||||
*/
|
||||
|
||||
private Marker MATERIALS = enterSection(AllSections.MATERIALS);
|
||||
private Marker MATERIALS = enterFolder("materials");
|
||||
|
||||
GeneratedRecipe
|
||||
|
||||
|
@ -136,7 +134,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
|||
|
||||
;
|
||||
|
||||
private Marker CURIOSITIES = enterSection(AllSections.CURIOSITIES);
|
||||
private Marker CURIOSITIES = enterFolder("curiosities");
|
||||
|
||||
GeneratedRecipe
|
||||
|
||||
|
@ -175,7 +173,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
|||
|
||||
;
|
||||
|
||||
private Marker KINETICS = enterSection(AllSections.KINETICS);
|
||||
private Marker KINETICS = enterFolder("kinetics");
|
||||
|
||||
GeneratedRecipe ANDESITE_LADDER = create(AllBlocks.ANDESITE_LADDER).returns(4)
|
||||
.unlockedBy(I::andesite)
|
||||
|
@ -829,7 +827,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
|||
|
||||
;
|
||||
|
||||
private Marker LOGISTICS = enterSection(AllSections.LOGISTICS);
|
||||
private Marker LOGISTICS = enterFolder("logistics");
|
||||
|
||||
GeneratedRecipe
|
||||
|
||||
|
@ -935,7 +933,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
|||
|
||||
;
|
||||
|
||||
private Marker SCHEMATICS = enterSection(AllSections.SCHEMATICS);
|
||||
private Marker SCHEMATICS = enterFolder("schematics");
|
||||
|
||||
GeneratedRecipe
|
||||
|
||||
|
@ -965,7 +963,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
|||
|
||||
;
|
||||
|
||||
private Marker PALETTES = enterSection(AllSections.PALETTES);
|
||||
private Marker PALETTES = enterFolder("palettes");
|
||||
|
||||
GeneratedRecipe
|
||||
|
||||
|
@ -1086,11 +1084,6 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
|||
|
||||
String currentFolder = "";
|
||||
|
||||
Marker enterSection(AllSections section) {
|
||||
currentFolder = Lang.asId(section.name());
|
||||
return new Marker();
|
||||
}
|
||||
|
||||
Marker enterFolder(String folder) {
|
||||
currentFolder = folder;
|
||||
return new Marker();
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.simibubi.create.foundation.item;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class BaseCreativeModeTab extends CreateCreativeModeTab {
|
||||
public BaseCreativeModeTab() {
|
||||
super("base");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return AllBlocks.COGWHEEL.asStack();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.simibubi.create.foundation.item;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public abstract class CreateCreativeModeTab extends CreativeModeTab {
|
||||
public CreateCreativeModeTab(String id) {
|
||||
super(Create.ID + "." + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemList(NonNullList<ItemStack> items) {
|
||||
addItems(items, true);
|
||||
addBlocks(items);
|
||||
addItems(items, false);
|
||||
}
|
||||
|
||||
public void addBlocks(NonNullList<ItemStack> items) {
|
||||
for (Item item : ForgeRegistries.ITEMS) {
|
||||
if (item instanceof BlockItem) {
|
||||
item.fillItemCategory(this, items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addItems(NonNullList<ItemStack> items, boolean specialItems) {
|
||||
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
||||
|
||||
for (Item item : ForgeRegistries.ITEMS) {
|
||||
if (!(item instanceof BlockItem)) {
|
||||
ItemStack stack = new ItemStack(item);
|
||||
BakedModel model = itemRenderer.getModel(stack, null, null, 0);
|
||||
if (model.isGui3d() == specialItems) {
|
||||
item.fillItemCategory(this, items);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package com.simibubi.create.foundation.item;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.AllSections;
|
||||
import com.tterrag.registrate.util.entry.RegistryEntry;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public abstract class CreateItemGroupBase extends CreativeModeTab {
|
||||
|
||||
public CreateItemGroupBase(String id) {
|
||||
super(Create.ID + "." + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void fillItemList(NonNullList<ItemStack> items) {
|
||||
addItems(items, true);
|
||||
addBlocks(items);
|
||||
addItems(items, false);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addBlocks(NonNullList<ItemStack> items) {
|
||||
for (RegistryEntry<? extends Block> entry : getBlocks()) {
|
||||
Block def = entry.get();
|
||||
Item item = def.asItem();
|
||||
if (item != Items.AIR)
|
||||
def.fillItemCategory(this, items);
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addItems(NonNullList<ItemStack> items, boolean specialItems) {
|
||||
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
||||
|
||||
for (RegistryEntry<? extends Item> entry : getItems()) {
|
||||
Item item = entry.get();
|
||||
if (item instanceof BlockItem)
|
||||
continue;
|
||||
ItemStack stack = new ItemStack(item);
|
||||
BakedModel model = itemRenderer.getModel(stack, null, null, 0);
|
||||
if (model.isGui3d() != specialItems)
|
||||
continue;
|
||||
item.fillItemCategory(this, items);
|
||||
}
|
||||
}
|
||||
|
||||
protected Collection<RegistryEntry<Block>> getBlocks() {
|
||||
return getSections().stream()
|
||||
.flatMap(s -> Create.REGISTRATE
|
||||
.getAll(s, Registry.BLOCK_REGISTRY)
|
||||
.stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
protected Collection<RegistryEntry<Item>> getItems() {
|
||||
return getSections().stream()
|
||||
.flatMap(s -> Create.REGISTRATE
|
||||
.getAll(s, Registry.ITEM_REGISTRY)
|
||||
.stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
protected EnumSet<AllSections> getSections() {
|
||||
return EnumSet.allOf(AllSections.class);
|
||||
}
|
||||
}
|
|
@ -1,192 +1,143 @@
|
|||
package com.simibubi.create.foundation.item;
|
||||
|
||||
import static com.simibubi.create.foundation.item.TooltipHelper.cutStringTextComponent;
|
||||
import static com.simibubi.create.foundation.item.TooltipHelper.cutTextComponent;
|
||||
import static net.minecraft.ChatFormatting.AQUA;
|
||||
import static net.minecraft.ChatFormatting.BLUE;
|
||||
import static net.minecraft.ChatFormatting.DARK_GRAY;
|
||||
import static net.minecraft.ChatFormatting.DARK_GREEN;
|
||||
import static net.minecraft.ChatFormatting.DARK_PURPLE;
|
||||
import static net.minecraft.ChatFormatting.DARK_RED;
|
||||
import static net.minecraft.ChatFormatting.GOLD;
|
||||
import static net.minecraft.ChatFormatting.GRAY;
|
||||
import static net.minecraft.ChatFormatting.GREEN;
|
||||
import static net.minecraft.ChatFormatting.LIGHT_PURPLE;
|
||||
import static net.minecraft.ChatFormatting.RED;
|
||||
import static net.minecraft.ChatFormatting.STRIKETHROUGH;
|
||||
import static net.minecraft.ChatFormatting.WHITE;
|
||||
import static net.minecraft.ChatFormatting.YELLOW;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate.StressImpact;
|
||||
import com.simibubi.create.content.contraptions.goggles.GogglesItem;
|
||||
import com.simibubi.create.foundation.block.BlockStressValues;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.config.CKinetics;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.LangBuilder;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class ItemDescription {
|
||||
public record ItemDescription(ImmutableList<Component> lines, ImmutableList<Component> linesOnShift, ImmutableList<Component> linesOnCtrl) {
|
||||
public static final ItemDescription MISSING = new ItemDescription(ImmutableList.of(), ImmutableList.of(), ImmutableList.of());
|
||||
|
||||
public static final ItemDescription MISSING = new ItemDescription(null);
|
||||
public static Component trim = Components.literal(" ").withStyle(WHITE, STRIKETHROUGH);
|
||||
|
||||
public enum Palette {
|
||||
|
||||
Blue(BLUE, AQUA),
|
||||
Green(DARK_GREEN, GREEN),
|
||||
Yellow(GOLD, YELLOW),
|
||||
Red(DARK_RED, RED),
|
||||
Purple(DARK_PURPLE, LIGHT_PURPLE),
|
||||
Gray(DARK_GRAY, GRAY),
|
||||
|
||||
;
|
||||
|
||||
private Palette(ChatFormatting primary, ChatFormatting highlight) {
|
||||
color = primary;
|
||||
hColor = highlight;
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public ChatFormatting color;
|
||||
public ChatFormatting hColor;
|
||||
public static ItemDescription create(Palette palette, String translationKey) {
|
||||
if (!I18n.exists(translationKey)) {
|
||||
return MISSING;
|
||||
}
|
||||
|
||||
private List<Component> lines;
|
||||
private List<Component> linesOnShift;
|
||||
private List<Component> linesOnCtrl;
|
||||
private Palette palette;
|
||||
Builder builder = builder();
|
||||
builder.palette(palette);
|
||||
|
||||
public ItemDescription(Palette palette) {
|
||||
// Summary
|
||||
String summaryKey = translationKey + ".summary";
|
||||
if (I18n.exists(summaryKey)) {
|
||||
builder.addSummary(I18n.get(summaryKey));
|
||||
}
|
||||
|
||||
// Behaviours
|
||||
for (int i = 1; i < 100; i++) {
|
||||
String conditionKey = translationKey + ".condition" + i;
|
||||
String behaviourKey = translationKey + ".behaviour" + i;
|
||||
if (!I18n.exists(conditionKey))
|
||||
break;
|
||||
builder.addBehaviour(I18n.get(conditionKey), I18n.get(behaviourKey));
|
||||
}
|
||||
|
||||
// Actions
|
||||
for (int i = 1; i < 100; i++) {
|
||||
String controlKey = translationKey + ".control" + i;
|
||||
String actionKey = translationKey + ".action" + i;
|
||||
if (!I18n.exists(controlKey))
|
||||
break;
|
||||
builder.addAction(I18n.get(controlKey), I18n.get(actionKey));
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public void addInformation(List<Component> tooltip) {
|
||||
if (Screen.hasShiftDown()) {
|
||||
tooltip.addAll(linesOnShift);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Screen.hasControlDown()) {
|
||||
tooltip.addAll(linesOnCtrl);
|
||||
return;
|
||||
}
|
||||
|
||||
tooltip.addAll(lines);
|
||||
}
|
||||
|
||||
public record Palette(ChatFormatting primary, ChatFormatting highlight) {
|
||||
public static final Palette BLUE = new Palette(ChatFormatting.BLUE, ChatFormatting.AQUA);
|
||||
public static final Palette GREEN = new Palette(ChatFormatting.DARK_GREEN, ChatFormatting.GREEN);
|
||||
public static final Palette YELLOW = new Palette(ChatFormatting.GOLD, ChatFormatting.YELLOW);
|
||||
public static final Palette RED = new Palette(ChatFormatting.DARK_RED, ChatFormatting.RED);
|
||||
public static final Palette PURPLE = new Palette(ChatFormatting.DARK_PURPLE, ChatFormatting.LIGHT_PURPLE);
|
||||
public static final Palette GRAY = new Palette(ChatFormatting.DARK_GRAY, ChatFormatting.GRAY);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
protected final List<String> summary = new ArrayList<>();
|
||||
protected final List<Pair<String, String>> behaviours = new ArrayList<>();
|
||||
protected final List<Pair<String, String>> actions = new ArrayList<>();
|
||||
protected Palette palette;
|
||||
|
||||
public Builder addSummary(String summaryLine) {
|
||||
summary.add(summaryLine);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addBehaviour(String condition, String behaviour) {
|
||||
behaviours.add(Pair.of(condition, behaviour));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addAction(String condition, String action) {
|
||||
actions.add(Pair.of(condition, action));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder palette(Palette palette) {
|
||||
this.palette = palette;
|
||||
lines = new ArrayList<>();
|
||||
linesOnShift = new ArrayList<>();
|
||||
linesOnCtrl = new ArrayList<>();
|
||||
}
|
||||
|
||||
public ItemDescription withSummary(Component summary) {
|
||||
addStrings(linesOnShift, cutTextComponent(summary, palette.color, palette.hColor));
|
||||
return this;
|
||||
}
|
||||
|
||||
public static List<Component> getKineticStats(Block block) {
|
||||
List<Component> list = new ArrayList<>();
|
||||
public ItemDescription build() {
|
||||
List<Component> lines = new ArrayList<>();
|
||||
List<Component> linesOnShift = new ArrayList<>();
|
||||
List<Component> linesOnCtrl = new ArrayList<>();
|
||||
|
||||
CKinetics config = AllConfigs.SERVER.kinetics;
|
||||
LangBuilder rpmUnit = Lang.translate("generic.unit.rpm");
|
||||
LangBuilder suUnit = Lang.translate("generic.unit.stress");
|
||||
|
||||
boolean hasGoggles = GogglesItem.isWearingGoggles(Minecraft.getInstance().player);
|
||||
|
||||
boolean showStressImpact;
|
||||
if (!(block instanceof IRotate)) {
|
||||
showStressImpact = true;
|
||||
} else {
|
||||
showStressImpact = !((IRotate) block).hideStressImpact();
|
||||
for (String summaryLine : summary) {
|
||||
linesOnShift.addAll(TooltipHelper.cutTextComponent(Components.literal(summaryLine), palette.primary(), palette.highlight()));
|
||||
}
|
||||
|
||||
boolean hasStressImpact =
|
||||
StressImpact.isEnabled() && showStressImpact && BlockStressValues.getImpact(block) > 0;
|
||||
boolean hasStressCapacity = StressImpact.isEnabled() && BlockStressValues.hasCapacity(block);
|
||||
|
||||
if (hasStressImpact) {
|
||||
Lang.translate("tooltip.stressImpact")
|
||||
.style(GRAY)
|
||||
.addTo(list);
|
||||
|
||||
double impact = BlockStressValues.getImpact(block);
|
||||
StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH
|
||||
: (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW);
|
||||
LangBuilder builder = Lang.builder()
|
||||
.add(Lang.text(makeProgressBar(3, impactId.ordinal() + 1))
|
||||
.style(impactId.getAbsoluteColor()));
|
||||
|
||||
if (hasGoggles) {
|
||||
builder.add(Lang.number(impact))
|
||||
.text("x ")
|
||||
.add(rpmUnit)
|
||||
.addTo(list);
|
||||
} else
|
||||
builder.translate("tooltip.stressImpact." + Lang.asId(impactId.name()))
|
||||
.addTo(list);
|
||||
if (!behaviours.isEmpty()) {
|
||||
linesOnShift.add(Components.immutableEmpty());
|
||||
}
|
||||
|
||||
if (hasStressCapacity) {
|
||||
Lang.translate("tooltip.capacityProvided")
|
||||
.style(GRAY)
|
||||
.addTo(list);
|
||||
|
||||
double capacity = BlockStressValues.getCapacity(block);
|
||||
BlockStressValues.IStressValueProvider stressProvider = BlockStressValues.getProvider(block);
|
||||
Couple<Integer> generatedRPM = stressProvider != null ?
|
||||
stressProvider.getGeneratedRPM(block)
|
||||
: null;
|
||||
|
||||
StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.HIGH
|
||||
: (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.LOW);
|
||||
StressImpact opposite = StressImpact.values()[StressImpact.values().length - 2 - impactId.ordinal()];
|
||||
LangBuilder builder = Lang.builder()
|
||||
.add(Lang.text(makeProgressBar(3, impactId.ordinal() + 1))
|
||||
.style(opposite.getAbsoluteColor()));
|
||||
|
||||
if (hasGoggles) {
|
||||
builder.add(Lang.number(capacity))
|
||||
.text("x ")
|
||||
.add(rpmUnit)
|
||||
.addTo(list);
|
||||
|
||||
if (generatedRPM != null) {
|
||||
LangBuilder amount = Lang.number(capacity * generatedRPM.getSecond())
|
||||
.add(suUnit);
|
||||
Lang.text(" -> ")
|
||||
.add(!generatedRPM.getFirst()
|
||||
.equals(generatedRPM.getSecond()) ? Lang.translate("tooltip.up_to", amount) : amount)
|
||||
.style(DARK_GRAY)
|
||||
.addTo(list);
|
||||
}
|
||||
} else
|
||||
builder.translate("tooltip.capacityProvided." + Lang.asId(impactId.name()))
|
||||
.addTo(list);
|
||||
for (Pair<String, String> behaviourPair : behaviours) {
|
||||
String condition = behaviourPair.getLeft();
|
||||
String behaviour = behaviourPair.getRight();
|
||||
linesOnShift.add(Components.literal(condition).withStyle(GRAY));
|
||||
linesOnShift.addAll(TooltipHelper.cutStringTextComponent(behaviour, palette.primary(), palette.highlight(), 1));
|
||||
}
|
||||
|
||||
return list;
|
||||
for (Pair<String, String> actionPair : actions) {
|
||||
String condition = actionPair.getLeft();
|
||||
String action = actionPair.getRight();
|
||||
linesOnCtrl.add(Components.literal(condition).withStyle(GRAY));
|
||||
linesOnCtrl.addAll(TooltipHelper.cutStringTextComponent(action, palette.primary(), palette.highlight(), 1));
|
||||
}
|
||||
|
||||
public static String makeProgressBar(int length, int filledLength) {
|
||||
String bar = " ";
|
||||
int emptySpaces = length - filledLength;
|
||||
for (int i = 0; i < filledLength; i++)
|
||||
bar += "\u2588";
|
||||
for (int i = 0; i < emptySpaces; i++)
|
||||
bar += "\u2592";
|
||||
return bar + " ";
|
||||
}
|
||||
|
||||
public ItemDescription withBehaviour(String condition, String behaviour) {
|
||||
add(linesOnShift, Components.literal(condition).withStyle(GRAY));
|
||||
addStrings(linesOnShift, cutStringTextComponent(behaviour, palette.color, palette.hColor, 1));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemDescription withControl(String condition, String action) {
|
||||
add(linesOnCtrl, Components.literal(condition).withStyle(GRAY));
|
||||
addStrings(linesOnCtrl, cutStringTextComponent(action, palette.color, palette.hColor, 1));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemDescription createTabs() {
|
||||
boolean hasDescription = !linesOnShift.isEmpty();
|
||||
boolean hasControls = !linesOnCtrl.isEmpty();
|
||||
|
||||
|
@ -231,59 +182,16 @@ public class ItemDescription {
|
|||
}
|
||||
}
|
||||
|
||||
if (!hasDescription)
|
||||
linesOnShift = lines;
|
||||
if (!hasControls)
|
||||
linesOnCtrl = lines;
|
||||
|
||||
return this;
|
||||
if (!hasDescription) {
|
||||
linesOnCtrl.clear();
|
||||
linesOnShift.addAll(lines);
|
||||
}
|
||||
if (!hasControls) {
|
||||
linesOnCtrl.clear();
|
||||
linesOnCtrl.addAll(lines);
|
||||
}
|
||||
|
||||
public static String hightlight(String s, Palette palette) {
|
||||
return palette.hColor + s + palette.color;
|
||||
return new ItemDescription(ImmutableList.copyOf(lines), ImmutableList.copyOf(linesOnShift), ImmutableList.copyOf(linesOnCtrl));
|
||||
}
|
||||
|
||||
public static void addStrings(List<Component> infoList, List<Component> textLines) {
|
||||
textLines.forEach(s -> add(infoList, s));
|
||||
}
|
||||
|
||||
public static void add(List<Component> infoList, List<Component> textLines) {
|
||||
infoList.addAll(textLines);
|
||||
}
|
||||
|
||||
public static void add(List<Component> infoList, Component line) {
|
||||
infoList.add(line);
|
||||
}
|
||||
|
||||
public Palette getPalette() {
|
||||
return palette;
|
||||
}
|
||||
|
||||
public List<Component> addInformation(List<Component> tooltip) {
|
||||
if (Screen.hasShiftDown()) {
|
||||
tooltip.addAll(linesOnShift);
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
if (Screen.hasControlDown()) {
|
||||
tooltip.addAll(linesOnCtrl);
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
tooltip.addAll(lines);
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
public List<Component> getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public List<Component> getLinesOnCtrl() {
|
||||
return linesOnCtrl;
|
||||
}
|
||||
|
||||
public List<Component> getLinesOnShift() {
|
||||
return linesOnShift;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,206 @@
|
|||
package com.simibubi.create.foundation.item;
|
||||
|
||||
import static net.minecraft.ChatFormatting.DARK_GRAY;
|
||||
import static net.minecraft.ChatFormatting.GRAY;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.mojang.bridge.game.Language;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate.StressImpact;
|
||||
import com.simibubi.create.content.contraptions.components.steam.SteamEngineBlock;
|
||||
import com.simibubi.create.content.contraptions.goggles.GogglesItem;
|
||||
import com.simibubi.create.foundation.block.BlockStressValues;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.config.CKinetics;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.LangBuilder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
|
||||
public class ItemTooltipHandler {
|
||||
private static final String ITEM_PREFIX = "item." + Create.ID;
|
||||
private static final String BLOCK_PREFIX = "block." + Create.ID;
|
||||
|
||||
private static final Map<Item, Function<ItemStack, String>> TOOLTIP_REFERRALS = new IdentityHashMap<>();
|
||||
private static final Map<String, ItemDescription> TOOLTIP_CACHE = new HashMap<>();
|
||||
private static Language cachedLanguage;
|
||||
|
||||
public static void referTo(ItemLike item, Function<ItemStack, String> func) {
|
||||
TOOLTIP_REFERRALS.put(item.asItem(), func);
|
||||
}
|
||||
|
||||
public static void referTo(ItemLike item, Supplier<? extends ItemLike> itemWithTooltip) {
|
||||
referTo(item, stack -> itemWithTooltip.get()
|
||||
.asItem()
|
||||
.getDescriptionId());
|
||||
}
|
||||
|
||||
public static void referTo(ItemLike item, String string) {
|
||||
referTo(item, stack -> string);
|
||||
}
|
||||
|
||||
public static void addToTooltip(ItemTooltipEvent event) {
|
||||
ItemStack stack = event.getItemStack();
|
||||
List<Component> tooltip = event.getToolTip();
|
||||
|
||||
String translationKey = stack.getDescriptionId();
|
||||
if (translationKey.startsWith(ITEM_PREFIX) || translationKey.startsWith(BLOCK_PREFIX)) {
|
||||
ItemDescription desc = getOrCreateTooltip(stack);
|
||||
if (desc != null) {
|
||||
List<Component> descTooltip = new ArrayList<>();
|
||||
desc.addInformation(descTooltip);
|
||||
tooltip.addAll(1, descTooltip);
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof BlockItem blockItem) {
|
||||
Block block = blockItem.getBlock();
|
||||
if (block instanceof IRotate || block instanceof SteamEngineBlock) {
|
||||
List<Component> kineticStats = getKineticStats(block, event.getPlayer());
|
||||
if (!kineticStats.isEmpty()) {
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
tooltip.addAll(kineticStats);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkLocale() {
|
||||
Language currentLanguage = Minecraft.getInstance()
|
||||
.getLanguageManager()
|
||||
.getSelected();
|
||||
if (cachedLanguage != currentLanguage) {
|
||||
cachedLanguage = currentLanguage;
|
||||
TOOLTIP_CACHE.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTooltipTranslationKey(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
if (TOOLTIP_REFERRALS.containsKey(item)) {
|
||||
return TOOLTIP_REFERRALS.get(item)
|
||||
.apply(stack) + ".tooltip";
|
||||
}
|
||||
return stack.getDescriptionId() + ".tooltip";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ItemDescription getOrCreateTooltip(ItemStack stack) {
|
||||
checkLocale();
|
||||
|
||||
String key = getTooltipTranslationKey(stack);
|
||||
ItemDescription desc = TOOLTIP_CACHE.get(key);
|
||||
|
||||
if (desc == null) {
|
||||
// TODO 0.5.1: Decide on colors and defer creation to registered factory/type based on key or item
|
||||
desc = ItemDescription.create(ItemDescription.Palette.GRAY, key);
|
||||
TOOLTIP_CACHE.put(key, desc);
|
||||
}
|
||||
|
||||
if (desc == ItemDescription.MISSING) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static List<Component> getKineticStats(Block block, Player player) {
|
||||
List<Component> list = new ArrayList<>();
|
||||
|
||||
CKinetics config = AllConfigs.SERVER.kinetics;
|
||||
LangBuilder rpmUnit = Lang.translate("generic.unit.rpm");
|
||||
LangBuilder suUnit = Lang.translate("generic.unit.stress");
|
||||
|
||||
boolean hasGoggles = GogglesItem.isWearingGoggles(player);
|
||||
|
||||
boolean showStressImpact;
|
||||
if (block instanceof IRotate) {
|
||||
showStressImpact = !((IRotate) block).hideStressImpact();
|
||||
} else {
|
||||
showStressImpact = true;
|
||||
}
|
||||
|
||||
boolean hasStressImpact =
|
||||
StressImpact.isEnabled() && showStressImpact && BlockStressValues.getImpact(block) > 0;
|
||||
boolean hasStressCapacity = StressImpact.isEnabled() && BlockStressValues.hasCapacity(block);
|
||||
|
||||
if (hasStressImpact) {
|
||||
Lang.translate("tooltip.stressImpact")
|
||||
.style(GRAY)
|
||||
.addTo(list);
|
||||
|
||||
double impact = BlockStressValues.getImpact(block);
|
||||
StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH
|
||||
: (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW);
|
||||
LangBuilder builder = Lang.builder()
|
||||
.add(Lang.text(TooltipHelper.makeProgressBar(3, impactId.ordinal() + 1))
|
||||
.style(impactId.getAbsoluteColor()));
|
||||
|
||||
if (hasGoggles) {
|
||||
builder.add(Lang.number(impact))
|
||||
.text("x ")
|
||||
.add(rpmUnit)
|
||||
.addTo(list);
|
||||
} else
|
||||
builder.translate("tooltip.stressImpact." + Lang.asId(impactId.name()))
|
||||
.addTo(list);
|
||||
}
|
||||
|
||||
if (hasStressCapacity) {
|
||||
Lang.translate("tooltip.capacityProvided")
|
||||
.style(GRAY)
|
||||
.addTo(list);
|
||||
|
||||
double capacity = BlockStressValues.getCapacity(block);
|
||||
Couple<Integer> generatedRPM = BlockStressValues.getGeneratedRPM(block);
|
||||
|
||||
StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.HIGH
|
||||
: (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.LOW);
|
||||
StressImpact opposite = StressImpact.values()[StressImpact.values().length - 2 - impactId.ordinal()];
|
||||
LangBuilder builder = Lang.builder()
|
||||
.add(Lang.text(TooltipHelper.makeProgressBar(3, impactId.ordinal() + 1))
|
||||
.style(opposite.getAbsoluteColor()));
|
||||
|
||||
if (hasGoggles) {
|
||||
builder.add(Lang.number(capacity))
|
||||
.text("x ")
|
||||
.add(rpmUnit)
|
||||
.addTo(list);
|
||||
|
||||
if (generatedRPM != null) {
|
||||
LangBuilder amount = Lang.number(capacity * generatedRPM.getSecond())
|
||||
.add(suUnit);
|
||||
Lang.text(" -> ")
|
||||
.add(!generatedRPM.getFirst()
|
||||
.equals(generatedRPM.getSecond()) ? Lang.translate("tooltip.up_to", amount) : amount)
|
||||
.style(DARK_GRAY)
|
||||
.addTo(list);
|
||||
}
|
||||
} else
|
||||
builder.translate("tooltip.capacityProvided." + Lang.asId(impactId.name()))
|
||||
.addTo(list);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -2,16 +2,10 @@ package com.simibubi.create.foundation.item;
|
|||
|
||||
import java.text.BreakIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.mojang.bridge.game.Language;
|
||||
import com.simibubi.create.content.AllSections;
|
||||
import com.simibubi.create.content.contraptions.goggles.GogglesItem;
|
||||
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.foundation.item.ItemDescription.Palette;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
|
@ -22,22 +16,13 @@ import com.simibubi.create.foundation.utility.Lang;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
public class TooltipHelper {
|
||||
|
||||
public static final int maxWidthPerLine = 200;
|
||||
public static final Map<String, ItemDescription> cachedTooltips = new HashMap<>();
|
||||
public static Language cachedLanguage;
|
||||
private static boolean gogglesMode;
|
||||
private static final Map<Item, Supplier<String>> tooltipReferrals = new HashMap<>();
|
||||
public static final int MAX_WIDTH_PER_LINE = 200;
|
||||
|
||||
public static MutableComponent holdShift(Palette color, boolean highlighted) {
|
||||
return Lang.translateDirect("tooltip.holdForDescription", Lang.translateDirect("tooltip.keyShift")
|
||||
|
@ -57,14 +42,14 @@ public class TooltipHelper {
|
|||
.append(component));
|
||||
}
|
||||
|
||||
public static void referTo(ItemLike item, Supplier<? extends ItemLike> itemWithTooltip) {
|
||||
tooltipReferrals.put(item.asItem(), () -> itemWithTooltip.get()
|
||||
.asItem()
|
||||
.getDescriptionId());
|
||||
}
|
||||
|
||||
public static void referTo(ItemLike item, String string) {
|
||||
tooltipReferrals.put(item.asItem(), () -> string);
|
||||
public static String makeProgressBar(int length, int filledLength) {
|
||||
String bar = " ";
|
||||
int emptySpaces = length - filledLength;
|
||||
for (int i = 0; i < filledLength; i++)
|
||||
bar += "\u2588";
|
||||
for (int i = 0; i < emptySpaces; i++)
|
||||
bar += "\u2592";
|
||||
return bar + " ";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -89,7 +74,7 @@ public class TooltipHelper {
|
|||
}
|
||||
|
||||
Font font = Minecraft.getInstance().font;
|
||||
List<String> lines = FontHelper.cutString(font, markedUp, maxWidthPerLine);
|
||||
List<String> lines = FontHelper.cutString(font, markedUp, MAX_WIDTH_PER_LINE);
|
||||
|
||||
// Format
|
||||
String lineStart = Strings.repeat(" ", indent);
|
||||
|
@ -142,7 +127,7 @@ public class TooltipHelper {
|
|||
int width = 0;
|
||||
for (String word : words) {
|
||||
int newWidth = font.width(word.replaceAll("_", ""));
|
||||
if (width + newWidth > maxWidthPerLine) {
|
||||
if (width + newWidth > MAX_WIDTH_PER_LINE) {
|
||||
if (width > 0) {
|
||||
String line = currentLine.toString();
|
||||
lines.add(line);
|
||||
|
@ -221,102 +206,6 @@ public class TooltipHelper {
|
|||
// return lines;
|
||||
// }
|
||||
|
||||
private static void checkLocale() {
|
||||
Language currentLanguage = Minecraft.getInstance()
|
||||
.getLanguageManager()
|
||||
.getSelected();
|
||||
if (cachedLanguage != currentLanguage) {
|
||||
cachedTooltips.clear();
|
||||
cachedLanguage = currentLanguage;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasTooltip(ItemStack stack, Player player) {
|
||||
checkLocale();
|
||||
|
||||
boolean hasGoggles = GogglesItem.isWearingGoggles(player);
|
||||
|
||||
if (hasGoggles != gogglesMode) {
|
||||
gogglesMode = hasGoggles;
|
||||
cachedTooltips.clear();
|
||||
}
|
||||
|
||||
String key = getTooltipTranslationKey(stack);
|
||||
if (cachedTooltips.containsKey(key))
|
||||
return cachedTooltips.get(key) != ItemDescription.MISSING;
|
||||
return findTooltip(stack);
|
||||
}
|
||||
|
||||
public static ItemDescription getTooltip(ItemStack stack) {
|
||||
checkLocale();
|
||||
String key = getTooltipTranslationKey(stack);
|
||||
if (cachedTooltips.containsKey(key)) {
|
||||
ItemDescription itemDescription = cachedTooltips.get(key);
|
||||
if (itemDescription != ItemDescription.MISSING)
|
||||
return itemDescription;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean findTooltip(ItemStack stack) {
|
||||
String key = getTooltipTranslationKey(stack);
|
||||
if (I18n.exists(key)) {
|
||||
cachedTooltips.put(key, buildToolTip(key, stack));
|
||||
return true;
|
||||
}
|
||||
cachedTooltips.put(key, ItemDescription.MISSING);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ItemDescription buildToolTip(String translationKey, ItemStack stack) {
|
||||
AllSections module = AllSections.of(stack);
|
||||
ItemDescription tooltip = new ItemDescription(module.getTooltipPalette());
|
||||
String summaryKey = translationKey + ".summary";
|
||||
|
||||
// Summary
|
||||
if (I18n.exists(summaryKey))
|
||||
tooltip = tooltip.withSummary(Components.literal(I18n.get(summaryKey)));
|
||||
|
||||
// Requirements
|
||||
// if (stack.getItem() instanceof BlockItem) {
|
||||
// BlockItem item = (BlockItem) stack.getItem();
|
||||
// if (item.getBlock() instanceof IRotate || item.getBlock() instanceof EngineBlock) {
|
||||
// tooltip = tooltip.withKineticStats(item.getBlock());
|
||||
// }
|
||||
// }
|
||||
|
||||
// Behaviours
|
||||
for (int i = 1; i < 100; i++) {
|
||||
String conditionKey = translationKey + ".condition" + i;
|
||||
String behaviourKey = translationKey + ".behaviour" + i;
|
||||
if (!I18n.exists(conditionKey))
|
||||
break;
|
||||
if (i == 1)
|
||||
tooltip.getLinesOnShift()
|
||||
.add(Components.immutableEmpty());
|
||||
tooltip.withBehaviour(I18n.get(conditionKey), I18n.get(behaviourKey));
|
||||
}
|
||||
|
||||
// Controls
|
||||
for (int i = 1; i < 100; i++) {
|
||||
String controlKey = translationKey + ".control" + i;
|
||||
String actionKey = translationKey + ".action" + i;
|
||||
if (!I18n.exists(controlKey))
|
||||
break;
|
||||
tooltip.withControl(I18n.get(controlKey), I18n.get(actionKey));
|
||||
}
|
||||
|
||||
return tooltip.createTabs();
|
||||
}
|
||||
|
||||
public static String getTooltipTranslationKey(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
if (tooltipReferrals.containsKey(item))
|
||||
return tooltipReferrals.get(item)
|
||||
.get() + ".tooltip";
|
||||
return item.getDescriptionId(stack) + ".tooltip";
|
||||
}
|
||||
|
||||
// private static int getComponentLength(ITextComponent component) {
|
||||
// AtomicInteger l = new AtomicInteger();
|
||||
// TextProcessing.visitFormatted(component, Style.EMPTY, (s, style, charConsumer) -> {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.simibubi.create.foundation.mixin.accessor;
|
||||
|
||||
import net.minecraft.nbt.NbtAccounter;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.nbt.NbtAccounter;
|
||||
|
||||
@Mixin(NbtAccounter.class)
|
||||
public interface NbtAccounterAccessor {
|
||||
@Accessor("usage")
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.minecraft.network.chat.Component;
|
|||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
|
||||
public class PonderTooltipHandler {
|
||||
|
||||
|
@ -73,10 +74,12 @@ public class PonderTooltipHandler {
|
|||
hoveredStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static void addToTooltip(List<Component> toolTip, ItemStack stack) {
|
||||
public static void addToTooltip(ItemTooltipEvent event) {
|
||||
if (!enable)
|
||||
return;
|
||||
|
||||
ItemStack stack = event.getItemStack();
|
||||
|
||||
updateHovered(stack);
|
||||
|
||||
if (deferTick)
|
||||
|
@ -90,10 +93,11 @@ public class PonderTooltipHandler {
|
|||
Component component = subject ? Lang.translateDirect(SUBJECT)
|
||||
.withStyle(ChatFormatting.GREEN)
|
||||
: makeProgressBar(Math.min(1, holdWProgress.getValue(renderPartialTicks) * 8 / 7f));
|
||||
if (toolTip.size() < 2)
|
||||
toolTip.add(component);
|
||||
List<Component> tooltip = event.getToolTip();
|
||||
if (tooltip.size() < 2)
|
||||
tooltip.add(component);
|
||||
else
|
||||
toolTip.add(1, component);
|
||||
tooltip.add(1, component);
|
||||
}
|
||||
|
||||
protected static void updateHovered(ItemStack stack) {
|
||||
|
|
|
@ -14,15 +14,15 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
public class CreateRegistry<K extends IForgeRegistryEntry<K>, V> {
|
||||
private static final List<CreateRegistry<?, ?>> ALL = new ArrayList<>();
|
||||
public class AttachedRegistry<K extends IForgeRegistryEntry<K>, V> {
|
||||
private static final List<AttachedRegistry<?, ?>> ALL = new ArrayList<>();
|
||||
|
||||
protected final IForgeRegistry<K> objectRegistry;
|
||||
protected final Map<ResourceLocation, V> locationMap = new HashMap<>();
|
||||
protected final Map<K, V> objectMap = new IdentityHashMap<>();
|
||||
protected boolean unwrapped = false;
|
||||
|
||||
public CreateRegistry(IForgeRegistry<K> objectRegistry) {
|
||||
public AttachedRegistry(IForgeRegistry<K> objectRegistry) {
|
||||
this.objectRegistry = objectRegistry;
|
||||
ALL.add(this);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class CreateRegistry<K extends IForgeRegistryEntry<K>, V> {
|
|||
if (object != null) {
|
||||
objectMap.put(object, value);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for location '" + location + "' in CreateRegistry after unwrapping!");
|
||||
Create.LOGGER.warn("Could not get object for location '" + location + "' in AttachedRegistry after unwrapping!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class CreateRegistry<K extends IForgeRegistryEntry<K>, V> {
|
|||
if (location != null) {
|
||||
locationMap.put(location, value);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get location of object '" + object + "' in CreateRegistry before unwrapping!");
|
||||
Create.LOGGER.warn("Could not get location of object '" + object + "' in AttachedRegistry before unwrapping!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class CreateRegistry<K extends IForgeRegistryEntry<K>, V> {
|
|||
if (object != null) {
|
||||
return objectMap.get(object);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for location '" + location + "' in CreateRegistry after unwrapping!");
|
||||
Create.LOGGER.warn("Could not get object for location '" + location + "' in AttachedRegistry after unwrapping!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class CreateRegistry<K extends IForgeRegistryEntry<K>, V> {
|
|||
if (location != null) {
|
||||
return locationMap.get(location);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get location of object '" + object + "' in CreateRegistry before unwrapping!");
|
||||
Create.LOGGER.warn("Could not get location of object '" + object + "' in AttachedRegistry before unwrapping!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -94,14 +94,14 @@ public class CreateRegistry<K extends IForgeRegistryEntry<K>, V> {
|
|||
if (object != null) {
|
||||
objectMap.put(object, entry.getValue());
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for location '" + location + "' in CreateRegistry during unwrapping!");
|
||||
Create.LOGGER.warn("Could not get object for location '" + location + "' in AttachedRegistry during unwrapping!");
|
||||
}
|
||||
}
|
||||
unwrapped = true;
|
||||
}
|
||||
|
||||
public static void unwrapAll() {
|
||||
for (CreateRegistry<?, ?> registry : ALL) {
|
||||
for (AttachedRegistry<?, ?> registry : ALL) {
|
||||
registry.unwrap();
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.nbt.NbtAccounter;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
||||
public class ContraptionData {
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue