diff --git a/settings.gradle.kts b/settings.gradle.kts index cc0a077..6b50b9a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -39,9 +39,9 @@ run { versionCatalogs { create("libs") { - version("neoforge", "21.0.13-beta") + version("neoforge", "21.0.87-beta") - version("ae2", "19.0.5-alpha") + version("ae2", "19.0.11-alpha") library("ae2", "appeng", "appliedenergistics2").versionRef("ae2") version("requester", "1.20.4-1.1.6") diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java index 61d4ca6..2d88f9f 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java @@ -40,13 +40,13 @@ public void generate(@NotNull BiConsumer, LootTable.Build @Override public void generate() { - for (var block : FullEngBlocks.getBlocks()) { + for (var block : FullEngBlocks.BLOCKS.getEntries()) { add( - block.block(), + block.get(), LootTable.lootTable() .withPool(LootPool.lootPool() .setRolls(ConstantValue.exactly(1)) - .add(LootItem.lootTableItem(block)) + .add(LootItem.lootTableItem(block.get())) .when(ExplosionCondition.survivesExplosion()))); } } diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java index 8bf7454..a02de45 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java @@ -1,14 +1,15 @@ package gripe._90.fulleng.datagen; import net.minecraft.data.PackOutput; +import net.minecraft.data.models.blockstates.MultiVariantGenerator; import net.minecraft.data.models.blockstates.PropertyDispatch; import net.minecraft.data.models.blockstates.Variant; import net.minecraft.data.models.blockstates.VariantProperties; import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.client.model.generators.ModelProvider; import net.neoforged.neoforge.common.data.ExistingFileHelper; +import net.neoforged.neoforge.registries.DeferredBlock; -import appeng.core.definitions.BlockDefinition; import appeng.datagen.providers.models.AE2BlockStateProvider; import gripe._90.fulleng.FullblockEnergistics; @@ -36,7 +37,7 @@ protected void registerStatesAndModels() { terminal(FullEngBlocks.REQUESTER_TERMINAL, "merequester:part/requester_terminal"); } - private void terminal(BlockDefinition terminal, String texturePrefix) { + private void terminal(DeferredBlock terminal, String texturePrefix) { var existing = models().existingFileHelper; existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_bright"), ModelProvider.TEXTURE); existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_medium"), ModelProvider.TEXTURE); @@ -44,21 +45,22 @@ private void terminal(BlockDefinition terminal, String texturePrefix) { var onModel = terminal != FullEngBlocks.TERMINAL ? models().withExistingParent( - "block/" + terminal.id().getPath(), FullblockEnergistics.MODID + ":block/terminal") + "block/" + terminal.getId().getPath(), FullblockEnergistics.MODID + ":block/terminal") .texture("lightsBright", texturePrefix + "_bright") .texture("lightsMedium", texturePrefix + "_medium") .texture("lightsDark", texturePrefix + "_dark") .renderType("cutout") : models().getExistingFile(FullblockEnergistics.makeId("block/terminal")); - multiVariantGenerator(terminal, Variant.variant()) + var builder = MultiVariantGenerator.multiVariant(terminal.get()) .with(createFacingSpinDispatch()) .with(PropertyDispatch.property(FullBlock.POWERED).generate(powered -> Variant.variant() .with(VariantProperties.MODEL, powered ? onModel.getLocation() : TERMINAL_OFF))); - simpleBlockItem(terminal.block(), onModel); + registeredBlocks.put(terminal.get(), () -> builder.get().getAsJsonObject()); + simpleBlockItem(terminal.get(), onModel); } - private void monitor(BlockDefinition monitor, String texturePrefix) { + private void monitor(DeferredBlock monitor, String texturePrefix) { var existing = models().existingFileHelper; existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_bright"), ModelProvider.TEXTURE); existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_medium"), ModelProvider.TEXTURE); @@ -66,19 +68,19 @@ private void monitor(BlockDefinition monitor, String texturePrefix) { existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_dark_locked"), ModelProvider.TEXTURE); var unlockedModel = models().withExistingParent( - "block/" + monitor.id().getPath(), FullblockEnergistics.MODID + ":block/terminal") + "block/" + monitor.getId().getPath(), FullblockEnergistics.MODID + ":block/terminal") .texture("lightsBright", texturePrefix + "_bright") .texture("lightsMedium", texturePrefix + "_medium") .texture("lightsDark", texturePrefix + "_dark") .renderType("cutout"); var lockedModel = models().withExistingParent( - "block/" + monitor.id().getPath(), FullblockEnergistics.MODID + ":block/terminal") + "block/" + monitor.getId().getPath(), FullblockEnergistics.MODID + ":block/terminal") .texture("lightsBright", texturePrefix + "_bright") .texture("lightsMedium", texturePrefix + "_medium") .texture("lightsDark", texturePrefix + "_dark_locked") .renderType("cutout"); - multiVariantGenerator(monitor, Variant.variant()) + var builder = MultiVariantGenerator.multiVariant(monitor.get()) .with(createFacingSpinDispatch()) .with(PropertyDispatch.properties(FullBlock.POWERED, MonitorBlock.LOCKED) .generate((powered, locked) -> Variant.variant() @@ -87,7 +89,8 @@ private void monitor(BlockDefinition monitor, String texturePrefix) { !powered ? TERMINAL_OFF : locked ? lockedModel.getLocation() : unlockedModel.getLocation()))); - simpleBlockItem(monitor.block(), unlockedModel); + registeredBlocks.put(monitor.get(), () -> builder.get().getAsJsonObject()); + simpleBlockItem(monitor.get(), unlockedModel); } @Override diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java index 9961088..72571fb 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java @@ -11,8 +11,7 @@ import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.data.recipes.ShapelessRecipeBuilder; - -import appeng.core.definitions.BlockDefinition; +import net.neoforged.neoforge.registries.DeferredBlock; import gripe._90.fulleng.FullblockEnergistics; import gripe._90.fulleng.block.FullBlock; @@ -39,8 +38,8 @@ public void buildRecipes(@NotNull RecipeOutput output) { } } - private void block(RecipeOutput output, BlockDefinition> block) { - var part = block.block().getEquivalentPart(); + private void block(RecipeOutput output, DeferredBlock> block) { + var part = block.get().getEquivalentPart(); var partId = BuiltInRegistries.ITEM.getKey(part.asItem()).getPath(); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, block) diff --git a/src/data/java/gripe/_90/fulleng/datagen/FullTagProvider.java b/src/data/java/gripe/_90/fulleng/datagen/FullTagProvider.java index cb61d6b..5dace23 100644 --- a/src/data/java/gripe/_90/fulleng/datagen/FullTagProvider.java +++ b/src/data/java/gripe/_90/fulleng/datagen/FullTagProvider.java @@ -20,8 +20,8 @@ public FullTagProvider(PackOutput output, CompletableFuture tag(BlockTags.MINEABLE_WITH_PICKAXE) - .add(BuiltInRegistries.BLOCK.getResourceKey(b.block()).orElseThrow())); + FullEngBlocks.BLOCKS.getEntries().forEach(b -> tag(BlockTags.MINEABLE_WITH_PICKAXE) + .add(BuiltInRegistries.BLOCK.getResourceKey(b.get()).orElseThrow())); } @NotNull diff --git a/src/generated/resources/.cache/cc4b70e39bb0fb6efac7e3196e5bd714468e6114 b/src/generated/resources/.cache/cc4b70e39bb0fb6efac7e3196e5bd714468e6114 index b14f2e8..ecee42f 100644 --- a/src/generated/resources/.cache/cc4b70e39bb0fb6efac7e3196e5bd714468e6114 +++ b/src/generated/resources/.cache/cc4b70e39bb0fb6efac7e3196e5bd714468e6114 @@ -1,4 +1,4 @@ -// 1.21 2024-07-11T19:11:25.597674337 Block States / Models +// 1.21 2024-07-13T13:19:04.18803467 Block States / Models 39f3a7fbd9af83227152e49f0f7d28ba69532c1b assets/fulleng/blockstates/conversion_monitor.json 48d2853ffde2d08b63407795966ee8b9c28831b2 assets/fulleng/blockstates/crafting_terminal.json a4f2d912b855982d7cc54e3ec6dbf81935cd1f9d assets/fulleng/blockstates/pattern_access_terminal.json diff --git a/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java b/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java index 49cf019..e7883c8 100644 --- a/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java +++ b/src/main/java/gripe/_90/fulleng/FullblockEnergistics.java @@ -34,7 +34,7 @@ import gripe._90.fulleng.block.entity.monitor.ConversionMonitorBlockEntity; import gripe._90.fulleng.client.MonitorBlockEntityRenderer; -import gripe._90.fulleng.definition.FullEngBlockEntities; +import gripe._90.fulleng.definition.FullEngBEs; import gripe._90.fulleng.definition.FullEngBlocks; import gripe._90.fulleng.integration.Addons; import gripe._90.fulleng.integration.requester.RequesterIntegration; @@ -49,7 +49,10 @@ public static ResourceLocation makeId(String path) { } public FullblockEnergistics(IEventBus modEventBus) { - modEventBus.addListener(this::registerAll); + FullEngBlocks.register(modEventBus); + FullEngBEs.DR.register(modEventBus); + + modEventBus.addListener(this::register); modEventBus.addListener(this::registerCapabilities); modEventBus.addListener(this::addToCreativeTab); @@ -58,15 +61,7 @@ public FullblockEnergistics(IEventBus modEventBus) { } } - private void registerAll(RegisterEvent event) { - FullEngBlocks.getBlocks().forEach(block -> { - event.register(Registries.BLOCK, block.id(), block::block); - event.register(Registries.ITEM, block.id(), block::asItem); - }); - - event.register(Registries.BLOCK_ENTITY_TYPE, helper -> FullEngBlockEntities.getBlockEntities() - .forEach(helper::register)); - + private void register(RegisterEvent event) { if (Addons.MEREQUESTER.isLoaded()) { event.register( Registries.MENU, AppEng.makeId("requester_terminal_f"), () -> RequesterTerminalMenu.TYPE_FULLBLOCK); @@ -74,14 +69,14 @@ private void registerAll(RegisterEvent event) { } private void registerCapabilities(RegisterCapabilitiesEvent event) { - for (var type : FullEngBlockEntities.getBlockEntities().values()) { + for (var type : FullEngBEs.DR.getEntries()) { event.registerBlockEntity( - AECapabilities.IN_WORLD_GRID_NODE_HOST, type, (be, context) -> (IInWorldGridNodeHost) be); + AECapabilities.IN_WORLD_GRID_NODE_HOST, type.get(), (be, context) -> (IInWorldGridNodeHost) be); } event.registerBlockEntity( Capabilities.ItemHandler.BLOCK, - FullEngBlockEntities.PATTERN_ENCODING_TERMINAL, + FullEngBEs.PATTERN_ENCODING_TERMINAL.get(), (be, context) -> context != Direction.NORTH ? be.getLogic().getBlankPatternInv().toItemHandler() : null); @@ -89,7 +84,7 @@ private void registerCapabilities(RegisterCapabilitiesEvent event) { private void addToCreativeTab(BuildCreativeModeTabContentsEvent event) { if (event.getTabKey().equals(AECreativeTabIds.MAIN)) { - FullEngBlocks.getBlocks().forEach(event::accept); + FullEngBlocks.BLOCKS.getEntries().forEach(b -> event.accept(b.get())); } } @@ -109,19 +104,19 @@ private void initScreens(RegisterMenuScreensEvent event) { } private void initBlockEntityRenders(ModelEvent.RegisterGeometryLoaders ignoredEvent) { - BlockEntityRenderers.register(FullEngBlockEntities.STORAGE_MONITOR, MonitorBlockEntityRenderer::new); - BlockEntityRenderers.register(FullEngBlockEntities.CONVERSION_MONITOR, MonitorBlockEntityRenderer::new); + BlockEntityRenderers.register(FullEngBEs.STORAGE_MONITOR.get(), MonitorBlockEntityRenderer::new); + BlockEntityRenderers.register(FullEngBEs.CONVERSION_MONITOR.get(), MonitorBlockEntityRenderer::new); } private void registerBlockColourProviders(RegisterColorHandlersEvent.Block event) { - for (var block : FullEngBlocks.getBlocks()) { - event.register(new ColorableBlockEntityBlockColor(), block.block()); + for (var block : FullEngBlocks.BLOCKS.getEntries()) { + event.register(new ColorableBlockEntityBlockColor(), block.get()); } } private void registerItemColourProviders(RegisterColorHandlersEvent.Item event) { - for (var block : FullEngBlocks.getBlocks()) { - event.register(new StaticItemColor(AEColor.TRANSPARENT), block.asItem()); + for (var block : FullEngBlocks.BLOCKS.getEntries()) { + event.register(new StaticItemColor(AEColor.TRANSPARENT), block.get()); } } diff --git a/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java b/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java index 7c2b8e4..ca68bcf 100644 --- a/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java +++ b/src/main/java/gripe/_90/fulleng/block/TerminalBlock.java @@ -44,7 +44,7 @@ public InteractionResult useWithoutItem( @Override public boolean hasAnalogOutputSignal(BlockState state) { - return state.is(FullEngBlocks.PATTERN_ENCODING_TERMINAL.block()); + return state.is(FullEngBlocks.PATTERN_ENCODING_TERMINAL.get()); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/FullBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/FullBlockEntity.java index 48b915c..6c5c275 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/FullBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/FullBlockEntity.java @@ -14,9 +14,9 @@ import appeng.api.networking.IGridNodeListener; import appeng.api.util.AECableType; import appeng.api.util.AEColor; -import appeng.blockentity.grid.AENetworkBlockEntity; +import appeng.blockentity.grid.AENetworkedBlockEntity; -public abstract class FullBlockEntity extends AENetworkBlockEntity implements IColorableBlockEntity { +public abstract class FullBlockEntity extends AENetworkedBlockEntity implements IColorableBlockEntity { private AEColor paintedColour = AEColor.TRANSPARENT; private boolean isActive = false; diff --git a/src/main/java/gripe/_90/fulleng/block/entity/monitor/ConversionMonitorBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/monitor/ConversionMonitorBlockEntity.java index 15befdb..df9225b 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/monitor/ConversionMonitorBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/monitor/ConversionMonitorBlockEntity.java @@ -18,11 +18,11 @@ import appeng.menu.me.crafting.CraftAmountMenu; import appeng.util.inv.PlayerInternalInventory; -import gripe._90.fulleng.definition.FullEngBlockEntities; +import gripe._90.fulleng.definition.FullEngBEs; public class ConversionMonitorBlockEntity extends StorageMonitorBlockEntity implements ISubMenuHost { public ConversionMonitorBlockEntity(BlockPos pos, BlockState state) { - super(FullEngBlockEntities.CONVERSION_MONITOR, pos, state); + super(FullEngBEs.CONVERSION_MONITOR.get(), pos, state); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java index b4928bb..c9a483d 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/monitor/StorageMonitorBlockEntity.java @@ -24,7 +24,7 @@ import appeng.core.localization.PlayerMessages; import gripe._90.fulleng.block.entity.FullBlockEntity; -import gripe._90.fulleng.definition.FullEngBlockEntities; +import gripe._90.fulleng.definition.FullEngBEs; @SuppressWarnings("UnstableApiUsage") public class StorageMonitorBlockEntity extends FullBlockEntity implements INetworkToolAware { @@ -39,7 +39,7 @@ public class StorageMonitorBlockEntity extends FullBlockEntity implements INetwo private IStackWatcher craftingWatcher; public StorageMonitorBlockEntity(BlockPos pos, BlockState state) { - this(FullEngBlockEntities.STORAGE_MONITOR, pos, state); + this(FullEngBEs.STORAGE_MONITOR.get(), pos, state); } public StorageMonitorBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java index 19df92d..f4a6baf 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/CraftingTerminalBlockEntity.java @@ -16,13 +16,13 @@ import appeng.parts.reporting.CraftingTerminalPart; import appeng.util.inv.AppEngInternalInventory; -import gripe._90.fulleng.definition.FullEngBlockEntities; +import gripe._90.fulleng.definition.FullEngBEs; public class CraftingTerminalBlockEntity extends StorageTerminalBlockEntity { private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory(this, 9); public CraftingTerminalBlockEntity(BlockPos pos, BlockState blockState) { - super(FullEngBlockEntities.CRAFTING_TERMINAL, pos, blockState); + super(FullEngBEs.CRAFTING_TERMINAL.get(), pos, blockState); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java index d378e5a..5b6c7b8 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternAccessTerminalBlockEntity.java @@ -14,11 +14,11 @@ import appeng.api.util.IConfigManagerBuilder; import appeng.menu.implementations.PatternAccessTermMenu; -import gripe._90.fulleng.definition.FullEngBlockEntities; +import gripe._90.fulleng.definition.FullEngBEs; public class PatternAccessTerminalBlockEntity extends TerminalBlockEntity implements IPatternAccessTermMenuHost { public PatternAccessTerminalBlockEntity(BlockPos pos, BlockState blockState) { - super(FullEngBlockEntities.PATTERN_ACCESS_TERMINAL, pos, blockState); + super(FullEngBEs.PATTERN_ACCESS_TERMINAL.get(), pos, blockState); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java index 103b924..495ef0a 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/PatternEncodingTerminalBlockEntity.java @@ -16,14 +16,14 @@ import appeng.parts.encoding.PatternEncodingLogic; import appeng.util.inv.AppEngInternalInventory; -import gripe._90.fulleng.definition.FullEngBlockEntities; +import gripe._90.fulleng.definition.FullEngBEs; public class PatternEncodingTerminalBlockEntity extends StorageTerminalBlockEntity implements IPatternTerminalLogicHost, IPatternTerminalMenuHost { private final PatternEncodingLogic logic = new PatternEncodingLogic(this); public PatternEncodingTerminalBlockEntity(BlockPos pos, BlockState blockState) { - super(FullEngBlockEntities.PATTERN_ENCODING_TERMINAL, pos, blockState); + super(FullEngBEs.PATTERN_ENCODING_TERMINAL.get(), pos, blockState); } @Override diff --git a/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java index 813f84f..2c858bf 100644 --- a/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/block/entity/terminal/StorageTerminalBlockEntity.java @@ -29,14 +29,14 @@ import appeng.util.inv.AppEngInternalInventory; import appeng.util.inv.InternalInventoryHost; -import gripe._90.fulleng.definition.FullEngBlockEntities; +import gripe._90.fulleng.definition.FullEngBEs; public class StorageTerminalBlockEntity extends TerminalBlockEntity implements ITerminalHost, IViewCellStorage, InternalInventoryHost { private final AppEngInternalInventory viewCell = new AppEngInternalInventory(this, 5); public StorageTerminalBlockEntity(BlockPos pos, BlockState state) { - this(FullEngBlockEntities.TERMINAL, pos, state); + this(FullEngBEs.TERMINAL.get(), pos, state); } public StorageTerminalBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { diff --git a/src/main/java/gripe/_90/fulleng/definition/FullEngBlockEntities.java b/src/main/java/gripe/_90/fulleng/definition/FullEngBEs.java similarity index 53% rename from src/main/java/gripe/_90/fulleng/definition/FullEngBlockEntities.java rename to src/main/java/gripe/_90/fulleng/definition/FullEngBEs.java index ed81dc3..c92ed2f 100644 --- a/src/main/java/gripe/_90/fulleng/definition/FullEngBlockEntities.java +++ b/src/main/java/gripe/_90/fulleng/definition/FullEngBEs.java @@ -1,15 +1,13 @@ package gripe._90.fulleng.definition; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; +import java.util.function.Supplier; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.registries.Registries; import net.minecraft.world.level.block.entity.BlockEntityType; +import net.neoforged.neoforge.registries.DeferredRegister; import appeng.block.AEBaseEntityBlock; import appeng.blockentity.AEBaseBlockEntity; -import appeng.core.definitions.BlockDefinition; import gripe._90.fulleng.FullblockEnergistics; import gripe._90.fulleng.block.entity.monitor.ConversionMonitorBlockEntity; @@ -20,58 +18,56 @@ import gripe._90.fulleng.block.entity.terminal.StorageTerminalBlockEntity; import gripe._90.fulleng.integration.requester.RequesterTerminalBlockEntity; -public class FullEngBlockEntities { - private static final Map> BLOCK_ENTITIES = new HashMap<>(); +public class FullEngBEs { + public static final DeferredRegister> DR = + DeferredRegister.create(Registries.BLOCK_ENTITY_TYPE, FullblockEnergistics.MODID); - public static Map> getBlockEntities() { - return Collections.unmodifiableMap(BLOCK_ENTITIES); - } - - public static final BlockEntityType TERMINAL = blockEntity( - "terminal", StorageTerminalBlockEntity.class, StorageTerminalBlockEntity::new, FullEngBlocks.TERMINAL); - public static final BlockEntityType CRAFTING_TERMINAL = blockEntity( + public static final Supplier> TERMINAL = + be("terminal", StorageTerminalBlockEntity.class, StorageTerminalBlockEntity::new, FullEngBlocks.TERMINAL); + public static final Supplier> CRAFTING_TERMINAL = be( "crafting_terminal", CraftingTerminalBlockEntity.class, CraftingTerminalBlockEntity::new, FullEngBlocks.CRAFTING_TERMINAL); - public static final BlockEntityType PATTERN_ENCODING_TERMINAL = blockEntity( + public static final Supplier> PATTERN_ENCODING_TERMINAL = be( "pattern_encoding_terminal", PatternEncodingTerminalBlockEntity.class, PatternEncodingTerminalBlockEntity::new, FullEngBlocks.PATTERN_ENCODING_TERMINAL); - public static final BlockEntityType PATTERN_ACCESS_TERMINAL = blockEntity( + public static final Supplier> PATTERN_ACCESS_TERMINAL = be( "pattern_access_terminal", PatternAccessTerminalBlockEntity.class, PatternAccessTerminalBlockEntity::new, FullEngBlocks.PATTERN_ACCESS_TERMINAL); - public static final BlockEntityType STORAGE_MONITOR = blockEntity( + public static final Supplier> STORAGE_MONITOR = be( "storage_monitor", StorageMonitorBlockEntity.class, StorageMonitorBlockEntity::new, FullEngBlocks.STORAGE_MONITOR); - public static final BlockEntityType CONVERSION_MONITOR = blockEntity( + public static final Supplier> CONVERSION_MONITOR = be( "conversion_monitor", ConversionMonitorBlockEntity.class, ConversionMonitorBlockEntity::new, FullEngBlocks.CONVERSION_MONITOR); - public static final BlockEntityType REQUESTER_TERMINAL = blockEntity( + public static final Supplier> REQUESTER_TERMINAL = be( "requester_terminal", RequesterTerminalBlockEntity.class, RequesterTerminalBlockEntity::new, FullEngBlocks.REQUESTER_TERMINAL); @SuppressWarnings("DataFlowIssue") - static BlockEntityType blockEntity( + static Supplier> be( String id, Class entityClass, BlockEntityType.BlockEntitySupplier supplier, - BlockDefinition> block) { - var type = BlockEntityType.Builder.of(supplier, block.block()).build(null); - BLOCK_ENTITIES.put(FullblockEnergistics.makeId(id), type); - AEBaseBlockEntity.registerBlockEntityItem(type, block.asItem()); - block.block().setBlockEntity(entityClass, type, null, null); - return type; + Supplier> block) { + return DR.register(id, () -> { + var type = BlockEntityType.Builder.of(supplier, block.get()).build(null); + AEBaseBlockEntity.registerBlockEntityItem(type, block.get().asItem()); + block.get().setBlockEntity(entityClass, type, null, null); + return type; + }); } } diff --git a/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java b/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java index c66b655..4f016ec 100644 --- a/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java +++ b/src/main/java/gripe/_90/fulleng/definition/FullEngBlocks.java @@ -1,17 +1,16 @@ package gripe._90.fulleng.definition; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import java.util.function.Function; import java.util.function.Supplier; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.neoforge.registries.DeferredBlock; +import net.neoforged.neoforge.registries.DeferredRegister; import appeng.block.AEBaseBlockItem; import appeng.core.definitions.AEParts; -import appeng.core.definitions.BlockDefinition; import appeng.core.definitions.ItemDefinition; import appeng.items.parts.PartItem; import appeng.parts.reporting.AbstractDisplayPart; @@ -33,57 +32,47 @@ import gripe._90.fulleng.integration.requester.RequesterTerminalBlockEntity; public class FullEngBlocks { - private static final List> BLOCKS = new ArrayList<>(); + public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(FullblockEnergistics.MODID); + private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(FullblockEnergistics.MODID); - public static List> getBlocks() { - return Collections.unmodifiableList(BLOCKS); + public static void register(IEventBus bus) { + BLOCKS.register(bus); + ITEMS.register(bus); } // spotless:off - public static final BlockDefinition> TERMINAL = terminal(AEParts.TERMINAL); - public static final BlockDefinition> CRAFTING_TERMINAL = terminal(AEParts.CRAFTING_TERMINAL); - public static final BlockDefinition> PATTERN_ENCODING_TERMINAL = terminal(AEParts.PATTERN_ENCODING_TERMINAL); - public static final BlockDefinition> PATTERN_ACCESS_TERMINAL = terminal(AEParts.PATTERN_ACCESS_TERMINAL); + public static final DeferredBlock> TERMINAL = terminal(AEParts.TERMINAL); + public static final DeferredBlock> CRAFTING_TERMINAL = terminal(AEParts.CRAFTING_TERMINAL); + public static final DeferredBlock> PATTERN_ENCODING_TERMINAL = terminal(AEParts.PATTERN_ENCODING_TERMINAL); + public static final DeferredBlock> PATTERN_ACCESS_TERMINAL = terminal(AEParts.PATTERN_ACCESS_TERMINAL); - public static final BlockDefinition> STORAGE_MONITOR = monitor(AEParts.STORAGE_MONITOR); - public static final BlockDefinition> CONVERSION_MONITOR = monitor(AEParts.CONVERSION_MONITOR); + public static final DeferredBlock> STORAGE_MONITOR = monitor(AEParts.STORAGE_MONITOR); + public static final DeferredBlock> CONVERSION_MONITOR = monitor(AEParts.CONVERSION_MONITOR); // spotless:on - public static final BlockDefinition> REQUESTER_TERMINAL = block( - "ME Requester Terminal", + public static final DeferredBlock> REQUESTER_TERMINAL = block( "requester_terminal", RequesterTerminalBlock::new, block -> new IntegrationBlockItem(block, Addons.MEREQUESTER)); - static

BlockDefinition> terminal( + static

DeferredBlock> terminal( ItemDefinition> equivalentPart) { - return block( - equivalentPart.getEnglishName(), - equivalentPart.id().getPath(), - () -> new TerminalBlock<>(equivalentPart)); + return block(equivalentPart.id().getPath(), () -> new TerminalBlock<>(equivalentPart)); } - static

- BlockDefinition> monitor(ItemDefinition> equivalentPart) { - return block( - equivalentPart.getEnglishName(), - equivalentPart.id().getPath(), - () -> new MonitorBlock<>(equivalentPart)); + static

DeferredBlock> monitor( + ItemDefinition> equivalentPart) { + return block(equivalentPart.id().getPath(), () -> new MonitorBlock<>(equivalentPart)); } - static BlockDefinition block(String englishName, String id, Supplier supplier) { - return block(englishName, id, supplier, block -> new AEBaseBlockItem(block, new Item.Properties())); + static DeferredBlock block(String id, Supplier supplier) { + return block(id, supplier, block -> new AEBaseBlockItem(block, new Item.Properties())); } - static BlockDefinition block( - String englishName, - String id, - Supplier blockSupplier, - Function itemFunction) { - var block = blockSupplier.get(); - var item = itemFunction.apply(block); - var definition = new BlockDefinition<>(englishName, FullblockEnergistics.makeId(id), block, item); - BLOCKS.add(definition); - return definition; + static DeferredBlock block( + String id, Supplier blockSupplier, Function itemFunction) { + var block = BLOCKS.register(id, blockSupplier); + ITEMS.register(id, () -> itemFunction.apply(block.get())); + return block; } } diff --git a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockEntity.java b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockEntity.java index c16d25d..94a91f9 100644 --- a/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockEntity.java +++ b/src/main/java/gripe/_90/fulleng/integration/requester/RequesterTerminalBlockEntity.java @@ -7,12 +7,12 @@ import appeng.api.util.IConfigManagerBuilder; import gripe._90.fulleng.block.entity.terminal.TerminalBlockEntity; -import gripe._90.fulleng.definition.FullEngBlockEntities; +import gripe._90.fulleng.definition.FullEngBEs; import gripe._90.fulleng.integration.Addons; public class RequesterTerminalBlockEntity extends TerminalBlockEntity { public RequesterTerminalBlockEntity(BlockPos pos, BlockState blockState) { - super(FullEngBlockEntities.REQUESTER_TERMINAL, pos, blockState); + super(FullEngBEs.REQUESTER_TERMINAL.get(), pos, blockState); } @Override