mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 10:23:42 +01:00
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:
parent
826e29f0f3
commit
9c8df2ff27
199 changed files with 1171 additions and 822 deletions
|
@ -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.ItemListDisplaySource;
|
||||
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.KineticStressDisplaySource;
|
||||
import com.simibubi.create.content.logistics.block.display.source.ObservedTrainNameSource;
|
||||
|
@ -1696,7 +1696,7 @@ public class AllBlocks {
|
|||
.properties(p -> p.color(MaterialColor.STONE))
|
||||
.transform(BuilderTransformers.beltTunnel("andesite", new ResourceLocation("block/polished_andesite")))
|
||||
.onRegister(assignDataBehaviour(new AccumulatedItemCountDisplaySource(), "accumulate_items"))
|
||||
.onRegister(assignDataBehaviour(new ItemThoughputDisplaySource(), "item_throughput"))
|
||||
.onRegister(assignDataBehaviour(new ItemThroughputDisplaySource(), "item_throughput"))
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<BrassTunnelBlock> BRASS_TUNNEL =
|
||||
|
@ -1704,7 +1704,7 @@ public class AllBlocks {
|
|||
.properties(p -> p.color(MaterialColor.TERRACOTTA_YELLOW))
|
||||
.transform(BuilderTransformers.beltTunnel("brass", Create.asResource("block/brass_block")))
|
||||
.onRegister(assignDataBehaviour(new AccumulatedItemCountDisplaySource(), "accumulate_items"))
|
||||
.onRegister(assignDataBehaviour(new ItemThoughputDisplaySource(), "item_throughput"))
|
||||
.onRegister(assignDataBehaviour(new ItemThroughputDisplaySource(), "item_throughput"))
|
||||
.onRegister(connectedTextures(BrassTunnelCTBehaviour::new))
|
||||
.register();
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.LeverMovingInteraction;
|
||||
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 net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class AllInteractionBehaviours {
|
||||
private static final 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<>();
|
||||
|
||||
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) {
|
||||
BLOCK_BEHAVIOURS.put(block, provider);
|
||||
registerBehaviour(block.name(), provider);
|
||||
}
|
||||
|
||||
public static void registerBehaviourProvider(BehaviourProvider provider) {
|
||||
|
@ -33,7 +43,7 @@ public class AllInteractionBehaviours {
|
|||
|
||||
@Nullable
|
||||
public static MovingInteractionBehaviour getBehaviour(BlockState state) {
|
||||
MovingInteractionBehaviour behaviour = BLOCK_BEHAVIOURS.get(state.getBlock().delegate);
|
||||
MovingInteractionBehaviour behaviour = BLOCK_BEHAVIOURS.get(state.getBlock());
|
||||
if (behaviour != null) {
|
||||
return behaviour;
|
||||
}
|
||||
|
@ -50,11 +60,11 @@ public class AllInteractionBehaviours {
|
|||
|
||||
public static <B extends Block> NonNullConsumer<? super B> interactionBehaviour(
|
||||
MovingInteractionBehaviour behaviour) {
|
||||
return b -> registerBehaviour(b.delegate, behaviour);
|
||||
return b -> registerBehaviour(b, behaviour);
|
||||
}
|
||||
|
||||
static void registerDefaults() {
|
||||
registerBehaviour(Blocks.LEVER.delegate, new LeverMovingInteraction());
|
||||
registerBehaviour(Blocks.LEVER, new LeverMovingInteraction());
|
||||
|
||||
DoorMovingInteraction doorBehaviour = new DoorMovingInteraction();
|
||||
registerBehaviourProvider(state -> {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.DropperMovementBehaviour;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
||||
import com.simibubi.create.foundation.utility.CreateRegistry;
|
||||
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.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class AllMovementBehaviours {
|
||||
private static final 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<>();
|
||||
|
||||
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) {
|
||||
BLOCK_BEHAVIOURS.put(block, behaviour);
|
||||
registerBehaviour(block.name(), behaviour);
|
||||
}
|
||||
|
||||
public static void registerBehaviourProvider(BehaviourProvider provider) {
|
||||
|
@ -33,7 +43,7 @@ public class AllMovementBehaviours {
|
|||
|
||||
@Nullable
|
||||
public static MovementBehaviour getBehaviour(BlockState state) {
|
||||
MovementBehaviour behaviour = BLOCK_BEHAVIOURS.get(state.getBlock().delegate);
|
||||
MovementBehaviour behaviour = BLOCK_BEHAVIOURS.get(state.getBlock());
|
||||
if (behaviour != null) {
|
||||
return behaviour;
|
||||
}
|
||||
|
@ -50,16 +60,16 @@ public class AllMovementBehaviours {
|
|||
|
||||
public static <B extends Block> NonNullConsumer<? super B> movementBehaviour(
|
||||
MovementBehaviour behaviour) {
|
||||
return b -> registerBehaviour(b.delegate, behaviour);
|
||||
return b -> registerBehaviour(b, behaviour);
|
||||
}
|
||||
|
||||
static void registerDefaults() {
|
||||
registerBehaviour(Blocks.BELL.delegate, new BellMovementBehaviour());
|
||||
registerBehaviour(Blocks.CAMPFIRE.delegate, new CampfireMovementBehaviour());
|
||||
registerBehaviour(Blocks.BELL, new BellMovementBehaviour());
|
||||
registerBehaviour(Blocks.CAMPFIRE, new CampfireMovementBehaviour());
|
||||
|
||||
DispenserMovementBehaviour.gatherMovedDispenseItemBehaviours();
|
||||
registerBehaviour(Blocks.DISPENSER.delegate, new DispenserMovementBehaviour());
|
||||
registerBehaviour(Blocks.DROPPER.delegate, new DropperMovementBehaviour());
|
||||
registerBehaviour(Blocks.DISPENSER, new DispenserMovementBehaviour());
|
||||
registerBehaviour(Blocks.DROPPER, new DropperMovementBehaviour());
|
||||
}
|
||||
|
||||
public interface BehaviourProvider {
|
||||
|
|
|
@ -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.tools.SandPaperPolishingRecipe;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
import com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -143,7 +144,7 @@ public enum AllRecipeTypes implements IRecipeTypeInfo {
|
|||
|
||||
public static boolean shouldIgnoreInAutomation(Recipe<?> recipe) {
|
||||
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 recipe.getId()
|
||||
.getPath()
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.simibubi.create.foundation.advancement.AllTriggers;
|
|||
import com.simibubi.create.foundation.block.CopperRegistries;
|
||||
import com.simibubi.create.foundation.command.ServerLagger;
|
||||
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.LangMerger;
|
||||
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.StandardRecipeGen;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.utility.CreateRegistry;
|
||||
import com.simibubi.create.foundation.worldgen.AllWorldFeatures;
|
||||
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.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
|
@ -80,6 +84,8 @@ public class Create {
|
|||
public static final TorquePropagator TORQUE_PROPAGATOR = new TorquePropagator();
|
||||
public static final GlobalRailwayManager RAILWAYS = new GlobalRailwayManager();
|
||||
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();
|
||||
|
||||
private static final NonNullSupplier<CreateRegistrate> REGISTRATE = CreateRegistrate.lazy(ID);
|
||||
|
@ -103,6 +109,7 @@ public class Create {
|
|||
AllMovementBehaviours.registerDefaults();
|
||||
AllInteractionBehaviours.registerDefaults();
|
||||
AllDisplayBehaviours.registerDefaults();
|
||||
ContraptionMovementSetting.registerDefaults();
|
||||
AllArmInteractionPointTypes.register();
|
||||
AllWorldFeatures.register();
|
||||
AllEnchantments.register();
|
||||
|
@ -133,6 +140,7 @@ public class Create {
|
|||
}
|
||||
|
||||
public static void init(final FMLCommonSetupEvent event) {
|
||||
CreateRegistry.unwrapAll();
|
||||
AllPackets.registerPackets();
|
||||
SchematicInstances.register();
|
||||
BuiltinPotatoProjectileTypes.register();
|
||||
|
|
|
@ -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.CreateContexts;
|
||||
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.ghost.GhostBlocks;
|
||||
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.client.GraphicsStatus;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.ComponentUtils;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.client.gui.ForgeIngameGui;
|
||||
import net.minecraftforge.client.gui.OverlayRegistry;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
@ -126,16 +125,16 @@ public class CreateClient {
|
|||
if (AllConfigs.CLIENT.ignoreFabulousWarning.get())
|
||||
return;
|
||||
|
||||
MutableComponent text = ComponentUtils.wrapInSquareBrackets(new TextComponent("WARN"))
|
||||
MutableComponent text = ComponentUtils.wrapInSquareBrackets(Components.literal("WARN"))
|
||||
.withStyle(ChatFormatting.GOLD)
|
||||
.append(new TextComponent(
|
||||
.append(Components.literal(
|
||||
" Some of Create's visual features will not be available while Fabulous graphics are enabled!"))
|
||||
.withStyle(style -> style
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/create dismissFabulousWarning"))
|
||||
.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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.simibubi.create.AllFluids;
|
|||
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler;
|
||||
import com.simibubi.create.content.contraptions.processing.ProcessingOutput;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import mezz.jei.api.forge.ForgeTypes;
|
||||
|
@ -27,7 +28,6 @@ import mezz.jei.api.registration.IRecipeRegistration;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
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;
|
||||
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())
|
||||
tooltip.add(0, text);
|
||||
else {
|
||||
List<Component> siblings = tooltip.get(0).getSiblings();
|
||||
siblings.add(new TextComponent(" "));
|
||||
siblings.add(Components.literal(" "));
|
||||
siblings.add(text);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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.ProcessingRecipeBuilder;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.forge.ForgeTypes;
|
||||
|
@ -68,10 +69,8 @@ public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
|
|||
continue;
|
||||
|
||||
Ingredient ingredient = Ingredient.of(stack);
|
||||
ResourceLocation itemName = stack.getItem()
|
||||
.getRegistryName();
|
||||
ResourceLocation fluidName = extracted.getFluid()
|
||||
.getRegistryName();
|
||||
ResourceLocation itemName = RegisteredObjects.getKeyOrThrow(stack.getItem());
|
||||
ResourceLocation fluidName = RegisteredObjects.getKeyOrThrow(extracted.getFluid());
|
||||
|
||||
consumer.accept(new ProcessingRecipeBuilder<>(EmptyingRecipe::new,
|
||||
Create.asResource("empty_" + itemName.getNamespace() + "_" + itemName.getPath() + "_of_"
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.compat.jei.category.animations.AnimatedCrafter;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
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.renderer.entity.ItemRenderer;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
|
@ -183,7 +184,7 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
|
|||
return ingredient.getTooltipLines(player, tooltipFlag);
|
||||
} catch (RuntimeException | LinkageError e) {
|
||||
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));
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@ import com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRe
|
|||
import com.simibubi.create.content.contraptions.itemAssembly.SequencedRecipe;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
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.RegisteredObjects;
|
||||
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
|
||||
|
@ -25,8 +27,7 @@ import net.minecraft.ChatFormatting;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
|
@ -75,9 +76,8 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
|
|||
}
|
||||
|
||||
private SequencedAssemblySubCategory getSubCategory(SequencedRecipe<?> sequencedRecipe) {
|
||||
return subCategories.computeIfAbsent(sequencedRecipe.getRecipe()
|
||||
.getSerializer()
|
||||
.getRegistryName(),
|
||||
return subCategories.computeIfAbsent(RegisteredObjects.getKeyOrThrow(sequencedRecipe.getRecipe()
|
||||
.getSerializer()),
|
||||
rl -> sequencedRecipe.getAsAssemblyRecipe()
|
||||
.getJEISubCategory()
|
||||
.get()
|
||||
|
@ -100,7 +100,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
|
|||
AllGuiTextures.JEI_LONG_ARROW.render(matrixStack, 52 + xOffset, 79);
|
||||
if (!singleOutput) {
|
||||
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,
|
||||
0xefefef);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
|
|||
matrixStack.pushPose();
|
||||
matrixStack.translate(15, 9, 0);
|
||||
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);
|
||||
matrixStack.popPose();
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
|
|||
SequencedRecipe<?> sequencedRecipe = sequence.get(i);
|
||||
SequencedAssemblySubCategory subCategory = getSubCategory(sequencedRecipe);
|
||||
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);
|
||||
subCategory.draw(sequencedRecipe, matrixStack, mouseX, mouseY, i);
|
||||
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) {
|
||||
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 willRepeat = recipe.getLoops() > 1;
|
||||
|
|
|
@ -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.foundation.fluid.FluidIngredient;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.forge.ForgeTypes;
|
||||
|
@ -77,10 +78,8 @@ public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
|
|||
return;
|
||||
|
||||
Ingredient bucket = Ingredient.of(stack);
|
||||
ResourceLocation itemName = stack.getItem()
|
||||
.getRegistryName();
|
||||
ResourceLocation fluidName = fluidCopy.getFluid()
|
||||
.getRegistryName();
|
||||
ResourceLocation itemName = RegisteredObjects.getKeyOrThrow(stack.getItem());
|
||||
ResourceLocation fluidName = RegisteredObjects.getKeyOrThrow(fluidCopy.getFluid());
|
||||
consumer.accept(new ProcessingRecipeBuilder<>(FillingRecipe::new,
|
||||
Create.asResource("fill_" + itemName.getNamespace() + "_" + itemName.getPath()
|
||||
+ "_with_" + fluidName.getNamespace() + "_" + fluidName.getPath()))
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.simibubi.create.compat.Mods;
|
|||
import com.simibubi.create.content.contraptions.fluids.actors.SpoutTileEntity;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -40,8 +41,7 @@ public class SpoutCasting extends BlockSpoutingBehaviour {
|
|||
if (handler.getTanks() != 1)
|
||||
return 0;
|
||||
|
||||
ResourceLocation registryName = te.getType()
|
||||
.getRegistryName();
|
||||
ResourceLocation registryName = RegisteredObjects.getKeyOrThrow(te.getType());
|
||||
if (!registryName.equals(TABLE) && !registryName.equals(BASIN))
|
||||
return 0;
|
||||
if (!handler.isFluidValid(0, availableFluid))
|
||||
|
|
|
@ -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.ProcessingRecipeBuilder;
|
||||
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
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.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
|
@ -59,9 +58,9 @@ public class DeployerApplicationRecipe extends ItemApplicationRecipe implements
|
|||
ItemStack[] matchingStacks = ingredients.get(1)
|
||||
.getItems();
|
||||
if (matchingStacks.length == 0)
|
||||
return new TextComponent("Invalid");
|
||||
return Components.literal("Invalid");
|
||||
return Lang.translateDirect("recipe.assembly.deploying_item",
|
||||
new TranslatableComponent(matchingStacks[0].getDescriptionId()).getString());
|
||||
Components.translatable(matchingStacks[0].getDescriptionId()).getString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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.TransportedItemStackHandlerBehaviour;
|
||||
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.NBTHelper;
|
||||
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.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
|
@ -480,13 +480,13 @@ public class DeployerTileEntity extends KineticTileEntity {
|
|||
|
||||
if (!heldItem.isEmpty())
|
||||
Lang.translate("tooltip.deployer.contains",
|
||||
new TranslatableComponent(heldItem.getDescriptionId()).getString(), heldItem.getCount())
|
||||
Components.translatable(heldItem.getDescriptionId()).getString(), heldItem.getCount())
|
||||
.style(ChatFormatting.GREEN)
|
||||
.forGoggles(tooltip);
|
||||
|
||||
float stressAtBase = calculateStressApplied();
|
||||
if (StressImpact.isEnabled() && !Mth.equal(stressAtBase, 0)) {
|
||||
tooltip.add(Lang.empty());
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
addStressImpactStats(tooltip, stressAtBase);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
|
||||
import com.simibubi.create.foundation.block.BlockStressValues;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
|
@ -81,7 +82,7 @@ public class PoweredShaftTileEntity extends GeneratingKineticTileEntity {
|
|||
if (enginePos != null && capacityKey != null) {
|
||||
compound.put("EnginePos", NbtUtils.writeBlockPos(enginePos));
|
||||
compound.putFloat("EnginePower", engineEfficiency);
|
||||
compound.putString("EngineType", capacityKey.getRegistryName()
|
||||
compound.putString("EngineType", RegisteredObjects.getKeyOrThrow(capacityKey)
|
||||
.toString());
|
||||
}
|
||||
super.write(compound, clientPacket);
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.simibubi.create.foundation.advancement.AllAdvancements;
|
|||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
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.VecHelper;
|
||||
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.nbt.CompoundTag;
|
||||
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.world.level.block.entity.BlockEntity;
|
||||
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")
|
||||
.getString()
|
||||
.split(";");
|
||||
TextComponent textComponent = new TextComponent(spacing);
|
||||
MutableComponent textComponent = Components.literal(spacing);
|
||||
tooltip.add(textComponent.append(Lang.translateDirect("generic.pitch", pitches[pitch % pitches.length])));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ import java.util.List;
|
|||
|
||||
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public interface IDisplayAssemblyExceptions {
|
||||
|
||||
|
@ -19,7 +19,7 @@ public interface IDisplayAssemblyExceptions {
|
|||
return false;
|
||||
|
||||
if (!tooltip.isEmpty())
|
||||
tooltip.add(TextComponent.EMPTY);
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
|
||||
tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("gui.assembly.exception")
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simibubi.create.AllSpecialTextures;
|
|||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.AbstractChassisBlock;
|
||||
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.RaycastHelper;
|
||||
|
||||
|
@ -18,7 +19,6 @@ import net.minecraft.client.multiplayer.ClientLevel;
|
|||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -62,7 +62,7 @@ public class SuperGlueSelectionHandler {
|
|||
|
||||
if (clusterCooldown > 0) {
|
||||
if (clusterCooldown == 25)
|
||||
player.displayClientMessage(TextComponent.EMPTY, true);
|
||||
player.displayClientMessage(Components.immutableEmpty(), true);
|
||||
CreateClient.OUTLINER.keep(clusterOutlineSlot);
|
||||
clusterCooldown--;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.fluids;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
|
@ -43,8 +44,7 @@ public class FluidBottleItemHook extends Item {
|
|||
return;
|
||||
|
||||
FluidState fluidState = world.getFluidState(blockpos);
|
||||
if (fluidState.is(FluidTags.WATER) && fluidState.getType()
|
||||
.getRegistryName()
|
||||
if (fluidState.is(FluidTags.WATER) && RegisteredObjects.getKeyOrThrow(fluidState.getType())
|
||||
.getNamespace()
|
||||
.equals(Create.ID)) {
|
||||
event.setCancellationResult(InteractionResult.PASS);
|
||||
|
|
|
@ -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.ProcessingRecipeBuilder.ProcessingRecipeParams;
|
||||
import com.simibubi.create.foundation.fluid.FluidIngredient;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -70,7 +70,7 @@ public class FillingRecipe extends ProcessingRecipe<RecipeWrapper> implements IA
|
|||
List<FluidStack> matchingFluidStacks = fluidIngredients.get(0)
|
||||
.getMatchingFluidStacks();
|
||||
if (matchingFluidStacks.size() == 0)
|
||||
return new TextComponent("Invalid");
|
||||
return Components.literal("Invalid");
|
||||
return Lang.translateDirect("recipe.assembly.spout_filling_fluid",
|
||||
matchingFluidStacks.get(0).getDisplayName().getString());
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.mojang.serialization.Codec;
|
|||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import com.simibubi.create.AllParticleTypes;
|
||||
import com.simibubi.create.content.contraptions.particle.ICustomParticleData;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import net.minecraft.client.particle.ParticleProvider;
|
||||
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.OnlyIn;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class FluidParticleData implements ParticleOptions, ICustomParticleData<FluidParticleData> {
|
||||
|
||||
|
@ -49,8 +49,7 @@ public class FluidParticleData implements ParticleOptions, ICustomParticleData<F
|
|||
|
||||
@Override
|
||||
public String writeToString() {
|
||||
return ForgeRegistries.PARTICLE_TYPES.getKey(type) + " " + fluid.getFluid()
|
||||
.getRegistryName();
|
||||
return RegisteredObjects.getKeyOrThrow(type) + " " + RegisteredObjects.getKeyOrThrow(fluid.getFluid());
|
||||
}
|
||||
|
||||
public static final Codec<FluidParticleData> CODEC = RecordCodecBuilder.create(i -> i
|
||||
|
|
|
@ -5,12 +5,13 @@ import java.util.List;
|
|||
|
||||
import com.simibubi.create.AllFluids;
|
||||
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.RegisteredObjects;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
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.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class PotionFluid extends VirtualFluid {
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class PotionFluid extends VirtualFluid {
|
|||
}
|
||||
|
||||
public static FluidStack addPotionToFluidStack(FluidStack fs, Potion potion) {
|
||||
ResourceLocation resourcelocation = ForgeRegistries.POTIONS.getKey(potion);
|
||||
ResourceLocation resourcelocation = RegisteredObjects.getKeyOrThrow(potion);
|
||||
if (potion == Potions.EMPTY) {
|
||||
fs.removeChildTag("Potion");
|
||||
return fs;
|
||||
|
@ -82,7 +82,7 @@ public class PotionFluid extends VirtualFluid {
|
|||
|
||||
@Override
|
||||
public Component getDisplayName(FluidStack stack) {
|
||||
return new TranslatableComponent(getTranslationKey(stack));
|
||||
return Components.translatable(getTranslationKey(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,14 +8,14 @@ import com.google.common.collect.Lists;
|
|||
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluid.BottleType;
|
||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||
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.Pair;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
|
@ -105,10 +105,10 @@ public class PotionFluidHandler {
|
|||
List<MobEffectInstance> list = PotionUtils.getAllEffects(fs.getOrCreateTag());
|
||||
List<Tuple<String, AttributeModifier>> list1 = Lists.newArrayList();
|
||||
if (list.isEmpty()) {
|
||||
tooltip.add((new TranslatableComponent("effect.none")).withStyle(ChatFormatting.GRAY));
|
||||
tooltip.add((Components.translatable("effect.none")).withStyle(ChatFormatting.GRAY));
|
||||
} else {
|
||||
for (MobEffectInstance effectinstance : list) {
|
||||
TranslatableComponent textcomponent = new TranslatableComponent(effectinstance.getDescriptionId());
|
||||
MutableComponent textcomponent = Components.translatable(effectinstance.getDescriptionId());
|
||||
MobEffect effect = effectinstance.getEffect();
|
||||
Map<Attribute, AttributeModifier> map = effect.getAttributeModifiers();
|
||||
if (!map.isEmpty()) {
|
||||
|
@ -125,7 +125,7 @@ public class PotionFluidHandler {
|
|||
|
||||
if (effectinstance.getAmplifier() > 0) {
|
||||
textcomponent.append(" ")
|
||||
.append(new TranslatableComponent("potion.potency." + effectinstance.getAmplifier()).getString());
|
||||
.append(Components.translatable("potion.potency." + effectinstance.getAmplifier()).getString());
|
||||
}
|
||||
|
||||
if (effectinstance.getDuration() > 20) {
|
||||
|
@ -140,8 +140,8 @@ public class PotionFluidHandler {
|
|||
}
|
||||
|
||||
if (!list1.isEmpty()) {
|
||||
tooltip.add(new TextComponent(""));
|
||||
tooltip.add((new TranslatableComponent("potion.whenDrank")).withStyle(ChatFormatting.DARK_PURPLE));
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
tooltip.add((Components.translatable("potion.whenDrank")).withStyle(ChatFormatting.DARK_PURPLE));
|
||||
|
||||
for (Tuple<String, AttributeModifier> tuple : list1) {
|
||||
AttributeModifier attributemodifier2 = tuple.getB();
|
||||
|
@ -155,19 +155,19 @@ public class PotionFluidHandler {
|
|||
}
|
||||
|
||||
if (d0 > 0.0D) {
|
||||
tooltip.add((new TranslatableComponent(
|
||||
tooltip.add((Components.translatable(
|
||||
"attribute.modifier.plus." + attributemodifier2.getOperation()
|
||||
.toValue(),
|
||||
ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1),
|
||||
new TranslatableComponent(tuple.getA())))
|
||||
Components.translatable(tuple.getA())))
|
||||
.withStyle(ChatFormatting.BLUE));
|
||||
} else if (d0 < 0.0D) {
|
||||
d1 = d1 * -1.0D;
|
||||
tooltip.add((new TranslatableComponent(
|
||||
tooltip.add((Components.translatable(
|
||||
"attribute.modifier.take." + attributemodifier2.getOperation()
|
||||
.toValue(),
|
||||
ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1),
|
||||
new TranslatableComponent(tuple.getA())))
|
||||
Components.translatable(tuple.getA())))
|
||||
.withStyle(ChatFormatting.RED));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.simibubi.create.foundation.advancement.AdvancementBehaviour;
|
|||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.block.BlockStressValues;
|
||||
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.Lang;
|
||||
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.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
@ -147,8 +147,8 @@ public class BoilerData {
|
|||
if (!isActive())
|
||||
return false;
|
||||
|
||||
Component indent = new TextComponent(IHaveGoggleInformation.spacing);
|
||||
Component indent2 = new TextComponent(IHaveGoggleInformation.spacing + " ");
|
||||
Component indent = Components.literal(IHaveGoggleInformation.spacing);
|
||||
Component indent2 = Components.literal(IHaveGoggleInformation.spacing + " ");
|
||||
|
||||
calcMinMaxForSize(boilerSize);
|
||||
|
||||
|
@ -169,7 +169,7 @@ public class BoilerData {
|
|||
double totalSU = getEngineEfficiency(boilerSize) * 16 * Math.max(boilerLevel, attachedEngines)
|
||||
* BlockStressValues.getCapacity(AllBlocks.STEAM_ENGINE.get());
|
||||
|
||||
tooltip.add(Lang.empty());
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
|
||||
Lang.translate("tooltip.capacityProvided")
|
||||
.style(ChatFormatting.GRAY)
|
||||
|
@ -234,12 +234,12 @@ public class BoilerData {
|
|||
}
|
||||
|
||||
private MutableComponent blockComponent(int level) {
|
||||
return new TextComponent(
|
||||
return Components.literal(
|
||||
"" + "\u2588".repeat(minValue) + "\u2592".repeat(level - minValue) + "\u2591".repeat(maxValue - 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(minValue > 0 ? 1 : 0, ChatFormatting.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) {
|
||||
return new TextComponent(Strings.repeat('|', level)).withStyle(format);
|
||||
return Components.literal(Strings.repeat('|', level)).withStyle(format);
|
||||
}
|
||||
|
||||
public boolean evaluate(FluidTankTileEntity controller) {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.fluids.tank;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -11,19 +9,31 @@ import com.simibubi.create.AllBlocks;
|
|||
import com.simibubi.create.AllTags.AllBlockTags;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
||||
import com.simibubi.create.foundation.utility.CreateRegistry;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class BoilerHeaters {
|
||||
private static final 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<>();
|
||||
|
||||
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) {
|
||||
BLOCK_HEATERS.put(block, heater);
|
||||
registerHeater(block.name(), heater);
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
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) {
|
||||
return heater.getActiveHeat(level, pos, state);
|
||||
}
|
||||
|
@ -52,7 +62,7 @@ public class BoilerHeaters {
|
|||
}
|
||||
|
||||
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);
|
||||
if (value == HeatLevel.NONE) {
|
||||
return -1;
|
||||
|
|
|
@ -8,12 +8,12 @@ import com.simibubi.create.AllItems;
|
|||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
|
||||
import com.simibubi.create.foundation.gui.element.GuiGameElement;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
|
@ -24,26 +24,26 @@ public class GoggleConfigScreen extends AbstractSimiScreen {
|
|||
private final List<Component> tooltip;
|
||||
|
||||
public GoggleConfigScreen() {
|
||||
Component componentSpacing = new TextComponent(" ");
|
||||
Component componentSpacing = Components.literal(" ");
|
||||
tooltip = new ArrayList<>();
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("gui.config.overlay1")));
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("gui.config.overlay2")
|
||||
.withStyle(ChatFormatting.GRAY)));
|
||||
tooltip.add(TextComponent.EMPTY);
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("gui.config.overlay3")));
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("gui.config.overlay4")));
|
||||
tooltip.add(TextComponent.EMPTY);
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("gui.config.overlay5")
|
||||
.withStyle(ChatFormatting.GRAY)));
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("gui.config.overlay6")
|
||||
.withStyle(ChatFormatting.GRAY)));
|
||||
tooltip.add(TextComponent.EMPTY);
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("gui.config.overlay7")));
|
||||
tooltip.add(componentSpacing.plainCopy()
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.simibubi.create.foundation.gui.Theme;
|
|||
import com.simibubi.create.foundation.gui.element.GuiGameElement;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox;
|
||||
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.Lang;
|
||||
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.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.GameType;
|
||||
|
@ -100,7 +100,7 @@ public class GoggleOverlayRenderer {
|
|||
|
||||
if (hasHoveringInformation) {
|
||||
if (!tooltip.isEmpty())
|
||||
tooltip.add(TextComponent.EMPTY);
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
IHaveHoveringInformation hte = (IHaveHoveringInformation) te;
|
||||
hoverAddedInformation = hte.addToTooltip(tooltip, mc.player.isShiftKeyDown());
|
||||
|
||||
|
@ -143,11 +143,11 @@ public class GoggleOverlayRenderer {
|
|||
if (!pistonFound)
|
||||
return;
|
||||
if (!tooltip.isEmpty())
|
||||
tooltip.add(TextComponent.EMPTY);
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
|
||||
tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy()
|
||||
.append(Lang.translateDirect("gui.goggles.pole_length"))
|
||||
.append(new TextComponent(" " + poles)));
|
||||
.append(Components.literal(" " + poles)));
|
||||
}
|
||||
|
||||
if (tooltip.isEmpty())
|
||||
|
|
|
@ -3,12 +3,12 @@ package com.simibubi.create.content.contraptions.goggles;
|
|||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.LangBuilder;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
@ -27,7 +27,7 @@ public interface IHaveGoggleInformation {
|
|||
* Use Lang.[...].forGoggles(list)
|
||||
*/
|
||||
@Deprecated
|
||||
Component componentSpacing = new TextComponent(spacing);
|
||||
Component componentSpacing = Components.literal(spacing);
|
||||
|
||||
/**
|
||||
* this method will be called when looking at a TileEntity that implemented this
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.simibubi.create.Create;
|
|||
import com.simibubi.create.content.contraptions.processing.ProcessingOutput;
|
||||
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
|
||||
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.Pair;
|
||||
|
||||
|
@ -19,7 +20,6 @@ import net.minecraft.ChatFormatting;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -239,7 +239,7 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
|
|||
int length = sequencedAssemblyRecipe.sequence.size();
|
||||
int step = sequencedAssemblyRecipe.getStep(stack);
|
||||
int total = length * sequencedAssemblyRecipe.loops;
|
||||
toolTip.add(new TextComponent(""));
|
||||
toolTip.add(Components.immutableEmpty());
|
||||
toolTip.add(Lang.translateDirect("recipe.sequenced_assembly")
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
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)
|
||||
.withStyle(ChatFormatting.AQUA));
|
||||
else
|
||||
toolTip.add(new TextComponent("-> ").append(textComponent)
|
||||
toolTip.add(Components.literal("-> ").append(textComponent)
|
||||
.withStyle(ChatFormatting.DARK_AQUA));
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
|
|||
import com.google.gson.JsonParseException;
|
||||
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
|
||||
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -35,7 +36,7 @@ public class SequencedRecipe<T extends ProcessingRecipe<?>> {
|
|||
@SuppressWarnings("unchecked")
|
||||
ProcessingRecipeSerializer<T> serializer = (ProcessingRecipeSerializer<T>) wrapped.getSerializer();
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("type", ForgeRegistries.RECIPE_SERIALIZERS.getKey(serializer)
|
||||
json.addProperty("type", RegisteredObjects.getKeyOrThrow(serializer)
|
||||
.toString());
|
||||
serializer.write(json, wrapped);
|
||||
return json;
|
||||
|
@ -62,7 +63,7 @@ public class SequencedRecipe<T extends ProcessingRecipe<?>> {
|
|||
public void writeToBuffer(FriendlyByteBuf buffer) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ProcessingRecipeSerializer<T> serializer = (ProcessingRecipeSerializer<T>) wrapped.getSerializer();
|
||||
buffer.writeResourceLocation(ForgeRegistries.RECIPE_SERIALIZERS.getKey(serializer));
|
||||
buffer.writeResourceLocation(RegisteredObjects.getKeyOrThrow(serializer));
|
||||
buffer.writeResourceLocation(wrapped.getId());
|
||||
serializer.toNetwork(buffer, wrapped);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.google.gson.JsonSyntaxException;
|
|||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.utility.Pair;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
@ -60,8 +61,8 @@ public class ProcessingOutput {
|
|||
|
||||
public JsonElement serialize() {
|
||||
JsonObject json = new JsonObject();
|
||||
ResourceLocation resourceLocation = compatDatagenOutput == null ? stack.getItem()
|
||||
.getRegistryName() : compatDatagenOutput.getFirst();
|
||||
ResourceLocation resourceLocation = compatDatagenOutput == null ? RegisteredObjects.getKeyOrThrow(stack
|
||||
.getItem()) : compatDatagenOutput.getFirst();
|
||||
json.addProperty("item", resourceLocation.toString());
|
||||
int count = compatDatagenOutput == null ? stack.getCount() : compatDatagenOutput.getSecond();
|
||||
if (count != 1)
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
|
@ -71,7 +72,7 @@ public class BlazeBurnerBlockItem extends BlockItem {
|
|||
|
||||
@Override
|
||||
public String getDescriptionId() {
|
||||
return hasCapturedBlaze() ? super.getDescriptionId() : "item.create." + getRegistryName().getPath();
|
||||
return hasCapturedBlaze() ? super.getDescriptionId() : "item.create." + RegisteredObjects.getKeyOrThrow(this).getPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,7 +100,7 @@ public class BlazeBurnerBlockItem extends BlockItem {
|
|||
possibleSpawns.add(spawner.nextSpawnData);
|
||||
}
|
||||
|
||||
ResourceLocation blazeId = EntityType.BLAZE.getRegistryName();
|
||||
ResourceLocation blazeId = RegisteredObjects.getKeyOrThrow(EntityType.BLAZE);
|
||||
for (SpawnData e : possibleSpawns) {
|
||||
ResourceLocation spawnerEntityId = new ResourceLocation(e.entityToSpawn()
|
||||
.getString("id"));
|
||||
|
|
|
@ -3,10 +3,10 @@ package com.simibubi.create.content.contraptions.relays.advanced.sequencer;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
public enum InstructionSpeedModifiers {
|
||||
|
||||
|
@ -24,7 +24,7 @@ public enum InstructionSpeedModifiers {
|
|||
value = modifier;
|
||||
}
|
||||
private InstructionSpeedModifiers(int modifier, String label) {
|
||||
this.label = new TextComponent(label);
|
||||
this.label = Components.literal(label);
|
||||
translationKey = "gui.sequenced_gearshift.speed." + Lang.asId(name());
|
||||
value = modifier;
|
||||
}
|
||||
|
|
|
@ -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.SelectionScrollInput;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class SequencedGearshiftScreen extends AbstractSimiScreen {
|
||||
|
@ -150,7 +150,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
|
|||
if (def.hasValueParameter) {
|
||||
String text = def.formatValue(instruction.value);
|
||||
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)
|
||||
label(ms, 127, yOffset - 3, instruction.speedModifier.label);
|
||||
|
|
|
@ -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.transport.BeltInventory;
|
||||
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.VecHelper;
|
||||
|
||||
|
@ -22,7 +23,6 @@ import net.minecraft.client.multiplayer.ClientLevel;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
|
@ -473,7 +473,7 @@ public class BeltSlicer {
|
|||
mc.player.displayClientMessage(Lang.translateDirect(feedback.langKey)
|
||||
.withStyle(feedback.formatting), true);
|
||||
else
|
||||
mc.player.displayClientMessage(new TextComponent(""), true);
|
||||
mc.player.displayClientMessage(Components.immutableEmpty(), true);
|
||||
|
||||
if (feedback.bb != null)
|
||||
CreateClient.OUTLINER.chaseAABB("BeltSlicer", feedback.bb)
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.simibubi.create.AllEnchantments;
|
|||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -11,7 +12,6 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
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.ClientboundSetTitleTextPacket;
|
||||
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 ClientboundSetSubtitleTextPacket(
|
||||
new TextComponent("\u26A0 ").withStyle(depleted ? ChatFormatting.RED : ChatFormatting.GOLD)
|
||||
Components.literal("\u26A0 ").withStyle(depleted ? ChatFormatting.RED : ChatFormatting.GOLD)
|
||||
.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) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
|
|||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.Color;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.util.StringUtil;
|
||||
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);
|
||||
|
||||
Component text = new TextComponent(StringUtil.formatTickDuration(timeLeft * 20));
|
||||
Component text = Components.literal(StringUtil.formatTickDuration(timeLeft * 20));
|
||||
GuiGameElement.of(AllItems.COPPER_BACKTANK.asStack())
|
||||
.at(0, 0)
|
||||
.render(poseStack);
|
||||
|
|
|
@ -5,6 +5,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
|||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.simibubi.create.content.contraptions.particle.ICustomParticleDataWithSprite;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
@ -16,7 +17,6 @@ import net.minecraft.core.particles.ParticleType;
|
|||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
|
@ -61,7 +61,7 @@ public abstract class BasicParticleData<T extends Particle> implements ParticleO
|
|||
|
||||
@Override
|
||||
public String writeToString() {
|
||||
return ForgeRegistries.PARTICLE_TYPES.getKey(getType()).toString();
|
||||
return RegisteredObjects.getKeyOrThrow(getType()).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -124,8 +124,8 @@ public class SymmetryHandler {
|
|||
.tesselateBlock(player.level, model, Blocks.AIR.defaultBlockState(), pos, ms, builder, true,
|
||||
random, Mth.getSeed(pos), OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
|
||||
|
||||
buffer.endBatch();
|
||||
ms.popPose();
|
||||
buffer.endBatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.SelectionScrollInput;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -61,9 +61,9 @@ public class SymmetryWandScreen extends AbstractSimiScreen {
|
|||
int x = guiLeft;
|
||||
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();
|
||||
labelAlign = new Label(x + 49, y + 50, TextComponent.EMPTY).colored(0xFFFFFFFF)
|
||||
labelAlign = new Label(x + 49, y + 50, Components.immutableEmpty()).colored(0xFFFFFFFF)
|
||||
.withShadow();
|
||||
|
||||
int state =
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.curiosities.weapons;
|
|||
import java.util.UUID;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
@ -43,7 +44,6 @@ import net.minecraftforge.common.IPlantable;
|
|||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.entity.EntityTeleportEvent;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class BuiltinPotatoProjectileTypes {
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class BuiltinPotatoProjectileTypes {
|
|||
.velocity(1.25f)
|
||||
.knockback(1.5f)
|
||||
.renderTumbling()
|
||||
.onBlockHit(plantCrop(Blocks.POTATOES.delegate))
|
||||
.onBlockHit(plantCrop(Blocks.POTATOES))
|
||||
.registerAndAssign(Items.POTATO),
|
||||
|
||||
BAKED_POTATO = create("baked_potato").damage(5)
|
||||
|
@ -79,7 +79,7 @@ public class BuiltinPotatoProjectileTypes {
|
|||
.knockback(0.3f)
|
||||
.renderTowardMotion(140, 1)
|
||||
.soundPitch(1.5f)
|
||||
.onBlockHit(plantCrop(Blocks.CARROTS.delegate))
|
||||
.onBlockHit(plantCrop(Blocks.CARROTS))
|
||||
.registerAndAssign(Items.CARROT),
|
||||
|
||||
GOLDEN_CARROT = create("golden_carrot").damage(12)
|
||||
|
@ -213,7 +213,7 @@ public class BuiltinPotatoProjectileTypes {
|
|||
.velocity(0.95f)
|
||||
.renderTumbling()
|
||||
.soundPitch(0.9f)
|
||||
.onBlockHit(placeBlockOnGround(Blocks.MELON.delegate))
|
||||
.onBlockHit(placeBlockOnGround(Blocks.MELON))
|
||||
.registerAndAssign(Blocks.MELON),
|
||||
|
||||
PUMPKIN_BLOCK = create("pumpkin_block").damage(6)
|
||||
|
@ -222,7 +222,7 @@ public class BuiltinPotatoProjectileTypes {
|
|||
.velocity(0.95f)
|
||||
.renderTumbling()
|
||||
.soundPitch(0.9f)
|
||||
.onBlockHit(placeBlockOnGround(Blocks.PUMPKIN.delegate))
|
||||
.onBlockHit(placeBlockOnGround(Blocks.PUMPKIN))
|
||||
.registerAndAssign(Blocks.PUMPKIN),
|
||||
|
||||
PUMPKIN_PIE = create("pumpkin_pie").damage(7)
|
||||
|
@ -303,7 +303,7 @@ public class BuiltinPotatoProjectileTypes {
|
|||
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) -> {
|
||||
if (world.isClientSide())
|
||||
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(
|
||||
IRegistryDelegate<? extends Block> block) {
|
||||
Supplier<? extends Block> block) {
|
||||
return (world, ray) -> {
|
||||
if (world.isClientSide())
|
||||
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) {
|
||||
return ray -> {
|
||||
Entity entity = ray.getEntity();
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.simibubi.create.content.curiosities.zapper.ShootableGadgetItemMethods
|
|||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.item.render.SimpleCustomRenderer;
|
||||
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.VecHelper;
|
||||
|
||||
|
@ -24,8 +25,6 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.network.chat.Component;
|
||||
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.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
@ -222,21 +221,21 @@ public class PotatoCannonItem extends ProjectileWeaponItem {
|
|||
String _reload = "potato_cannon.ammo.reload_ticks";
|
||||
String _knockback = "potato_cannon.ammo.knockback";
|
||||
|
||||
tooltip.add(new TextComponent(""));
|
||||
tooltip.add(new TranslatableComponent(ammo.getDescriptionId()).append(new TextComponent(":"))
|
||||
tooltip.add(Components.immutableEmpty());
|
||||
tooltip.add(Components.translatable(ammo.getDescriptionId()).append(Components.literal(":"))
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
PotatoCannonProjectileType type = PotatoProjectileTypeManager.getTypeForStack(ammo)
|
||||
.get();
|
||||
TextComponent spacing = new TextComponent(" ");
|
||||
MutableComponent spacing = Components.literal(" ");
|
||||
ChatFormatting green = ChatFormatting.GREEN;
|
||||
ChatFormatting darkGreen = ChatFormatting.DARK_GREEN;
|
||||
|
||||
float damageF = type.getDamage() * additionalDamageMult;
|
||||
MutableComponent damage = new TextComponent(
|
||||
MutableComponent damage = Components.literal(
|
||||
damageF == Mth.floor(damageF) ? "" + Mth.floor(damageF) : "" + damageF);
|
||||
MutableComponent reloadTicks = new TextComponent("" + type.getReloadTicks());
|
||||
MutableComponent reloadTicks = Components.literal("" + type.getReloadTicks());
|
||||
MutableComponent knockback =
|
||||
new TextComponent("" + (type.getKnockback() + additionalKnockback));
|
||||
Components.literal("" + (type.getKnockback() + additionalKnockback));
|
||||
|
||||
damage = damage.withStyle(additionalDamageMult > 1 ? green : darkGreen);
|
||||
knockback = knockback.withStyle(additionalKnockback > 0 ? green : darkGreen);
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package com.simibubi.create.content.curiosities.weapons;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import net.minecraft.ResourceLocationException;
|
||||
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.EntityHitResult;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class PotatoCannonProjectileType {
|
||||
|
||||
private Set<IRegistryDelegate<Item>> items = new HashSet<>();
|
||||
private List<Supplier<Item>> items = new ArrayList<>();
|
||||
|
||||
private int reloadTicks = 10;
|
||||
private int damage = 1;
|
||||
|
@ -43,7 +44,7 @@ public class PotatoCannonProjectileType {
|
|||
protected PotatoCannonProjectileType() {
|
||||
}
|
||||
|
||||
public Set<IRegistryDelegate<Item>> getItems() {
|
||||
public List<Supplier<Item>> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
|
@ -148,8 +149,8 @@ public class PotatoCannonProjectileType {
|
|||
|
||||
public static void toBuffer(PotatoCannonProjectileType type, FriendlyByteBuf buffer) {
|
||||
buffer.writeVarInt(type.items.size());
|
||||
for (IRegistryDelegate<Item> delegate : type.items) {
|
||||
buffer.writeResourceLocation(delegate.name());
|
||||
for (Supplier<Item> delegate : type.items) {
|
||||
buffer.writeResourceLocation(RegisteredObjects.getKeyOrThrow(delegate.get()));
|
||||
}
|
||||
buffer.writeInt(type.reloadTicks);
|
||||
buffer.writeInt(type.damage);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.content.curiosities.weapons;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -22,13 +23,12 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.network.NetworkEvent.Context;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class PotatoProjectileTypeManager {
|
||||
|
||||
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<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) {
|
||||
synchronized (BUILTIN_TYPE_MAP) {
|
||||
|
@ -44,14 +44,14 @@ public class PotatoProjectileTypeManager {
|
|||
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);
|
||||
}
|
||||
|
||||
public static Optional<PotatoCannonProjectileType> getTypeForStack(ItemStack item) {
|
||||
if (item.isEmpty())
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(getTypeForItem(item.getItem().delegate));
|
||||
return Optional.ofNullable(getTypeForItem(item.getItem()));
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
|
@ -62,17 +62,17 @@ public class PotatoProjectileTypeManager {
|
|||
public static void fillItemMap() {
|
||||
for (Map.Entry<ResourceLocation, PotatoCannonProjectileType> entry : BUILTIN_TYPE_MAP.entrySet()) {
|
||||
PotatoCannonProjectileType type = entry.getValue();
|
||||
for (IRegistryDelegate<Item> delegate : type.getItems()) {
|
||||
ITEM_TO_TYPE_MAP.put(delegate, type);
|
||||
for (Supplier<Item> delegate : type.getItems()) {
|
||||
ITEM_TO_TYPE_MAP.put(delegate.get(), type);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<ResourceLocation, PotatoCannonProjectileType> entry : CUSTOM_TYPE_MAP.entrySet()) {
|
||||
PotatoCannonProjectileType type = entry.getValue();
|
||||
for (IRegistryDelegate<Item> delegate : type.getItems()) {
|
||||
ITEM_TO_TYPE_MAP.put(delegate, type);
|
||||
for (Supplier<Item> delegate : type.getItems()) {
|
||||
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) {
|
||||
|
|
|
@ -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.widget.IconButton;
|
||||
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.NBTHelper;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
@ -44,7 +44,7 @@ public abstract class ZapperScreen extends AbstractSimiScreen {
|
|||
this.background = background;
|
||||
this.zapper = zapper;
|
||||
this.hand = hand;
|
||||
title = TextComponent.EMPTY;
|
||||
title = Components.immutableEmpty();
|
||||
brightColor = 0xFEFEFE;
|
||||
fontColor = AllGuiTextures.FONT_COLOR;
|
||||
|
||||
|
|
|
@ -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.ScrollInput;
|
||||
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.NBTHelper;
|
||||
|
||||
|
@ -22,7 +23,6 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class WorldshaperScreen extends ZapperScreen {
|
|||
int x = guiLeft;
|
||||
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)
|
||||
.titled(Lang.translateDirect("gui.terrainzapper.brush"))
|
||||
.writingTo(brushLabel)
|
||||
|
@ -111,7 +111,7 @@ public class WorldshaperScreen extends ZapperScreen {
|
|||
brushParams.clear();
|
||||
|
||||
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;
|
||||
ScrollInput input = new ScrollInput(x + 56 + 20 * index, y + 40, 18, 18)
|
||||
|
@ -155,10 +155,10 @@ public class WorldshaperScreen extends ZapperScreen {
|
|||
if (currentBrush.hasConnectivityOptions()) {
|
||||
int x1 = x + 7 + 4 * 18;
|
||||
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);
|
||||
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);
|
||||
|
||||
followDiagonals.withCallback(() -> {
|
||||
|
|
|
@ -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.ScrollOptionBehaviour;
|
||||
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.Iterate;
|
||||
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.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
@ -752,7 +752,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave
|
|||
.withStyle(ChatFormatting.WHITE));
|
||||
for (ItemStack item : allStacks) {
|
||||
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()))
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
|
|
|
@ -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.TransportedResult;
|
||||
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.Lang;
|
||||
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.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
|
@ -719,7 +719,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
|||
.withStyle(ChatFormatting.YELLOW)));
|
||||
if (!item.isEmpty()) {
|
||||
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()))
|
||||
.withStyle(ChatFormatting.GREEN));
|
||||
}
|
||||
|
|
|
@ -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.LecternDisplayTarget;
|
||||
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 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.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class AllDisplayBehaviours {
|
||||
|
||||
public static final Map<ResourceLocation, DisplayBehaviour> GATHERER_BEHAVIOURS = new HashMap<>();
|
||||
|
||||
public static final Map<IRegistryDelegate<Block>, List<DisplaySource>> SOURCES_BY_BLOCK = new HashMap<>();
|
||||
public static final Map<IRegistryDelegate<BlockEntityType<?>>, List<DisplaySource>> SOURCES_BY_TILE = new HashMap<>();
|
||||
private static final CreateRegistry<Block, List<DisplaySource>> SOURCES_BY_BLOCK = new CreateRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final CreateRegistry<BlockEntityType<?>, List<DisplaySource>> SOURCES_BY_TILE = new CreateRegistry<>(ForgeRegistries.BLOCK_ENTITIES);
|
||||
|
||||
public static final Map<IRegistryDelegate<Block>, DisplayTarget> TARGETS_BY_BLOCK = new HashMap<>();
|
||||
public static final Map<IRegistryDelegate<BlockEntityType<?>>, DisplayTarget> TARGETS_BY_TILE = new HashMap<>();
|
||||
private static final CreateRegistry<Block, DisplayTarget> TARGETS_BY_BLOCK = new CreateRegistry<>(ForgeRegistries.BLOCKS);
|
||||
private static final CreateRegistry<BlockEntityType<?>, DisplayTarget> TARGETS_BY_TILE = new CreateRegistry<>(ForgeRegistries.BLOCK_ENTITIES);
|
||||
|
||||
public static DisplayBehaviour register(ResourceLocation id, DisplayBehaviour behaviour) {
|
||||
behaviour.id = id;
|
||||
|
@ -45,45 +47,95 @@ public class AllDisplayBehaviours {
|
|||
return behaviour;
|
||||
}
|
||||
|
||||
public static void assignBlock(DisplayBehaviour behaviour, IRegistryDelegate<Block> block) {
|
||||
if (behaviour instanceof DisplaySource source)
|
||||
SOURCES_BY_BLOCK.computeIfAbsent(block, r -> new ArrayList<>())
|
||||
.add(source);
|
||||
if (behaviour instanceof DisplayTarget target)
|
||||
TARGETS_BY_BLOCK.put(block, target);
|
||||
public static void assignBlock(DisplayBehaviour behaviour, ResourceLocation 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, 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) {
|
||||
if (behaviour instanceof DisplaySource source)
|
||||
SOURCES_BY_TILE.computeIfAbsent(teType, r -> new ArrayList<>())
|
||||
.add(source);
|
||||
if (behaviour instanceof DisplayTarget target)
|
||||
TARGETS_BY_TILE.put(teType, target);
|
||||
assignTile(behaviour, teType.name());
|
||||
}
|
||||
|
||||
public static <B extends Block> NonNullConsumer<? super B> assignDataBehaviour(DisplayBehaviour behaviour,
|
||||
String... suffix) {
|
||||
return b -> {
|
||||
ResourceLocation registryName = b.getRegistryName();
|
||||
ResourceLocation registryName = RegisteredObjects.getKeyOrThrow(b);
|
||||
String idSuffix = behaviour instanceof DisplaySource ? "_source" : "_target";
|
||||
if (suffix.length > 0)
|
||||
idSuffix += "_" + suffix[0];
|
||||
assignBlock(register(new ResourceLocation(registryName.getNamespace(), registryName.getPath() + idSuffix),
|
||||
behaviour), b.delegate);
|
||||
behaviour), registryName);
|
||||
};
|
||||
}
|
||||
|
||||
public static <B extends BlockEntityType<?>> NonNullConsumer<? super B> assignDataBehaviourTE(
|
||||
DisplayBehaviour behaviour, String... suffix) {
|
||||
return b -> {
|
||||
ResourceLocation registryName = b.getRegistryName();
|
||||
ResourceLocation registryName = RegisteredObjects.getKeyOrThrow(b);
|
||||
String idSuffix = behaviour instanceof DisplaySource ? "_source" : "_target";
|
||||
if (suffix.length > 0)
|
||||
idSuffix += "_" + suffix[0];
|
||||
assignTile(
|
||||
register(new ResourceLocation(registryName.getNamespace(), registryName.getPath() + idSuffix),
|
||||
behaviour),
|
||||
b.delegate);
|
||||
registryName);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -108,7 +160,11 @@ public class AllDisplayBehaviours {
|
|||
//
|
||||
|
||||
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) {
|
||||
|
@ -116,7 +172,11 @@ public class AllDisplayBehaviours {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -125,7 +185,7 @@ public class AllDisplayBehaviours {
|
|||
|
||||
@Nullable
|
||||
public static DisplayTarget targetOf(Block block) {
|
||||
return TARGETS_BY_BLOCK.get(block.delegate);
|
||||
return TARGETS_BY_BLOCK.get(block);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -135,7 +195,7 @@ public class AllDisplayBehaviours {
|
|||
|
||||
@Nullable
|
||||
public static DisplayTarget targetOf(BlockEntityType<?> tileEntityType) {
|
||||
return TARGETS_BY_TILE.get(tileEntityType.delegate);
|
||||
return TARGETS_BY_TILE.get(tileEntityType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -171,11 +231,11 @@ public class AllDisplayBehaviours {
|
|||
//
|
||||
|
||||
public static void registerDefaults() {
|
||||
assignTile(register(Create.asResource("sign_display_target"), new SignDisplayTarget()), BlockEntityType.SIGN.delegate);
|
||||
assignTile(register(Create.asResource("lectern_display_target"), new LecternDisplayTarget()), BlockEntityType.LECTERN.delegate);
|
||||
assignBlock(register(Create.asResource("death_count_display_source"), new DeathCounterDisplaySource()), Blocks.RESPAWN_ANCHOR.delegate);
|
||||
assignTile(register(Create.asResource("scoreboard_display_source"), new ScoreboardDisplaySource()), BlockEntityType.COMMAND_BLOCK.delegate);
|
||||
assignTile(register(Create.asResource("enchant_power_display_source"), new EnchantPowerDisplaySource()), BlockEntityType.ENCHANTING_TABLE.delegate);
|
||||
assignBlock(register(Create.asResource("redstone_power_display_source"), new RedstonePowerDisplaySource()), Blocks.TARGET.delegate);
|
||||
assignTile(register(Create.asResource("sign_display_target"), new SignDisplayTarget()), BlockEntityType.SIGN);
|
||||
assignTile(register(Create.asResource("lectern_display_target"), new LecternDisplayTarget()), BlockEntityType.LECTERN);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.simibubi.create.foundation.gui.widget.SelectionScrollInput;
|
|||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.ponder.PonderTag;
|
||||
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.Lang;
|
||||
|
||||
|
@ -35,7 +36,6 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -137,7 +137,7 @@ public class DisplayLinkScreen extends AbstractSimiScreen {
|
|||
int rows = stats.maxRows();
|
||||
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);
|
||||
|
||||
if (rows > 1) {
|
||||
|
@ -189,7 +189,7 @@ public class DisplayLinkScreen extends AbstractSimiScreen {
|
|||
if (!sources.isEmpty()) {
|
||||
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)
|
||||
.getName();
|
||||
|
||||
|
|
|
@ -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.DisplayLinkTileEntity;
|
||||
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.TextComponent;
|
||||
|
||||
public class AccumulatedItemCountDisplaySource extends NumericSingleLineDisplaySource {
|
||||
|
||||
@Override
|
||||
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
|
||||
return new TextComponent(String.valueOf(context.sourceConfig()
|
||||
return Components.literal(String.valueOf(context.sourceConfig()
|
||||
.getInt("Collected")));
|
||||
}
|
||||
|
||||
|
|
|
@ -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.FlapDisplaySection;
|
||||
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 joptsimple.internal.Strings;
|
||||
import net.minecraft.ChatFormatting;
|
||||
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.LecternBlockEntity;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class BoilerDisplaySource extends DisplaySource {
|
|||
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))
|
||||
.orElse(EMPTY_LINE));
|
||||
}
|
||||
|
@ -128,9 +128,9 @@ public class BoilerDisplaySource extends DisplaySource {
|
|||
|
||||
int lw = labelWidth();
|
||||
if (forFlapDisplay) {
|
||||
size = new TextComponent(Strings.repeat(' ', lw - labelWidthOf("size"))).append(size);
|
||||
water = new TextComponent(Strings.repeat(' ', lw - labelWidthOf("water"))).append(water);
|
||||
heat = new TextComponent(Strings.repeat(' ', lw - labelWidthOf("heat"))).append(heat);
|
||||
size = Components.literal(Strings.repeat(' ', lw - labelWidthOf("size"))).append(size);
|
||||
water = Components.literal(Strings.repeat(' ', lw - labelWidthOf("water"))).append(water);
|
||||
heat = Components.literal(Strings.repeat(' ', lw - labelWidthOf("heat"))).append(heat);
|
||||
}
|
||||
|
||||
return Stream.of(List.of(Lang.translateDirect(label, boiler.getHeatLevelTextComponent())),
|
||||
|
@ -150,7 +150,7 @@ public class BoilerDisplaySource extends DisplaySource {
|
|||
|
||||
private MutableComponent labelOf(String label) {
|
||||
if (label.isBlank())
|
||||
return TextComponent.EMPTY.copy();
|
||||
return Components.empty();
|
||||
return Lang.translateDirect("boiler." + label);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.FlapDisplayTileEntity;
|
||||
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.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public abstract class DisplaySource extends DisplayBehaviour {
|
||||
|
||||
public static final List<MutableComponent> EMPTY = ImmutableList.of(new TextComponent(""));
|
||||
public static final MutableComponent EMPTY_LINE = new TextComponent("");
|
||||
public static final MutableComponent WHITESPACE = new TextComponent(" ");
|
||||
public static final List<MutableComponent> EMPTY = ImmutableList.of(Components.empty());
|
||||
public static final MutableComponent EMPTY_LINE = Components.empty();
|
||||
public static final MutableComponent WHITESPACE = Components.literal(" ");
|
||||
|
||||
public abstract List<MutableComponent> provideText(DisplayLinkContext context, DisplayTargetStats stats);
|
||||
|
||||
|
@ -55,7 +54,7 @@ public abstract class DisplaySource extends DisplayBehaviour {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -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.target.DisplayTargetStats;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
|
@ -23,7 +23,7 @@ public class EnchantPowerDisplaySource extends NumericSingleLineDisplaySource {
|
|||
@Override
|
||||
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
|
||||
if (!(context.getSourceTE() instanceof EnchantmentTableBlockEntity enchantmentTile))
|
||||
return ZERO;
|
||||
return ZERO.copy();
|
||||
|
||||
BlockPos pos = context.getSourcePos();
|
||||
Level level = context.level();
|
||||
|
@ -39,7 +39,7 @@ public class EnchantPowerDisplaySource extends NumericSingleLineDisplaySource {
|
|||
|
||||
int cost = EnchantmentHelper.getEnchantmentCost(random, 2, (int) enchantPower, stack);
|
||||
|
||||
return new TextComponent(String.valueOf(cost));
|
||||
return Components.literal(String.valueOf(cost));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.TankManipulationBehaviour;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.FluidFormatter;
|
||||
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
@ -38,7 +38,7 @@ public class FluidAmountDisplaySource extends SingleLineDisplaySource {
|
|||
collected += stack.getAmount();
|
||||
}
|
||||
|
||||
return new TextComponent(FluidFormatter.asString(collected, false));
|
||||
return Components.literal(FluidFormatter.asString(collected, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
|
||||
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.FluidFormatter;
|
||||
import com.simibubi.create.foundation.utility.IntAttached;
|
||||
|
||||
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.material.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
@ -63,7 +63,7 @@ public class FluidListDisplaySource extends ValueListDisplaySource {
|
|||
.limit(maxRows)
|
||||
.map(entry -> IntAttached.with(
|
||||
entry.getValue(),
|
||||
new TranslatableComponent(fluidNames.get(entry.getKey()).getTranslationKey()))
|
||||
Components.translatable(fluidNames.get(entry.getKey()).getTranslationKey()))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
|
||||
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.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
@ -18,14 +18,14 @@ public class ItemCountDisplaySource extends NumericSingleLineDisplaySource {
|
|||
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
|
||||
BlockEntity sourceTE = context.getSourceTE();
|
||||
if (!(sourceTE instanceof ContentObserverTileEntity cote))
|
||||
return ZERO;
|
||||
return ZERO.copy();
|
||||
|
||||
InvManipulationBehaviour invManipulationBehaviour = cote.getBehaviour(InvManipulationBehaviour.TYPE);
|
||||
FilteringBehaviour filteringBehaviour = cote.getBehaviour(FilteringBehaviour.TYPE);
|
||||
IItemHandler handler = invManipulationBehaviour.getInventory();
|
||||
|
||||
if (handler == null)
|
||||
return ZERO;
|
||||
return ZERO.copy();
|
||||
|
||||
int collected = 0;
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
|
@ -37,7 +37,7 @@ public class ItemCountDisplaySource extends NumericSingleLineDisplaySource {
|
|||
collected += stack.getCount();
|
||||
}
|
||||
|
||||
return new TextComponent(String.valueOf(collected));
|
||||
return Components.literal(String.valueOf(collected));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,11 +12,10 @@ import net.minecraft.nbt.FloatTag;
|
|||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class ItemThoughputDisplaySource extends AccumulatedItemCountDisplaySource {
|
||||
public class ItemThroughputDisplaySource extends AccumulatedItemCountDisplaySource {
|
||||
|
||||
static final int POOL_SIZE = 10;
|
||||
|
||||
|
@ -24,7 +23,7 @@ public class ItemThoughputDisplaySource extends AccumulatedItemCountDisplaySourc
|
|||
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
|
||||
CompoundTag conf = context.sourceConfig();
|
||||
if (conf.contains("Inactive"))
|
||||
return new TextComponent("0");
|
||||
return ZERO.copy();
|
||||
|
||||
double interval = 20 * Math.pow(60, conf.getInt("Interval"));
|
||||
double rate = conf.getFloat("Rate") * interval;
|
|
@ -14,8 +14,8 @@ public class KineticSpeedDisplaySource extends NumericSingleLineDisplaySource {
|
|||
|
||||
@Override
|
||||
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
|
||||
if (!(context.getSourceTE()instanceof SpeedGaugeTileEntity gaugeTile))
|
||||
return ZERO;
|
||||
if (!(context.getSourceTE() instanceof SpeedGaugeTileEntity gaugeTile))
|
||||
return ZERO.copy();
|
||||
|
||||
boolean absoluteValue = context.sourceConfig()
|
||||
.getInt("Directional") == 0;
|
||||
|
|
|
@ -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.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 {
|
||||
|
||||
protected static final TextComponent ZERO = new TextComponent("0");
|
||||
protected static final Component ZERO = Components.literal("0");
|
||||
|
||||
@Override
|
||||
protected String getFlapDisplayLayoutName(DisplayLinkContext context) {
|
||||
|
|
|
@ -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.trains.management.display.FlapDisplaySection;
|
||||
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.TextComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
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++)
|
||||
s.append("\u2592");
|
||||
|
||||
return new TextComponent(s.toString());
|
||||
return Components.literal(s.toString());
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -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.foundation.gui.ModularGuiLineBuilder;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
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.properties.BlockStateProperties;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -20,7 +20,7 @@ public class RedstonePowerDisplaySource extends PercentOrProgressBarDisplaySourc
|
|||
|
||||
@Override
|
||||
protected MutableComponent formatNumeric(DisplayLinkContext context, Float currentLevel) {
|
||||
return new TextComponent(String.valueOf((int) (currentLevel * 15)));
|
||||
return Components.literal(String.valueOf((int) (currentLevel * 15)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,12 +5,12 @@ import java.util.stream.Stream;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
|
||||
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.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
|
@ -41,7 +41,7 @@ public class ScoreboardDisplaySource extends ValueListDisplaySource {
|
|||
.getPlayerScores(objective)
|
||||
.stream()
|
||||
.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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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.FlapDisplayTileEntity;
|
||||
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
@ -51,7 +51,7 @@ public abstract class SingleLineDisplaySource extends DisplaySource {
|
|||
String label = context.sourceConfig()
|
||||
.getString("Label");
|
||||
if (!label.isEmpty())
|
||||
line = new TextComponent(label + " ").append(line);
|
||||
line = Components.literal(label + " ").append(line);
|
||||
}
|
||||
|
||||
return ImmutableList.of(line);
|
||||
|
@ -64,7 +64,7 @@ public abstract class SingleLineDisplaySource extends DisplaySource {
|
|||
String label = context.sourceConfig()
|
||||
.getString("Label");
|
||||
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);
|
||||
|
|
|
@ -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.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
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 =
|
||||
ImmutableList.of(WHITESPACE, new TextComponent(" . "), WHITESPACE, WHITESPACE);
|
||||
ImmutableList.of(WHITESPACE, Components.literal(" . "), WHITESPACE, WHITESPACE);
|
||||
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
|
||||
public List<MutableComponent> provideText(DisplayLinkContext context, DisplayTargetStats stats) {
|
||||
|
@ -67,7 +67,7 @@ public class StationSummaryDisplaySource extends DisplaySource {
|
|||
min++;
|
||||
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")
|
||||
: Lang.translateDirect("display_source.station_summary.seconds", sec));
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class StationSummaryDisplaySource extends DisplaySource {
|
|||
platform = platform.replace(string, "");
|
||||
platform = platform.replace("*", "?");
|
||||
|
||||
lines.add(new TextComponent(platform.trim()));
|
||||
lines.add(Components.literal(platform.trim()));
|
||||
list.add(lines);
|
||||
});
|
||||
|
||||
|
|
|
@ -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.target.DisplayTargetStats;
|
||||
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.TextComponent;
|
||||
|
||||
public class StopWatchDisplaySource extends SingleLineDisplaySource {
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class StopWatchDisplaySource extends SingleLineDisplaySource {
|
|||
int minutes = (diff / 60 / 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);
|
||||
|
||||
return component;
|
||||
|
|
|
@ -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.trains.management.display.FlapDisplaySection;
|
||||
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class TimeOfDayDisplaySource extends SingleLineDisplaySource {
|
||||
|
||||
public static final MutableComponent EMPTY_TIME = new TextComponent("--:--");
|
||||
public static final MutableComponent EMPTY_TIME = Components.literal("--:--");
|
||||
|
||||
@Override
|
||||
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
|
||||
|
@ -49,7 +49,7 @@ public class TimeOfDayDisplaySource extends SingleLineDisplaySource {
|
|||
minutes = Create.RANDOM.nextInt(40) + 60;
|
||||
}
|
||||
|
||||
MutableComponent component = new TextComponent(
|
||||
MutableComponent component = Components.literal(
|
||||
(hours < 10 ? " " : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + (c12 ? " " : ""));
|
||||
|
||||
return c12 ? component.append(suffix) : component;
|
||||
|
|
|
@ -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.FlapDisplayTileEntity;
|
||||
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.IntAttached;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.level.block.entity.LecternBlockEntity;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
@ -63,7 +63,7 @@ public abstract class ValueListDisplaySource extends DisplaySource {
|
|||
current = atIndex;
|
||||
continue;
|
||||
}
|
||||
current.append(new TextComponent("\n"))
|
||||
current.append(Components.literal("\n"))
|
||||
.append(atIndex);
|
||||
if ((i + 1) % ENTRIES_PER_PAGE == 0) {
|
||||
condensed.add(current);
|
||||
|
@ -99,7 +99,7 @@ public abstract class ValueListDisplaySource extends DisplaySource {
|
|||
: 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);
|
||||
}
|
||||
|
||||
|
@ -137,14 +137,14 @@ public abstract class ValueListDisplaySource extends DisplaySource {
|
|||
|
||||
private Couple<MutableComponent> shorten(int number) {
|
||||
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")
|
||||
.append(WHITESPACE));
|
||||
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")
|
||||
.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) {
|
||||
|
|
|
@ -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.foundation.tileEntity.SmartTileEntity;
|
||||
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.DynamicComponent;
|
||||
|
||||
|
@ -16,7 +17,6 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
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.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
@ -82,7 +82,7 @@ public class NixieTubeTileEntity extends SmartTileEntity {
|
|||
|
||||
public MutableComponent getFullText() {
|
||||
return customText.map(DynamicComponent::get)
|
||||
.orElse(new TextComponent("" + redstoneStrength));
|
||||
.orElse(Components.literal("" + redstoneStrength));
|
||||
}
|
||||
|
||||
public void updateRedstoneStrength(int signalStrength) {
|
||||
|
|
|
@ -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.ScrollInput;
|
||||
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.animation.LerpedFloat;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class StockpileSwitchScreen extends AbstractSimiScreen {
|
||||
|
@ -57,7 +57,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
|
|||
.startWithValue(te.getState() ? 1 : 0);
|
||||
|
||||
offBelow = new ScrollInput(x + 36, y + 40, 102, 18).withRange(0, 100)
|
||||
.titled(TextComponent.EMPTY.plainCopy())
|
||||
.titled(Components.empty())
|
||||
.calling(state -> {
|
||||
lastModification = 0;
|
||||
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));
|
||||
|
||||
onAbove = new ScrollInput(x + 36, y + 18, 102, 18).withRange(1, 101)
|
||||
.titled(TextComponent.EMPTY.plainCopy())
|
||||
.titled(Components.empty())
|
||||
.calling(state -> {
|
||||
lastModification = 0;
|
||||
onAbove.titled(Lang.translateDirect("gui.stockpile_switch.move_to_lower_at", state));
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.simibubi.create.foundation.item.TooltipHelper;
|
|||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkBehaviour;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.ControlsUtil;
|
||||
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.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.client.gui.ForgeIngameGui;
|
||||
|
@ -220,7 +220,7 @@ public class LinkedControllerClientHandler {
|
|||
return;
|
||||
|
||||
poseStack.pushPose();
|
||||
Screen tooltipScreen = new Screen(TextComponent.EMPTY) {
|
||||
Screen tooltipScreen = new Screen(Components.immutableEmpty()) {
|
||||
};
|
||||
tooltipScreen.init(mc, width1, height1);
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.AllContainerTypes;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Pair;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -11,7 +12,6 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
|
@ -52,7 +52,7 @@ public class AttributeFilterContainer extends AbstractFilterContainer {
|
|||
super.init(inv, contentHolder);
|
||||
ItemStack stack = new ItemStack(Items.NAME_TAG);
|
||||
stack.setHoverName(
|
||||
new TextComponent("Selected Tags").withStyle(ChatFormatting.RESET, ChatFormatting.BLUE));
|
||||
Components.literal("Selected Tags").withStyle(ChatFormatting.RESET, ChatFormatting.BLUE));
|
||||
ghostInventory.setStackInSlot(1, stack);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.SelectionScrollInput;
|
||||
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.Pair;
|
||||
|
||||
|
@ -22,7 +23,6 @@ import net.minecraft.ChatFormatting;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
|
@ -86,9 +86,9 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
});
|
||||
blacklist.setToolTip(denyN);
|
||||
|
||||
whitelistDisIndicator = new Indicator(x + 47, y + 53, TextComponent.EMPTY);
|
||||
whitelistConIndicator = new Indicator(x + 65, y + 53, TextComponent.EMPTY);
|
||||
blacklistIndicator = new Indicator(x + 83, y + 53, TextComponent.EMPTY);
|
||||
whitelistDisIndicator = new Indicator(x + 47, y + 53, Components.immutableEmpty());
|
||||
whitelistConIndicator = new Indicator(x + 65, y + 53, Components.immutableEmpty());
|
||||
blacklistIndicator = new Indicator(x + 83, y + 53, Components.immutableEmpty());
|
||||
|
||||
addRenderableWidgets(blacklist, whitelistCon, whitelistDis, blacklistIndicator, whitelistConIndicator,
|
||||
whitelistDisIndicator);
|
||||
|
@ -106,10 +106,10 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
|
||||
handleIndicators();
|
||||
|
||||
attributeSelectorLabel = new Label(x + 43, y + 26, TextComponent.EMPTY).colored(0xF3EBDE)
|
||||
attributeSelectorLabel = new Label(x + 43, y + 26, Components.immutableEmpty()).colored(0xF3EBDE)
|
||||
.withShadow();
|
||||
attributeSelector = new SelectionScrollInput(x + 39, y + 21, 137, 18);
|
||||
attributeSelector.forOptions(Arrays.asList(TextComponent.EMPTY));
|
||||
attributeSelector.forOptions(Arrays.asList(Components.immutableEmpty()));
|
||||
attributeSelector.removeCallback();
|
||||
referenceItemChanged(menu.ghostInventory.getStackInSlot(0));
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
selectedAttributes.clear();
|
||||
selectedAttributes.add((menu.selectedAttributes.isEmpty() ? noSelectedT : selectedT).plainCopy()
|
||||
.withStyle(ChatFormatting.YELLOW));
|
||||
menu.selectedAttributes.forEach(at -> selectedAttributes.add(new TextComponent("- ")
|
||||
menu.selectedAttributes.forEach(at -> selectedAttributes.add(Components.literal("- ")
|
||||
.append(at.getFirst()
|
||||
.format(at.getSecond()))
|
||||
.withStyle(ChatFormatting.GRAY)));
|
||||
|
@ -243,7 +243,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
if (menu.selectedAttributes.size() == 1)
|
||||
selectedAttributes.set(0, selectedT.plainCopy()
|
||||
.withStyle(ChatFormatting.YELLOW));
|
||||
selectedAttributes.add(new TextComponent("- ").append(itemAttribute.format(inverted))
|
||||
selectedAttributes.add(Components.literal("- ").append(itemAttribute.format(inverted))
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.simibubi.create.AllKeys;
|
|||
import com.simibubi.create.content.contraptions.processing.EmptyingByBasin;
|
||||
import com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer.WhitelistMode;
|
||||
import com.simibubi.create.foundation.item.ItemDescription;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -18,7 +19,6 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
@ -75,7 +75,7 @@ public class FilterItem extends Item implements MenuProvider {
|
|||
List<Component> makeSummary = makeSummary(stack);
|
||||
if (makeSummary.isEmpty())
|
||||
return;
|
||||
ItemDescription.add(tooltip, new TextComponent(" "));
|
||||
ItemDescription.add(tooltip, Components.literal(" "));
|
||||
ItemDescription.add(tooltip, makeSummary);
|
||||
}
|
||||
}
|
||||
|
@ -92,14 +92,14 @@ public class FilterItem extends Item implements MenuProvider {
|
|||
int count = 0;
|
||||
for (int i = 0; i < filterItems.getSlots(); i++) {
|
||||
if (count > 3) {
|
||||
list.add(new TextComponent("- ...").withStyle(ChatFormatting.DARK_GRAY));
|
||||
list.add(Components.literal("- ...").withStyle(ChatFormatting.DARK_GRAY));
|
||||
break;
|
||||
}
|
||||
|
||||
ItemStack filterStack = filterItems.getStackInSlot(i);
|
||||
if (filterStack.isEmpty())
|
||||
continue;
|
||||
list.add(new TextComponent("- ").append(filterStack.getHoverName()).withStyle(ChatFormatting.GRAY));
|
||||
list.add(Components.literal("- ").append(filterStack.getHoverName()).withStyle(ChatFormatting.GRAY));
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -124,10 +124,10 @@ public class FilterItem extends Item implements MenuProvider {
|
|||
ItemAttribute attribute = ItemAttribute.fromNBT(compound);
|
||||
boolean inverted = compound.getBoolean("Inverted");
|
||||
if (count > 3) {
|
||||
list.add(new TextComponent("- ...").withStyle(ChatFormatting.DARK_GRAY));
|
||||
list.add(Components.literal("- ...").withStyle(ChatFormatting.DARK_GRAY));
|
||||
break;
|
||||
}
|
||||
list.add(new TextComponent("- ").append(attribute.format(inverted)));
|
||||
list.add(Components.literal("- ").append(attribute.format(inverted)));
|
||||
count++;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ import com.simibubi.create.foundation.gui.AllGuiTextures;
|
|||
import com.simibubi.create.foundation.gui.AllIcons;
|
||||
import com.simibubi.create.foundation.gui.widget.IconButton;
|
||||
import com.simibubi.create.foundation.gui.widget.Indicator;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
public class FilterScreen extends AbstractFilterScreen<FilterContainer> {
|
||||
|
@ -58,8 +58,8 @@ public class FilterScreen extends AbstractFilterScreen<FilterContainer> {
|
|||
sendOptionUpdate(Option.WHITELIST);
|
||||
});
|
||||
whitelist.setToolTip(allowN);
|
||||
blacklistIndicator = new Indicator(x + 18, y + 67, TextComponent.EMPTY);
|
||||
whitelistIndicator = new Indicator(x + 36, y + 67, TextComponent.EMPTY);
|
||||
blacklistIndicator = new Indicator(x + 18, y + 67, Components.immutableEmpty());
|
||||
whitelistIndicator = new Indicator(x + 36, y + 67, Components.immutableEmpty());
|
||||
addRenderableWidgets(blacklist, whitelist, blacklistIndicator, whitelistIndicator);
|
||||
|
||||
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);
|
||||
});
|
||||
ignoreNBT.setToolTip(ignoreDataN);
|
||||
respectNBTIndicator = new Indicator(x + 60, y + 67, TextComponent.EMPTY);
|
||||
ignoreNBTIndicator = new Indicator(x + 78, y + 67, TextComponent.EMPTY);
|
||||
respectNBTIndicator = new Indicator(x + 60, y + 67, Components.immutableEmpty());
|
||||
ignoreNBTIndicator = new Indicator(x + 78, y + 67, Components.immutableEmpty());
|
||||
addRenderableWidgets(respectNBT, ignoreNBT, respectNBTIndicator, ignoreNBTIndicator);
|
||||
|
||||
handleIndicators();
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.simibubi.create.content.logistics.item.filter.attribute.astralsorcery
|
|||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
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.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
@ -121,7 +121,7 @@ public interface ItemAttribute {
|
|||
}
|
||||
|
||||
@OnlyIn(value = Dist.CLIENT)
|
||||
default TranslatableComponent format(boolean inverted) {
|
||||
default MutableComponent format(boolean inverted) {
|
||||
return Lang.translateDirect("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""),
|
||||
getTranslationParameters());
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ public interface ItemAttribute {
|
|||
|
||||
@Override
|
||||
@OnlyIn(value = Dist.CLIENT)
|
||||
public TranslatableComponent format(boolean inverted) {
|
||||
public MutableComponent format(boolean inverted) {
|
||||
return Lang.translateDirect("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""),
|
||||
group.getDisplayName());
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
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.nbt.CompoundTag;
|
||||
|
@ -56,7 +57,7 @@ public class ColorAttribute implements ItemAttribute {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ import java.util.stream.Collectors;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
|
@ -43,7 +43,7 @@ public class EnchantAttribute implements ItemAttribute {
|
|||
public Object[] getTranslationParameters() {
|
||||
String parameter = "";
|
||||
if(enchantment != null)
|
||||
parameter = new TranslatableComponent(enchantment.getDescriptionId()).getString();
|
||||
parameter = Components.translatable(enchantment.getDescriptionId()).getString();
|
||||
return new Object[] { parameter };
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class EnchantAttribute implements ItemAttribute {
|
|||
public void writeNBT(CompoundTag nbt) {
|
||||
if (enchantment == null)
|
||||
return;
|
||||
ResourceLocation id = ForgeRegistries.ENCHANTMENTS.getKey(enchantment);
|
||||
ResourceLocation id = enchantment.getRegistryName();
|
||||
if (id == null)
|
||||
return;
|
||||
nbt.putString("id", id.toString());
|
||||
|
|
|
@ -7,9 +7,9 @@ import java.util.stream.Collectors;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
@ -46,7 +46,7 @@ public class FluidContentsAttribute implements ItemAttribute {
|
|||
public Object[] getTranslationParameters() {
|
||||
String parameter = "";
|
||||
if (fluid != null)
|
||||
parameter = new TranslatableComponent(fluid.getAttributes().getTranslationKey()).getString();
|
||||
parameter = Components.translatable(fluid.getAttributes().getTranslationKey()).getString();
|
||||
return new Object[] { parameter };
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class FluidContentsAttribute implements ItemAttribute {
|
|||
public void writeNBT(CompoundTag nbt) {
|
||||
if (fluid == null)
|
||||
return;
|
||||
ResourceLocation id = ForgeRegistries.FLUIDS.getKey(fluid);
|
||||
ResourceLocation id = fluid.getRegistryName();
|
||||
if (id == null)
|
||||
return;
|
||||
nbt.putString("id", id.toString());
|
||||
|
|
|
@ -4,11 +4,11 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
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.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
|
@ -56,7 +56,7 @@ public class AstralSorceryAmuletAttribute implements ItemAttribute {
|
|||
|
||||
Enchantment enchant = ForgeRegistries.ENCHANTMENTS.getValue(ResourceLocation.tryParse(enchName));
|
||||
if(enchant != null) {
|
||||
something = new TranslatableComponent(enchant.getDescriptionId()).getString();
|
||||
something = Components.translatable(enchant.getDescriptionId()).getString();
|
||||
}
|
||||
|
||||
if(enchType == 1) something = "existing " + something;
|
||||
|
|
|
@ -4,9 +4,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.content.logistics.item.filter.ItemAttribute;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class AstralSorceryAttunementAttribute implements ItemAttribute {
|
|||
|
||||
// Special handling for shifting stars
|
||||
ResourceLocation itemResource = itemStack.getItem().getRegistryName();
|
||||
if(itemResource != null && itemResource.toString().contains("shifting_star_")) {
|
||||
if (itemResource != null && itemResource.toString().contains("shifting_star_")) {
|
||||
constellation = itemResource.toString().replace("shifting_star_", "");
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class AstralSorceryAttunementAttribute implements ItemAttribute {
|
|||
|
||||
// Special handling for shifting stars
|
||||
ResourceLocation itemResource = itemStack.getItem().getRegistryName();
|
||||
if(itemResource != null && itemResource.toString().contains("shifting_star_")) {
|
||||
if (itemResource != null && itemResource.toString().contains("shifting_star_")) {
|
||||
constellation = itemResource.toString().replace("shifting_star_", "");
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class AstralSorceryAttunementAttribute implements ItemAttribute {
|
|||
@Override
|
||||
public Object[] getTranslationParameters() {
|
||||
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 };
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
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.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class AstralSorceryCrystalAttribute implements ItemAttribute {
|
|||
@Override
|
||||
public Object[] getTranslationParameters() {
|
||||
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 };
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
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.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class AstralSorceryPerkGemAttribute implements ItemAttribute {
|
|||
@Override
|
||||
public Object[] getTranslationParameters() {
|
||||
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 };
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
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.CarriageBogey;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -63,7 +64,7 @@ public interface IBogeyBlock extends IWrenchable {
|
|||
@Override
|
||||
default BlockState getRotatedBlockState(BlockState state, Direction targetedFace) {
|
||||
Block block = state.getBlock();
|
||||
int indexOf = BOGEYS.indexOf(block.getRegistryName());
|
||||
int indexOf = BOGEYS.indexOf(RegisteredObjects.getKeyOrThrow(block));
|
||||
if (indexOf == -1)
|
||||
return state;
|
||||
|
||||
|
|
|
@ -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.Couple;
|
||||
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.animation.LerpedFloat;
|
||||
|
||||
|
@ -146,7 +147,7 @@ public class CarriageBogey {
|
|||
|
||||
public CompoundTag write(DimensionPalette dimensions) {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.putString("Type", ((Block) type).getRegistryName()
|
||||
tag.putString("Type", RegisteredObjects.getKeyOrThrow((Block) type)
|
||||
.toString());
|
||||
tag.put("Points", points.serializeEach(tp -> tp.write(dimensions)));
|
||||
return tag;
|
||||
|
|
|
@ -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.networking.AllPackets;
|
||||
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.Lang;
|
||||
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.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.KeybindComponent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
|
@ -592,7 +591,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
|
|||
GlobalStation currentStation = carriage.train.getCurrentStation();
|
||||
if (currentStation != null && spaceDown) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -604,7 +603,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
|
|||
if (currentStation != null && targetSpeed != 0) {
|
||||
stationMessage = false;
|
||||
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) {
|
||||
|
@ -617,8 +616,8 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
|
|||
double f = (nav.distanceToDestination / navDistanceTotal);
|
||||
int progress = (int) (Mth.clamp(1 - ((1 - f) * (1 - f)), 0, 1) * 30);
|
||||
boolean arrived = progress == 0;
|
||||
TextComponent whiteComponent = new TextComponent(Strings.repeat("|", progress));
|
||||
TextComponent greenComponent = new TextComponent(Strings.repeat("|", 30 - progress));
|
||||
MutableComponent whiteComponent = Components.literal(Strings.repeat("|", progress));
|
||||
MutableComponent greenComponent = Components.literal(Strings.repeat("|", 30 - progress));
|
||||
|
||||
int fromColor = 0x00_FFC244;
|
||||
int toColor = 0x00_529915;
|
||||
|
@ -684,14 +683,14 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
|
|||
|
||||
private void displayApproachStationMessage(Player player, GlobalStation 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;
|
||||
}
|
||||
|
||||
private void cleanUpApproachStationMessage(Player player) {
|
||||
if (!stationMessage)
|
||||
return;
|
||||
player.displayClientMessage(new TextComponent(""), true);
|
||||
player.displayClientMessage(Components.immutableEmpty(), true);
|
||||
stationMessage = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.simibubi.create.content.logistics.trains.IBogeyBlock;
|
|||
import com.simibubi.create.foundation.networking.SimplePacketBase;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -84,7 +85,7 @@ public class TrainPacket extends SimplePacketBase {
|
|||
continue;
|
||||
}
|
||||
CarriageBogey bogey = carriage.bogeys.get(first);
|
||||
buffer.writeResourceLocation(((Block) bogey.type).getRegistryName());
|
||||
buffer.writeResourceLocation(RegisteredObjects.getKeyOrThrow((Block) bogey.type));
|
||||
}
|
||||
buffer.writeVarInt(carriage.bogeySpacing);
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ package com.simibubi.create.content.logistics.trains.entity;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -130,7 +130,7 @@ public class TrainStatus {
|
|||
}
|
||||
|
||||
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)
|
||||
.withStyle(st -> st.withColor(itsAGoodThing ? 0xD5ECC2 : 0xFFD3B4))));
|
||||
if (queued.size() > 3)
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.google.gson.JsonElement;
|
|||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
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.DynamicComponent;
|
||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
|
@ -18,7 +19,6 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -145,7 +145,7 @@ public class FlapDisplayTileEntity extends KineticTileEntity {
|
|||
FlapDisplaySection flapDisplaySection = sections.get(0);
|
||||
if (rawComponentText == null) {
|
||||
manualLines[lineIndex] = false;
|
||||
flapDisplaySection.setText(new TextComponent(""));
|
||||
flapDisplaySection.setText(Components.immutableEmpty());
|
||||
notifyUpdate();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simibubi.create.AllTileEntities;
|
|||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
|
@ -19,7 +20,6 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.saveddata.maps.MapDecoration;
|
||||
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
|
||||
|
@ -40,7 +40,7 @@ public class StationMarker {
|
|||
BlockPos source = NbtUtils.readBlockPos(tag.getCompound("source"));
|
||||
BlockPos target = NbtUtils.readBlockPos(tag.getCompound("target"));
|
||||
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);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class StationMarker {
|
|||
String name = stationOption.get()
|
||||
.getStation().name;
|
||||
return new StationMarker(pos, TileEntityBehaviour.get(stationOption.get(), TrackTargetingBehaviour.TYPE)
|
||||
.getPositionForMapMarker(), new TextComponent(name));
|
||||
.getPositionForMapMarker(), Components.literal(name));
|
||||
}
|
||||
|
||||
public CompoundTag save() {
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.simibubi.create.foundation.gui.AllIcons;
|
|||
import com.simibubi.create.foundation.gui.UIRenderHelper;
|
||||
import com.simibubi.create.foundation.gui.widget.IconButton;
|
||||
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.animation.LerpedFloat;
|
||||
|
||||
|
@ -23,7 +24,6 @@ import net.minecraft.ChatFormatting;
|
|||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class StationScreen extends AbstractStationScreen {
|
||||
|
@ -58,7 +58,7 @@ public class StationScreen extends AbstractStationScreen {
|
|||
|
||||
onTextChanged = s -> nameBox.x = nameBoxX(s, nameBox);
|
||||
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.setMaxLength(25);
|
||||
nameBox.setTextColor(0x442000);
|
||||
|
@ -92,7 +92,7 @@ public class StationScreen extends AbstractStationScreen {
|
|||
addRenderableWidget(dropScheduleButton);
|
||||
|
||||
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.setMaxLength(35);
|
||||
trainNameBox.setTextColor(0xC6C6C6);
|
||||
|
|
|
@ -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.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.networking.SimplePacketBase;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -52,7 +52,7 @@ public class TrainEditPacket extends SimplePacketBase {
|
|||
if (train == null)
|
||||
return;
|
||||
if (!name.isBlank())
|
||||
train.name = new TextComponent(name);
|
||||
train.name = Components.literal(name);
|
||||
train.icon = TrainIconType.byId(iconType);
|
||||
if (sender != null)
|
||||
AllPackets.channel.send(PacketDistributor.ALL.noArg(), new TrainEditReturnPacket(id, name, iconType));
|
||||
|
|
|
@ -7,11 +7,11 @@ import javax.annotation.Nullable;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Pair;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -32,7 +32,7 @@ public interface IScheduleInput {
|
|||
public default List<Component> getTitleAs(String type) {
|
||||
ResourceLocation id = getId();
|
||||
return ImmutableList
|
||||
.of(new TranslatableComponent(id.getNamespace() + ".schedule." + type + "." + id.getPath()));
|
||||
.of(Components.translatable(id.getNamespace() + ".schedule." + type + "." + id.getPath()));
|
||||
}
|
||||
|
||||
public default ItemStack getSecondLineIcon() {
|
||||
|
|
|
@ -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.DestinationInstruction;
|
||||
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.Pair;
|
||||
|
||||
|
@ -26,7 +27,6 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class Schedule {
|
||||
|
@ -64,7 +64,7 @@ public class Schedule {
|
|||
return list.stream()
|
||||
.map(Pair::getFirst)
|
||||
.map(rl -> rl.getNamespace() + ".schedule." + langSection + rl.getPath())
|
||||
.map(TranslatableComponent::new)
|
||||
.map(Components::translatable)
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
|
|
@ -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.management.schedule.destination.DestinationInstruction;
|
||||
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.Lang;
|
||||
|
||||
|
@ -18,7 +19,6 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
@ -133,8 +133,8 @@ public class ScheduleItem extends Item implements MenuProvider {
|
|||
if (schedule == null || schedule.entries.isEmpty())
|
||||
return;
|
||||
|
||||
MutableComponent caret = new TextComponent("> ").withStyle(ChatFormatting.GRAY);
|
||||
MutableComponent arrow = new TextComponent("-> ").withStyle(ChatFormatting.GRAY);
|
||||
MutableComponent caret = Components.literal("> ").withStyle(ChatFormatting.GRAY);
|
||||
MutableComponent arrow = Components.literal("-> ").withStyle(ChatFormatting.GRAY);
|
||||
|
||||
List<ScheduleEntry> entries = schedule.entries;
|
||||
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;
|
||||
MutableComponent prefix = current ? arrow : caret;
|
||||
tooltip.add(prefix.copy()
|
||||
.append(new TextComponent(destination.getFilter()).withStyle(format)));
|
||||
.append(Components.literal(destination.getFilter()).withStyle(format)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.DestinationInstruction;
|
||||
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 net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -371,7 +371,7 @@ public class ScheduleRuntime {
|
|||
int size = schedule.entries.size();
|
||||
if (index >= size) {
|
||||
if (!schedule.cyclic)
|
||||
return new TrainDeparturePrediction(train, time, new TextComponent(" "), destination);
|
||||
return new TrainDeparturePrediction(train, time, Components.literal(" "), destination);
|
||||
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() {
|
||||
|
@ -448,12 +448,12 @@ public class ScheduleRuntime {
|
|||
public MutableComponent getWaitingStatus(Level level) {
|
||||
List<List<ScheduleWaitCondition>> conditions = schedule.entries.get(currentEntry).conditions;
|
||||
if (conditions.isEmpty() || conditionProgress.isEmpty() || conditionContext.isEmpty())
|
||||
return TextComponent.EMPTY.copy();
|
||||
return Components.empty();
|
||||
|
||||
List<ScheduleWaitCondition> list = conditions.get(0);
|
||||
int progress = conditionProgress.get(0);
|
||||
if (progress >= list.size())
|
||||
return TextComponent.EMPTY.copy();
|
||||
return Components.empty();
|
||||
|
||||
CompoundTag tag = conditionContext.get(0);
|
||||
ScheduleWaitCondition condition = list.get(progress);
|
||||
|
|
|
@ -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.SelectionScrollInput;
|
||||
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.Lang;
|
||||
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.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
@ -116,7 +116,7 @@ public class ScheduleScreen extends AbstractSimiContainerScreen<ScheduleContaine
|
|||
confirmButton.withCallback(() -> minecraft.player.closeContainer());
|
||||
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;
|
||||
addRenderableWidget(cyclicIndicator);
|
||||
|
||||
|
@ -171,7 +171,7 @@ public class ScheduleScreen extends AbstractSimiContainerScreen<ScheduleContaine
|
|||
resetProgress.visible = false;
|
||||
|
||||
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);
|
||||
if (allowDeletion)
|
||||
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)
|
||||
return false;
|
||||
|
||||
Component empty = new TextComponent("");
|
||||
Component empty = Components.immutableEmpty();
|
||||
|
||||
int mx = (int) mouseX;
|
||||
int my = (int) mouseY;
|
||||
|
|
|
@ -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.Train;
|
||||
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.Pair;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -81,7 +81,7 @@ public abstract class CargoThresholdCondition extends LazyTickedScheduleConditio
|
|||
|
||||
@Override
|
||||
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
|
||||
|
@ -119,7 +119,7 @@ public abstract class CargoThresholdCondition extends LazyTickedScheduleConditio
|
|||
builder.addSelectionScrollInput(0, 24, (i, l) -> {
|
||||
i.forOptions(Ops.translatedOptions())
|
||||
.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");
|
||||
builder.addIntegerTextInput(29, 41, (e, t) -> {
|
||||
}, "Threshold");
|
||||
|
|
|
@ -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.Train;
|
||||
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -16,7 +17,6 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -31,7 +31,7 @@ public class FluidThresholdCondition extends CargoThresholdCondition {
|
|||
|
||||
@Override
|
||||
protected Component getUnit() {
|
||||
return new TextComponent("b");
|
||||
return Components.literal("b");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,7 +135,7 @@ public class FluidThresholdCondition extends CargoThresholdCondition {
|
|||
public MutableComponent getWaitingStatus(Level level, Train train, CompoundTag tag) {
|
||||
int lastDisplaySnapshot = getLastDisplaySnapshot(tag);
|
||||
if (lastDisplaySnapshot == -1)
|
||||
return TextComponent.EMPTY.copy();
|
||||
return Components.empty();
|
||||
int offset = getOperator() == Ops.LESS ? -1 : getOperator() == Ops.GREATER ? 1 : 0;
|
||||
return Lang.translateDirect("schedule.condition.threshold.status", lastDisplaySnapshot,
|
||||
Math.max(0, getThreshold() + offset), Lang.translateDirect("schedule.condition.threshold.buckets"));
|
||||
|
|
|
@ -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.Train;
|
||||
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -27,7 +27,7 @@ public class ItemThresholdCondition extends CargoThresholdCondition {
|
|||
|
||||
@Override
|
||||
protected Component getUnit() {
|
||||
return new TextComponent(inStacks() ? "\u25A4" : "");
|
||||
return Components.literal(inStacks() ? "\u25A4" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -126,7 +126,7 @@ public class ItemThresholdCondition extends CargoThresholdCondition {
|
|||
public MutableComponent getWaitingStatus(Level level, Train train, CompoundTag tag) {
|
||||
int lastDisplaySnapshot = getLastDisplaySnapshot(tag);
|
||||
if (lastDisplaySnapshot == -1)
|
||||
return TextComponent.EMPTY.copy();
|
||||
return Components.empty();
|
||||
int offset = getOperator() == Ops.LESS ? -1 : getOperator() == Ops.GREATER ? 1 : 0;
|
||||
return Lang.translateDirect("schedule.condition.threshold.status", lastDisplaySnapshot,
|
||||
Math.max(0, getThreshold() + offset),
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue