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.AllInteractionBehaviours.interactionBehaviour;
|
||||||
import static com.simibubi.create.AllMovementBehaviours.movementBehaviour;
|
import static com.simibubi.create.AllMovementBehaviours.movementBehaviour;
|
||||||
import static com.simibubi.create.Create.REGISTRATE;
|
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.content.logistics.block.display.AllDisplayBehaviours.assignDataBehaviour;
|
||||||
import static com.simibubi.create.foundation.data.BlockStateGen.axisBlock;
|
import static com.simibubi.create.foundation.data.BlockStateGen.axisBlock;
|
||||||
import static com.simibubi.create.foundation.data.BlockStateGen.simpleCubeAll;
|
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.AllBlockTags;
|
||||||
import com.simibubi.create.AllTags.AllItemTags;
|
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.base.CasingBlock;
|
||||||
import com.simibubi.create.content.contraptions.components.AssemblyOperatorBlockItem;
|
import com.simibubi.create.content.contraptions.components.AssemblyOperatorBlockItem;
|
||||||
import com.simibubi.create.content.contraptions.components.actors.BellMovementBehaviour;
|
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.CreateRegistrate;
|
||||||
import com.simibubi.create.foundation.data.ModelGen;
|
import com.simibubi.create.foundation.data.ModelGen;
|
||||||
import com.simibubi.create.foundation.data.SharedProperties;
|
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.item.UncontainableBlockItem;
|
||||||
import com.simibubi.create.foundation.utility.ColorHandlers;
|
import com.simibubi.create.foundation.utility.ColorHandlers;
|
||||||
import com.simibubi.create.foundation.utility.Couple;
|
import com.simibubi.create.foundation.utility.Couple;
|
||||||
|
@ -293,10 +291,6 @@ public class AllBlocks {
|
||||||
|
|
||||||
// Schematics
|
// Schematics
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRATE.startSection(SCHEMATICS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final BlockEntry<SchematicannonBlock> SCHEMATICANNON =
|
public static final BlockEntry<SchematicannonBlock> SCHEMATICANNON =
|
||||||
REGISTRATE.block("schematicannon", SchematicannonBlock::new)
|
REGISTRATE.block("schematicannon", SchematicannonBlock::new)
|
||||||
.initialProperties(() -> Blocks.DISPENSER)
|
.initialProperties(() -> Blocks.DISPENSER)
|
||||||
|
@ -330,10 +324,6 @@ public class AllBlocks {
|
||||||
|
|
||||||
// Kinetics
|
// Kinetics
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRATE.startSection(AllSections.KINETICS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new)
|
public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new)
|
||||||
.initialProperties(SharedProperties::stone)
|
.initialProperties(SharedProperties::stone)
|
||||||
.properties(p -> p.color(MaterialColor.METAL))
|
.properties(p -> p.color(MaterialColor.METAL))
|
||||||
|
@ -583,7 +573,7 @@ public class AllBlocks {
|
||||||
.transform(axeOrPickaxe())
|
.transform(axeOrPickaxe())
|
||||||
.transform(BuilderTransformers.cuckooClock())
|
.transform(BuilderTransformers.cuckooClock())
|
||||||
.lang("Cuckoo Clock")
|
.lang("Cuckoo Clock")
|
||||||
.onRegisterAfter(Registry.ITEM_REGISTRY, c -> TooltipHelper.referTo(c, CUCKOO_CLOCK))
|
.onRegisterAfter(Registry.ITEM_REGISTRY, c -> ItemTooltipHandler.referTo(c, CUCKOO_CLOCK))
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final BlockEntry<MillstoneBlock> MILLSTONE = REGISTRATE.block("millstone", MillstoneBlock::new)
|
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))
|
.unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag))
|
||||||
.save(p, Create.asResource("crafting/kinetics/" + c.getName() + "_from_other_seat"));
|
.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)
|
.tag(AllBlockTags.SEATS.tag)
|
||||||
.item()
|
.item()
|
||||||
.tag(AllItemTags.SEATS.tag)
|
.tag(AllItemTags.SEATS.tag)
|
||||||
|
@ -1529,10 +1519,6 @@ public class AllBlocks {
|
||||||
|
|
||||||
// Logistics
|
// Logistics
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRATE.startSection(AllSections.LOGISTICS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final BlockEntry<ArmBlock> MECHANICAL_ARM = REGISTRATE.block("mechanical_arm", ArmBlock::new)
|
public static final BlockEntry<ArmBlock> MECHANICAL_ARM = REGISTRATE.block("mechanical_arm", ArmBlock::new)
|
||||||
.initialProperties(SharedProperties::softMetal)
|
.initialProperties(SharedProperties::softMetal)
|
||||||
.properties(p -> p.color(MaterialColor.TERRACOTTA_YELLOW))
|
.properties(p -> p.color(MaterialColor.TERRACOTTA_YELLOW))
|
||||||
|
@ -1970,10 +1956,6 @@ public class AllBlocks {
|
||||||
|
|
||||||
// Curiosities
|
// Curiosities
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRATE.startSection(AllSections.CURIOSITIES);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final BlockEntry<BacktankBlock> COPPER_BACKTANK =
|
public static final BlockEntry<BacktankBlock> COPPER_BACKTANK =
|
||||||
REGISTRATE.block("copper_backtank", BacktankBlock::new)
|
REGISTRATE.block("copper_backtank", BacktankBlock::new)
|
||||||
.initialProperties(SharedProperties::copperMetal)
|
.initialProperties(SharedProperties::copperMetal)
|
||||||
|
@ -2025,7 +2007,7 @@ public class AllBlocks {
|
||||||
.withExistingParent(colourName + "_toolbox", p.modLoc("block/toolbox/block"))
|
.withExistingParent(colourName + "_toolbox", p.modLoc("block/toolbox/block"))
|
||||||
.texture("0", p.modLoc("block/toolbox/" + colourName)));
|
.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)
|
.tag(AllBlockTags.TOOLBOXES.tag)
|
||||||
.item(UncontainableBlockItem::new)
|
.item(UncontainableBlockItem::new)
|
||||||
.model((c, p) -> p.withExistingParent(colourName + "_toolbox", p.modLoc("block/toolbox/item"))
|
.model((c, p) -> p.withExistingParent(colourName + "_toolbox", p.modLoc("block/toolbox/item"))
|
||||||
|
@ -2037,10 +2019,6 @@ public class AllBlocks {
|
||||||
|
|
||||||
// Materials
|
// Materials
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRATE.startSection(AllSections.PALETTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final BlockEntry<Block> ZINC_ORE = REGISTRATE.block("zinc_ore", Block::new)
|
public static final BlockEntry<Block> ZINC_ORE = REGISTRATE.block("zinc_ore", Block::new)
|
||||||
.initialProperties(() -> Blocks.GOLD_ORE)
|
.initialProperties(() -> Blocks.GOLD_ORE)
|
||||||
.properties(p -> p.color(MaterialColor.METAL))
|
.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.DoorMovingInteraction;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.interaction.LeverMovingInteraction;
|
import com.simibubi.create.content.contraptions.components.structureMovement.interaction.LeverMovingInteraction;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.interaction.TrapdoorMovingInteraction;
|
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 com.tterrag.registrate.util.nullness.NonNullConsumer;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
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.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.IRegistryDelegate;
|
|
||||||
|
|
||||||
public class AllInteractionBehaviours {
|
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<>();
|
private static final List<BehaviourProvider> GLOBAL_BEHAVIOURS = new ArrayList<>();
|
||||||
|
|
||||||
public static void registerBehaviour(ResourceLocation block, MovingInteractionBehaviour provider) {
|
public static void registerBehaviour(ResourceLocation block, MovingInteractionBehaviour provider) {
|
||||||
|
@ -32,11 +31,6 @@ public class AllInteractionBehaviours {
|
||||||
BLOCK_BEHAVIOURS.register(block, provider);
|
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) {
|
public static void registerBehaviourProvider(BehaviourProvider provider) {
|
||||||
GLOBAL_BEHAVIOURS.add(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.CRUSHED_ORES;
|
||||||
import static com.simibubi.create.AllTags.AllItemTags.PLATES;
|
import static com.simibubi.create.AllTags.AllItemTags.PLATES;
|
||||||
import static com.simibubi.create.Create.REGISTRATE;
|
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.ALUMINUM;
|
||||||
import static com.simibubi.create.foundation.data.recipe.CompatMetals.LEAD;
|
import static com.simibubi.create.foundation.data.recipe.CompatMetals.LEAD;
|
||||||
import static com.simibubi.create.foundation.data.recipe.CompatMetals.NICKEL;
|
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.CreateRegistrate;
|
||||||
import com.simibubi.create.foundation.data.recipe.CompatMetals;
|
import com.simibubi.create.foundation.data.recipe.CompatMetals;
|
||||||
import com.simibubi.create.foundation.item.HiddenIngredientItem;
|
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.TagDependentIngredientItem;
|
||||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
|
||||||
import com.tterrag.registrate.util.entry.ItemEntry;
|
import com.tterrag.registrate.util.entry.ItemEntry;
|
||||||
|
|
||||||
import net.minecraft.tags.ItemTags;
|
import net.minecraft.tags.ItemTags;
|
||||||
|
@ -77,11 +72,7 @@ public class AllItems {
|
||||||
REGISTRATE.creativeModeTab(() -> Create.BASE_CREATIVE_TAB);
|
REGISTRATE.creativeModeTab(() -> Create.BASE_CREATIVE_TAB);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schematics
|
// Materials
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRATE.startSection(MATERIALS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ItemEntry<Item> WHEAT_FLOUR =
|
public static final ItemEntry<Item> WHEAT_FLOUR =
|
||||||
taggedIngredient("wheat_flour", forgeItemTag("flour/wheat"), forgeItemTag("flour")),
|
taggedIngredient("wheat_flour", forgeItemTag("flour/wheat"), forgeItemTag("flour")),
|
||||||
|
@ -202,10 +193,6 @@ public class AllItems {
|
||||||
|
|
||||||
// Kinetics
|
// Kinetics
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRATE.startSection(KINETICS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ItemEntry<BeltConnectorItem> BELT_CONNECTOR =
|
public static final ItemEntry<BeltConnectorItem> BELT_CONNECTOR =
|
||||||
REGISTRATE.item("belt_connector", BeltConnectorItem::new)
|
REGISTRATE.item("belt_connector", BeltConnectorItem::new)
|
||||||
.lang("Mechanical Belt")
|
.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)
|
public static final ItemEntry<SandPaperItem> RED_SAND_PAPER = REGISTRATE.item("red_sand_paper", SandPaperItem::new)
|
||||||
.tag(AllTags.AllItemTags.SANDPAPER.tag)
|
.tag(AllTags.AllItemTags.SANDPAPER.tag)
|
||||||
.onRegister(s -> TooltipHelper.referTo(s, SAND_PAPER))
|
.onRegister(s -> ItemTooltipHandler.referTo(s, SAND_PAPER))
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final ItemEntry<WrenchItem> WRENCH = REGISTRATE.item("wrench", WrenchItem::new)
|
public static final ItemEntry<WrenchItem> WRENCH = REGISTRATE.item("wrench", WrenchItem::new)
|
||||||
|
@ -311,10 +298,6 @@ public class AllItems {
|
||||||
|
|
||||||
// Curiosities
|
// Curiosities
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRATE.startSection(CURIOSITIES);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ItemEntry<LinkedControllerItem> LINKED_CONTROLLER =
|
public static final ItemEntry<LinkedControllerItem> LINKED_CONTROLLER =
|
||||||
REGISTRATE.item("linked_controller", LinkedControllerItem::new)
|
REGISTRATE.item("linked_controller", LinkedControllerItem::new)
|
||||||
.properties(p -> p.stacksTo(1))
|
.properties(p -> p.stacksTo(1))
|
||||||
|
@ -351,10 +334,6 @@ public class AllItems {
|
||||||
|
|
||||||
// Logistics
|
// Logistics
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRATE.startSection(LOGISTICS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ItemEntry<FilterItem> FILTER = REGISTRATE.item("filter", FilterItem::regular)
|
public static final ItemEntry<FilterItem> FILTER = REGISTRATE.item("filter", FilterItem::regular)
|
||||||
.model(AssetLookup.existingItemModel())
|
.model(AssetLookup.existingItemModel())
|
||||||
.register();
|
.register();
|
||||||
|
@ -370,10 +349,6 @@ public class AllItems {
|
||||||
|
|
||||||
// Schematics
|
// Schematics
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRATE.startSection(SCHEMATICS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ItemEntry<Item> EMPTY_SCHEMATIC = REGISTRATE.item("empty_schematic", Item::new)
|
public static final ItemEntry<Item> EMPTY_SCHEMATIC = REGISTRATE.item("empty_schematic", Item::new)
|
||||||
.properties(p -> p.stacksTo(1))
|
.properties(p -> p.stacksTo(1))
|
||||||
.register();
|
.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.DispenserMovementBehaviour;
|
||||||
import com.simibubi.create.content.contraptions.components.actors.dispenser.DropperMovementBehaviour;
|
import com.simibubi.create.content.contraptions.components.actors.dispenser.DropperMovementBehaviour;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
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 com.tterrag.registrate.util.nullness.NonNullConsumer;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
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.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.IRegistryDelegate;
|
|
||||||
|
|
||||||
public class AllMovementBehaviours {
|
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<>();
|
private static final List<BehaviourProvider> GLOBAL_BEHAVIOURS = new ArrayList<>();
|
||||||
|
|
||||||
public static void registerBehaviour(ResourceLocation block, MovementBehaviour behaviour) {
|
public static void registerBehaviour(ResourceLocation block, MovementBehaviour behaviour) {
|
||||||
|
@ -32,11 +31,6 @@ public class AllMovementBehaviours {
|
||||||
BLOCK_BEHAVIOURS.register(block, behaviour);
|
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) {
|
public static void registerBehaviourProvider(BehaviourProvider provider) {
|
||||||
GLOBAL_BEHAVIOURS.add(provider);
|
GLOBAL_BEHAVIOURS.add(provider);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,13 @@ import static com.simibubi.create.AllTags.NameSpace.TIC;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.data.TagGen;
|
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
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.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.tags.FluidTags;
|
import net.minecraft.tags.FluidTags;
|
||||||
import net.minecraft.tags.ItemTags;
|
import net.minecraft.tags.ItemTags;
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.item.BlockItem;
|
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
@ -52,27 +47,6 @@ public class AllTags {
|
||||||
return forgeTag(ForgeRegistries.FLUIDS, path);
|
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 {
|
public enum NameSpace {
|
||||||
MOD(Create.ID, false, true),
|
MOD(Create.ID, false, true),
|
||||||
FORGE("forge"),
|
FORGE("forge"),
|
||||||
|
|
|
@ -10,7 +10,6 @@ import com.mojang.logging.LogUtils;
|
||||||
import com.simibubi.create.api.behaviour.BlockSpoutingBehaviour;
|
import com.simibubi.create.api.behaviour.BlockSpoutingBehaviour;
|
||||||
import com.simibubi.create.compat.Mods;
|
import com.simibubi.create.compat.Mods;
|
||||||
import com.simibubi.create.compat.curios.Curios;
|
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.TorquePropagator;
|
||||||
import com.simibubi.create.content.contraptions.fluids.tank.BoilerHeaters;
|
import com.simibubi.create.content.contraptions.fluids.tank.BoilerHeaters;
|
||||||
import com.simibubi.create.content.curiosities.deco.SlidingDoorBlock;
|
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.block.mechanicalArm.AllArmInteractionPointTypes;
|
||||||
import com.simibubi.create.content.logistics.trains.GlobalRailwayManager;
|
import com.simibubi.create.content.logistics.trains.GlobalRailwayManager;
|
||||||
import com.simibubi.create.content.palettes.AllPaletteBlocks;
|
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.ServerSchematicLoader;
|
||||||
import com.simibubi.create.content.schematics.filtering.SchematicInstances;
|
import com.simibubi.create.content.schematics.filtering.SchematicInstances;
|
||||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
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.ProcessingRecipeGen;
|
||||||
import com.simibubi.create.foundation.data.recipe.SequencedAssemblyRecipeGen;
|
import com.simibubi.create.foundation.data.recipe.SequencedAssemblyRecipeGen;
|
||||||
import com.simibubi.create.foundation.data.recipe.StandardRecipeGen;
|
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.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.AllFeatures;
|
||||||
import com.simibubi.create.foundation.worldgen.AllOreFeatureConfigEntries;
|
import com.simibubi.create.foundation.worldgen.AllOreFeatureConfigEntries;
|
||||||
import com.simibubi.create.foundation.worldgen.AllPlacementModifiers;
|
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 CreateRegistrate REGISTRATE = CreateRegistrate.create(ID);
|
||||||
|
|
||||||
public static final CreativeModeTab BASE_CREATIVE_TAB = new CreateItemGroup();
|
public static final CreativeModeTab BASE_CREATIVE_TAB = new BaseCreativeModeTab();
|
||||||
public static final CreativeModeTab PALETTES_CREATIVE_TAB = new PalettesItemGroup();
|
public static final CreativeModeTab PALETTES_CREATIVE_TAB = new PalettesCreativeModeTab();
|
||||||
|
|
||||||
public static final ServerSchematicLoader SCHEMATIC_RECEIVER = new ServerSchematicLoader();
|
public static final ServerSchematicLoader SCHEMATIC_RECEIVER = new ServerSchematicLoader();
|
||||||
public static final RedstoneLinkNetworkHandler REDSTONE_LINK_NETWORK_HANDLER = new RedstoneLinkNetworkHandler();
|
public static final RedstoneLinkNetworkHandler REDSTONE_LINK_NETWORK_HANDLER = new RedstoneLinkNetworkHandler();
|
||||||
|
@ -146,7 +146,7 @@ public class Create {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(final FMLCommonSetupEvent event) {
|
public static void init(final FMLCommonSetupEvent event) {
|
||||||
CreateRegistry.unwrapAll();
|
AttachedRegistry.unwrapAll();
|
||||||
AllPackets.registerPackets();
|
AllPackets.registerPackets();
|
||||||
SchematicInstances.register();
|
SchematicInstances.register();
|
||||||
BuiltinPotatoProjectileTypes.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.content.contraptions.wrench.IWrenchable;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
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.Lang;
|
||||||
import com.simibubi.create.foundation.utility.LangBuilder;
|
import com.simibubi.create.foundation.utility.LangBuilder;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public interface IRotate extends IWrenchable {
|
||||||
|
|
||||||
public static LangBuilder getFormattedSpeedText(float speed, boolean overstressed) {
|
public static LangBuilder getFormattedSpeedText(float speed, boolean overstressed) {
|
||||||
SpeedLevel speedLevel = of(speed);
|
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()))
|
builder.translate("tooltip.speedRequirement." + Lang.asId(speedLevel.name()))
|
||||||
.space()
|
.space()
|
||||||
|
@ -133,7 +133,7 @@ public interface IRotate extends IWrenchable {
|
||||||
|
|
||||||
public static LangBuilder getFormattedStressText(double stressPercent) {
|
public static LangBuilder getFormattedStressText(double stressPercent) {
|
||||||
StressImpact stressLevel = of(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()))
|
.translate("tooltip.stressImpact." + Lang.asId(stressLevel.name()))
|
||||||
.text(String.format(" (%s%%) ", (int) (stressPercent * 100)))
|
.text(String.format(" (%s%%) ", (int) (stressPercent * 100)))
|
||||||
.style(stressLevel.getRelativeColor());
|
.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.advancement.AdvancementBehaviour;
|
||||||
import com.simibubi.create.foundation.block.ITE;
|
import com.simibubi.create.foundation.block.ITE;
|
||||||
import com.simibubi.create.foundation.item.ItemDescription.Palette;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
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 {
|
public abstract class KineticBlock extends Block implements IRotate {
|
||||||
|
|
||||||
protected static final Palette color = Palette.Red;
|
|
||||||
|
|
||||||
public KineticBlock(Properties properties) {
|
public KineticBlock(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,6 @@ import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.utility.ContraptionData;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
import org.apache.commons.lang3.tuple.MutablePair;
|
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.mixin.accessor.ServerLevelAccessor;
|
||||||
import com.simibubi.create.foundation.networking.AllPackets;
|
import com.simibubi.create.foundation.networking.AllPackets;
|
||||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.ContraptionData;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
|
@ -4,10 +4,6 @@ import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
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 org.apache.commons.lang3.tuple.MutablePair;
|
||||||
|
|
||||||
import com.simibubi.create.AllItems;
|
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.advancement.AllAdvancements;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.config.ContraptionMovementSetting;
|
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.Lang;
|
||||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
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.DefaultDispenseItemBehavior;
|
||||||
import net.minecraft.core.dispenser.DispenseItemBehavior;
|
import net.minecraft.core.dispenser.DispenseItemBehavior;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.Entity;
|
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.AllTags.AllBlockTags;
|
||||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
||||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
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.core.BlockPos;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
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.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.IRegistryDelegate;
|
|
||||||
|
|
||||||
public class BoilerHeaters {
|
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<>();
|
private static final List<HeaterProvider> GLOBAL_HEATERS = new ArrayList<>();
|
||||||
|
|
||||||
public static void registerHeater(ResourceLocation block, Heater heater) {
|
public static void registerHeater(ResourceLocation block, Heater heater) {
|
||||||
|
@ -31,11 +30,6 @@ public class BoilerHeaters {
|
||||||
BLOCK_HEATERS.register(block, heater);
|
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) {
|
public static void registerHeaterProvider(HeaterProvider provider) {
|
||||||
GLOBAL_HEATERS.add(provider);
|
GLOBAL_HEATERS.add(provider);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.world.level.ItemLike;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||||
|
|
||||||
|
@ -220,29 +221,31 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@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()
|
if (!stack.hasTag() || !stack.getTag()
|
||||||
.contains("SequencedAssembly"))
|
.contains("SequencedAssembly"))
|
||||||
return;
|
return;
|
||||||
CompoundTag compound = stack.getTag()
|
CompoundTag compound = stack.getTag()
|
||||||
.getCompound("SequencedAssembly");
|
.getCompound("SequencedAssembly");
|
||||||
ResourceLocation resourceLocation = new ResourceLocation(compound.getString("id"));
|
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);
|
.byKey(resourceLocation);
|
||||||
if (!recipe.isPresent())
|
if (!optionalRecipe.isPresent())
|
||||||
return;
|
return;
|
||||||
Recipe<?> iRecipe = recipe.get();
|
Recipe<?> recipe = optionalRecipe.get();
|
||||||
if (!(iRecipe instanceof SequencedAssemblyRecipe))
|
if (!(recipe instanceof SequencedAssemblyRecipe))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SequencedAssemblyRecipe sequencedAssemblyRecipe = (SequencedAssemblyRecipe) iRecipe;
|
SequencedAssemblyRecipe sequencedAssemblyRecipe = (SequencedAssemblyRecipe) recipe;
|
||||||
int length = sequencedAssemblyRecipe.sequence.size();
|
int length = sequencedAssemblyRecipe.sequence.size();
|
||||||
int step = sequencedAssemblyRecipe.getStep(stack);
|
int step = sequencedAssemblyRecipe.getStep(stack);
|
||||||
int total = length * sequencedAssemblyRecipe.loops;
|
int total = length * sequencedAssemblyRecipe.loops;
|
||||||
toolTip.add(Components.immutableEmpty());
|
List<Component> tooltip = event.getToolTip();
|
||||||
toolTip.add(Lang.translateDirect("recipe.sequenced_assembly")
|
tooltip.add(Components.immutableEmpty());
|
||||||
|
tooltip.add(Lang.translateDirect("recipe.sequenced_assembly")
|
||||||
.withStyle(ChatFormatting.GRAY));
|
.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));
|
.withStyle(ChatFormatting.DARK_GRAY));
|
||||||
|
|
||||||
int remaining = total - step;
|
int remaining = total - step;
|
||||||
|
@ -253,10 +256,10 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
|
||||||
Component textComponent = sequencedRecipe.getAsAssemblyRecipe()
|
Component textComponent = sequencedRecipe.getAsAssemblyRecipe()
|
||||||
.getDescriptionForAssembly();
|
.getDescriptionForAssembly();
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
toolTip.add(Lang.translateDirect("recipe.assembly.next", textComponent)
|
tooltip.add(Lang.translateDirect("recipe.assembly.next", textComponent)
|
||||||
.withStyle(ChatFormatting.AQUA));
|
.withStyle(ChatFormatting.AQUA));
|
||||||
else
|
else
|
||||||
toolTip.add(Components.literal("-> ").append(textComponent)
|
tooltip.add(Components.literal("-> ").append(textComponent)
|
||||||
.withStyle(ChatFormatting.DARK_AQUA));
|
.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.content.contraptions.base.IRotate.StressImpact;
|
||||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
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.networking.AllPackets;
|
||||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||||
import com.simibubi.create.foundation.utility.Color;
|
import com.simibubi.create.foundation.utility.Color;
|
||||||
|
@ -86,7 +86,7 @@ public class StressGaugeTileEntity extends GaugeTileEntity {
|
||||||
.forGoggles(tooltip);
|
.forGoggles(tooltip);
|
||||||
|
|
||||||
if (getTheoreticalSpeed() == 0)
|
if (getTheoreticalSpeed() == 0)
|
||||||
Lang.text(ItemDescription.makeProgressBar(3, 0))
|
Lang.text(TooltipHelper.makeProgressBar(3, 0))
|
||||||
.translate("gui.stressometer.no_rotation")
|
.translate("gui.stressometer.no_rotation")
|
||||||
.style(ChatFormatting.DARK_GRAY)
|
.style(ChatFormatting.DARK_GRAY)
|
||||||
.forGoggles(tooltip);
|
.forGoggles(tooltip);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.simibubi.create.content.curiosities.weapons;
|
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.jozufozu.flywheel.util.transform.TransformStack;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
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.AllTags.AllBlockTags;
|
||||||
import com.simibubi.create.CreateClient;
|
import com.simibubi.create.CreateClient;
|
||||||
import com.simibubi.create.foundation.item.CustomArmPoseItem;
|
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.BlockHelper;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||||
|
@ -63,10 +62,9 @@ public abstract class ZapperItem extends Item implements CustomArmPoseItem {
|
||||||
.getCompound("BlockUsed"))
|
.getCompound("BlockUsed"))
|
||||||
.getBlock()
|
.getBlock()
|
||||||
.getName();
|
.getName();
|
||||||
ItemDescription.add(tooltip,
|
tooltip.add(Lang.translateDirect("terrainzapper.usingBlock",
|
||||||
Lang.translateDirect("terrainzapper.usingBlock",
|
usedBlock.withStyle(ChatFormatting.GRAY))
|
||||||
usedBlock.withStyle(ChatFormatting.GRAY))
|
.withStyle(ChatFormatting.DARK_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.DisplayTarget;
|
||||||
import com.simibubi.create.content.logistics.block.display.target.LecternDisplayTarget;
|
import com.simibubi.create.content.logistics.block.display.target.LecternDisplayTarget;
|
||||||
import com.simibubi.create.content.logistics.block.display.target.SignDisplayTarget;
|
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.simibubi.create.foundation.utility.RegisteredObjects;
|
||||||
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
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.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.IRegistryDelegate;
|
|
||||||
|
|
||||||
public class AllDisplayBehaviours {
|
public class AllDisplayBehaviours {
|
||||||
public static final Map<ResourceLocation, DisplayBehaviour> GATHERER_BEHAVIOURS = new HashMap<>();
|
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 AttachedRegistry<Block, List<DisplaySource>> SOURCES_BY_BLOCK = new AttachedRegistry<>(ForgeRegistries.BLOCKS);
|
||||||
private static final CreateRegistry<BlockEntityType<?>, List<DisplaySource>> SOURCES_BY_TILE = new CreateRegistry<>(ForgeRegistries.BLOCK_ENTITIES);
|
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 AttachedRegistry<Block, DisplayTarget> TARGETS_BY_BLOCK = new AttachedRegistry<>(ForgeRegistries.BLOCKS);
|
||||||
private static final CreateRegistry<BlockEntityType<?>, DisplayTarget> TARGETS_BY_TILE = new CreateRegistry<>(ForgeRegistries.BLOCK_ENTITIES);
|
private static final AttachedRegistry<BlockEntityType<?>, DisplayTarget> TARGETS_BY_TILE = new AttachedRegistry<>(ForgeRegistries.BLOCK_ENTITIES);
|
||||||
|
|
||||||
public static DisplayBehaviour register(ResourceLocation id, DisplayBehaviour behaviour) {
|
public static DisplayBehaviour register(ResourceLocation id, DisplayBehaviour behaviour) {
|
||||||
behaviour.id = id;
|
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,
|
public static <B extends Block> NonNullConsumer<? super B> assignDataBehaviour(DisplayBehaviour behaviour,
|
||||||
String... suffix) {
|
String... suffix) {
|
||||||
return b -> {
|
return b -> {
|
||||||
|
|
|
@ -104,7 +104,7 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
|
||||||
button.setToolTip(button.getToolTip()
|
button.setToolTip(button.getToolTip()
|
||||||
.get(0));
|
.get(0));
|
||||||
button.getToolTip()
|
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.AllKeys;
|
||||||
import com.simibubi.create.content.contraptions.processing.EmptyingByBasin;
|
import com.simibubi.create.content.contraptions.processing.EmptyingByBasin;
|
||||||
import com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer.WhitelistMode;
|
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.Components;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
|
||||||
|
@ -75,8 +74,8 @@ public class FilterItem extends Item implements MenuProvider {
|
||||||
List<Component> makeSummary = makeSummary(stack);
|
List<Component> makeSummary = makeSummary(stack);
|
||||||
if (makeSummary.isEmpty())
|
if (makeSummary.isEmpty())
|
||||||
return;
|
return;
|
||||||
ItemDescription.add(tooltip, Components.literal(" "));
|
tooltip.add(Components.literal(" "));
|
||||||
ItemDescription.add(tooltip, makeSummary);
|
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.AllSpriteShifts;
|
||||||
import com.simibubi.create.Create;
|
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.HorizontalCTBehaviour;
|
||||||
import com.simibubi.create.foundation.block.connected.SimpleCTBehaviour;
|
import com.simibubi.create.foundation.block.connected.SimpleCTBehaviour;
|
||||||
import com.simibubi.create.foundation.data.BlockStateGen;
|
import com.simibubi.create.foundation.data.BlockStateGen;
|
||||||
|
@ -31,9 +30,7 @@ import net.minecraftforge.common.Tags;
|
||||||
public class AllPaletteBlocks {
|
public class AllPaletteBlocks {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
REGISTRATE
|
REGISTRATE.creativeModeTab(() -> Create.PALETTES_CREATIVE_TAB);
|
||||||
.creativeModeTab(() -> Create.PALETTES_CREATIVE_TAB)
|
|
||||||
.startSection(AllSections.PALETTES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Windows and Glass
|
// 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()
|
button.setToolTip(button.getToolTip()
|
||||||
.get(0));
|
.get(0));
|
||||||
button.getToolTip()
|
button.getToolTip()
|
||||||
.add(TooltipHelper.holdShift(Palette.Blue, hasShiftDown()));
|
.add(TooltipHelper.holdShift(Palette.BLUE, hasShiftDown()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package com.simibubi.create.events;
|
package com.simibubi.create.events;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.simibubi.create.AllFluids;
|
import com.simibubi.create.AllFluids;
|
||||||
|
@ -10,9 +7,7 @@ import com.simibubi.create.AllItems;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.CreateClient;
|
import com.simibubi.create.CreateClient;
|
||||||
import com.simibubi.create.content.contraptions.KineticDebugger;
|
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.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.ContraptionHandler;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisRangeDisplay;
|
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisRangeDisplay;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.interaction.controls.ControlsHandler;
|
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.AllConfigs;
|
||||||
import com.simibubi.create.foundation.config.ui.BaseConfigScreen;
|
import com.simibubi.create.foundation.config.ui.BaseConfigScreen;
|
||||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||||
import com.simibubi.create.foundation.item.ItemDescription;
|
import com.simibubi.create.foundation.item.ItemTooltipHandler;
|
||||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
|
||||||
import com.simibubi.create.foundation.networking.AllPackets;
|
import com.simibubi.create.foundation.networking.AllPackets;
|
||||||
import com.simibubi.create.foundation.networking.LeftClickPacket;
|
import com.simibubi.create.foundation.networking.LeftClickPacket;
|
||||||
import com.simibubi.create.foundation.ponder.PonderTooltipHandler;
|
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.tileEntity.behaviour.scrollvalue.ScrollValueRenderer;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.CameraAngleAnimationService;
|
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.ServerSpeedProvider;
|
||||||
import com.simibubi.create.foundation.utility.placement.PlacementHelpers;
|
import com.simibubi.create.foundation.utility.placement.PlacementHelpers;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.WrappedClientWorld;
|
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.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||||
import net.minecraft.core.BlockPos;
|
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.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
|
@ -105,9 +96,6 @@ import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
|
||||||
@EventBusSubscriber(Dist.CLIENT)
|
@EventBusSubscriber(Dist.CLIENT)
|
||||||
public class ClientEvents {
|
public class ClientEvents {
|
||||||
|
|
||||||
private static final String ITEM_PREFIX = "item." + Create.ID;
|
|
||||||
private static final String BLOCK_PREFIX = "block." + Create.ID;
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onTick(ClientTickEvent event) {
|
public static void onTick(ClientTickEvent event) {
|
||||||
if (!isGameActive())
|
if (!isGameActive())
|
||||||
|
@ -251,35 +239,9 @@ public class ClientEvents {
|
||||||
if (event.getPlayer() == null)
|
if (event.getPlayer() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ItemStack stack = event.getItemStack();
|
ItemTooltipHandler.addToTooltip(event);
|
||||||
String translationKey = stack.getItem()
|
PonderTooltipHandler.addToTooltip(event);
|
||||||
.getDescriptionId(stack);
|
SequencedAssemblyRecipe.addToTooltip(event);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -74,6 +74,16 @@ public class BlockStressValues {
|
||||||
return BlockStressDefaults.DEFAULT_CAPACITIES.containsKey(blockId);
|
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 {
|
public interface IStressValueProvider {
|
||||||
/**
|
/**
|
||||||
* Gets the stress impact of a block.
|
* Gets the stress impact of a block.
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
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.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
@ -17,7 +17,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||||
public enum ContraptionMovementSetting {
|
public enum ContraptionMovementSetting {
|
||||||
MOVABLE, NO_PICKUP, UNMOVABLE;
|
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) {
|
public static void register(ResourceLocation block, Supplier<ContraptionMovementSetting> settingSupplier) {
|
||||||
SETTING_SUPPLIERS.register(block, settingSupplier);
|
SETTING_SUPPLIERS.register(block, settingSupplier);
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.util.function.Supplier;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllTags;
|
|
||||||
import com.simibubi.create.AllTags.AllBlockTags;
|
import com.simibubi.create.AllTags.AllBlockTags;
|
||||||
import com.simibubi.create.AllTags.AllItemTags;
|
import com.simibubi.create.AllTags.AllItemTags;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
|
@ -117,7 +116,7 @@ public class BuilderTransformers {
|
||||||
.addLayer(() -> RenderType::translucent)
|
.addLayer(() -> RenderType::translucent)
|
||||||
.color(() -> CopycatBlock::wrappedColor)
|
.color(() -> CopycatBlock::wrappedColor)
|
||||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||||
.transform(AllTags.axeOrPickaxe());
|
.transform(TagGen.axeOrPickaxe());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <B extends TrapDoorBlock, P> NonNullUnaryOperator<BlockBuilder<B, P>> trapdoor(boolean orientable) {
|
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 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.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.CreateClient;
|
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.fluids.VirtualFluid;
|
||||||
import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity;
|
import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity;
|
||||||
import com.simibubi.create.foundation.block.connected.CTModel;
|
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.AbstractRegistrate;
|
||||||
import com.tterrag.registrate.builders.BlockBuilder;
|
import com.tterrag.registrate.builders.BlockBuilder;
|
||||||
import com.tterrag.registrate.builders.BlockEntityBuilder.BlockEntityFactory;
|
import com.tterrag.registrate.builders.BlockEntityBuilder.BlockEntityFactory;
|
||||||
import com.tterrag.registrate.builders.Builder;
|
|
||||||
import com.tterrag.registrate.builders.FluidBuilder;
|
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.NonNullBiFunction;
|
||||||
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
||||||
import com.tterrag.registrate.util.nullness.NonNullFunction;
|
import com.tterrag.registrate.util.nullness.NonNullFunction;
|
||||||
import com.tterrag.registrate.util.nullness.NonNullSupplier;
|
import com.tterrag.registrate.util.nullness.NonNullSupplier;
|
||||||
|
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
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.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.world.entity.Entity;
|
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.FluidAttributes;
|
||||||
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
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> {
|
public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
||||||
protected CreateRegistrate(String modid) {
|
protected CreateRegistrate(String modid) {
|
||||||
|
@ -62,66 +49,11 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
||||||
return new CreateRegistrate(modid);
|
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
|
@Override
|
||||||
public CreateRegistrate registerEventListeners(IEventBus bus) {
|
public CreateRegistrate registerEventListeners(IEventBus bus) {
|
||||||
return super.registerEventListeners(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,
|
public <T extends BlockEntity> CreateTileEntityBuilder<T, CreateRegistrate> tileEntity(String name,
|
||||||
BlockEntityFactory<T> factory) {
|
BlockEntityFactory<T> factory) {
|
||||||
return this.tileEntity(this.self(), name, 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;
|
||||||
import com.simibubi.create.AllTags.AllItemTags;
|
import com.simibubi.create.AllTags.AllItemTags;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.content.AllSections;
|
|
||||||
import com.simibubi.create.content.palettes.AllPaletteBlocks;
|
import com.simibubi.create.content.palettes.AllPaletteBlocks;
|
||||||
import com.simibubi.create.content.palettes.AllPaletteStoneTypes;
|
import com.simibubi.create.content.palettes.AllPaletteStoneTypes;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
|
||||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||||
import com.tterrag.registrate.util.entry.BlockEntry;
|
import com.tterrag.registrate.util.entry.BlockEntry;
|
||||||
import com.tterrag.registrate.util.entry.ItemEntry;
|
import com.tterrag.registrate.util.entry.ItemEntry;
|
||||||
|
@ -68,7 +66,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
||||||
* (Ctrl-o) in Eclipse
|
* (Ctrl-o) in Eclipse
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Marker MATERIALS = enterSection(AllSections.MATERIALS);
|
private Marker MATERIALS = enterFolder("materials");
|
||||||
|
|
||||||
GeneratedRecipe
|
GeneratedRecipe
|
||||||
|
|
||||||
|
@ -136,7 +134,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private Marker CURIOSITIES = enterSection(AllSections.CURIOSITIES);
|
private Marker CURIOSITIES = enterFolder("curiosities");
|
||||||
|
|
||||||
GeneratedRecipe
|
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)
|
GeneratedRecipe ANDESITE_LADDER = create(AllBlocks.ANDESITE_LADDER).returns(4)
|
||||||
.unlockedBy(I::andesite)
|
.unlockedBy(I::andesite)
|
||||||
|
@ -829,7 +827,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private Marker LOGISTICS = enterSection(AllSections.LOGISTICS);
|
private Marker LOGISTICS = enterFolder("logistics");
|
||||||
|
|
||||||
GeneratedRecipe
|
GeneratedRecipe
|
||||||
|
|
||||||
|
@ -935,7 +933,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private Marker SCHEMATICS = enterSection(AllSections.SCHEMATICS);
|
private Marker SCHEMATICS = enterFolder("schematics");
|
||||||
|
|
||||||
GeneratedRecipe
|
GeneratedRecipe
|
||||||
|
|
||||||
|
@ -965,7 +963,7 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private Marker PALETTES = enterSection(AllSections.PALETTES);
|
private Marker PALETTES = enterFolder("palettes");
|
||||||
|
|
||||||
GeneratedRecipe
|
GeneratedRecipe
|
||||||
|
|
||||||
|
@ -1086,11 +1084,6 @@ public class StandardRecipeGen extends CreateRecipeProvider {
|
||||||
|
|
||||||
String currentFolder = "";
|
String currentFolder = "";
|
||||||
|
|
||||||
Marker enterSection(AllSections section) {
|
|
||||||
currentFolder = Lang.asId(section.name());
|
|
||||||
return new Marker();
|
|
||||||
}
|
|
||||||
|
|
||||||
Marker enterFolder(String folder) {
|
Marker enterFolder(String folder) {
|
||||||
currentFolder = folder;
|
currentFolder = folder;
|
||||||
return new Marker();
|
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,289 +1,197 @@
|
||||||
package com.simibubi.create.foundation.item;
|
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_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.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.WHITE;
|
||||||
import static net.minecraft.ChatFormatting.YELLOW;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import com.simibubi.create.content.contraptions.base.IRotate.StressImpact;
|
|
||||||
import com.simibubi.create.content.contraptions.goggles.GogglesItem;
|
import com.google.common.collect.ImmutableList;
|
||||||
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.Components;
|
||||||
import com.simibubi.create.foundation.utility.Couple;
|
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.foundation.utility.LangBuilder;
|
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
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.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
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 Builder builder() {
|
||||||
public static Component trim = Components.literal(" ").withStyle(WHITE, STRIKETHROUGH);
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
public enum Palette {
|
public static ItemDescription create(Palette palette, String translationKey) {
|
||||||
|
if (!I18n.exists(translationKey)) {
|
||||||
Blue(BLUE, AQUA),
|
return MISSING;
|
||||||
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 ChatFormatting color;
|
Builder builder = builder();
|
||||||
public ChatFormatting hColor;
|
builder.palette(palette);
|
||||||
}
|
|
||||||
|
|
||||||
private List<Component> lines;
|
// Summary
|
||||||
private List<Component> linesOnShift;
|
String summaryKey = translationKey + ".summary";
|
||||||
private List<Component> linesOnCtrl;
|
if (I18n.exists(summaryKey)) {
|
||||||
private Palette palette;
|
builder.addSummary(I18n.get(summaryKey));
|
||||||
|
|
||||||
public ItemDescription(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<>();
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasStressImpact =
|
// Behaviours
|
||||||
StressImpact.isEnabled() && showStressImpact && BlockStressValues.getImpact(block) > 0;
|
for (int i = 1; i < 100; i++) {
|
||||||
boolean hasStressCapacity = StressImpact.isEnabled() && BlockStressValues.hasCapacity(block);
|
String conditionKey = translationKey + ".condition" + i;
|
||||||
|
String behaviourKey = translationKey + ".behaviour" + i;
|
||||||
if (hasStressImpact) {
|
if (!I18n.exists(conditionKey))
|
||||||
Lang.translate("tooltip.stressImpact")
|
break;
|
||||||
.style(GRAY)
|
builder.addBehaviour(I18n.get(conditionKey), I18n.get(behaviourKey));
|
||||||
.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 (hasStressCapacity) {
|
// Actions
|
||||||
Lang.translate("tooltip.capacityProvided")
|
for (int i = 1; i < 100; i++) {
|
||||||
.style(GRAY)
|
String controlKey = translationKey + ".control" + i;
|
||||||
.addTo(list);
|
String actionKey = translationKey + ".action" + i;
|
||||||
|
if (!I18n.exists(controlKey))
|
||||||
double capacity = BlockStressValues.getCapacity(block);
|
break;
|
||||||
BlockStressValues.IStressValueProvider stressProvider = BlockStressValues.getProvider(block);
|
builder.addAction(I18n.get(controlKey), I18n.get(actionKey));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String makeProgressBar(int length, int filledLength) {
|
public void addInformation(List<Component> tooltip) {
|
||||||
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();
|
|
||||||
|
|
||||||
if (hasDescription || hasControls) {
|
|
||||||
String[] holdDesc = Lang.translateDirect("tooltip.holdForDescription", "$")
|
|
||||||
.getString()
|
|
||||||
.split("\\$");
|
|
||||||
String[] holdCtrl = Lang.translateDirect("tooltip.holdForControls", "$")
|
|
||||||
.getString()
|
|
||||||
.split("\\$");
|
|
||||||
MutableComponent keyShift = Lang.translateDirect("tooltip.keyShift");
|
|
||||||
MutableComponent keyCtrl = Lang.translateDirect("tooltip.keyCtrl");
|
|
||||||
for (List<Component> list : Arrays.asList(lines, linesOnShift, linesOnCtrl)) {
|
|
||||||
boolean shift = list == linesOnShift;
|
|
||||||
boolean ctrl = list == linesOnCtrl;
|
|
||||||
|
|
||||||
if (holdDesc.length != 2 || holdCtrl.length != 2) {
|
|
||||||
list.add(0, Components.literal("Invalid lang formatting!"));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasControls) {
|
|
||||||
MutableComponent tabBuilder = Components.empty();
|
|
||||||
tabBuilder.append(Components.literal(holdCtrl[0]).withStyle(DARK_GRAY));
|
|
||||||
tabBuilder.append(keyCtrl.plainCopy()
|
|
||||||
.withStyle(ctrl ? WHITE : GRAY));
|
|
||||||
tabBuilder.append(Components.literal(holdCtrl[1]).withStyle(DARK_GRAY));
|
|
||||||
list.add(0, tabBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasDescription) {
|
|
||||||
MutableComponent tabBuilder = Components.empty();
|
|
||||||
tabBuilder.append(Components.literal(holdDesc[0]).withStyle(DARK_GRAY));
|
|
||||||
tabBuilder.append(keyShift.plainCopy()
|
|
||||||
.withStyle(shift ? WHITE : GRAY));
|
|
||||||
tabBuilder.append(Components.literal(holdDesc[1]).withStyle(DARK_GRAY));
|
|
||||||
list.add(0, tabBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shift || ctrl)
|
|
||||||
list.add(hasDescription && hasControls ? 2 : 1, Components.immutableEmpty());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasDescription)
|
|
||||||
linesOnShift = lines;
|
|
||||||
if (!hasControls)
|
|
||||||
linesOnCtrl = lines;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String hightlight(String s, Palette palette) {
|
|
||||||
return palette.hColor + s + palette.color;
|
|
||||||
}
|
|
||||||
|
|
||||||
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()) {
|
if (Screen.hasShiftDown()) {
|
||||||
tooltip.addAll(linesOnShift);
|
tooltip.addAll(linesOnShift);
|
||||||
return tooltip;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Screen.hasControlDown()) {
|
if (Screen.hasControlDown()) {
|
||||||
tooltip.addAll(linesOnCtrl);
|
tooltip.addAll(linesOnCtrl);
|
||||||
return tooltip;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tooltip.addAll(lines);
|
tooltip.addAll(lines);
|
||||||
return tooltip;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Component> getLines() {
|
public record Palette(ChatFormatting primary, ChatFormatting highlight) {
|
||||||
return lines;
|
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 List<Component> getLinesOnCtrl() {
|
public static class Builder {
|
||||||
return linesOnCtrl;
|
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 List<Component> getLinesOnShift() {
|
public Builder addSummary(String summaryLine) {
|
||||||
return linesOnShift;
|
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;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemDescription build() {
|
||||||
|
List<Component> lines = new ArrayList<>();
|
||||||
|
List<Component> linesOnShift = new ArrayList<>();
|
||||||
|
List<Component> linesOnCtrl = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String summaryLine : summary) {
|
||||||
|
linesOnShift.addAll(TooltipHelper.cutTextComponent(Components.literal(summaryLine), palette.primary(), palette.highlight()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!behaviours.isEmpty()) {
|
||||||
|
linesOnShift.add(Components.immutableEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean hasDescription = !linesOnShift.isEmpty();
|
||||||
|
boolean hasControls = !linesOnCtrl.isEmpty();
|
||||||
|
|
||||||
|
if (hasDescription || hasControls) {
|
||||||
|
String[] holdDesc = Lang.translateDirect("tooltip.holdForDescription", "$")
|
||||||
|
.getString()
|
||||||
|
.split("\\$");
|
||||||
|
String[] holdCtrl = Lang.translateDirect("tooltip.holdForControls", "$")
|
||||||
|
.getString()
|
||||||
|
.split("\\$");
|
||||||
|
MutableComponent keyShift = Lang.translateDirect("tooltip.keyShift");
|
||||||
|
MutableComponent keyCtrl = Lang.translateDirect("tooltip.keyCtrl");
|
||||||
|
for (List<Component> list : Arrays.asList(lines, linesOnShift, linesOnCtrl)) {
|
||||||
|
boolean shift = list == linesOnShift;
|
||||||
|
boolean ctrl = list == linesOnCtrl;
|
||||||
|
|
||||||
|
if (holdDesc.length != 2 || holdCtrl.length != 2) {
|
||||||
|
list.add(0, Components.literal("Invalid lang formatting!"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasControls) {
|
||||||
|
MutableComponent tabBuilder = Components.empty();
|
||||||
|
tabBuilder.append(Components.literal(holdCtrl[0]).withStyle(DARK_GRAY));
|
||||||
|
tabBuilder.append(keyCtrl.plainCopy()
|
||||||
|
.withStyle(ctrl ? WHITE : GRAY));
|
||||||
|
tabBuilder.append(Components.literal(holdCtrl[1]).withStyle(DARK_GRAY));
|
||||||
|
list.add(0, tabBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasDescription) {
|
||||||
|
MutableComponent tabBuilder = Components.empty();
|
||||||
|
tabBuilder.append(Components.literal(holdDesc[0]).withStyle(DARK_GRAY));
|
||||||
|
tabBuilder.append(keyShift.plainCopy()
|
||||||
|
.withStyle(shift ? WHITE : GRAY));
|
||||||
|
tabBuilder.append(Components.literal(holdDesc[1]).withStyle(DARK_GRAY));
|
||||||
|
list.add(0, tabBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shift || ctrl)
|
||||||
|
list.add(hasDescription && hasControls ? 2 : 1, Components.immutableEmpty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasDescription) {
|
||||||
|
linesOnCtrl.clear();
|
||||||
|
linesOnShift.addAll(lines);
|
||||||
|
}
|
||||||
|
if (!hasControls) {
|
||||||
|
linesOnCtrl.clear();
|
||||||
|
linesOnCtrl.addAll(lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ItemDescription(ImmutableList.copyOf(lines), ImmutableList.copyOf(linesOnShift), ImmutableList.copyOf(linesOnCtrl));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.text.BreakIterator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
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.content.contraptions.goggles.IHaveGoggleInformation;
|
||||||
import com.simibubi.create.foundation.item.ItemDescription.Palette;
|
import com.simibubi.create.foundation.item.ItemDescription.Palette;
|
||||||
import com.simibubi.create.foundation.utility.Components;
|
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.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.resources.language.I18n;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
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;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
|
|
||||||
public class TooltipHelper {
|
public class TooltipHelper {
|
||||||
|
|
||||||
public static final int maxWidthPerLine = 200;
|
public static final int MAX_WIDTH_PER_LINE = 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 MutableComponent holdShift(Palette color, boolean highlighted) {
|
public static MutableComponent holdShift(Palette color, boolean highlighted) {
|
||||||
return Lang.translateDirect("tooltip.holdForDescription", Lang.translateDirect("tooltip.keyShift")
|
return Lang.translateDirect("tooltip.holdForDescription", Lang.translateDirect("tooltip.keyShift")
|
||||||
|
@ -57,14 +42,14 @@ public class TooltipHelper {
|
||||||
.append(component));
|
.append(component));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void referTo(ItemLike item, Supplier<? extends ItemLike> itemWithTooltip) {
|
public static String makeProgressBar(int length, int filledLength) {
|
||||||
tooltipReferrals.put(item.asItem(), () -> itemWithTooltip.get()
|
String bar = " ";
|
||||||
.asItem()
|
int emptySpaces = length - filledLength;
|
||||||
.getDescriptionId());
|
for (int i = 0; i < filledLength; i++)
|
||||||
}
|
bar += "\u2588";
|
||||||
|
for (int i = 0; i < emptySpaces; i++)
|
||||||
public static void referTo(ItemLike item, String string) {
|
bar += "\u2592";
|
||||||
tooltipReferrals.put(item.asItem(), () -> string);
|
return bar + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -89,7 +74,7 @@ public class TooltipHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
Font font = Minecraft.getInstance().font;
|
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
|
// Format
|
||||||
String lineStart = Strings.repeat(" ", indent);
|
String lineStart = Strings.repeat(" ", indent);
|
||||||
|
@ -142,7 +127,7 @@ public class TooltipHelper {
|
||||||
int width = 0;
|
int width = 0;
|
||||||
for (String word : words) {
|
for (String word : words) {
|
||||||
int newWidth = font.width(word.replaceAll("_", ""));
|
int newWidth = font.width(word.replaceAll("_", ""));
|
||||||
if (width + newWidth > maxWidthPerLine) {
|
if (width + newWidth > MAX_WIDTH_PER_LINE) {
|
||||||
if (width > 0) {
|
if (width > 0) {
|
||||||
String line = currentLine.toString();
|
String line = currentLine.toString();
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
|
@ -221,102 +206,6 @@ public class TooltipHelper {
|
||||||
// return lines;
|
// 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) {
|
// private static int getComponentLength(ITextComponent component) {
|
||||||
// AtomicInteger l = new AtomicInteger();
|
// AtomicInteger l = new AtomicInteger();
|
||||||
// TextProcessing.visitFormatted(component, Style.EMPTY, (s, style, charConsumer) -> {
|
// TextProcessing.visitFormatted(component, Style.EMPTY, (s, style, charConsumer) -> {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.simibubi.create.foundation.mixin.accessor;
|
package com.simibubi.create.foundation.mixin.accessor;
|
||||||
|
|
||||||
import net.minecraft.nbt.NbtAccounter;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NbtAccounter;
|
||||||
|
|
||||||
@Mixin(NbtAccounter.class)
|
@Mixin(NbtAccounter.class)
|
||||||
public interface NbtAccounterAccessor {
|
public interface NbtAccounterAccessor {
|
||||||
@Accessor("usage")
|
@Accessor("usage")
|
||||||
|
|
|
@ -22,6 +22,7 @@ import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||||
|
|
||||||
public class PonderTooltipHandler {
|
public class PonderTooltipHandler {
|
||||||
|
|
||||||
|
@ -73,10 +74,12 @@ public class PonderTooltipHandler {
|
||||||
hoveredStack = ItemStack.EMPTY;
|
hoveredStack = ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addToTooltip(List<Component> toolTip, ItemStack stack) {
|
public static void addToTooltip(ItemTooltipEvent event) {
|
||||||
if (!enable)
|
if (!enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ItemStack stack = event.getItemStack();
|
||||||
|
|
||||||
updateHovered(stack);
|
updateHovered(stack);
|
||||||
|
|
||||||
if (deferTick)
|
if (deferTick)
|
||||||
|
@ -90,10 +93,11 @@ public class PonderTooltipHandler {
|
||||||
Component component = subject ? Lang.translateDirect(SUBJECT)
|
Component component = subject ? Lang.translateDirect(SUBJECT)
|
||||||
.withStyle(ChatFormatting.GREEN)
|
.withStyle(ChatFormatting.GREEN)
|
||||||
: makeProgressBar(Math.min(1, holdWProgress.getValue(renderPartialTicks) * 8 / 7f));
|
: makeProgressBar(Math.min(1, holdWProgress.getValue(renderPartialTicks) * 8 / 7f));
|
||||||
if (toolTip.size() < 2)
|
List<Component> tooltip = event.getToolTip();
|
||||||
toolTip.add(component);
|
if (tooltip.size() < 2)
|
||||||
|
tooltip.add(component);
|
||||||
else
|
else
|
||||||
toolTip.add(1, component);
|
tooltip.add(1, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void updateHovered(ItemStack stack) {
|
protected static void updateHovered(ItemStack stack) {
|
||||||
|
|
|
@ -14,15 +14,15 @@ import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.registries.IForgeRegistry;
|
import net.minecraftforge.registries.IForgeRegistry;
|
||||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||||
|
|
||||||
public class CreateRegistry<K extends IForgeRegistryEntry<K>, V> {
|
public class AttachedRegistry<K extends IForgeRegistryEntry<K>, V> {
|
||||||
private static final List<CreateRegistry<?, ?>> ALL = new ArrayList<>();
|
private static final List<AttachedRegistry<?, ?>> ALL = new ArrayList<>();
|
||||||
|
|
||||||
protected final IForgeRegistry<K> objectRegistry;
|
protected final IForgeRegistry<K> objectRegistry;
|
||||||
protected final Map<ResourceLocation, V> locationMap = new HashMap<>();
|
protected final Map<ResourceLocation, V> locationMap = new HashMap<>();
|
||||||
protected final Map<K, V> objectMap = new IdentityHashMap<>();
|
protected final Map<K, V> objectMap = new IdentityHashMap<>();
|
||||||
protected boolean unwrapped = false;
|
protected boolean unwrapped = false;
|
||||||
|
|
||||||
public CreateRegistry(IForgeRegistry<K> objectRegistry) {
|
public AttachedRegistry(IForgeRegistry<K> objectRegistry) {
|
||||||
this.objectRegistry = objectRegistry;
|
this.objectRegistry = objectRegistry;
|
||||||
ALL.add(this);
|
ALL.add(this);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class CreateRegistry<K extends IForgeRegistryEntry<K>, V> {
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
objectMap.put(object, value);
|
objectMap.put(object, value);
|
||||||
} else {
|
} 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) {
|
if (location != null) {
|
||||||
locationMap.put(location, value);
|
locationMap.put(location, value);
|
||||||
} else {
|
} 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) {
|
if (object != null) {
|
||||||
return objectMap.get(object);
|
return objectMap.get(object);
|
||||||
} else {
|
} 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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ public class CreateRegistry<K extends IForgeRegistryEntry<K>, V> {
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
return locationMap.get(location);
|
return locationMap.get(location);
|
||||||
} else {
|
} 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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,14 +94,14 @@ public class CreateRegistry<K extends IForgeRegistryEntry<K>, V> {
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
objectMap.put(object, entry.getValue());
|
objectMap.put(object, entry.getValue());
|
||||||
} else {
|
} 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;
|
unwrapped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unwrapAll() {
|
public static void unwrapAll() {
|
||||||
for (CreateRegistry<?, ?> registry : ALL) {
|
for (AttachedRegistry<?, ?> registry : ALL) {
|
||||||
registry.unwrap();
|
registry.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,6 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtAccounter;
|
import net.minecraft.nbt.NbtAccounter;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraftforge.fml.ModList;
|
|
||||||
|
|
||||||
public class ContraptionData {
|
public class ContraptionData {
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue