From effa6d95218aa4934390552f4619410677667a65 Mon Sep 17 00:00:00 2001 From: alpha Date: Sat, 30 Jul 2022 15:42:27 -0500 Subject: [PATCH] Update to 1.19.1 and fix #2 --- build.gradle | 10 +- gradle.properties | 5 +- .../machines/api/core/Constants.java | 2 + .../machines/datagen/BlockLootGenerator.java | 94 ------------------- .../compactmods/machines/CompactMachines.java | 66 ++++++------- .../machines/client/ClientEventHandler.java | 2 - .../client/gui/widget/PSDIconButton.java | 4 +- .../machines/command/Commands.java | 5 +- .../compat/rei/CompactMachinesReiPlugin.java | 8 +- .../theoneprobe/providers/TunnelProvider.java | 2 +- .../compactmods/machines/core/Registries.java | 23 +++-- .../machines/core/UIRegistration.java | 4 - .../machines/datagen/BlockLootGenerator.java | 23 ++--- .../datagen/lang/EnglishLangGenerator.java | 1 + .../machines/dimension/Dimension.java | 3 +- .../machines/dimension/VoidAirBlock.java | 7 +- .../dev/compactmods/machines/graph/Graph.java | 9 +- .../machines/location/SimpleTeleporter.java | 2 +- .../machine/CompactMachineBlockEntity.java | 1 + .../machines/machine/Machines.java | 2 +- .../machines/room/RoomCapabilities.java | 19 +--- .../machines/room/data/LootFunctions.java | 2 +- .../PlayerStartedRoomTrackingPacket.java | 2 +- .../machines/shrinking/Shrinking.java | 2 +- .../machines/tunnel/TunnelItem.java | 2 +- .../machines/tunnel/TunnelWallBlock.java | 1 + .../machines/tunnel/TunnelWallEntity.java | 2 + .../compactmods/machines/tunnel/Tunnels.java | 10 +- .../tunnel/graph/TunnelConnectionGraph.java | 6 +- .../machines/upgrade/MachineRoomUpgrades.java | 4 +- .../machines/upgrade/RoomUpgradeItem.java | 2 +- .../machines/upgrade/RoomUpgradeManager.java | 10 +- .../upgrade/command/RoomUpgradeArgument.java | 6 +- .../upgrade/graph/RoomUpgradeConnection.java | 2 +- .../upgrade/graph/UpgradeConnectionEntry.java | 2 +- .../compactmods/machines/util/PlayerUtil.java | 2 +- .../dev/compactmods/machines/wall/Walls.java | 2 +- src/main/resources/fabric.mod.json | 2 +- 38 files changed, 117 insertions(+), 234 deletions(-) delete mode 100644 src/datagen/java/dev/compactmods/machines/datagen/BlockLootGenerator.java diff --git a/build.gradle b/build.gradle index 9714609c..0622bb04 100644 --- a/build.gradle +++ b/build.gradle @@ -130,15 +130,15 @@ dependencies { mappings loom.officialMojangMappings() modImplementation("net.fabricmc:fabric-loader:${project.loader_version}") modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") - modImplementation(include("io.github.fabricators_of_create:Porting-Lib:${project.port_lib_version}+${project.minecraft_version}.${project.port_lib_hash}")) + modImplementation(include("io.github.fabricators_of_create:Porting-Lib:${project.port_lib_version}+${project.minecraft_version}")) modImplementation(include("me.alphamode:ForgeTags:${project.forge_tags_version}")) // REI modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}") - modImplementation("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") + modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") // JEI - modCompileOnly("mezz.jei:jei-${project.minecraft_version}-fabric:${project.jei_version}") { transitive = false } + modImplementation("mezz.jei:jei-${project.minecraft_version}-fabric:${project.jei_version}") { transitive = false } include modApi('teamreborn:energy:2.2.0') { exclude(group: "net.fabricmc.fabric-api") @@ -153,7 +153,7 @@ dependencies { // runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-1.16:${top_version}") // Nicephore - Screenshots and Stuff - modRuntimeOnly("curse.maven:nicephore-fabric-405990:3848375") +// modRuntimeOnly("curse.maven:nicephore-fabric-405990:3848375") // Shut up Experimental Settings - so we don't have to deal with that CONSTANTLY modRuntimeOnly("curse.maven:fabric-disable-custom-worlds-advice-401978:3827588") @@ -199,7 +199,7 @@ processResources { properties.put("loader_version", project.loader_version) properties.put("fabric_version", project.fabric_version) properties.put("minecraft_version", project.minecraft_version) - properties.put("port_lib_version", "${project.port_lib_version}+${project.minecraft_version}.${project.port_lib_hash}") + properties.put("port_lib_version", "${project.port_lib_version}+${project.minecraft_version}") properties.forEach((k, v) -> inputs.property(k, v)) diff --git a/gradle.properties b/gradle.properties index a14365df..b3d6670f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,10 +12,9 @@ mod_id=compactmachines # Dependencies and Libs jei_mc_version=1.19.1 jei_version=11.2.0.241 -rei_version=9.1.517 +rei_version=9.1.518 top_version=1.19-6.0.0 -port_lib_version=2.0.422 -port_lib_hash=26b170a +port_lib_version=2.0.437 forge_tags_version=2.2 night_config_toml_version=3.6.3 night_config_core_version=3.6.3 diff --git a/src/api/java/dev/compactmods/machines/api/core/Constants.java b/src/api/java/dev/compactmods/machines/api/core/Constants.java index 09b0af61..bf3c4191 100644 --- a/src/api/java/dev/compactmods/machines/api/core/Constants.java +++ b/src/api/java/dev/compactmods/machines/api/core/Constants.java @@ -1,5 +1,7 @@ package dev.compactmods.machines.api.core; +import net.minecraft.resources.ResourceLocation; + public abstract class Constants { public static final String MOD_ID = "compactmachines"; diff --git a/src/datagen/java/dev/compactmods/machines/datagen/BlockLootGenerator.java b/src/datagen/java/dev/compactmods/machines/datagen/BlockLootGenerator.java deleted file mode 100644 index 53118ec3..00000000 --- a/src/datagen/java/dev/compactmods/machines/datagen/BlockLootGenerator.java +++ /dev/null @@ -1,94 +0,0 @@ -package dev.compactmods.machines.datagen; - -import com.google.common.collect.ImmutableList; -import com.mojang.datafixers.util.Pair; -import dev.compactmods.machines.machine.Machines; -import dev.compactmods.machines.room.data.CopyRoomBindingFunction; -import dev.compactmods.machines.wall.Walls; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.loot.BlockLoot; -import net.minecraft.data.loot.LootTableProvider; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.storage.loot.LootPool; -import net.minecraft.world.level.storage.loot.LootTable; -import net.minecraft.world.level.storage.loot.LootTables; -import net.minecraft.world.level.storage.loot.ValidationContext; -import net.minecraft.world.level.storage.loot.entries.LootItem; -import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet; -import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; -import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition; -import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; -import net.minecraftforge.registries.RegistryObject; - -import javax.annotation.Nonnull; -import java.util.List; -import java.util.Map; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Supplier; - -public class BlockLootGenerator extends LootTableProvider { - - public BlockLootGenerator(DataGenerator dataGeneratorIn) { - super(dataGeneratorIn); - } - - @Override - protected List>>, LootContextParamSet>> getTables() { - return ImmutableList.of(Pair.of(Blocks::new, LootContextParamSets.BLOCK)); - } - - @Override - protected void validate(Map map, @Nonnull ValidationContext val) { - map.forEach((name, table) -> LootTables.validate(val, name, table)); - } - - private static class Blocks extends BlockLoot { - @Override - protected void addTables() { - this.add(Walls.BLOCK_BREAKABLE_WALL.get(), LootTable.lootTable().withPool(LootPool - .lootPool() - .name(Walls.BLOCK_BREAKABLE_WALL.getId().toString()) - .setRolls(ConstantValue.exactly(1)) - .when(ExplosionCondition.survivesExplosion()) - .add(LootItem.lootTableItem(Walls.ITEM_BREAKABLE_WALL.get())))); - - // Compact Machines - registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_TINY, Machines.MACHINE_BLOCK_ITEM_TINY); - registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_SMALL, Machines.MACHINE_BLOCK_ITEM_SMALL); - registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_NORMAL, Machines.MACHINE_BLOCK_ITEM_NORMAL); - registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_LARGE, Machines.MACHINE_BLOCK_ITEM_LARGE); - registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_GIANT, Machines.MACHINE_BLOCK_ITEM_GIANT); - registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_MAXIMUM, Machines.MACHINE_BLOCK_ITEM_MAXIMUM); - } - - private void registerCompactMachineBlockDrops(RegistryObject block, RegistryObject item) { - LootPool.Builder builder = LootPool.lootPool() - .name(block.getId().toString()) - .setRolls(ConstantValue.exactly(1)) - .when(ExplosionCondition.survivesExplosion()) - .apply(CopyRoomBindingFunction.binding()) - .add(LootItem.lootTableItem(item.get())); - - this.add(block.get(), LootTable.lootTable().withPool(builder)); - } - - @Override - protected Iterable getKnownBlocks() { - return ImmutableList.of( - // Breakable Walls - Walls.BLOCK_BREAKABLE_WALL.get(), - - // Compact Machines - Machines.MACHINE_BLOCK_TINY.get(), - Machines.MACHINE_BLOCK_SMALL.get(), - Machines.MACHINE_BLOCK_NORMAL.get(), - Machines.MACHINE_BLOCK_LARGE.get(), - Machines.MACHINE_BLOCK_GIANT.get(), - Machines.MACHINE_BLOCK_MAXIMUM.get() - ); - } - } -} diff --git a/src/main/java/dev/compactmods/machines/CompactMachines.java b/src/main/java/dev/compactmods/machines/CompactMachines.java index a7fb3145..8aa38324 100644 --- a/src/main/java/dev/compactmods/machines/CompactMachines.java +++ b/src/main/java/dev/compactmods/machines/CompactMachines.java @@ -1,17 +1,21 @@ package dev.compactmods.machines; import dev.compactmods.machines.api.core.Constants; +import dev.compactmods.machines.api.tunnels.capability.CapabilityTunnel; import dev.compactmods.machines.command.Commands; import dev.compactmods.machines.config.CommonConfig; import dev.compactmods.machines.config.EnableVanillaRecipesConfigCondition; import dev.compactmods.machines.config.ServerConfig; -import dev.compactmods.machines.core.Registries; -import dev.compactmods.machines.core.UIRegistration; +import dev.compactmods.machines.core.*; import dev.compactmods.machines.dimension.Dimension; import dev.compactmods.machines.graph.Graph; +import dev.compactmods.machines.machine.CompactMachineBlockEntity; import dev.compactmods.machines.machine.Machines; +import dev.compactmods.machines.room.RoomEventHandler; import dev.compactmods.machines.room.data.LootFunctions; +import dev.compactmods.machines.room.network.RoomNetworkHandler; import dev.compactmods.machines.shrinking.Shrinking; +import dev.compactmods.machines.tunnel.TunnelWallEntity; import dev.compactmods.machines.tunnel.Tunnels; import dev.compactmods.machines.upgrade.MachineRoomUpgrades; import dev.compactmods.machines.wall.Walls; @@ -62,28 +66,18 @@ public void onInitialize() { doRegistration(); // Configuration - ModLoadingContext mlCtx = ModLoadingContext.get(); - mlCtx.registerConfig(ModConfig.Type.COMMON, CommonConfig.CONFIG); - mlCtx.registerConfig(ModConfig.Type.SERVER, ServerConfig.CONFIG); + ModLoadingContext.registerConfig(Constants.MOD_ID, ModConfig.Type.COMMON, CommonConfig.CONFIG); + ModLoadingContext.registerConfig(Constants.MOD_ID, ModConfig.Type.SERVER, ServerConfig.CONFIG); EnableVanillaRecipesConfigCondition.register(); -// UIRegistration.init(); TODO: PORT -// Tunnels.init(); -// CMGraphRegistration.init(); -// MachineRoomUpgrades.init(); -// CompactMachinesCommands.init(); -// CompactMachinesLootFunctions.init(); -// -// ModLoadingContext.registerConfig(MOD_ID, ModConfig.Type.COMMON, CommonConfig.CONFIG); -// ModLoadingContext.registerConfig(MOD_ID, ModConfig.Type.SERVER, ServerConfig.CONFIG); -// ModConfigEvent.LOADING.register(CommonConfig::onLoaded); -// ServerWorldEvents.LOAD.register(ServerEventHandler::onWorldLoaded); -// ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register(ServerEventHandler::onPlayerDimChange); -// ServerPlayConnectionEvents.JOIN.register(ServerEventHandler::onPlayerLogin); -// CommonEventHandler.init(); -// RoomEventHandler.init(); -// ModBusEvents.setup(); + ModConfigEvent.LOADING.register(CommonConfig::onLoaded); + ServerWorldEvents.LOAD.register(ServerEventHandler::onWorldLoaded); + ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register(ServerEventHandler::onPlayerDimChange); + ServerPlayConnectionEvents.JOIN.register(ServerEventHandler::onPlayerLogin); + CommonEventHandler.init(); + RoomEventHandler.init(); + ModBusEvents.setup(); CompactMachinesNet.CHANNEL.initServerListener(); RoomNetworkHandler.CHANNEL.initServerListener(); @@ -92,47 +86,43 @@ public void onInitialize() { RoomNetworkHandler.CHANNEL.initClientListener(); } - Registration.init(); - ItemStorage.SIDED.registerForBlockEntities((blockEntity, context) -> { if (blockEntity instanceof CompactMachineBlockEntity machine) return machine.getTunnelContext(CapabilityTunnel.ITEM, context); if (blockEntity instanceof TunnelWallEntity tunnel) return tunnel.getCapability(CapabilityTunnel.ITEM, context); return null; - }, Registration.MACHINE_TILE_ENTITY.get(), Tunnels.TUNNEL_BLOCK_ENTITY.get()); + }, Machines.MACHINE_TILE_ENTITY.get(), Tunnels.TUNNEL_BLOCK_ENTITY.get()); FluidStorage.SIDED.registerForBlockEntities((blockEntity, context) -> { if (blockEntity instanceof CompactMachineBlockEntity machine) return machine.getTunnelContext(CapabilityTunnel.FLUID, context); if (blockEntity instanceof TunnelWallEntity tunnel) return tunnel.getCapability(CapabilityTunnel.FLUID, context); return null; - }, Registration.MACHINE_TILE_ENTITY.get(), Tunnels.TUNNEL_BLOCK_ENTITY.get()); + }, Machines.MACHINE_TILE_ENTITY.get(), Tunnels.TUNNEL_BLOCK_ENTITY.get()); EnergyStorage.SIDED.registerForBlockEntities((blockEntity, context) -> { if (blockEntity instanceof CompactMachineBlockEntity machine) return machine.getTunnelContext(CapabilityTunnel.ENERGY, context); if (blockEntity instanceof TunnelWallEntity tunnel) return tunnel.getCapability(CapabilityTunnel.ENERGY, context); return null; - }, Registration.MACHINE_TILE_ENTITY.get(), Tunnels.TUNNEL_BLOCK_ENTITY.get()); + }, Machines.MACHINE_TILE_ENTITY.get(), Tunnels.TUNNEL_BLOCK_ENTITY.get()); } /** * Sets up the deferred registration for usage in package/module setup. */ private static void doRegistration() { - var bus = FMLJavaModLoadingContext.get().getModEventBus(); - - Registries.BLOCKS.register(bus); - Registries.ITEMS.register(bus); - Registries.BLOCK_ENTITIES.register(bus); - Registries.TUNNEL_DEFINITIONS.register(bus); - Registries.CONTAINERS.register(bus); - Registries.UPGRADES.register(bus); - Registries.NODE_TYPES.register(bus); - Registries.EDGE_TYPES.register(bus); - Registries.COMMAND_ARGUMENT_TYPES.register(bus); - Registries.LOOT_FUNCS.register(bus); + Registries.BLOCKS.register(); + Registries.ITEMS.register(); + Registries.BLOCK_ENTITIES.register(); + Registries.TUNNEL_DEFINITIONS.register(); + Registries.CONTAINERS.register(); + Registries.UPGRADES.register(); + Registries.NODE_TYPES.register(); + Registries.EDGE_TYPES.register(); + Registries.COMMAND_ARGUMENT_TYPES.register(); + Registries.LOOT_FUNCS.register(); } private static void preparePackages() { diff --git a/src/main/java/dev/compactmods/machines/client/ClientEventHandler.java b/src/main/java/dev/compactmods/machines/client/ClientEventHandler.java index e32ae0c9..1e21e919 100644 --- a/src/main/java/dev/compactmods/machines/client/ClientEventHandler.java +++ b/src/main/java/dev/compactmods/machines/client/ClientEventHandler.java @@ -15,12 +15,10 @@ public class ClientEventHandler implements ClientModInitializer { - @SubscribeEvent public static void onItemColors() { ColorProviderRegistry.ITEM.register(new TunnelItemColor(), Tunnels.ITEM_TUNNEL.get()); } - @SubscribeEvent public static void onBlockColors() { ColorProviderRegistry.BLOCK.register(new TunnelColors(), Tunnels.BLOCK_TUNNEL_WALL.get()); } diff --git a/src/main/java/dev/compactmods/machines/client/gui/widget/PSDIconButton.java b/src/main/java/dev/compactmods/machines/client/gui/widget/PSDIconButton.java index 1281e833..7aa27363 100644 --- a/src/main/java/dev/compactmods/machines/client/gui/widget/PSDIconButton.java +++ b/src/main/java/dev/compactmods/machines/client/gui/widget/PSDIconButton.java @@ -5,6 +5,8 @@ import dev.compactmods.machines.room.client.MachineRoomScreen; import dev.compactmods.machines.room.network.PlayerRequestedTeleportPacket; import dev.compactmods.machines.shrinking.Shrinking; +import io.github.fabricators_of_create.porting_lib.util.client.ExtendedButton; +import net.fabricmc.fabric.api.client.screen.v1.Screens; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; @@ -23,7 +25,7 @@ public PSDIconButton(MachineRoomScreen parent, int xPos, int yPos) { public void render(@NotNull PoseStack pose, int mouseX, int mouseY, float partialTicks) { super.render(pose, mouseX, mouseY, partialTicks); - ((ScreenAccessor)this.parent).port_lib$getMinecraft().getItemRenderer().renderAndDecorateItem( + Screens.getItemRenderer(this.parent).renderAndDecorateItem( new ItemStack(Shrinking.PERSONAL_SHRINKING_DEVICE.get()), x + 2, y + 2, 40); } diff --git a/src/main/java/dev/compactmods/machines/command/Commands.java b/src/main/java/dev/compactmods/machines/command/Commands.java index 145384e5..4fbd9c4b 100644 --- a/src/main/java/dev/compactmods/machines/command/Commands.java +++ b/src/main/java/dev/compactmods/machines/command/Commands.java @@ -14,6 +14,7 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.commands.synchronization.ArgumentTypeInfos; import net.minecraft.commands.synchronization.SingletonArgumentInfo; @@ -37,10 +38,10 @@ public static , T extends ArgumentTypeInfo.Template public static void init() { - CommandRegistrationCallback.EVENT.register(CompactMachinesCommands::onCommandsRegister); + CommandRegistrationCallback.EVENT.register(Commands::onCommandsRegister); } - public static void onCommandsRegister(CommandDispatcher dispatcher, CommandBuildContext registryAccess, Commands.CommandSelection environment) { + public static void onCommandsRegister(CommandDispatcher dispatcher, CommandBuildContext registryAccess, net.minecraft.commands.Commands.CommandSelection environment) { final LiteralArgumentBuilder root = LiteralArgumentBuilder.literal(CompactMachines.MOD_ID); root.then(CMEjectSubcommand.make()); root.then(CMSummarySubcommand.make()); diff --git a/src/main/java/dev/compactmods/machines/compat/rei/CompactMachinesReiPlugin.java b/src/main/java/dev/compactmods/machines/compat/rei/CompactMachinesReiPlugin.java index 25606226..b52d7f94 100644 --- a/src/main/java/dev/compactmods/machines/compat/rei/CompactMachinesReiPlugin.java +++ b/src/main/java/dev/compactmods/machines/compat/rei/CompactMachinesReiPlugin.java @@ -1,11 +1,11 @@ package dev.compactmods.machines.compat.rei; import dev.compactmods.machines.api.core.JeiInfo; -import dev.compactmods.machines.core.Registration; -import dev.compactmods.machines.core.Tunnels; +import dev.compactmods.machines.api.room.RoomSize; import dev.compactmods.machines.i18n.TranslationUtil; import dev.compactmods.machines.machine.CompactMachineItem; -import dev.compactmods.machines.room.RoomSize; +import dev.compactmods.machines.shrinking.Shrinking; +import dev.compactmods.machines.tunnel.Tunnels; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry; @@ -27,7 +27,7 @@ public void registerDisplays(DisplayRegistry registry) { registry.add(DefaultInformationDisplay.createFromEntry( - EntryStacks.of(Registration.PERSONAL_SHRINKING_DEVICE.get()), + EntryStacks.of(Shrinking.PERSONAL_SHRINKING_DEVICE.get()), Component.empty()) .lines(TranslationUtil.jeiInfo(JeiInfo.SHRINKING_DEVICE))); diff --git a/src/main/java/dev/compactmods/machines/compat/theoneprobe/providers/TunnelProvider.java b/src/main/java/dev/compactmods/machines/compat/theoneprobe/providers/TunnelProvider.java index 9cb28740..bd339a29 100644 --- a/src/main/java/dev/compactmods/machines/compat/theoneprobe/providers/TunnelProvider.java +++ b/src/main/java/dev/compactmods/machines/compat/theoneprobe/providers/TunnelProvider.java @@ -46,7 +46,7 @@ public void addProbeInfo(ProbeMode probeMode, IProbeInfo info, Player playerEnti if (probeMode == ProbeMode.EXTENDED) { TunnelDefinition definition = tile.getTunnelType(); - final var tunnelReg = Tunnels.TUNNEL_DEF_REGISTRY; + final var tunnelReg = Tunnels.TUNNEL_DEF_REGISTRY.get(); MutableComponent tunType = Component.literal(tunnelReg.getKey(definition).toString()) .withStyle(ChatFormatting.GRAY); diff --git a/src/main/java/dev/compactmods/machines/core/Registries.java b/src/main/java/dev/compactmods/machines/core/Registries.java index 304182b1..034d5515 100644 --- a/src/main/java/dev/compactmods/machines/core/Registries.java +++ b/src/main/java/dev/compactmods/machines/core/Registries.java @@ -5,6 +5,7 @@ import dev.compactmods.machines.api.tunnels.TunnelDefinition; import dev.compactmods.machines.graph.IGraphEdgeType; import dev.compactmods.machines.graph.IGraphNodeType; +import io.github.fabricators_of_create.porting_lib.util.LazyRegistrar; import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; @@ -14,43 +15,41 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; import static dev.compactmods.machines.CompactMachines.MOD_ID; public class Registries { // Machines, Walls, Shrinking - 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_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MOD_ID); + public static final LazyRegistrar BLOCKS = LazyRegistrar.create(Registry.BLOCK, MOD_ID); + public static final LazyRegistrar ITEMS = LazyRegistrar.create(Registry.ITEM, MOD_ID); + public static final LazyRegistrar> BLOCK_ENTITIES = LazyRegistrar.create(Registry.BLOCK_ENTITY_TYPE, MOD_ID); // Tunnels public static final ResourceLocation TYPES_REG_KEY = new ResourceLocation(MOD_ID, "tunnel_types"); - public static final DeferredRegister TUNNEL_DEFINITIONS = DeferredRegister.create(TYPES_REG_KEY, MOD_ID); + public static final LazyRegistrar TUNNEL_DEFINITIONS = LazyRegistrar.create(TYPES_REG_KEY, MOD_ID); // UIRegistration - public static final DeferredRegister> CONTAINERS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, MOD_ID); + public static final LazyRegistrar> CONTAINERS = LazyRegistrar.create(Registry.MENU, MOD_ID); // MachineRoomUpgrades public static final ResourceKey> ROOM_UPGRADES_REG_KEY = ResourceKey .createRegistryKey(new ResourceLocation(CompactMachines.MOD_ID, "room_upgrades")); - public static final DeferredRegister UPGRADES = DeferredRegister.create(ROOM_UPGRADES_REG_KEY, MOD_ID); + public static final LazyRegistrar UPGRADES = LazyRegistrar.create(ROOM_UPGRADES_REG_KEY, MOD_ID); // Graph public static final ResourceKey> NODES_REG_KEY = ResourceKey .createRegistryKey(new ResourceLocation(CompactMachines.MOD_ID, "graph_nodes")); public static final ResourceKey> EDGES_REG_KEY = ResourceKey .createRegistryKey(new ResourceLocation(CompactMachines.MOD_ID, "graph_edges")); - public static final DeferredRegister NODE_TYPES = DeferredRegister.create(NODES_REG_KEY, MOD_ID); - public static final DeferredRegister EDGE_TYPES = DeferredRegister.create(EDGES_REG_KEY, MOD_ID); + public static final LazyRegistrar NODE_TYPES = LazyRegistrar.create(NODES_REG_KEY, MOD_ID); + public static final LazyRegistrar EDGE_TYPES = LazyRegistrar.create(EDGES_REG_KEY, MOD_ID); // Commands - public static final DeferredRegister> COMMAND_ARGUMENT_TYPES = DeferredRegister.create(Registry.COMMAND_ARGUMENT_TYPE_REGISTRY, MOD_ID); + public static final LazyRegistrar> COMMAND_ARGUMENT_TYPES = LazyRegistrar.create(Registry.COMMAND_ARGUMENT_TYPE_REGISTRY, MOD_ID); // LootFunctions - public static final DeferredRegister LOOT_FUNCS = DeferredRegister.create(Registry.LOOT_FUNCTION_REGISTRY, MOD_ID); + public static final LazyRegistrar LOOT_FUNCS = LazyRegistrar.create(Registry.LOOT_FUNCTION_REGISTRY, MOD_ID); public static void setup() { diff --git a/src/main/java/dev/compactmods/machines/core/UIRegistration.java b/src/main/java/dev/compactmods/machines/core/UIRegistration.java index 88268910..a6fc5574 100644 --- a/src/main/java/dev/compactmods/machines/core/UIRegistration.java +++ b/src/main/java/dev/compactmods/machines/core/UIRegistration.java @@ -2,13 +2,9 @@ import dev.compactmods.machines.location.LevelBlockPosition; import dev.compactmods.machines.room.menu.MachineRoomMenu; -import io.github.fabricators_of_create.porting_lib.util.LazyRegistrar; import io.github.fabricators_of_create.porting_lib.util.RegistryObject; import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType; -import net.minecraft.core.Registry; import net.minecraft.world.inventory.MenuType; -import net.minecraftforge.common.extensions.IForgeMenuType; -import net.minecraftforge.registries.RegistryObject; public class UIRegistration { diff --git a/src/main/java/dev/compactmods/machines/datagen/BlockLootGenerator.java b/src/main/java/dev/compactmods/machines/datagen/BlockLootGenerator.java index 5bab4a56..c15657d8 100644 --- a/src/main/java/dev/compactmods/machines/datagen/BlockLootGenerator.java +++ b/src/main/java/dev/compactmods/machines/datagen/BlockLootGenerator.java @@ -1,7 +1,8 @@ package dev.compactmods.machines.datagen; -import dev.compactmods.machines.core.Registration; +import dev.compactmods.machines.machine.Machines; import dev.compactmods.machines.room.data.CopyRoomBindingFunction; +import dev.compactmods.machines.wall.Walls; import io.github.fabricators_of_create.porting_lib.util.RegistryObject; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider; @@ -21,25 +22,25 @@ public BlockLootGenerator(FabricDataGenerator dataGeneratorIn) { @Override protected void generateBlockLootTables() { - this.add(Registration.BLOCK_BREAKABLE_WALL.get(), LootTable.lootTable().withPool(LootPool + this.add(Walls.BLOCK_BREAKABLE_WALL.get(), LootTable.lootTable().withPool(LootPool .lootPool() -// .name(Registration.BLOCK_BREAKABLE_WALL.getId().toString()) +// .name(Walls.BLOCK_BREAKABLE_WALL.getId().toString()) .setRolls(ConstantValue.exactly(1)) .when(ExplosionCondition.survivesExplosion()) - .add(LootItem.lootTableItem(Registration.ITEM_BREAKABLE_WALL.get())))); + .add(LootItem.lootTableItem(Walls.ITEM_BREAKABLE_WALL.get())))); // Compact Machines - registerCompactMachineBlockDrops(Registration.MACHINE_BLOCK_TINY, Registration.MACHINE_BLOCK_ITEM_TINY); - registerCompactMachineBlockDrops(Registration.MACHINE_BLOCK_SMALL, Registration.MACHINE_BLOCK_ITEM_SMALL); - registerCompactMachineBlockDrops(Registration.MACHINE_BLOCK_NORMAL, Registration.MACHINE_BLOCK_ITEM_NORMAL); - registerCompactMachineBlockDrops(Registration.MACHINE_BLOCK_LARGE, Registration.MACHINE_BLOCK_ITEM_LARGE); - registerCompactMachineBlockDrops(Registration.MACHINE_BLOCK_GIANT, Registration.MACHINE_BLOCK_ITEM_GIANT); - registerCompactMachineBlockDrops(Registration.MACHINE_BLOCK_MAXIMUM, Registration.MACHINE_BLOCK_ITEM_MAXIMUM); + registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_TINY, Machines.MACHINE_BLOCK_ITEM_TINY); + registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_SMALL, Machines.MACHINE_BLOCK_ITEM_SMALL); + registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_NORMAL, Machines.MACHINE_BLOCK_ITEM_NORMAL); + registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_LARGE, Machines.MACHINE_BLOCK_ITEM_LARGE); + registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_GIANT, Machines.MACHINE_BLOCK_ITEM_GIANT); + registerCompactMachineBlockDrops(Machines.MACHINE_BLOCK_MAXIMUM, Machines.MACHINE_BLOCK_ITEM_MAXIMUM); } private void registerCompactMachineBlockDrops(RegistryObject block, RegistryObject item) { LootPool.Builder builder = LootPool.lootPool() -// .name(block.getId().toString()) +// .name(block.getId().toString()) .setRolls(ConstantValue.exactly(1)) .when(ExplosionCondition.survivesExplosion()) .apply(CopyRoomBindingFunction.binding()) diff --git a/src/main/java/dev/compactmods/machines/datagen/lang/EnglishLangGenerator.java b/src/main/java/dev/compactmods/machines/datagen/lang/EnglishLangGenerator.java index f989200d..d93a7c7e 100644 --- a/src/main/java/dev/compactmods/machines/datagen/lang/EnglishLangGenerator.java +++ b/src/main/java/dev/compactmods/machines/datagen/lang/EnglishLangGenerator.java @@ -12,6 +12,7 @@ import dev.compactmods.machines.upgrade.MachineRoomUpgrades; import dev.compactmods.machines.wall.Walls; import net.minecraft.data.DataGenerator; +import org.apache.commons.lang3.StringUtils; import static org.apache.commons.lang3.StringUtils.capitalize; diff --git a/src/main/java/dev/compactmods/machines/dimension/Dimension.java b/src/main/java/dev/compactmods/machines/dimension/Dimension.java index fc8a5c30..810cd72a 100644 --- a/src/main/java/dev/compactmods/machines/dimension/Dimension.java +++ b/src/main/java/dev/compactmods/machines/dimension/Dimension.java @@ -1,14 +1,13 @@ package dev.compactmods.machines.dimension; import dev.compactmods.machines.core.Registries; +import io.github.fabricators_of_create.porting_lib.util.RegistryObject; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.dimension.DimensionType; -import net.minecraftforge.registries.RegistryObject; - import static dev.compactmods.machines.CompactMachines.MOD_ID; public class Dimension { diff --git a/src/main/java/dev/compactmods/machines/dimension/VoidAirBlock.java b/src/main/java/dev/compactmods/machines/dimension/VoidAirBlock.java index 0ea59524..ac724ed1 100644 --- a/src/main/java/dev/compactmods/machines/dimension/VoidAirBlock.java +++ b/src/main/java/dev/compactmods/machines/dimension/VoidAirBlock.java @@ -1,9 +1,9 @@ package dev.compactmods.machines.dimension; -import dev.compactmods.machines.api.room.IRoomHistory; import dev.compactmods.machines.config.ServerConfig; import dev.compactmods.machines.room.RoomCapabilities; import dev.compactmods.machines.util.PlayerUtil; +import io.github.fabricators_of_create.porting_lib.mixin.common.accessor.DamageSourceAccessor; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.damagesource.DamageSource; @@ -18,9 +18,8 @@ import static dev.compactmods.machines.CompactMachines.MOD_ID; - public class VoidAirBlock extends AirBlock { - final public static DamageSource DAMAGE_SOURCE = new DamageSource(MOD_ID + "_voidair"); + final public static DamageSource DAMAGE_SOURCE = DamageSourceAccessor.port_lib$init(MOD_ID + "_voidair"); public VoidAirBlock() { super(BlockBehaviour.Properties.of(Material.AIR).noCollission().air().noLootTable()); @@ -40,7 +39,7 @@ public void entityInside(BlockState pState, Level pLevel, BlockPos pPos, Entity player.hurt(DAMAGE_SOURCE, 1); PlayerUtil.howDidYouGetThere(player); - player.getCapability(RoomCapabilities.ROOM_HISTORY).ifPresent(IRoomHistory::clear); + RoomCapabilities.ROOM_HISTORY.maybeGet(player).ifPresent(provider -> provider.getHistory().clear()); PlayerUtil.teleportPlayerToRespawnOrOverworld(player.server, player); } } diff --git a/src/main/java/dev/compactmods/machines/graph/Graph.java b/src/main/java/dev/compactmods/machines/graph/Graph.java index 710d314b..e842e8e2 100644 --- a/src/main/java/dev/compactmods/machines/graph/Graph.java +++ b/src/main/java/dev/compactmods/machines/graph/Graph.java @@ -1,16 +1,15 @@ package dev.compactmods.machines.graph; import dev.compactmods.machines.core.Registries; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.RegistryBuilder; -import net.minecraftforge.registries.RegistryObject; +import io.github.fabricators_of_create.porting_lib.util.RegistryObject; +import net.minecraft.core.Registry; import java.util.function.Supplier; public class Graph { - public static final Supplier> NODE_TYPE_REG = Registries.NODE_TYPES.makeRegistry(RegistryBuilder::new); - public static final Supplier> EDGE_TYPE_REG = Registries.EDGE_TYPES.makeRegistry(RegistryBuilder::new); + public static final Supplier> NODE_TYPE_REG = Registries.NODE_TYPES.makeRegistry(); + public static final Supplier> EDGE_TYPE_REG = Registries.EDGE_TYPES.makeRegistry(); public static final RegistryObject MACH_NODE = Registries.NODE_TYPES.register("machine", () -> GraphNodeType.MACHINE); diff --git a/src/main/java/dev/compactmods/machines/location/SimpleTeleporter.java b/src/main/java/dev/compactmods/machines/location/SimpleTeleporter.java index 9b74d92b..4a1e75b1 100644 --- a/src/main/java/dev/compactmods/machines/location/SimpleTeleporter.java +++ b/src/main/java/dev/compactmods/machines/location/SimpleTeleporter.java @@ -1,9 +1,9 @@ package dev.compactmods.machines.location; +import io.github.fabricators_of_create.porting_lib.extensions.ITeleporter; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.common.util.ITeleporter; import java.util.function.Function; diff --git a/src/main/java/dev/compactmods/machines/machine/CompactMachineBlockEntity.java b/src/main/java/dev/compactmods/machines/machine/CompactMachineBlockEntity.java index 05630e74..05d59627 100644 --- a/src/main/java/dev/compactmods/machines/machine/CompactMachineBlockEntity.java +++ b/src/main/java/dev/compactmods/machines/machine/CompactMachineBlockEntity.java @@ -2,6 +2,7 @@ import dev.compactmods.machines.CompactMachines; import dev.compactmods.machines.api.machine.MachineNbt; +import dev.compactmods.machines.api.tunnels.capability.CapabilityTunnel; import dev.compactmods.machines.dimension.Dimension; import dev.compactmods.machines.location.LevelBlockPosition; import dev.compactmods.machines.dimension.MissingDimensionException; diff --git a/src/main/java/dev/compactmods/machines/machine/Machines.java b/src/main/java/dev/compactmods/machines/machine/Machines.java index 76d25be8..dde2f5c7 100644 --- a/src/main/java/dev/compactmods/machines/machine/Machines.java +++ b/src/main/java/dev/compactmods/machines/machine/Machines.java @@ -3,12 +3,12 @@ import dev.compactmods.machines.CompactMachines; import dev.compactmods.machines.core.Registries; import dev.compactmods.machines.api.room.RoomSize; +import io.github.fabricators_of_create.porting_lib.util.RegistryObject; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Material; -import net.minecraftforge.registries.RegistryObject; import java.util.function.Supplier; diff --git a/src/main/java/dev/compactmods/machines/room/RoomCapabilities.java b/src/main/java/dev/compactmods/machines/room/RoomCapabilities.java index 0d2a7507..226aaa35 100644 --- a/src/main/java/dev/compactmods/machines/room/RoomCapabilities.java +++ b/src/main/java/dev/compactmods/machines/room/RoomCapabilities.java @@ -2,35 +2,18 @@ import dev.compactmods.machines.CompactMachines; import dev.compactmods.machines.room.capability.PlayerRoomHistoryCapProvider; -import dev.onyxstudios.cca.api.v3.block.BlockComponentFactoryRegistry; -import dev.onyxstudios.cca.api.v3.block.BlockComponentInitializer; import dev.onyxstudios.cca.api.v3.component.ComponentKey; import dev.onyxstudios.cca.api.v3.component.ComponentRegistry; import dev.onyxstudios.cca.api.v3.entity.EntityComponentFactoryRegistry; import dev.onyxstudios.cca.api.v3.entity.EntityComponentInitializer; import net.minecraft.resources.ResourceLocation; -public class RoomCapabilities implements EntityComponentInitializer, BlockComponentInitializer { +public class RoomCapabilities implements EntityComponentInitializer { public static final ComponentKey ROOM_HISTORY = ComponentRegistry.getOrCreate(new ResourceLocation(CompactMachines.MOD_ID, "room_history"), PlayerRoomHistoryCapProvider.class); - @SubscribeEvent - void onCapRegistration(final RegisterCapabilitiesEvent evt) { - evt.register(IRoomHistory.class); - } - @Override public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) { registry.registerForPlayers(ROOM_HISTORY, PlayerRoomHistoryCapProvider::new); } - - @Override - public void registerBlockComponentFactories(BlockComponentFactoryRegistry registry) { -// registry.registerFor(CompactMachineBlockEntity.class, ROOM, be -> { -// LazyOptional optional = be.getLazyRoom(); -// if (optional != null) -// return optional.getValueUnsafer(); -// return null; -// }); - } } diff --git a/src/main/java/dev/compactmods/machines/room/data/LootFunctions.java b/src/main/java/dev/compactmods/machines/room/data/LootFunctions.java index 49fdb15a..b5afb284 100644 --- a/src/main/java/dev/compactmods/machines/room/data/LootFunctions.java +++ b/src/main/java/dev/compactmods/machines/room/data/LootFunctions.java @@ -1,8 +1,8 @@ package dev.compactmods.machines.room.data; import dev.compactmods.machines.core.Registries; +import io.github.fabricators_of_create.porting_lib.util.RegistryObject; import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType; -import net.minecraftforge.registries.RegistryObject; public class LootFunctions { diff --git a/src/main/java/dev/compactmods/machines/room/network/PlayerStartedRoomTrackingPacket.java b/src/main/java/dev/compactmods/machines/room/network/PlayerStartedRoomTrackingPacket.java index 51134dba..430d6aec 100644 --- a/src/main/java/dev/compactmods/machines/room/network/PlayerStartedRoomTrackingPacket.java +++ b/src/main/java/dev/compactmods/machines/room/network/PlayerStartedRoomTrackingPacket.java @@ -14,7 +14,7 @@ import java.util.function.Supplier; -public record PlayerStartedRoomTrackingPacket(ChunkPos room) { +public record PlayerStartedRoomTrackingPacket(ChunkPos room) implements C2SPacket { public PlayerStartedRoomTrackingPacket(FriendlyByteBuf buf) { this(buf.readChunkPos()); diff --git a/src/main/java/dev/compactmods/machines/shrinking/Shrinking.java b/src/main/java/dev/compactmods/machines/shrinking/Shrinking.java index 99b2db8b..d90e53e7 100644 --- a/src/main/java/dev/compactmods/machines/shrinking/Shrinking.java +++ b/src/main/java/dev/compactmods/machines/shrinking/Shrinking.java @@ -2,8 +2,8 @@ import dev.compactmods.machines.CompactMachines; import dev.compactmods.machines.core.Registries; +import io.github.fabricators_of_create.porting_lib.util.RegistryObject; import net.minecraft.world.item.Item; -import net.minecraftforge.registries.RegistryObject; public class Shrinking { diff --git a/src/main/java/dev/compactmods/machines/tunnel/TunnelItem.java b/src/main/java/dev/compactmods/machines/tunnel/TunnelItem.java index 662fe93d..c651ab22 100644 --- a/src/main/java/dev/compactmods/machines/tunnel/TunnelItem.java +++ b/src/main/java/dev/compactmods/machines/tunnel/TunnelItem.java @@ -93,7 +93,7 @@ public void appendHoverText(@Nonnull ItemStack stack, @Nullable Level worldIn, L @Override public void fillItemCategory(CreativeModeTab group, NonNullList items) { if (this.allowedIn(group)) { - Registry definitions = Tunnels.TUNNEL_DEF_REGISTRY; + Registry definitions = Tunnels.TUNNEL_DEF_REGISTRY.get(); definitions.forEach(def -> { if (def == Tunnels.UNKNOWN.get()) return; diff --git a/src/main/java/dev/compactmods/machines/tunnel/TunnelWallBlock.java b/src/main/java/dev/compactmods/machines/tunnel/TunnelWallBlock.java index d71bac9e..4c92cd8e 100644 --- a/src/main/java/dev/compactmods/machines/tunnel/TunnelWallBlock.java +++ b/src/main/java/dev/compactmods/machines/tunnel/TunnelWallBlock.java @@ -9,6 +9,7 @@ import dev.compactmods.machines.tunnel.graph.TunnelConnectionGraph; import dev.compactmods.machines.wall.ProtectedWallBlock; import dev.compactmods.machines.wall.Walls; +import io.github.fabricators_of_create.porting_lib.block.ConnectableRedstoneBlock; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; diff --git a/src/main/java/dev/compactmods/machines/tunnel/TunnelWallEntity.java b/src/main/java/dev/compactmods/machines/tunnel/TunnelWallEntity.java index 29791ad9..bf3a169f 100644 --- a/src/main/java/dev/compactmods/machines/tunnel/TunnelWallEntity.java +++ b/src/main/java/dev/compactmods/machines/tunnel/TunnelWallEntity.java @@ -14,6 +14,8 @@ import dev.compactmods.machines.machine.graph.legacy.LegacyMachineLocationsGraph; import dev.compactmods.machines.tunnel.graph.TunnelConnectionGraph; import dev.compactmods.machines.wall.Walls; +import io.github.fabricators_of_create.porting_lib.block.CustomUpdateTagHandlingBlockEntity; +import io.github.fabricators_of_create.porting_lib.extensions.INBTSerializable; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/dev/compactmods/machines/tunnel/Tunnels.java b/src/main/java/dev/compactmods/machines/tunnel/Tunnels.java index 710ee6bc..02cfded8 100644 --- a/src/main/java/dev/compactmods/machines/tunnel/Tunnels.java +++ b/src/main/java/dev/compactmods/machines/tunnel/Tunnels.java @@ -20,18 +20,20 @@ import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; +import java.util.function.Supplier; + import static dev.compactmods.machines.CompactMachines.MOD_ID; public class Tunnels { - public static final Supplier> TUNNEL_DEF_REGISTRY = Registries.TUNNEL_DEFINITIONS.makeRegistry(RegistryBuilder::new); + public static final Supplier> TUNNEL_DEF_REGISTRY = Registries.TUNNEL_DEFINITIONS.makeRegistry(); public static boolean isRegistered(ResourceLocation id) { - return TUNNEL_DEF_REGISTRY.containsKey(id); + return TUNNEL_DEF_REGISTRY.get().containsKey(id); } public static TunnelDefinition getDefinition(ResourceLocation id) { - if (isRegistered(id)) return TUNNEL_DEF_REGISTRY.get(id); + if (isRegistered(id)) return TUNNEL_DEF_REGISTRY.get().get(id); CompactMachines.LOGGER.warn("Unknown tunnel requested: {}", id); return Tunnels.UNKNOWN.get(); } @@ -66,7 +68,7 @@ public static TunnelDefinition getDefinition(ResourceLocation id) { .register("tunnel_wall", () -> BlockEntityType.Builder.of(TunnelWallEntity::new, BLOCK_TUNNEL_WALL.get()).build(null)); public static ResourceLocation getRegistryId(TunnelDefinition definition) { - final var reg = TUNNEL_DEF_REGISTRY; + final var reg = TUNNEL_DEF_REGISTRY.get(); ResourceLocation key = reg.getKey(definition); if (key == null) return new ResourceLocation(MOD_ID, "unknown"); return key; diff --git a/src/main/java/dev/compactmods/machines/tunnel/graph/TunnelConnectionGraph.java b/src/main/java/dev/compactmods/machines/tunnel/graph/TunnelConnectionGraph.java index ddbc3bdb..86d4a87b 100644 --- a/src/main/java/dev/compactmods/machines/tunnel/graph/TunnelConnectionGraph.java +++ b/src/main/java/dev/compactmods/machines/tunnel/graph/TunnelConnectionGraph.java @@ -284,7 +284,7 @@ public CompoundTag serializeNBT() { HashMap nodeIds = new HashMap<>(); - final var nodeReg = Graph.NODE_TYPE_REG; + final var nodeReg = Graph.NODE_TYPE_REG.get(); final var nodeRegCodec = nodeReg.byNameCodec() .dispatchStable(IGraphNode::getType, IGraphNodeType::codec); @@ -332,11 +332,11 @@ public void deserializeNBT(CompoundTag tag) { final var graphRoot = tag.getCompound("graph"); - final var nodeReg = Graph.NODE_TYPE_REG; + final var nodeReg = Graph.NODE_TYPE_REG.get(); final var nodeRegCodec = nodeReg.byNameCodec() .dispatchStable(IGraphNode::getType, IGraphNodeType::codec); - final var edgeRegCodec = Graph.EDGE_TYPE_REG.byNameCodec() + final var edgeRegCodec = Graph.EDGE_TYPE_REG.get().byNameCodec() .dispatchStable(IGraphEdge::getEdgeType, IGraphEdgeType::codec); final var nodes = graphRoot.getList("nodes", Tag.TAG_COMPOUND); diff --git a/src/main/java/dev/compactmods/machines/upgrade/MachineRoomUpgrades.java b/src/main/java/dev/compactmods/machines/upgrade/MachineRoomUpgrades.java index 96034009..b8ab4f44 100644 --- a/src/main/java/dev/compactmods/machines/upgrade/MachineRoomUpgrades.java +++ b/src/main/java/dev/compactmods/machines/upgrade/MachineRoomUpgrades.java @@ -3,13 +3,15 @@ import dev.compactmods.machines.CompactMachines; import dev.compactmods.machines.api.room.upgrade.RoomUpgrade; import dev.compactmods.machines.core.Registries; +import io.github.fabricators_of_create.porting_lib.util.RegistryObject; +import net.minecraft.core.Registry; import net.minecraft.world.item.Item; import java.util.function.Supplier; public class MachineRoomUpgrades { - public static final Supplier> REGISTRY = Registries.UPGRADES.makeRegistry(RegistryBuilder::new); + public static final Supplier> REGISTRY = Registries.UPGRADES.makeRegistry(); // ================================================================================================================ public static final RegistryObject CHUNKLOAD = Registries.UPGRADES.register(ChunkloadUpgrade.REG_ID.getPath(), ChunkloadUpgrade::new); diff --git a/src/main/java/dev/compactmods/machines/upgrade/RoomUpgradeItem.java b/src/main/java/dev/compactmods/machines/upgrade/RoomUpgradeItem.java index a43b05b3..b6d595b2 100644 --- a/src/main/java/dev/compactmods/machines/upgrade/RoomUpgradeItem.java +++ b/src/main/java/dev/compactmods/machines/upgrade/RoomUpgradeItem.java @@ -26,7 +26,7 @@ public RoomUpgradeItem(Properties props) { @Override public Component getName(ItemStack stack) { String key = RoomUpgradeHelper.getTypeFrom(stack) - .map(rl -> MachineRoomUpgrades.REGISTRY.get(rl)) + .map(rl -> MachineRoomUpgrades.REGISTRY.get().get(rl)) .map(def -> def.getTranslationKey(stack)) .orElse(RoomUpgrade.UNNAMED_TRANS_KEY); diff --git a/src/main/java/dev/compactmods/machines/upgrade/RoomUpgradeManager.java b/src/main/java/dev/compactmods/machines/upgrade/RoomUpgradeManager.java index bcf7b51e..cb54bfe3 100644 --- a/src/main/java/dev/compactmods/machines/upgrade/RoomUpgradeManager.java +++ b/src/main/java/dev/compactmods/machines/upgrade/RoomUpgradeManager.java @@ -75,7 +75,7 @@ private static RoomUpgradeManager fromNbt(CompoundTag tag) { @Override public CompoundTag save(CompoundTag tag) { if (!roomNodes.isEmpty() || !upgradeNodes.isEmpty()) { - final var upgReg = MachineRoomUpgrades.REGISTRY; + final var upgReg = MachineRoomUpgrades.REGISTRY.get(); List upgradeList = new ArrayList<>(); for (var upg : upgradeNodes.values()) { @@ -102,7 +102,7 @@ public CompoundTag save(CompoundTag tag) { } public boolean addUpgrade(T upgrade, ChunkPos room) { - final var upgRegistry = MachineRoomUpgrades.REGISTRY; + final var upgRegistry = MachineRoomUpgrades.REGISTRY.get(); final var upgradeNode = upgradeNodes.computeIfAbsent(upgRegistry.getKey(upgrade), rl -> { final var node = new RoomUpgradeGraphNode(rl); @@ -124,7 +124,7 @@ public boolean addUpgrade(T upgrade, ChunkPos room) { } public boolean removeUpgrade(T upgrade, ChunkPos room) { - final var upgRegistry = MachineRoomUpgrades.REGISTRY; + final var upgRegistry = MachineRoomUpgrades.REGISTRY.get(); final var upgId = upgRegistry.getKey(upgrade); if(upgId == null) return false; @@ -154,7 +154,7 @@ public Stream roomsWith(ResourceKey upgradeKey) { } public Stream> implementing(Class inter) { - final var upgRegistry = MachineRoomUpgrades.REGISTRY; + final var upgRegistry = MachineRoomUpgrades.REGISTRY.get(); // Find all applicable upgrades in registry final var matchedUpgrades = upgRegistry.stream() @@ -187,7 +187,7 @@ public Stream> implementing(Class } public boolean hasUpgrade(ChunkPos room, RoomUpgrade upgrade) { - final var upgRegistry = MachineRoomUpgrades.REGISTRY; + final var upgRegistry = MachineRoomUpgrades.REGISTRY.get(); final var upgId = upgRegistry.getKey(upgrade); if(upgId == null) return false; diff --git a/src/main/java/dev/compactmods/machines/upgrade/command/RoomUpgradeArgument.java b/src/main/java/dev/compactmods/machines/upgrade/command/RoomUpgradeArgument.java index f1b80432..9b2543ce 100644 --- a/src/main/java/dev/compactmods/machines/upgrade/command/RoomUpgradeArgument.java +++ b/src/main/java/dev/compactmods/machines/upgrade/command/RoomUpgradeArgument.java @@ -19,17 +19,17 @@ public class RoomUpgradeArgument extends ResourceKeyArgument { public static final SuggestionProvider SUGGESTOR = (ctx, builder) -> - SharedSuggestionProvider.suggestResource(MachineRoomUpgrades.REGISTRY.keySet(), builder); + SharedSuggestionProvider.suggestResource(MachineRoomUpgrades.REGISTRY.get().keySet(), builder); private static final DynamicCommandExceptionType ERROR_INVALID_UPGRADE = new DynamicCommandExceptionType((a) -> TranslationUtil.command(CMCommands.WRONG_DIMENSION)); private RoomUpgradeArgument() { - super(MachineRoomUpgrades.REGISTRY.key()); + super(MachineRoomUpgrades.REGISTRY.get().key()); } public static Optional getUpgrade(CommandContext stack, String argName) throws CommandSyntaxException { - final var UPGRADES = MachineRoomUpgrades.REGISTRY; + final var UPGRADES = MachineRoomUpgrades.REGISTRY.get(); ResourceKey resourcekey = getRegistryType(stack, argName, Registries.ROOM_UPGRADES_REG_KEY, ERROR_INVALID_UPGRADE); return Optional.ofNullable(UPGRADES.get(resourcekey.location())); } diff --git a/src/main/java/dev/compactmods/machines/upgrade/graph/RoomUpgradeConnection.java b/src/main/java/dev/compactmods/machines/upgrade/graph/RoomUpgradeConnection.java index a596aa4f..e1df41bc 100644 --- a/src/main/java/dev/compactmods/machines/upgrade/graph/RoomUpgradeConnection.java +++ b/src/main/java/dev/compactmods/machines/upgrade/graph/RoomUpgradeConnection.java @@ -11,7 +11,7 @@ public class RoomUpgradeConnection implements IGraphEdge { public static final Codec> CODEC = RecordCodecBuilder.create(i -> i.group( - MachineRoomUpgrades.REGISTRY.byNameCodec().fieldOf("data").forGetter(RoomUpgradeConnection::instance) + MachineRoomUpgrades.REGISTRY.get().byNameCodec().fieldOf("data").forGetter(RoomUpgradeConnection::instance) ).apply(i, RoomUpgradeConnection::new)); private final T upgradeData; diff --git a/src/main/java/dev/compactmods/machines/upgrade/graph/UpgradeConnectionEntry.java b/src/main/java/dev/compactmods/machines/upgrade/graph/UpgradeConnectionEntry.java index b8a03292..5f8b3837 100644 --- a/src/main/java/dev/compactmods/machines/upgrade/graph/UpgradeConnectionEntry.java +++ b/src/main/java/dev/compactmods/machines/upgrade/graph/UpgradeConnectionEntry.java @@ -19,7 +19,7 @@ public record UpgradeConnectionEntry(ChunkPos room, Resou .fieldOf("upgrade") .forGetter(UpgradeConnectionEntry::upgradeKey), - MachineRoomUpgrades.REGISTRY.byNameCodec() + MachineRoomUpgrades.REGISTRY.get().byNameCodec() .fieldOf("data").forGetter(UpgradeConnectionEntry::instance) ).apply(i, UpgradeConnectionEntry::new)); diff --git a/src/main/java/dev/compactmods/machines/util/PlayerUtil.java b/src/main/java/dev/compactmods/machines/util/PlayerUtil.java index 8c8c3be1..9f5c0348 100644 --- a/src/main/java/dev/compactmods/machines/util/PlayerUtil.java +++ b/src/main/java/dev/compactmods/machines/util/PlayerUtil.java @@ -14,6 +14,7 @@ import dev.compactmods.machines.location.SimpleTeleporter; import dev.compactmods.machines.machine.CompactMachineBlockEntity; import dev.compactmods.machines.room.Rooms; +import dev.compactmods.machines.room.capability.PlayerRoomHistoryCapProvider; import dev.compactmods.machines.room.exceptions.NonexistentRoomException; import dev.compactmods.machines.room.history.PlayerRoomHistoryItem; import net.minecraft.core.BlockPos; @@ -67,7 +68,6 @@ public static void teleportPlayerIntoMachine(Level machineLevel, Player player, // Mark the player as inside the machine, set external spawn, and yeet RoomCapabilities.ROOM_HISTORY.maybeGet(player).ifPresent(hist -> { - var entry = PreciseDimensionalPosition.fromPlayer(player); hist.getHistory().addHistory(new PlayerRoomHistoryItem(entry, tile.getLevelPosition())); }); } catch (MissingDimensionException | NonexistentRoomException e) { diff --git a/src/main/java/dev/compactmods/machines/wall/Walls.java b/src/main/java/dev/compactmods/machines/wall/Walls.java index 045670f9..d31e8ca7 100644 --- a/src/main/java/dev/compactmods/machines/wall/Walls.java +++ b/src/main/java/dev/compactmods/machines/wall/Walls.java @@ -2,13 +2,13 @@ import dev.compactmods.machines.CompactMachines; import dev.compactmods.machines.core.Registries; +import io.github.fabricators_of_create.porting_lib.util.RegistryObject; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; 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.registries.RegistryObject; import java.util.function.Supplier; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b05e288b..bc9ff580 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -34,7 +34,7 @@ "dev.compactmods.machines.test.MathTests" ], "cardinal-components-entity": [ - "dev.compactmods.machines.core.Capabilities" + "dev.compactmods.machines.room.RoomCapabilities" ], "jei_mod_plugin": [ "dev.compactmods.machines.compat.jei.CompactMachinesJeiPlugin"