正确注册Menu
This commit is contained in:
parent
9586526142
commit
0cf015bd7c
4 changed files with 27 additions and 19 deletions
|
@ -1,11 +1,15 @@
|
|||
package com.atsuishio.superbwarfare.block;
|
||||
|
||||
import com.atsuishio.superbwarfare.menu.ReforgingTableMenu;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -25,6 +29,7 @@ import net.minecraft.world.phys.shapes.Shapes;
|
|||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -118,11 +123,11 @@ public class ReforgingTableBlock extends Block {
|
|||
return super.updateShape(state, facing, facingState, world, currentPos, facingPos);
|
||||
}
|
||||
|
||||
// TODO Menu
|
||||
// @Override
|
||||
// @Nullable
|
||||
// public MenuProvider getMenuProvider(BlockState pState, Level pLevel, BlockPos pPos) {
|
||||
// return new SimpleMenuProvider((i, inventory, player) ->
|
||||
// new ReforgingTableMenu(i, inventory, ContainerLevelAccess.create(pLevel, pPos)), CONTAINER_TITLE);
|
||||
// }
|
||||
@Override
|
||||
@Nullable
|
||||
@ParametersAreNonnullByDefault
|
||||
public MenuProvider getMenuProvider(BlockState pState, Level pLevel, BlockPos pPos) {
|
||||
return new SimpleMenuProvider((i, inventory, player) ->
|
||||
new ReforgingTableMenu(i, inventory, ContainerLevelAccess.create(pLevel, pPos)), CONTAINER_TITLE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ public class ModItems {
|
|||
public static final DeferredHolder<Item, Item> TUNGSTEN_BLOCK = block(ModBlocks.TUNGSTEN_BLOCK);
|
||||
public static final DeferredHolder<Item, Item> SILVER_BLOCK = block(ModBlocks.SILVER_BLOCK);
|
||||
public static final DeferredHolder<Item, Item> CEMENTED_CARBIDE_BLOCK = block(ModBlocks.CEMENTED_CARBIDE_BLOCK);
|
||||
// public static final DeferredHolder<Item, Item> FUMO_25 = block(ModBlocks.FUMO_25);
|
||||
public static final DeferredHolder<Item, Item> FUMO_25 = block(ModBlocks.FUMO_25);
|
||||
|
||||
/**
|
||||
* Perk Items
|
||||
|
|
|
@ -6,26 +6,26 @@ import com.atsuishio.superbwarfare.menu.FuMO25Menu;
|
|||
import com.atsuishio.superbwarfare.menu.ReforgingTableMenu;
|
||||
import com.atsuishio.superbwarfare.menu.VehicleMenu;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
|
||||
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ModMenuTypes {
|
||||
|
||||
public static final DeferredRegister<MenuType<?>> REGISTRY = DeferredRegister.create(BuiltInRegistries.MENU, ModUtils.MODID);
|
||||
|
||||
public static final DeferredHolder<MenuType<?>, MenuType<AbstractContainerMenu>> REFORGING_TABLE_MENU =
|
||||
public static final Supplier<MenuType<ReforgingTableMenu>> REFORGING_TABLE_MENU =
|
||||
REGISTRY.register("reforging_table_menu",
|
||||
() -> IMenuTypeExtension.create((windowId, inv, data) -> new ReforgingTableMenu(windowId, inv)));
|
||||
public static final DeferredHolder<MenuType<?>, MenuType<AbstractContainerMenu>> CHARGING_STATION_MENU =
|
||||
public static final Supplier<MenuType<ChargingStationMenu>> CHARGING_STATION_MENU =
|
||||
REGISTRY.register("charging_station_menu",
|
||||
() -> IMenuTypeExtension.create((windowId, inv, data) -> new ChargingStationMenu(windowId, inv)));
|
||||
public static final DeferredHolder<MenuType<?>, MenuType<AbstractContainerMenu>> VEHICLE_MENU =
|
||||
public static final Supplier<MenuType<VehicleMenu>> VEHICLE_MENU =
|
||||
REGISTRY.register("vehicle_menu",
|
||||
() -> IMenuTypeExtension.create((windowId, inv, data) -> new VehicleMenu(windowId, inv)));
|
||||
public static final DeferredHolder<MenuType<?>, MenuType<AbstractContainerMenu>> FUMO_25_MENU =
|
||||
public static final Supplier<MenuType<FuMO25Menu>> FUMO_25_MENU =
|
||||
REGISTRY.register("fumo_25_menu",
|
||||
() -> IMenuTypeExtension.create((windowId, inv, data) -> new FuMO25Menu(windowId, inv)));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package com.atsuishio.superbwarfare.init;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.client.screens.ChargingStationScreen;
|
||||
import com.atsuishio.superbwarfare.client.screens.FuMO25Screen;
|
||||
import com.atsuishio.superbwarfare.client.screens.ReforgingTableScreen;
|
||||
import com.atsuishio.superbwarfare.client.screens.VehicleScreen;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
|
@ -11,10 +15,9 @@ public class ModScreens {
|
|||
|
||||
@SubscribeEvent
|
||||
public static void clientLoad(RegisterMenuScreensEvent event) {
|
||||
// TODO 正确注册menu
|
||||
// event.register(ModMenuTypes.REFORGING_TABLE_MENU.get(), ReforgingTableScreen::new);
|
||||
// event.register(ModMenuTypes.CHARGING_STATION_MENU.get(), ChargingStationScreen::new);
|
||||
// event.register(ModMenuTypes.VEHICLE_MENU.get(), VehicleScreen::new);
|
||||
// event.register(ModMenuTypes.FUMO_25_MENU.get(), FuMO25Screen::new);
|
||||
event.register(ModMenuTypes.REFORGING_TABLE_MENU.get(), ReforgingTableScreen::new);
|
||||
event.register(ModMenuTypes.CHARGING_STATION_MENU.get(), ChargingStationScreen::new);
|
||||
event.register(ModMenuTypes.VEHICLE_MENU.get(), VehicleScreen::new);
|
||||
event.register(ModMenuTypes.FUMO_25_MENU.get(), FuMO25Screen::new);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue