Skip to content

Commit

Permalink
Fix menu content helper on neoforge
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatGravyBoat committed Jan 1, 2024
1 parent 72a2185 commit d09c63f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
import net.neoforged.neoforge.network.NetworkHooks;

import java.util.Optional;

Expand All @@ -23,7 +22,7 @@ public static <T extends AbstractContainerMenu, C extends MenuContent<C>> MenuTy
}

public static <C extends MenuContent<C>> void open(ServerPlayer player, ContentMenuProvider<C> provider) {
NetworkHooks.openScreen(player, provider, buf -> {
player.openMenu(provider, buf -> {
C content = provider.createContent();
if (content != null) {
content.serializer().to(buf, content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.mojang.serialization.Codec;
import com.teamresourceful.resourcefullib.common.recipe.ingredient.CodecIngredient;
import com.teamresourceful.resourcefullib.common.recipe.ingredient.CodecIngredientSerializer;
import com.teamresourceful.resourcefullib.neoforge.ResourcefulLibNeoForge;
import net.minecraft.world.item.crafting.Ingredient;
import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext;
import net.neoforged.neoforge.common.crafting.IngredientType;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.neoforged.neoforge.registries.NeoForgeRegistries;
Expand All @@ -19,7 +19,7 @@ public class IngredientHelperImpl {
private static DeferredRegister<IngredientType<?>> getOrCreate(String namespace) {
return REGISTRIES.computeIfAbsent(namespace, s -> {
var registry = DeferredRegister.create(NeoForgeRegistries.INGREDIENT_TYPES, s);
registry.register(FMLJavaModLoadingContext.get().getModEventBus());
ResourcefulLibNeoForge.listen(registry::register);
return registry;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ResourcefulLibNeoForge {
public ResourcefulLibNeoForge(IEventBus bus) {
ResourcefulLib.init();
if (FMLLoader.getDist().isClient()) {
ResourcefulLibNeoForgeClient.init();
ResourcefulLibNeoForgeClient.init(bus);
}

ResourcefulLibNeoForge.setBus(bus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
import net.neoforged.neoforge.client.event.RenderHighlightEvent;
import net.neoforged.neoforge.common.NeoForge;

public class ResourcefulLibNeoForgeClient {

public static void init() {
public static void init(IEventBus modEventBus) {
NeoForgeResourcePackHandler.load();
NeoForge.EVENT_BUS.addListener(ResourcefulLibNeoForgeClient::onHighlight);
NeoForge.EVENT_BUS.addListener(ResourcefulLibNeoForgeClient::onClientCommandRegister);
FMLJavaModLoadingContext.get().getModEventBus().addListener(ResourcefulLibNeoForgeClient::onClientReloadListeners);
FMLJavaModLoadingContext.get().getModEventBus().addListener(NeoForgeResourcePackHandler::onRegisterPackFinders);
modEventBus.addListener(ResourcefulLibNeoForgeClient::onClientReloadListeners);
modEventBus.addListener(NeoForgeResourcePackHandler::onRegisterPackFinders);
}

public static void onClientReloadListeners(RegisterClientReloadListenersEvent event) {
Expand Down

0 comments on commit d09c63f

Please sign in to comment.