Registries and components

- Abstract all custom registries behind improved CreateRegistry class
- Remove usage of ForgeRegistryEntry.delegate and IRegistryDelegate
where possible
- Replace usage of IForgeRegistryEntry#getRegistryName with
RegisteredObjects#getKeyOrThrow where key is expected to be not null
- Move all component creation to the Components class
- Backport some other miscellaneous changes from 1.19
This commit is contained in:
PepperCode1 2022-08-03 10:08:00 -07:00
parent 826e29f0f3
commit 9c8df2ff27
199 changed files with 1171 additions and 822 deletions

View file

@ -172,7 +172,7 @@ import com.simibubi.create.content.logistics.block.display.source.FluidListDispl
import com.simibubi.create.content.logistics.block.display.source.ItemCountDisplaySource; import com.simibubi.create.content.logistics.block.display.source.ItemCountDisplaySource;
import com.simibubi.create.content.logistics.block.display.source.ItemListDisplaySource; import com.simibubi.create.content.logistics.block.display.source.ItemListDisplaySource;
import com.simibubi.create.content.logistics.block.display.source.ItemNameDisplaySource; import com.simibubi.create.content.logistics.block.display.source.ItemNameDisplaySource;
import com.simibubi.create.content.logistics.block.display.source.ItemThoughputDisplaySource; import com.simibubi.create.content.logistics.block.display.source.ItemThroughputDisplaySource;
import com.simibubi.create.content.logistics.block.display.source.KineticSpeedDisplaySource; import com.simibubi.create.content.logistics.block.display.source.KineticSpeedDisplaySource;
import com.simibubi.create.content.logistics.block.display.source.KineticStressDisplaySource; import com.simibubi.create.content.logistics.block.display.source.KineticStressDisplaySource;
import com.simibubi.create.content.logistics.block.display.source.ObservedTrainNameSource; import com.simibubi.create.content.logistics.block.display.source.ObservedTrainNameSource;
@ -1696,7 +1696,7 @@ public class AllBlocks {
.properties(p -> p.color(MaterialColor.STONE)) .properties(p -> p.color(MaterialColor.STONE))
.transform(BuilderTransformers.beltTunnel("andesite", new ResourceLocation("block/polished_andesite"))) .transform(BuilderTransformers.beltTunnel("andesite", new ResourceLocation("block/polished_andesite")))
.onRegister(assignDataBehaviour(new AccumulatedItemCountDisplaySource(), "accumulate_items")) .onRegister(assignDataBehaviour(new AccumulatedItemCountDisplaySource(), "accumulate_items"))
.onRegister(assignDataBehaviour(new ItemThoughputDisplaySource(), "item_throughput")) .onRegister(assignDataBehaviour(new ItemThroughputDisplaySource(), "item_throughput"))
.register(); .register();
public static final BlockEntry<BrassTunnelBlock> BRASS_TUNNEL = public static final BlockEntry<BrassTunnelBlock> BRASS_TUNNEL =
@ -1704,7 +1704,7 @@ public class AllBlocks {
.properties(p -> p.color(MaterialColor.TERRACOTTA_YELLOW)) .properties(p -> p.color(MaterialColor.TERRACOTTA_YELLOW))
.transform(BuilderTransformers.beltTunnel("brass", Create.asResource("block/brass_block"))) .transform(BuilderTransformers.beltTunnel("brass", Create.asResource("block/brass_block")))
.onRegister(assignDataBehaviour(new AccumulatedItemCountDisplaySource(), "accumulate_items")) .onRegister(assignDataBehaviour(new AccumulatedItemCountDisplaySource(), "accumulate_items"))
.onRegister(assignDataBehaviour(new ItemThoughputDisplaySource(), "item_throughput")) .onRegister(assignDataBehaviour(new ItemThroughputDisplaySource(), "item_throughput"))
.onRegister(connectedTextures(BrassTunnelCTBehaviour::new)) .onRegister(connectedTextures(BrassTunnelCTBehaviour::new))
.register(); .register();

View file

@ -1,9 +1,7 @@
package com.simibubi.create; package com.simibubi.create;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -11,20 +9,32 @@ 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.tterrag.registrate.util.nullness.NonNullConsumer; import com.tterrag.registrate.util.nullness.NonNullConsumer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.Block; 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.IRegistryDelegate; import net.minecraftforge.registries.IRegistryDelegate;
public class AllInteractionBehaviours { public class AllInteractionBehaviours {
private static final Map<IRegistryDelegate<Block>, MovingInteractionBehaviour> BLOCK_BEHAVIOURS = new HashMap<>(); private static final CreateRegistry<Block, MovingInteractionBehaviour> BLOCK_BEHAVIOURS = new CreateRegistry<>(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) {
BLOCK_BEHAVIOURS.register(block, provider);
}
public static void registerBehaviour(Block block, MovingInteractionBehaviour provider) {
BLOCK_BEHAVIOURS.register(block, provider);
}
@Deprecated(forRemoval = true)
public static void registerBehaviour(IRegistryDelegate<Block> block, MovingInteractionBehaviour provider) { public static void registerBehaviour(IRegistryDelegate<Block> block, MovingInteractionBehaviour provider) {
BLOCK_BEHAVIOURS.put(block, provider); registerBehaviour(block.name(), provider);
} }
public static void registerBehaviourProvider(BehaviourProvider provider) { public static void registerBehaviourProvider(BehaviourProvider provider) {
@ -33,7 +43,7 @@ public class AllInteractionBehaviours {
@Nullable @Nullable
public static MovingInteractionBehaviour getBehaviour(BlockState state) { public static MovingInteractionBehaviour getBehaviour(BlockState state) {
MovingInteractionBehaviour behaviour = BLOCK_BEHAVIOURS.get(state.getBlock().delegate); MovingInteractionBehaviour behaviour = BLOCK_BEHAVIOURS.get(state.getBlock());
if (behaviour != null) { if (behaviour != null) {
return behaviour; return behaviour;
} }
@ -50,11 +60,11 @@ public class AllInteractionBehaviours {
public static <B extends Block> NonNullConsumer<? super B> interactionBehaviour( public static <B extends Block> NonNullConsumer<? super B> interactionBehaviour(
MovingInteractionBehaviour behaviour) { MovingInteractionBehaviour behaviour) {
return b -> registerBehaviour(b.delegate, behaviour); return b -> registerBehaviour(b, behaviour);
} }
static void registerDefaults() { static void registerDefaults() {
registerBehaviour(Blocks.LEVER.delegate, new LeverMovingInteraction()); registerBehaviour(Blocks.LEVER, new LeverMovingInteraction());
DoorMovingInteraction doorBehaviour = new DoorMovingInteraction(); DoorMovingInteraction doorBehaviour = new DoorMovingInteraction();
registerBehaviourProvider(state -> { registerBehaviourProvider(state -> {

View file

@ -1,9 +1,7 @@
package com.simibubi.create; package com.simibubi.create;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -12,19 +10,31 @@ 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.tterrag.registrate.util.nullness.NonNullConsumer; import com.tterrag.registrate.util.nullness.NonNullConsumer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block; 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.IRegistryDelegate; import net.minecraftforge.registries.IRegistryDelegate;
public class AllMovementBehaviours { public class AllMovementBehaviours {
private static final Map<IRegistryDelegate<Block>, MovementBehaviour> BLOCK_BEHAVIOURS = new HashMap<>(); private static final CreateRegistry<Block, MovementBehaviour> BLOCK_BEHAVIOURS = new CreateRegistry<>(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) {
BLOCK_BEHAVIOURS.register(block, behaviour);
}
public static void registerBehaviour(Block block, MovementBehaviour behaviour) {
BLOCK_BEHAVIOURS.register(block, behaviour);
}
@Deprecated(forRemoval = true)
public static void registerBehaviour(IRegistryDelegate<Block> block, MovementBehaviour behaviour) { public static void registerBehaviour(IRegistryDelegate<Block> block, MovementBehaviour behaviour) {
BLOCK_BEHAVIOURS.put(block, behaviour); registerBehaviour(block.name(), behaviour);
} }
public static void registerBehaviourProvider(BehaviourProvider provider) { public static void registerBehaviourProvider(BehaviourProvider provider) {
@ -33,7 +43,7 @@ public class AllMovementBehaviours {
@Nullable @Nullable
public static MovementBehaviour getBehaviour(BlockState state) { public static MovementBehaviour getBehaviour(BlockState state) {
MovementBehaviour behaviour = BLOCK_BEHAVIOURS.get(state.getBlock().delegate); MovementBehaviour behaviour = BLOCK_BEHAVIOURS.get(state.getBlock());
if (behaviour != null) { if (behaviour != null) {
return behaviour; return behaviour;
} }
@ -50,16 +60,16 @@ public class AllMovementBehaviours {
public static <B extends Block> NonNullConsumer<? super B> movementBehaviour( public static <B extends Block> NonNullConsumer<? super B> movementBehaviour(
MovementBehaviour behaviour) { MovementBehaviour behaviour) {
return b -> registerBehaviour(b.delegate, behaviour); return b -> registerBehaviour(b, behaviour);
} }
static void registerDefaults() { static void registerDefaults() {
registerBehaviour(Blocks.BELL.delegate, new BellMovementBehaviour()); registerBehaviour(Blocks.BELL, new BellMovementBehaviour());
registerBehaviour(Blocks.CAMPFIRE.delegate, new CampfireMovementBehaviour()); registerBehaviour(Blocks.CAMPFIRE, new CampfireMovementBehaviour());
DispenserMovementBehaviour.gatherMovedDispenseItemBehaviours(); DispenserMovementBehaviour.gatherMovedDispenseItemBehaviours();
registerBehaviour(Blocks.DISPENSER.delegate, new DispenserMovementBehaviour()); registerBehaviour(Blocks.DISPENSER, new DispenserMovementBehaviour());
registerBehaviour(Blocks.DROPPER.delegate, new DropperMovementBehaviour()); registerBehaviour(Blocks.DROPPER, new DropperMovementBehaviour());
} }
public interface BehaviourProvider { public interface BehaviourProvider {

View file

@ -26,6 +26,7 @@ import com.simibubi.create.content.contraptions.processing.ProcessingRecipeSeria
import com.simibubi.create.content.curiosities.toolbox.ToolboxDyeingRecipe; import com.simibubi.create.content.curiosities.toolbox.ToolboxDyeingRecipe;
import com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe; import com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo; import com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
@ -143,7 +144,7 @@ public enum AllRecipeTypes implements IRecipeTypeInfo {
public static boolean shouldIgnoreInAutomation(Recipe<?> recipe) { public static boolean shouldIgnoreInAutomation(Recipe<?> recipe) {
RecipeSerializer<?> serializer = recipe.getSerializer(); RecipeSerializer<?> serializer = recipe.getSerializer();
if (serializer != null && RECIPE_DENY_SET.contains(serializer.getRegistryName())) if (serializer != null && RECIPE_DENY_SET.contains(RegisteredObjects.getKeyOrThrow(serializer)))
return true; return true;
return recipe.getId() return recipe.getId()
.getPath() .getPath()

View file

@ -29,6 +29,7 @@ import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.block.CopperRegistries; import com.simibubi.create.foundation.block.CopperRegistries;
import com.simibubi.create.foundation.command.ServerLagger; import com.simibubi.create.foundation.command.ServerLagger;
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.data.CreateRegistrate; import com.simibubi.create.foundation.data.CreateRegistrate;
import com.simibubi.create.foundation.data.LangMerger; import com.simibubi.create.foundation.data.LangMerger;
import com.simibubi.create.foundation.data.recipe.MechanicalCraftingRecipeGen; import com.simibubi.create.foundation.data.recipe.MechanicalCraftingRecipeGen;
@ -36,6 +37,7 @@ 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.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.CreateRegistry;
import com.simibubi.create.foundation.worldgen.AllWorldFeatures; import com.simibubi.create.foundation.worldgen.AllWorldFeatures;
import com.tterrag.registrate.util.nullness.NonNullSupplier; import com.tterrag.registrate.util.nullness.NonNullSupplier;
@ -43,8 +45,10 @@ import net.minecraft.core.particles.ParticleType;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.ForgeMod;
@ -80,6 +84,8 @@ public class Create {
public static final TorquePropagator TORQUE_PROPAGATOR = new TorquePropagator(); public static final TorquePropagator TORQUE_PROPAGATOR = new TorquePropagator();
public static final GlobalRailwayManager RAILWAYS = new GlobalRailwayManager(); public static final GlobalRailwayManager RAILWAYS = new GlobalRailwayManager();
public static final ServerLagger LAGGER = new ServerLagger(); public static final ServerLagger LAGGER = new ServerLagger();
/** Use the {@link Random} of a local {@link Level} or {@link Entity} or create one */
@Deprecated
public static final Random RANDOM = new Random(); public static final Random RANDOM = new Random();
private static final NonNullSupplier<CreateRegistrate> REGISTRATE = CreateRegistrate.lazy(ID); private static final NonNullSupplier<CreateRegistrate> REGISTRATE = CreateRegistrate.lazy(ID);
@ -103,6 +109,7 @@ public class Create {
AllMovementBehaviours.registerDefaults(); AllMovementBehaviours.registerDefaults();
AllInteractionBehaviours.registerDefaults(); AllInteractionBehaviours.registerDefaults();
AllDisplayBehaviours.registerDefaults(); AllDisplayBehaviours.registerDefaults();
ContraptionMovementSetting.registerDefaults();
AllArmInteractionPointTypes.register(); AllArmInteractionPointTypes.register();
AllWorldFeatures.register(); AllWorldFeatures.register();
AllEnchantments.register(); AllEnchantments.register();
@ -133,6 +140,7 @@ public class Create {
} }
public static void init(final FMLCommonSetupEvent event) { public static void init(final FMLCommonSetupEvent event) {
CreateRegistry.unwrapAll();
AllPackets.registerPackets(); AllPackets.registerPackets();
SchematicInstances.register(); SchematicInstances.register();
BuiltinPotatoProjectileTypes.register(); BuiltinPotatoProjectileTypes.register();

View file

@ -26,6 +26,7 @@ import com.simibubi.create.foundation.ponder.element.WorldSectionElement;
import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.CreateContexts; import com.simibubi.create.foundation.render.CreateContexts;
import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.render.SuperByteBufferCache;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.ModelSwapper; import com.simibubi.create.foundation.utility.ModelSwapper;
import com.simibubi.create.foundation.utility.ghost.GhostBlocks; import com.simibubi.create.foundation.utility.ghost.GhostBlocks;
import com.simibubi.create.foundation.utility.outliner.Outliner; import com.simibubi.create.foundation.utility.outliner.Outliner;
@ -33,12 +34,10 @@ import com.simibubi.create.foundation.utility.outliner.Outliner;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.client.GraphicsStatus; import net.minecraft.client.GraphicsStatus;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.ComponentUtils; import net.minecraft.network.chat.ComponentUtils;
import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.client.gui.ForgeIngameGui; import net.minecraftforge.client.gui.ForgeIngameGui;
import net.minecraftforge.client.gui.OverlayRegistry; import net.minecraftforge.client.gui.OverlayRegistry;
import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.IEventBus;
@ -126,16 +125,16 @@ public class CreateClient {
if (AllConfigs.CLIENT.ignoreFabulousWarning.get()) if (AllConfigs.CLIENT.ignoreFabulousWarning.get())
return; return;
MutableComponent text = ComponentUtils.wrapInSquareBrackets(new TextComponent("WARN")) MutableComponent text = ComponentUtils.wrapInSquareBrackets(Components.literal("WARN"))
.withStyle(ChatFormatting.GOLD) .withStyle(ChatFormatting.GOLD)
.append(new TextComponent( .append(Components.literal(
" Some of Create's visual features will not be available while Fabulous graphics are enabled!")) " Some of Create's visual features will not be available while Fabulous graphics are enabled!"))
.withStyle(style -> style .withStyle(style -> style
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/create dismissFabulousWarning")) .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/create dismissFabulousWarning"))
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new TextComponent("Click here to disable this warning")))); Components.literal("Click here to disable this warning"))));
mc.gui.handleChat(ChatType.CHAT, text, mc.player.getUUID()); mc.player.displayClientMessage(text, false);
} }
} }

View file

@ -15,6 +15,7 @@ import com.simibubi.create.AllFluids;
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler;
import com.simibubi.create.content.contraptions.processing.ProcessingOutput; import com.simibubi.create.content.contraptions.processing.ProcessingOutput;
import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import mezz.jei.api.forge.ForgeTypes; import mezz.jei.api.forge.ForgeTypes;
@ -27,7 +28,6 @@ import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.Recipe;
@ -159,12 +159,12 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
} }
int amount = mbAmount == -1 ? fluidStack.getAmount() : mbAmount; int amount = mbAmount == -1 ? fluidStack.getAmount() : mbAmount;
Component text = new TextComponent(String.valueOf(amount)).append(Lang.translateDirect("generic.unit.millibuckets")).withStyle(ChatFormatting.GOLD); Component text = Components.literal(String.valueOf(amount)).append(Lang.translateDirect("generic.unit.millibuckets")).withStyle(ChatFormatting.GOLD);
if (tooltip.isEmpty()) if (tooltip.isEmpty())
tooltip.add(0, text); tooltip.add(0, text);
else { else {
List<Component> siblings = tooltip.get(0).getSiblings(); List<Component> siblings = tooltip.get(0).getSiblings();
siblings.add(new TextComponent(" ")); siblings.add(Components.literal(" "));
siblings.add(text); siblings.add(text);
} }
}; };

View file

@ -11,6 +11,7 @@ import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler
import com.simibubi.create.content.contraptions.processing.EmptyingRecipe; import com.simibubi.create.content.contraptions.processing.EmptyingRecipe;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder;
import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.forge.ForgeTypes; import mezz.jei.api.forge.ForgeTypes;
@ -68,10 +69,8 @@ public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
continue; continue;
Ingredient ingredient = Ingredient.of(stack); Ingredient ingredient = Ingredient.of(stack);
ResourceLocation itemName = stack.getItem() ResourceLocation itemName = RegisteredObjects.getKeyOrThrow(stack.getItem());
.getRegistryName(); ResourceLocation fluidName = RegisteredObjects.getKeyOrThrow(extracted.getFluid());
ResourceLocation fluidName = extracted.getFluid()
.getRegistryName();
consumer.accept(new ProcessingRecipeBuilder<>(EmptyingRecipe::new, consumer.accept(new ProcessingRecipeBuilder<>(EmptyingRecipe::new,
Create.asResource("empty_" + itemName.getNamespace() + "_" + itemName.getPath() + "_of_" Create.asResource("empty_" + itemName.getNamespace() + "_" + itemName.getPath() + "_of_"

View file

@ -11,6 +11,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.compat.jei.category.animations.AnimatedCrafter; import com.simibubi.create.compat.jei.category.animations.AnimatedCrafter;
import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.utility.Components;
import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
@ -23,7 +24,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font; import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.TooltipFlag;
@ -183,7 +184,7 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
return ingredient.getTooltipLines(player, tooltipFlag); return ingredient.getTooltipLines(player, tooltipFlag);
} catch (RuntimeException | LinkageError e) { } catch (RuntimeException | LinkageError e) {
List<Component> list = new ArrayList<>(); List<Component> list = new ArrayList<>();
TranslatableComponent crash = new TranslatableComponent("jei.tooltip.error.crash"); MutableComponent crash = Components.translatable("jei.tooltip.error.crash");
list.add(crash.withStyle(ChatFormatting.RED)); list.add(crash.withStyle(ChatFormatting.RED));
return list; return list;
} }

View file

@ -15,7 +15,9 @@ import com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRe
import com.simibubi.create.content.contraptions.itemAssembly.SequencedRecipe; import com.simibubi.create.content.contraptions.itemAssembly.SequencedRecipe;
import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView; import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
@ -25,8 +27,7 @@ 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.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
@ -75,9 +76,8 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
} }
private SequencedAssemblySubCategory getSubCategory(SequencedRecipe<?> sequencedRecipe) { private SequencedAssemblySubCategory getSubCategory(SequencedRecipe<?> sequencedRecipe) {
return subCategories.computeIfAbsent(sequencedRecipe.getRecipe() return subCategories.computeIfAbsent(RegisteredObjects.getKeyOrThrow(sequencedRecipe.getRecipe()
.getSerializer() .getSerializer()),
.getRegistryName(),
rl -> sequencedRecipe.getAsAssemblyRecipe() rl -> sequencedRecipe.getAsAssemblyRecipe()
.getJEISubCategory() .getJEISubCategory()
.get() .get()
@ -100,7 +100,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
AllGuiTextures.JEI_LONG_ARROW.render(matrixStack, 52 + xOffset, 79); AllGuiTextures.JEI_LONG_ARROW.render(matrixStack, 52 + xOffset, 79);
if (!singleOutput) { if (!singleOutput) {
AllGuiTextures.JEI_CHANCE_SLOT.render(matrixStack, 150 + xOffset, 75); AllGuiTextures.JEI_CHANCE_SLOT.render(matrixStack, 150 + xOffset, 75);
Component component = new TextComponent("?").withStyle(ChatFormatting.BOLD); Component component = Components.literal("?").withStyle(ChatFormatting.BOLD);
font.drawShadow(matrixStack, component, font.width(component) / -2 + 8 + 150 + xOffset, 2 + 78, font.drawShadow(matrixStack, component, font.width(component) / -2 + 8 + 150 + xOffset, 2 + 78,
0xefefef); 0xefefef);
} }
@ -109,7 +109,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
matrixStack.pushPose(); matrixStack.pushPose();
matrixStack.translate(15, 9, 0); matrixStack.translate(15, 9, 0);
AllIcons.I_SEQ_REPEAT.render(matrixStack, 50 + xOffset, 75); AllIcons.I_SEQ_REPEAT.render(matrixStack, 50 + xOffset, 75);
Component repeat = new TextComponent("x" + recipe.getLoops()); Component repeat = Components.literal("x" + recipe.getLoops());
font.draw(matrixStack, repeat, 66 + xOffset, 80, 0x888888); font.draw(matrixStack, repeat, 66 + xOffset, 80, 0x888888);
matrixStack.popPose(); matrixStack.popPose();
} }
@ -129,7 +129,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
SequencedRecipe<?> sequencedRecipe = sequence.get(i); SequencedRecipe<?> sequencedRecipe = sequence.get(i);
SequencedAssemblySubCategory subCategory = getSubCategory(sequencedRecipe); SequencedAssemblySubCategory subCategory = getSubCategory(sequencedRecipe);
int subWidth = subCategory.getWidth(); int subWidth = subCategory.getWidth();
TextComponent component = new TextComponent("" + romans[Math.min(i, 6)]); MutableComponent component = Components.literal("" + romans[Math.min(i, 6)]);
font.draw(matrixStack, component, font.width(component) / -2 + subWidth / 2, 2, 0x888888); font.draw(matrixStack, component, font.width(component) / -2 + subWidth / 2, 2, 0x888888);
subCategory.draw(sequencedRecipe, matrixStack, mouseX, mouseY, i); subCategory.draw(sequencedRecipe, matrixStack, mouseX, mouseY, i);
matrixStack.translate(subWidth + margin, 0, 0); matrixStack.translate(subWidth + margin, 0, 0);
@ -144,7 +144,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
public List<Component> getTooltipStrings(SequencedAssemblyRecipe recipe, IRecipeSlotsView iRecipeSlotsView, double mouseX, double mouseY) { public List<Component> getTooltipStrings(SequencedAssemblyRecipe recipe, IRecipeSlotsView iRecipeSlotsView, double mouseX, double mouseY) {
List<Component> tooltip = new ArrayList<>(); List<Component> tooltip = new ArrayList<>();
TranslatableComponent junk = Lang.translateDirect("recipe.assembly.junk"); MutableComponent junk = Lang.translateDirect("recipe.assembly.junk");
boolean singleOutput = recipe.getOutputChance() == 1; boolean singleOutput = recipe.getOutputChance() == 1;
boolean willRepeat = recipe.getLoops() > 1; boolean willRepeat = recipe.getLoops() > 1;

View file

@ -14,6 +14,7 @@ import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder;
import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.fluid.FluidIngredient;
import com.simibubi.create.foundation.gui.AllGuiTextures; import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.forge.ForgeTypes; import mezz.jei.api.forge.ForgeTypes;
@ -77,10 +78,8 @@ public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
return; return;
Ingredient bucket = Ingredient.of(stack); Ingredient bucket = Ingredient.of(stack);
ResourceLocation itemName = stack.getItem() ResourceLocation itemName = RegisteredObjects.getKeyOrThrow(stack.getItem());
.getRegistryName(); ResourceLocation fluidName = RegisteredObjects.getKeyOrThrow(fluidCopy.getFluid());
ResourceLocation fluidName = fluidCopy.getFluid()
.getRegistryName();
consumer.accept(new ProcessingRecipeBuilder<>(FillingRecipe::new, consumer.accept(new ProcessingRecipeBuilder<>(FillingRecipe::new,
Create.asResource("fill_" + itemName.getNamespace() + "_" + itemName.getPath() Create.asResource("fill_" + itemName.getNamespace() + "_" + itemName.getPath()
+ "_with_" + fluidName.getNamespace() + "_" + fluidName.getPath())) + "_with_" + fluidName.getNamespace() + "_" + fluidName.getPath()))

View file

@ -5,6 +5,7 @@ import com.simibubi.create.compat.Mods;
import com.simibubi.create.content.contraptions.fluids.actors.SpoutTileEntity; import com.simibubi.create.content.contraptions.fluids.actors.SpoutTileEntity;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.fluid.FluidHelper;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -40,8 +41,7 @@ public class SpoutCasting extends BlockSpoutingBehaviour {
if (handler.getTanks() != 1) if (handler.getTanks() != 1)
return 0; return 0;
ResourceLocation registryName = te.getType() ResourceLocation registryName = RegisteredObjects.getKeyOrThrow(te.getType());
.getRegistryName();
if (!registryName.equals(TABLE) && !registryName.equals(BASIN)) if (!registryName.equals(TABLE) && !registryName.equals(BASIN))
return 0; return 0;
if (!handler.isFluidValid(0, availableFluid)) if (!handler.isFluidValid(0, availableFluid))

View file

@ -12,11 +12,10 @@ import com.simibubi.create.content.contraptions.itemAssembly.IAssemblyRecipe;
import com.simibubi.create.content.contraptions.processing.ItemApplicationRecipe; import com.simibubi.create.content.contraptions.processing.ItemApplicationRecipe;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
@ -59,9 +58,9 @@ public class DeployerApplicationRecipe extends ItemApplicationRecipe implements
ItemStack[] matchingStacks = ingredients.get(1) ItemStack[] matchingStacks = ingredients.get(1)
.getItems(); .getItems();
if (matchingStacks.length == 0) if (matchingStacks.length == 0)
return new TextComponent("Invalid"); return Components.literal("Invalid");
return Lang.translateDirect("recipe.assembly.deploying_item", return Lang.translateDirect("recipe.assembly.deploying_item",
new TranslatableComponent(matchingStacks[0].getDescriptionId()).getString()); Components.translatable(matchingStacks[0].getDescriptionId()).getString());
} }
@Override @Override

View file

@ -23,6 +23,7 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.utility.Components;
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;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -35,7 +36,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
@ -480,13 +480,13 @@ public class DeployerTileEntity extends KineticTileEntity {
if (!heldItem.isEmpty()) if (!heldItem.isEmpty())
Lang.translate("tooltip.deployer.contains", Lang.translate("tooltip.deployer.contains",
new TranslatableComponent(heldItem.getDescriptionId()).getString(), heldItem.getCount()) Components.translatable(heldItem.getDescriptionId()).getString(), heldItem.getCount())
.style(ChatFormatting.GREEN) .style(ChatFormatting.GREEN)
.forGoggles(tooltip); .forGoggles(tooltip);
float stressAtBase = calculateStressApplied(); float stressAtBase = calculateStressApplied();
if (StressImpact.isEnabled() && !Mth.equal(stressAtBase, 0)) { if (StressImpact.isEnabled() && !Mth.equal(stressAtBase, 0)) {
tooltip.add(Lang.empty()); tooltip.add(Components.immutableEmpty());
addStressImpactStats(tooltip, stressAtBase); addStressImpactStats(tooltip, stressAtBase);
} }

View file

@ -4,6 +4,7 @@ import java.util.List;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity; import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import com.simibubi.create.foundation.block.BlockStressValues; import com.simibubi.create.foundation.block.BlockStressValues;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
@ -81,7 +82,7 @@ public class PoweredShaftTileEntity extends GeneratingKineticTileEntity {
if (enginePos != null && capacityKey != null) { if (enginePos != null && capacityKey != null) {
compound.put("EnginePos", NbtUtils.writeBlockPos(enginePos)); compound.put("EnginePos", NbtUtils.writeBlockPos(enginePos));
compound.putFloat("EnginePower", engineEfficiency); compound.putFloat("EnginePower", engineEfficiency);
compound.putString("EngineType", capacityKey.getRegistryName() compound.putString("EngineType", RegisteredObjects.getKeyOrThrow(capacityKey)
.toString()); .toString());
} }
super.write(compound, clientPacket); super.write(compound, clientPacket);

View file

@ -14,6 +14,7 @@ import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat;
@ -25,7 +26,7 @@ import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@ -110,7 +111,7 @@ public class WhistleTileEntity extends SmartTileEntity implements IHaveGoggleInf
String[] pitches = Lang.translateDirect("generic.notes") String[] pitches = Lang.translateDirect("generic.notes")
.getString() .getString()
.split(";"); .split(";");
TextComponent textComponent = new TextComponent(spacing); MutableComponent textComponent = Components.literal(spacing);
tooltip.add(textComponent.append(Lang.translateDirect("generic.pitch", pitches[pitch % pitches.length]))); tooltip.add(textComponent.append(Lang.translateDirect("generic.pitch", pitches[pitch % pitches.length])));
return true; return true;
} }

View file

@ -5,11 +5,11 @@ import java.util.List;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
public interface IDisplayAssemblyExceptions { public interface IDisplayAssemblyExceptions {
@ -19,7 +19,7 @@ public interface IDisplayAssemblyExceptions {
return false; return false;
if (!tooltip.isEmpty()) if (!tooltip.isEmpty())
tooltip.add(TextComponent.EMPTY); tooltip.add(Components.immutableEmpty());
tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy() tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy()
.append(Lang.translateDirect("gui.assembly.exception") .append(Lang.translateDirect("gui.assembly.exception")

View file

@ -10,6 +10,7 @@ import com.simibubi.create.AllSpecialTextures;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.AbstractChassisBlock; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.AbstractChassisBlock;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.RaycastHelper; import com.simibubi.create.foundation.utility.RaycastHelper;
@ -18,7 +19,6 @@ import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -62,7 +62,7 @@ public class SuperGlueSelectionHandler {
if (clusterCooldown > 0) { if (clusterCooldown > 0) {
if (clusterCooldown == 25) if (clusterCooldown == 25)
player.displayClientMessage(TextComponent.EMPTY, true); player.displayClientMessage(Components.immutableEmpty(), true);
CreateClient.OUTLINER.keep(clusterOutlineSlot); CreateClient.OUTLINER.keep(clusterOutlineSlot);
clusterCooldown--; clusterCooldown--;
} }

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.contraptions.fluids; package com.simibubi.create.content.contraptions.fluids;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.tags.FluidTags; import net.minecraft.tags.FluidTags;
@ -43,8 +44,7 @@ public class FluidBottleItemHook extends Item {
return; return;
FluidState fluidState = world.getFluidState(blockpos); FluidState fluidState = world.getFluidState(blockpos);
if (fluidState.is(FluidTags.WATER) && fluidState.getType() if (fluidState.is(FluidTags.WATER) && RegisteredObjects.getKeyOrThrow(fluidState.getType())
.getRegistryName()
.getNamespace() .getNamespace()
.equals(Create.ID)) { .equals(Create.ID)) {
event.setCancellationResult(InteractionResult.PASS); event.setCancellationResult(InteractionResult.PASS);

View file

@ -11,10 +11,10 @@ import com.simibubi.create.content.contraptions.itemAssembly.IAssemblyRecipe;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams;
import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.fluid.FluidIngredient;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@ -70,7 +70,7 @@ public class FillingRecipe extends ProcessingRecipe<RecipeWrapper> implements IA
List<FluidStack> matchingFluidStacks = fluidIngredients.get(0) List<FluidStack> matchingFluidStacks = fluidIngredients.get(0)
.getMatchingFluidStacks(); .getMatchingFluidStacks();
if (matchingFluidStacks.size() == 0) if (matchingFluidStacks.size() == 0)
return new TextComponent("Invalid"); return Components.literal("Invalid");
return Lang.translateDirect("recipe.assembly.spout_filling_fluid", return Lang.translateDirect("recipe.assembly.spout_filling_fluid",
matchingFluidStacks.get(0).getDisplayName().getString()); matchingFluidStacks.get(0).getDisplayName().getString());
} }

View file

@ -6,6 +6,7 @@ import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder; import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.simibubi.create.AllParticleTypes; import com.simibubi.create.AllParticleTypes;
import com.simibubi.create.content.contraptions.particle.ICustomParticleData; import com.simibubi.create.content.contraptions.particle.ICustomParticleData;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.client.particle.ParticleProvider; import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleOptions;
@ -15,7 +16,6 @@ import net.minecraft.world.level.material.Fluids;
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.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.registries.ForgeRegistries;
public class FluidParticleData implements ParticleOptions, ICustomParticleData<FluidParticleData> { public class FluidParticleData implements ParticleOptions, ICustomParticleData<FluidParticleData> {
@ -49,8 +49,7 @@ public class FluidParticleData implements ParticleOptions, ICustomParticleData<F
@Override @Override
public String writeToString() { public String writeToString() {
return ForgeRegistries.PARTICLE_TYPES.getKey(type) + " " + fluid.getFluid() return RegisteredObjects.getKeyOrThrow(type) + " " + RegisteredObjects.getKeyOrThrow(fluid.getFluid());
.getRegistryName();
} }
public static final Codec<FluidParticleData> CODEC = RecordCodecBuilder.create(i -> i public static final Codec<FluidParticleData> CODEC = RecordCodecBuilder.create(i -> i

View file

@ -5,12 +5,13 @@ import java.util.List;
import com.simibubi.create.AllFluids; import com.simibubi.create.AllFluids;
import com.simibubi.create.content.contraptions.fluids.VirtualFluid; import com.simibubi.create.content.contraptions.fluids.VirtualFluid;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.item.alchemy.Potion;
@ -20,7 +21,6 @@ import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.registries.ForgeRegistries;
public class PotionFluid extends VirtualFluid { public class PotionFluid extends VirtualFluid {
@ -42,7 +42,7 @@ public class PotionFluid extends VirtualFluid {
} }
public static FluidStack addPotionToFluidStack(FluidStack fs, Potion potion) { public static FluidStack addPotionToFluidStack(FluidStack fs, Potion potion) {
ResourceLocation resourcelocation = ForgeRegistries.POTIONS.getKey(potion); ResourceLocation resourcelocation = RegisteredObjects.getKeyOrThrow(potion);
if (potion == Potions.EMPTY) { if (potion == Potions.EMPTY) {
fs.removeChildTag("Potion"); fs.removeChildTag("Potion");
return fs; return fs;
@ -82,7 +82,7 @@ public class PotionFluid extends VirtualFluid {
@Override @Override
public Component getDisplayName(FluidStack stack) { public Component getDisplayName(FluidStack stack) {
return new TranslatableComponent(getTranslationKey(stack)); return Components.translatable(getTranslationKey(stack));
} }
@Override @Override

View file

@ -8,14 +8,14 @@ import com.google.common.collect.Lists;
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluid.BottleType; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluid.BottleType;
import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.fluid.FluidHelper;
import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.fluid.FluidIngredient;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.Tuple; import net.minecraft.util.Tuple;
import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffectInstance;
@ -105,10 +105,10 @@ public class PotionFluidHandler {
List<MobEffectInstance> list = PotionUtils.getAllEffects(fs.getOrCreateTag()); List<MobEffectInstance> list = PotionUtils.getAllEffects(fs.getOrCreateTag());
List<Tuple<String, AttributeModifier>> list1 = Lists.newArrayList(); List<Tuple<String, AttributeModifier>> list1 = Lists.newArrayList();
if (list.isEmpty()) { if (list.isEmpty()) {
tooltip.add((new TranslatableComponent("effect.none")).withStyle(ChatFormatting.GRAY)); tooltip.add((Components.translatable("effect.none")).withStyle(ChatFormatting.GRAY));
} else { } else {
for (MobEffectInstance effectinstance : list) { for (MobEffectInstance effectinstance : list) {
TranslatableComponent textcomponent = new TranslatableComponent(effectinstance.getDescriptionId()); MutableComponent textcomponent = Components.translatable(effectinstance.getDescriptionId());
MobEffect effect = effectinstance.getEffect(); MobEffect effect = effectinstance.getEffect();
Map<Attribute, AttributeModifier> map = effect.getAttributeModifiers(); Map<Attribute, AttributeModifier> map = effect.getAttributeModifiers();
if (!map.isEmpty()) { if (!map.isEmpty()) {
@ -125,7 +125,7 @@ public class PotionFluidHandler {
if (effectinstance.getAmplifier() > 0) { if (effectinstance.getAmplifier() > 0) {
textcomponent.append(" ") textcomponent.append(" ")
.append(new TranslatableComponent("potion.potency." + effectinstance.getAmplifier()).getString()); .append(Components.translatable("potion.potency." + effectinstance.getAmplifier()).getString());
} }
if (effectinstance.getDuration() > 20) { if (effectinstance.getDuration() > 20) {
@ -140,8 +140,8 @@ public class PotionFluidHandler {
} }
if (!list1.isEmpty()) { if (!list1.isEmpty()) {
tooltip.add(new TextComponent("")); tooltip.add(Components.immutableEmpty());
tooltip.add((new TranslatableComponent("potion.whenDrank")).withStyle(ChatFormatting.DARK_PURPLE)); tooltip.add((Components.translatable("potion.whenDrank")).withStyle(ChatFormatting.DARK_PURPLE));
for (Tuple<String, AttributeModifier> tuple : list1) { for (Tuple<String, AttributeModifier> tuple : list1) {
AttributeModifier attributemodifier2 = tuple.getB(); AttributeModifier attributemodifier2 = tuple.getB();
@ -155,19 +155,19 @@ public class PotionFluidHandler {
} }
if (d0 > 0.0D) { if (d0 > 0.0D) {
tooltip.add((new TranslatableComponent( tooltip.add((Components.translatable(
"attribute.modifier.plus." + attributemodifier2.getOperation() "attribute.modifier.plus." + attributemodifier2.getOperation()
.toValue(), .toValue(),
ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1), ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1),
new TranslatableComponent(tuple.getA()))) Components.translatable(tuple.getA())))
.withStyle(ChatFormatting.BLUE)); .withStyle(ChatFormatting.BLUE));
} else if (d0 < 0.0D) { } else if (d0 < 0.0D) {
d1 = d1 * -1.0D; d1 = d1 * -1.0D;
tooltip.add((new TranslatableComponent( tooltip.add((Components.translatable(
"attribute.modifier.take." + attributemodifier2.getOperation() "attribute.modifier.take." + attributemodifier2.getOperation()
.toValue(), .toValue(),
ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1), ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1),
new TranslatableComponent(tuple.getA()))) Components.translatable(tuple.getA())))
.withStyle(ChatFormatting.RED)); .withStyle(ChatFormatting.RED));
} }
} }

View file

@ -17,6 +17,7 @@ import com.simibubi.create.foundation.advancement.AdvancementBehaviour;
import com.simibubi.create.foundation.advancement.AllAdvancements; import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.block.BlockStressValues; import com.simibubi.create.foundation.block.BlockStressValues;
import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.fluid.FluidHelper;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat;
@ -29,7 +30,6 @@ import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
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.network.chat.TextComponent;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -147,8 +147,8 @@ public class BoilerData {
if (!isActive()) if (!isActive())
return false; return false;
Component indent = new TextComponent(IHaveGoggleInformation.spacing); Component indent = Components.literal(IHaveGoggleInformation.spacing);
Component indent2 = new TextComponent(IHaveGoggleInformation.spacing + " "); Component indent2 = Components.literal(IHaveGoggleInformation.spacing + " ");
calcMinMaxForSize(boilerSize); calcMinMaxForSize(boilerSize);
@ -169,7 +169,7 @@ public class BoilerData {
double totalSU = getEngineEfficiency(boilerSize) * 16 * Math.max(boilerLevel, attachedEngines) double totalSU = getEngineEfficiency(boilerSize) * 16 * Math.max(boilerLevel, attachedEngines)
* BlockStressValues.getCapacity(AllBlocks.STEAM_ENGINE.get()); * BlockStressValues.getCapacity(AllBlocks.STEAM_ENGINE.get());
tooltip.add(Lang.empty()); tooltip.add(Components.immutableEmpty());
Lang.translate("tooltip.capacityProvided") Lang.translate("tooltip.capacityProvided")
.style(ChatFormatting.GRAY) .style(ChatFormatting.GRAY)
@ -234,12 +234,12 @@ public class BoilerData {
} }
private MutableComponent blockComponent(int level) { private MutableComponent blockComponent(int level) {
return new TextComponent( return Components.literal(
"" + "\u2588".repeat(minValue) + "\u2592".repeat(level - minValue) + "\u2591".repeat(maxValue - level)); "" + "\u2588".repeat(minValue) + "\u2592".repeat(level - minValue) + "\u2591".repeat(maxValue - level));
} }
private MutableComponent barComponent(int level) { private MutableComponent barComponent(int level) {
return TextComponent.EMPTY.copy() return Components.empty()
.append(bars(Math.max(0, minValue - 1), ChatFormatting.DARK_GREEN)) .append(bars(Math.max(0, minValue - 1), ChatFormatting.DARK_GREEN))
.append(bars(minValue > 0 ? 1 : 0, ChatFormatting.GREEN)) .append(bars(minValue > 0 ? 1 : 0, ChatFormatting.GREEN))
.append(bars(Math.max(0, level - minValue), ChatFormatting.DARK_GREEN)) .append(bars(Math.max(0, level - minValue), ChatFormatting.DARK_GREEN))
@ -250,7 +250,7 @@ public class BoilerData {
} }
private MutableComponent bars(int level, ChatFormatting format) { private MutableComponent bars(int level, ChatFormatting format) {
return new TextComponent(Strings.repeat('|', level)).withStyle(format); return Components.literal(Strings.repeat('|', level)).withStyle(format);
} }
public boolean evaluate(FluidTankTileEntity controller) { public boolean evaluate(FluidTankTileEntity controller) {

View file

@ -1,9 +1,7 @@
package com.simibubi.create.content.contraptions.fluids.tank; package com.simibubi.create.content.contraptions.fluids.tank;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -11,19 +9,31 @@ 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 net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level; 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.IRegistryDelegate; import net.minecraftforge.registries.IRegistryDelegate;
public class BoilerHeaters { public class BoilerHeaters {
private static final Map<IRegistryDelegate<Block>, Heater> BLOCK_HEATERS = new HashMap<>(); private static final CreateRegistry<Block, Heater> BLOCK_HEATERS = new CreateRegistry<>(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) {
BLOCK_HEATERS.register(block, heater);
}
public static void registerHeater(Block block, Heater heater) {
BLOCK_HEATERS.register(block, heater);
}
@Deprecated(forRemoval = true)
public static void registerHeater(IRegistryDelegate<Block> block, Heater heater) { public static void registerHeater(IRegistryDelegate<Block> block, Heater heater) {
BLOCK_HEATERS.put(block, heater); registerHeater(block.name(), heater);
} }
public static void registerHeaterProvider(HeaterProvider provider) { public static void registerHeaterProvider(HeaterProvider provider) {
@ -36,7 +46,7 @@ public class BoilerHeaters {
* All other positive values are used as the amount of active heat. * All other positive values are used as the amount of active heat.
*/ */
public static float getActiveHeat(Level level, BlockPos pos, BlockState state) { public static float getActiveHeat(Level level, BlockPos pos, BlockState state) {
Heater heater = BLOCK_HEATERS.get(state.getBlock().delegate); Heater heater = BLOCK_HEATERS.get(state.getBlock());
if (heater != null) { if (heater != null) {
return heater.getActiveHeat(level, pos, state); return heater.getActiveHeat(level, pos, state);
} }
@ -52,7 +62,7 @@ public class BoilerHeaters {
} }
public static void registerDefaults() { public static void registerDefaults() {
registerHeater(AllBlocks.BLAZE_BURNER.get().delegate, (level, pos, state) -> { registerHeater(AllBlocks.BLAZE_BURNER.get(), (level, pos, state) -> {
HeatLevel value = state.getValue(BlazeBurnerBlock.HEAT_LEVEL); HeatLevel value = state.getValue(BlazeBurnerBlock.HEAT_LEVEL);
if (value == HeatLevel.NONE) { if (value == HeatLevel.NONE) {
return -1; return -1;

View file

@ -8,12 +8,12 @@ import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.gui.AbstractSimiScreen; import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.element.GuiGameElement; import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText; import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -24,26 +24,26 @@ public class GoggleConfigScreen extends AbstractSimiScreen {
private final List<Component> tooltip; private final List<Component> tooltip;
public GoggleConfigScreen() { public GoggleConfigScreen() {
Component componentSpacing = new TextComponent(" "); Component componentSpacing = Components.literal(" ");
tooltip = new ArrayList<>(); tooltip = new ArrayList<>();
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(Lang.translateDirect("gui.config.overlay1"))); .append(Lang.translateDirect("gui.config.overlay1")));
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(Lang.translateDirect("gui.config.overlay2") .append(Lang.translateDirect("gui.config.overlay2")
.withStyle(ChatFormatting.GRAY))); .withStyle(ChatFormatting.GRAY)));
tooltip.add(TextComponent.EMPTY); tooltip.add(Components.immutableEmpty());
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(Lang.translateDirect("gui.config.overlay3"))); .append(Lang.translateDirect("gui.config.overlay3")));
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(Lang.translateDirect("gui.config.overlay4"))); .append(Lang.translateDirect("gui.config.overlay4")));
tooltip.add(TextComponent.EMPTY); tooltip.add(Components.immutableEmpty());
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(Lang.translateDirect("gui.config.overlay5") .append(Lang.translateDirect("gui.config.overlay5")
.withStyle(ChatFormatting.GRAY))); .withStyle(ChatFormatting.GRAY)));
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(Lang.translateDirect("gui.config.overlay6") .append(Lang.translateDirect("gui.config.overlay6")
.withStyle(ChatFormatting.GRAY))); .withStyle(ChatFormatting.GRAY)));
tooltip.add(TextComponent.EMPTY); tooltip.add(Components.immutableEmpty());
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(Lang.translateDirect("gui.config.overlay7"))); .append(Lang.translateDirect("gui.config.overlay7")));
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()

View file

@ -19,6 +19,7 @@ import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.element.GuiGameElement; import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox;
import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.outliner.Outline; import com.simibubi.create.foundation.utility.outliner.Outline;
@ -30,7 +31,6 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText; import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType; import net.minecraft.world.level.GameType;
@ -100,7 +100,7 @@ public class GoggleOverlayRenderer {
if (hasHoveringInformation) { if (hasHoveringInformation) {
if (!tooltip.isEmpty()) if (!tooltip.isEmpty())
tooltip.add(TextComponent.EMPTY); tooltip.add(Components.immutableEmpty());
IHaveHoveringInformation hte = (IHaveHoveringInformation) te; IHaveHoveringInformation hte = (IHaveHoveringInformation) te;
hoverAddedInformation = hte.addToTooltip(tooltip, mc.player.isShiftKeyDown()); hoverAddedInformation = hte.addToTooltip(tooltip, mc.player.isShiftKeyDown());
@ -143,11 +143,11 @@ public class GoggleOverlayRenderer {
if (!pistonFound) if (!pistonFound)
return; return;
if (!tooltip.isEmpty()) if (!tooltip.isEmpty())
tooltip.add(TextComponent.EMPTY); tooltip.add(Components.immutableEmpty());
tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy() tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy()
.append(Lang.translateDirect("gui.goggles.pole_length")) .append(Lang.translateDirect("gui.goggles.pole_length"))
.append(new TextComponent(" " + poles))); .append(Components.literal(" " + poles)));
} }
if (tooltip.isEmpty()) if (tooltip.isEmpty())

View file

@ -3,12 +3,12 @@ package com.simibubi.create.content.contraptions.goggles;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import com.simibubi.create.foundation.utility.Components;
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;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
@ -27,7 +27,7 @@ public interface IHaveGoggleInformation {
* Use Lang.[...].forGoggles(list) * Use Lang.[...].forGoggles(list)
*/ */
@Deprecated @Deprecated
Component componentSpacing = new TextComponent(spacing); Component componentSpacing = Components.literal(spacing);
/** /**
* this method will be called when looking at a TileEntity that implemented this * this method will be called when looking at a TileEntity that implemented this

View file

@ -12,6 +12,7 @@ import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.processing.ProcessingOutput; import com.simibubi.create.content.contraptions.processing.ProcessingOutput;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
import com.simibubi.create.foundation.fluid.FluidIngredient; import com.simibubi.create.foundation.fluid.FluidIngredient;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
@ -19,7 +20,6 @@ import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container; import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -239,7 +239,7 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
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(new TextComponent("")); toolTip.add(Components.immutableEmpty());
toolTip.add(Lang.translateDirect("recipe.sequenced_assembly") 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)
@ -256,7 +256,7 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
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(new TextComponent("-> ").append(textComponent) toolTip.add(Components.literal("-> ").append(textComponent)
.withStyle(ChatFormatting.DARK_AQUA)); .withStyle(ChatFormatting.DARK_AQUA));
} }

View file

@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -35,7 +36,7 @@ public class SequencedRecipe<T extends ProcessingRecipe<?>> {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ProcessingRecipeSerializer<T> serializer = (ProcessingRecipeSerializer<T>) wrapped.getSerializer(); ProcessingRecipeSerializer<T> serializer = (ProcessingRecipeSerializer<T>) wrapped.getSerializer();
JsonObject json = new JsonObject(); JsonObject json = new JsonObject();
json.addProperty("type", ForgeRegistries.RECIPE_SERIALIZERS.getKey(serializer) json.addProperty("type", RegisteredObjects.getKeyOrThrow(serializer)
.toString()); .toString());
serializer.write(json, wrapped); serializer.write(json, wrapped);
return json; return json;
@ -62,7 +63,7 @@ public class SequencedRecipe<T extends ProcessingRecipe<?>> {
public void writeToBuffer(FriendlyByteBuf buffer) { public void writeToBuffer(FriendlyByteBuf buffer) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ProcessingRecipeSerializer<T> serializer = (ProcessingRecipeSerializer<T>) wrapped.getSerializer(); ProcessingRecipeSerializer<T> serializer = (ProcessingRecipeSerializer<T>) wrapped.getSerializer();
buffer.writeResourceLocation(ForgeRegistries.RECIPE_SERIALIZERS.getKey(serializer)); buffer.writeResourceLocation(RegisteredObjects.getKeyOrThrow(serializer));
buffer.writeResourceLocation(wrapped.getId()); buffer.writeResourceLocation(wrapped.getId());
serializer.toNetwork(buffer, wrapped); serializer.toNetwork(buffer, wrapped);
} }

View file

@ -9,6 +9,7 @@ import com.google.gson.JsonSyntaxException;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.nbt.TagParser; import net.minecraft.nbt.TagParser;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
@ -60,8 +61,8 @@ public class ProcessingOutput {
public JsonElement serialize() { public JsonElement serialize() {
JsonObject json = new JsonObject(); JsonObject json = new JsonObject();
ResourceLocation resourceLocation = compatDatagenOutput == null ? stack.getItem() ResourceLocation resourceLocation = compatDatagenOutput == null ? RegisteredObjects.getKeyOrThrow(stack
.getRegistryName() : compatDatagenOutput.getFirst(); .getItem()) : compatDatagenOutput.getFirst();
json.addProperty("item", resourceLocation.toString()); json.addProperty("item", resourceLocation.toString());
int count = compatDatagenOutput == null ? stack.getCount() : compatDatagenOutput.getSecond(); int count = compatDatagenOutput == null ? stack.getCount() : compatDatagenOutput.getSecond();
if (count != 1) if (count != 1)

View file

@ -7,6 +7,7 @@ import java.util.Map;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;
@ -71,7 +72,7 @@ public class BlazeBurnerBlockItem extends BlockItem {
@Override @Override
public String getDescriptionId() { public String getDescriptionId() {
return hasCapturedBlaze() ? super.getDescriptionId() : "item.create." + getRegistryName().getPath(); return hasCapturedBlaze() ? super.getDescriptionId() : "item.create." + RegisteredObjects.getKeyOrThrow(this).getPath();
} }
@Override @Override
@ -99,7 +100,7 @@ public class BlazeBurnerBlockItem extends BlockItem {
possibleSpawns.add(spawner.nextSpawnData); possibleSpawns.add(spawner.nextSpawnData);
} }
ResourceLocation blazeId = EntityType.BLAZE.getRegistryName(); ResourceLocation blazeId = RegisteredObjects.getKeyOrThrow(EntityType.BLAZE);
for (SpawnData e : possibleSpawns) { for (SpawnData e : possibleSpawns) {
ResourceLocation spawnerEntityId = new ResourceLocation(e.entityToSpawn() ResourceLocation spawnerEntityId = new ResourceLocation(e.entityToSpawn()
.getString("id")); .getString("id"));

View file

@ -3,10 +3,10 @@ package com.simibubi.create.content.contraptions.relays.advanced.sequencer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
public enum InstructionSpeedModifiers { public enum InstructionSpeedModifiers {
@ -24,7 +24,7 @@ public enum InstructionSpeedModifiers {
value = modifier; value = modifier;
} }
private InstructionSpeedModifiers(int modifier, String label) { private InstructionSpeedModifiers(int modifier, String label) {
this.label = new TextComponent(label); this.label = Components.literal(label);
translationKey = "gui.sequenced_gearshift.speed." + Lang.asId(name()); translationKey = "gui.sequenced_gearshift.speed." + Lang.asId(name());
value = modifier; value = modifier;
} }

View file

@ -12,12 +12,12 @@ import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.ScrollInput; import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput; import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class SequencedGearshiftScreen extends AbstractSimiScreen { public class SequencedGearshiftScreen extends AbstractSimiScreen {
@ -150,7 +150,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
if (def.hasValueParameter) { if (def.hasValueParameter) {
String text = def.formatValue(instruction.value); String text = def.formatValue(instruction.value);
int stringWidth = font.width(text); int stringWidth = font.width(text);
label(ms, 90 + (12 - stringWidth / 2), yOffset - 3, new TextComponent(text)); label(ms, 90 + (12 - stringWidth / 2), yOffset - 3, Components.literal(text));
} }
if (def.hasSpeedParameter) if (def.hasSpeedParameter)
label(ms, 127, yOffset - 3, instruction.speedModifier.label); label(ms, 127, yOffset - 3, instruction.speedModifier.label);

View file

@ -13,6 +13,7 @@ import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.Casin
import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorItem; import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorItem;
import com.simibubi.create.content.contraptions.relays.belt.transport.BeltInventory; import com.simibubi.create.content.contraptions.relays.belt.transport.BeltInventory;
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack; import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -22,7 +23,6 @@ import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
@ -473,7 +473,7 @@ public class BeltSlicer {
mc.player.displayClientMessage(Lang.translateDirect(feedback.langKey) mc.player.displayClientMessage(Lang.translateDirect(feedback.langKey)
.withStyle(feedback.formatting), true); .withStyle(feedback.formatting), true);
else else
mc.player.displayClientMessage(new TextComponent(""), true); mc.player.displayClientMessage(Components.immutableEmpty(), true);
if (feedback.bb != null) if (feedback.bb != null)
CreateClient.OUTLINER.chaseAABB("BeltSlicer", feedback.bb) CreateClient.OUTLINER.chaseAABB("BeltSlicer", feedback.bb)

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllEnchantments;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.AllTags; import com.simibubi.create.AllTags;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
@ -11,7 +12,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.protocol.game.ClientboundSetSubtitleTextPacket; import net.minecraft.network.protocol.game.ClientboundSetSubtitleTextPacket;
import net.minecraft.network.protocol.game.ClientboundSetTitleTextPacket; import net.minecraft.network.protocol.game.ClientboundSetTitleTextPacket;
import net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket; import net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket;
@ -70,9 +70,9 @@ public class BackTankUtil {
player.connection.send(new ClientboundSetTitlesAnimationPacket(10, 40, 10)); player.connection.send(new ClientboundSetTitlesAnimationPacket(10, 40, 10));
player.connection.send(new ClientboundSetSubtitleTextPacket( player.connection.send(new ClientboundSetSubtitleTextPacket(
new TextComponent("\u26A0 ").withStyle(depleted ? ChatFormatting.RED : ChatFormatting.GOLD) Components.literal("\u26A0 ").withStyle(depleted ? ChatFormatting.RED : ChatFormatting.GOLD)
.append(component.withStyle(ChatFormatting.GRAY)))); .append(component.withStyle(ChatFormatting.GRAY))));
player.connection.send(new ClientboundSetTitleTextPacket(new TextComponent(""))); player.connection.send(new ClientboundSetTitleTextPacket(Components.immutableEmpty()));
} }
public static int maxAir(ItemStack backtank) { public static int maxAir(ItemStack backtank) {

View file

@ -10,6 +10,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.EntityModel; import net.minecraft.client.model.EntityModel;
@ -25,7 +26,6 @@ import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.RenderLayer; import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.tags.FluidTags; import net.minecraft.tags.FluidTags;
import net.minecraft.util.StringUtil; import net.minecraft.util.StringUtil;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@ -129,7 +129,7 @@ public class CopperBacktankArmorLayer<T extends LivingEntity, M extends EntityMo
poseStack.translate(width / 2 + 90, height - 53, 0); poseStack.translate(width / 2 + 90, height - 53, 0);
Component text = new TextComponent(StringUtil.formatTickDuration(timeLeft * 20)); Component text = Components.literal(StringUtil.formatTickDuration(timeLeft * 20));
GuiGameElement.of(AllItems.COPPER_BACKTANK.asStack()) GuiGameElement.of(AllItems.COPPER_BACKTANK.asStack())
.at(0, 0) .at(0, 0)
.render(poseStack); .render(poseStack);

View file

@ -5,6 +5,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
import com.mojang.brigadier.StringReader; import com.mojang.brigadier.StringReader;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import com.simibubi.create.content.contraptions.particle.ICustomParticleDataWithSprite; import com.simibubi.create.content.contraptions.particle.ICustomParticleDataWithSprite;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
@ -16,7 +17,6 @@ import net.minecraft.core.particles.ParticleType;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
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.registries.ForgeRegistries;
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault @MethodsReturnNonnullByDefault
@ -61,7 +61,7 @@ public abstract class BasicParticleData<T extends Particle> implements ParticleO
@Override @Override
public String writeToString() { public String writeToString() {
return ForgeRegistries.PARTICLE_TYPES.getKey(getType()).toString(); return RegisteredObjects.getKeyOrThrow(getType()).toString();
} }
@Override @Override

View file

@ -124,8 +124,8 @@ public class SymmetryHandler {
.tesselateBlock(player.level, model, Blocks.AIR.defaultBlockState(), pos, ms, builder, true, .tesselateBlock(player.level, model, Blocks.AIR.defaultBlockState(), pos, ms, builder, true,
random, Mth.getSeed(pos), OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE); random, Mth.getSeed(pos), OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
buffer.endBatch();
ms.popPose(); ms.popPose();
buffer.endBatch();
} }
} }

View file

@ -16,10 +16,10 @@ import com.simibubi.create.foundation.gui.widget.Label;
import com.simibubi.create.foundation.gui.widget.ScrollInput; import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput; import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
@ -61,9 +61,9 @@ public class SymmetryWandScreen extends AbstractSimiScreen {
int x = guiLeft; int x = guiLeft;
int y = guiTop; int y = guiTop;
labelType = new Label(x + 49, y + 28, TextComponent.EMPTY).colored(0xFFFFFFFF) labelType = new Label(x + 49, y + 28, Components.immutableEmpty()).colored(0xFFFFFFFF)
.withShadow(); .withShadow();
labelAlign = new Label(x + 49, y + 50, TextComponent.EMPTY).colored(0xFFFFFFFF) labelAlign = new Label(x + 49, y + 50, Components.immutableEmpty()).colored(0xFFFFFFFF)
.withShadow(); .withShadow();
int state = int state =

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.curiosities.weapons;
import java.util.UUID; import java.util.UUID;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
@ -43,7 +44,6 @@ import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.EntityTeleportEvent; import net.minecraftforge.event.entity.EntityTeleportEvent;
import net.minecraftforge.registries.IRegistryDelegate;
public class BuiltinPotatoProjectileTypes { public class BuiltinPotatoProjectileTypes {
@ -62,7 +62,7 @@ public class BuiltinPotatoProjectileTypes {
.velocity(1.25f) .velocity(1.25f)
.knockback(1.5f) .knockback(1.5f)
.renderTumbling() .renderTumbling()
.onBlockHit(plantCrop(Blocks.POTATOES.delegate)) .onBlockHit(plantCrop(Blocks.POTATOES))
.registerAndAssign(Items.POTATO), .registerAndAssign(Items.POTATO),
BAKED_POTATO = create("baked_potato").damage(5) BAKED_POTATO = create("baked_potato").damage(5)
@ -79,7 +79,7 @@ public class BuiltinPotatoProjectileTypes {
.knockback(0.3f) .knockback(0.3f)
.renderTowardMotion(140, 1) .renderTowardMotion(140, 1)
.soundPitch(1.5f) .soundPitch(1.5f)
.onBlockHit(plantCrop(Blocks.CARROTS.delegate)) .onBlockHit(plantCrop(Blocks.CARROTS))
.registerAndAssign(Items.CARROT), .registerAndAssign(Items.CARROT),
GOLDEN_CARROT = create("golden_carrot").damage(12) GOLDEN_CARROT = create("golden_carrot").damage(12)
@ -213,7 +213,7 @@ public class BuiltinPotatoProjectileTypes {
.velocity(0.95f) .velocity(0.95f)
.renderTumbling() .renderTumbling()
.soundPitch(0.9f) .soundPitch(0.9f)
.onBlockHit(placeBlockOnGround(Blocks.MELON.delegate)) .onBlockHit(placeBlockOnGround(Blocks.MELON))
.registerAndAssign(Blocks.MELON), .registerAndAssign(Blocks.MELON),
PUMPKIN_BLOCK = create("pumpkin_block").damage(6) PUMPKIN_BLOCK = create("pumpkin_block").damage(6)
@ -222,7 +222,7 @@ public class BuiltinPotatoProjectileTypes {
.velocity(0.95f) .velocity(0.95f)
.renderTumbling() .renderTumbling()
.soundPitch(0.9f) .soundPitch(0.9f)
.onBlockHit(placeBlockOnGround(Blocks.PUMPKIN.delegate)) .onBlockHit(placeBlockOnGround(Blocks.PUMPKIN))
.registerAndAssign(Blocks.PUMPKIN), .registerAndAssign(Blocks.PUMPKIN),
PUMPKIN_PIE = create("pumpkin_pie").damage(7) PUMPKIN_PIE = create("pumpkin_pie").damage(7)
@ -303,7 +303,7 @@ public class BuiltinPotatoProjectileTypes {
entity.addEffect(effect); entity.addEffect(effect);
} }
private static BiPredicate<LevelAccessor, BlockHitResult> plantCrop(IRegistryDelegate<? extends Block> cropBlock) { private static BiPredicate<LevelAccessor, BlockHitResult> plantCrop(Supplier<? extends Block> cropBlock) {
return (world, ray) -> { return (world, ray) -> {
if (world.isClientSide()) if (world.isClientSide())
return true; return true;
@ -328,8 +328,12 @@ public class BuiltinPotatoProjectileTypes {
}; };
} }
private static BiPredicate<LevelAccessor, BlockHitResult> plantCrop(Block cropBlock) {
return plantCrop(cropBlock.delegate);
}
private static BiPredicate<LevelAccessor, BlockHitResult> placeBlockOnGround( private static BiPredicate<LevelAccessor, BlockHitResult> placeBlockOnGround(
IRegistryDelegate<? extends Block> block) { Supplier<? extends Block> block) {
return (world, ray) -> { return (world, ray) -> {
if (world.isClientSide()) if (world.isClientSide())
return true; return true;
@ -364,6 +368,10 @@ public class BuiltinPotatoProjectileTypes {
}; };
} }
private static BiPredicate<LevelAccessor, BlockHitResult> placeBlockOnGround(Block block) {
return placeBlockOnGround(block.delegate);
}
private static Predicate<EntityHitResult> chorusTeleport(double teleportDiameter) { private static Predicate<EntityHitResult> chorusTeleport(double teleportDiameter) {
return ray -> { return ray -> {
Entity entity = ray.getEntity(); Entity entity = ray.getEntity();

View file

@ -14,6 +14,7 @@ import com.simibubi.create.content.curiosities.zapper.ShootableGadgetItemMethods
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.item.render.SimpleCustomRenderer; import com.simibubi.create.foundation.item.render.SimpleCustomRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -24,8 +25,6 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
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.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -222,21 +221,21 @@ public class PotatoCannonItem extends ProjectileWeaponItem {
String _reload = "potato_cannon.ammo.reload_ticks"; String _reload = "potato_cannon.ammo.reload_ticks";
String _knockback = "potato_cannon.ammo.knockback"; String _knockback = "potato_cannon.ammo.knockback";
tooltip.add(new TextComponent("")); tooltip.add(Components.immutableEmpty());
tooltip.add(new TranslatableComponent(ammo.getDescriptionId()).append(new TextComponent(":")) tooltip.add(Components.translatable(ammo.getDescriptionId()).append(Components.literal(":"))
.withStyle(ChatFormatting.GRAY)); .withStyle(ChatFormatting.GRAY));
PotatoCannonProjectileType type = PotatoProjectileTypeManager.getTypeForStack(ammo) PotatoCannonProjectileType type = PotatoProjectileTypeManager.getTypeForStack(ammo)
.get(); .get();
TextComponent spacing = new TextComponent(" "); MutableComponent spacing = Components.literal(" ");
ChatFormatting green = ChatFormatting.GREEN; ChatFormatting green = ChatFormatting.GREEN;
ChatFormatting darkGreen = ChatFormatting.DARK_GREEN; ChatFormatting darkGreen = ChatFormatting.DARK_GREEN;
float damageF = type.getDamage() * additionalDamageMult; float damageF = type.getDamage() * additionalDamageMult;
MutableComponent damage = new TextComponent( MutableComponent damage = Components.literal(
damageF == Mth.floor(damageF) ? "" + Mth.floor(damageF) : "" + damageF); damageF == Mth.floor(damageF) ? "" + Mth.floor(damageF) : "" + damageF);
MutableComponent reloadTicks = new TextComponent("" + type.getReloadTicks()); MutableComponent reloadTicks = Components.literal("" + type.getReloadTicks());
MutableComponent knockback = MutableComponent knockback =
new TextComponent("" + (type.getKnockback() + additionalKnockback)); Components.literal("" + (type.getKnockback() + additionalKnockback));
damage = damage.withStyle(additionalDamageMult > 1 ? green : darkGreen); damage = damage.withStyle(additionalDamageMult > 1 ? green : darkGreen);
knockback = knockback.withStyle(additionalKnockback > 0 ? green : darkGreen); knockback = knockback.withStyle(additionalKnockback > 0 ? green : darkGreen);

View file

@ -1,14 +1,16 @@
package com.simibubi.create.content.curiosities.weapons; package com.simibubi.create.content.curiosities.weapons;
import java.util.HashSet; import java.util.ArrayList;
import java.util.Set; import java.util.List;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.ResourceLocationException; import net.minecraft.ResourceLocationException;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
@ -19,11 +21,10 @@ import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.EntityHitResult;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.IRegistryDelegate;
public class PotatoCannonProjectileType { public class PotatoCannonProjectileType {
private Set<IRegistryDelegate<Item>> items = new HashSet<>(); private List<Supplier<Item>> items = new ArrayList<>();
private int reloadTicks = 10; private int reloadTicks = 10;
private int damage = 1; private int damage = 1;
@ -43,7 +44,7 @@ public class PotatoCannonProjectileType {
protected PotatoCannonProjectileType() { protected PotatoCannonProjectileType() {
} }
public Set<IRegistryDelegate<Item>> getItems() { public List<Supplier<Item>> getItems() {
return items; return items;
} }
@ -148,8 +149,8 @@ public class PotatoCannonProjectileType {
public static void toBuffer(PotatoCannonProjectileType type, FriendlyByteBuf buffer) { public static void toBuffer(PotatoCannonProjectileType type, FriendlyByteBuf buffer) {
buffer.writeVarInt(type.items.size()); buffer.writeVarInt(type.items.size());
for (IRegistryDelegate<Item> delegate : type.items) { for (Supplier<Item> delegate : type.items) {
buffer.writeResourceLocation(delegate.name()); buffer.writeResourceLocation(RegisteredObjects.getKeyOrThrow(delegate.get()));
} }
buffer.writeInt(type.reloadTicks); buffer.writeInt(type.reloadTicks);
buffer.writeInt(type.damage); buffer.writeInt(type.damage);

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.curiosities.weapons; package com.simibubi.create.content.curiosities.weapons;
import java.util.HashMap; import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -22,13 +23,12 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.network.NetworkEvent.Context; import net.minecraftforge.network.NetworkEvent.Context;
import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PacketDistributor;
import net.minecraftforge.registries.IRegistryDelegate;
public class PotatoProjectileTypeManager { public class PotatoProjectileTypeManager {
private static final Map<ResourceLocation, PotatoCannonProjectileType> BUILTIN_TYPE_MAP = new HashMap<>(); private static final Map<ResourceLocation, PotatoCannonProjectileType> BUILTIN_TYPE_MAP = new HashMap<>();
private static final Map<ResourceLocation, PotatoCannonProjectileType> CUSTOM_TYPE_MAP = new HashMap<>(); private static final Map<ResourceLocation, PotatoCannonProjectileType> CUSTOM_TYPE_MAP = new HashMap<>();
private static final Map<IRegistryDelegate<Item>, PotatoCannonProjectileType> ITEM_TO_TYPE_MAP = new HashMap<>(); private static final Map<Item, PotatoCannonProjectileType> ITEM_TO_TYPE_MAP = new IdentityHashMap<>();
public static void registerBuiltinType(ResourceLocation id, PotatoCannonProjectileType type) { public static void registerBuiltinType(ResourceLocation id, PotatoCannonProjectileType type) {
synchronized (BUILTIN_TYPE_MAP) { synchronized (BUILTIN_TYPE_MAP) {
@ -44,14 +44,14 @@ public class PotatoProjectileTypeManager {
return CUSTOM_TYPE_MAP.get(id); return CUSTOM_TYPE_MAP.get(id);
} }
public static PotatoCannonProjectileType getTypeForItem(IRegistryDelegate<Item> item) { public static PotatoCannonProjectileType getTypeForItem(Item item) {
return ITEM_TO_TYPE_MAP.get(item); return ITEM_TO_TYPE_MAP.get(item);
} }
public static Optional<PotatoCannonProjectileType> getTypeForStack(ItemStack item) { public static Optional<PotatoCannonProjectileType> getTypeForStack(ItemStack item) {
if (item.isEmpty()) if (item.isEmpty())
return Optional.empty(); return Optional.empty();
return Optional.ofNullable(getTypeForItem(item.getItem().delegate)); return Optional.ofNullable(getTypeForItem(item.getItem()));
} }
public static void clear() { public static void clear() {
@ -62,17 +62,17 @@ public class PotatoProjectileTypeManager {
public static void fillItemMap() { public static void fillItemMap() {
for (Map.Entry<ResourceLocation, PotatoCannonProjectileType> entry : BUILTIN_TYPE_MAP.entrySet()) { for (Map.Entry<ResourceLocation, PotatoCannonProjectileType> entry : BUILTIN_TYPE_MAP.entrySet()) {
PotatoCannonProjectileType type = entry.getValue(); PotatoCannonProjectileType type = entry.getValue();
for (IRegistryDelegate<Item> delegate : type.getItems()) { for (Supplier<Item> delegate : type.getItems()) {
ITEM_TO_TYPE_MAP.put(delegate, type); ITEM_TO_TYPE_MAP.put(delegate.get(), type);
} }
} }
for (Map.Entry<ResourceLocation, PotatoCannonProjectileType> entry : CUSTOM_TYPE_MAP.entrySet()) { for (Map.Entry<ResourceLocation, PotatoCannonProjectileType> entry : CUSTOM_TYPE_MAP.entrySet()) {
PotatoCannonProjectileType type = entry.getValue(); PotatoCannonProjectileType type = entry.getValue();
for (IRegistryDelegate<Item> delegate : type.getItems()) { for (Supplier<Item> delegate : type.getItems()) {
ITEM_TO_TYPE_MAP.put(delegate, type); ITEM_TO_TYPE_MAP.put(delegate.get(), type);
} }
} }
ITEM_TO_TYPE_MAP.remove(AllItems.POTATO_CANNON.get().delegate); ITEM_TO_TYPE_MAP.remove(AllItems.POTATO_CANNON.get());
} }
public static void toBuffer(FriendlyByteBuf buffer) { public static void toBuffer(FriendlyByteBuf buffer) {

View file

@ -10,13 +10,13 @@ import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.element.GuiGameElement; import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton; import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Components;
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;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
@ -44,7 +44,7 @@ public abstract class ZapperScreen extends AbstractSimiScreen {
this.background = background; this.background = background;
this.zapper = zapper; this.zapper = zapper;
this.hand = hand; this.hand = hand;
title = TextComponent.EMPTY; title = Components.immutableEmpty();
brightColor = 0xFEFEFE; brightColor = 0xFEFEFE;
fontColor = AllGuiTextures.FONT_COLOR; fontColor = AllGuiTextures.FONT_COLOR;

View file

@ -14,6 +14,7 @@ import com.simibubi.create.foundation.gui.widget.Indicator.State;
import com.simibubi.create.foundation.gui.widget.Label; import com.simibubi.create.foundation.gui.widget.Label;
import com.simibubi.create.foundation.gui.widget.ScrollInput; import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput; import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.utility.Components;
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;
@ -22,7 +23,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -82,7 +82,7 @@ public class WorldshaperScreen extends ZapperScreen {
int x = guiLeft; int x = guiLeft;
int y = guiTop; int y = guiTop;
brushLabel = new Label(x + 61, y + 25, TextComponent.EMPTY).withShadow(); brushLabel = new Label(x + 61, y + 25, Components.immutableEmpty()).withShadow();
brushInput = new SelectionScrollInput(x + 56, y + 20, 77, 18).forOptions(brushOptions) brushInput = new SelectionScrollInput(x + 56, y + 20, 77, 18).forOptions(brushOptions)
.titled(Lang.translateDirect("gui.terrainzapper.brush")) .titled(Lang.translateDirect("gui.terrainzapper.brush"))
.writingTo(brushLabel) .writingTo(brushLabel)
@ -111,7 +111,7 @@ public class WorldshaperScreen extends ZapperScreen {
brushParams.clear(); brushParams.clear();
for (int index = 0; index < 3; index++) { for (int index = 0; index < 3; index++) {
Label label = new Label(x + 65 + 20 * index, y + 45, TextComponent.EMPTY).withShadow(); Label label = new Label(x + 65 + 20 * index, y + 45, Components.immutableEmpty()).withShadow();
final int finalIndex = index; final int finalIndex = index;
ScrollInput input = new ScrollInput(x + 56 + 20 * index, y + 40, 18, 18) ScrollInput input = new ScrollInput(x + 56 + 20 * index, y + 40, 18, 18)
@ -155,10 +155,10 @@ public class WorldshaperScreen extends ZapperScreen {
if (currentBrush.hasConnectivityOptions()) { if (currentBrush.hasConnectivityOptions()) {
int x1 = x + 7 + 4 * 18; int x1 = x + 7 + 4 * 18;
int y1 = y + 79; int y1 = y + 79;
followDiagonalsIndicator = new Indicator(x1, y1 - 6, TextComponent.EMPTY); followDiagonalsIndicator = new Indicator(x1, y1 - 6, Components.immutableEmpty());
followDiagonals = new IconButton(x1, y1, AllIcons.I_FOLLOW_DIAGONAL); followDiagonals = new IconButton(x1, y1, AllIcons.I_FOLLOW_DIAGONAL);
x1 += 18; x1 += 18;
acrossMaterialsIndicator = new Indicator(x1, y1 - 6, TextComponent.EMPTY); acrossMaterialsIndicator = new Indicator(x1, y1 - 6, Components.immutableEmpty());
acrossMaterials = new IconButton(x1, y1, AllIcons.I_FOLLOW_MATERIAL); acrossMaterials = new IconButton(x1, y1, AllIcons.I_FOLLOW_MATERIAL);
followDiagonals.withCallback(() -> { followDiagonals.withCallback(() -> {

View file

@ -26,6 +26,7 @@ import com.simibubi.create.foundation.tileEntity.behaviour.filtering.SidedFilter
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOptionBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOptionBehaviour;
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
@ -40,7 +41,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
@ -752,7 +752,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave
.withStyle(ChatFormatting.WHITE)); .withStyle(ChatFormatting.WHITE));
for (ItemStack item : allStacks) { for (ItemStack item : allStacks) {
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(Lang.translateDirect("tooltip.brass_tunnel.contains_entry", new TranslatableComponent(item.getDescriptionId()) .append(Lang.translateDirect("tooltip.brass_tunnel.contains_entry", Components.translatable(item.getDescriptionId())
.getString(), item.getCount())) .getString(), item.getCount()))
.withStyle(ChatFormatting.GRAY)); .withStyle(ChatFormatting.GRAY));
} }

View file

@ -25,6 +25,7 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputB
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -38,7 +39,6 @@ import net.minecraft.core.particles.ItemParticleOption;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.Containers; import net.minecraft.world.Containers;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
@ -719,7 +719,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
.withStyle(ChatFormatting.YELLOW))); .withStyle(ChatFormatting.YELLOW)));
if (!item.isEmpty()) { if (!item.isEmpty()) {
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(Lang.translateDirect("tooltip.chute.contains", new TranslatableComponent(item.getDescriptionId()) .append(Lang.translateDirect("tooltip.chute.contains", Components.translatable(item.getDescriptionId())
.getString(), item.getCount())) .getString(), item.getCount()))
.withStyle(ChatFormatting.GREEN)); .withStyle(ChatFormatting.GREEN));
} }

View file

@ -17,6 +17,8 @@ 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.RegisteredObjects;
import com.tterrag.registrate.util.nullness.NonNullConsumer; import com.tterrag.registrate.util.nullness.NonNullConsumer;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -27,17 +29,17 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity; 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.IRegistryDelegate; 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<>();
public static final Map<IRegistryDelegate<Block>, List<DisplaySource>> SOURCES_BY_BLOCK = new HashMap<>(); private static final CreateRegistry<Block, List<DisplaySource>> SOURCES_BY_BLOCK = new CreateRegistry<>(ForgeRegistries.BLOCKS);
public static final Map<IRegistryDelegate<BlockEntityType<?>>, List<DisplaySource>> SOURCES_BY_TILE = new HashMap<>(); private static final CreateRegistry<BlockEntityType<?>, List<DisplaySource>> SOURCES_BY_TILE = new CreateRegistry<>(ForgeRegistries.BLOCK_ENTITIES);
public static final Map<IRegistryDelegate<Block>, DisplayTarget> TARGETS_BY_BLOCK = new HashMap<>(); private static final CreateRegistry<Block, DisplayTarget> TARGETS_BY_BLOCK = new CreateRegistry<>(ForgeRegistries.BLOCKS);
public static final Map<IRegistryDelegate<BlockEntityType<?>>, DisplayTarget> TARGETS_BY_TILE = new HashMap<>(); private static final CreateRegistry<BlockEntityType<?>, DisplayTarget> TARGETS_BY_TILE = new CreateRegistry<>(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;
@ -45,45 +47,95 @@ public class AllDisplayBehaviours {
return behaviour; return behaviour;
} }
public static void assignBlock(DisplayBehaviour behaviour, IRegistryDelegate<Block> block) { public static void assignBlock(DisplayBehaviour behaviour, ResourceLocation block) {
if (behaviour instanceof DisplaySource source) if (behaviour instanceof DisplaySource source) {
SOURCES_BY_BLOCK.computeIfAbsent(block, r -> new ArrayList<>()) List<DisplaySource> sources = SOURCES_BY_BLOCK.get(block);
.add(source); if (sources == null) {
if (behaviour instanceof DisplayTarget target) sources = new ArrayList<>();
TARGETS_BY_BLOCK.put(block, target); SOURCES_BY_BLOCK.register(block, sources);
}
sources.add(source);
}
if (behaviour instanceof DisplayTarget target) {
TARGETS_BY_BLOCK.register(block, target);
}
} }
public static void assignTile(DisplayBehaviour behaviour, ResourceLocation teType) {
if (behaviour instanceof DisplaySource source) {
List<DisplaySource> sources = SOURCES_BY_TILE.get(teType);
if (sources == null) {
sources = new ArrayList<>();
SOURCES_BY_TILE.register(teType, sources);
}
sources.add(source);
}
if (behaviour instanceof DisplayTarget target) {
TARGETS_BY_TILE.register(teType, target);
}
}
public static void assignBlock(DisplayBehaviour behaviour, Block block) {
if (behaviour instanceof DisplaySource source) {
List<DisplaySource> sources = SOURCES_BY_BLOCK.get(block);
if (sources == null) {
sources = new ArrayList<>();
SOURCES_BY_BLOCK.register(block, sources);
}
sources.add(source);
}
if (behaviour instanceof DisplayTarget target) {
TARGETS_BY_BLOCK.register(block, target);
}
}
public static void assignTile(DisplayBehaviour behaviour, BlockEntityType<?> teType) {
if (behaviour instanceof DisplaySource source) {
List<DisplaySource> sources = SOURCES_BY_TILE.get(teType);
if (sources == null) {
sources = new ArrayList<>();
SOURCES_BY_TILE.register(teType, sources);
}
sources.add(source);
}
if (behaviour instanceof DisplayTarget target) {
TARGETS_BY_TILE.register(teType, target);
}
}
@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) { public static void assignTile(DisplayBehaviour behaviour, IRegistryDelegate<BlockEntityType<?>> teType) {
if (behaviour instanceof DisplaySource source) assignTile(behaviour, teType.name());
SOURCES_BY_TILE.computeIfAbsent(teType, r -> new ArrayList<>())
.add(source);
if (behaviour instanceof DisplayTarget target)
TARGETS_BY_TILE.put(teType, target);
} }
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 -> {
ResourceLocation registryName = b.getRegistryName(); ResourceLocation registryName = RegisteredObjects.getKeyOrThrow(b);
String idSuffix = behaviour instanceof DisplaySource ? "_source" : "_target"; String idSuffix = behaviour instanceof DisplaySource ? "_source" : "_target";
if (suffix.length > 0) if (suffix.length > 0)
idSuffix += "_" + suffix[0]; idSuffix += "_" + suffix[0];
assignBlock(register(new ResourceLocation(registryName.getNamespace(), registryName.getPath() + idSuffix), assignBlock(register(new ResourceLocation(registryName.getNamespace(), registryName.getPath() + idSuffix),
behaviour), b.delegate); behaviour), registryName);
}; };
} }
public static <B extends BlockEntityType<?>> NonNullConsumer<? super B> assignDataBehaviourTE( public static <B extends BlockEntityType<?>> NonNullConsumer<? super B> assignDataBehaviourTE(
DisplayBehaviour behaviour, String... suffix) { DisplayBehaviour behaviour, String... suffix) {
return b -> { return b -> {
ResourceLocation registryName = b.getRegistryName(); ResourceLocation registryName = RegisteredObjects.getKeyOrThrow(b);
String idSuffix = behaviour instanceof DisplaySource ? "_source" : "_target"; String idSuffix = behaviour instanceof DisplaySource ? "_source" : "_target";
if (suffix.length > 0) if (suffix.length > 0)
idSuffix += "_" + suffix[0]; idSuffix += "_" + suffix[0];
assignTile( assignTile(
register(new ResourceLocation(registryName.getNamespace(), registryName.getPath() + idSuffix), register(new ResourceLocation(registryName.getNamespace(), registryName.getPath() + idSuffix),
behaviour), behaviour),
b.delegate); registryName);
}; };
} }
@ -108,7 +160,11 @@ public class AllDisplayBehaviours {
// //
public static List<DisplaySource> sourcesOf(Block block) { public static List<DisplaySource> sourcesOf(Block block) {
return SOURCES_BY_BLOCK.getOrDefault(block.delegate, Collections.emptyList()); List<DisplaySource> sources = SOURCES_BY_BLOCK.get(block);
if (sources == null) {
return Collections.emptyList();
}
return sources;
} }
public static List<DisplaySource> sourcesOf(BlockState state) { public static List<DisplaySource> sourcesOf(BlockState state) {
@ -116,7 +172,11 @@ public class AllDisplayBehaviours {
} }
public static List<DisplaySource> sourcesOf(BlockEntityType<?> tileEntityType) { public static List<DisplaySource> sourcesOf(BlockEntityType<?> tileEntityType) {
return SOURCES_BY_TILE.getOrDefault(tileEntityType.delegate, Collections.emptyList()); List<DisplaySource> sources = SOURCES_BY_TILE.get(tileEntityType);
if (sources == null) {
return Collections.emptyList();
}
return sources;
} }
public static List<DisplaySource> sourcesOf(BlockEntity tileEntity) { public static List<DisplaySource> sourcesOf(BlockEntity tileEntity) {
@ -125,7 +185,7 @@ public class AllDisplayBehaviours {
@Nullable @Nullable
public static DisplayTarget targetOf(Block block) { public static DisplayTarget targetOf(Block block) {
return TARGETS_BY_BLOCK.get(block.delegate); return TARGETS_BY_BLOCK.get(block);
} }
@Nullable @Nullable
@ -135,7 +195,7 @@ public class AllDisplayBehaviours {
@Nullable @Nullable
public static DisplayTarget targetOf(BlockEntityType<?> tileEntityType) { public static DisplayTarget targetOf(BlockEntityType<?> tileEntityType) {
return TARGETS_BY_TILE.get(tileEntityType.delegate); return TARGETS_BY_TILE.get(tileEntityType);
} }
@Nullable @Nullable
@ -171,11 +231,11 @@ public class AllDisplayBehaviours {
// //
public static void registerDefaults() { public static void registerDefaults() {
assignTile(register(Create.asResource("sign_display_target"), new SignDisplayTarget()), BlockEntityType.SIGN.delegate); assignTile(register(Create.asResource("sign_display_target"), new SignDisplayTarget()), BlockEntityType.SIGN);
assignTile(register(Create.asResource("lectern_display_target"), new LecternDisplayTarget()), BlockEntityType.LECTERN.delegate); assignTile(register(Create.asResource("lectern_display_target"), new LecternDisplayTarget()), BlockEntityType.LECTERN);
assignBlock(register(Create.asResource("death_count_display_source"), new DeathCounterDisplaySource()), Blocks.RESPAWN_ANCHOR.delegate); assignBlock(register(Create.asResource("death_count_display_source"), new DeathCounterDisplaySource()), Blocks.RESPAWN_ANCHOR);
assignTile(register(Create.asResource("scoreboard_display_source"), new ScoreboardDisplaySource()), BlockEntityType.COMMAND_BLOCK.delegate); assignTile(register(Create.asResource("scoreboard_display_source"), new ScoreboardDisplaySource()), BlockEntityType.COMMAND_BLOCK);
assignTile(register(Create.asResource("enchant_power_display_source"), new EnchantPowerDisplaySource()), BlockEntityType.ENCHANTING_TABLE.delegate); assignTile(register(Create.asResource("enchant_power_display_source"), new EnchantPowerDisplaySource()), BlockEntityType.ENCHANTING_TABLE);
assignBlock(register(Create.asResource("redstone_power_display_source"), new RedstonePowerDisplaySource()), Blocks.TARGET.delegate); assignBlock(register(Create.asResource("redstone_power_display_source"), new RedstonePowerDisplaySource()), Blocks.TARGET);
} }
} }

View file

@ -25,6 +25,7 @@ import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.ponder.PonderTag; import com.simibubi.create.foundation.ponder.PonderTag;
import com.simibubi.create.foundation.ponder.ui.PonderTagScreen; import com.simibubi.create.foundation.ponder.ui.PonderTagScreen;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
@ -35,7 +36,6 @@ import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
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.network.chat.TextComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
@ -137,7 +137,7 @@ public class DisplayLinkScreen extends AbstractSimiScreen {
int rows = stats.maxRows(); int rows = stats.maxRows();
int startIndex = Math.min(te.targetLine, rows); int startIndex = Math.min(te.targetLine, rows);
targetLineLabel = new Label(x + 65, y + 109, TextComponent.EMPTY).withShadow(); targetLineLabel = new Label(x + 65, y + 109, Components.immutableEmpty()).withShadow();
targetLineLabel.text = target.getLineOptionText(startIndex); targetLineLabel.text = target.getLineOptionText(startIndex);
if (rows > 1) { if (rows > 1) {
@ -189,7 +189,7 @@ public class DisplayLinkScreen extends AbstractSimiScreen {
if (!sources.isEmpty()) { if (!sources.isEmpty()) {
int startIndex = Math.max(sources.indexOf(te.activeSource), 0); int startIndex = Math.max(sources.indexOf(te.activeSource), 0);
sourceTypeLabel = new Label(x + 65, y + 30, TextComponent.EMPTY).withShadow(); sourceTypeLabel = new Label(x + 65, y + 30, Components.immutableEmpty()).withShadow();
sourceTypeLabel.text = sources.get(startIndex) sourceTypeLabel.text = sources.get(startIndex)
.getName(); .getName();

View file

@ -4,15 +4,15 @@ import com.simibubi.create.content.logistics.block.display.DisplayLinkBlock;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.block.display.DisplayLinkTileEntity; import com.simibubi.create.content.logistics.block.display.DisplayLinkTileEntity;
import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats; import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
public class AccumulatedItemCountDisplaySource extends NumericSingleLineDisplaySource { public class AccumulatedItemCountDisplaySource extends NumericSingleLineDisplaySource {
@Override @Override
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) { protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
return new TextComponent(String.valueOf(context.sourceConfig() return Components.literal(String.valueOf(context.sourceConfig()
.getInt("Collected"))); .getInt("Collected")));
} }

View file

@ -11,12 +11,12 @@ import com.simibubi.create.content.logistics.block.display.target.DisplayTargetS
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayLayout; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayLayout;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import joptsimple.internal.Strings; import joptsimple.internal.Strings;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.LecternBlockEntity; import net.minecraft.world.level.block.entity.LecternBlockEntity;
@ -50,7 +50,7 @@ public class BoilerDisplaySource extends DisplaySource {
return reduce.orElse(EMPTY_LINE); return reduce.orElse(EMPTY_LINE);
}); });
return List.of(componentList.reduce((comp1, comp2) -> comp1.append(new TextComponent("\n")) return List.of(componentList.reduce((comp1, comp2) -> comp1.append(Components.literal("\n"))
.append(comp2)) .append(comp2))
.orElse(EMPTY_LINE)); .orElse(EMPTY_LINE));
} }
@ -128,9 +128,9 @@ public class BoilerDisplaySource extends DisplaySource {
int lw = labelWidth(); int lw = labelWidth();
if (forFlapDisplay) { if (forFlapDisplay) {
size = new TextComponent(Strings.repeat(' ', lw - labelWidthOf("size"))).append(size); size = Components.literal(Strings.repeat(' ', lw - labelWidthOf("size"))).append(size);
water = new TextComponent(Strings.repeat(' ', lw - labelWidthOf("water"))).append(water); water = Components.literal(Strings.repeat(' ', lw - labelWidthOf("water"))).append(water);
heat = new TextComponent(Strings.repeat(' ', lw - labelWidthOf("heat"))).append(heat); heat = Components.literal(Strings.repeat(' ', lw - labelWidthOf("heat"))).append(heat);
} }
return Stream.of(List.of(Lang.translateDirect(label, boiler.getHeatLevelTextComponent())), return Stream.of(List.of(Lang.translateDirect(label, boiler.getHeatLevelTextComponent())),
@ -150,7 +150,7 @@ public class BoilerDisplaySource extends DisplaySource {
private MutableComponent labelOf(String label) { private MutableComponent labelOf(String label) {
if (label.isBlank()) if (label.isBlank())
return TextComponent.EMPTY.copy(); return Components.empty();
return Lang.translateDirect("boiler." + label); return Lang.translateDirect("boiler." + label);
} }

View file

@ -12,19 +12,18 @@ import com.simibubi.create.content.logistics.block.display.target.DisplayTargetS
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayLayout; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayLayout;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
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.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
public abstract class DisplaySource extends DisplayBehaviour { public abstract class DisplaySource extends DisplayBehaviour {
public static final List<MutableComponent> EMPTY = ImmutableList.of(new TextComponent("")); public static final List<MutableComponent> EMPTY = ImmutableList.of(Components.empty());
public static final MutableComponent EMPTY_LINE = new TextComponent(""); public static final MutableComponent EMPTY_LINE = Components.empty();
public static final MutableComponent WHITESPACE = new TextComponent(" "); public static final MutableComponent WHITESPACE = Components.literal(" ");
public abstract List<MutableComponent> provideText(DisplayLinkContext context, DisplayTargetStats stats); public abstract List<MutableComponent> provideText(DisplayLinkContext context, DisplayTargetStats stats);
@ -55,7 +54,7 @@ public abstract class DisplaySource extends DisplayBehaviour {
} }
public Component getName() { public Component getName() {
return new TranslatableComponent(id.getNamespace() + ".display_source." + getTranslationKey()); return Components.translatable(id.getNamespace() + ".display_source." + getTranslationKey());
} }
public void loadFlapDisplayLayout(DisplayLinkContext context, FlapDisplayTileEntity flapDisplay, FlapDisplayLayout layout, int lineIndex) { public void loadFlapDisplayLayout(DisplayLinkContext context, FlapDisplayTileEntity flapDisplay, FlapDisplayLayout layout, int lineIndex) {

View file

@ -4,10 +4,10 @@ import java.util.Random;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats; import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.EnchantmentHelper;
@ -23,7 +23,7 @@ public class EnchantPowerDisplaySource extends NumericSingleLineDisplaySource {
@Override @Override
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) { protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
if (!(context.getSourceTE() instanceof EnchantmentTableBlockEntity enchantmentTile)) if (!(context.getSourceTE() instanceof EnchantmentTableBlockEntity enchantmentTile))
return ZERO; return ZERO.copy();
BlockPos pos = context.getSourcePos(); BlockPos pos = context.getSourcePos();
Level level = context.level(); Level level = context.level();
@ -39,7 +39,7 @@ public class EnchantPowerDisplaySource extends NumericSingleLineDisplaySource {
int cost = EnchantmentHelper.getEnchantmentCost(random, 2, (int) enchantPower, stack); int cost = EnchantmentHelper.getEnchantmentCost(random, 2, (int) enchantPower, stack);
return new TextComponent(String.valueOf(cost)); return Components.literal(String.valueOf(cost));
} }
@Override @Override

View file

@ -5,10 +5,10 @@ import com.simibubi.create.content.logistics.block.display.target.DisplayTargetS
import com.simibubi.create.content.logistics.block.redstone.ContentObserverTileEntity; import com.simibubi.create.content.logistics.block.redstone.ContentObserverTileEntity;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.TankManipulationBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.inventory.TankManipulationBehaviour;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.FluidFormatter; import com.simibubi.create.foundation.utility.FluidFormatter;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
@ -38,7 +38,7 @@ public class FluidAmountDisplaySource extends SingleLineDisplaySource {
collected += stack.getAmount(); collected += stack.getAmount();
} }
return new TextComponent(FluidFormatter.asString(collected, false)); return Components.literal(FluidFormatter.asString(collected, false));
} }
@Override @Override

View file

@ -15,12 +15,12 @@ import com.simibubi.create.content.logistics.trains.management.display.FlapDispl
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.TankManipulationBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.inventory.TankManipulationBehaviour;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.FluidFormatter; import com.simibubi.create.foundation.utility.FluidFormatter;
import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.IntAttached;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -63,7 +63,7 @@ public class FluidListDisplaySource extends ValueListDisplaySource {
.limit(maxRows) .limit(maxRows)
.map(entry -> IntAttached.with( .map(entry -> IntAttached.with(
entry.getValue(), entry.getValue(),
new TranslatableComponent(fluidNames.get(entry.getKey()).getTranslationKey())) Components.translatable(fluidNames.get(entry.getKey()).getTranslationKey()))
); );
} }

View file

@ -5,9 +5,9 @@ import com.simibubi.create.content.logistics.block.display.target.DisplayTargetS
import com.simibubi.create.content.logistics.block.redstone.ContentObserverTileEntity; import com.simibubi.create.content.logistics.block.redstone.ContentObserverTileEntity;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@ -18,14 +18,14 @@ public class ItemCountDisplaySource extends NumericSingleLineDisplaySource {
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) { protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
BlockEntity sourceTE = context.getSourceTE(); BlockEntity sourceTE = context.getSourceTE();
if (!(sourceTE instanceof ContentObserverTileEntity cote)) if (!(sourceTE instanceof ContentObserverTileEntity cote))
return ZERO; return ZERO.copy();
InvManipulationBehaviour invManipulationBehaviour = cote.getBehaviour(InvManipulationBehaviour.TYPE); InvManipulationBehaviour invManipulationBehaviour = cote.getBehaviour(InvManipulationBehaviour.TYPE);
FilteringBehaviour filteringBehaviour = cote.getBehaviour(FilteringBehaviour.TYPE); FilteringBehaviour filteringBehaviour = cote.getBehaviour(FilteringBehaviour.TYPE);
IItemHandler handler = invManipulationBehaviour.getInventory(); IItemHandler handler = invManipulationBehaviour.getInventory();
if (handler == null) if (handler == null)
return ZERO; return ZERO.copy();
int collected = 0; int collected = 0;
for (int i = 0; i < handler.getSlots(); i++) { for (int i = 0; i < handler.getSlots(); i++) {
@ -37,7 +37,7 @@ public class ItemCountDisplaySource extends NumericSingleLineDisplaySource {
collected += stack.getCount(); collected += stack.getCount();
} }
return new TextComponent(String.valueOf(collected)); return Components.literal(String.valueOf(collected));
} }
@Override @Override

View file

@ -12,11 +12,10 @@ import net.minecraft.nbt.FloatTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
public class ItemThoughputDisplaySource extends AccumulatedItemCountDisplaySource { public class ItemThroughputDisplaySource extends AccumulatedItemCountDisplaySource {
static final int POOL_SIZE = 10; static final int POOL_SIZE = 10;
@ -24,7 +23,7 @@ public class ItemThoughputDisplaySource extends AccumulatedItemCountDisplaySourc
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) { protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
CompoundTag conf = context.sourceConfig(); CompoundTag conf = context.sourceConfig();
if (conf.contains("Inactive")) if (conf.contains("Inactive"))
return new TextComponent("0"); return ZERO.copy();
double interval = 20 * Math.pow(60, conf.getInt("Interval")); double interval = 20 * Math.pow(60, conf.getInt("Interval"));
double rate = conf.getFloat("Rate") * interval; double rate = conf.getFloat("Rate") * interval;

View file

@ -15,7 +15,7 @@ public class KineticSpeedDisplaySource extends NumericSingleLineDisplaySource {
@Override @Override
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) { protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
if (!(context.getSourceTE() instanceof SpeedGaugeTileEntity gaugeTile)) if (!(context.getSourceTE() instanceof SpeedGaugeTileEntity gaugeTile))
return ZERO; return ZERO.copy();
boolean absoluteValue = context.sourceConfig() boolean absoluteValue = context.sourceConfig()
.getInt("Directional") == 0; .getInt("Directional") == 0;

View file

@ -2,12 +2,13 @@ package com.simibubi.create.content.logistics.block.display.source;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.Component;
public abstract class NumericSingleLineDisplaySource extends SingleLineDisplaySource { public abstract class NumericSingleLineDisplaySource extends SingleLineDisplaySource {
protected static final TextComponent ZERO = new TextComponent("0"); protected static final Component ZERO = Components.literal("0");
@Override @Override
protected String getFlapDisplayLayoutName(DisplayLinkContext context) { protected String getFlapDisplayLayoutName(DisplayLinkContext context) {

View file

@ -8,9 +8,9 @@ import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats; import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.block.entity.SignBlockEntity;
@ -47,11 +47,11 @@ public abstract class PercentOrProgressBarDisplaySource extends NumericSingleLin
for (int i = 0; i < emptySpaces; i++) for (int i = 0; i < emptySpaces; i++)
s.append("\u2592"); s.append("\u2592");
return new TextComponent(s.toString()); return Components.literal(s.toString());
} }
protected MutableComponent formatNumeric(DisplayLinkContext context, Float currentLevel) { protected MutableComponent formatNumeric(DisplayLinkContext context, Float currentLevel) {
return new TextComponent(Mth.clamp((int) (currentLevel * 100), 0, 100) + "%"); return Components.literal(Mth.clamp((int) (currentLevel * 100), 0, 100) + "%");
} }
@Nullable @Nullable

View file

@ -2,10 +2,10 @@ package com.simibubi.create.content.logistics.block.display.source;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -20,7 +20,7 @@ public class RedstonePowerDisplaySource extends PercentOrProgressBarDisplaySourc
@Override @Override
protected MutableComponent formatNumeric(DisplayLinkContext context, Float currentLevel) { protected MutableComponent formatNumeric(DisplayLinkContext context, Float currentLevel) {
return new TextComponent(String.valueOf((int) (currentLevel * 15))); return Components.literal(String.valueOf((int) (currentLevel * 15)));
} }
@Override @Override

View file

@ -5,12 +5,12 @@ import java.util.stream.Stream;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.IntAttached;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.scores.Objective; import net.minecraft.world.scores.Objective;
@ -41,7 +41,7 @@ public class ScoreboardDisplaySource extends ValueListDisplaySource {
.getPlayerScores(objective) .getPlayerScores(objective)
.stream() .stream()
.limit(maxRows) .limit(maxRows)
.map(score -> IntAttached.with(score.getScore(), new TextComponent(score.getOwner()).copy())) .map(score -> IntAttached.with(score.getScore(), Components.literal(score.getOwner()).copy()))
.sorted(IntAttached.comparator()); .sorted(IntAttached.comparator());
} }

View file

@ -9,11 +9,11 @@ import com.simibubi.create.content.logistics.trains.management.display.FlapDispl
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -51,7 +51,7 @@ public abstract class SingleLineDisplaySource extends DisplaySource {
String label = context.sourceConfig() String label = context.sourceConfig()
.getString("Label"); .getString("Label");
if (!label.isEmpty()) if (!label.isEmpty())
line = new TextComponent(label + " ").append(line); line = Components.literal(label + " ").append(line);
} }
return ImmutableList.of(line); return ImmutableList.of(line);
@ -64,7 +64,7 @@ public abstract class SingleLineDisplaySource extends DisplaySource {
String label = context.sourceConfig() String label = context.sourceConfig()
.getString("Label"); .getString("Label");
if (!label.isEmpty()) if (!label.isEmpty())
return ImmutableList.of(ImmutableList.of(new TextComponent(label + " "), provideLine(context, stats))); return ImmutableList.of(ImmutableList.of(Components.literal(label + " "), provideLine(context, stats)));
} }
return super.provideFlapDisplayText(context, stats); return super.provideFlapDisplayText(context, stats);

View file

@ -16,24 +16,24 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.station
import com.simibubi.create.content.logistics.trains.management.edgePoint.station.StationTileEntity; import com.simibubi.create.content.logistics.trains.management.edgePoint.station.StationTileEntity;
import com.simibubi.create.foundation.advancement.AllAdvancements; import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
public class StationSummaryDisplaySource extends DisplaySource { public class StationSummaryDisplaySource extends DisplaySource {
protected static final MutableComponent UNPREDICTABLE = new TextComponent(" ~ "); protected static final MutableComponent UNPREDICTABLE = Components.literal(" ~ ");
protected static final List<MutableComponent> EMPTY_ENTRY_4 = protected static final List<MutableComponent> EMPTY_ENTRY_4 =
ImmutableList.of(WHITESPACE, new TextComponent(" . "), WHITESPACE, WHITESPACE); ImmutableList.of(WHITESPACE, Components.literal(" . "), WHITESPACE, WHITESPACE);
protected static final List<MutableComponent> EMPTY_ENTRY_5 = protected static final List<MutableComponent> EMPTY_ENTRY_5 =
ImmutableList.of(WHITESPACE, new TextComponent(" . "), WHITESPACE, WHITESPACE, WHITESPACE); ImmutableList.of(WHITESPACE, Components.literal(" . "), WHITESPACE, WHITESPACE, WHITESPACE);
@Override @Override
public List<MutableComponent> provideText(DisplayLinkContext context, DisplayTargetStats stats) { public List<MutableComponent> provideText(DisplayLinkContext context, DisplayTargetStats stats) {
@ -67,7 +67,7 @@ public class StationSummaryDisplaySource extends DisplaySource {
min++; min++;
sec = 0; sec = 0;
} }
lines.add(min > 0 ? new TextComponent(String.valueOf(min)) : WHITESPACE); lines.add(min > 0 ? Components.literal(String.valueOf(min)) : WHITESPACE);
lines.add(min > 0 ? Lang.translateDirect("display_source.station_summary.minutes") lines.add(min > 0 ? Lang.translateDirect("display_source.station_summary.minutes")
: Lang.translateDirect("display_source.station_summary.seconds", sec)); : Lang.translateDirect("display_source.station_summary.seconds", sec));
} }
@ -86,7 +86,7 @@ public class StationSummaryDisplaySource extends DisplaySource {
platform = platform.replace(string, ""); platform = platform.replace(string, "");
platform = platform.replace("*", "?"); platform = platform.replace("*", "?");
lines.add(new TextComponent(platform.trim())); lines.add(Components.literal(platform.trim()));
list.add(lines); list.add(lines);
}); });

View file

@ -4,9 +4,9 @@ import com.simibubi.create.content.contraptions.components.clock.CuckooClockTile
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext; import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats; import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
public class StopWatchDisplaySource extends SingleLineDisplaySource { public class StopWatchDisplaySource extends SingleLineDisplaySource {
@ -32,7 +32,7 @@ public class StopWatchDisplaySource extends SingleLineDisplaySource {
int minutes = (diff / 60 / 20) % 60; int minutes = (diff / 60 / 20) % 60;
int seconds = (diff / 20) % 60; int seconds = (diff / 20) % 60;
MutableComponent component = new TextComponent((hours == 0 ? "" : (hours < 10 ? " " : "") + hours + ":") MutableComponent component = Components.literal((hours == 0 ? "" : (hours < 10 ? " " : "") + hours + ":")
+ (minutes < 10 ? hours == 0 ? " " : "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds); + (minutes < 10 ? hours == 0 ? " " : "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds);
return component; return component;

View file

@ -6,17 +6,17 @@ import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats; import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
public class TimeOfDayDisplaySource extends SingleLineDisplaySource { public class TimeOfDayDisplaySource extends SingleLineDisplaySource {
public static final MutableComponent EMPTY_TIME = new TextComponent("--:--"); public static final MutableComponent EMPTY_TIME = Components.literal("--:--");
@Override @Override
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) { protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
@ -49,7 +49,7 @@ public class TimeOfDayDisplaySource extends SingleLineDisplaySource {
minutes = Create.RANDOM.nextInt(40) + 60; minutes = Create.RANDOM.nextInt(40) + 60;
} }
MutableComponent component = new TextComponent( MutableComponent component = Components.literal(
(hours < 10 ? " " : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + (c12 ? " " : "")); (hours < 10 ? " " : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + (c12 ? " " : ""));
return c12 ? component.append(suffix) : component; return c12 ? component.append(suffix) : component;

View file

@ -15,12 +15,12 @@ import com.simibubi.create.content.logistics.trains.management.display.FlapDispl
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplaySection;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity; import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.IntAttached;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.block.entity.LecternBlockEntity; import net.minecraft.world.level.block.entity.LecternBlockEntity;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -63,7 +63,7 @@ public abstract class ValueListDisplaySource extends DisplaySource {
current = atIndex; current = atIndex;
continue; continue;
} }
current.append(new TextComponent("\n")) current.append(Components.literal("\n"))
.append(atIndex); .append(atIndex);
if ((i + 1) % ENTRIES_PER_PAGE == 0) { if ((i + 1) % ENTRIES_PER_PAGE == 0) {
condensed.add(current); condensed.add(current);
@ -99,7 +99,7 @@ public abstract class ValueListDisplaySource extends DisplaySource {
: Arrays.asList(name, shortened.getFirst(), shortened.getSecond()); : Arrays.asList(name, shortened.getFirst(), shortened.getSecond());
} }
MutableComponent formattedNumber = new TextComponent(String.valueOf(number)).append(WHITESPACE); MutableComponent formattedNumber = Components.literal(String.valueOf(number)).append(WHITESPACE);
return valueFirst() ? Arrays.asList(formattedNumber, name) : Arrays.asList(name, formattedNumber); return valueFirst() ? Arrays.asList(formattedNumber, name) : Arrays.asList(name, formattedNumber);
} }
@ -137,14 +137,14 @@ public abstract class ValueListDisplaySource extends DisplaySource {
private Couple<MutableComponent> shorten(int number) { private Couple<MutableComponent> shorten(int number) {
if (number >= 1000000) if (number >= 1000000)
return Couple.create(new TextComponent(String.valueOf(number / 1000000)), return Couple.create(Components.literal(String.valueOf(number / 1000000)),
Lang.translateDirect("display_source.value_list.million") Lang.translateDirect("display_source.value_list.million")
.append(WHITESPACE)); .append(WHITESPACE));
if (number >= 1000) if (number >= 1000)
return Couple.create(new TextComponent(String.valueOf(number / 1000)), return Couple.create(Components.literal(String.valueOf(number / 1000)),
Lang.translateDirect("display_source.value_list.thousand") Lang.translateDirect("display_source.value_list.thousand")
.append(WHITESPACE)); .append(WHITESPACE));
return Couple.create(new TextComponent(String.valueOf(number)), WHITESPACE); return Couple.create(Components.literal(String.valueOf(number)), WHITESPACE);
} }
protected boolean shortenNumbers(DisplayLinkContext context) { protected boolean shortenNumbers(DisplayLinkContext context) {

View file

@ -9,6 +9,7 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.
import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalTileEntity.SignalState; import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalTileEntity.SignalState;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.DynamicComponent; import com.simibubi.create.foundation.utility.DynamicComponent;
@ -16,7 +17,6 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.block.entity.BlockEntity; 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;
@ -82,7 +82,7 @@ public class NixieTubeTileEntity extends SmartTileEntity {
public MutableComponent getFullText() { public MutableComponent getFullText() {
return customText.map(DynamicComponent::get) return customText.map(DynamicComponent::get)
.orElse(new TextComponent("" + redstoneStrength)); .orElse(Components.literal("" + redstoneStrength));
} }
public void updateRedstoneStrength(int signalStrength) { public void updateRedstoneStrength(int signalStrength) {

View file

@ -10,12 +10,12 @@ import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.widget.IconButton; import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.ScrollInput; import com.simibubi.create.foundation.gui.widget.ScrollInput;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class StockpileSwitchScreen extends AbstractSimiScreen { public class StockpileSwitchScreen extends AbstractSimiScreen {
@ -57,7 +57,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
.startWithValue(te.getState() ? 1 : 0); .startWithValue(te.getState() ? 1 : 0);
offBelow = new ScrollInput(x + 36, y + 40, 102, 18).withRange(0, 100) offBelow = new ScrollInput(x + 36, y + 40, 102, 18).withRange(0, 100)
.titled(TextComponent.EMPTY.plainCopy()) .titled(Components.empty())
.calling(state -> { .calling(state -> {
lastModification = 0; lastModification = 0;
offBelow.titled(Lang.translateDirect("gui.stockpile_switch.move_to_upper_at", state)); offBelow.titled(Lang.translateDirect("gui.stockpile_switch.move_to_upper_at", state));
@ -69,7 +69,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
.setState((int) (te.offWhenBelow * 100)); .setState((int) (te.offWhenBelow * 100));
onAbove = new ScrollInput(x + 36, y + 18, 102, 18).withRange(1, 101) onAbove = new ScrollInput(x + 36, y + 18, 102, 18).withRange(1, 101)
.titled(TextComponent.EMPTY.plainCopy()) .titled(Components.empty())
.calling(state -> { .calling(state -> {
lastModification = 0; lastModification = 0;
onAbove.titled(Lang.translateDirect("gui.stockpile_switch.move_to_lower_at", state)); onAbove.titled(Lang.translateDirect("gui.stockpile_switch.move_to_lower_at", state));

View file

@ -18,6 +18,7 @@ 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.tileEntity.behaviour.linked.LinkBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkBehaviour;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.ControlsUtil; import com.simibubi.create.foundation.utility.ControlsUtil;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
@ -28,7 +29,6 @@ import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.client.gui.ForgeIngameGui; import net.minecraftforge.client.gui.ForgeIngameGui;
@ -220,7 +220,7 @@ public class LinkedControllerClientHandler {
return; return;
poseStack.pushPose(); poseStack.pushPose();
Screen tooltipScreen = new Screen(TextComponent.EMPTY) { Screen tooltipScreen = new Screen(Components.immutableEmpty()) {
}; };
tooltipScreen.init(mc, width1, height1); tooltipScreen.init(mc, width1, height1);

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.AllContainerTypes; import com.simibubi.create.AllContainerTypes;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
@ -11,7 +12,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ClickType; import net.minecraft.world.inventory.ClickType;
@ -52,7 +52,7 @@ public class AttributeFilterContainer extends AbstractFilterContainer {
super.init(inv, contentHolder); super.init(inv, contentHolder);
ItemStack stack = new ItemStack(Items.NAME_TAG); ItemStack stack = new ItemStack(Items.NAME_TAG);
stack.setHoverName( stack.setHoverName(
new TextComponent("Selected Tags").withStyle(ChatFormatting.RESET, ChatFormatting.BLUE)); Components.literal("Selected Tags").withStyle(ChatFormatting.RESET, ChatFormatting.BLUE));
ghostInventory.setStackInSlot(1, stack); ghostInventory.setStackInSlot(1, stack);
} }

View file

@ -15,6 +15,7 @@ import com.simibubi.create.foundation.gui.widget.Indicator;
import com.simibubi.create.foundation.gui.widget.Label; import com.simibubi.create.foundation.gui.widget.Label;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput; import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
@ -22,7 +23,6 @@ import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
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.network.chat.TextComponent;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -86,9 +86,9 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
}); });
blacklist.setToolTip(denyN); blacklist.setToolTip(denyN);
whitelistDisIndicator = new Indicator(x + 47, y + 53, TextComponent.EMPTY); whitelistDisIndicator = new Indicator(x + 47, y + 53, Components.immutableEmpty());
whitelistConIndicator = new Indicator(x + 65, y + 53, TextComponent.EMPTY); whitelistConIndicator = new Indicator(x + 65, y + 53, Components.immutableEmpty());
blacklistIndicator = new Indicator(x + 83, y + 53, TextComponent.EMPTY); blacklistIndicator = new Indicator(x + 83, y + 53, Components.immutableEmpty());
addRenderableWidgets(blacklist, whitelistCon, whitelistDis, blacklistIndicator, whitelistConIndicator, addRenderableWidgets(blacklist, whitelistCon, whitelistDis, blacklistIndicator, whitelistConIndicator,
whitelistDisIndicator); whitelistDisIndicator);
@ -106,10 +106,10 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
handleIndicators(); handleIndicators();
attributeSelectorLabel = new Label(x + 43, y + 26, TextComponent.EMPTY).colored(0xF3EBDE) attributeSelectorLabel = new Label(x + 43, y + 26, Components.immutableEmpty()).colored(0xF3EBDE)
.withShadow(); .withShadow();
attributeSelector = new SelectionScrollInput(x + 39, y + 21, 137, 18); attributeSelector = new SelectionScrollInput(x + 39, y + 21, 137, 18);
attributeSelector.forOptions(Arrays.asList(TextComponent.EMPTY)); attributeSelector.forOptions(Arrays.asList(Components.immutableEmpty()));
attributeSelector.removeCallback(); attributeSelector.removeCallback();
referenceItemChanged(menu.ghostInventory.getStackInSlot(0)); referenceItemChanged(menu.ghostInventory.getStackInSlot(0));
@ -119,7 +119,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
selectedAttributes.clear(); selectedAttributes.clear();
selectedAttributes.add((menu.selectedAttributes.isEmpty() ? noSelectedT : selectedT).plainCopy() selectedAttributes.add((menu.selectedAttributes.isEmpty() ? noSelectedT : selectedT).plainCopy()
.withStyle(ChatFormatting.YELLOW)); .withStyle(ChatFormatting.YELLOW));
menu.selectedAttributes.forEach(at -> selectedAttributes.add(new TextComponent("- ") menu.selectedAttributes.forEach(at -> selectedAttributes.add(Components.literal("- ")
.append(at.getFirst() .append(at.getFirst()
.format(at.getSecond())) .format(at.getSecond()))
.withStyle(ChatFormatting.GRAY))); .withStyle(ChatFormatting.GRAY)));
@ -243,7 +243,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
if (menu.selectedAttributes.size() == 1) if (menu.selectedAttributes.size() == 1)
selectedAttributes.set(0, selectedT.plainCopy() selectedAttributes.set(0, selectedT.plainCopy()
.withStyle(ChatFormatting.YELLOW)); .withStyle(ChatFormatting.YELLOW));
selectedAttributes.add(new TextComponent("- ").append(itemAttribute.format(inverted)) selectedAttributes.add(Components.literal("- ").append(itemAttribute.format(inverted))
.withStyle(ChatFormatting.GRAY)); .withStyle(ChatFormatting.GRAY));
return true; return true;
} }

View file

@ -11,6 +11,7 @@ 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.item.ItemDescription;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
@ -18,7 +19,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -75,7 +75,7 @@ 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, new TextComponent(" ")); ItemDescription.add(tooltip, Components.literal(" "));
ItemDescription.add(tooltip, makeSummary); ItemDescription.add(tooltip, makeSummary);
} }
} }
@ -92,14 +92,14 @@ public class FilterItem extends Item implements MenuProvider {
int count = 0; int count = 0;
for (int i = 0; i < filterItems.getSlots(); i++) { for (int i = 0; i < filterItems.getSlots(); i++) {
if (count > 3) { if (count > 3) {
list.add(new TextComponent("- ...").withStyle(ChatFormatting.DARK_GRAY)); list.add(Components.literal("- ...").withStyle(ChatFormatting.DARK_GRAY));
break; break;
} }
ItemStack filterStack = filterItems.getStackInSlot(i); ItemStack filterStack = filterItems.getStackInSlot(i);
if (filterStack.isEmpty()) if (filterStack.isEmpty())
continue; continue;
list.add(new TextComponent("- ").append(filterStack.getHoverName()).withStyle(ChatFormatting.GRAY)); list.add(Components.literal("- ").append(filterStack.getHoverName()).withStyle(ChatFormatting.GRAY));
count++; count++;
} }
@ -124,10 +124,10 @@ public class FilterItem extends Item implements MenuProvider {
ItemAttribute attribute = ItemAttribute.fromNBT(compound); ItemAttribute attribute = ItemAttribute.fromNBT(compound);
boolean inverted = compound.getBoolean("Inverted"); boolean inverted = compound.getBoolean("Inverted");
if (count > 3) { if (count > 3) {
list.add(new TextComponent("- ...").withStyle(ChatFormatting.DARK_GRAY)); list.add(Components.literal("- ...").withStyle(ChatFormatting.DARK_GRAY));
break; break;
} }
list.add(new TextComponent("- ").append(attribute.format(inverted))); list.add(Components.literal("- ").append(attribute.format(inverted)));
count++; count++;
} }

View file

@ -8,11 +8,11 @@ import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.widget.IconButton; import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.gui.widget.Indicator; import com.simibubi.create.foundation.gui.widget.Indicator;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
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.network.chat.TextComponent;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
public class FilterScreen extends AbstractFilterScreen<FilterContainer> { public class FilterScreen extends AbstractFilterScreen<FilterContainer> {
@ -58,8 +58,8 @@ public class FilterScreen extends AbstractFilterScreen<FilterContainer> {
sendOptionUpdate(Option.WHITELIST); sendOptionUpdate(Option.WHITELIST);
}); });
whitelist.setToolTip(allowN); whitelist.setToolTip(allowN);
blacklistIndicator = new Indicator(x + 18, y + 67, TextComponent.EMPTY); blacklistIndicator = new Indicator(x + 18, y + 67, Components.immutableEmpty());
whitelistIndicator = new Indicator(x + 36, y + 67, TextComponent.EMPTY); whitelistIndicator = new Indicator(x + 36, y + 67, Components.immutableEmpty());
addRenderableWidgets(blacklist, whitelist, blacklistIndicator, whitelistIndicator); addRenderableWidgets(blacklist, whitelist, blacklistIndicator, whitelistIndicator);
respectNBT = new IconButton(x + 60, y + 73, AllIcons.I_RESPECT_NBT); respectNBT = new IconButton(x + 60, y + 73, AllIcons.I_RESPECT_NBT);
@ -74,8 +74,8 @@ public class FilterScreen extends AbstractFilterScreen<FilterContainer> {
sendOptionUpdate(Option.IGNORE_DATA); sendOptionUpdate(Option.IGNORE_DATA);
}); });
ignoreNBT.setToolTip(ignoreDataN); ignoreNBT.setToolTip(ignoreDataN);
respectNBTIndicator = new Indicator(x + 60, y + 67, TextComponent.EMPTY); respectNBTIndicator = new Indicator(x + 60, y + 67, Components.immutableEmpty());
ignoreNBTIndicator = new Indicator(x + 78, y + 67, TextComponent.EMPTY); ignoreNBTIndicator = new Indicator(x + 78, y + 67, Components.immutableEmpty());
addRenderableWidgets(respectNBT, ignoreNBT, respectNBTIndicator, ignoreNBTIndicator); addRenderableWidgets(respectNBT, ignoreNBT, respectNBTIndicator, ignoreNBTIndicator);
handleIndicators(); handleIndicators();

View file

@ -27,7 +27,7 @@ import com.simibubi.create.content.logistics.item.filter.attribute.astralsorcery
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
@ -121,7 +121,7 @@ public interface ItemAttribute {
} }
@OnlyIn(value = Dist.CLIENT) @OnlyIn(value = Dist.CLIENT)
default TranslatableComponent format(boolean inverted) { default MutableComponent format(boolean inverted) {
return Lang.translateDirect("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""), return Lang.translateDirect("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""),
getTranslationParameters()); getTranslationParameters());
} }
@ -299,7 +299,7 @@ public interface ItemAttribute {
@Override @Override
@OnlyIn(value = Dist.CLIENT) @OnlyIn(value = Dist.CLIENT)
public TranslatableComponent format(boolean inverted) { public MutableComponent format(boolean inverted) {
return Lang.translateDirect("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""), return Lang.translateDirect("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""),
group.getDisplayName()); group.getDisplayName());
} }

View file

@ -9,6 +9,7 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.simibubi.create.content.logistics.item.filter.ItemAttribute; import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -56,7 +57,7 @@ public class ColorAttribute implements ItemAttribute {
colors.addAll(getFireworkStarColors(nbt.getCompound("Explosion"))); colors.addAll(getFireworkStarColors(nbt.getCompound("Explosion")));
} }
Arrays.stream(DyeColor.values()).filter(c -> stack.getItem().getRegistryName().getPath().startsWith(c.getName() + "_")).forEach(colors::add); Arrays.stream(DyeColor.values()).filter(c -> RegisteredObjects.getKeyOrThrow(stack.getItem()).getPath().startsWith(c.getName() + "_")).forEach(colors::add);
return colors; return colors;
} }

View file

@ -6,9 +6,9 @@ import java.util.stream.Collectors;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.simibubi.create.content.logistics.item.filter.ItemAttribute; import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.Enchantment;
@ -43,7 +43,7 @@ public class EnchantAttribute implements ItemAttribute {
public Object[] getTranslationParameters() { public Object[] getTranslationParameters() {
String parameter = ""; String parameter = "";
if(enchantment != null) if(enchantment != null)
parameter = new TranslatableComponent(enchantment.getDescriptionId()).getString(); parameter = Components.translatable(enchantment.getDescriptionId()).getString();
return new Object[] { parameter }; return new Object[] { parameter };
} }
@ -51,7 +51,7 @@ public class EnchantAttribute implements ItemAttribute {
public void writeNBT(CompoundTag nbt) { public void writeNBT(CompoundTag nbt) {
if (enchantment == null) if (enchantment == null)
return; return;
ResourceLocation id = ForgeRegistries.ENCHANTMENTS.getKey(enchantment); ResourceLocation id = enchantment.getRegistryName();
if (id == null) if (id == null)
return; return;
nbt.putString("id", id.toString()); nbt.putString("id", id.toString());

View file

@ -7,9 +7,9 @@ import java.util.stream.Collectors;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.simibubi.create.content.logistics.item.filter.ItemAttribute; import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluid;
@ -46,7 +46,7 @@ public class FluidContentsAttribute implements ItemAttribute {
public Object[] getTranslationParameters() { public Object[] getTranslationParameters() {
String parameter = ""; String parameter = "";
if (fluid != null) if (fluid != null)
parameter = new TranslatableComponent(fluid.getAttributes().getTranslationKey()).getString(); parameter = Components.translatable(fluid.getAttributes().getTranslationKey()).getString();
return new Object[] { parameter }; return new Object[] { parameter };
} }
@ -54,7 +54,7 @@ public class FluidContentsAttribute implements ItemAttribute {
public void writeNBT(CompoundTag nbt) { public void writeNBT(CompoundTag nbt) {
if (fluid == null) if (fluid == null)
return; return;
ResourceLocation id = ForgeRegistries.FLUIDS.getKey(fluid); ResourceLocation id = fluid.getRegistryName();
if (id == null) if (id == null)
return; return;
nbt.putString("id", id.toString()); nbt.putString("id", id.toString());

View file

@ -4,11 +4,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.content.logistics.item.filter.ItemAttribute; import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.Enchantment;
@ -56,7 +56,7 @@ public class AstralSorceryAmuletAttribute implements ItemAttribute {
Enchantment enchant = ForgeRegistries.ENCHANTMENTS.getValue(ResourceLocation.tryParse(enchName)); Enchantment enchant = ForgeRegistries.ENCHANTMENTS.getValue(ResourceLocation.tryParse(enchName));
if(enchant != null) { if(enchant != null) {
something = new TranslatableComponent(enchant.getDescriptionId()).getString(); something = Components.translatable(enchant.getDescriptionId()).getString();
} }
if(enchType == 1) something = "existing " + something; if(enchType == 1) something = "existing " + something;

View file

@ -4,9 +4,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.content.logistics.item.filter.ItemAttribute; import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -57,7 +57,7 @@ public class AstralSorceryAttunementAttribute implements ItemAttribute {
@Override @Override
public Object[] getTranslationParameters() { public Object[] getTranslationParameters() {
ResourceLocation constResource = new ResourceLocation(constellationName); ResourceLocation constResource = new ResourceLocation(constellationName);
String something = new TranslatableComponent(String.format("%s.constellation.%s", constResource.getNamespace(), constResource.getPath())).getString(); String something = Components.translatable(String.format("%s.constellation.%s", constResource.getNamespace(), constResource.getPath())).getString();
return new Object[] { something }; return new Object[] { something };
} }

View file

@ -4,11 +4,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.content.logistics.item.filter.ItemAttribute; import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -46,7 +46,7 @@ public class AstralSorceryCrystalAttribute implements ItemAttribute {
@Override @Override
public Object[] getTranslationParameters() { public Object[] getTranslationParameters() {
ResourceLocation traitResource = new ResourceLocation(traitName); ResourceLocation traitResource = new ResourceLocation(traitName);
String something = new TranslatableComponent(String.format("crystal.property.%s.%s.name", traitResource.getNamespace(), traitResource.getPath())).getString(); String something = Components.translatable(String.format("crystal.property.%s.%s.name", traitResource.getNamespace(), traitResource.getPath())).getString();
return new Object[] { something }; return new Object[] { something };
} }

View file

@ -4,11 +4,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.content.logistics.item.filter.ItemAttribute; import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -46,7 +46,7 @@ public class AstralSorceryPerkGemAttribute implements ItemAttribute {
@Override @Override
public Object[] getTranslationParameters() { public Object[] getTranslationParameters() {
ResourceLocation traitResource = new ResourceLocation(traitName); ResourceLocation traitResource = new ResourceLocation(traitName);
String something = new TranslatableComponent(String.format("perk.attribute.%s.%s.name", traitResource.getNamespace(), traitResource.getPath())).getString(); String something = Components.translatable(String.format("perk.attribute.%s.%s.name", traitResource.getNamespace(), traitResource.getPath())).getString();
return new Object[] { something }; return new Object[] { something };
} }

View file

@ -13,6 +13,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.content.logistics.trains.entity.BogeyInstance; import com.simibubi.create.content.logistics.trains.entity.BogeyInstance;
import com.simibubi.create.content.logistics.trains.entity.CarriageBogey; import com.simibubi.create.content.logistics.trains.entity.CarriageBogey;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -63,7 +64,7 @@ public interface IBogeyBlock extends IWrenchable {
@Override @Override
default BlockState getRotatedBlockState(BlockState state, Direction targetedFace) { default BlockState getRotatedBlockState(BlockState state, Direction targetedFace) {
Block block = state.getBlock(); Block block = state.getBlock();
int indexOf = BOGEYS.indexOf(block.getRegistryName()); int indexOf = BOGEYS.indexOf(RegisteredObjects.getKeyOrThrow(block));
if (indexOf == -1) if (indexOf == -1)
return state; return state;

View file

@ -10,6 +10,7 @@ import com.simibubi.create.content.logistics.trains.TrackGraph;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat;
@ -146,7 +147,7 @@ public class CarriageBogey {
public CompoundTag write(DimensionPalette dimensions) { public CompoundTag write(DimensionPalette dimensions) {
CompoundTag tag = new CompoundTag(); CompoundTag tag = new CompoundTag();
tag.putString("Type", ((Block) type).getRegistryName() tag.putString("Type", RegisteredObjects.getKeyOrThrow((Block) type)
.toString()); .toString());
tag.put("Points", points.serializeEach(tp -> tp.write(dimensions))); tag.put("Points", points.serializeEach(tp -> tp.write(dimensions)));
return tag; return tag;

View file

@ -27,6 +27,7 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.station
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Couple; 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.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
@ -37,9 +38,7 @@ import net.minecraft.core.Direction.Axis;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.KeybindComponent;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
@ -592,7 +591,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
GlobalStation currentStation = carriage.train.getCurrentStation(); GlobalStation currentStation = carriage.train.getCurrentStation();
if (currentStation != null && spaceDown) { if (currentStation != null && spaceDown) {
sendPrompt(player, Lang.translateDirect("train.arrived_at", sendPrompt(player, Lang.translateDirect("train.arrived_at",
new TextComponent(currentStation.name).withStyle(s -> s.withColor(0x704630))), false); Components.literal(currentStation.name).withStyle(s -> s.withColor(0x704630))), false);
return true; return true;
} }
@ -604,7 +603,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
if (currentStation != null && targetSpeed != 0) { if (currentStation != null && targetSpeed != 0) {
stationMessage = false; stationMessage = false;
sendPrompt(player, Lang.translateDirect("train.departing_from", sendPrompt(player, Lang.translateDirect("train.departing_from",
new TextComponent(currentStation.name).withStyle(s -> s.withColor(0x704630))), false); Components.literal(currentStation.name).withStyle(s -> s.withColor(0x704630))), false);
} }
if (currentStation == null) { if (currentStation == null) {
@ -617,8 +616,8 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
double f = (nav.distanceToDestination / navDistanceTotal); double f = (nav.distanceToDestination / navDistanceTotal);
int progress = (int) (Mth.clamp(1 - ((1 - f) * (1 - f)), 0, 1) * 30); int progress = (int) (Mth.clamp(1 - ((1 - f) * (1 - f)), 0, 1) * 30);
boolean arrived = progress == 0; boolean arrived = progress == 0;
TextComponent whiteComponent = new TextComponent(Strings.repeat("|", progress)); MutableComponent whiteComponent = Components.literal(Strings.repeat("|", progress));
TextComponent greenComponent = new TextComponent(Strings.repeat("|", 30 - progress)); MutableComponent greenComponent = Components.literal(Strings.repeat("|", 30 - progress));
int fromColor = 0x00_FFC244; int fromColor = 0x00_FFC244;
int toColor = 0x00_529915; int toColor = 0x00_529915;
@ -684,14 +683,14 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
private void displayApproachStationMessage(Player player, GlobalStation station) { private void displayApproachStationMessage(Player player, GlobalStation station) {
sendPrompt(player, Lang.translateDirect("contraption.controls.approach_station", sendPrompt(player, Lang.translateDirect("contraption.controls.approach_station",
new KeybindComponent("key.jump"), station.name), false); Components.keybind("key.jump"), station.name), false);
stationMessage = true; stationMessage = true;
} }
private void cleanUpApproachStationMessage(Player player) { private void cleanUpApproachStationMessage(Player player) {
if (!stationMessage) if (!stationMessage)
return; return;
player.displayClientMessage(new TextComponent(""), true); player.displayClientMessage(Components.immutableEmpty(), true);
stationMessage = false; stationMessage = false;
} }

View file

@ -11,6 +11,7 @@ import com.simibubi.create.content.logistics.trains.IBogeyBlock;
import com.simibubi.create.foundation.networking.SimplePacketBase; import com.simibubi.create.foundation.networking.SimplePacketBase;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.RegisteredObjects;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -84,7 +85,7 @@ public class TrainPacket extends SimplePacketBase {
continue; continue;
} }
CarriageBogey bogey = carriage.bogeys.get(first); CarriageBogey bogey = carriage.bogeys.get(first);
buffer.writeResourceLocation(((Block) bogey.type).getRegistryName()); buffer.writeResourceLocation(RegisteredObjects.getKeyOrThrow((Block) bogey.type));
} }
buffer.writeVarInt(carriage.bogeySpacing); buffer.writeVarInt(carriage.bogeySpacing);
} }

View file

@ -3,11 +3,11 @@ package com.simibubi.create.content.logistics.trains.entity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@ -130,7 +130,7 @@ public class TrainStatus {
} }
public void displayInformation(String key, boolean itsAGoodThing, Object... args) { public void displayInformation(String key, boolean itsAGoodThing, Object... args) {
queued.add(new TextComponent(" - ").withStyle(ChatFormatting.GRAY) queued.add(Components.literal(" - ").withStyle(ChatFormatting.GRAY)
.append(Lang.translateDirect("train.status." + key, args) .append(Lang.translateDirect("train.status." + key, args)
.withStyle(st -> st.withColor(itsAGoodThing ? 0xD5ECC2 : 0xFFD3B4)))); .withStyle(st -> st.withColor(itsAGoodThing ? 0xD5ECC2 : 0xFFD3B4))));
if (queued.size() > 3) if (queued.size() > 3)

View file

@ -8,6 +8,7 @@ import com.google.gson.JsonElement;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.DyeHelper; import com.simibubi.create.foundation.utility.DyeHelper;
import com.simibubi.create.foundation.utility.DynamicComponent; import com.simibubi.create.foundation.utility.DynamicComponent;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
@ -18,7 +19,6 @@ import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -145,7 +145,7 @@ public class FlapDisplayTileEntity extends KineticTileEntity {
FlapDisplaySection flapDisplaySection = sections.get(0); FlapDisplaySection flapDisplaySection = sections.get(0);
if (rawComponentText == null) { if (rawComponentText == null) {
manualLines[lineIndex] = false; manualLines[lineIndex] = false;
flapDisplaySection.setText(new TextComponent("")); flapDisplaySection.setText(Components.immutableEmpty());
notifyUpdate(); notifyUpdate();
return; return;
} }

View file

@ -10,6 +10,7 @@ import com.simibubi.create.AllTileEntities;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour; import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font; import net.minecraft.client.gui.Font;
@ -19,7 +20,6 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.saveddata.maps.MapDecoration; import net.minecraft.world.level.saveddata.maps.MapDecoration;
import net.minecraft.world.level.saveddata.maps.MapItemSavedData; import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
@ -40,7 +40,7 @@ public class StationMarker {
BlockPos source = NbtUtils.readBlockPos(tag.getCompound("source")); BlockPos source = NbtUtils.readBlockPos(tag.getCompound("source"));
BlockPos target = NbtUtils.readBlockPos(tag.getCompound("target")); BlockPos target = NbtUtils.readBlockPos(tag.getCompound("target"));
Component name = Component.Serializer.fromJson(tag.getString("name")); Component name = Component.Serializer.fromJson(tag.getString("name"));
if (name == null) name = TextComponent.EMPTY; if (name == null) name = Components.immutableEmpty();
return new StationMarker(source, target, name); return new StationMarker(source, target, name);
} }
@ -54,7 +54,7 @@ public class StationMarker {
String name = stationOption.get() String name = stationOption.get()
.getStation().name; .getStation().name;
return new StationMarker(pos, TileEntityBehaviour.get(stationOption.get(), TrackTargetingBehaviour.TYPE) return new StationMarker(pos, TileEntityBehaviour.get(stationOption.get(), TrackTargetingBehaviour.TYPE)
.getPositionForMapMarker(), new TextComponent(name)); .getPositionForMapMarker(), Components.literal(name));
} }
public CompoundTag save() { public CompoundTag save() {

View file

@ -16,6 +16,7 @@ import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.gui.UIRenderHelper; import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.gui.widget.IconButton; import com.simibubi.create.foundation.gui.widget.IconButton;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat;
@ -23,7 +24,6 @@ import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.EditBox;
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.network.chat.TextComponent;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
public class StationScreen extends AbstractStationScreen { public class StationScreen extends AbstractStationScreen {
@ -58,7 +58,7 @@ public class StationScreen extends AbstractStationScreen {
onTextChanged = s -> nameBox.x = nameBoxX(s, nameBox); onTextChanged = s -> nameBox.x = nameBoxX(s, nameBox);
nameBox = new EditBox(new NoShadowFontWrapper(font), x + 23, y + 4, background.width - 20, 10, nameBox = new EditBox(new NoShadowFontWrapper(font), x + 23, y + 4, background.width - 20, 10,
new TextComponent(station.name)); Components.literal(station.name));
nameBox.setBordered(false); nameBox.setBordered(false);
nameBox.setMaxLength(25); nameBox.setMaxLength(25);
nameBox.setTextColor(0x442000); nameBox.setTextColor(0x442000);
@ -92,7 +92,7 @@ public class StationScreen extends AbstractStationScreen {
addRenderableWidget(dropScheduleButton); addRenderableWidget(dropScheduleButton);
onTextChanged = s -> trainNameBox.x = nameBoxX(s, trainNameBox); onTextChanged = s -> trainNameBox.x = nameBoxX(s, trainNameBox);
trainNameBox = new EditBox(font, x + 23, y + 47, background.width - 75, 10, new TextComponent("")); trainNameBox = new EditBox(font, x + 23, y + 47, background.width - 75, 10, Components.immutableEmpty());
trainNameBox.setBordered(false); trainNameBox.setBordered(false);
trainNameBox.setMaxLength(35); trainNameBox.setMaxLength(35);
trainNameBox.setTextColor(0xC6C6C6); trainNameBox.setTextColor(0xC6C6C6);

View file

@ -8,9 +8,9 @@ import com.simibubi.create.content.logistics.trains.entity.Train;
import com.simibubi.create.content.logistics.trains.entity.TrainIconType; import com.simibubi.create.content.logistics.trains.entity.TrainIconType;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.networking.SimplePacketBase; import com.simibubi.create.foundation.networking.SimplePacketBase;
import com.simibubi.create.foundation.utility.Components;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@ -52,7 +52,7 @@ public class TrainEditPacket extends SimplePacketBase {
if (train == null) if (train == null)
return; return;
if (!name.isBlank()) if (!name.isBlank())
train.name = new TextComponent(name); train.name = Components.literal(name);
train.icon = TrainIconType.byId(iconType); train.icon = TrainIconType.byId(iconType);
if (sender != null) if (sender != null)
AllPackets.channel.send(PacketDistributor.ALL.noArg(), new TrainEditReturnPacket(id, name, iconType)); AllPackets.channel.send(PacketDistributor.ALL.noArg(), new TrainEditReturnPacket(id, name, iconType));

View file

@ -7,11 +7,11 @@ import javax.annotation.Nullable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -32,7 +32,7 @@ public interface IScheduleInput {
public default List<Component> getTitleAs(String type) { public default List<Component> getTitleAs(String type) {
ResourceLocation id = getId(); ResourceLocation id = getId();
return ImmutableList return ImmutableList
.of(new TranslatableComponent(id.getNamespace() + ".schedule." + type + "." + id.getPath())); .of(Components.translatable(id.getNamespace() + ".schedule." + type + "." + id.getPath()));
} }
public default ItemStack getSecondLineIcon() { public default ItemStack getSecondLineIcon() {

View file

@ -19,6 +19,7 @@ import com.simibubi.create.content.logistics.trains.management.schedule.destinat
import com.simibubi.create.content.logistics.trains.management.schedule.destination.ChangeTitleInstruction; import com.simibubi.create.content.logistics.trains.management.schedule.destination.ChangeTitleInstruction;
import com.simibubi.create.content.logistics.trains.management.schedule.destination.DestinationInstruction; import com.simibubi.create.content.logistics.trains.management.schedule.destination.DestinationInstruction;
import com.simibubi.create.content.logistics.trains.management.schedule.destination.ScheduleInstruction; import com.simibubi.create.content.logistics.trains.management.schedule.destination.ScheduleInstruction;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
@ -26,7 +27,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
public class Schedule { public class Schedule {
@ -64,7 +64,7 @@ public class Schedule {
return list.stream() return list.stream()
.map(Pair::getFirst) .map(Pair::getFirst)
.map(rl -> rl.getNamespace() + ".schedule." + langSection + rl.getPath()) .map(rl -> rl.getNamespace() + ".schedule." + langSection + rl.getPath())
.map(TranslatableComponent::new) .map(Components::translatable)
.toList(); .toList();
} }

View file

@ -10,6 +10,7 @@ import com.simibubi.create.content.logistics.trains.entity.CarriageContraptionEn
import com.simibubi.create.content.logistics.trains.entity.Train; import com.simibubi.create.content.logistics.trains.entity.Train;
import com.simibubi.create.content.logistics.trains.management.schedule.destination.DestinationInstruction; import com.simibubi.create.content.logistics.trains.management.schedule.destination.DestinationInstruction;
import com.simibubi.create.foundation.advancement.AllAdvancements; import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
@ -18,7 +19,6 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
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.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -133,8 +133,8 @@ public class ScheduleItem extends Item implements MenuProvider {
if (schedule == null || schedule.entries.isEmpty()) if (schedule == null || schedule.entries.isEmpty())
return; return;
MutableComponent caret = new TextComponent("> ").withStyle(ChatFormatting.GRAY); MutableComponent caret = Components.literal("> ").withStyle(ChatFormatting.GRAY);
MutableComponent arrow = new TextComponent("-> ").withStyle(ChatFormatting.GRAY); MutableComponent arrow = Components.literal("-> ").withStyle(ChatFormatting.GRAY);
List<ScheduleEntry> entries = schedule.entries; List<ScheduleEntry> entries = schedule.entries;
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
@ -145,7 +145,7 @@ public class ScheduleItem extends Item implements MenuProvider {
ChatFormatting format = current ? ChatFormatting.YELLOW : ChatFormatting.GOLD; ChatFormatting format = current ? ChatFormatting.YELLOW : ChatFormatting.GOLD;
MutableComponent prefix = current ? arrow : caret; MutableComponent prefix = current ? arrow : caret;
tooltip.add(prefix.copy() tooltip.add(prefix.copy()
.append(new TextComponent(destination.getFilter()).withStyle(format))); .append(Components.literal(destination.getFilter()).withStyle(format)));
} }
} }

View file

@ -17,12 +17,12 @@ import com.simibubi.create.content.logistics.trains.management.schedule.destinat
import com.simibubi.create.content.logistics.trains.management.schedule.destination.ChangeTitleInstruction; import com.simibubi.create.content.logistics.trains.management.schedule.destination.ChangeTitleInstruction;
import com.simibubi.create.content.logistics.trains.management.schedule.destination.DestinationInstruction; import com.simibubi.create.content.logistics.trains.management.schedule.destination.DestinationInstruction;
import com.simibubi.create.content.logistics.trains.management.schedule.destination.ScheduleInstruction; import com.simibubi.create.content.logistics.trains.management.schedule.destination.ScheduleInstruction;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@ -371,7 +371,7 @@ public class ScheduleRuntime {
int size = schedule.entries.size(); int size = schedule.entries.size();
if (index >= size) { if (index >= size) {
if (!schedule.cyclic) if (!schedule.cyclic)
return new TrainDeparturePrediction(train, time, new TextComponent(" "), destination); return new TrainDeparturePrediction(train, time, Components.literal(" "), destination);
index %= size; index %= size;
} }
@ -389,7 +389,7 @@ public class ScheduleRuntime {
} }
} }
return new TrainDeparturePrediction(train, time, new TextComponent(text), destination); return new TrainDeparturePrediction(train, time, Components.literal(text), destination);
} }
public CompoundTag write() { public CompoundTag write() {
@ -448,12 +448,12 @@ public class ScheduleRuntime {
public MutableComponent getWaitingStatus(Level level) { public MutableComponent getWaitingStatus(Level level) {
List<List<ScheduleWaitCondition>> conditions = schedule.entries.get(currentEntry).conditions; List<List<ScheduleWaitCondition>> conditions = schedule.entries.get(currentEntry).conditions;
if (conditions.isEmpty() || conditionProgress.isEmpty() || conditionContext.isEmpty()) if (conditions.isEmpty() || conditionProgress.isEmpty() || conditionContext.isEmpty())
return TextComponent.EMPTY.copy(); return Components.empty();
List<ScheduleWaitCondition> list = conditions.get(0); List<ScheduleWaitCondition> list = conditions.get(0);
int progress = conditionProgress.get(0); int progress = conditionProgress.get(0);
if (progress >= list.size()) if (progress >= list.size())
return TextComponent.EMPTY.copy(); return Components.empty();
CompoundTag tag = conditionContext.get(0); CompoundTag tag = conditionContext.get(0);
ScheduleWaitCondition condition = list.get(progress); ScheduleWaitCondition condition = list.get(progress);

View file

@ -41,6 +41,7 @@ import com.simibubi.create.foundation.gui.widget.Indicator.State;
import com.simibubi.create.foundation.gui.widget.Label; import com.simibubi.create.foundation.gui.widget.Label;
import com.simibubi.create.foundation.gui.widget.SelectionScrollInput; import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.IntAttached;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
@ -55,7 +56,6 @@ import net.minecraft.client.gui.components.Widget;
import net.minecraft.client.renderer.Rect2i; import net.minecraft.client.renderer.Rect2i;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.FormattedCharSequence;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -116,7 +116,7 @@ public class ScheduleScreen extends AbstractSimiContainerScreen<ScheduleContaine
confirmButton.withCallback(() -> minecraft.player.closeContainer()); confirmButton.withCallback(() -> minecraft.player.closeContainer());
addRenderableWidget(confirmButton); addRenderableWidget(confirmButton);
cyclicIndicator = new Indicator(leftPos + 21, topPos + 196, TextComponent.EMPTY); cyclicIndicator = new Indicator(leftPos + 21, topPos + 196, Components.immutableEmpty());
cyclicIndicator.state = schedule.cyclic ? State.ON : State.OFF; cyclicIndicator.state = schedule.cyclic ? State.ON : State.OFF;
addRenderableWidget(cyclicIndicator); addRenderableWidget(cyclicIndicator);
@ -171,7 +171,7 @@ public class ScheduleScreen extends AbstractSimiContainerScreen<ScheduleContaine
resetProgress.visible = false; resetProgress.visible = false;
scrollInput = new SelectionScrollInput(leftPos + 56, topPos + 65, 143, 16); scrollInput = new SelectionScrollInput(leftPos + 56, topPos + 65, 143, 16);
scrollInputLabel = new Label(leftPos + 59, topPos + 69, new TextComponent("")).withShadow(); scrollInputLabel = new Label(leftPos + 59, topPos + 69, Components.immutableEmpty()).withShadow();
editorConfirm = new IconButton(leftPos + 56 + 168, topPos + 65 + 22, AllIcons.I_CONFIRM); editorConfirm = new IconButton(leftPos + 56 + 168, topPos + 65 + 22, AllIcons.I_CONFIRM);
if (allowDeletion) if (allowDeletion)
editorDelete = new IconButton(leftPos + 56 - 45, topPos + 65 + 22, AllIcons.I_TRASH); editorDelete = new IconButton(leftPos + 56 - 45, topPos + 65 + 22, AllIcons.I_TRASH);
@ -642,7 +642,7 @@ public class ScheduleScreen extends AbstractSimiContainerScreen<ScheduleContaine
if (editingCondition != null || editingDestination != null) if (editingCondition != null || editingDestination != null)
return false; return false;
Component empty = new TextComponent(""); Component empty = Components.immutableEmpty();
int mx = (int) mouseX; int mx = (int) mouseX;
int my = (int) mouseY; int my = (int) mouseY;

View file

@ -7,13 +7,13 @@ import com.google.common.collect.ImmutableList;
import com.simibubi.create.content.logistics.trains.entity.Carriage; import com.simibubi.create.content.logistics.trains.entity.Carriage;
import com.simibubi.create.content.logistics.trains.entity.Train; import com.simibubi.create.content.logistics.trains.entity.Train;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
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.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -81,7 +81,7 @@ public abstract class CargoThresholdCondition extends LazyTickedScheduleConditio
@Override @Override
public Pair<ItemStack, Component> getSummary() { public Pair<ItemStack, Component> getSummary() {
return Pair.of(getIcon(), new TextComponent(getOperator().formatted + " " + getThreshold()).append(getUnit())); return Pair.of(getIcon(), Components.literal(getOperator().formatted + " " + getThreshold()).append(getUnit()));
} }
@Override @Override
@ -119,7 +119,7 @@ public abstract class CargoThresholdCondition extends LazyTickedScheduleConditio
builder.addSelectionScrollInput(0, 24, (i, l) -> { builder.addSelectionScrollInput(0, 24, (i, l) -> {
i.forOptions(Ops.translatedOptions()) i.forOptions(Ops.translatedOptions())
.titled(Lang.translateDirect("schedule.condition.threshold.train_holds")) .titled(Lang.translateDirect("schedule.condition.threshold.train_holds"))
.format(state -> new TextComponent(" " + Ops.values()[state].formatted)); .format(state -> Components.literal(" " + Ops.values()[state].formatted));
}, "Operator"); }, "Operator");
builder.addIntegerTextInput(29, 41, (e, t) -> { builder.addIntegerTextInput(29, 41, (e, t) -> {
}, "Threshold"); }, "Threshold");

View file

@ -9,6 +9,7 @@ import com.simibubi.create.content.logistics.item.filter.FilterItem;
import com.simibubi.create.content.logistics.trains.entity.Carriage; import com.simibubi.create.content.logistics.trains.entity.Carriage;
import com.simibubi.create.content.logistics.trains.entity.Train; import com.simibubi.create.content.logistics.trains.entity.Train;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
@ -16,7 +17,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
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.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@ -31,7 +31,7 @@ public class FluidThresholdCondition extends CargoThresholdCondition {
@Override @Override
protected Component getUnit() { protected Component getUnit() {
return new TextComponent("b"); return Components.literal("b");
} }
@Override @Override
@ -135,7 +135,7 @@ public class FluidThresholdCondition extends CargoThresholdCondition {
public MutableComponent getWaitingStatus(Level level, Train train, CompoundTag tag) { public MutableComponent getWaitingStatus(Level level, Train train, CompoundTag tag) {
int lastDisplaySnapshot = getLastDisplaySnapshot(tag); int lastDisplaySnapshot = getLastDisplaySnapshot(tag);
if (lastDisplaySnapshot == -1) if (lastDisplaySnapshot == -1)
return TextComponent.EMPTY.copy(); return Components.empty();
int offset = getOperator() == Ops.LESS ? -1 : getOperator() == Ops.GREATER ? 1 : 0; int offset = getOperator() == Ops.LESS ? -1 : getOperator() == Ops.GREATER ? 1 : 0;
return Lang.translateDirect("schedule.condition.threshold.status", lastDisplaySnapshot, return Lang.translateDirect("schedule.condition.threshold.status", lastDisplaySnapshot,
Math.max(0, getThreshold() + offset), Lang.translateDirect("schedule.condition.threshold.buckets")); Math.max(0, getThreshold() + offset), Lang.translateDirect("schedule.condition.threshold.buckets"));

View file

@ -8,13 +8,13 @@ import com.simibubi.create.content.logistics.item.filter.FilterItem;
import com.simibubi.create.content.logistics.trains.entity.Carriage; import com.simibubi.create.content.logistics.trains.entity.Carriage;
import com.simibubi.create.content.logistics.trains.entity.Train; import com.simibubi.create.content.logistics.trains.entity.Train;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder; import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
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.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@ -27,7 +27,7 @@ public class ItemThresholdCondition extends CargoThresholdCondition {
@Override @Override
protected Component getUnit() { protected Component getUnit() {
return new TextComponent(inStacks() ? "\u25A4" : ""); return Components.literal(inStacks() ? "\u25A4" : "");
} }
@Override @Override
@ -126,7 +126,7 @@ public class ItemThresholdCondition extends CargoThresholdCondition {
public MutableComponent getWaitingStatus(Level level, Train train, CompoundTag tag) { public MutableComponent getWaitingStatus(Level level, Train train, CompoundTag tag) {
int lastDisplaySnapshot = getLastDisplaySnapshot(tag); int lastDisplaySnapshot = getLastDisplaySnapshot(tag);
if (lastDisplaySnapshot == -1) if (lastDisplaySnapshot == -1)
return TextComponent.EMPTY.copy(); return Components.empty();
int offset = getOperator() == Ops.LESS ? -1 : getOperator() == Ops.GREATER ? 1 : 0; int offset = getOperator() == Ops.LESS ? -1 : getOperator() == Ops.GREATER ? 1 : 0;
return Lang.translateDirect("schedule.condition.threshold.status", lastDisplaySnapshot, return Lang.translateDirect("schedule.condition.threshold.status", lastDisplaySnapshot,
Math.max(0, getThreshold() + offset), Math.max(0, getThreshold() + offset),

Some files were not shown because too many files have changed in this diff Show more