From 056aa3728784da8037b662b578e5790035e4923d Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Wed, 3 Jul 2024 18:26:25 +0200 Subject: [PATCH] wip: Port to Minecraft 1.21 --- .../neoforge/NeoForgeExCompressum.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/neoforge/src/main/java/net/blay09/mods/excompressum/neoforge/NeoForgeExCompressum.java b/neoforge/src/main/java/net/blay09/mods/excompressum/neoforge/NeoForgeExCompressum.java index c77e9575..5027e104 100644 --- a/neoforge/src/main/java/net/blay09/mods/excompressum/neoforge/NeoForgeExCompressum.java +++ b/neoforge/src/main/java/net/blay09/mods/excompressum/neoforge/NeoForgeExCompressum.java @@ -1,13 +1,19 @@ package net.blay09.mods.excompressum.neoforge; import net.blay09.mods.balm.api.Balm; +import net.blay09.mods.balm.neoforge.NeoForgeBalm; import net.blay09.mods.balm.neoforge.NeoForgeLoadContext; +import net.blay09.mods.balm.neoforge.energy.NeoForgeEnergyStorage; +import net.blay09.mods.balm.neoforge.fluid.NeoForgeFluidTank; import net.blay09.mods.excompressum.ExCompressum; +import net.blay09.mods.excompressum.block.entity.ModBlockEntities; import net.blay09.mods.excompressum.neoforge.compat.top.TheOneProbeAddon; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.ModList; import net.neoforged.fml.common.Mod; import net.neoforged.fml.event.lifecycle.InterModEnqueueEvent; +import net.neoforged.neoforge.capabilities.Capabilities; +import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,6 +26,7 @@ public NeoForgeExCompressum(IEventBus modEventBus) { final var context = new NeoForgeLoadContext(modEventBus); Balm.initialize(ExCompressum.MOD_ID, context, ExCompressum::initialize); + modEventBus.addListener(this::registerCapabilities); modEventBus.addListener(this::imc); } @@ -28,4 +35,50 @@ private void imc(InterModEnqueueEvent event) { TheOneProbeAddon.register(); } } + + private void registerCapabilities(RegisterCapabilitiesEvent event) { + event.registerBlockEntity(Capabilities.FluidHandler.BLOCK, + ModBlockEntities.woodenCrucible.get(), + (blockEntity, context) -> new NeoForgeFluidTank(blockEntity.getFluidTank())); + event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, + ModBlockEntities.autoCompressor.get(), + (blockEntity, context) -> new NeoForgeEnergyStorage(blockEntity.getEnergyStorage())); + event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, + ModBlockEntities.rationingAutoCompressor.get(), + (blockEntity, context) -> new NeoForgeEnergyStorage(blockEntity.getEnergyStorage())); + event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, + ModBlockEntities.autoSieve.get(), + (blockEntity, context) -> new NeoForgeEnergyStorage(blockEntity.getEnergyStorage())); + event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, + ModBlockEntities.autoHeavySieve.get(), + (blockEntity, context) -> new NeoForgeEnergyStorage(blockEntity.getEnergyStorage())); + event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, + ModBlockEntities.autoHammer.get(), + (blockEntity, context) -> new NeoForgeEnergyStorage(blockEntity.getEnergyStorage())); + event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, + ModBlockEntities.autoCompressedHammer.get(), + (blockEntity, context) -> new NeoForgeEnergyStorage(blockEntity.getEnergyStorage())); + + event.registerBlockEntity(NeoForgeBalm.FLUID_TANK_CAPABILITY, + ModBlockEntities.woodenCrucible.get(), + (blockEntity, context) -> blockEntity.getFluidTank()); + event.registerBlockEntity(NeoForgeBalm.ENERGY_STORAGE_CAPABILITY, + ModBlockEntities.autoCompressor.get(), + (blockEntity, context) -> blockEntity.getEnergyStorage()); + event.registerBlockEntity(NeoForgeBalm.ENERGY_STORAGE_CAPABILITY, + ModBlockEntities.rationingAutoCompressor.get(), + (blockEntity, context) -> blockEntity.getEnergyStorage()); + event.registerBlockEntity(NeoForgeBalm.ENERGY_STORAGE_CAPABILITY, + ModBlockEntities.autoSieve.get(), + (blockEntity, context) -> blockEntity.getEnergyStorage()); + event.registerBlockEntity(NeoForgeBalm.ENERGY_STORAGE_CAPABILITY, + ModBlockEntities.autoHeavySieve.get(), + (blockEntity, context) -> blockEntity.getEnergyStorage()); + event.registerBlockEntity(NeoForgeBalm.ENERGY_STORAGE_CAPABILITY, + ModBlockEntities.autoHammer.get(), + (blockEntity, context) -> blockEntity.getEnergyStorage()); + event.registerBlockEntity(NeoForgeBalm.ENERGY_STORAGE_CAPABILITY, + ModBlockEntities.autoCompressedHammer.get(), + (blockEntity, context) -> blockEntity.getEnergyStorage()); + } }