diff --git a/src/main/java/com/fureniku/metropolis/RegistrationBase.java b/src/main/java/com/fureniku/metropolis/RegistrationBase.java index 5b016cd..6411c14 100644 --- a/src/main/java/com/fureniku/metropolis/RegistrationBase.java +++ b/src/main/java/com/fureniku/metropolis/RegistrationBase.java @@ -1,13 +1,13 @@ package com.fureniku.metropolis; import com.fureniku.metropolis.blockentity.MetroBlockEntity; -import com.fureniku.metropolis.test.BlockEntityTest; -import com.fureniku.metropolis.test.RegistrationTest; +import com.fureniku.metropolis.menus.MetroMenu; import com.fureniku.metropolis.utils.CreativeTabSet; import com.fureniku.metropolis.utils.Debug; import net.minecraft.core.registries.Registries; import net.minecraft.data.DataGenerator; import net.minecraft.data.PackOutput; +import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.*; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -38,6 +38,7 @@ public abstract class RegistrationBase { protected final DeferredRegister itemRegistry; protected final DeferredRegister creativeTabs; protected final DeferredRegister> blockEntityRegistry; + protected final DeferredRegister> menuTypeRegistry; /** * Used by registration groups @@ -58,6 +59,7 @@ public RegistrationBase(String modid, IEventBus modEventBus) { itemRegistry = DeferredRegister.create(ForgeRegistries.ITEMS, modid); creativeTabs = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, modid); blockEntityRegistry = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, modid); + menuTypeRegistry = DeferredRegister.create(ForgeRegistries.MENU_TYPES, modid); modEventBus.addListener(this::common); modEventBus.addListener(this::client); modEventBus.addListener(this::buildCreativeTabs); @@ -69,6 +71,7 @@ public RegistrationBase(String modid, IEventBus modEventBus) { itemRegistry.register(modEventBus); creativeTabs.register(modEventBus); blockEntityRegistry.register(modEventBus); + menuTypeRegistry.register(modEventBus); } /** @@ -163,6 +166,10 @@ public RegistryObject> registerB return blockEntityRegistry.register(name + "_entity", () -> BlockEntityType.Builder.of(blockEntity, block.get()).build(null)); } + public RegistryObject> registerMenuType(String name, Supplier> menu) { + return menuTypeRegistry.register(name, menu); + } + /** * Add all your blocks to the created creative tabs in here! *

It may be neater to create a function for each tab, and call those functions from here.

diff --git a/src/main/java/com/fureniku/metropolis/menus/MetroMenu.java b/src/main/java/com/fureniku/metropolis/menus/MetroMenu.java new file mode 100644 index 0000000..ba2c05c --- /dev/null +++ b/src/main/java/com/fureniku/metropolis/menus/MetroMenu.java @@ -0,0 +1,12 @@ +package com.fureniku.metropolis.menus; + +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import org.jetbrains.annotations.Nullable; + +public abstract class MetroMenu extends AbstractContainerMenu { + + protected MetroMenu(@Nullable MenuType menuType, int containerId) { + super(menuType, containerId); + } +} diff --git a/src/main/java/com/fureniku/metropolis/utils/ShapeUtils.java b/src/main/java/com/fureniku/metropolis/utils/ShapeUtils.java index 3ab7f0b..4a99402 100644 --- a/src/main/java/com/fureniku/metropolis/utils/ShapeUtils.java +++ b/src/main/java/com/fureniku/metropolis/utils/ShapeUtils.java @@ -16,7 +16,8 @@ public class ShapeUtils { private static final Object2IntMap stateToIndex = new Object2IntOpenHashMap<>(); public static VoxelShape makeShape(float size, float height) { - return Block.box(size, 0, size, 16-size, height, 16-size); + double x = size/2; + return Block.box(8-x, 0, 8-x, 8+x, height, 8+x); } public static VoxelShape makeShape(Vec3 shape) {