From e8ae3316845a522709e72a77c611839b5372b9f7 Mon Sep 17 00:00:00 2001 From: Sunekaer - MAC Date: Mon, 15 Jan 2024 15:46:13 +0100 Subject: [PATCH] neo changes --- neoforge/build.gradle | 8 +++++++- .../sunekaer/toolkit/neoforge/ToolkitNeo.java | 4 +--- .../toolkit/neoforge/ToolkitPlatformImpl.java | 16 ++++++---------- neoforge/src/main/resources/META-INF/mods.toml | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 5c78617..1afa68d 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -82,4 +82,10 @@ publishing { from components.java } } -} \ No newline at end of file +} + +sourceSets.each { + def dir = layout.buildDirectory.dir("sourcesSets/$it.name") + it.output.resourcesDir = dir + it.java.destinationDirectory = dir +} diff --git a/neoforge/src/main/java/com/sunekaer/toolkit/neoforge/ToolkitNeo.java b/neoforge/src/main/java/com/sunekaer/toolkit/neoforge/ToolkitNeo.java index 9eb2972..a193cd3 100644 --- a/neoforge/src/main/java/com/sunekaer/toolkit/neoforge/ToolkitNeo.java +++ b/neoforge/src/main/java/com/sunekaer/toolkit/neoforge/ToolkitNeo.java @@ -8,7 +8,6 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; -import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext; import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredRegister; @@ -18,8 +17,7 @@ public class ToolkitNeo { private static final DeferredRegister> ARGUMENT_REGISTRY = DeferredRegister.create(BuiltInRegistries.COMMAND_ARGUMENT_TYPE, Toolkit.MOD_ID); private static final DeferredHolder, SingletonArgumentInfo> KILL_TYPE_ARG = ARGUMENT_REGISTRY.register("kill_type", () -> ArgumentTypeInfos.registerByClass(KillEntitiesCommand.KillTypeArgument.class, SingletonArgumentInfo.contextFree(KillEntitiesCommand.KillTypeArgument::killType))); - public ToolkitNeo() { - IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + public ToolkitNeo(IEventBus modEventBus) { Toolkit.init(); ARGUMENT_REGISTRY.register(modEventBus); diff --git a/neoforge/src/main/java/com/sunekaer/toolkit/neoforge/ToolkitPlatformImpl.java b/neoforge/src/main/java/com/sunekaer/toolkit/neoforge/ToolkitPlatformImpl.java index 75b0df8..913d298 100644 --- a/neoforge/src/main/java/com/sunekaer/toolkit/neoforge/ToolkitPlatformImpl.java +++ b/neoforge/src/main/java/com/sunekaer/toolkit/neoforge/ToolkitPlatformImpl.java @@ -8,8 +8,8 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.neoforged.fml.loading.FMLPaths; +import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.common.Tags; -import net.neoforged.neoforge.common.capabilities.Capabilities; import org.jetbrains.annotations.Nullable; import java.nio.file.Path; @@ -32,20 +32,16 @@ public static Path getGamePath() { public static List getInventoryFromBlockEntity(Level level, BlockPos pos, @Nullable Direction direction) { List items = new ArrayList<>(); - BlockEntity entity = level.getBlockEntity(pos); - if (entity == null) { - return items; - } - - entity.getCapability(Capabilities.ITEM_HANDLER).ifPresent(handler -> { - for (int i = 0; i < handler.getSlots(); i++) { - var stack = handler.getStackInSlot(i); + var obj = level.getCapability(Capabilities.ItemHandler.BLOCK, pos, Direction.UP); + if(obj != null) { + for (int i = 0; i < obj.getSlots(); i++) { + var stack = obj.getStackInSlot(i); if (stack.isEmpty()) { continue; } items.add(stack); } - }); + } return items; } diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml index dd463ed..0d542ba 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -27,7 +27,7 @@ side = "BOTH" [[dependencies.toolkit]] modId = "architectury" -mandatory = true +required = true versionRange = "[11.0.11,)" ordering = "AFTER" side = "BOTH"