From 80f962115a31b8d9be6d385d0dccb16f45418355 Mon Sep 17 00:00:00 2001 From: MrTJP Date: Mon, 11 Dec 2023 00:46:42 -0500 Subject: [PATCH] feat: port to MC 1.19.2 --- api/build.gradle | 2 +- build.gradle | 1 + core/build.gradle | 2 +- .../mrtjp/projectred/core/ProjectRedCore.java | 25 +-- .../client/FullyOrientableBlockRenderer.java | 14 +- .../projectred/core/client/HaloRenderer.java | 2 +- .../data/CoreBlockStateModelProvider.java | 3 +- .../core/data/CoreRecipeProvider.java | 8 +- .../container/BasePoweredTileContainer.java | 2 +- .../core/item/CraftingDamageItem.java | 4 +- .../core/tile/ElectrotineGeneratorTile.java | 7 +- .../java/mrtjp/projectred/lib/GuiLib.java | 5 +- .../java/mrtjp/projectred/lib/ModelLib.java | 5 +- .../mrtjp/projectred/redui/DebugRectNode.java | 4 +- core/src/main/resources/META-INF/mods.toml | 2 +- expansion/build.gradle | 2 +- .../projectred/expansion/CraftingHelper.java | 5 + .../projectred/expansion/MovementManager.java | 39 ++-- .../expansion/ProjectRedExpansion.java | 23 +-- .../expansion/block/BatteryBoxBlock.java | 3 +- .../expansion/block/FrameBlock.java | 6 +- .../expansion/block/FrameMotorBlock.java | 6 +- .../expansion/client/FrameBlockRenderer.java | 18 +- .../client/FrameMotorBlockRenderer.java | 6 +- .../expansion/client/FramePartRenderer.java | 4 +- .../client/MovingBlockSuppressorRenderer.java | 19 +- .../ExpansionBlockStateModelProvider.java | 13 +- .../expansion/init/ExpansionClientInit.java | 5 +- .../expansion/item/RecipePlanItem.java | 3 +- .../expansion/tile/BaseMachineTile.java | 3 +- .../expansion/tile/BatteryBoxTile.java | 6 +- .../expansion/tile/ChargingBenchTile.java | 6 +- .../expansion/tile/ProjectBenchTile.java | 6 +- .../src/main/resources/META-INF/mods.toml | 2 +- exploration/build.gradle | 2 +- .../exploration/ProjectRedExploration.java | 44 ++-- .../block/ElectrotineOreBlock.java | 13 +- .../data/ExplorationItemModelProvider.java | 3 +- .../data/ExplorationRecipeProvider.java | 7 +- .../exploration/init/ExplorationBlocks.java | 43 ++-- .../init/ExplorationWorldFeatures.java | 189 +++++++++--------- .../exploration/item/BackpackItem.java | 6 +- .../item/DamageableCraftingContainerItem.java | 4 +- .../world/gen/MarbleCaveWorldCarver.java | 11 +- .../src/main/resources/META-INF/mods.toml | 2 +- fabrication/build.gradle | 2 +- .../fabrication/ProjectRedFabrication.java | 19 +- .../FabricationBlockStateModelProvider.java | 5 +- .../fabrication/engine/BaseTile.java | 3 +- .../fabrication/engine/gates/IOGateTile.java | 15 +- .../engine/gates/RepeaterGateTile.java | 5 +- .../engine/gates/SimpleGateTile.java | 3 +- .../engine/log/DeadGateWarning.java | 5 +- .../engine/log/DeadWireWarning.java | 5 +- .../engine/log/IODirectionMismatchError.java | 5 +- .../engine/log/MultipleDriversError.java | 10 +- .../fabrication/engine/log/NoInputsError.java | 5 +- .../engine/log/NoOutputsError.java | 5 +- .../fabrication/gui/CTNListNode.java | 11 +- .../fabrication/gui/EraserToolTab.java | 3 +- .../fabrication/gui/GatePlacerToolTab.java | 5 +- .../fabrication/gui/ICEditorToolTab.java | 6 +- .../fabrication/gui/InteractToolTab.java | 3 +- .../fabrication/gui/SimpleUVTab.java | 3 +- .../fabrication/gui/WirePlacerToolTab.java | 5 +- .../gui/screen/ICWorkbenchCompileTab.java | 48 +++-- .../gui/screen/ICWorkbenchInfoTab.java | 35 ++-- .../gui/screen/ICWorkbenchScreen.java | 15 +- .../init/FabricationClientInit.java | 3 +- .../FabricationMachineContainer.java | 2 +- .../item/BaseSiliconWaferItem.java | 5 +- .../item/EtchedSiliconWaferItem.java | 17 +- .../fabrication/item/ICBlueprintItem.java | 42 ++-- .../lithography/YieldCalculator.java | 12 +- .../tile/LithographyTableTile.java | 5 +- .../fabrication/tile/PackagingTableTile.java | 4 +- .../fabrication/tile/PlottingTableTile.java | 3 +- .../src/main/resources/META-INF/mods.toml | 2 +- gradle.properties | 13 +- illumination/build.gradle | 2 +- .../MultipartLightProperties.java | 4 +- .../illumination/ProjectRedIllumination.java | 19 +- .../illumination/block/IllumarLampBlock.java | 3 +- .../client/IllumarLampItemRenderer.java | 8 +- .../client/MultipartLightPartRenderer.java | 4 +- .../init/IlluminationClientInit.java | 7 +- .../init/IlluminationMicroMaterials.java | 20 +- .../part/IllumarLampMicroMaterial.java | 2 +- .../src/main/resources/META-INF/mods.toml | 2 +- integration/build.gradle | 2 +- .../integration/ProjectRedIntegration.java | 13 +- .../client/GateComponentModels.java | 3 +- .../integration/client/GateModelRenderer.java | 10 +- .../client/GatePartItemRenderer.java | 5 +- .../integration/client/GatePartRenderer.java | 4 +- .../integration/gui/screen/CounterScreen.java | 4 +- .../integration/gui/screen/TimerScreen.java | 4 +- .../integration/part/RedstoneGatePart.java | 3 +- .../src/main/resources/META-INF/mods.toml | 2 +- transmission/build.gradle | 2 +- .../transmission/ProjectRedTransmission.java | 14 +- .../client/CenterWirePartRenderer.java | 4 +- .../client/FaceWirePartRenderer.java | 4 +- .../client/FramedWirePartItemRenderer.java | 4 +- .../client/WirePartItemRenderer.java | 4 +- .../data/TransmissionRecipeProvider.java | 13 +- .../transmission/part/BaseCenterWirePart.java | 8 +- .../src/main/resources/META-INF/mods.toml | 2 +- 108 files changed, 535 insertions(+), 555 deletions(-) diff --git a/api/build.gradle b/api/build.gradle index 4a067626d..977fa524a 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -3,7 +3,7 @@ plugins { } minecraft { - mappings channel: mcp_mappings, version: mc_version + mappings channel: mcp_mappings, version: mcp_mappings_version // accessTransformer = file("../core/src/main/resources/META-INF/accesstransformer.cfg") } diff --git a/build.gradle b/build.gradle index b4f3eab2d..2c2e0bbf1 100644 --- a/build.gradle +++ b/build.gradle @@ -43,6 +43,7 @@ subprojects { p -> mavenLocal() maven { url = "https://proxy-maven.covers1624.net/" } maven { url = "https://squiddev.cc/maven/" } + maven { url = "https://maven.blamejared.com/" } } // Replace version tokens in mods.toml diff --git a/core/build.gradle b/core/build.gradle index 98675d448..da7e2460a 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -9,7 +9,7 @@ String mod_id = 'projectred_core' sourceSets.main.java.srcDirs += ['../api/src/main/java'] minecraft { - mappings channel: mcp_mappings, version: mc_version + mappings channel: mcp_mappings, version: mcp_mappings_version accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg") runs { data { diff --git a/core/src/main/java/mrtjp/projectred/core/ProjectRedCore.java b/core/src/main/java/mrtjp/projectred/core/ProjectRedCore.java index 9d7199dcf..cc2164973 100644 --- a/core/src/main/java/mrtjp/projectred/core/ProjectRedCore.java +++ b/core/src/main/java/mrtjp/projectred/core/ProjectRedCore.java @@ -14,13 +14,13 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.OptionalMod; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; @@ -36,8 +36,8 @@ public class ProjectRedCore { public static final Logger LOGGER = LogManager.getLogger(MOD_ID); public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID); - public static final DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, MOD_ID); - public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.CONTAINERS, MOD_ID); + public static final DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MOD_ID); + public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, MOD_ID); public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); public static final DeferredRegister> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, MOD_ID); public static final DeferredRegister> PART_TYPES = DeferredRegister.create(MultipartType.MULTIPART_TYPES, MOD_ID); @@ -85,16 +85,13 @@ private void onGatherDataEvent(final GatherDataEvent event) { DataGenerator generator = event.getGenerator(); ExistingFileHelper fileHelper = event.getExistingFileHelper(); - if (event.includeClient()) { - generator.addProvider(new CoreBlockStateModelProvider(generator, fileHelper)); - generator.addProvider(new CoreItemModelProvider(generator, fileHelper)); - generator.addProvider(new CoreLanguageProvider(generator)); - } - if (event.includeServer()) { - generator.addProvider(new CoreRecipeProvider(generator)); - generator.addProvider(new CoreLootTableProvider(generator)); - generator.addProvider(new CoreItemTagsProvider(generator, fileHelper)); - generator.addProvider(new CoreBlockTagsProvider(generator, fileHelper)); - } + generator.addProvider(event.includeClient(), new CoreBlockStateModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new CoreItemModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new CoreLanguageProvider(generator)); + + generator.addProvider(event.includeServer(), new CoreRecipeProvider(generator)); + generator.addProvider(event.includeServer(), new CoreLootTableProvider(generator)); + generator.addProvider(event.includeServer(), new CoreItemTagsProvider(generator, fileHelper)); + generator.addProvider(event.includeServer(), new CoreBlockTagsProvider(generator, fileHelper)); } } diff --git a/core/src/main/java/mrtjp/projectred/core/client/FullyOrientableBlockRenderer.java b/core/src/main/java/mrtjp/projectred/core/client/FullyOrientableBlockRenderer.java index 180c19542..2bf128157 100644 --- a/core/src/main/java/mrtjp/projectred/core/client/FullyOrientableBlockRenderer.java +++ b/core/src/main/java/mrtjp/projectred/core/client/FullyOrientableBlockRenderer.java @@ -1,10 +1,12 @@ package mrtjp.projectred.core.client; +import codechicken.lib.model.PerspectiveModelState; import codechicken.lib.render.CCModel; import codechicken.lib.render.CCRenderState; import codechicken.lib.render.block.ICCBlockRenderer; import codechicken.lib.render.buffer.TransformingVertexConsumer; import codechicken.lib.render.item.IItemRenderer; +import codechicken.lib.util.TransformUtils; import codechicken.lib.vec.Cuboid6; import codechicken.lib.vec.Rotation; import codechicken.lib.vec.Vector3; @@ -17,15 +19,14 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.MinecraftForgeClient; -import net.minecraftforge.client.model.data.IModelData; +import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.client.model.generators.ConfiguredModel; import javax.annotation.Nullable; -import java.util.Random; /** * Needs to exist because Vanilla's default {@link ConfiguredModel} only supports a single x rotation and y rotation, @@ -62,14 +63,13 @@ private static int modelKey(int side, int rot) { //endregion @Override - public boolean renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, Random random, IModelData data) { + public void renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, RandomSource random, ModelData data, @Nullable RenderType renderType) { CCRenderState ccrs = CCRenderState.instance(); ccrs.reset(); ccrs.bind(new TransformingVertexConsumer(builder, mStack), DefaultVertexFormat.BLOCK); ccrs.lightMatrix.locate(world, pos); - render(ccrs, MinecraftForgeClient.getRenderType(), getBlockRenderData(state, pos, world)); - return true; + render(ccrs, renderType, getBlockRenderData(state, pos, world)); } @Override @@ -104,6 +104,6 @@ public record RenderData(int side, int rotation, MultiIconTransformation iconT) // @Override public boolean useAmbientOcclusion() { return true; } // @Override public boolean isGui3d() { return true; } // @Override public boolean usesBlockLight() { return true; } -// @Override public ModelState getModelTransform() { return TransformUtils.DEFAULT_BLOCK; } +// @Override public @Nullable PerspectiveModelState getModelState() { return TransformUtils.DEFAULT_BLOCK; } // //@formatter:on } diff --git a/core/src/main/java/mrtjp/projectred/core/client/HaloRenderer.java b/core/src/main/java/mrtjp/projectred/core/client/HaloRenderer.java index c23f562c7..3b035d065 100644 --- a/core/src/main/java/mrtjp/projectred/core/client/HaloRenderer.java +++ b/core/src/main/java/mrtjp/projectred/core/client/HaloRenderer.java @@ -250,7 +250,7 @@ private static void unloadPostChain() { } private static boolean isFabulous() { - return Configurator.fabulousLights && Minecraft.getInstance().options.graphicsMode.getId() >= GraphicsStatus.FABULOUS.getId(); + return Configurator.fabulousLights && Minecraft.getInstance().options.graphicsMode().get().getId() >= GraphicsStatus.FABULOUS.getId(); } //endregion diff --git a/core/src/main/java/mrtjp/projectred/core/data/CoreBlockStateModelProvider.java b/core/src/main/java/mrtjp/projectred/core/data/CoreBlockStateModelProvider.java index b3ed8dc41..4cd6cf772 100644 --- a/core/src/main/java/mrtjp/projectred/core/data/CoreBlockStateModelProvider.java +++ b/core/src/main/java/mrtjp/projectred/core/data/CoreBlockStateModelProvider.java @@ -8,6 +8,7 @@ import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nonnull; @@ -59,7 +60,7 @@ private void addRotatablePoweredMachineVariants(Block block, ModelFile idleModel } private BlockModelBuilder createFrontFacedPoweredMachineModel(Block block, int state) { - String texture = block.getRegistryName().getPath(); + String texture = ForgeRegistries.BLOCKS.getKey(block).getPath(); String modelName = texture + (state > 0 ? "_state" + state : ""); return models().orientableWithBottom(modelName, diff --git a/core/src/main/java/mrtjp/projectred/core/data/CoreRecipeProvider.java b/core/src/main/java/mrtjp/projectred/core/data/CoreRecipeProvider.java index abfce0559..bc808f515 100644 --- a/core/src/main/java/mrtjp/projectred/core/data/CoreRecipeProvider.java +++ b/core/src/main/java/mrtjp/projectred/core/data/CoreRecipeProvider.java @@ -11,7 +11,9 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Blocks; -import net.minecraftforge.common.crafting.NBTIngredient; +import net.minecraftforge.common.crafting.StrictNBTIngredient; + +import java.util.Objects; import static mrtjp.projectred.core.init.CoreBlocks.ELECTROTINE_GENERATOR_BLOCK; import static mrtjp.projectred.core.init.CoreItems.*; @@ -199,8 +201,8 @@ protected void registerRecipes() { } shapedRecipe(DRAW_PLATE_ITEM.get()) - .key('I', NBTIngredient.of(ItemMicroBlock.create(3, 2, MicroMaterialRegistry.getMaterial(BlockMicroMaterial.makeMaterialKey(Blocks.IRON_BLOCK.defaultBlockState()))))) - .key('D', NBTIngredient.of(ItemMicroBlock.create(0, 2, MicroMaterialRegistry.getMaterial(BlockMicroMaterial.makeMaterialKey(Blocks.DIAMOND_BLOCK.defaultBlockState()))))) + .key('I', StrictNBTIngredient.of(ItemMicroBlock.create(3, 2, Objects.requireNonNull(MicroMaterialRegistry.getMaterial(BlockMicroMaterial.makeMaterialKey(Blocks.IRON_BLOCK.defaultBlockState())))))) + .key('D', StrictNBTIngredient.of(ItemMicroBlock.create(0, 2, Objects.requireNonNull(MicroMaterialRegistry.getMaterial(BlockMicroMaterial.makeMaterialKey(Blocks.DIAMOND_BLOCK.defaultBlockState())))))) .patternLine(" I ") .patternLine("IDI") .patternLine(" I "); diff --git a/core/src/main/java/mrtjp/projectred/core/inventory/container/BasePoweredTileContainer.java b/core/src/main/java/mrtjp/projectred/core/inventory/container/BasePoweredTileContainer.java index 667074b72..3679cabd1 100644 --- a/core/src/main/java/mrtjp/projectred/core/inventory/container/BasePoweredTileContainer.java +++ b/core/src/main/java/mrtjp/projectred/core/inventory/container/BasePoweredTileContainer.java @@ -7,7 +7,7 @@ import javax.annotation.Nullable; -public class BasePoweredTileContainer extends AbstractContainerMenu { +public abstract class BasePoweredTileContainer extends AbstractContainerMenu { private final BasePoweredTile tile; diff --git a/core/src/main/java/mrtjp/projectred/core/item/CraftingDamageItem.java b/core/src/main/java/mrtjp/projectred/core/item/CraftingDamageItem.java index 307f0bbc1..d444a9aae 100644 --- a/core/src/main/java/mrtjp/projectred/core/item/CraftingDamageItem.java +++ b/core/src/main/java/mrtjp/projectred/core/item/CraftingDamageItem.java @@ -10,12 +10,12 @@ public CraftingDamageItem(Item.Properties properties) { } @Override - public boolean hasContainerItem(ItemStack stack) { + public boolean hasCraftingRemainingItem(ItemStack stack) { return true; } @Override - public ItemStack getContainerItem(ItemStack itemStack) { + public ItemStack getCraftingRemainingItem(ItemStack itemStack) { if (canBeDepleted()) { ItemStack ret = itemStack.copy(); ret.setDamageValue(ret.getDamageValue() + 1); diff --git a/core/src/main/java/mrtjp/projectred/core/tile/ElectrotineGeneratorTile.java b/core/src/main/java/mrtjp/projectred/core/tile/ElectrotineGeneratorTile.java index 6ca9735c3..8e9f49606 100644 --- a/core/src/main/java/mrtjp/projectred/core/tile/ElectrotineGeneratorTile.java +++ b/core/src/main/java/mrtjp/projectred/core/tile/ElectrotineGeneratorTile.java @@ -12,7 +12,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -23,6 +23,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.InvWrapper; @@ -79,7 +80,7 @@ public InteractionResult onBlockActivated(Player player, InteractionHand hand, B if (!getLevel().isClientSide) { ServerUtils.openContainer((ServerPlayer) player, new SimpleMenuProvider( (id, inv, p) -> new ElectrotineGeneratorContainer(inv, this, id), - new TranslatableComponent(getBlockState().getBlock().getDescriptionId())), + getBlockState().getBlock().getName()), p -> p.writePos(getBlockPos())); } @@ -209,7 +210,7 @@ public boolean canConductorWork() { @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { - if (!this.remove && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (!this.remove && cap == ForgeCapabilities.ITEM_HANDLER) { return handler.cast(); } return super.getCapability(cap, side); diff --git a/core/src/main/java/mrtjp/projectred/lib/GuiLib.java b/core/src/main/java/mrtjp/projectred/lib/GuiLib.java index 9190d23bb..b16b1acad 100644 --- a/core/src/main/java/mrtjp/projectred/lib/GuiLib.java +++ b/core/src/main/java/mrtjp/projectred/lib/GuiLib.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.*; import com.mojang.math.Matrix4f; import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.renderer.GameRenderer; import net.minecraft.resources.ResourceLocation; import static com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS; @@ -41,13 +42,13 @@ public static void drawLine(PoseStack stack, int x1, int y1, int x2, int y2, int RenderSystem.enableBlend(); RenderSystem.disableTexture(); RenderSystem.defaultBlendFunc(); + RenderSystem.setShader(GameRenderer::getPositionColorShader); bufferbuilder.begin(QUADS, DefaultVertexFormat.POSITION_COLOR); bufferbuilder.vertex(p_238460_0_, (float) r1.dx, (float) r1.dy, 0.0F).color(f, f1, f2, f3).endVertex(); bufferbuilder.vertex(p_238460_0_, (float) r2.dx, (float) r2.dy, 0.0F).color(f, f1, f2, f3).endVertex(); bufferbuilder.vertex(p_238460_0_, (float) r3.dx, (float) r3.dy, 0.0F).color(f, f1, f2, f3).endVertex(); bufferbuilder.vertex(p_238460_0_, (float) r4.dx, (float) r4.dy, 0.0F).color(f, f1, f2, f3).endVertex(); - bufferbuilder.end(); - BufferUploader.end(bufferbuilder); + BufferUploader.draw(bufferbuilder.end()); RenderSystem.enableTexture(); RenderSystem.disableBlend(); } diff --git a/core/src/main/java/mrtjp/projectred/lib/ModelLib.java b/core/src/main/java/mrtjp/projectred/lib/ModelLib.java index a716d6a1b..237554dbd 100644 --- a/core/src/main/java/mrtjp/projectred/lib/ModelLib.java +++ b/core/src/main/java/mrtjp/projectred/lib/ModelLib.java @@ -4,7 +4,6 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.ResourceManager; import java.io.*; @@ -51,9 +50,7 @@ public static void exportVertsToJson(String filePath, Map ver } public static Map importVertsFromJson(ResourceManager resourceManager, ResourceLocation resource) { - try ( - Resource res = resourceManager.getResource(resource); - InputStream stream = res.getInputStream()) { + try (InputStream stream = resourceManager.getResource(resource).get().open()) { return importVertsFromJson(new InputStreamReader(stream)); diff --git a/core/src/main/java/mrtjp/projectred/redui/DebugRectNode.java b/core/src/main/java/mrtjp/projectred/redui/DebugRectNode.java index ad37efe69..0e1fa693c 100644 --- a/core/src/main/java/mrtjp/projectred/redui/DebugRectNode.java +++ b/core/src/main/java/mrtjp/projectred/redui/DebugRectNode.java @@ -7,7 +7,7 @@ import mrtjp.projectred.lib.Rect; import mrtjp.projectred.lib.Size; import net.minecraft.client.gui.GuiComponent; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import org.lwjgl.glfw.GLFW; import java.util.Collections; @@ -47,7 +47,7 @@ public void drawFront(PoseStack stack, Point mouse, float partialFrame) { GuiComponent.fill(stack, cursorRect.x(), cursorRect.y(), cursorRect.maxX(), cursorRect.maxY(), EnumColour.WHITE.argb(clickDown ? 150 : 50)); // Tooltip showing name - renderTooltip(stack, mouse, Collections.singletonList(new TextComponent(name))); + renderTooltip(stack, mouse, Collections.singletonList(Component.literal(name))); } @Override diff --git a/core/src/main/resources/META-INF/mods.toml b/core/src/main/resources/META-INF/mods.toml index c5eea412d..1ed248a02 100644 --- a/core/src/main/resources/META-INF/mods.toml +++ b/core/src/main/resources/META-INF/mods.toml @@ -23,7 +23,7 @@ Redstone. The way it was meant to be. [[dependencies.projectred_core]] modId="minecraft" mandatory=true - versionRange="[1.18.2]" + versionRange="[1.19.2]" ordering="NONE" side="BOTH" [[dependencies.projectred_core]] diff --git a/expansion/build.gradle b/expansion/build.gradle index e94a444b1..ea3417192 100644 --- a/expansion/build.gradle +++ b/expansion/build.gradle @@ -7,7 +7,7 @@ plugins { String mod_id = 'projectred_expansion' minecraft { - mappings channel: mcp_mappings, version: mc_version + mappings channel: mcp_mappings, version: mcp_mappings_version accessTransformer = file("../core/src/main/resources/META-INF/accesstransformer.cfg") runs { data { diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/CraftingHelper.java b/expansion/src/main/java/mrtjp/projectred/expansion/CraftingHelper.java index 5a5c3603b..a5d6510d9 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/CraftingHelper.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/CraftingHelper.java @@ -25,6 +25,11 @@ public class CraftingHelper { public boolean stillValid(Player p_75145_1_) { return false; } + + @Override + public ItemStack quickMoveStack(Player pPlayer, int pIndex) { + return ItemStack.EMPTY; + } }, 3, 3); private final ResultContainer craftResultInventory = new ResultContainer(); diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/MovementManager.java b/expansion/src/main/java/mrtjp/projectred/expansion/MovementManager.java index 7957fd6f1..6a514bf6c 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/MovementManager.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/MovementManager.java @@ -22,6 +22,7 @@ import net.minecraft.core.SectionPos; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; @@ -29,14 +30,12 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.ForgeHooksClient; -import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.event.RenderLevelStageEvent; -import net.minecraftforge.client.model.data.EmptyModelData; +import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.event.TickEvent; -import net.minecraftforge.event.world.ChunkEvent; -import net.minecraftforge.event.world.ChunkWatchEvent; -import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.event.level.ChunkEvent; +import net.minecraftforge.event.level.ChunkWatchEvent; +import net.minecraftforge.event.level.LevelEvent; import java.util.*; import java.util.function.Consumer; @@ -78,33 +77,33 @@ private int getNextStructureId() { //region Events public static void onChunkWatchEvent(ChunkWatchEvent.Watch event) { - getInstance(event.getWorld()).addChunkWatcher(event.getPos(), event.getPlayer()); + getInstance(event.getLevel()).addChunkWatcher(event.getPos(), event.getPlayer()); } public static void onChunkUnwatchEvent(ChunkWatchEvent.UnWatch event) { - getInstance(event.getWorld()).removeChunkWatcher(event.getPos(), event.getPlayer()); + getInstance(event.getLevel()).removeChunkWatcher(event.getPos(), event.getPlayer()); } public static void onChunkUnloadEvent(ChunkEvent.Unload event) { - if (event.getWorld() instanceof Level level) { + if (event.getLevel() instanceof Level level) { getInstance(level).cancelMovementsInChunk(level, event.getChunk().getPos()); } } - public static void onLevelUnload(WorldEvent.Unload event) { + public static void onLevelUnload(LevelEvent.Unload event) { // Note: Client unloads levels as player changes dimensions, but // server appears to always have all dims loaded and unloads only // on shutdown - LOGGER.debug("Level {} unloaded", event.getWorld()); + LOGGER.debug("Level {} unloaded", event.getLevel()); } - public static void onLevelLoad(WorldEvent.Load event) { - LOGGER.debug("Level {} loaded", event.getWorld()); + public static void onLevelLoad(LevelEvent.Load event) { + LOGGER.debug("Level {} loaded", event.getLevel()); } - public static void onLevelTick(TickEvent.WorldTickEvent event) { + public static void onLevelTick(TickEvent.LevelTickEvent event) { if (event.phase == TickEvent.Phase.END) { - getInstance(event.world).tick(event.world); + getInstance(event.level).tick(event.level); } } @@ -129,7 +128,7 @@ public static void onRenderLevelStage(RenderLevelStageEvent event) { } if (renderType == null) return; - Random random = new Random(); + RandomSource random = RandomSource.create(); // Set up camera pose Vec3 cam = event.getCamera().getPosition(); @@ -152,20 +151,16 @@ public static void onRenderLevelStage(RenderLevelStageEvent event) { BlockPos p = it.next(); BlockState state = level.getBlockState(p); - if (!ItemBlockRenderTypes.canRenderInLayer(state, renderType)) continue; + if (!ItemBlockRenderTypes.getRenderLayers(state).contains(renderType)) continue; // Render the moving block stack.pushPose(); stack.translate(p.getX(), p.getY(), p.getZ()); - RenderType oldType = MinecraftForgeClient.getRenderType(); - ForgeHooksClient.setRenderType(renderType); - MovingBlockSuppressorRenderer.allowMovingRenderOnRenderThread = true; - Minecraft.getInstance().getBlockRenderer().renderBatched(state, p, level, stack, buffers.getBuffer(renderType), false, random, EmptyModelData.INSTANCE); + Minecraft.getInstance().getBlockRenderer().renderBatched(state, p, level, stack, buffers.getBuffer(renderType), false, random, ModelData.EMPTY, renderType); MovingBlockSuppressorRenderer.allowMovingRenderOnRenderThread = false; - ForgeHooksClient.setRenderType(oldType); stack.popPose(); //p } } diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/ProjectRedExpansion.java b/expansion/src/main/java/mrtjp/projectred/expansion/ProjectRedExpansion.java index 2d57cc4c4..3ee1cd017 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/ProjectRedExpansion.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/ProjectRedExpansion.java @@ -16,12 +16,12 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; @@ -38,8 +38,8 @@ public class ProjectRedExpansion { public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID); public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); - public static final DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, MOD_ID); - public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.CONTAINERS, MOD_ID); + public static final DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MOD_ID); + public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, MOD_ID); public static final DeferredRegister> PART_TYPES = DeferredRegister.create(MultipartType.MULTIPART_TYPES, MOD_ID); public static final DeferredRegister PART_CONVERTERS = DeferredRegister.create(PartConverter.PART_CONVERTERS, MOD_ID); @@ -92,15 +92,12 @@ private void onGatherDataEvent(final GatherDataEvent event) { DataGenerator generator = event.getGenerator(); ExistingFileHelper fileHelper = event.getExistingFileHelper(); - if (event.includeClient()) { - generator.addProvider(new ExpansionBlockStateModelProvider(generator, fileHelper)); - generator.addProvider(new ExpansionItemModelProvider(generator, fileHelper)); - generator.addProvider(new ExpansionLanguageProvider(generator)); - } - if (event.includeServer()) { - generator.addProvider(new ExpansionBlockTagsProvider(generator, fileHelper)); - generator.addProvider(new ExpansionRecipeProvider(generator)); - generator.addProvider(new ExpansionLootTableProvider(generator)); - } + generator.addProvider(event.includeClient(), new ExpansionBlockStateModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new ExpansionItemModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new ExpansionLanguageProvider(generator)); + + generator.addProvider(event.includeServer(), new ExpansionBlockTagsProvider(generator, fileHelper)); + generator.addProvider(event.includeServer(), new ExpansionRecipeProvider(generator)); + generator.addProvider(event.includeServer(), new ExpansionLootTableProvider(generator)); } } diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/block/BatteryBoxBlock.java b/expansion/src/main/java/mrtjp/projectred/expansion/block/BatteryBoxBlock.java index e8e341caa..21b8eac64 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/block/BatteryBoxBlock.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/block/BatteryBoxBlock.java @@ -6,7 +6,6 @@ import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; @@ -83,7 +82,7 @@ public void appendHoverText(ItemStack stack, @Nullable BlockGetter level, List consumer) { - consumer.accept(new IBlockRenderProperties() { + public void initializeClient(Consumer consumer) { + consumer.accept(new IClientBlockExtensions() { @Override public boolean addHitEffects(BlockState state, Level level, HitResult hit, ParticleEngine engine) { if (!(hit instanceof BlockHitResult blockHit)) { diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/block/FrameMotorBlock.java b/expansion/src/main/java/mrtjp/projectred/expansion/block/FrameMotorBlock.java index db623b7b0..718c21f2c 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/block/FrameMotorBlock.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/block/FrameMotorBlock.java @@ -18,7 +18,7 @@ import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; -import net.minecraftforge.client.IBlockRenderProperties; +import net.minecraftforge.client.extensions.common.IClientBlockExtensions; import org.jetbrains.annotations.Nullable; import java.util.Collections; @@ -31,8 +31,8 @@ public FrameMotorBlock() { } @Override - public void initializeClient(Consumer consumer) { - consumer.accept(new IBlockRenderProperties() { + public void initializeClient(Consumer consumer) { + consumer.accept(new IClientBlockExtensions() { @Override public boolean addHitEffects(BlockState state, Level level, HitResult hit, ParticleEngine engine) { if (!(hit instanceof BlockHitResult blockHit)) return false; diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/client/FrameBlockRenderer.java b/expansion/src/main/java/mrtjp/projectred/expansion/client/FrameBlockRenderer.java index c57a9f919..a1fef5e44 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/client/FrameBlockRenderer.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/client/FrameBlockRenderer.java @@ -1,5 +1,6 @@ package mrtjp.projectred.expansion.client; +import codechicken.lib.model.PerspectiveModelState; import codechicken.lib.render.CCRenderState; import codechicken.lib.render.block.ICCBlockRenderer; import codechicken.lib.render.buffer.TransformingVertexConsumer; @@ -11,15 +12,15 @@ import mrtjp.projectred.expansion.init.ExpansionBlocks; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.resources.model.ModelState; import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.model.data.IModelData; - -import java.util.Random; +import net.minecraftforge.client.model.data.ModelData; +import org.jetbrains.annotations.Nullable; public class FrameBlockRenderer implements ICCBlockRenderer, IItemRenderer { @@ -30,12 +31,12 @@ private FrameBlockRenderer() { //region ICCBlockRenderer @Override - public boolean canHandleBlock(BlockAndTintGetter world, BlockPos pos, BlockState blockState) { + public boolean canHandleBlock(BlockAndTintGetter world, BlockPos pos, BlockState blockState, @Nullable RenderType renderType) { return blockState.getBlock() == ExpansionBlocks.FRAME_BLOCK.get(); } @Override - public boolean renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, Random random, IModelData data) { + public void renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, RandomSource random, ModelData data, @Nullable RenderType renderType) { CCRenderState ccrs = CCRenderState.instance(); ccrs.reset(); ccrs.bind(new TransformingVertexConsumer(builder, mStack), DefaultVertexFormat.BLOCK); @@ -43,7 +44,6 @@ public boolean renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter wo ccrs.setBrightness(world, pos); FrameModelRenderer.renderStatic(ccrs, 0); - return true; } //endregion @@ -59,11 +59,13 @@ public void renderItem(ItemStack stack, ItemTransforms.TransformType transformTy FrameModelRenderer.renderStatic(ccrs, 0); } + + //@formatter:off @Override public boolean useAmbientOcclusion() { return true; } @Override public boolean isGui3d() { return true; } @Override public boolean usesBlockLight() { return true; } - @Override public ModelState getModelTransform() { return TransformUtils.DEFAULT_BLOCK; } + @Override public @Nullable PerspectiveModelState getModelState() { return TransformUtils.DEFAULT_BLOCK; } //@formatter:on //endregion } diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/client/FrameMotorBlockRenderer.java b/expansion/src/main/java/mrtjp/projectred/expansion/client/FrameMotorBlockRenderer.java index 7f18111fb..678191430 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/client/FrameMotorBlockRenderer.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/client/FrameMotorBlockRenderer.java @@ -1,5 +1,6 @@ package mrtjp.projectred.expansion.client; +import codechicken.lib.model.PerspectiveModelState; import codechicken.lib.texture.AtlasRegistrar; import codechicken.lib.util.TransformUtils; import codechicken.lib.vec.uv.MultiIconTransformation; @@ -8,7 +9,6 @@ import mrtjp.projectred.expansion.init.ExpansionBlocks; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.ModelState; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -41,7 +41,7 @@ private FrameMotorBlockRenderer() { } @Override - public boolean canHandleBlock(BlockAndTintGetter world, BlockPos pos, BlockState blockState) { + public boolean canHandleBlock(BlockAndTintGetter world, BlockPos pos, BlockState blockState, @Nullable RenderType renderType) { return blockState.getBlock() == ExpansionBlocks.FRAME_MOTOR_BLOCK.get(); } @@ -106,6 +106,6 @@ public static TextureAtlasSprite getParticleIcon(BlockState state, int side) { @Override public boolean useAmbientOcclusion() { return true; } @Override public boolean isGui3d() { return true; } @Override public boolean usesBlockLight() { return true; } - @Override public ModelState getModelTransform() { return TransformUtils.DEFAULT_BLOCK; } + @Override public @Nullable PerspectiveModelState getModelState() { return TransformUtils.DEFAULT_BLOCK; } //@formatter:on } diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/client/FramePartRenderer.java b/expansion/src/main/java/mrtjp/projectred/expansion/client/FramePartRenderer.java index 967879cd1..b40b231eb 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/client/FramePartRenderer.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/client/FramePartRenderer.java @@ -14,12 +14,10 @@ private FramePartRenderer() { } @Override - public boolean renderStatic(FramePart part, @Nullable RenderType type, CCRenderState ccrs) { + public void renderStatic(FramePart part, @Nullable RenderType type, CCRenderState ccrs) { if (type == null || type == RenderType.cutout()) { ccrs.setBrightness(part.level(), part.pos()); FrameModelRenderer.renderStatic(ccrs, part.getOccludedSideMask()); - return true; } - return false; } } diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/client/MovingBlockSuppressorRenderer.java b/expansion/src/main/java/mrtjp/projectred/expansion/client/MovingBlockSuppressorRenderer.java index 6fd17f31b..c040e270c 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/client/MovingBlockSuppressorRenderer.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/client/MovingBlockSuppressorRenderer.java @@ -6,13 +6,14 @@ import com.mojang.blaze3d.vertex.VertexConsumer; import mrtjp.projectred.expansion.MovementManager; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderType; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.model.data.IModelData; - -import java.util.Random; +import net.minecraftforge.client.model.data.ModelData; +import org.jetbrains.annotations.Nullable; /** * A global block renderer that takes care of temporarily suppressing rendering for any blocks that are @@ -30,7 +31,7 @@ private MovingBlockSuppressorRenderer() { } @Override - public boolean canHandleBlock(BlockAndTintGetter world, BlockPos pos, BlockState blockState) { + public boolean canHandleBlock(BlockAndTintGetter world, BlockPos pos, BlockState blockState, @Nullable RenderType renderType) { // Infinite recursion prevention. #renderBlock is attempting a no-cull render. if (isRendering) return false; @@ -52,17 +53,17 @@ public boolean canHandleBlock(BlockAndTintGetter world, BlockPos pos, BlockState } @Override - public boolean renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, Random random, IModelData data) { + public void renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, RandomSource random, ModelData data, @Nullable RenderType renderType) { // Moving blocks don't render here - if (isMoving(pos)) return false; + if (isMoving(pos)) return; // Render adjacent blocks without culling isRendering = true; // Prevents ourselves from re-handling this event - Minecraft.getInstance().getBlockRenderer().renderBatched(state, pos, world, mStack, builder, false, random); + // renderType should be nullable + //noinspection DataFlowIssue + Minecraft.getInstance().getBlockRenderer().renderBatched(state, pos, world, mStack, builder, false, random, data, renderType); isRendering = false; - - return true; } private static boolean isMoving(BlockPos pos) { diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/data/ExpansionBlockStateModelProvider.java b/expansion/src/main/java/mrtjp/projectred/expansion/data/ExpansionBlockStateModelProvider.java index 6cdac2597..8aa8c7205 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/data/ExpansionBlockStateModelProvider.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/data/ExpansionBlockStateModelProvider.java @@ -9,6 +9,7 @@ import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nonnull; @@ -160,7 +161,7 @@ private void addSidedPoweredDeviceVariants(Block block, ModelFile idle, ModelFil } private BlockModelBuilder createOppositeMatchingFaceModel(Block block) { - String texture = block.getRegistryName().getPath(); + String texture = ForgeRegistries.BLOCKS.getKey(block).getPath(); return models().cube(texture, modLoc("block/" + texture + "_bottom"), modLoc("block/" + texture + "_top"), @@ -172,7 +173,7 @@ private BlockModelBuilder createOppositeMatchingFaceModel(Block block) { } private BlockModelBuilder createBatteryModel(Block block, int charge) { - String texture = block.getRegistryName().getPath(); + String texture = ForgeRegistries.BLOCKS.getKey(block).getPath(); String modelName = texture + (charge > 0 ? "_charge" + charge : ""); return models().cubeBottomTop(modelName, modLoc("block/" + texture + "_side_" + charge), @@ -181,7 +182,7 @@ private BlockModelBuilder createBatteryModel(Block block, int charge) { } private BlockModelBuilder createFrontFacedMachineModel(Block block, int state) { - String texture = block.getRegistryName().getPath(); + String texture = ForgeRegistries.BLOCKS.getKey(block).getPath(); String modelName = texture + (state > 0 ? "_state" + state : ""); return models().orientableWithBottom(modelName, modLoc("block/" + texture + "_side"), @@ -191,7 +192,7 @@ private BlockModelBuilder createFrontFacedMachineModel(Block block, int state) { } private BlockModelBuilder createSideAndTopStateModel(Block block, int state) { - String texture = block.getRegistryName().getPath(); + String texture = ForgeRegistries.BLOCKS.getKey(block).getPath(); String modelName = texture + (state > 0 ? "_state" + state : ""); return models().cubeBottomTop(modelName, modLoc("block/" + texture + "_side_" + state), @@ -200,7 +201,7 @@ private BlockModelBuilder createSideAndTopStateModel(Block block, int state) { } private BlockModelBuilder createSideStateModel(Block block, int state) { - String texture = block.getRegistryName().getPath(); + String texture = ForgeRegistries.BLOCKS.getKey(block).getPath(); String modelName = texture + (state > 0 ? "_state" + state : ""); return models().cubeBottomTop(modelName, modLoc("block/" + texture + "_side_" + state), @@ -209,7 +210,7 @@ private BlockModelBuilder createSideStateModel(Block block, int state) { } private BlockModelBuilder createOppositeMatchingFaceDeviceModel(Block block, boolean active) { - String texture = block.getRegistryName().getPath(); + String texture = ForgeRegistries.BLOCKS.getKey(block).getPath(); String activeKey = active ? "_active" : ""; String modelName = texture + activeKey; return models().cube(modelName, diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/init/ExpansionClientInit.java b/expansion/src/main/java/mrtjp/projectred/expansion/init/ExpansionClientInit.java index 85a015c89..a4f9e7cc6 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/init/ExpansionClientInit.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/init/ExpansionClientInit.java @@ -22,6 +22,7 @@ import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.ForgeRegistries; import static mrtjp.projectred.expansion.ProjectRedExpansion.MOD_ID; import static mrtjp.projectred.expansion.init.ExpansionBlocks.*; @@ -69,8 +70,8 @@ private static void clientSetup(final FMLClientSetupEvent event) { BlockRenderingRegistry.registerGlobalRenderer(MovingBlockSuppressorRenderer.INSTANCE); // Register item renderers - MODEL_HELPER.register(new ModelResourceLocation(FRAME_BLOCK.get().getRegistryName(), "inventory"), FrameBlockRenderer.INSTANCE); - MODEL_HELPER.register(new ModelResourceLocation(FRAME_MOTOR_BLOCK.get().getRegistryName(), "inventory"), FrameMotorBlockRenderer.INSTANCE); + MODEL_HELPER.register(new ModelResourceLocation(ForgeRegistries.BLOCKS.getKey(FRAME_BLOCK.get()), "inventory"), FrameBlockRenderer.INSTANCE); + MODEL_HELPER.register(new ModelResourceLocation(ForgeRegistries.BLOCKS.getKey(FRAME_MOTOR_BLOCK.get()), "inventory"), FrameMotorBlockRenderer.INSTANCE); // Register part renderers MultipartClientRegistry.register(FRAME_PART.get(), FramePartRenderer.INSTANCE); diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/item/RecipePlanItem.java b/expansion/src/main/java/mrtjp/projectred/expansion/item/RecipePlanItem.java index 86715f231..d7a588bbf 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/item/RecipePlanItem.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/item/RecipePlanItem.java @@ -4,7 +4,6 @@ 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.Container; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -29,7 +28,7 @@ public void appendHoverText(ItemStack stack, @Nullable Level world, List p.writePos(getBlockPos())); } diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/tile/BatteryBoxTile.java b/expansion/src/main/java/mrtjp/projectred/expansion/tile/BatteryBoxTile.java index 06bdd1576..0440b0889 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/tile/BatteryBoxTile.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/tile/BatteryBoxTile.java @@ -13,7 +13,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TextComponent; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Tuple; import net.minecraft.world.*; @@ -23,6 +22,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.SidedInvWrapper; @@ -79,7 +79,7 @@ public InteractionResult onBlockActivated(Player player, InteractionHand hand, B (ServerPlayer) player, new SimpleMenuProvider( (id, inv, p) -> new BatteryBoxContainer(inv, this, id), - new TextComponent(getBlockState().getBlock().getDescriptionId())), + getBlockState().getBlock().getName()), p -> p.writePos(getBlockPos())); } @@ -216,7 +216,7 @@ private boolean tryDischargeBattery() { @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { - if (!this.remove && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (!this.remove && cap == ForgeCapabilities.ITEM_HANDLER) { return side == Direction.UP ? handlers[0].cast() : handlers[1].cast(); } return super.getCapability(cap, side); diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/tile/ChargingBenchTile.java b/expansion/src/main/java/mrtjp/projectred/expansion/tile/ChargingBenchTile.java index 1c470dc6d..985e6f038 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/tile/ChargingBenchTile.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/tile/ChargingBenchTile.java @@ -13,7 +13,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TextComponent; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Tuple; import net.minecraft.world.*; @@ -22,6 +21,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.SidedInvWrapper; @@ -76,7 +76,7 @@ public InteractionResult onBlockActivated(Player player, InteractionHand hand, B (ServerPlayer) player, new SimpleMenuProvider( (id, inv, p) -> new ChargingBenchContainer(inv, this, id), - new TextComponent(getBlockState().getBlock().getDescriptionId())), + getBlockState().getBlock().getName()), p -> p.writePos(getBlockPos())); } @@ -177,7 +177,7 @@ private boolean tryDropDownItemInSlot(int i) { @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { - if (!this.remove && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (!this.remove && cap == ForgeCapabilities.ITEM_HANDLER) { return side == Direction.UP ? handlers[0].cast() : handlers[1].cast(); } return super.getCapability(cap, side); diff --git a/expansion/src/main/java/mrtjp/projectred/expansion/tile/ProjectBenchTile.java b/expansion/src/main/java/mrtjp/projectred/expansion/tile/ProjectBenchTile.java index cbc4f9964..c5e7d60a4 100644 --- a/expansion/src/main/java/mrtjp/projectred/expansion/tile/ProjectBenchTile.java +++ b/expansion/src/main/java/mrtjp/projectred/expansion/tile/ProjectBenchTile.java @@ -15,7 +15,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TextComponent; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.*; import net.minecraft.world.entity.player.Player; @@ -25,6 +24,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.InvWrapper; @@ -119,7 +119,7 @@ public InteractionResult onBlockActivated(Player player, InteractionHand hand, B (ServerPlayer) player, new SimpleMenuProvider( (id, inv, p) -> new ProjectBenchContainer(inv, this, id), - new TextComponent(getBlockState().getBlock().getDescriptionId())), + getBlockState().getBlock().getName()), p -> p.writePos(getBlockPos())); } @@ -262,7 +262,7 @@ public CraftingHelper getCraftingHelper() { @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { - if (!this.remove && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + if (!this.remove && cap == ForgeCapabilities.ITEM_HANDLER) return storageInventoryCap.cast(); return super.getCapability(cap, side); } diff --git a/expansion/src/main/resources/META-INF/mods.toml b/expansion/src/main/resources/META-INF/mods.toml index 937257e86..52fb7112f 100644 --- a/expansion/src/main/resources/META-INF/mods.toml +++ b/expansion/src/main/resources/META-INF/mods.toml @@ -23,7 +23,7 @@ Redstone. The way it was meant to be. [[dependencies.projectred_expansion]] modId="minecraft" mandatory=true - versionRange="[1.18.2]" + versionRange="[1.19.2]" ordering="NONE" side="BOTH" [[dependencies.projectred_expansion]] diff --git a/exploration/build.gradle b/exploration/build.gradle index 820693933..3521c8236 100644 --- a/exploration/build.gradle +++ b/exploration/build.gradle @@ -6,7 +6,7 @@ plugins { String mod_id = 'projectred_exploration' minecraft { - mappings channel: mcp_mappings, version: mc_version + mappings channel: mcp_mappings, version: mcp_mappings_version accessTransformer = file("../core/src/main/resources/META-INF/accesstransformer.cfg") runs { data { diff --git a/exploration/src/main/java/mrtjp/projectred/exploration/ProjectRedExploration.java b/exploration/src/main/java/mrtjp/projectred/exploration/ProjectRedExploration.java index 4a8ede839..8718f272b 100644 --- a/exploration/src/main/java/mrtjp/projectred/exploration/ProjectRedExploration.java +++ b/exploration/src/main/java/mrtjp/projectred/exploration/ProjectRedExploration.java @@ -5,6 +5,7 @@ import codechicken.microblock.api.MicroMaterial; import mrtjp.projectred.exploration.data.*; import mrtjp.projectred.exploration.init.*; +import net.minecraft.core.Registry; import net.minecraft.data.DataGenerator; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.MenuType; @@ -12,17 +13,21 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.carver.WorldCarver; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -36,8 +41,12 @@ public class ProjectRedExploration { public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID); public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); - public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.CONTAINERS, MOD_ID); + public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, MOD_ID); public static final DeferredRegister> WORLD_CARVERS = DeferredRegister.create(ForgeRegistries.WORLD_CARVERS, MOD_ID); + public static final DeferredRegister> CONFIGURED_CARVERS = DeferredRegister.create(Registry.CONFIGURED_CARVER_REGISTRY, MOD_ID); + public static final DeferredRegister> FEATURES = DeferredRegister.create(ForgeRegistries.FEATURES, MOD_ID); + public static final DeferredRegister> CONFIGURED_FEATURES = DeferredRegister.create(Registry.CONFIGURED_FEATURE_REGISTRY, MOD_ID); + public static final DeferredRegister PLACED_FEATURES = DeferredRegister.create(Registry.PLACED_FEATURE_REGISTRY, MOD_ID); public static final DeferredRegister> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, MOD_ID); public static final DeferredRegister MICRO_MATERIALS = DeferredRegister.create(new ResourceLocation(CBMicroblock.MOD_ID, "micro_material"), MOD_ID); @@ -56,7 +65,7 @@ public ProjectRedExploration() { modEventBus.addListener(this::commonSetup); modEventBus.addListener(this::onGatherDataEvent); - modEventBus.addGenericListener(MicroMaterial.class, ExplorationBlocks::onRegisterMicroMaterials); + modEventBus.addListener(ExplorationBlocks::onRegisterMicroMaterials); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> ExplorationClientInit::init); @@ -64,31 +73,34 @@ public ProjectRedExploration() { ITEMS.register(modEventBus); MENU_TYPES.register(modEventBus); WORLD_CARVERS.register(modEventBus); + CONFIGURED_CARVERS.register(modEventBus); + FEATURES.register(modEventBus); + CONFIGURED_FEATURES.register(modEventBus); + PLACED_FEATURES.register(modEventBus); RECIPE_SERIALIZERS.register(modEventBus); MICRO_MATERIALS.register(modEventBus); - MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, ExplorationWorldFeatures::onBiomeLoadingEvent); + //TODO figure out how to load in features +// MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, ExplorationWorldFeatures::onBiomeLoadingEvent); } private void commonSetup(final FMLCommonSetupEvent event) { - event.enqueueWork(ExplorationWorldFeatures::load); + //TODO figure out how to load in features +// event.enqueueWork(ExplorationWorldFeatures::load); } private void onGatherDataEvent(final GatherDataEvent event) { DataGenerator generator = event.getGenerator(); ExistingFileHelper fileHelper = event.getExistingFileHelper(); - if (event.includeClient()) { - generator.addProvider(new ExplorationBlockStateModelProvider(generator, fileHelper)); - generator.addProvider(new ExplorationItemModelProvider(generator, fileHelper)); - generator.addProvider(new ExplorationLanguageProvider(generator)); - } - if (event.includeServer()) { - generator.addProvider(new ExplorationBlockTagsProvider(generator, fileHelper)); - generator.addProvider(new ExplorationItemTagsProvider(generator, fileHelper)); - generator.addProvider(new ExplorationLootTableProvider(generator)); - generator.addProvider(new ExplorationRecipeProvider(generator)); - } + generator.addProvider(event.includeClient(), new ExplorationBlockStateModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new ExplorationItemModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new ExplorationLanguageProvider(generator)); + + generator.addProvider(event.includeServer(), new ExplorationBlockTagsProvider(generator, fileHelper)); + generator.addProvider(event.includeServer(), new ExplorationItemTagsProvider(generator, fileHelper)); + generator.addProvider(event.includeServer(), new ExplorationLootTableProvider(generator)); + generator.addProvider(event.includeServer(), new ExplorationRecipeProvider(generator)); } } diff --git a/exploration/src/main/java/mrtjp/projectred/exploration/block/ElectrotineOreBlock.java b/exploration/src/main/java/mrtjp/projectred/exploration/block/ElectrotineOreBlock.java index 1f98eb608..57bfd6d13 100644 --- a/exploration/src/main/java/mrtjp/projectred/exploration/block/ElectrotineOreBlock.java +++ b/exploration/src/main/java/mrtjp/projectred/exploration/block/ElectrotineOreBlock.java @@ -5,7 +5,8 @@ import net.minecraft.core.Direction; import net.minecraft.core.particles.DustParticleOptions; import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.valueproviders.UniformInt; +import net.minecraft.util.RandomSource; +import net.minecraft.util.valueproviders.IntProvider; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; @@ -15,7 +16,7 @@ import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.OreBlock; +import net.minecraft.world.level.block.DropExperienceBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; @@ -28,14 +29,14 @@ /** * All methods lifted straight from RedstoneOreBlock */ -public class ElectrotineOreBlock extends OreBlock { +public class ElectrotineOreBlock extends DropExperienceBlock { public static final BooleanProperty LIT = BlockStateProperties.LIT; public static final DustParticleOptions ELECTROTINE_PARTICLE = new DustParticleOptions( new Vector3f(15 / 255F, 103 / 255F, 178 / 255F), 0.6F); - public ElectrotineOreBlock(BlockBehaviour.Properties properties, UniformInt xpRange) { + public ElectrotineOreBlock(BlockBehaviour.Properties properties, IntProvider xpRange) { super(properties.lightLevel(s -> s.getValue(LIT) ? 9 : 0), xpRange); registerDefaultState(defaultBlockState().setValue(LIT, false)); @@ -82,7 +83,7 @@ public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random } @Override - public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { + public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) { if (state.getValue(LIT)) { spawnParticles(world, pos); } @@ -90,7 +91,7 @@ public void animateTick(BlockState state, Level world, BlockPos pos, Random rand private static void spawnParticles(Level world, BlockPos pos) { double d0 = 0.5625D; - Random random = world.random; + RandomSource random = world.random; for (Direction direction : Direction.values()) { BlockPos blockpos = pos.relative(direction); diff --git a/exploration/src/main/java/mrtjp/projectred/exploration/data/ExplorationItemModelProvider.java b/exploration/src/main/java/mrtjp/projectred/exploration/data/ExplorationItemModelProvider.java index 427b4fad7..fa0b61e1c 100644 --- a/exploration/src/main/java/mrtjp/projectred/exploration/data/ExplorationItemModelProvider.java +++ b/exploration/src/main/java/mrtjp/projectred/exploration/data/ExplorationItemModelProvider.java @@ -4,6 +4,7 @@ import net.minecraft.data.DataGenerator; import net.minecraft.world.level.block.Block; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.registries.ForgeRegistries; import static mrtjp.projectred.exploration.ProjectRedExploration.MOD_ID; import static mrtjp.projectred.exploration.init.ExplorationBlocks.*; @@ -151,6 +152,6 @@ protected void registerModels() { private void wallItemBlock(Block wallBlock, Block textureBlock) { getSimple(wallBlock) .noTexture() - .parent(wallInventory(wallBlock.getRegistryName() + "_inventory", blockTexture(textureBlock))); + .parent(wallInventory(ForgeRegistries.BLOCKS.getKey(wallBlock) + "_inventory", blockTexture(textureBlock))); } } diff --git a/exploration/src/main/java/mrtjp/projectred/exploration/data/ExplorationRecipeProvider.java b/exploration/src/main/java/mrtjp/projectred/exploration/data/ExplorationRecipeProvider.java index 7f66f91ee..f7c8b5b3b 100644 --- a/exploration/src/main/java/mrtjp/projectred/exploration/data/ExplorationRecipeProvider.java +++ b/exploration/src/main/java/mrtjp/projectred/exploration/data/ExplorationRecipeProvider.java @@ -13,6 +13,7 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.ItemLike; import net.minecraftforge.common.Tags; +import net.minecraftforge.registries.ForgeRegistries; import java.util.Collection; import java.util.List; @@ -166,10 +167,10 @@ protected void registerRecipes() { } private void oreSmeltingRecipe(ItemLike result, Collection sources, float xp) { - String resultName = result.asItem().getRegistryName().getPath(); + String resultName = ForgeRegistries.ITEMS.getKey(result.asItem()).getPath(); for (ItemLike source : sources) { - String sourceName = source.asItem().getRegistryName().getPath(); + String sourceName = ForgeRegistries.ITEMS.getKey(source.asItem()).getPath(); smelting(result, 1, new ResourceLocation(MOD_ID, resultName + "_from_" + sourceName + "_smelting")) .ingredient(source) @@ -186,7 +187,7 @@ private void nineBlockStorageRecipes(TagKey itemTag, ItemLike block, ItemL .patternLine("SSS"); // Block to item - shapelessRecipe(item, 9, new ResourceLocation(MOD_ID, item.asItem().getRegistryName().getPath() + "_from_nineblock")) + shapelessRecipe(item, 9, new ResourceLocation(MOD_ID, ForgeRegistries.ITEMS.getKey(item.asItem()).getPath() + "_from_nineblock")) .addIngredient(block); } diff --git a/exploration/src/main/java/mrtjp/projectred/exploration/init/ExplorationBlocks.java b/exploration/src/main/java/mrtjp/projectred/exploration/init/ExplorationBlocks.java index 29f531c51..e950fdef9 100644 --- a/exploration/src/main/java/mrtjp/projectred/exploration/init/ExplorationBlocks.java +++ b/exploration/src/main/java/mrtjp/projectred/exploration/init/ExplorationBlocks.java @@ -2,19 +2,19 @@ import codechicken.microblock.api.BlockMicroMaterial; import codechicken.microblock.api.MicroMaterial; +import codechicken.microblock.util.MicroMaterialRegistry; import mrtjp.projectred.exploration.block.ElectrotineOreBlock; import net.minecraft.util.valueproviders.UniformInt; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.OreBlock; +import net.minecraft.world.level.block.DropExperienceBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.WallBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.registries.IForgeRegistry; +import net.minecraftforge.registries.RegisterEvent; import net.minecraftforge.registries.RegistryObject; import static mrtjp.projectred.exploration.ProjectRedExploration.*; @@ -100,13 +100,6 @@ public class ExplorationBlocks { public static RegistryObject ELECTROTINE_BLOCK_WALL; -// // Direct references needed for early init and worldgen -// public static RegistryObject MARBLE_BLOCK; -// public static RegistryObject MARBLE_BRICK_BLOCK; -// public static RegistryObject BASALT_BLOCK; -// public static RegistryObject BASALT_COBBLE_BLOCK; -// public static RegistryObject BASALT_BRICK_BLOCK; - public static void register() { // Ores @@ -192,21 +185,27 @@ public static void register() { ITEMS.register(ID_ELECTROTINE_BLOCK_WALL, () -> createBlockItem(ELECTROTINE_BLOCK_WALL)); } - public static void onRegisterMicroMaterials(RegistryEvent.Register event) { - IForgeRegistry r = event.getRegistry(); - r.register(new BlockMicroMaterial(MARBLE_BLOCK.get())); - r.register(new BlockMicroMaterial(MARBLE_BRICK_BLOCK.get())); - r.register(new BlockMicroMaterial(BASALT_BLOCK.get())); - r.register(new BlockMicroMaterial(BASALT_COBBLE_BLOCK.get())); - r.register(new BlockMicroMaterial(BASALT_BRICK_BLOCK.get())); - r.register(new BlockMicroMaterial(RUBY_BLOCK.get())); - r.register(new BlockMicroMaterial(SAPPHIRE_BLOCK.get())); - r.register(new BlockMicroMaterial(PERIDOT_BLOCK.get())); - r.register(new BlockMicroMaterial(ELECTROTINE_BLOCK.get())); + public static void onRegisterMicroMaterials(RegisterEvent event) { + + event.register(MicroMaterialRegistry.MICRO_MATERIALS.getRegistryKey(), r -> { + registerBlockMicro(r, new BlockMicroMaterial(MARBLE_BLOCK.get())); + registerBlockMicro(r, new BlockMicroMaterial(MARBLE_BRICK_BLOCK.get())); + registerBlockMicro(r, new BlockMicroMaterial(BASALT_BLOCK.get())); + registerBlockMicro(r, new BlockMicroMaterial(BASALT_COBBLE_BLOCK.get())); + registerBlockMicro(r, new BlockMicroMaterial(BASALT_BRICK_BLOCK.get())); + registerBlockMicro(r, new BlockMicroMaterial(RUBY_BLOCK.get())); + registerBlockMicro(r, new BlockMicroMaterial(SAPPHIRE_BLOCK.get())); + registerBlockMicro(r, new BlockMicroMaterial(PERIDOT_BLOCK.get())); + registerBlockMicro(r, new BlockMicroMaterial(ELECTROTINE_BLOCK.get())); + }); + } + + private static void registerBlockMicro(RegisterEvent.RegisterHelper r, BlockMicroMaterial material) { + r.register(BlockMicroMaterial.makeMaterialKey(material.state), material); } private static Block createOreBlock(boolean isDeepslate, int minxp, int maxxp) { - return new OreBlock(BlockBehaviour.Properties.of(Material.STONE) + return new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE) .strength(isDeepslate ? 4.5F : 3.0F, 3.0F) .requiresCorrectToolForDrops() .color(isDeepslate ? MaterialColor.DEEPSLATE : MaterialColor.STONE) diff --git a/exploration/src/main/java/mrtjp/projectred/exploration/init/ExplorationWorldFeatures.java b/exploration/src/main/java/mrtjp/projectred/exploration/init/ExplorationWorldFeatures.java index 605205bd6..5957dc3dd 100644 --- a/exploration/src/main/java/mrtjp/projectred/exploration/init/ExplorationWorldFeatures.java +++ b/exploration/src/main/java/mrtjp/projectred/exploration/init/ExplorationWorldFeatures.java @@ -4,16 +4,12 @@ import mrtjp.projectred.core.Configurator; import mrtjp.projectred.exploration.world.gen.MarbleCaveWorldCarver; import net.minecraft.core.Holder; -import net.minecraft.data.BuiltinRegistries; -import net.minecraft.data.worldgen.features.FeatureUtils; +import net.minecraft.core.Registry; import net.minecraft.data.worldgen.features.OreFeatures; -import net.minecraft.data.worldgen.placement.PlacementUtils; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; import net.minecraft.util.valueproviders.UniformFloat; -import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.VerticalAnchor; import net.minecraft.world.level.levelgen.carver.CarverDebugSettings; import net.minecraft.world.level.levelgen.carver.CaveCarverConfiguration; @@ -24,121 +20,130 @@ import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; import net.minecraft.world.level.levelgen.heightproviders.UniformHeight; import net.minecraft.world.level.levelgen.placement.*; -import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder; -import net.minecraftforge.event.world.BiomeLoadingEvent; import net.minecraftforge.registries.RegistryObject; import java.util.List; +import java.util.function.Supplier; -import static mrtjp.projectred.exploration.ProjectRedExploration.MOD_ID; -import static mrtjp.projectred.exploration.ProjectRedExploration.WORLD_CARVERS; +import static mrtjp.projectred.exploration.ProjectRedExploration.*; import static mrtjp.projectred.exploration.init.ExplorationBlocks.*; -import static net.minecraft.world.level.biome.Biome.BiomeCategory.*; @SuppressWarnings("NotNullFieldNotInitialized") public class ExplorationWorldFeatures { public static final String ID_MARBLE_CAVE_CARVER = "marble_cave"; - // Marble Cave world carver - private static RegistryObject> MARBLE_CAVE_CARVER; + // World carvers + public static RegistryObject> MARBLE_CAVE_CARVER; - // Ore placements - public static Holder RUBY_ORE_PLACED_FEATURE; - public static Holder SAPPHIRE_ORE_PLACED_FEATURE; - public static Holder PERIDOT_ORE_PLACED_FEATURE; - public static Holder ELECTROTINE_ORE_PLACED_FEATURE; - public static Holder TIN_ORE_PLACED_FEATURE; - public static Holder SILVER_ORE_PLACED_FEATURE; + // Configured carvers + public static RegistryObject> MARBLE_CAVE_CONFIGURED_CARVER; + + // Configured features + public static RegistryObject> RUBY_ORE_CONFIGURED_FEATURE; + public static RegistryObject> SAPPHIRE_ORE_CONFIGURED_FEATURE; + public static RegistryObject> PERIDOT_ORE_CONFIGURED_FEATURE; + public static RegistryObject> ELECTROTINE_ORE_CONFIGURED_FEATURE; + public static RegistryObject> TIN_ORE_CONFIGURED_FEATURE; + public static RegistryObject> SILVER_ORE_CONFIGURED_FEATURE; + + // Placed features + public static RegistryObject RUBY_ORE_PLACED_FEATURE; + public static RegistryObject SAPPHIRE_ORE_PLACED_FEATURE; + public static RegistryObject PERIDOT_ORE_PLACED_FEATURE; + public static RegistryObject ELECTROTINE_ORE_PLACED_FEATURE; + public static RegistryObject TIN_ORE_PLACED_FEATURE; + public static RegistryObject SILVER_ORE_PLACED_FEATURE; - // Carver features - private static Holder> MARBLE_CAVE_CONFIGURED_CARVER; public static void register() { + // Carvers MARBLE_CAVE_CARVER = WORLD_CARVERS.register(ID_MARBLE_CAVE_CARVER, () -> new MarbleCaveWorldCarver(CaveCarverConfiguration.CODEC)); - } - public static void load() { - // Load configurations of Ore features and world carvers. Happens during common init because there is no Forge registry for this - - // Create features - Holder> RUBY_ORE_CONFIGURED_FEATURE = registerOreConfiguration("ruby_ore", RUBY_ORE_BLOCK.get(), DEEPSLATE_RUBY_ORE_BLOCK.get(), Configurator.gen_RubyVeinSize); - Holder> SAPPHIRE_ORE_CONFIGURED_FEATURE = registerOreConfiguration("sapphire_ore", SAPPHIRE_ORE_BLOCK.get(), DEEPSLATE_SAPPHIRE_ORE_BLOCK.get(), Configurator.gen_SapphireVeinSize); - Holder> PERIDOT_ORE_CONFIGURED_FEATURE = registerOreConfiguration("peridot_ore", PERIDOT_ORE_BLOCK.get(), DEEPSLATE_PERIDOT_ORE_BLOCK.get(), Configurator.gen_PeridotVeinSize); - Holder> ELECTROTINE_ORE_CONFIGURED_FEATURE = registerOreConfiguration("electrotine_ore", ELECTROTINE_ORE_BLOCK.get(), DEEPSLATE_ELECTROTINE_ORE_BLOCK.get(), Configurator.gen_ElectrotineVeinSize); - Holder> TIN_ORE_CONFIGURED_FEATURE = registerOreConfiguration("tin_ore", TIN_ORE_BLOCK.get(), DEEPSLATE_TIN_ORE_BLOCK.get(), Configurator.gen_TinVeinSize); - Holder> SILVER_ORE_CONFIGURED_FEATURE = registerOreConfiguration("silver_ore", SILVER_ORE_BLOCK.get(), DEEPSLATE_SILVER_ORE_BLOCK.get(), Configurator.gen_SilverVeinSize); - - // Create placements - RUBY_ORE_PLACED_FEATURE = createOrePlacements("ruby_ore", RUBY_ORE_CONFIGURED_FEATURE, -80, 80, 1); - SAPPHIRE_ORE_PLACED_FEATURE = createOrePlacements("sapphire_ore", SAPPHIRE_ORE_CONFIGURED_FEATURE, -80, 80, 1); - PERIDOT_ORE_PLACED_FEATURE = createOrePlacements("peridot_ore", PERIDOT_ORE_CONFIGURED_FEATURE, -80, 80, 1); - ELECTROTINE_ORE_PLACED_FEATURE = createOrePlacements("electrotine_ore", ELECTROTINE_ORE_CONFIGURED_FEATURE, -32, 32, 4); - TIN_ORE_PLACED_FEATURE = createOrePlacements("tin_ore", TIN_ORE_CONFIGURED_FEATURE, -24, 56, 8); - SILVER_ORE_PLACED_FEATURE = createOrePlacements("silver_ore", SILVER_ORE_CONFIGURED_FEATURE, -64, 32, 6); - - MARBLE_CAVE_CONFIGURED_CARVER = registerMarbleCaveCarverConfiguration(0.02F); + // Configured carvers + MARBLE_CAVE_CONFIGURED_CARVER = CONFIGURED_CARVERS.register(ID_MARBLE_CAVE_CARVER, () -> MARBLE_CAVE_CARVER.get().configured(new CaveCarverConfiguration( + 0.02F, // probability + UniformHeight.of(VerticalAnchor.aboveBottom(8), VerticalAnchor.absolute(180)), // Max/min heights + UniformFloat.of(0.1F, 0.9F), // y scale + VerticalAnchor.aboveBottom(8), // lava level + CarverDebugSettings.of(false, Blocks.CRIMSON_BUTTON.defaultBlockState()), // debug settings (enable, air state) + Registry.BLOCK.getOrCreateTag(BlockTags.OVERWORLD_CARVER_REPLACEABLES), + UniformFloat.of(0.7F, 1.4F), // horizontal radius + UniformFloat.of(0.8F, 1.3F), // vertical radius + UniformFloat.of(-1.0F, -0.4F)))); // floor level + + // Configured ores + RUBY_ORE_CONFIGURED_FEATURE = registerOreConfiguration("ruby_ore", RUBY_ORE_BLOCK, DEEPSLATE_RUBY_ORE_BLOCK, Configurator.gen_RubyVeinSize); + SAPPHIRE_ORE_CONFIGURED_FEATURE = registerOreConfiguration("sapphire_ore", SAPPHIRE_ORE_BLOCK, DEEPSLATE_SAPPHIRE_ORE_BLOCK, Configurator.gen_SapphireVeinSize); + PERIDOT_ORE_CONFIGURED_FEATURE = registerOreConfiguration("peridot_ore", PERIDOT_ORE_BLOCK, DEEPSLATE_PERIDOT_ORE_BLOCK, Configurator.gen_PeridotVeinSize); + ELECTROTINE_ORE_CONFIGURED_FEATURE = registerOreConfiguration("electrotine_ore", ELECTROTINE_ORE_BLOCK, DEEPSLATE_ELECTROTINE_ORE_BLOCK, Configurator.gen_ElectrotineVeinSize); + TIN_ORE_CONFIGURED_FEATURE = registerOreConfiguration("tin_ore", TIN_ORE_BLOCK, DEEPSLATE_TIN_ORE_BLOCK, Configurator.gen_TinVeinSize); + SILVER_ORE_CONFIGURED_FEATURE = registerOreConfiguration("silver_ore", SILVER_ORE_BLOCK, DEEPSLATE_SILVER_ORE_BLOCK, Configurator.gen_SilverVeinSize); + + // Placements + RUBY_ORE_PLACED_FEATURE = registerOrePlacement("ruby_ore", RUBY_ORE_CONFIGURED_FEATURE, -80, 80, 1); + SAPPHIRE_ORE_PLACED_FEATURE = registerOrePlacement("sapphire_ore", SAPPHIRE_ORE_CONFIGURED_FEATURE, -80, 80, 1); + PERIDOT_ORE_PLACED_FEATURE = registerOrePlacement("peridot_ore", PERIDOT_ORE_CONFIGURED_FEATURE, -80, 80, 1); + ELECTROTINE_ORE_PLACED_FEATURE = registerOrePlacement("electrotine_ore", ELECTROTINE_ORE_CONFIGURED_FEATURE, -32, 32, 4); + TIN_ORE_PLACED_FEATURE = registerOrePlacement("tin_ore", TIN_ORE_CONFIGURED_FEATURE, -24, 56, 8); + SILVER_ORE_PLACED_FEATURE = registerOrePlacement("silver_ore", SILVER_ORE_CONFIGURED_FEATURE, -64, 32, 6); } - public static void onBiomeLoadingEvent(final BiomeLoadingEvent event) { - Biome.BiomeCategory category = event.getCategory(); - BiomeGenerationSettingsBuilder builder = event.getGeneration(); - - if (category != NONE && category != THEEND && category != NETHER) { // if overworld - - if (Configurator.gen_Ruby) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, RUBY_ORE_PLACED_FEATURE); - if (Configurator.gen_Sapphire) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, SAPPHIRE_ORE_PLACED_FEATURE); - if (Configurator.gen_Peridot) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, PERIDOT_ORE_PLACED_FEATURE); - if (Configurator.gen_Electrotine) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, ELECTROTINE_ORE_PLACED_FEATURE); - if (Configurator.gen_Tin) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, TIN_ORE_PLACED_FEATURE); - if (Configurator.gen_Silver) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, SILVER_ORE_PLACED_FEATURE); - - if (Configurator.gen_MarbleCave) builder.addCarver(GenerationStep.Carving.AIR, MARBLE_CAVE_CONFIGURED_CARVER); - } - } + //TODO figure out how to load these into biomes +// public static void load() { +// // Load configurations of Ore features and world carvers. Happens during common init because there is no Forge registry for this +// +// // Create features +// Holder> RUBY_ORE_CONFIGURED_FEATURE = registerOreConfiguration("ruby_ore", RUBY_ORE_BLOCK.get(), DEEPSLATE_RUBY_ORE_BLOCK.get(), Configurator.gen_RubyVeinSize); +// Holder> SAPPHIRE_ORE_CONFIGURED_FEATURE = registerOreConfiguration("sapphire_ore", SAPPHIRE_ORE_BLOCK.get(), DEEPSLATE_SAPPHIRE_ORE_BLOCK.get(), Configurator.gen_SapphireVeinSize); +// Holder> PERIDOT_ORE_CONFIGURED_FEATURE = registerOreConfiguration("peridot_ore", PERIDOT_ORE_BLOCK.get(), DEEPSLATE_PERIDOT_ORE_BLOCK.get(), Configurator.gen_PeridotVeinSize); +// Holder> ELECTROTINE_ORE_CONFIGURED_FEATURE = registerOreConfiguration("electrotine_ore", ELECTROTINE_ORE_BLOCK.get(), DEEPSLATE_ELECTROTINE_ORE_BLOCK.get(), Configurator.gen_ElectrotineVeinSize); +// Holder> TIN_ORE_CONFIGURED_FEATURE = registerOreConfiguration("tin_ore", TIN_ORE_BLOCK.get(), DEEPSLATE_TIN_ORE_BLOCK.get(), Configurator.gen_TinVeinSize); +// Holder> SILVER_ORE_CONFIGURED_FEATURE = registerOreConfiguration("silver_ore", SILVER_ORE_BLOCK.get(), DEEPSLATE_SILVER_ORE_BLOCK.get(), Configurator.gen_SilverVeinSize); +// +// // Create placements +// RUBY_ORE_PLACED_FEATURE = registerOrePlacement("ruby_ore", RUBY_ORE_CONFIGURED_FEATURE, -80, 80, 1); +// SAPPHIRE_ORE_PLACED_FEATURE = registerOrePlacement("sapphire_ore", SAPPHIRE_ORE_CONFIGURED_FEATURE, -80, 80, 1); +// PERIDOT_ORE_PLACED_FEATURE = registerOrePlacement("peridot_ore", PERIDOT_ORE_CONFIGURED_FEATURE, -80, 80, 1); +// ELECTROTINE_ORE_PLACED_FEATURE = registerOrePlacement("electrotine_ore", ELECTROTINE_ORE_CONFIGURED_FEATURE, -32, 32, 4); +// TIN_ORE_PLACED_FEATURE = registerOrePlacement("tin_ore", TIN_ORE_CONFIGURED_FEATURE, -24, 56, 8); +// SILVER_ORE_PLACED_FEATURE = registerOrePlacement("silver_ore", SILVER_ORE_CONFIGURED_FEATURE, -64, 32, 6); +// +// MARBLE_CAVE_CONFIGURED_CARVER = registerMarbleCaveCarverConfiguration(0.02F); +// } + +// public static void onBiomeLoadingEvent(final BiomeLoadingEvent event) { +// Biome.BiomeCategory category = event.getCategory(); +// BiomeGenerationSettingsBuilder builder = event.getGeneration(); +// +// if (category != NONE && category != THEEND && category != NETHER) { // if overworld +// +// if (Configurator.gen_Ruby) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, RUBY_ORE_PLACED_FEATURE); +// if (Configurator.gen_Sapphire) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, SAPPHIRE_ORE_PLACED_FEATURE); +// if (Configurator.gen_Peridot) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, PERIDOT_ORE_PLACED_FEATURE); +// if (Configurator.gen_Electrotine) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, ELECTROTINE_ORE_PLACED_FEATURE); +// if (Configurator.gen_Tin) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, TIN_ORE_PLACED_FEATURE); +// if (Configurator.gen_Silver) builder.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, SILVER_ORE_PLACED_FEATURE); +// +// if (Configurator.gen_MarbleCave) builder.addCarver(GenerationStep.Carving.AIR, MARBLE_CAVE_CONFIGURED_CARVER); +// } +// } // Registers the actual ore feature. This describes a single cluster of this specific ore type - private static Holder> registerOreConfiguration(String id, Block standard, Block deepslate, int veinSize) { - return FeatureUtils.register( - modId(id), - Feature.ORE, - new OreConfiguration(ImmutableList.of( - OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, standard.defaultBlockState()), - OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, deepslate.defaultBlockState())), veinSize)); + private static RegistryObject> registerOreConfiguration(String id, Supplier standard, Supplier deepslate, int veinSize) { + return CONFIGURED_FEATURES.register(id, () -> new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(ImmutableList.of( + OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, standard.get().defaultBlockState()), + OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, deepslate.get().defaultBlockState())), veinSize))); } // Registers a placement for the given feature. This controls how many of said features spawn and where - private static Holder createOrePlacements(String id, Holder> configuredFeature, int minY, int maxY, int count) { + private static RegistryObject registerOrePlacement(String id, RegistryObject> configuredFeature, int minY, int maxY, int count) { List modifiers = ImmutableList.of( CountPlacement.of(count), InSquarePlacement.spread(), HeightRangePlacement.triangle(VerticalAnchor.absolute(minY), VerticalAnchor.absolute(maxY))); - return PlacementUtils.register( - modId(id), - configuredFeature, - modifiers); - } - - private static Holder> registerMarbleCaveCarverConfiguration(float probability) { - ConfiguredWorldCarver configuredCarver = MARBLE_CAVE_CARVER.get().configured(new CaveCarverConfiguration( - probability, - UniformHeight.of(VerticalAnchor.aboveBottom(8), VerticalAnchor.absolute(180)), // Max/min heights - UniformFloat.of(0.1F, 0.9F), // y scale - VerticalAnchor.aboveBottom(8), // lava level - CarverDebugSettings.of(false, Blocks.CRIMSON_BUTTON.defaultBlockState()), // debug settings (enable, air state) - UniformFloat.of(0.7F, 1.4F), // horizontal radius - UniformFloat.of(0.8F, 1.3F), // vertical radius - UniformFloat.of(-1.0F, -0.4F))); // floor level - - return BuiltinRegistries.register( - BuiltinRegistries.CONFIGURED_CARVER, - new ResourceLocation(MOD_ID, ID_MARBLE_CAVE_CARVER), - configuredCarver); - } - - private static String modId(String id) { - return MOD_ID + ":" + id; + return PLACED_FEATURES.register(id, () -> new PlacedFeature(Holder.hackyErase(configuredFeature.getHolder().orElseThrow()), modifiers)); } } diff --git a/exploration/src/main/java/mrtjp/projectred/exploration/item/BackpackItem.java b/exploration/src/main/java/mrtjp/projectred/exploration/item/BackpackItem.java index 2ec48cac8..cea577ae9 100644 --- a/exploration/src/main/java/mrtjp/projectred/exploration/item/BackpackItem.java +++ b/exploration/src/main/java/mrtjp/projectred/exploration/item/BackpackItem.java @@ -8,8 +8,6 @@ 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.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -66,7 +64,7 @@ public InteractionResultHolder use(Level world, Player player, Intera private void openGui(ServerPlayer player) { ServerUtils.openContainer(player, new SimpleMenuProvider((windowId, playerInventory, playerEntity) -> new BackpackContainer(windowId, playerInventory), - new TranslatableComponent(this.getDescriptionId()))); + Component.translatable(this.getDescriptionId()))); } @Override @@ -74,7 +72,7 @@ public void appendHoverText(ItemStack stack, @Nullable Level world, List= stack.getMaxDamage()) { return ItemStack.EMPTY; diff --git a/exploration/src/main/java/mrtjp/projectred/exploration/world/gen/MarbleCaveWorldCarver.java b/exploration/src/main/java/mrtjp/projectred/exploration/world/gen/MarbleCaveWorldCarver.java index 80d6bd99c..cbfe2fb5a 100644 --- a/exploration/src/main/java/mrtjp/projectred/exploration/world/gen/MarbleCaveWorldCarver.java +++ b/exploration/src/main/java/mrtjp/projectred/exploration/world/gen/MarbleCaveWorldCarver.java @@ -28,10 +28,11 @@ public MarbleCaveWorldCarver(Codec codec) { super(codec); // A little awkward, but this is now NetherWorldCarver overrides this list - this.replaceableBlocks = new ImmutableSet.Builder() - .addAll(this.replaceableBlocks) - .add(ExplorationBlocks.MARBLE_BLOCK.get()) - .build(); + // TODO make this class generic, and intake the block for cave walls +// this.replaceableBlocks = new ImmutableSet.Builder() +// .addAll(this.replaceableBlocks) +// .add(ExplorationBlocks.MARBLE_BLOCK.get()) +// .build(); } @Override @@ -50,7 +51,7 @@ protected boolean carveBlock(CarvingContext context, CaveCarverConfiguration con for (int s = 0; s < 6; s++) { pos.set(pos1).move(Direction.values()[s]); BlockState adjacentState = chunkAccess.getBlockState(pos); - if (canReplaceBlock(adjacentState)) { + if (canReplaceBlock(config, adjacentState)) { chunkAccess.setBlockState(pos, marbleState, false); } } diff --git a/exploration/src/main/resources/META-INF/mods.toml b/exploration/src/main/resources/META-INF/mods.toml index 54ec622dd..8901c7a3c 100644 --- a/exploration/src/main/resources/META-INF/mods.toml +++ b/exploration/src/main/resources/META-INF/mods.toml @@ -23,7 +23,7 @@ Redstone. The way it was meant to be. [[dependencies.projectred_exploration]] modId="minecraft" mandatory=true - versionRange="[1.18.2]" + versionRange="[1.19.2]" ordering="AFTER" side="BOTH" [[dependencies.projectred_exploration]] diff --git a/fabrication/build.gradle b/fabrication/build.gradle index e16737b9e..2b00d5dae 100644 --- a/fabrication/build.gradle +++ b/fabrication/build.gradle @@ -7,7 +7,7 @@ plugins { String mod_id = 'projectred_fabrication' minecraft { - mappings channel: mcp_mappings, version: mc_version + mappings channel: mcp_mappings, version: mcp_mappings_version accessTransformer = file("../core/src/main/resources/META-INF/accesstransformer.cfg") runs { data { diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/ProjectRedFabrication.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/ProjectRedFabrication.java index 8f501c379..128c04afa 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/ProjectRedFabrication.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/ProjectRedFabrication.java @@ -15,12 +15,12 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; @@ -37,8 +37,8 @@ public class ProjectRedFabrication { public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID); public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); - public static final DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, MOD_ID); - public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.CONTAINERS, MOD_ID); + public static final DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MOD_ID); + public static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, MOD_ID); public static final DeferredRegister> PARTS = DeferredRegister.create(MultipartType.MULTIPART_TYPES, MOD_ID); public static final SimpleCreativeTab FABRICATION_GROUP = new SimpleCreativeTab(MOD_ID, () -> new ItemStack(FabricationBlocks.IC_WORKBENCH_BLOCK.get())); @@ -73,13 +73,10 @@ private void onGatherDataEvent(final GatherDataEvent event) { DataGenerator generator = event.getGenerator(); ExistingFileHelper fileHelper = event.getExistingFileHelper(); - if (event.includeClient()) { - generator.addProvider(new FabricationBlockStateModelProvider(generator, fileHelper)); - generator.addProvider(new FabricationItemModelProvider(generator, fileHelper)); - generator.addProvider(new FabricationLanguageProvider(generator)); - } - if (event.includeServer()) { - generator.addProvider(new FabricationRecipeProvider(generator)); - } + generator.addProvider(event.includeClient(), new FabricationBlockStateModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new FabricationItemModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new FabricationLanguageProvider(generator)); + + generator.addProvider(event.includeServer(), new FabricationRecipeProvider(generator)); } } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/data/FabricationBlockStateModelProvider.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/data/FabricationBlockStateModelProvider.java index d8ef3f0fb..1e09e8d30 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/data/FabricationBlockStateModelProvider.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/data/FabricationBlockStateModelProvider.java @@ -11,6 +11,7 @@ import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nonnull; @@ -72,7 +73,7 @@ private void addRotatableDomedMachineVariants(Block block, ModelFile workingMode } private BlockModelBuilder createDomedMachineModelFileForBlock(Block block, int chargeState) { - String textureName = block.getRegistryName().getPath(); + String textureName = ForgeRegistries.BLOCKS.getKey(block).getPath(); String modelName = textureName + (chargeState > 0 ? "_state" + chargeState : ""); return models() .withExistingParent(modelName, modLoc("block/domed_machine")) @@ -85,7 +86,7 @@ private BlockModelBuilder createDomedMachineModelFileForBlock(Block block, int c } private BlockModelBuilder createICWorkbenchModel(Block block, boolean hasBlueprint) { - String textureName = block.getRegistryName().getPath(); + String textureName = ForgeRegistries.BLOCKS.getKey(block).getPath(); String suffix = hasBlueprint ? "" : "_empty"; String modelName = textureName + suffix; return models().cube(modelName, diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/BaseTile.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/BaseTile.java index 40a239314..2b396e0bd 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/BaseTile.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/BaseTile.java @@ -10,7 +10,6 @@ import mrtjp.projectred.fabrication.editor.ICWorkbenchEditor; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -99,7 +98,7 @@ public void onInteractionZoneActivated(int i) { } @OnlyIn(Dist.CLIENT) public void buildToolTip(List toolTip) { - toolTip.add(new TranslatableComponent(tileType.getUnlocalizedName())); + toolTip.add(Component.translatable(tileType.getUnlocalizedName())); } @OnlyIn(Dist.CLIENT) diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/IOGateTile.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/IOGateTile.java index dc73911dc..f9a5c0a80 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/IOGateTile.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/IOGateTile.java @@ -17,8 +17,6 @@ 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.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -26,7 +24,6 @@ import java.util.List; import java.util.Optional; -import static mrtjp.projectred.fabrication.ProjectRedFabrication.LOGGER; import static mrtjp.projectred.fabrication.engine.PRFabricationEngine.*; import static mrtjp.projectred.fabrication.init.FabricationUnlocal.*; @@ -132,16 +129,16 @@ public void buildInteractionToolTip(List toolTip, int i) { switch (i) { case 0: - toolTip.add(new TranslatableComponent(UL_TOGGLE_STATE)); - toolTip.add(new TextComponent(((getState() & 0x44) != 0 ? "0x1" : "0x0")).withStyle(ChatFormatting.GRAY)); + toolTip.add(Component.translatable(UL_TOGGLE_STATE)); + toolTip.add(Component.literal(((getState() & 0x44) != 0 ? "0x1" : "0x0")).withStyle(ChatFormatting.GRAY)); break; case 1: - toolTip.add(new TranslatableComponent(UL_TOGGLE_IO_MODE)); - toolTip.add(new TranslatableComponent((isInputIOMode() ? UL_IO_MODE_INPUT : UL_IO_MODE_OUTPUT)).withStyle(ChatFormatting.GRAY)); + toolTip.add(Component.translatable(UL_TOGGLE_IO_MODE)); + toolTip.add(Component.translatable((isInputIOMode() ? UL_IO_MODE_INPUT : UL_IO_MODE_OUTPUT)).withStyle(ChatFormatting.GRAY)); break; case 2: - toolTip.add(new TranslatableComponent(UL_TOGGLE_COLOUR)); - toolTip.add(new TranslatableComponent(EnumColour.values()[colour & 0xFF].getUnlocalizedName()).withStyle(ChatFormatting.GRAY)); + toolTip.add(Component.translatable(UL_TOGGLE_COLOUR)); + toolTip.add(Component.translatable(EnumColour.values()[colour & 0xFF].getUnlocalizedName()).withStyle(ChatFormatting.GRAY)); break; default: } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/RepeaterGateTile.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/RepeaterGateTile.java index 9a63c48bb..f3e50504f 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/RepeaterGateTile.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/RepeaterGateTile.java @@ -8,7 +8,6 @@ import mrtjp.fengine.simulate.ICSimulation; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -44,8 +43,8 @@ public List getInteractionZones() { @OnlyIn(Dist.CLIENT) public void buildInteractionToolTip(List toolTip, int i) { - toolTip.add(new TranslatableComponent(UL_TOGGLE_DELAY)); - toolTip.add(new TranslatableComponent(UL_UNIT_TICKS, DELAYS[getShape()]).withStyle(ChatFormatting.GRAY)); + toolTip.add(Component.translatable(UL_TOGGLE_DELAY)); + toolTip.add(Component.translatable(UL_UNIT_TICKS, DELAYS[getShape()]).withStyle(ChatFormatting.GRAY)); } @Override diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/SimpleGateTile.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/SimpleGateTile.java index 66f8d13fc..54f1ee6a3 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/SimpleGateTile.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/gates/SimpleGateTile.java @@ -4,7 +4,6 @@ import mrtjp.fengine.simulate.ICGate; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -78,7 +77,7 @@ public List getInteractionZones() { public void buildInteractionToolTip(List toolTip, int i) { boolean isEnabled = (getShape() & (1 << (i-1))) == 0; - toolTip.add(new TranslatableComponent(isEnabled ? UL_SIDE_ENABLED : UL_SIDE_DISABLED)); + toolTip.add(Component.translatable(isEnabled ? UL_SIDE_ENABLED : UL_SIDE_DISABLED)); } @Override diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/DeadGateWarning.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/DeadGateWarning.java index 02f16d587..d99ebed84 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/DeadGateWarning.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/DeadGateWarning.java @@ -3,7 +3,6 @@ import mrtjp.fengine.TileCoord; import mrtjp.projectred.fabrication.editor.ICWorkbenchEditor; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import java.util.List; @@ -22,11 +21,11 @@ public DeadGateWarning(TileCoord coord) { @Override public Component getName() { - return new TranslatableComponent(UL_DEAD_GATE_TITLE); + return Component.translatable(UL_DEAD_GATE_TITLE); } @Override public void buildToolTip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_DEAD_GATE_DESC).withStyle(ICWorkbenchEditor.UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_DEAD_GATE_DESC).withStyle(ICWorkbenchEditor.UNIFORM_GRAY)); } } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/DeadWireWarning.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/DeadWireWarning.java index a8bf71d1f..e0c960a19 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/DeadWireWarning.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/DeadWireWarning.java @@ -3,7 +3,6 @@ import mrtjp.fengine.TileCoord; import mrtjp.projectred.fabrication.editor.ICWorkbenchEditor; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import java.util.List; @@ -22,11 +21,11 @@ public DeadWireWarning(TileCoord coord) { @Override public Component getName() { - return new TranslatableComponent(UL_DEAD_WIRE_TITLE); + return Component.translatable(UL_DEAD_WIRE_TITLE); } @Override public void buildToolTip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_DEAD_WIRE_DESC).withStyle(ICWorkbenchEditor.UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_DEAD_WIRE_DESC).withStyle(ICWorkbenchEditor.UNIFORM_GRAY)); } } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/IODirectionMismatchError.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/IODirectionMismatchError.java index 26be91d2d..1e9a63708 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/IODirectionMismatchError.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/IODirectionMismatchError.java @@ -2,7 +2,6 @@ import mrtjp.fengine.TileCoord; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import java.util.Collection; import java.util.List; @@ -23,11 +22,11 @@ public IODirectionMismatchError() { @Override public Component getName() { - return new TranslatableComponent(UL_IO_DIR_MISMATCH_TITLE); + return Component.translatable(UL_IO_DIR_MISMATCH_TITLE); } @Override public void buildToolTip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_IO_DIR_MISMATCH_DESC).withStyle(UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_IO_DIR_MISMATCH_DESC).withStyle(UNIFORM_GRAY)); } } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/MultipleDriversError.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/MultipleDriversError.java index 8ce2467c6..39b145561 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/MultipleDriversError.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/MultipleDriversError.java @@ -12,8 +12,6 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; import java.util.ArrayList; import java.util.List; @@ -74,7 +72,7 @@ public void readDesc(MCDataInput in) { @Override public Component getName() { - return new TranslatableComponent(UL_MULTIPLE_DRIVERS_TITLE); + return Component.translatable(UL_MULTIPLE_DRIVERS_TITLE); } @Override @@ -86,15 +84,15 @@ public void buildToolTip(List tooltip, TileCoord hoverPosition) { @Override public void buildToolTip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_MULTIPLE_DRIVERS_DESC).withStyle(UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_MULTIPLE_DRIVERS_DESC).withStyle(UNIFORM_GRAY)); StringBuilder s = new StringBuilder(); for (int r : registerList) { s.append("R").append(r).append(", "); } s.delete(s.length() - 2, s.length()); // remove trailing comma - tooltip.add(new TextComponent(" ").withStyle(UNIFORM_GRAY).append( - new TextComponent(s.toString()).withStyle(UNIFORM_GRAY))); + tooltip.add(Component.literal(" ").withStyle(UNIFORM_GRAY).append( + Component.literal(s.toString()).withStyle(UNIFORM_GRAY))); } @Override diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/NoInputsError.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/NoInputsError.java index e36736876..5267b729b 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/NoInputsError.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/NoInputsError.java @@ -9,7 +9,6 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import java.util.List; @@ -41,7 +40,7 @@ public void readDesc(MCDataInput in) { @Override public Component getName() { - return new TranslatableComponent(UL_NO_INPUTS_TITLE); + return Component.translatable(UL_NO_INPUTS_TITLE); } @Override @@ -51,7 +50,7 @@ public void buildToolTip(List tooltip, TileCoord hoverPosition) { @Override public void buildToolTip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_NO_INPUTS_DESC).withStyle(UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_NO_INPUTS_DESC).withStyle(UNIFORM_GRAY)); } @Override diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/NoOutputsError.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/NoOutputsError.java index 7074d76b5..5fdc5ce49 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/NoOutputsError.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/engine/log/NoOutputsError.java @@ -9,7 +9,6 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import java.util.List; @@ -41,7 +40,7 @@ public void readDesc(MCDataInput in) { @Override public Component getName() { - return new TranslatableComponent(UL_NO_OUTPUTS_TITLE); + return Component.translatable(UL_NO_OUTPUTS_TITLE); } @Override @@ -51,7 +50,7 @@ public void buildToolTip(List tooltip, TileCoord hoverPosition) { @Override public void buildToolTip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_NO_OUTPUTS_DESC).withStyle(UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_NO_OUTPUTS_DESC).withStyle(UNIFORM_GRAY)); } @Override diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/CTNListNode.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/CTNListNode.java index 700f8916c..0af7a58fa 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/CTNListNode.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/CTNListNode.java @@ -9,7 +9,6 @@ import mrtjp.projectred.redui.AbstractGuiNode; import net.minecraft.client.gui.GuiComponent; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; import java.util.LinkedList; import java.util.List; @@ -93,11 +92,11 @@ public void drawFront(PoseStack stack, Point mouse, float partialFrame) { if (!isFirstHit(mouse)) return; List toolTip = new LinkedList<>(); - toolTip.add(new TextComponent(node.step.toString())); //TODO localize - toolTip.add(new TextComponent("Positions: " + node.tileCoords.size())); - toolTip.add(new TextComponent("Registers: " + node.registerIds.size())); - toolTip.add(new TextComponent("Gates: " + node.gateIds.size())); - toolTip.add(new TextComponent("Remaps: " + node.registerRemaps.size())); + toolTip.add(Component.literal(node.step.toString())); //TODO localize + toolTip.add(Component.literal("Positions: " + node.tileCoords.size())); + toolTip.add(Component.literal("Registers: " + node.registerIds.size())); + toolTip.add(Component.literal("Gates: " + node.gateIds.size())); + toolTip.add(Component.literal("Remaps: " + node.registerRemaps.size())); renderTooltip(stack, mouse, toolTip); } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/EraserToolTab.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/EraserToolTab.java index a3222bfe2..075f7743e 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/EraserToolTab.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/EraserToolTab.java @@ -7,7 +7,6 @@ import mrtjp.projectred.lib.Point; import net.minecraft.client.gui.GuiComponent; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import java.util.List; @@ -38,7 +37,7 @@ public void renderIcon(PoseStack stack, Point mouse, float partialFrame) { @Override public void buildTooltip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_ERASER_TOOL)); + tooltip.add(Component.translatable(UL_ERASER_TOOL)); } }; } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/GatePlacerToolTab.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/GatePlacerToolTab.java index 552f91b65..a1ed19a19 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/GatePlacerToolTab.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/GatePlacerToolTab.java @@ -19,7 +19,6 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import java.util.List; @@ -37,7 +36,7 @@ public GatePlacerToolTab(ICEditorToolManager manager, GatePlacerTool tool) { private void addGateButton(ICGateTileType type) { ButtonController buttonController = new ButtonController() { - @Override public void getTooltip(List tooltip) { tooltip.add(new TranslatableComponent(type.tileType.getUnlocalizedName())); } + @Override public void getTooltip(List tooltip) { tooltip.add(Component.translatable(type.tileType.getUnlocalizedName())); } @Override public void onClick() { tool.setGateType(type); } @Override public boolean isSelected() { return tool.getGateType() == type; } @@ -105,7 +104,7 @@ public void renderIcon(PoseStack stack, Point mouse, float partialFrame) { @Override public void buildTooltip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_GATE_TOOL)); + tooltip.add(Component.translatable(UL_GATE_TOOL)); } }; } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/ICEditorToolTab.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/ICEditorToolTab.java index f2a1aaf5b..a18dda040 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/ICEditorToolTab.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/ICEditorToolTab.java @@ -10,8 +10,6 @@ import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.sounds.SoundEvents; import java.util.LinkedList; @@ -68,7 +66,7 @@ private void setAndIncrGridPos(AbstractGuiNode node, int cellWidth) { } protected void addGroup(String unlocal) { - addGroup(new TranslatableComponent(unlocal)); + addGroup(Component.translatable(unlocal)); } protected void addGroup(Component groupName) { @@ -136,7 +134,7 @@ public void renderIcon(PoseStack stack, Point mouse, float partialFrame) { @Override public void buildTooltip(List tooltip) { - tooltip.add(new TextComponent("//TODO implement tab")); + tooltip.add(Component.literal("//TODO implement tab")); } }; } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/InteractToolTab.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/InteractToolTab.java index 7ea2edde5..f488d5ba8 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/InteractToolTab.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/InteractToolTab.java @@ -7,7 +7,6 @@ import mrtjp.projectred.lib.Point; import net.minecraft.client.gui.GuiComponent; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import java.util.List; @@ -38,7 +37,7 @@ public void renderIcon(PoseStack stack, Point mouse, float partialFrame) { @Override public void buildTooltip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_INTERACT_TOOL)); + tooltip.add(Component.translatable(UL_INTERACT_TOOL)); } }; } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/SimpleUVTab.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/SimpleUVTab.java index 03ae5fe81..ba9f7ea6c 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/SimpleUVTab.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/SimpleUVTab.java @@ -7,7 +7,6 @@ import mrtjp.projectred.redui.AbstractGuiNode; import net.minecraft.client.gui.GuiComponent; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import java.util.List; @@ -24,7 +23,7 @@ public class SimpleUVTab implements TabControllerNode.IToolbarTab { public SimpleUVTab(AbstractGuiNode tabBodyNode, String unlocalTabName, TabButtonNode.TabSide side, int u, int v, ResourceLocation texture) { //TODO Icon width/height? this.tabBodyNode = tabBodyNode; - this.tabName = new TranslatableComponent(unlocalTabName); + this.tabName = Component.translatable(unlocalTabName); this.tabSide = side; this.u = u; this.v = v; diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/WirePlacerToolTab.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/WirePlacerToolTab.java index 601d0d4e6..b5804dbdc 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/WirePlacerToolTab.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/WirePlacerToolTab.java @@ -19,7 +19,6 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import java.util.List; @@ -37,7 +36,7 @@ public WirePlacerToolTab(ICEditorToolManager manager, WirePlacerTool tool) { private void addWireButton(ICWireTileType type, boolean fullRow) { ButtonController buttonController = new ButtonController() { - @Override public void getTooltip(List tooltip) { tooltip.add(new TranslatableComponent(type.tileType.getUnlocalizedName())); } + @Override public void getTooltip(List tooltip) { tooltip.add(Component.translatable(type.tileType.getUnlocalizedName())); } @Override public void onClick() { tool.setWireType(type); } @Override public boolean isSelected() { return tool.getWireType() == type; } @@ -104,7 +103,7 @@ public void renderIcon(PoseStack stack, Point mouse, float partialFrame) { @Override public void buildTooltip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_WIRE_TOOL)); + tooltip.add(Component.translatable(UL_WIRE_TOOL)); } }; } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchCompileTab.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchCompileTab.java index 63b6697ea..886494935 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchCompileTab.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchCompileTab.java @@ -19,8 +19,6 @@ import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import org.lwjgl.glfw.GLFW; @@ -118,27 +116,27 @@ public void drawBack(PoseStack stack, Point mouse, float partialFrame) { // Progress text ICCompilerLog log = editor.getStateMachine().getCompilerLog(); getRoot().getFontRenderer().draw(stack, - new TranslatableComponent(editor.getStateMachine().isCompiling() ? UL_COMPILE_PROGRESS : UL_COMPILE_DONE, log.getCompletedSteps(), log.getTotalSteps()) + Component.translatable(editor.getStateMachine().isCompiling() ? UL_COMPILE_PROGRESS : UL_COMPILE_DONE, log.getCompletedSteps(), log.getTotalSteps()) .withStyle(UNIFORM_DARK_GRAY), getFrame().x() + 208, getFrame().y() + 42, EnumColour.GRAY.argb()); // Error Count Component errorText = log.getErrorCount() == 0 ? - new TextComponent(" ") - .append(new TranslatableComponent(UL_NO_ERRORS)) + Component.literal(" ") + .append(Component.translatable(UL_NO_ERRORS)) .withStyle(UNIFORM_DARK_GRAY) : - new TextComponent(" ") + Component.literal(" ") .withStyle(ICWorkbenchEditor.UNIFORM_RED) - .append(new TranslatableComponent(UL_UNIT_ERRORS, log.getErrorCount()) + .append(Component.translatable(UL_UNIT_ERRORS, log.getErrorCount()) .withStyle(UNIFORM_DARK_GRAY)); Component warningText = log.getWarningCount() == 0 ? - new TextComponent(" ") - .append(new TranslatableComponent(UL_NO_WARNINGS)) + Component.literal(" ") + .append(Component.translatable(UL_NO_WARNINGS)) .withStyle(UNIFORM_DARK_GRAY) : - new TextComponent(" ") + Component.literal(" ") .withStyle(ICWorkbenchEditor.UNIFORM_YELLOW) - .append(new TranslatableComponent(UL_UNIT_WARNINGS, log.getWarningCount()) + .append(Component.translatable(UL_UNIT_WARNINGS, log.getWarningCount()) .withStyle(UNIFORM_DARK_GRAY)); getRoot().getFontRenderer().draw(stack, errorText, getFrame().x() + 208, getFrame().y() + 52, EnumColour.GRAY.argb()); @@ -255,21 +253,21 @@ public void onRenderOverlay(ICRenderNode renderNode, Vector3 mousePosition, bool //region Utilities public static void appendProblemsInfo(ICCompilerLog log, List tooltip) { Component errorText = log.getErrorCount() == 0 ? - new TextComponent(" ") - .append(new TranslatableComponent(UL_NO_ERRORS)) + Component.literal(" ") + .append(Component.translatable(UL_NO_ERRORS)) .withStyle(UNIFORM_GRAY) : - new TextComponent(" ") + Component.literal(" ") .withStyle(UNIFORM_RED) - .append(new TranslatableComponent(UL_UNIT_ERRORS, log.getErrorCount()) + .append(Component.translatable(UL_UNIT_ERRORS, log.getErrorCount()) .withStyle(UNIFORM_GRAY)); Component warningText = log.getWarningCount() == 0 ? - new TextComponent(" ") - .append(new TranslatableComponent(UL_NO_WARNINGS)) + Component.literal(" ") + .append(Component.translatable(UL_NO_WARNINGS)) .withStyle(UNIFORM_GRAY) : - new TextComponent(" ") + Component.literal(" ") .withStyle(ICWorkbenchEditor.UNIFORM_YELLOW) - .append(new TranslatableComponent(UL_UNIT_WARNINGS, log.getWarningCount()) + .append(Component.translatable(UL_UNIT_WARNINGS, log.getWarningCount()) .withStyle(UNIFORM_GRAY)); tooltip.add(errorText); @@ -314,9 +312,9 @@ private void blitCentered(PoseStack stack, int u, int v, int width, int height) @Override protected void buildTooltip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_COMPILE)); + tooltip.add(Component.translatable(UL_COMPILE)); if (editor.getStateMachine().canTriggerCompile()) { - tooltip.add(new TranslatableComponent(UL_COMPILE_READY).withStyle(UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_COMPILE_READY).withStyle(UNIFORM_GRAY)); } } } @@ -340,12 +338,12 @@ protected void onClicked() { @Override protected void buildTooltip(List tooltip) { - tooltip.add(new TranslatableComponent(UL_AUTO_COMPILE)); - tooltip.add(new TranslatableComponent(UL_AUTO_COMPILE_DESCRIPTION).withStyle(UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_AUTO_COMPILE)); + tooltip.add(Component.translatable(UL_AUTO_COMPILE_DESCRIPTION).withStyle(UNIFORM_GRAY)); if (isDisabled()) { - tooltip.add(new TextComponent(" ") + tooltip.add(Component.literal(" ") .withStyle(UNIFORM_RED) - .append(new TranslatableComponent(UL_AUTO_COMPILE_DISABLED) + .append(Component.translatable(UL_AUTO_COMPILE_DISABLED) .withStyle(UNIFORM_GRAY))); } } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchInfoTab.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchInfoTab.java index 8b8a36889..9ff368d0c 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchInfoTab.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchInfoTab.java @@ -19,8 +19,7 @@ import mrtjp.projectred.redui.ScrollBarNode; import mrtjp.projectred.redui.TextBoxNode; import net.minecraft.client.gui.GuiComponent; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import javax.annotation.Nullable; @@ -54,33 +53,33 @@ private void initSubNodes() { NameTextBox nameTextBox = new NameTextBox(); nameTextBox.setSize(80, 18); - listNode.addTitleRow(new TranslatableComponent(UL_BLUEPRINT_INFO)); - listNode.addTextWithNodeRow(new TranslatableComponent(UL_BLUEPRINT_NAME), nameTextBox); - listNode.addKeyValueRow(new TranslatableComponent(UL_BLUEPRINT_OWNER), () -> new TranslatableComponent("//TODO")); + listNode.addTitleRow(Component.translatable(UL_BLUEPRINT_INFO)); + listNode.addTextWithNodeRow(Component.translatable(UL_BLUEPRINT_NAME), nameTextBox); + listNode.addKeyValueRow(Component.translatable(UL_BLUEPRINT_OWNER), () -> Component.literal("//TODO")); - listNode.addKeyValueRow(new TranslatableComponent(UL_BLUEPRINT_DIM), () -> { + listNode.addKeyValueRow(Component.translatable(UL_BLUEPRINT_DIM), () -> { TileCoord dimensions = editor.getTileMap().getDimensions(); - return new TranslatableComponent(UL_DIMENSIONS_TILES, dimensions.x, dimensions.z); + return Component.translatable(UL_DIMENSIONS_TILES, dimensions.x, dimensions.z); }); - listNode.addKeyValueRow(new TranslatableComponent(UL_BLUEPRINT_LAYERS), () -> { + listNode.addKeyValueRow(Component.translatable(UL_BLUEPRINT_LAYERS), () -> { TileCoord dimensions = editor.getTileMap().getDimensions(); - return new TextComponent(String.valueOf(dimensions.y)); + return Component.literal(String.valueOf(dimensions.y)); }); - listNode.addTitleRow(new TranslatableComponent(UL_YIELD_CALCULATOR)); + listNode.addTitleRow(Component.translatable(UL_YIELD_CALCULATOR)); ButtonArrayNode pipelineButtonGrid = createPipelineButtons(); pipelineButtonGrid.setGridSize(128, 18); - listNode.addTextWithNodeRow(new TranslatableComponent(UL_LITHOGRAPHY_PIPELINE), pipelineButtonGrid); + listNode.addTextWithNodeRow(Component.translatable(UL_LITHOGRAPHY_PIPELINE), pipelineButtonGrid); ButtonArrayNode processNodeButtonGrid = createProcessNodeButtons(); processNodeButtonGrid.setGridSize(128, 18); - listNode.addTextWithNodeRow(new TranslatableComponent(UL_PROCESS_NODE), processNodeButtonGrid); + listNode.addTextWithNodeRow(Component.translatable(UL_PROCESS_NODE), processNodeButtonGrid); ButtonArrayNode waferTypeButtonGrid = createWaferTypeButtons(); waferTypeButtonGrid.setGridSize(128, 18); - listNode.addTextWithNodeRow(new TranslatableComponent(UL_WAFER_TYPE), waferTypeButtonGrid); + listNode.addTextWithNodeRow(Component.translatable(UL_WAFER_TYPE), waferTypeButtonGrid); PipelineDiagramNode diagramNode = new PipelineDiagramNode(yieldCalculator); listNode.addSingleNodeRow(diagramNode); @@ -98,11 +97,11 @@ protected void adjustContent(double scrollPercentage) { } }; - listNode.addKeyValueRow(new TranslatableComponent(UL_DIE_SIZE), yieldCalculator::getDieDimensionsText); - listNode.addKeyValueRow(new TranslatableComponent(UL_WAFER_SIZE), yieldCalculator::getWaferDimensionsText); - listNode.addKeyValueRow(new TranslatableComponent(UL_DIES_PER_WAFER), yieldCalculator::getDieCountDimensionsText); - listNode.addKeyValueRow(new TranslatableComponent(UL_SINGLE_LAYER_YIELD), yieldCalculator::getSingleLayerYieldText); - listNode.addKeyValueRow(new TranslatableComponent(UL_YIELD), yieldCalculator::getYieldText); + listNode.addKeyValueRow(Component.translatable(UL_DIE_SIZE), yieldCalculator::getDieDimensionsText); + listNode.addKeyValueRow(Component.translatable(UL_WAFER_SIZE), yieldCalculator::getWaferDimensionsText); + listNode.addKeyValueRow(Component.translatable(UL_DIES_PER_WAFER), yieldCalculator::getDieCountDimensionsText); + listNode.addKeyValueRow(Component.translatable(UL_SINGLE_LAYER_YIELD), yieldCalculator::getSingleLayerYieldText); + listNode.addKeyValueRow(Component.translatable(UL_YIELD), yieldCalculator::getYieldText); scrollBarNode.setPosition(290, 17); scrollBarNode.setSize(8, 198); diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchScreen.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchScreen.java index f09d00bef..c96236730 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchScreen.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/gui/screen/ICWorkbenchScreen.java @@ -17,10 +17,9 @@ 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.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import net.minecraftforge.registries.ForgeRegistries; import org.lwjgl.glfw.GLFW; import javax.annotation.Nullable; @@ -44,7 +43,7 @@ public class ICWorkbenchScreen extends RedUIScreen { private @Nullable InactiveOverlayNode overlayNode; public ICWorkbenchScreen(ICWorkbenchTile tile) { - super(304, 222, new TextComponent(Objects.requireNonNull(tile.getType().getRegistryName()).toString())); + super(304, 222, Component.literal(Objects.requireNonNull(ForgeRegistries.BLOCK_ENTITY_TYPES.getKey(tile.getType())).toString())); this.tile = tile; this.editor = tile.getEditor(); @@ -164,7 +163,7 @@ public void drawBack(PoseStack stack, Point mouse, float partialFrame) { blit(stack, getFrame().x(), getFrame().y(), 0, 222, getFrame().width(), getFrame().height(), 512, 512); Font fontRenderer = getRoot().getFontRenderer(); - Component text = new TranslatableComponent(UL_PLACE_BLUEPRINT); + Component text = Component.translatable(UL_PLACE_BLUEPRINT); fontRenderer.draw(stack, text, getFrame().midX() - fontRenderer.width(text) / 2f, @@ -190,7 +189,7 @@ protected StatusDot getStatusDot() { protected void buildTooltip(List tooltip) { super.buildTooltip(tooltip); if (editor.getStateMachine().isSimulating()) { - tooltip.add(new TranslatableComponent(UL_SIM_RUNNING).withStyle(UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_SIM_RUNNING).withStyle(UNIFORM_GRAY)); } } } @@ -221,15 +220,15 @@ protected void buildTooltip(List tooltip) { ICCompilerLog log = editor.getStateMachine().getCompilerLog(); if (editor.getStateMachine().canTriggerCompile()) { - tooltip.add(new TranslatableComponent(UL_COMPILE_READY).withStyle(UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_COMPILE_READY).withStyle(UNIFORM_GRAY)); } if (editor.getStateMachine().isCompiling()) { - tooltip.add(new TranslatableComponent(UL_COMPILE_PROGRESS, log.getCompletedSteps(), log.getTotalSteps()).withStyle(UNIFORM_GRAY)); + tooltip.add(Component.translatable(UL_COMPILE_PROGRESS, log.getCompletedSteps(), log.getTotalSteps()).withStyle(UNIFORM_GRAY)); } if (editor.getStateMachine().didLastCompileFailed()) { - tooltip.add(new TranslatableComponent(UL_COMPILE_FAILED).withStyle(UNIFORM_RED)); + tooltip.add(Component.translatable(UL_COMPILE_FAILED).withStyle(UNIFORM_RED)); } ICWorkbenchCompileTab.appendProblemsInfo(log, tooltip); diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/init/FabricationClientInit.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/init/FabricationClientInit.java index 562cdb15e..d4e204c46 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/init/FabricationClientInit.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/init/FabricationClientInit.java @@ -12,6 +12,7 @@ import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.ForgeRegistries; import static mrtjp.projectred.fabrication.init.FabricationMenus.*; @@ -32,7 +33,7 @@ private static void clientSetup(final FMLClientSetupEvent event) { // Register models ModelRegistryHelper modelRegistryHelper = new ModelRegistryHelper(); - modelRegistryHelper.register(new ModelResourceLocation(FabricationParts.FABRICATED_GATE_ITEM.get().getRegistryName(), "inventory"), GatePartItemRenderer.INSTANCE); + modelRegistryHelper.register(new ModelResourceLocation(ForgeRegistries.ITEMS.getKey(FabricationParts.FABRICATED_GATE_ITEM.get()), "inventory"), GatePartItemRenderer.INSTANCE); // Register screens MenuScreens.register(PLOTTING_TABLE_CONTAINER.get(), PlottingTableScreen::new); diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/inventory/container/FabricationMachineContainer.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/inventory/container/FabricationMachineContainer.java index 4117d64cc..e49bed133 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/inventory/container/FabricationMachineContainer.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/inventory/container/FabricationMachineContainer.java @@ -7,7 +7,7 @@ import javax.annotation.Nullable; -public class FabricationMachineContainer extends BasePoweredTileContainer { +public abstract class FabricationMachineContainer extends BasePoweredTileContainer { private final FabricationMachineTile tile; diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/item/BaseSiliconWaferItem.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/item/BaseSiliconWaferItem.java index 246f43f6f..c3f793ded 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/item/BaseSiliconWaferItem.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/item/BaseSiliconWaferItem.java @@ -4,7 +4,6 @@ import mrtjp.projectred.fabrication.lithography.WaferType; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; @@ -30,8 +29,8 @@ public BaseSiliconWaferItem(WaferType waferType) { public void appendHoverText(ItemStack stack, @Nullable Level world, List tooltipList, TooltipFlag tooltipFlag) { super.appendHoverText(stack, world, tooltipList, tooltipFlag); - tooltipList.add(new TranslatableComponent(UL_SIZE).append(": " + waferType.getWaferWidth() + "nm x " + waferType.getWaferHeight() + "nm").withStyle(ChatFormatting.GRAY)); - tooltipList.add(new TranslatableComponent(UL_DEFECT_CHANCE).append(": " + waferType.getDefectRatePerUnitArea()*100 + "% / nm^2").withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.translatable(UL_SIZE).append(": " + waferType.getWaferWidth() + "nm x " + waferType.getWaferHeight() + "nm").withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.translatable(UL_DEFECT_CHANCE).append(": " + waferType.getDefectRatePerUnitArea()*100 + "% / nm^2").withStyle(ChatFormatting.GRAY)); } public WaferType getWaferType() { diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/item/EtchedSiliconWaferItem.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/item/EtchedSiliconWaferItem.java index 2051b79ea..ec91eb77c 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/item/EtchedSiliconWaferItem.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/item/EtchedSiliconWaferItem.java @@ -5,7 +5,6 @@ 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.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; @@ -31,16 +30,18 @@ public void appendHoverText(ItemStack stack, @Nullable Level world, List> 4) & 0xF)).withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.literal("Input mask: " + "0x" + Integer.toHexString(bmask & 0xF)).withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.literal("Output mask: " + "0x" + Integer.toHexString((bmask >> 4) & 0xF)).withStyle(ChatFormatting.GRAY)); // Wafer etching data - tooltipList.add(new TextComponent("Yield: " + tag.getDouble("yield")*100 + "%").withStyle(ChatFormatting.GRAY)); - tooltipList.add(new TextComponent("Defects: " + tag.getInt("defectCount")).withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.literal("Yield: " + tag.getDouble("yield")*100 + "%").withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.literal("Defects: " + tag.getInt("defectCount")).withStyle(ChatFormatting.GRAY)); byte[] defects = tag.getByteArray("defects"); int gridLen = tag.getInt("gridLen"); for (int y = 0; y < gridLen; y++) { @@ -49,7 +50,7 @@ public void appendHoverText(ItemStack stack, @Nullable Level world, List ").withStyle(ChatFormatting.RED) - .append(new TranslatableComponent(UL_CORRUPTED_DISCARD).withStyle(ChatFormatting.GRAY))); + tooltipList.add(Component.literal(" ").withStyle(ChatFormatting.RED) + .append(Component.translatable(UL_CORRUPTED_DISCARD).withStyle(ChatFormatting.GRAY))); return; } - tooltipList.add(new TranslatableComponent(UL_NAME).append(": " + blueprintTag.getString(KEY_IC_NAME)).withStyle(ChatFormatting.GRAY)); - tooltipList.add(new TranslatableComponent(UL_TILE_COUNT).append(": " + blueprintTag.getInt(KEY_TILE_COUNT)).withStyle(ChatFormatting.GRAY)); - tooltipList.add(new TranslatableComponent(UL_IO_TYPES).append(": ").withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.translatable(UL_NAME).append(": " + blueprintTag.getString(KEY_IC_NAME)).withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.translatable(UL_TILE_COUNT).append(": " + blueprintTag.getInt(KEY_TILE_COUNT)).withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.translatable(UL_IO_TYPES).append(": ").withStyle(ChatFormatting.GRAY)); InterfaceSpec spec = getInterfaceSpec(blueprintTag); - TextComponent indent = new TextComponent(" "); - tooltipList.add(indent.copy().append(new TranslatableComponent(UL_TOP)).append(": ").append(new TranslatableComponent(spec.getInterfaceType(0).getUnlocalName())).withStyle(ChatFormatting.GRAY)); - tooltipList.add(indent.copy().append(new TranslatableComponent(UL_RIGHT)).append(": ").append(new TranslatableComponent(spec.getInterfaceType(1).getUnlocalName())).withStyle(ChatFormatting.GRAY)); - tooltipList.add(indent.copy().append(new TranslatableComponent(UL_BOTTOM)).append(": ").append(new TranslatableComponent(spec.getInterfaceType(2).getUnlocalName())).withStyle(ChatFormatting.GRAY)); - tooltipList.add(indent.copy().append(new TranslatableComponent(UL_LEFT)).append(": ").append(new TranslatableComponent(spec.getInterfaceType(3).getUnlocalName())).withStyle(ChatFormatting.GRAY)); + Component indent = Component.literal(" "); + tooltipList.add(indent.copy().append(Component.translatable(UL_TOP)).append(": ").append(Component.translatable(spec.getInterfaceType(0).getUnlocalName())).withStyle(ChatFormatting.GRAY)); + tooltipList.add(indent.copy().append(Component.translatable(UL_RIGHT)).append(": ").append(Component.translatable(spec.getInterfaceType(1).getUnlocalName())).withStyle(ChatFormatting.GRAY)); + tooltipList.add(indent.copy().append(Component.translatable(UL_BOTTOM)).append(": ").append(Component.translatable(spec.getInterfaceType(2).getUnlocalName())).withStyle(ChatFormatting.GRAY)); + tooltipList.add(indent.copy().append(Component.translatable(UL_LEFT)).append(": ").append(Component.translatable(spec.getInterfaceType(3).getUnlocalName())).withStyle(ChatFormatting.GRAY)); - tooltipList.add(new TranslatableComponent(UL_INPUT_MASK).append(String.format(": 0x%X", spec.getInputMask())).withStyle(ChatFormatting.GRAY)); - tooltipList.add(new TranslatableComponent(UL_OUTPUT_MASK).append(String.format(": 0x%X", spec.getOutputMask())).withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.translatable(UL_INPUT_MASK).append(String.format(": 0x%X", spec.getInputMask())).withStyle(ChatFormatting.GRAY)); + tooltipList.add(Component.translatable(UL_OUTPUT_MASK).append(String.format(": 0x%X", spec.getOutputMask())).withStyle(ChatFormatting.GRAY)); int warningCount = getWarningCount(blueprintTag); int errorCount = getErrorCount(blueprintTag); if (warningCount > 0) { - tooltipList.add(new TextComponent(" ").withStyle(ChatFormatting.YELLOW) - .append(new TranslatableComponent(UL_UNIT_WARNINGS, warningCount).withStyle(ChatFormatting.GRAY))); + tooltipList.add(Component.literal(" ").withStyle(ChatFormatting.YELLOW) + .append(Component.translatable(UL_UNIT_WARNINGS, warningCount).withStyle(ChatFormatting.GRAY))); } if (errorCount > 0) { - tooltipList.add(new TextComponent(" ").withStyle(ChatFormatting.RED) - .append(new TranslatableComponent(UL_UNIT_ERRORS, errorCount).withStyle(ChatFormatting.GRAY))); + tooltipList.add(Component.literal(" ").withStyle(ChatFormatting.RED) + .append(Component.translatable(UL_UNIT_ERRORS, errorCount).withStyle(ChatFormatting.GRAY))); } if (!canFabricate(blueprintTag)) { - tooltipList.add(new TextComponent(" - ") - .append(new TranslatableComponent(UL_CANNOT_FABRICATE)).withStyle(ChatFormatting.RED)); + tooltipList.add(Component.literal(" - ") + .append(Component.translatable(UL_CANNOT_FABRICATE)).withStyle(ChatFormatting.RED)); } } - private static TranslatableComponent getBundledIOTextComponent(byte bmask, int r) { + private static Component getBundledIOTextComponent(byte bmask, int r) { int i = 0x01 << r; int o = 0x10 << r; - return new TranslatableComponent((bmask & i) != 0 ? UL_BUNDLED_INPUT : (bmask & o) != 0 ? UL_BUNDLED_OUTPUT : UL_IO_NONE); + return Component.translatable((bmask & i) != 0 ? UL_BUNDLED_INPUT : (bmask & o) != 0 ? UL_BUNDLED_OUTPUT : UL_IO_NONE); } public static ItemStack createPhotomaskStack(ItemStack blueprintStack) { diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/lithography/YieldCalculator.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/lithography/YieldCalculator.java index aab7ca107..8a95ac78d 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/lithography/YieldCalculator.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/lithography/YieldCalculator.java @@ -2,8 +2,6 @@ import mrtjp.projectred.lib.Size; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; import static mrtjp.projectred.fabrication.init.FabricationUnlocal.UL_DIMENSIONS_DIES_TOTAL; import static mrtjp.projectred.fabrication.init.FabricationUnlocal.UL_DIMENSIONS_NM; @@ -75,23 +73,23 @@ public double getMultiLayerYield() { public Component getDieDimensionsText() { Size dieSize = getDieSize(); - return new TranslatableComponent(UL_DIMENSIONS_NM, dieSize.width, dieSize.height); + return Component.translatable(UL_DIMENSIONS_NM, dieSize.width, dieSize.height); } public Component getWaferDimensionsText() { - return new TranslatableComponent(UL_DIMENSIONS_NM, waferType.getWaferWidth(), waferType.getWaferHeight()); + return Component.translatable(UL_DIMENSIONS_NM, waferType.getWaferWidth(), waferType.getWaferHeight()); } public Component getDieCountDimensionsText() { Size dieCount = getDieCount(); - return new TranslatableComponent(UL_DIMENSIONS_DIES_TOTAL, dieCount.width, dieCount.height, dieCount.width * dieCount.height); + return Component.translatable(UL_DIMENSIONS_DIES_TOTAL, dieCount.width, dieCount.height, dieCount.width * dieCount.height); } public Component getSingleLayerYieldText() { - return new TextComponent(String.format("%.2f%%", getSingleLayerYield() * 100)); + return Component.literal(String.format("%.2f%%", getSingleLayerYield() * 100)); } public Component getYieldText() { - return new TextComponent(String.format("%.2f%%", getMultiLayerYield() * 100)); + return Component.literal(String.format("%.2f%%", getMultiLayerYield() * 100)); } } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/LithographyTableTile.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/LithographyTableTile.java index 21db539d0..13af833a9 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/LithographyTableTile.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/LithographyTableTile.java @@ -15,7 +15,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Container; import net.minecraft.world.InteractionHand; @@ -83,7 +82,9 @@ public void readDesc(MCDataInput in) { @Override public InteractionResult onBlockActivated(Player player, InteractionHand hand, BlockHitResult hit) { if (!getLevel().isClientSide) { - ServerUtils.openContainer((ServerPlayer) player, new SimpleMenuProvider((id, inv, p) -> new LithographyTableContainer(inv, this, id), new TranslatableComponent(getBlockState().getBlock().getDescriptionId())), p -> p.writePos(getBlockPos())); + ServerUtils.openContainer((ServerPlayer) player, + new SimpleMenuProvider((id, inv, p) -> new LithographyTableContainer(inv, this, id), getBlockState().getBlock().getName()), + p -> p.writePos(getBlockPos())); } return InteractionResult.SUCCESS; diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/PackagingTableTile.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/PackagingTableTile.java index d3d3a8c52..3a0a05e79 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/PackagingTableTile.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/PackagingTableTile.java @@ -15,7 +15,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Container; import net.minecraft.world.InteractionHand; @@ -93,7 +93,7 @@ public void readDesc(MCDataInput in) { public InteractionResult onBlockActivated(Player player, InteractionHand hand, BlockHitResult hit) { if (!getLevel().isClientSide) { ServerUtils.openContainer((ServerPlayer) player, - new SimpleMenuProvider((id, inv, p) -> new PackagingTableContainer(inv, this, id), new TranslatableComponent(getBlockState().getBlock().getDescriptionId())), + new SimpleMenuProvider((id, inv, p) -> new PackagingTableContainer(inv, this, id), getBlockState().getBlock().getName()), p -> p.writePos(getBlockPos())); } diff --git a/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/PlottingTableTile.java b/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/PlottingTableTile.java index 55dcde9ff..eb716e730 100644 --- a/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/PlottingTableTile.java +++ b/fabrication/src/main/java/mrtjp/projectred/fabrication/tile/PlottingTableTile.java @@ -13,7 +13,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Container; import net.minecraft.world.InteractionHand; @@ -82,7 +81,7 @@ public void readDesc(MCDataInput in) { public InteractionResult onBlockActivated(Player player, InteractionHand hand, BlockHitResult hit) { if (!getLevel().isClientSide) { ServerUtils.openContainer((ServerPlayer) player, - new SimpleMenuProvider((id, inv, p) -> new PlottingTableContainer(inv, this, id), new TranslatableComponent(getBlockState().getBlock().getDescriptionId())), + new SimpleMenuProvider((id, inv, p) -> new PlottingTableContainer(inv, this, id), getBlockState().getBlock().getName()), p -> p.writePos(getBlockPos())); } diff --git a/fabrication/src/main/resources/META-INF/mods.toml b/fabrication/src/main/resources/META-INF/mods.toml index 78528e2f9..cce9764fd 100644 --- a/fabrication/src/main/resources/META-INF/mods.toml +++ b/fabrication/src/main/resources/META-INF/mods.toml @@ -23,7 +23,7 @@ Redstone. The way it was meant to be. [[dependencies.projectred_fabrication]] modId="minecraft" mandatory=true - versionRange="[1.18.2]" + versionRange="[1.19.2]" ordering="NONE" side="BOTH" [[dependencies.projectred_fabrication]] diff --git a/gradle.properties b/gradle.properties index 9ec0bd3c6..c9f50f369 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,15 @@ java_lang_version=17 -mc_version=1.18.2 -forge_version=40.2.4 +mc_version=1.19.2 +forge_version=43.3.0 mcp_mappings=official +mcp_mappings_version=1.19.2 mod_version=5.0 -ccl_version=4.1.4.+ -cbm_version=3.1.1.+ +ccl_version=4.3.2.+ +cbm_version=3.2.0.+ -jei_version=10.2.1.+ -cct_version=1.101.2 +jei_version=11.5.0.+ +cct_version=1.101.3 fabrication_version=0.1.0-alpha-15 diff --git a/illumination/build.gradle b/illumination/build.gradle index 8ee0e7a21..d56d93fb8 100644 --- a/illumination/build.gradle +++ b/illumination/build.gradle @@ -6,7 +6,7 @@ plugins { String mod_id = 'projectred_illumination' minecraft { - mappings channel: mcp_mappings, version: mc_version + mappings channel: mcp_mappings, version: mcp_mappings_version accessTransformer = file("../core/src/main/resources/META-INF/accesstransformer.cfg") runs { data { diff --git a/illumination/src/main/java/mrtjp/projectred/illumination/MultipartLightProperties.java b/illumination/src/main/java/mrtjp/projectred/illumination/MultipartLightProperties.java index 78fe27ade..b4150dd97 100644 --- a/illumination/src/main/java/mrtjp/projectred/illumination/MultipartLightProperties.java +++ b/illumination/src/main/java/mrtjp/projectred/illumination/MultipartLightProperties.java @@ -2,6 +2,7 @@ import codechicken.lib.colour.Colour; import codechicken.lib.colour.EnumColour; +import codechicken.lib.model.PerspectiveModelState; import codechicken.lib.raytracer.VoxelShapeCache; import codechicken.lib.render.CCModel; import codechicken.lib.render.CCRenderState; @@ -24,7 +25,6 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.ModelState; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.shapes.VoxelShape; @@ -120,7 +120,7 @@ public void renderItem(ItemStack stack, ItemTransforms.TransformType transformTy } //@formatter:off - @Override public ModelState getModelTransform() { return TransformUtils.DEFAULT_BLOCK; } + @Override public PerspectiveModelState getModelState() { return TransformUtils.DEFAULT_BLOCK; } @Override public boolean useAmbientOcclusion() { return false; } @Override public boolean isGui3d() { return true; } @Override public boolean usesBlockLight() { return true; } diff --git a/illumination/src/main/java/mrtjp/projectred/illumination/ProjectRedIllumination.java b/illumination/src/main/java/mrtjp/projectred/illumination/ProjectRedIllumination.java index e335808c9..cf66496ad 100644 --- a/illumination/src/main/java/mrtjp/projectred/illumination/ProjectRedIllumination.java +++ b/illumination/src/main/java/mrtjp/projectred/illumination/ProjectRedIllumination.java @@ -15,12 +15,12 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -33,7 +33,7 @@ public class ProjectRedIllumination { public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID); public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); - public static final DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, MOD_ID); + public static final DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MOD_ID); public static final DeferredRegister> PART_TYPES = DeferredRegister.create(MultipartType.MULTIPART_TYPES, MOD_ID); public static final SimpleCreativeTab ILLUMINATION_GROUP = new SimpleCreativeTab(MOD_ID, () -> new ItemStack(BlockLightType.ILLUMAR_LAMP.getBlock(EnumColour.RED.ordinal(), true))); @@ -68,14 +68,11 @@ private void onGatherDataEvent(final GatherDataEvent event) { DataGenerator generator = event.getGenerator(); ExistingFileHelper fileHelper = event.getExistingFileHelper(); - if (event.includeClient()) { - generator.addProvider(new IlluminationBlockStateModelProvider(generator, fileHelper)); - generator.addProvider(new IlluminationItemModelProvider(generator, fileHelper)); - generator.addProvider(new IlluminationLanguageProvider(generator)); - } - if (event.includeServer()) { - generator.addProvider(new IlluminationBlockLootProvider(generator)); - generator.addProvider(new IlluminationRecipeProvider(generator)); - } + generator.addProvider(event.includeClient(), new IlluminationBlockStateModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new IlluminationItemModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new IlluminationLanguageProvider(generator)); + + generator.addProvider(event.includeServer(), new IlluminationBlockLootProvider(generator)); + generator.addProvider(event.includeServer(), new IlluminationRecipeProvider(generator)); } } diff --git a/illumination/src/main/java/mrtjp/projectred/illumination/block/IllumarLampBlock.java b/illumination/src/main/java/mrtjp/projectred/illumination/block/IllumarLampBlock.java index e0d8c51cc..cec3bc090 100644 --- a/illumination/src/main/java/mrtjp/projectred/illumination/block/IllumarLampBlock.java +++ b/illumination/src/main/java/mrtjp/projectred/illumination/block/IllumarLampBlock.java @@ -4,6 +4,7 @@ import mrtjp.projectred.illumination.tile.IllumarLampTile; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; @@ -72,7 +73,7 @@ public void neighborChanged(BlockState state, Level world, BlockPos pos, Block b } @Override - public void tick(BlockState state, ServerLevel world, BlockPos pos, Random rand) { + public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource rand) { super.tick(state, world, pos, rand); boolean isLit = state.getValue(LIT); diff --git a/illumination/src/main/java/mrtjp/projectred/illumination/client/IllumarLampItemRenderer.java b/illumination/src/main/java/mrtjp/projectred/illumination/client/IllumarLampItemRenderer.java index 240474c16..1bca0b01b 100644 --- a/illumination/src/main/java/mrtjp/projectred/illumination/client/IllumarLampItemRenderer.java +++ b/illumination/src/main/java/mrtjp/projectred/illumination/client/IllumarLampItemRenderer.java @@ -1,5 +1,6 @@ package mrtjp.projectred.illumination.client; +import codechicken.lib.model.PerspectiveModelState; import codechicken.lib.model.bakedmodels.WrappedItemModel; import codechicken.lib.render.BlockRenderer; import codechicken.lib.render.CCRenderState; @@ -18,9 +19,12 @@ import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.ModelState; import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.levelgen.RandomState; +import org.jetbrains.annotations.Nullable; import java.util.Random; @@ -28,7 +32,7 @@ public class IllumarLampItemRenderer extends WrappedItemModel implements IItemRe private static final Cuboid6 BLOCK_BOUNDS = Cuboid6.full.copy().expand(-0.02D); private static final Cuboid6 GLOW_BOUNDS = Cuboid6.full.copy().expand(0.02D); - private static final Random random = new Random(); + private static final RandomSource random = RandomSource.create(); public IllumarLampItemRenderer(BakedModel wrapped) { super(wrapped); @@ -69,7 +73,7 @@ public void renderItem(ItemStack stack, ItemTransforms.TransformType transformTy } @Override - public ModelState getModelTransform() { + public @Nullable PerspectiveModelState getModelState() { return TransformUtils.DEFAULT_BLOCK; } diff --git a/illumination/src/main/java/mrtjp/projectred/illumination/client/MultipartLightPartRenderer.java b/illumination/src/main/java/mrtjp/projectred/illumination/client/MultipartLightPartRenderer.java index 2c76c1d24..9386e033c 100644 --- a/illumination/src/main/java/mrtjp/projectred/illumination/client/MultipartLightPartRenderer.java +++ b/illumination/src/main/java/mrtjp/projectred/illumination/client/MultipartLightPartRenderer.java @@ -18,13 +18,11 @@ private MultipartLightPartRenderer() { } @Override - public boolean renderStatic(MultipartLightPart part, @Nullable RenderType layer, CCRenderState ccrs) { + public void renderStatic(MultipartLightPart part, @Nullable RenderType layer, CCRenderState ccrs) { if (layer == null || layer == RenderType.cutout()) { ccrs.setBrightness(part.level(), part.pos()); part.getProperties().render(part, Vector3.ZERO, ccrs); - return true; } - return false; } @Override diff --git a/illumination/src/main/java/mrtjp/projectred/illumination/init/IlluminationClientInit.java b/illumination/src/main/java/mrtjp/projectred/illumination/init/IlluminationClientInit.java index 0a3fdd72b..cb4a4cd3d 100644 --- a/illumination/src/main/java/mrtjp/projectred/illumination/init/IlluminationClientInit.java +++ b/illumination/src/main/java/mrtjp/projectred/illumination/init/IlluminationClientInit.java @@ -16,6 +16,7 @@ import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.ForgeRegistries; import java.util.Objects; @@ -39,10 +40,10 @@ public static void init() { modelHelper.registerCallback(e -> { // Illumar lamp renderer for (int color = 0; color < 16; color++) { - ResourceLocation blockRL = Objects.requireNonNull(BlockLightType.ILLUMAR_LAMP.getBlock(color, true).getRegistryName()); + ResourceLocation blockRL = Objects.requireNonNull(ForgeRegistries.BLOCKS.getKey(BlockLightType.ILLUMAR_LAMP.getBlock(color, true))); // Override default BlockItem renderer for the lit variants to render lamp glow - BakedModel litModel = e.getModelRegistry().get(new ModelResourceLocation(blockRL, "lit=true")); - e.getModelRegistry().put( + BakedModel litModel = e.getModels().get(new ModelResourceLocation(blockRL, "lit=true")); + e.getModels().put( new ModelResourceLocation(blockRL, "inventory"), new IllumarLampItemRenderer(litModel)); } diff --git a/illumination/src/main/java/mrtjp/projectred/illumination/init/IlluminationMicroMaterials.java b/illumination/src/main/java/mrtjp/projectred/illumination/init/IlluminationMicroMaterials.java index 7196242cc..63b54c334 100644 --- a/illumination/src/main/java/mrtjp/projectred/illumination/init/IlluminationMicroMaterials.java +++ b/illumination/src/main/java/mrtjp/projectred/illumination/init/IlluminationMicroMaterials.java @@ -1,27 +1,27 @@ package mrtjp.projectred.illumination.init; -import codechicken.microblock.api.MicroMaterial; +import codechicken.microblock.api.BlockMicroMaterial; +import codechicken.microblock.util.MicroMaterialRegistry; import mrtjp.projectred.illumination.BlockLightType; import mrtjp.projectred.illumination.part.IllumarLampMicroMaterial; -import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.registries.RegisterEvent; public class IlluminationMicroMaterials { public static void register() { - // Register mixin - // Nothing to do. IllumarLampMicroblock is registered via annotation + // Cannot register deferred since MicroMaterialRegistry.MICRO_MATERIALS registry is null at this point. + // So we register during registry event below } @SubscribeEvent - @SuppressWarnings({"unchecked","rawtypes"}) - public void onRegisterMicroMaterials(RegistryEvent.Register event) { - if (event.getGenericType() == MicroMaterial.class) { - // Illumar lamp microblocks + public void onRegisterMicroMaterials(RegisterEvent event) { + event.register(MicroMaterialRegistry.MICRO_MATERIALS.getRegistryKey(), r -> { for (int color = 0; color < 16; color++) { int colorFinal = color; - event.getRegistry().register(new IllumarLampMicroMaterial(() -> BlockLightType.ILLUMAR_LAMP.getBlock(colorFinal, true))); + IllumarLampMicroMaterial material = new IllumarLampMicroMaterial(() -> BlockLightType.ILLUMAR_LAMP.getBlock(colorFinal, true)); + r.register(BlockMicroMaterial.makeMaterialKey(material.state), material); } - } + }); } } diff --git a/illumination/src/main/java/mrtjp/projectred/illumination/part/IllumarLampMicroMaterial.java b/illumination/src/main/java/mrtjp/projectred/illumination/part/IllumarLampMicroMaterial.java index 9db90fab8..f3ae940e0 100644 --- a/illumination/src/main/java/mrtjp/projectred/illumination/part/IllumarLampMicroMaterial.java +++ b/illumination/src/main/java/mrtjp/projectred/illumination/part/IllumarLampMicroMaterial.java @@ -59,7 +59,7 @@ public RenderType getItemRenderLayer() { // Delegate the rest to super material //@formatter:off - @Override public boolean renderCuboids(CCRenderState ccrs, @Nullable RenderType layer, Iterable cuboids) { return superMicroMaterial.renderCuboids(ccrs, layer, cuboids); } + @Override public void renderCuboids(CCRenderState ccrs, @Nullable RenderType layer, Iterable cuboids) { superMicroMaterial.renderCuboids(ccrs, layer, cuboids); } @Override public void addHitEffects(MicroblockPart part, PartRayTraceResult hit, ParticleEngine engine) { superMicroMaterial.addHitEffects(part, hit, engine); } @Override public void addDestroyEffects(MicroblockPart part, PartRayTraceResult hit, ParticleEngine engine) { superMicroMaterial.addDestroyEffects(part, hit, engine); } @Override public void addLandingEffects(MicroblockPart part, PartRayTraceResult hit, Vector3 entity, int numberOfParticles) { superMicroMaterial.addLandingEffects(part, hit, entity, numberOfParticles); } diff --git a/illumination/src/main/resources/META-INF/mods.toml b/illumination/src/main/resources/META-INF/mods.toml index ba8f626c1..c6445dace 100644 --- a/illumination/src/main/resources/META-INF/mods.toml +++ b/illumination/src/main/resources/META-INF/mods.toml @@ -23,7 +23,7 @@ Redstone. The way it was meant to be. [[dependencies.projectred_illumination]] modId="minecraft" mandatory=true - versionRange="[1.18.2]" + versionRange="[1.19.2]" ordering="NONE" side="BOTH" [[dependencies.projectred_illumination]] diff --git a/integration/build.gradle b/integration/build.gradle index 77bcc00fd..b53f7bd2d 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -6,7 +6,7 @@ plugins { String mod_id = 'projectred_integration' minecraft { - mappings channel: mcp_mappings, version: mc_version + mappings channel: mcp_mappings, version: mcp_mappings_version accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg") runs { data { diff --git a/integration/src/main/java/mrtjp/projectred/integration/ProjectRedIntegration.java b/integration/src/main/java/mrtjp/projectred/integration/ProjectRedIntegration.java index 35a5393b5..153c89878 100644 --- a/integration/src/main/java/mrtjp/projectred/integration/ProjectRedIntegration.java +++ b/integration/src/main/java/mrtjp/projectred/integration/ProjectRedIntegration.java @@ -11,12 +11,12 @@ import net.minecraft.world.item.Item; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; @@ -60,12 +60,9 @@ private void onGatherDataEvent(final GatherDataEvent event) { DataGenerator generator = event.getGenerator(); ExistingFileHelper fileHelper = event.getExistingFileHelper(); - if (event.includeClient()) { - generator.addProvider(new IntegrationItemModelProvider(generator, fileHelper)); - generator.addProvider(new IntegrationLanguageProvider(generator)); - } - if (event.includeServer()) { - generator.addProvider(new IntegrationRecipeProvider(generator)); - } + generator.addProvider(event.includeClient(), new IntegrationItemModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new IntegrationLanguageProvider(generator)); + + generator.addProvider(event.includeServer(), new IntegrationRecipeProvider(generator)); } } diff --git a/integration/src/main/java/mrtjp/projectred/integration/client/GateComponentModels.java b/integration/src/main/java/mrtjp/projectred/integration/client/GateComponentModels.java index 34cf2ea06..1594bd41b 100644 --- a/integration/src/main/java/mrtjp/projectred/integration/client/GateComponentModels.java +++ b/integration/src/main/java/mrtjp/projectred/integration/client/GateComponentModels.java @@ -26,7 +26,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceLocation; import javax.annotation.Nullable; @@ -1498,7 +1497,7 @@ public void renderModel(Transformation t, int orient, CCRenderState ccrs) { public void renderName(String name, PoseStack mStack, Transformation t1) { - Component nameComponent = new TextComponent(name).withStyle(UNIFORM); + Component nameComponent = Component.literal(name).withStyle(UNIFORM); Font fr = Minecraft.getInstance().font; // Calculate font scale diff --git a/integration/src/main/java/mrtjp/projectred/integration/client/GateModelRenderer.java b/integration/src/main/java/mrtjp/projectred/integration/client/GateModelRenderer.java index dbc895c01..3712e9620 100644 --- a/integration/src/main/java/mrtjp/projectred/integration/client/GateModelRenderer.java +++ b/integration/src/main/java/mrtjp/projectred/integration/client/GateModelRenderer.java @@ -20,10 +20,14 @@ import net.minecraft.core.particles.DustParticleOptions; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.util.RandomSource; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; import static mrtjp.projectred.core.part.IOrientableFacePart.flipMaskZ; import static mrtjp.projectred.integration.client.GateComponentModels.*; @@ -122,7 +126,7 @@ public void renderInventory(CCRenderState ccrs, @Nullable ItemStack stack, int r } //endregion - public void spawnParticles(GatePart part, Random random) { + public void spawnParticles(GatePart part, RandomSource random) { GateRenderer r = getRenderer(part.getGateType().ordinal()); r.prepare(part); r.spawnParticles(part, random); @@ -177,7 +181,7 @@ public void renderStatic(CCRenderState ccrs, int orient, Transformation t) { renderModels(ccrs, reflect ? orient + 24 : orient, t); } - public void spawnParticles(GatePart gate, Random random) { + public void spawnParticles(GatePart gate, RandomSource random) { List torches = new LinkedList<>(); for (ComponentModel m : getModels()) { diff --git a/integration/src/main/java/mrtjp/projectred/integration/client/GatePartItemRenderer.java b/integration/src/main/java/mrtjp/projectred/integration/client/GatePartItemRenderer.java index a229bbd80..d81aeaf47 100644 --- a/integration/src/main/java/mrtjp/projectred/integration/client/GatePartItemRenderer.java +++ b/integration/src/main/java/mrtjp/projectred/integration/client/GatePartItemRenderer.java @@ -1,5 +1,6 @@ package mrtjp.projectred.integration.client; +import codechicken.lib.model.PerspectiveModelState; import codechicken.lib.render.CCRenderState; import codechicken.lib.render.item.IItemRenderer; import codechicken.lib.util.TransformUtils; @@ -9,8 +10,8 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.resources.model.ModelState; import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.Nullable; public class GatePartItemRenderer implements IItemRenderer { @@ -32,7 +33,7 @@ public boolean usesBlockLight() { } @Override - public ModelState getModelTransform() { + public @Nullable PerspectiveModelState getModelState() { return TransformUtils.DEFAULT_BLOCK; } diff --git a/integration/src/main/java/mrtjp/projectred/integration/client/GatePartRenderer.java b/integration/src/main/java/mrtjp/projectred/integration/client/GatePartRenderer.java index b7d750cab..48d347c36 100644 --- a/integration/src/main/java/mrtjp/projectred/integration/client/GatePartRenderer.java +++ b/integration/src/main/java/mrtjp/projectred/integration/client/GatePartRenderer.java @@ -21,13 +21,11 @@ private GatePartRenderer() { } @Override - public boolean renderStatic(GatePart part, @Nullable RenderType layer, CCRenderState ccrs) { + public void renderStatic(GatePart part, @Nullable RenderType layer, CCRenderState ccrs) { if (layer == null || (layer == RenderType.cutout() && Configurator.staticGates)) { ccrs.setBrightness(part.level(), part.pos()); GateModelRenderer.instance().renderStatic(ccrs, part, RedundantTransformation.INSTANCE); - return true; } - return false; } @Override diff --git a/integration/src/main/java/mrtjp/projectred/integration/gui/screen/CounterScreen.java b/integration/src/main/java/mrtjp/projectred/integration/gui/screen/CounterScreen.java index 9c577d074..d95ed1de7 100644 --- a/integration/src/main/java/mrtjp/projectred/integration/gui/screen/CounterScreen.java +++ b/integration/src/main/java/mrtjp/projectred/integration/gui/screen/CounterScreen.java @@ -9,7 +9,7 @@ import mrtjp.projectred.lib.Point; import mrtjp.projectred.redui.ButtonNode; import mrtjp.projectred.redui.RedUIScreen; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import java.util.Objects; @@ -24,7 +24,7 @@ public class CounterScreen extends RedUIScreen { private final ComplexGatePart.ICounterGuiLogic counterGate; public CounterScreen(GatePart gate) { - super(256, 145, new TextComponent(Objects.requireNonNull(gate.getType().getRegistryName()).toString())); + super(256, 145, Component.translatable(gate.getType().getRegistryName().toString())); this.gate = gate; this.counterGate = (ComplexGatePart.ICounterGuiLogic) gate; diff --git a/integration/src/main/java/mrtjp/projectred/integration/gui/screen/TimerScreen.java b/integration/src/main/java/mrtjp/projectred/integration/gui/screen/TimerScreen.java index 1e32dd39c..1c216a198 100644 --- a/integration/src/main/java/mrtjp/projectred/integration/gui/screen/TimerScreen.java +++ b/integration/src/main/java/mrtjp/projectred/integration/gui/screen/TimerScreen.java @@ -9,7 +9,7 @@ import mrtjp.projectred.lib.Point; import mrtjp.projectred.redui.ButtonNode; import mrtjp.projectred.redui.RedUIScreen; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import java.util.Objects; @@ -24,7 +24,7 @@ public class TimerScreen extends RedUIScreen { private final ComplexGatePart.ITimerGuiLogic timerGate; public TimerScreen(GatePart gate) { - super(256, 55, new TextComponent(Objects.requireNonNull(gate.getType().getRegistryName()).toString())); + super(256, 55, Component.literal(Objects.requireNonNull(gate.getType().getRegistryName()).toString())); this.gate = gate; this.timerGate = (ComplexGatePart.ITimerGuiLogic) gate; diff --git a/integration/src/main/java/mrtjp/projectred/integration/part/RedstoneGatePart.java b/integration/src/main/java/mrtjp/projectred/integration/part/RedstoneGatePart.java index 9aeec01b4..0c67d1307 100644 --- a/integration/src/main/java/mrtjp/projectred/integration/part/RedstoneGatePart.java +++ b/integration/src/main/java/mrtjp/projectred/integration/part/RedstoneGatePart.java @@ -17,6 +17,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RedStoneWireBlock; @@ -256,7 +257,7 @@ protected int getInput(int mask) { //region Rendering @Override - public void animateTick(Random random) { + public void animateTick(RandomSource random) { // client side only GateModelRenderer.instance().spawnParticles(this, random); } diff --git a/integration/src/main/resources/META-INF/mods.toml b/integration/src/main/resources/META-INF/mods.toml index 7aa4950d5..f0c66d7e8 100644 --- a/integration/src/main/resources/META-INF/mods.toml +++ b/integration/src/main/resources/META-INF/mods.toml @@ -23,7 +23,7 @@ Redstone. The way it was meant to be. [[dependencies.projectred_integration]] modId="minecraft" mandatory=true - versionRange="[1.18.2]" + versionRange="[1.19.2]" ordering="NONE" side="BOTH" [[dependencies.projectred_integration]] diff --git a/transmission/build.gradle b/transmission/build.gradle index 2b128fc74..f537527ba 100644 --- a/transmission/build.gradle +++ b/transmission/build.gradle @@ -8,7 +8,7 @@ apply plugin: 'net.minecraftforge.gradle' String mod_id = 'projectred_transmission' minecraft { - mappings channel: mcp_mappings, version: mc_version + mappings channel: mcp_mappings, version: mcp_mappings_version accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg") runs { data { diff --git a/transmission/src/main/java/mrtjp/projectred/transmission/ProjectRedTransmission.java b/transmission/src/main/java/mrtjp/projectred/transmission/ProjectRedTransmission.java index 1142863b7..e1fabb2db 100644 --- a/transmission/src/main/java/mrtjp/projectred/transmission/ProjectRedTransmission.java +++ b/transmission/src/main/java/mrtjp/projectred/transmission/ProjectRedTransmission.java @@ -15,13 +15,13 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.event.server.ServerAboutToStartEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -65,15 +65,11 @@ private void onGatherDataEvent(final GatherDataEvent event) { DataGenerator generator = event.getGenerator(); ExistingFileHelper fileHelper = event.getExistingFileHelper(); - if (event.includeClient()) { - generator.addProvider(new TransmissionItemModelProvider(generator, fileHelper)); - generator.addProvider(new TransmissionLanguageProvider(generator)); - } - if (event.includeServer()) { - generator.addProvider(new TransmissionItemTagsProvider(generator, fileHelper)); - generator.addProvider(new TransmissionRecipeProvider(generator)); - } + generator.addProvider(event.includeClient(), new TransmissionItemModelProvider(generator, fileHelper)); + generator.addProvider(event.includeClient(), new TransmissionLanguageProvider(generator)); + generator.addProvider(event.includeServer(), new TransmissionItemTagsProvider(generator, fileHelper)); + generator.addProvider(event.includeServer(), new TransmissionRecipeProvider(generator)); } private void onServerStartEvent(final ServerAboutToStartEvent event) { diff --git a/transmission/src/main/java/mrtjp/projectred/transmission/client/CenterWirePartRenderer.java b/transmission/src/main/java/mrtjp/projectred/transmission/client/CenterWirePartRenderer.java index 2f21eed06..9573be2e9 100644 --- a/transmission/src/main/java/mrtjp/projectred/transmission/client/CenterWirePartRenderer.java +++ b/transmission/src/main/java/mrtjp/projectred/transmission/client/CenterWirePartRenderer.java @@ -16,13 +16,11 @@ public class CenterWirePartRenderer implements PartRenderer public static final CenterWirePartRenderer INSTANCE = new CenterWirePartRenderer(); @Override - public boolean renderStatic(BaseCenterWirePart part, @Nullable RenderType layer, CCRenderState ccrs) { + public void renderStatic(BaseCenterWirePart part, @Nullable RenderType layer, CCRenderState ccrs) { if (layer == null || (layer == RenderType.cutout() && part.useStaticRenderer())) { ccrs.setBrightness(part.level(), part.pos()); FramedWireModelRenderer.render(ccrs, part); - return true; } - return false; } @Override diff --git a/transmission/src/main/java/mrtjp/projectred/transmission/client/FaceWirePartRenderer.java b/transmission/src/main/java/mrtjp/projectred/transmission/client/FaceWirePartRenderer.java index 2ec98c33f..d4ac70e41 100644 --- a/transmission/src/main/java/mrtjp/projectred/transmission/client/FaceWirePartRenderer.java +++ b/transmission/src/main/java/mrtjp/projectred/transmission/client/FaceWirePartRenderer.java @@ -18,13 +18,11 @@ public class FaceWirePartRenderer implements PartRenderer { public static final FaceWirePartRenderer INSTANCE = new FaceWirePartRenderer(); @Override - public boolean renderStatic(BaseFaceWirePart part, @Nullable RenderType layer, CCRenderState ccrs) { + public void renderStatic(BaseFaceWirePart part, @Nullable RenderType layer, CCRenderState ccrs) { if (layer == null || (layer == RenderType.solid() && useStaticRenderer(part))) { ccrs.setBrightness(part.level(), part.pos()); WireModelRenderer.render(ccrs, part); - return true; } - return false; } @Override diff --git a/transmission/src/main/java/mrtjp/projectred/transmission/client/FramedWirePartItemRenderer.java b/transmission/src/main/java/mrtjp/projectred/transmission/client/FramedWirePartItemRenderer.java index 1bfeeb168..98cf030df 100644 --- a/transmission/src/main/java/mrtjp/projectred/transmission/client/FramedWirePartItemRenderer.java +++ b/transmission/src/main/java/mrtjp/projectred/transmission/client/FramedWirePartItemRenderer.java @@ -1,5 +1,6 @@ package mrtjp.projectred.transmission.client; +import codechicken.lib.model.PerspectiveModelState; import codechicken.lib.render.CCRenderState; import codechicken.lib.render.item.IItemRenderer; import codechicken.lib.util.TransformUtils; @@ -10,7 +11,6 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.resources.model.ModelState; import net.minecraft.world.item.ItemStack; public class FramedWirePartItemRenderer implements IItemRenderer { @@ -35,7 +35,7 @@ public boolean usesBlockLight() { } @Override - public ModelState getModelTransform() { + public PerspectiveModelState getModelState() { return TransformUtils.DEFAULT_BLOCK; } diff --git a/transmission/src/main/java/mrtjp/projectred/transmission/client/WirePartItemRenderer.java b/transmission/src/main/java/mrtjp/projectred/transmission/client/WirePartItemRenderer.java index f71e7468f..c0788e70e 100644 --- a/transmission/src/main/java/mrtjp/projectred/transmission/client/WirePartItemRenderer.java +++ b/transmission/src/main/java/mrtjp/projectred/transmission/client/WirePartItemRenderer.java @@ -1,5 +1,6 @@ package mrtjp.projectred.transmission.client; +import codechicken.lib.model.PerspectiveModelState; import codechicken.lib.render.CCRenderState; import codechicken.lib.render.item.IItemRenderer; import codechicken.lib.util.TransformUtils; @@ -10,7 +11,6 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.resources.model.ModelState; import net.minecraft.world.item.ItemStack; public class WirePartItemRenderer implements IItemRenderer { @@ -35,7 +35,7 @@ public boolean usesBlockLight() { } @Override - public ModelState getModelTransform() { + public PerspectiveModelState getModelState() { return TransformUtils.DEFAULT_BLOCK; } diff --git a/transmission/src/main/java/mrtjp/projectred/transmission/data/TransmissionRecipeProvider.java b/transmission/src/main/java/mrtjp/projectred/transmission/data/TransmissionRecipeProvider.java index 0428f5b12..bfdc581b4 100644 --- a/transmission/src/main/java/mrtjp/projectred/transmission/data/TransmissionRecipeProvider.java +++ b/transmission/src/main/java/mrtjp/projectred/transmission/data/TransmissionRecipeProvider.java @@ -10,6 +10,7 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraftforge.common.Tags; +import net.minecraftforge.registries.ForgeRegistries; import static mrtjp.projectred.core.init.CoreItems.*; import static mrtjp.projectred.core.init.CoreTags.ELECTROTINE_ALLOY_INGOT_TAG; @@ -48,7 +49,7 @@ protected void registerRecipes() { .patternLine("WRW") .patternLine("WRW"); // Re-colouring recipe - shapelessRecipe(w, 1, new ResourceLocation(w.getRegistryName() + "_re_color")) + shapelessRecipe(w, 1, new ResourceLocation(ForgeRegistries.ITEMS.getKey(w) + "_re_color")) .addIngredient(INSULATED_WIRE_ITEM_TAG) .addIngredient(getDyeTag(type.getColour())); } @@ -63,7 +64,7 @@ protected void registerRecipes() { for (WireType type : WireType.COLOURED_BUNDLED_WIRES) { Item w = type.getItem(); // Recolouring recipe - shapelessRecipe(w, 1, new ResourceLocation(w.getRegistryName() + "_re_color")) + shapelessRecipe(w, 1, new ResourceLocation(ForgeRegistries.ITEMS.getKey(w) + "_re_color")) .addIngredient(BUNDLED_WIRE_ITEM_TAG) .addIngredient(getDyeTag(type.getColour())); } @@ -89,7 +90,7 @@ protected void registerRecipes() { framedWireRecipe(w, WireType.INSULATED_WIRES[i].getItem()); // Re-colouring recipe - shapelessRecipe(w, 1, new ResourceLocation(w.getRegistryName() + "_re_color")) + shapelessRecipe(w, 1, new ResourceLocation(ForgeRegistries.ITEMS.getKey(w) + "_re_color")) .addIngredient(FRAMED_INSULATED_WIRE_ITEM_TAG) .addIngredient(getDyeTag(type.getColour())); } @@ -103,7 +104,7 @@ protected void registerRecipes() { framedWireRecipe(w, WireType.COLOURED_BUNDLED_WIRES[i].getItem()); // Re-colouring recipe - shapelessRecipe(w, 1, new ResourceLocation(w.getRegistryName() + "_re_color")) + shapelessRecipe(w, 1, new ResourceLocation(ForgeRegistries.ITEMS.getKey(w) + "_re_color")) .addIngredient(FRAMED_BUNDLED_WIRE_ITEM_TAG) .addIngredient(getDyeTag(type.getColour())); } @@ -112,14 +113,14 @@ protected void registerRecipes() { framedWireRecipe(WireType.FRAMED_POWER_LOWLOAD.getItem(), WireType.POWER_LOWLOAD.getItem()); // Wired plate - shapedRecipe(WIRED_PLATE_ITEM.get(), 1, new ResourceLocation(MOD_ID, WIRED_PLATE_ITEM.get().getRegistryName().getPath())) + shapedRecipe(WIRED_PLATE_ITEM.get(), 1, new ResourceLocation(MOD_ID, ForgeRegistries.ITEMS.getKey(WIRED_PLATE_ITEM.get()).getPath())) .key('W', WireType.RED_ALLOY.getItem()) .key('P', PLATE_ITEM.get()) .patternLine("W") .patternLine("P"); // Bundled plate - shapedRecipe(BUNDLED_PLATE_ITEM.get(), 1, new ResourceLocation(MOD_ID, BUNDLED_PLATE_ITEM.get().getRegistryName().getPath())) + shapedRecipe(BUNDLED_PLATE_ITEM.get(), 1, new ResourceLocation(MOD_ID, ForgeRegistries.ITEMS.getKey(BUNDLED_PLATE_ITEM.get()).getPath())) .key('W', BUNDLED_WIRE_ITEM_TAG) .key('P', PLATE_ITEM.get()) .patternLine("W") diff --git a/transmission/src/main/java/mrtjp/projectred/transmission/part/BaseCenterWirePart.java b/transmission/src/main/java/mrtjp/projectred/transmission/part/BaseCenterWirePart.java index 10d64e72c..db2d9cca3 100644 --- a/transmission/src/main/java/mrtjp/projectred/transmission/part/BaseCenterWirePart.java +++ b/transmission/src/main/java/mrtjp/projectred/transmission/part/BaseCenterWirePart.java @@ -117,7 +117,7 @@ public void writeDesc(MCDataOutput packet) { packet.writeByte(packedConnMap()); packet.writeBoolean(material != null); if (material != null) { - packet.writeRegistryIdUnsafe(MicroMaterialRegistry.MICRO_MATERIALS, material); + packet.writeRegistryIdDirect(MicroMaterialRegistry.MICRO_MATERIALS, material); } } @@ -126,7 +126,7 @@ public void readDesc(MCDataInput packet) { super.readDesc(packet); connMap = packet.readUByte(); if (packet.readBoolean()) { - material = packet.readRegistryIdUnsafe(MicroMaterialRegistry.MICRO_MATERIALS); + material = packet.readRegistryIdDirect(MicroMaterialRegistry.MICRO_MATERIALS); } } @@ -138,7 +138,7 @@ protected void read(MCDataInput packet, int key) { if (useStaticRenderer()) tile().markRender(); break; case KEY_MATERIAL: - material = packet.readRegistryIdUnsafe(MicroMaterialRegistry.MICRO_MATERIALS); + material = packet.readRegistryIdDirect(MicroMaterialRegistry.MICRO_MATERIALS); if (useStaticRenderer()) tile().markRender(); break; case KEY_REMOVE_MATERIAL: @@ -159,7 +159,7 @@ protected void sendMaterialUpdate() { if (material == null) { sendUpdate(KEY_REMOVE_MATERIAL, p -> {}); } else { - sendUpdate(KEY_MATERIAL, p -> p.writeRegistryIdUnsafe(MicroMaterialRegistry.MICRO_MATERIALS, material)); + sendUpdate(KEY_MATERIAL, p -> p.writeRegistryIdDirect(MicroMaterialRegistry.MICRO_MATERIALS, material)); } } diff --git a/transmission/src/main/resources/META-INF/mods.toml b/transmission/src/main/resources/META-INF/mods.toml index 90790b05b..8b8ccd93a 100644 --- a/transmission/src/main/resources/META-INF/mods.toml +++ b/transmission/src/main/resources/META-INF/mods.toml @@ -24,7 +24,7 @@ Redstone. The way it was meant to be. [[dependencies.projectred_transmission]] modId="minecraft" mandatory=true - versionRange="[1.18.2]" + versionRange="[1.19.2]" ordering="NONE" side="BOTH" [[dependencies.projectred_transmission]]