From be1714e3287deea621adb802e0c1b84d1ccef574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E6=82=A6=E8=A7=A3=E8=AF=B4?= Date: Sat, 10 Aug 2024 23:42:39 +0800 Subject: [PATCH] Brand new filters system Bro I learned Java reflection at past day and right now I am using it XDDDD --- .../mtr/mapping/registry/RegistryHelper.java | 11 - .../tjmetro/fabric/MainFabricClient.java | 4 +- .../ziyue/tjmetro/mapping/FilterBuilder.java | 14 ++ .../ziyue/tjmetro/mapping/RegistryHelper.java | 28 +++ .../ziyue/tjmetro/mod/BlockEntityTypes.java | 8 +- .../java/ziyue/tjmetro/mod/BlockList.java | 192 +++++++++--------- .../ziyue/tjmetro/mod/CreativeModeTabs.java | 15 ++ .../main/java/ziyue/tjmetro/mod/ItemList.java | 23 +-- .../java/ziyue/tjmetro/mod/Reference.java | 2 +- .../main/java/ziyue/tjmetro/mod/Registry.java | 18 +- .../ziyue/tjmetro/mod/RegistryClient.java | 7 +- .../java/ziyue/tjmetro/mod/TianjinMetro.java | 2 +- .../ziyue/tjmetro/mod/TianjinMetroClient.java | 27 +-- .../mod/block/BlockAPGGlassTianjinBMT.java | 6 +- .../tjmetro/mod/block/BlockPSDTopTianjin.java | 4 +- .../ziyue/tjmetro/mod/client/Filters.java | 61 ++++-- .../resources/assets/tjmetro/lang/en_us.json | 16 +- .../mtr/mapping/registry/RegistryHelper.java | 11 - .../java/ziyue/tjmetro/forge/MainForge.java | 23 +-- .../ziyue/tjmetro/mapping/FilterBuilder.java | 19 +- .../ziyue/tjmetro/mapping/RegistryHelper.java | 27 +++ 21 files changed, 297 insertions(+), 221 deletions(-) delete mode 100644 fabric/src/main/java/org/mtr/mapping/registry/RegistryHelper.java create mode 100644 fabric/src/main/java/ziyue/tjmetro/mapping/RegistryHelper.java create mode 100644 fabric/src/main/java/ziyue/tjmetro/mod/CreativeModeTabs.java delete mode 100644 forge/src/main/java/org/mtr/mapping/registry/RegistryHelper.java create mode 100644 forge/src/main/java/ziyue/tjmetro/mapping/RegistryHelper.java diff --git a/fabric/src/main/java/org/mtr/mapping/registry/RegistryHelper.java b/fabric/src/main/java/org/mtr/mapping/registry/RegistryHelper.java deleted file mode 100644 index fbce0c6..0000000 --- a/fabric/src/main/java/org/mtr/mapping/registry/RegistryHelper.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.mtr.mapping.registry; - -import org.mtr.mapping.holder.Identifier; - -// This is a very hacky way but I have no choice. -public interface RegistryHelper -{ - static ItemRegistryObject RegistryObjectBlock2Item(BlockRegistryObject fabric, Identifier forge) { - return new ItemRegistryObject(fabric.get().asItem()); - } -} diff --git a/fabric/src/main/java/ziyue/tjmetro/fabric/MainFabricClient.java b/fabric/src/main/java/ziyue/tjmetro/fabric/MainFabricClient.java index fc313be..55a24ea 100644 --- a/fabric/src/main/java/ziyue/tjmetro/fabric/MainFabricClient.java +++ b/fabric/src/main/java/ziyue/tjmetro/fabric/MainFabricClient.java @@ -3,6 +3,7 @@ import net.fabricmc.api.ClientModInitializer; import ziyue.tjmetro.mod.Registry; import ziyue.tjmetro.mod.TianjinMetroClient; +import ziyue.tjmetro.mod.client.Filters; /** * @since 1.0.0-beta-1 @@ -13,7 +14,6 @@ public final class MainFabricClient implements ClientModInitializer @Override public void onInitializeClient() { TianjinMetroClient.init(); - Registry.FILTERS_REGISTRY_ITEM.forEach(pair -> pair.getFirst().addItems(pair.getSecond().get().data)); - Registry.FILTERS_REGISTRY_BLOCK.forEach(pair -> pair.getFirst().addItems(pair.getSecond().get().asItem().data)); + Filters.init(); } } diff --git a/fabric/src/main/java/ziyue/tjmetro/mapping/FilterBuilder.java b/fabric/src/main/java/ziyue/tjmetro/mapping/FilterBuilder.java index 3b25443..c79487e 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mapping/FilterBuilder.java +++ b/fabric/src/main/java/ziyue/tjmetro/mapping/FilterBuilder.java @@ -3,7 +3,9 @@ import org.mtr.mapping.holder.ItemStack; import org.mtr.mapping.holder.MutableText; import org.mtr.mapping.holder.PressAction; +import org.mtr.mapping.registry.BlockRegistryObject; import org.mtr.mapping.registry.CreativeModeTabHolder; +import org.mtr.mapping.registry.ItemRegistryObject; import ziyue.filters.Filter; import java.util.function.Supplier; @@ -29,4 +31,16 @@ static void filtersVisibility(CreativeModeTabHolder creativeModeTab, boolean vis static void setReservedButton(CreativeModeTabHolder creativeModeTab, MutableText tooltip, PressAction onPress) { ziyue.filters.FilterBuilder.setReservedButton(creativeModeTab.creativeModeTab, tooltip.data, onPress); } + + static void addBlocks(Filter filter, BlockRegistryObject... blocks) { + for (BlockRegistryObject block : blocks) { + filter.addItems(block.get().asItem().data); + } + } + + static void addItems(Filter filter, ItemRegistryObject... items) { + for (ItemRegistryObject item : items) { + filter.addItems(item.get().data); + } + } } diff --git a/fabric/src/main/java/ziyue/tjmetro/mapping/RegistryHelper.java b/fabric/src/main/java/ziyue/tjmetro/mapping/RegistryHelper.java new file mode 100644 index 0000000..12cbb39 --- /dev/null +++ b/fabric/src/main/java/ziyue/tjmetro/mapping/RegistryHelper.java @@ -0,0 +1,28 @@ +package ziyue.tjmetro.mapping; + +import org.mtr.mapping.holder.Identifier; +import org.mtr.mapping.holder.Item; +import org.mtr.mapping.registry.BlockRegistryObject; +import org.mtr.mapping.registry.ItemRegistryObject; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +/** + * Converting block to item. This may not be stable since it uses reflection. + * + * @author ZiYueCommentary + * @since 1.0.0-beta-2 + */ + +// This is a very mad way but I have no choice. +public interface RegistryHelper +{ + static ItemRegistryObject RegistryObjectBlock2Item(BlockRegistryObject fabric, Identifier forge) + throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException { + Class clazz = ItemRegistryObject.class; + Constructor constructor = clazz.getDeclaredConstructor(Item.class); + constructor.setAccessible(true); + return constructor.newInstance(fabric.get().asItem()); + } +} diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/BlockEntityTypes.java b/fabric/src/main/java/ziyue/tjmetro/mod/BlockEntityTypes.java index e257880..a495e00 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/BlockEntityTypes.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/BlockEntityTypes.java @@ -50,7 +50,7 @@ public interface BlockEntityTypes BlockEntityTypeRegistryObject STATION_NAME_ENTRANCE_TIANJIN_PINYIN = Registry.registerBlockEntityType("station_name_entrance_tianjin_pinyin", (pos, state) -> new BlockStationNameEntranceTianjin.BlockEntity(true, false, pos, state), BlockList.STATION_NAME_ENTRANCE_TIANJIN_PINYIN::get); BlockEntityTypeRegistryObject STATION_NAME_ENTRANCE_TIANJIN_BMT = Registry.registerBlockEntityType("station_name_entrance_tianjin_bmt", (pos, state) -> new BlockStationNameEntranceTianjin.BlockEntity(false, true, pos, state), BlockList.STATION_NAME_ENTRANCE_TIANJIN_BMT::get); BlockEntityTypeRegistryObject STATION_NAME_ENTRANCE_TIANJIN_BMT_PINYIN = Registry.registerBlockEntityType("station_name_entrance_tianjin_bmt_pinyin", (pos, state) -> new BlockStationNameEntranceTianjin.BlockEntity(true, true, pos, state), BlockList.STATION_NAME_ENTRANCE_TIANJIN_BMT_PINYIN::get); - BlockEntityTypeRegistryObject PSD_DOOR_TIANJIN = Registry.registerBlockEntityType("psd_door_tianjin", BlockPSDDoorTianjin.BlockEntity::new, BlockList.PSD_DOOR_TIANJIN::get); + BlockEntityTypeRegistryObject PSD_DOOR_TIANJIN = Registry.registerBlockEntityType("psd_door_tianjin", BlockPSDDoorTianjin.BlockEntity::new, BlockList.PSD_DOOR_TIANJIN_BLOCK::get); BlockEntityTypeRegistryObject PSD_TOP_TIANJIN = Registry.registerBlockEntityType("psd_top_tianjin", BlockPSDTopTianjin.BlockEntity::new, BlockList.PSD_TOP_TIANJIN::get); BlockEntityTypeRegistryObject STATION_NAME_WALL_LEGACY = Registry.registerBlockEntityType("station_name_wall_legacy", BlockStationNameWallLegacy.BlockEntity::new, BlockList.STATION_NAME_WALL_LEGACY::get); BlockEntityTypeRegistryObject STATION_NAME_PLATE = Registry.registerBlockEntityType("station_name_plate", BlockStationNamePlate.BlockEntity::new, BlockList.STATION_NAME_PLATE::get); @@ -66,9 +66,9 @@ public interface BlockEntityTypes BlockEntityTypeRegistryObject RAILWAY_SIGN_TIANJIN_BMT_5_EVEN = Registry.registerBlockEntityType("railway_sign_tianjin_bmt_5_even", (pos, state) -> new BlockRailwaySignTianjinBMT.BlockEntity(5, false, pos, state), BlockList.RAILWAY_SIGN_TIANJIN_BMT_5_EVEN::get); BlockEntityTypeRegistryObject RAILWAY_SIGN_TIANJIN_BMT_6_EVEN = Registry.registerBlockEntityType("railway_sign_tianjin_bmt_6_even", (pos, state) -> new BlockRailwaySignTianjinBMT.BlockEntity(6, false, pos, state), BlockList.RAILWAY_SIGN_TIANJIN_BMT_6_EVEN::get); BlockEntityTypeRegistryObject RAILWAY_SIGN_TIANJIN_BMT_7_EVEN = Registry.registerBlockEntityType("railway_sign_tianjin_bmt_7_even", (pos, state) -> new BlockRailwaySignTianjinBMT.BlockEntity(7, false, pos, state), BlockList.RAILWAY_SIGN_TIANJIN_BMT_7_EVEN::get); - BlockEntityTypeRegistryObject APG_DOOR_TIANJIN = Registry.registerBlockEntityType("apg_door_tianjin", BlockAPGDoorTianjin.BlockEntity::new, BlockList.APG_DOOR_TIANJIN::get); - BlockEntityTypeRegistryObject APG_DOOR_TIANJIN_BMT = Registry.registerBlockEntityType("apg_door_tianjin_bmt", BlockAPGDoorTianjinBMT.BlockEntity::new, BlockList.APG_DOOR_TIANJIN_BMT::get); - BlockEntityTypeRegistryObject APG_GLASS_TIANJIN_BMT = Registry.registerBlockEntityType("apg_glass_tianjin_bmt", BlockAPGGlassTianjinBMT.BlockEntity::new, BlockList.APG_GLASS_TIANJIN_BMT::get); + BlockEntityTypeRegistryObject APG_DOOR_TIANJIN = Registry.registerBlockEntityType("apg_door_tianjin", BlockAPGDoorTianjin.BlockEntity::new, BlockList.APG_DOOR_TIANJIN_BLOCK::get); + BlockEntityTypeRegistryObject APG_DOOR_TIANJIN_BMT = Registry.registerBlockEntityType("apg_door_tianjin_bmt", BlockAPGDoorTianjinBMT.BlockEntity::new, BlockList.APG_DOOR_TIANJIN_BMT_BLOCK::get); + BlockEntityTypeRegistryObject APG_GLASS_TIANJIN_BMT = Registry.registerBlockEntityType("apg_glass_tianjin_bmt", BlockAPGGlassTianjinBMT.BlockEntity::new, BlockList.APG_GLASS_TIANJIN_BMT_BLOCK::get); BlockEntityTypeRegistryObject METAL_POLE_BMT = Registry.registerBlockEntityType("metal_pole_bmt", BlockMetalPoleBMT.BlockEntity::new, BlockList.METAL_POLE_BMT::get); static void registerBlockEntities() { diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/BlockList.java b/fabric/src/main/java/ziyue/tjmetro/mod/BlockList.java index eaa9483..fabea66 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/BlockList.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/BlockList.java @@ -12,116 +12,114 @@ import ziyue.tjmetro.mod.block.*; import ziyue.tjmetro.mod.block.base.StairBlock; -import static ziyue.tjmetro.mod.client.Filters.*; - /** * @since 1.0.0-beta-1 */ public interface BlockList { - BlockRegistryObject LOGO = Registry.registerBlockWithBlockItem("logo", () -> new Block(new BlockLogo()), DECORATION); - BlockRegistryObject PLAYER_DETECTOR = Registry.registerBlockWithBlockItem("player_detector", () -> new Block(new BlockPlayerDetector()), MISCELLANEOUS); - BlockRegistryObject ROLLING = Registry.registerBlockWithBlockItem("rolling", () -> new Block(new BlockRolling()), BUILDING); - BlockRegistryObject CEILING_NOT_LIT = Registry.registerBlockWithBlockItem("ceiling_not_lit", () -> new Block(new BlockCeiling(BlockHelper.createBlockSettings(false))), CEILINGS); - BlockRegistryObject STATION_COLOR_CEILING = Registry.registerBlockWithBlockItem("station_color_ceiling", () -> new Block(new BlockStationColorCeilingAuto()), ItemBlockEnchanted::new, CEILINGS); - BlockRegistryObject STATION_COLOR_CEILING_LIGHT = Registry.registerBlockWithBlockItem("station_color_ceiling_light", () -> new Block(new BlockStationColorCeiling()), ItemBlockEnchanted::new, CEILINGS); - BlockRegistryObject STATION_COLOR_CEILING_NO_LIGHT = Registry.registerBlockWithBlockItem("station_color_ceiling_no_light", () -> new Block(new BlockStationColorCeiling()), ItemBlockEnchanted::new, CEILINGS); - BlockRegistryObject STATION_COLOR_CEILING_NOT_LIT = Registry.registerBlockWithBlockItem("station_color_ceiling_not_lit", () -> new Block(new BlockStationColorCeiling(BlockHelper.createBlockSettings(false))), ItemBlockEnchanted::new, CEILINGS); - BlockRegistryObject STATION_NAME_SIGN_1 = Registry.registerBlockWithBlockItem("station_name_sign_1", () -> new Block(new BlockStationNameSign1()), SIGNS); - BlockRegistryObject STATION_NAME_SIGN_2 = Registry.registerBlockWithBlockItem("station_name_sign_2", () -> new Block(new BlockStationNameSign2()), SIGNS); - BlockRegistryObject APG_CORNER = Registry.registerBlockWithBlockItem("apg_corner", () -> new Block(new BlockAPGCorner()), DECORATION); - BlockRegistryObject PLATFORM_TJ_1 = Registry.registerBlockWithBlockItem("platform_tj_1", () -> new Block(new BlockPlatform(BlockHelper.createBlockSettings(false), false)), BUILDING); - BlockRegistryObject PLATFORM_TJ_1_INDENTED = Registry.registerBlockWithBlockItem("platform_tj_1_indented", () -> new Block(new BlockPlatform(BlockHelper.createBlockSettings(false), true)), BUILDING); - BlockRegistryObject PLATFORM_TJ_2 = Registry.registerBlockWithBlockItem("platform_tj_2", () -> new Block(new BlockPlatform(BlockHelper.createBlockSettings(false), false)), BUILDING); - BlockRegistryObject PLATFORM_TJ_2_INDENTED = Registry.registerBlockWithBlockItem("platform_tj_2_indented", () -> new Block(new BlockPlatform(BlockHelper.createBlockSettings(false), true)), BUILDING); - BlockRegistryObject MARBLE_GRAY = Registry.registerBlockWithBlockItem("marble_gray", () -> new Block(BlockHelper.createBlockSettings(false)), BUILDING); - BlockRegistryObject MARBLE_GRAY_SLAB = Registry.registerBlockWithBlockItem("marble_gray_slab", () -> new Block(new SlabBlockExtension(BlockHelper.createBlockSettings(false))), BUILDING); - BlockRegistryObject MARBLE_GRAY_STAIRS = Registry.registerBlockWithBlockItem("marble_gray_stairs", () -> new Block(new StairBlock(Blocks.getBricksMapped())), BUILDING); - BlockRegistryObject MARBLE_YELLOW = Registry.registerBlockWithBlockItem("marble_yellow", () -> new Block(BlockHelper.createBlockSettings(false)), BUILDING); - BlockRegistryObject MARBLE_YELLOW_SLAB = Registry.registerBlockWithBlockItem("marble_yellow_slab", () -> new Block(new SlabBlockExtension(BlockHelper.createBlockSettings(false))), BUILDING); - BlockRegistryObject MARBLE_YELLOW_STAIRS = Registry.registerBlockWithBlockItem("marble_yellow_stairs", () -> new Block(new StairBlock(Blocks.getBricksMapped())), BUILDING); - BlockRegistryObject TIME_DISPLAY = Registry.registerBlockWithBlockItem("time_display", () -> new Block(new BlockTimeDisplay()), DECORATION); - BlockRegistryObject EMERGENCY_EXIT_SIGN = Registry.registerBlockWithBlockItem("emergency_exit_sign", () -> new Block(new BlockEmergencyExitSign()), DECORATION); - BlockRegistryObject SERVICE_CORRIDOR_SIGN = Registry.registerBlockWithBlockItem("service_corridor_sign", () -> new Block(new BlockServiceCorridorSign()), DECORATION); - BlockRegistryObject ROADBLOCK = Registry.registerBlockWithBlockItem("roadblock", () -> new Block(new BlockRoadblock()), BUILDING); - BlockRegistryObject ROADBLOCK_SIGN = Registry.registerBlockWithBlockItem("roadblock_sign", () -> new Block(new BlockRoadblockSign()), BUILDING); - BlockRegistryObject BENCH = Registry.registerBlockWithBlockItem("bench", () -> new Block(new BlockBench()), DECORATION); - BlockRegistryObject CUSTOM_COLOR_CONCRETE = Registry.registerBlockWithBlockItem("custom_color_concrete", () -> new Block(new BlockCustomColorConcrete()), ItemBlockEnchanted::new, BUILDING); - BlockRegistryObject CUSTOM_COLOR_CONCRETE_SLAB = Registry.registerBlockWithBlockItem("custom_color_concrete_slab", () -> new Block(new BlockCustomColorConcreteSlab()), ItemBlockEnchanted::new, BUILDING); - BlockRegistryObject CUSTOM_COLOR_CONCRETE_STAIRS = Registry.registerBlockWithBlockItem("custom_color_concrete_stairs", () -> new Block(new BlockCustomColorConcreteStairs()), ItemBlockEnchanted::new, BUILDING); - BlockRegistryObject RAILWAY_SIGN_WALL_4 = Registry.registerBlockWithBlockItem("railway_sign_wall_4", () -> new Block(new BlockRailwaySignWall(4)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_6 = Registry.registerBlockWithBlockItem("railway_sign_wall_6", () -> new Block(new BlockRailwaySignWall(6)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_8 = Registry.registerBlockWithBlockItem("railway_sign_wall_8", () -> new Block(new BlockRailwaySignWall(8)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_10 = Registry.registerBlockWithBlockItem("railway_sign_wall_10", () -> new Block(new BlockRailwaySignWall(10)), RAILWAY_SIGNS); + BlockRegistryObject LOGO = Registry.registerBlockWithBlockItem("logo", () -> new Block(new BlockLogo()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject PLAYER_DETECTOR = Registry.registerBlockWithBlockItem("player_detector", () -> new Block(new BlockPlayerDetector()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject ROLLING = Registry.registerBlockWithBlockItem("rolling", () -> new Block(new BlockRolling()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject CEILING_NOT_LIT = Registry.registerBlockWithBlockItem("ceiling_not_lit", () -> new Block(new BlockCeiling(BlockHelper.createBlockSettings(false))), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_COLOR_CEILING = Registry.registerBlockWithBlockItem("station_color_ceiling", () -> new Block(new BlockStationColorCeilingAuto()), ItemBlockEnchanted::new, CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_COLOR_CEILING_LIGHT = Registry.registerBlockWithBlockItem("station_color_ceiling_light", () -> new Block(new BlockStationColorCeiling()), ItemBlockEnchanted::new, CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_COLOR_CEILING_NO_LIGHT = Registry.registerBlockWithBlockItem("station_color_ceiling_no_light", () -> new Block(new BlockStationColorCeiling()), ItemBlockEnchanted::new, CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_COLOR_CEILING_NOT_LIT = Registry.registerBlockWithBlockItem("station_color_ceiling_not_lit", () -> new Block(new BlockStationColorCeiling(BlockHelper.createBlockSettings(false))), ItemBlockEnchanted::new, CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_NAME_SIGN_1 = Registry.registerBlockWithBlockItem("station_name_sign_1", () -> new Block(new BlockStationNameSign1()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_NAME_SIGN_2 = Registry.registerBlockWithBlockItem("station_name_sign_2", () -> new Block(new BlockStationNameSign2()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject APG_CORNER = Registry.registerBlockWithBlockItem("apg_corner", () -> new Block(new BlockAPGCorner()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject PLATFORM_TJ_1 = Registry.registerBlockWithBlockItem("platform_tj_1", () -> new Block(new BlockPlatform(BlockHelper.createBlockSettings(false), false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject PLATFORM_TJ_1_INDENTED = Registry.registerBlockWithBlockItem("platform_tj_1_indented", () -> new Block(new BlockPlatform(BlockHelper.createBlockSettings(false), true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject PLATFORM_TJ_2 = Registry.registerBlockWithBlockItem("platform_tj_2", () -> new Block(new BlockPlatform(BlockHelper.createBlockSettings(false), false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject PLATFORM_TJ_2_INDENTED = Registry.registerBlockWithBlockItem("platform_tj_2_indented", () -> new Block(new BlockPlatform(BlockHelper.createBlockSettings(false), true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject MARBLE_GRAY = Registry.registerBlockWithBlockItem("marble_gray", () -> new Block(BlockHelper.createBlockSettings(false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject MARBLE_GRAY_SLAB = Registry.registerBlockWithBlockItem("marble_gray_slab", () -> new Block(new SlabBlockExtension(BlockHelper.createBlockSettings(false))), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject MARBLE_GRAY_STAIRS = Registry.registerBlockWithBlockItem("marble_gray_stairs", () -> new Block(new StairBlock(Blocks.getBricksMapped())), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject MARBLE_YELLOW = Registry.registerBlockWithBlockItem("marble_yellow", () -> new Block(BlockHelper.createBlockSettings(false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject MARBLE_YELLOW_SLAB = Registry.registerBlockWithBlockItem("marble_yellow_slab", () -> new Block(new SlabBlockExtension(BlockHelper.createBlockSettings(false))), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject MARBLE_YELLOW_STAIRS = Registry.registerBlockWithBlockItem("marble_yellow_stairs", () -> new Block(new StairBlock(Blocks.getBricksMapped())), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject TIME_DISPLAY = Registry.registerBlockWithBlockItem("time_display", () -> new Block(new BlockTimeDisplay()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject EMERGENCY_EXIT_SIGN = Registry.registerBlockWithBlockItem("emergency_exit_sign", () -> new Block(new BlockEmergencyExitSign()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject SERVICE_CORRIDOR_SIGN = Registry.registerBlockWithBlockItem("service_corridor_sign", () -> new Block(new BlockServiceCorridorSign()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject ROADBLOCK = Registry.registerBlockWithBlockItem("roadblock", () -> new Block(new BlockRoadblock()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject ROADBLOCK_SIGN = Registry.registerBlockWithBlockItem("roadblock_sign", () -> new Block(new BlockRoadblockSign()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject BENCH = Registry.registerBlockWithBlockItem("bench", () -> new Block(new BlockBench()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject CUSTOM_COLOR_CONCRETE = Registry.registerBlockWithBlockItem("custom_color_concrete", () -> new Block(new BlockCustomColorConcrete()), ItemBlockEnchanted::new, CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject CUSTOM_COLOR_CONCRETE_SLAB = Registry.registerBlockWithBlockItem("custom_color_concrete_slab", () -> new Block(new BlockCustomColorConcreteSlab()), ItemBlockEnchanted::new, CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject CUSTOM_COLOR_CONCRETE_STAIRS = Registry.registerBlockWithBlockItem("custom_color_concrete_stairs", () -> new Block(new BlockCustomColorConcreteStairs()), ItemBlockEnchanted::new, CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_4 = Registry.registerBlockWithBlockItem("railway_sign_wall_4", () -> new Block(new BlockRailwaySignWall(4)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_6 = Registry.registerBlockWithBlockItem("railway_sign_wall_6", () -> new Block(new BlockRailwaySignWall(6)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_8 = Registry.registerBlockWithBlockItem("railway_sign_wall_8", () -> new Block(new BlockRailwaySignWall(8)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_10 = Registry.registerBlockWithBlockItem("railway_sign_wall_10", () -> new Block(new BlockRailwaySignWall(10)), CreativeModeTabs.TIANJIN_METRO); BlockRegistryObject RAILWAY_SIGN_WALL_MIDDLE = Registry.registerBlock("railway_sign_wall_middle", () -> new Block(new BlockRailwaySignWall(0))); - BlockRegistryObject RAILWAY_SIGN_WALL_DOUBLE_4 = Registry.registerBlockWithBlockItem("railway_sign_wall_double_4", () -> new Block(new BlockRailwaySignWallDouble(4)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_DOUBLE_6 = Registry.registerBlockWithBlockItem("railway_sign_wall_double_6", () -> new Block(new BlockRailwaySignWallDouble(6)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_DOUBLE_8 = Registry.registerBlockWithBlockItem("railway_sign_wall_double_8", () -> new Block(new BlockRailwaySignWallDouble(8)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_DOUBLE_10 = Registry.registerBlockWithBlockItem("railway_sign_wall_double_10", () -> new Block(new BlockRailwaySignWallDouble(10)), RAILWAY_SIGNS); + BlockRegistryObject RAILWAY_SIGN_WALL_DOUBLE_4 = Registry.registerBlockWithBlockItem("railway_sign_wall_double_4", () -> new Block(new BlockRailwaySignWallDouble(4)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_DOUBLE_6 = Registry.registerBlockWithBlockItem("railway_sign_wall_double_6", () -> new Block(new BlockRailwaySignWallDouble(6)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_DOUBLE_8 = Registry.registerBlockWithBlockItem("railway_sign_wall_double_8", () -> new Block(new BlockRailwaySignWallDouble(8)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_DOUBLE_10 = Registry.registerBlockWithBlockItem("railway_sign_wall_double_10", () -> new Block(new BlockRailwaySignWallDouble(10)), CreativeModeTabs.TIANJIN_METRO); BlockRegistryObject RAILWAY_SIGN_WALL_DOUBLE_MIDDLE = Registry.registerBlock("railway_sign_wall_double_middle", () -> new Block(new BlockRailwaySignWallDouble(0))); - BlockRegistryObject RAILWAY_SIGN_WALL_BIG_2 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_2", () -> new Block(new BlockRailwaySignWallBig(2)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_BIG_3 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_3", () -> new Block(new BlockRailwaySignWallBig(3)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_BIG_4 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_4", () -> new Block(new BlockRailwaySignWallBig(4)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_BIG_5 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_5", () -> new Block(new BlockRailwaySignWallBig(5)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_BIG_6 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_6", () -> new Block(new BlockRailwaySignWallBig(6)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_BIG_7 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_7", () -> new Block(new BlockRailwaySignWallBig(7)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_BIG_8 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_8", () -> new Block(new BlockRailwaySignWallBig(8)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_BIG_9 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_9", () -> new Block(new BlockRailwaySignWallBig(9)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_WALL_BIG_10 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_10", () -> new Block(new BlockRailwaySignWallBig(10)), RAILWAY_SIGNS); + BlockRegistryObject RAILWAY_SIGN_WALL_BIG_2 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_2", () -> new Block(new BlockRailwaySignWallBig(2)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_BIG_3 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_3", () -> new Block(new BlockRailwaySignWallBig(3)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_BIG_4 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_4", () -> new Block(new BlockRailwaySignWallBig(4)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_BIG_5 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_5", () -> new Block(new BlockRailwaySignWallBig(5)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_BIG_6 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_6", () -> new Block(new BlockRailwaySignWallBig(6)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_BIG_7 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_7", () -> new Block(new BlockRailwaySignWallBig(7)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_BIG_8 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_8", () -> new Block(new BlockRailwaySignWallBig(8)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_BIG_9 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_9", () -> new Block(new BlockRailwaySignWallBig(9)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_WALL_BIG_10 = Registry.registerBlockWithBlockItem("railway_sign_wall_big_10", () -> new Block(new BlockRailwaySignWallBig(10)), CreativeModeTabs.TIANJIN_METRO); BlockRegistryObject RAILWAY_SIGN_WALL_BIG_MIDDLE = Registry.registerBlock("railway_sign_wall_big_middle", () -> new Block(new BlockRailwaySignWallBig(0))); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_3_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_3_odd", () -> new Block(new BlockRailwaySignTianjin(3, true)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_4_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_4_odd", () -> new Block(new BlockRailwaySignTianjin(4, true)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_5_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_5_odd", () -> new Block(new BlockRailwaySignTianjin(5, true)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_6_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_6_odd", () -> new Block(new BlockRailwaySignTianjin(6, true)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_7_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_7_odd", () -> new Block(new BlockRailwaySignTianjin(7, true)), RAILWAY_SIGNS); -// BlockRegistryObject RAILWAY_SIGN_TIANJIN_8_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_8_odd", () -> new Block(new BlockRailwaySignTianjin(8, true)), SIGNS); -// BlockRegistryObject RAILWAY_SIGN_TIANJIN_9_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_9_odd", () -> new Block(new BlockRailwaySignTianjin(9, true)), SIGNS); -// BlockRegistryObject RAILWAY_SIGN_TIANJIN_10_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_10_odd", () -> new Block(new BlockRailwaySignTianjin(10, true)), SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_2_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_2_even", () -> new Block(new BlockRailwaySignTianjin(2, false)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_3_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_3_even", () -> new Block(new BlockRailwaySignTianjin(3, false)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_4_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_4_even", () -> new Block(new BlockRailwaySignTianjin(4, false)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_5_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_5_even", () -> new Block(new BlockRailwaySignTianjin(5, false)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_6_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_6_even", () -> new Block(new BlockRailwaySignTianjin(6, false)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_7_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_7_even", () -> new Block(new BlockRailwaySignTianjin(7, false)), RAILWAY_SIGNS); -// BlockRegistryObject RAILWAY_SIGN_TIANJIN_8_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_8_even", () -> new Block(new BlockRailwaySignTianjin(8, false)), SIGNS); -// BlockRegistryObject RAILWAY_SIGN_TIANJIN_9_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_9_even", () -> new Block(new BlockRailwaySignTianjin(9, false)), SIGNS); -// BlockRegistryObject RAILWAY_SIGN_TIANJIN_10_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_10_even", () -> new Block(new BlockRailwaySignTianjin(10, false)), SIGNS); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_3_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_3_odd", () -> new Block(new BlockRailwaySignTianjin(3, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_4_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_4_odd", () -> new Block(new BlockRailwaySignTianjin(4, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_5_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_5_odd", () -> new Block(new BlockRailwaySignTianjin(5, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_6_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_6_odd", () -> new Block(new BlockRailwaySignTianjin(6, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_7_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_7_odd", () -> new Block(new BlockRailwaySignTianjin(7, true)), CreativeModeTabs.TIANJIN_METRO); +// BlockRegistryObject RAILWAY_SIGN_TIANJIN_8_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_8_odd", () -> new Block(new BlockRailwaySignTianjin(8, true)), CreativeModeTabs.TIANJIN_METRO); +// BlockRegistryObject RAILWAY_SIGN_TIANJIN_9_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_9_odd", () -> new Block(new BlockRailwaySignTianjin(9, true)), CreativeModeTabs.TIANJIN_METRO); +// BlockRegistryObject RAILWAY_SIGN_TIANJIN_10_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_10_odd", () -> new Block(new BlockRailwaySignTianjin(10, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_2_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_2_even", () -> new Block(new BlockRailwaySignTianjin(2, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_3_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_3_even", () -> new Block(new BlockRailwaySignTianjin(3, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_4_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_4_even", () -> new Block(new BlockRailwaySignTianjin(4, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_5_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_5_even", () -> new Block(new BlockRailwaySignTianjin(5, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_6_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_6_even", () -> new Block(new BlockRailwaySignTianjin(6, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_7_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_7_even", () -> new Block(new BlockRailwaySignTianjin(7, false)), CreativeModeTabs.TIANJIN_METRO); +// BlockRegistryObject RAILWAY_SIGN_TIANJIN_8_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_8_even", () -> new Block(new BlockRailwaySignTianjin(8, false)), CreativeModeTabs.TIANJIN_METRO); +// BlockRegistryObject RAILWAY_SIGN_TIANJIN_9_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_9_even", () -> new Block(new BlockRailwaySignTianjin(9, false)), CreativeModeTabs.TIANJIN_METRO); +// BlockRegistryObject RAILWAY_SIGN_TIANJIN_10_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_10_even", () -> new Block(new BlockRailwaySignTianjin(10, false)), CreativeModeTabs.TIANJIN_METRO); BlockRegistryObject RAILWAY_SIGN_TIANJIN_MIDDLE = Registry.registerBlock("railway_sign_tianjin_middle", () -> new Block(new BlockRailwaySignTianjin(0, false))); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_POLE = Registry.registerBlockWithBlockItem("railway_sign_tianjin_pole", () -> new Block(new BlockRailwaySignTianjinPole()), RAILWAY_SIGNS); - BlockRegistryObject STATION_NAME_ENTRANCE_TIANJIN = Registry.registerBlockWithBlockItem("station_name_entrance_tianjin", () -> new Block(new BlockStationNameEntranceTianjin(false, false)), SIGNS); - BlockRegistryObject STATION_NAME_ENTRANCE_TIANJIN_PINYIN = Registry.registerBlockWithBlockItem("station_name_entrance_tianjin_pinyin", () -> new Block(new BlockStationNameEntranceTianjin(true, false)), SIGNS); - BlockRegistryObject STATION_NAME_ENTRANCE_TIANJIN_BMT = Registry.registerBlockWithBlockItem("station_name_entrance_tianjin_bmt", () -> new Block(new BlockStationNameEntranceTianjin(false, true)), SIGNS); - BlockRegistryObject STATION_NAME_ENTRANCE_TIANJIN_BMT_PINYIN = Registry.registerBlockWithBlockItem("station_name_entrance_tianjin_bmt_pinyin", () -> new Block(new BlockStationNameEntranceTianjin(true, true)), SIGNS); - BlockRegistryObject PSD_DOOR_TIANJIN = Registry.registerBlock("psd_door_tianjin", () -> new Block(new BlockPSDDoorTianjin())); - BlockRegistryObject PSD_GLASS_TIANJIN = Registry.registerBlock("psd_glass_tianjin", () -> new Block(new BlockPSDGlassTianjin())); - BlockRegistryObject PSD_GLASS_END_TIANJIN = Registry.registerBlock("psd_glass_end_tianjin", () -> new Block(new BlockPSDGlassEndTianjin())); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_POLE = Registry.registerBlockWithBlockItem("railway_sign_tianjin_pole", () -> new Block(new BlockRailwaySignTianjinPole()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_NAME_ENTRANCE_TIANJIN = Registry.registerBlockWithBlockItem("station_name_entrance_tianjin", () -> new Block(new BlockStationNameEntranceTianjin(false, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_NAME_ENTRANCE_TIANJIN_PINYIN = Registry.registerBlockWithBlockItem("station_name_entrance_tianjin_pinyin", () -> new Block(new BlockStationNameEntranceTianjin(true, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_NAME_ENTRANCE_TIANJIN_BMT = Registry.registerBlockWithBlockItem("station_name_entrance_tianjin_bmt", () -> new Block(new BlockStationNameEntranceTianjin(false, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_NAME_ENTRANCE_TIANJIN_BMT_PINYIN = Registry.registerBlockWithBlockItem("station_name_entrance_tianjin_bmt_pinyin", () -> new Block(new BlockStationNameEntranceTianjin(true, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject PSD_DOOR_TIANJIN_BLOCK = Registry.registerBlock("psd_door_tianjin", () -> new Block(new BlockPSDDoorTianjin())); + BlockRegistryObject PSD_GLASS_TIANJIN_BLOCK = Registry.registerBlock("psd_glass_tianjin", () -> new Block(new BlockPSDGlassTianjin())); + BlockRegistryObject PSD_GLASS_END_TIANJIN_BLOCK = Registry.registerBlock("psd_glass_end_tianjin", () -> new Block(new BlockPSDGlassEndTianjin())); BlockRegistryObject PSD_TOP_TIANJIN = Registry.registerBlock("psd_top_tianjin", () -> new Block(new BlockPSDTopTianjin())); - BlockRegistryObject METAL_DETECTION_DOOR = Registry.registerBlockWithBlockItem("metal_detection_door", () -> new Block(new BlockMetalDetectionDoor()), DECORATION); -// BlockRegistryObject HIGH_SPEED_REPEATER = Registry.registerBlockWithBlockItem("high_speed_repeater", () -> new Block(new BlockHighSpeedRepeater()), MISCELLANEOUS); - BlockRegistryObject STATION_NAME_WALL_LEGACY = Registry.registerBlockWithBlockItem("station_name_wall_legacy", () -> new Block(new BlockStationNameWallLegacy()), SIGNS); - BlockRegistryObject STATION_NAME_PLATE = Registry.registerBlockWithBlockItem("station_name_plate", () -> new Block(new BlockStationNamePlate()), SIGNS); + BlockRegistryObject METAL_DETECTION_DOOR = Registry.registerBlockWithBlockItem("metal_detection_door", () -> new Block(new BlockMetalDetectionDoor()), CreativeModeTabs.TIANJIN_METRO); +// BlockRegistryObject HIGH_SPEED_REPEATER = Registry.registerBlockWithBlockItem("high_speed_repeater", () -> new Block(new BlockHighSpeedRepeater()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_NAME_WALL_LEGACY = Registry.registerBlockWithBlockItem("station_name_wall_legacy", () -> new Block(new BlockStationNameWallLegacy()), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject STATION_NAME_PLATE = Registry.registerBlockWithBlockItem("station_name_plate", () -> new Block(new BlockStationNamePlate()), CreativeModeTabs.TIANJIN_METRO); BlockRegistryObject STATION_NAME_PLATE_MIDDLE = Registry.registerBlock("station_name_plate_middle", () -> new Block(new BlockStationNamePlate())); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_2_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_2_odd", () -> new Block(new BlockRailwaySignTianjinBMT(2, true)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_3_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_3_odd", () -> new Block(new BlockRailwaySignTianjinBMT(3, true)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_4_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_4_odd", () -> new Block(new BlockRailwaySignTianjinBMT(4, true)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_5_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_5_odd", () -> new Block(new BlockRailwaySignTianjinBMT(5, true)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_6_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_6_odd", () -> new Block(new BlockRailwaySignTianjinBMT(6, true)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_7_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_7_odd", () -> new Block(new BlockRailwaySignTianjinBMT(7, true)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_2_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_2_even", () -> new Block(new BlockRailwaySignTianjinBMT(2, false)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_3_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_3_even", () -> new Block(new BlockRailwaySignTianjinBMT(3, false)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_4_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_4_even", () -> new Block(new BlockRailwaySignTianjinBMT(4, false)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_5_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_5_even", () -> new Block(new BlockRailwaySignTianjinBMT(5, false)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_6_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_6_even", () -> new Block(new BlockRailwaySignTianjinBMT(6, false)), RAILWAY_SIGNS); - BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_7_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_7_even", () -> new Block(new BlockRailwaySignTianjinBMT(7, false)), RAILWAY_SIGNS); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_2_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_2_odd", () -> new Block(new BlockRailwaySignTianjinBMT(2, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_3_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_3_odd", () -> new Block(new BlockRailwaySignTianjinBMT(3, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_4_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_4_odd", () -> new Block(new BlockRailwaySignTianjinBMT(4, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_5_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_5_odd", () -> new Block(new BlockRailwaySignTianjinBMT(5, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_6_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_6_odd", () -> new Block(new BlockRailwaySignTianjinBMT(6, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_7_ODD = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_7_odd", () -> new Block(new BlockRailwaySignTianjinBMT(7, true)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_2_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_2_even", () -> new Block(new BlockRailwaySignTianjinBMT(2, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_3_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_3_even", () -> new Block(new BlockRailwaySignTianjinBMT(3, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_4_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_4_even", () -> new Block(new BlockRailwaySignTianjinBMT(4, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_5_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_5_even", () -> new Block(new BlockRailwaySignTianjinBMT(5, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_6_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_6_even", () -> new Block(new BlockRailwaySignTianjinBMT(6, false)), CreativeModeTabs.TIANJIN_METRO); + BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_7_EVEN = Registry.registerBlockWithBlockItem("railway_sign_tianjin_bmt_7_even", () -> new Block(new BlockRailwaySignTianjinBMT(7, false)), CreativeModeTabs.TIANJIN_METRO); BlockRegistryObject RAILWAY_SIGN_TIANJIN_BMT_MIDDLE = Registry.registerBlock("railway_sign_tianjin_bmt_middle", () -> new Block(new BlockRailwaySignTianjinBMT(0, false))); - BlockRegistryObject APG_DOOR_TIANJIN = Registry.registerBlock("apg_door_tianjin", () -> new Block(new BlockAPGDoorTianjin())); - BlockRegistryObject APG_GLASS_TIANJIN = Registry.registerBlock("apg_glass_tianjin", () -> new Block(new BlockAPGGlassTianjin())); - BlockRegistryObject APG_GLASS_END_TIANJIN = Registry.registerBlock("apg_glass_end_tianjin", () -> new Block(new BlockAPGGlassEndTianjin())); - BlockRegistryObject APG_DOOR_TIANJIN_BMT = Registry.registerBlock("apg_door_tianjin_bmt", () -> new Block(new BlockAPGDoorTianjinBMT())); - BlockRegistryObject APG_GLASS_TIANJIN_BMT = Registry.registerBlock("apg_glass_tianjin_bmt", () -> new Block(new BlockAPGGlassTianjinBMT())); - BlockRegistryObject APG_GLASS_END_TIANJIN_BMT = Registry.registerBlock("apg_glass_end_tianjin_bmt", () -> new Block(new BlockAPGGlassEndTianjinBMT())); - BlockRegistryObject METAL_POLE_BMT = Registry.registerBlockWithBlockItem("metal_pole_bmt", () -> new Block(new BlockMetalPoleBMT()), BlockItemExtension::new, DECORATION); + BlockRegistryObject APG_DOOR_TIANJIN_BLOCK = Registry.registerBlock("apg_door_tianjin", () -> new Block(new BlockAPGDoorTianjin())); + BlockRegistryObject APG_GLASS_TIANJIN_BLOCK = Registry.registerBlock("apg_glass_tianjin", () -> new Block(new BlockAPGGlassTianjin())); + BlockRegistryObject APG_GLASS_END_TIANJIN_BLOCK = Registry.registerBlock("apg_glass_end_tianjin", () -> new Block(new BlockAPGGlassEndTianjin())); + BlockRegistryObject APG_DOOR_TIANJIN_BMT_BLOCK = Registry.registerBlock("apg_door_tianjin_bmt", () -> new Block(new BlockAPGDoorTianjinBMT())); + BlockRegistryObject APG_GLASS_TIANJIN_BMT_BLOCK = Registry.registerBlock("apg_glass_tianjin_bmt", () -> new Block(new BlockAPGGlassTianjinBMT())); + BlockRegistryObject APG_GLASS_END_TIANJIN_BMT_BLOCK = Registry.registerBlock("apg_glass_end_tianjin_bmt", () -> new Block(new BlockAPGGlassEndTianjinBMT())); + BlockRegistryObject METAL_POLE_BMT = Registry.registerBlockWithBlockItem("metal_pole_bmt", () -> new Block(new BlockMetalPoleBMT()), BlockItemExtension::new, CreativeModeTabs.TIANJIN_METRO); static void registerBlocks() { // Calling this class to initialize constants diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/CreativeModeTabs.java b/fabric/src/main/java/ziyue/tjmetro/mod/CreativeModeTabs.java new file mode 100644 index 0000000..2686a59 --- /dev/null +++ b/fabric/src/main/java/ziyue/tjmetro/mod/CreativeModeTabs.java @@ -0,0 +1,15 @@ +package ziyue.tjmetro.mod; + +import org.mtr.mapping.holder.ItemConvertible; +import org.mtr.mapping.holder.ItemStack; +import org.mtr.mapping.registry.CreativeModeTabHolder; + +public interface CreativeModeTabs +{ + CreativeModeTabHolder TIANJIN_METRO = Registry.createCreativeModeTabHolder("tianjin_metro", () -> new ItemStack(new ItemConvertible(BlockList.LOGO.get().data))); + + static void registerCreativeModeTabs() { + // Calling this class to initialize constants + TianjinMetro.LOGGER.info("Registering creative mode tabs"); + } +} diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/ItemList.java b/fabric/src/main/java/ziyue/tjmetro/mod/ItemList.java index d7aad5e..8aad854 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/ItemList.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/ItemList.java @@ -5,25 +5,22 @@ import org.mtr.mapping.registry.ItemRegistryObject; import ziyue.tjmetro.mod.item.ItemPSDAPGTianjinBase; -import static ziyue.tjmetro.mod.client.Filters.GATES; -import static ziyue.tjmetro.mod.client.Filters.MISCELLANEOUS; - /** * @since 1.0.0-beta-1 */ public interface ItemList { - ItemRegistryObject WRENCH = Registry.registerItem("wrench", itemSettings -> new Item(new ItemExtension(itemSettings.maxCount(1))), MISCELLANEOUS); - ItemRegistryObject PSD_DOOR_TIANJIN = Registry.registerItem("psd_door_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.PSD_DOOR_TIANJIN, itemSettings)), GATES); - ItemRegistryObject PSD_GLASS_TIANJIN = Registry.registerItem("psd_glass_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.PSD_GLASS_TIANJIN, itemSettings)), GATES); - ItemRegistryObject PSD_GLASS_END_TIANJIN = Registry.registerItem("psd_glass_end_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.PSD_GLASS_END_TIANJIN, itemSettings)), GATES); - ItemRegistryObject APG_DOOR_TIANJIN = Registry.registerItem("apg_door_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_DOOR_TIANJIN, itemSettings)), GATES); - ItemRegistryObject APG_GLASS_TIANJIN = Registry.registerItem("apg_glass_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_GLASS_TIANJIN, itemSettings)), GATES); - ItemRegistryObject APG_GLASS_END_TIANJIN = Registry.registerItem("apg_glass_end_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_GLASS_END_TIANJIN, itemSettings)), GATES); - ItemRegistryObject APG_DOOR_TIANJIN_BMT = Registry.registerItem("apg_door_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_DOOR_TIANJIN_BMT, itemSettings)), GATES); - ItemRegistryObject APG_GLASS_TIANJIN_BMT = Registry.registerItem("apg_glass_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_GLASS_TIANJIN_BMT, itemSettings)), GATES); - ItemRegistryObject APG_GLASS_END_TIANJIN_BMT = Registry.registerItem("apg_glass_end_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_GLASS_END_TIANJIN_BMT, itemSettings)), GATES); + ItemRegistryObject WRENCH = Registry.registerItem("wrench", itemSettings -> new Item(new ItemExtension(itemSettings.maxCount(1))), CreativeModeTabs.TIANJIN_METRO); + ItemRegistryObject PSD_DOOR_TIANJIN = Registry.registerItem("psd_door_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.PSD_DOOR_TIANJIN_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO); + ItemRegistryObject PSD_GLASS_TIANJIN = Registry.registerItem("psd_glass_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.PSD_GLASS_TIANJIN_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO); + ItemRegistryObject PSD_GLASS_END_TIANJIN = Registry.registerItem("psd_glass_end_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.PSD_GLASS_END_TIANJIN_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO); + ItemRegistryObject APG_DOOR_TIANJIN = Registry.registerItem("apg_door_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_DOOR_TIANJIN_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO); + ItemRegistryObject APG_GLASS_TIANJIN = Registry.registerItem("apg_glass_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_GLASS_TIANJIN_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO); + ItemRegistryObject APG_GLASS_END_TIANJIN = Registry.registerItem("apg_glass_end_tianjin", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_GLASS_END_TIANJIN_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO); + ItemRegistryObject APG_DOOR_TIANJIN_BMT = Registry.registerItem("apg_door_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_DOOR_TIANJIN_BMT_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO); + ItemRegistryObject APG_GLASS_TIANJIN_BMT = Registry.registerItem("apg_glass_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_GLASS_TIANJIN_BMT_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO); + ItemRegistryObject APG_GLASS_END_TIANJIN_BMT = Registry.registerItem("apg_glass_end_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_GLASS_END_TIANJIN_BMT_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO); static void registerItems() { // Calling this class to initialize constants diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/Reference.java b/fabric/src/main/java/ziyue/tjmetro/mod/Reference.java index 1e00624..63338cf 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/Reference.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/Reference.java @@ -10,7 +10,7 @@ public interface Reference { String MOD_ID = "tjmetro"; String NAME = "Tianjin Metro"; - String VERSION = "1.0.0-beta-1"; + String VERSION = "1.0.0-beta-2"; String GITHUB_REPO = "https://github.com/ZiYueCommentary/Tianjin-Metro"; String CONTRIBUTORS = "https://github.com/ZiYueCommentary/Tianjin-Metro/graphs/contributors"; diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/Registry.java b/fabric/src/main/java/ziyue/tjmetro/mod/Registry.java index 547436a..8e05a38 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/Registry.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/Registry.java @@ -23,8 +23,6 @@ public final class Registry { public static final org.mtr.mapping.registry.Registry REGISTRY = new org.mtr.mapping.registry.Registry(); public static final org.mtr.mapping.registry.Registry REGISTRY_TABS = new org.mtr.mapping.registry.Registry(); - public static final List> FILTERS_REGISTRY_ITEM = new ArrayList<>(); - public static final List> FILTERS_REGISTRY_BLOCK = new ArrayList<>(); public static CreativeModeTabHolder createCreativeModeTabHolder(String id, Supplier icon) { return REGISTRY_TABS.createCreativeModeTabHolder(new Identifier(Reference.MOD_ID, id), icon); @@ -34,20 +32,16 @@ public static BlockRegistryObject registerBlock(String id, Supplier suppl return REGISTRY.registerBlock(new Identifier(Reference.MOD_ID, id), supplier); } - public static ItemRegistryObject registerItem(String id, Function function, Filter filter) { - ItemRegistryObject object = REGISTRY.registerItem(new Identifier(Reference.MOD_ID, id), function, TianjinMetro.CREATIVE_MODE_TAB); - FILTERS_REGISTRY_ITEM.add(new Pair<>(filter, object)); - return object; + public static ItemRegistryObject registerItem(String id, Function function, CreativeModeTabHolder creativeModeTab) { + return REGISTRY.registerItem(new Identifier(Reference.MOD_ID, id), function, creativeModeTab); } - public static BlockRegistryObject registerBlockWithBlockItem(String id, Supplier block, Filter filter) { - return registerBlockWithBlockItem(id, block, BlockItemExtension::new, filter); + public static BlockRegistryObject registerBlockWithBlockItem(String id, Supplier block, CreativeModeTabHolder creativeModeTab) { + return registerBlockWithBlockItem(id, block, BlockItemExtension::new, creativeModeTab); } - public static BlockRegistryObject registerBlockWithBlockItem(String id, Supplier block, BiFunction function, Filter filter) { - BlockRegistryObject object = REGISTRY.registerBlockWithBlockItem(new Identifier(Reference.MOD_ID, id), block, function, TianjinMetro.CREATIVE_MODE_TAB); - if (filter != null) FILTERS_REGISTRY_BLOCK.add(new Pair<>(filter, object)); - return object; + public static BlockRegistryObject registerBlockWithBlockItem(String id, Supplier block, BiFunction function, CreativeModeTabHolder creativeModeTab) { + return REGISTRY.registerBlockWithBlockItem(new Identifier(Reference.MOD_ID, id), block, function, creativeModeTab); } @SafeVarargs diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/RegistryClient.java b/fabric/src/main/java/ziyue/tjmetro/mod/RegistryClient.java index 882e4a3..3e3b8f0 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/RegistryClient.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/RegistryClient.java @@ -8,6 +8,7 @@ import org.mtr.mapping.mapper.EntityRenderer; import org.mtr.mapping.registry.*; import org.mtr.mod.InitClient; +import ziyue.tjmetro.mapping.RegistryHelper; import ziyue.tjmetro.mod.block.base.BlockCustomColorBase; import java.util.function.Function; @@ -29,7 +30,11 @@ public static void registerBlockStationColor(BlockRegistryObject... blocks) { } public static void registerItemCustomColor(int color, BlockRegistryObject block, String blockId) { - REGISTRY_CLIENT.registerItemColors((stack, index) -> color, RegistryHelper.RegistryObjectBlock2Item(block, new Identifier(Reference.MOD_ID, blockId))); + try { + REGISTRY_CLIENT.registerItemColors((stack, index) -> color, RegistryHelper.RegistryObjectBlock2Item(block, new Identifier(Reference.MOD_ID, blockId))); + } catch (Exception e) { + TianjinMetro.LOGGER.warn("ItemRegistryObject reflection failed: " + e.getMessage(), e); + } } public static void registerBlockCustomColor(BlockRegistryObject... blocks) { diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetro.java b/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetro.java index a213bd9..c7823ef 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetro.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetro.java @@ -18,7 +18,6 @@ public final class TianjinMetro public static final Logger LOGGER = LogManager.getLogger(Reference.NAME); public static final BooleanGameRule NO_FALLING_BLOCK = GameRuleRegistry.registerBoolean("preventBlockFalling", false); - public static final CreativeModeTabHolder CREATIVE_MODE_TAB = Registry.createCreativeModeTabHolder("tjmetro_tab", () -> new ItemStack(new ItemConvertible(BlockList.LOGO.get().data))); public static void init() { LOGGER.info("--------------- " + Reference.NAME + " ---------------"); @@ -26,6 +25,7 @@ public static void init() { LOGGER.info("Mod ID: " + Reference.MOD_ID); LOGGER.info("Version: " + Reference.VERSION); + CreativeModeTabs.registerCreativeModeTabs(); Registry.REGISTRY_TABS.init(); BlockList.registerBlocks(); diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetroClient.java b/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetroClient.java index 6a8f324..fe1b358 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetroClient.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetroClient.java @@ -1,15 +1,9 @@ package ziyue.tjmetro.mod; -import org.mtr.mapping.holder.MinecraftClient; import org.mtr.mapping.holder.RenderLayer; -import org.mtr.mapping.holder.Screen; -import org.mtr.mapping.mapper.TextHelper; -import org.mtr.mapping.registry.ItemRegistryObject; import org.mtr.mod.render.RenderPSDAPGDoor; import ziyue.tjmetro.mod.config.ConfigClient; -import ziyue.tjmetro.mapping.FilterBuilder; import ziyue.tjmetro.mod.render.*; -import ziyue.tjmetro.mod.screen.ConfigClientScreen; /** * @since 1.0.0-beta-1 @@ -28,15 +22,15 @@ public static void init() { RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PLATFORM_TJ_2_INDENTED); RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.EMERGENCY_EXIT_SIGN); RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.SERVICE_CORRIDOR_SIGN); - RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_DOOR_TIANJIN); - RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_GLASS_TIANJIN); - RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_GLASS_END_TIANJIN); - RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_DOOR_TIANJIN); - RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_GLASS_TIANJIN); - RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_GLASS_END_TIANJIN); - RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_DOOR_TIANJIN_BMT); - RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_GLASS_TIANJIN_BMT); - RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_GLASS_END_TIANJIN_BMT); + RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_DOOR_TIANJIN_BLOCK); + RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_GLASS_TIANJIN_BLOCK); + RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_GLASS_END_TIANJIN_BLOCK); + RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_DOOR_TIANJIN_BLOCK); + RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_GLASS_TIANJIN_BLOCK); + RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_GLASS_END_TIANJIN_BLOCK); + RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_DOOR_TIANJIN_BMT_BLOCK); + RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_GLASS_TIANJIN_BMT_BLOCK); + RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_GLASS_END_TIANJIN_BMT_BLOCK); RegistryClient.registerBlockRenderType(RenderLayer.getTranslucent(), BlockList.ROLLING); RegistryClient.registerBlockEntityRenderer(BlockEntityTypes.STATION_NAME_SIGN_1, RenderStationNameSign::new); @@ -108,9 +102,6 @@ public static void init() { RegistryClient.REGISTRY_CLIENT.init(); - FilterBuilder.setReservedButton(TianjinMetro.CREATIVE_MODE_TAB, TextHelper.translatable("button.tjmetro.tianjin_metro_options"), button -> - MinecraftClient.getInstance().openScreen(new Screen(new ConfigClientScreen(MinecraftClient.getInstance().getCurrentScreenMapped())))); - ConfigClient.refreshProperties(); } } diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/block/BlockAPGGlassTianjinBMT.java b/fabric/src/main/java/ziyue/tjmetro/mod/block/BlockAPGGlassTianjinBMT.java index 04202c5..dc89fbe 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/block/BlockAPGGlassTianjinBMT.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/block/BlockAPGGlassTianjinBMT.java @@ -14,8 +14,6 @@ import javax.annotation.Nonnull; import java.util.List; import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Function; /** * @author ZiYueCommentary @@ -42,7 +40,7 @@ public ActionResult onUse2(BlockState state, World world, BlockPos pos, PlayerEn EnumDoorType style = IBlock.getStatePropertySafe(world, pos, STYLE); BlockPos offsetPos = pos; for (; ; ) { - if (IBlockExtension.isBlock(world.getBlockState(offsetPos), BlockList.APG_DOOR_TIANJIN_BMT.get())) { + if (IBlockExtension.isBlock(world.getBlockState(offsetPos), BlockList.APG_DOOR_TIANJIN_BMT_BLOCK.get())) { offsetPos = offsetPos.offset(direction); if (bool) { final int id = (style.asId() - 1); @@ -50,7 +48,7 @@ public ActionResult onUse2(BlockState state, World world, BlockPos pos, PlayerEn } else { style = EnumDoorType.byId((style.asId() + 1) % 3); } - } else if (IBlockExtension.isBlock(world.getBlockState(offsetPos), BlockList.APG_GLASS_TIANJIN_BMT.get())) { + } else if (IBlockExtension.isBlock(world.getBlockState(offsetPos), BlockList.APG_GLASS_TIANJIN_BMT_BLOCK.get())) { world.setBlockState(offsetPos, world.getBlockState(offsetPos).with(new Property<>(STYLE.data), style)); } else { break; diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/block/BlockPSDTopTianjin.java b/fabric/src/main/java/ziyue/tjmetro/mod/block/BlockPSDTopTianjin.java index 9ceb581..f991a9e 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/block/BlockPSDTopTianjin.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/block/BlockPSDTopTianjin.java @@ -31,7 +31,7 @@ public class BlockPSDTopTianjin extends BlockPSDTop implements BlockFlagPSDTianj public ActionResult onUse2(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { return IBlock.checkHoldingItem(world, player, item -> { if (item.data == ItemList.WRENCH.get().data) { - if (BlockList.PSD_DOOR_TIANJIN.get().data == world.getBlockState(pos.down()).getBlock().data) { + if (BlockList.PSD_DOOR_TIANJIN_BLOCK.get().data == world.getBlockState(pos.down()).getBlock().data) { world.setBlockState(pos, IBlockExtension.cycleBlockState(state, STYLE, value -> value != EnumDoorType.NEXT_STATION)); BlockPos pos1 = (IBlock.getStatePropertySafe(state, SIDE_EXTENDED) == EnumSide.LEFT) ? pos.offset(IBlock.getStatePropertySafe(state, FACING).rotateYClockwise()) : pos.offset(IBlock.getStatePropertySafe(state, FACING).rotateYCounterclockwise()); world.setBlockState(pos1, IBlockExtension.cycleBlockState(world.getBlockState(pos1), STYLE, value -> value != EnumDoorType.NEXT_STATION)); @@ -41,7 +41,7 @@ public ActionResult onUse2(BlockState state, World world, BlockPos pos, PlayerEn EnumDoorType style = IBlock.getStatePropertySafe(world, pos, STYLE); BlockPos offsetPos = pos; for (; ; ) { - if (BlockList.PSD_DOOR_TIANJIN.get().data == world.getBlockState(offsetPos.down()).getBlock().data) { + if (BlockList.PSD_DOOR_TIANJIN_BLOCK.get().data == world.getBlockState(offsetPos.down()).getBlock().data) { offsetPos = offsetPos.offset(direction); style = (style == EnumDoorType.DEFAULT) ? EnumDoorType.NEXT_STATION : EnumDoorType.DEFAULT; } else if (this == world.getBlockState(offsetPos).getBlock().data) { diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/client/Filters.java b/fabric/src/main/java/ziyue/tjmetro/mod/client/Filters.java index f4107af..9d22cd8 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/client/Filters.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/client/Filters.java @@ -1,24 +1,59 @@ package ziyue.tjmetro.mod.client; -import org.mtr.mapping.holder.ItemConvertible; -import org.mtr.mapping.holder.ItemStack; +import org.mtr.mapping.holder.*; import org.mtr.mapping.mapper.TextHelper; -import org.mtr.mod.Blocks; -import org.mtr.mod.CreativeModeTabs; -import org.mtr.mod.Items; import ziyue.filters.Filter; import ziyue.tjmetro.mapping.FilterBuilder; import ziyue.tjmetro.mod.BlockList; +import ziyue.tjmetro.mod.CreativeModeTabs; import ziyue.tjmetro.mod.ItemList; -import ziyue.tjmetro.mod.TianjinMetro; +import ziyue.tjmetro.mod.screen.ConfigClientScreen; + +import static ziyue.tjmetro.mod.BlockList.*; +import static ziyue.tjmetro.mod.ItemList.*; public interface Filters { - Filter MISCELLANEOUS = FilterBuilder.registerFilter(TianjinMetro.CREATIVE_MODE_TAB, TextHelper.translatable("filter.tjmetro.miscellaneous"), () -> new ItemStack(new ItemConvertible(ItemList.WRENCH.get().data))); - Filter BUILDING = FilterBuilder.registerFilter(TianjinMetro.CREATIVE_MODE_TAB, TextHelper.translatable("filter.tjmetro.building"), () -> new ItemStack(new ItemConvertible(BlockList.ROLLING.get().data))); - Filter SIGNS = FilterBuilder.registerFilter(TianjinMetro.CREATIVE_MODE_TAB, TextHelper.translatable("filter.tjmetro.signs"), () -> new ItemStack(new ItemConvertible(BlockList.STATION_NAME_SIGN_1.get().data))); - Filter GATES = FilterBuilder.registerFilter(TianjinMetro.CREATIVE_MODE_TAB, TextHelper.translatable("filter.tjmetro.gates"), () -> new ItemStack(new ItemConvertible(ItemList.PSD_DOOR_TIANJIN.get().data))); - Filter DECORATION = FilterBuilder.registerFilter(TianjinMetro.CREATIVE_MODE_TAB, TextHelper.translatable("filter.tjmetro.decoration"), () -> new ItemStack(new ItemConvertible(BlockList.LOGO.get().data))); - Filter CEILINGS = FilterBuilder.registerFilter(TianjinMetro.CREATIVE_MODE_TAB, TextHelper.translatable("filter.tjmetro.ceilings"), () -> new ItemStack(new ItemConvertible(BlockList.STATION_COLOR_CEILING.get().data))); - Filter RAILWAY_SIGNS = FilterBuilder.registerFilter(TianjinMetro.CREATIVE_MODE_TAB, TextHelper.translatable("filter.tjmetro.railway_signs"), () -> new ItemStack(new ItemConvertible(BlockList.RAILWAY_SIGN_TIANJIN_3_EVEN.get().data))); + PressAction OPTION_BUTTON_ACTION = button -> MinecraftClient.getInstance().openScreen(new Screen(new ConfigClientScreen(MinecraftClient.getInstance().getCurrentScreenMapped()))); + + Filter TIANJIN_MISCELLANEOUS = FilterBuilder.registerFilter(CreativeModeTabs.TIANJIN_METRO, TextHelper.translatable("filter.tjmetro.tianjin_miscellaneous"), () -> new ItemStack(new ItemConvertible(ItemList.WRENCH.get().data))); + Filter TIANJIN_BUILDING = FilterBuilder.registerFilter(CreativeModeTabs.TIANJIN_METRO, TextHelper.translatable("filter.tjmetro.tianjin_building"), () -> new ItemStack(new ItemConvertible(BlockList.ROLLING.get().data))); + Filter TIANJIN_SIGNS = FilterBuilder.registerFilter(CreativeModeTabs.TIANJIN_METRO, TextHelper.translatable("filter.tjmetro.tianjin_signs"), () -> new ItemStack(new ItemConvertible(BlockList.STATION_NAME_SIGN_1.get().data))); + Filter TIANJIN_GATES = FilterBuilder.registerFilter(CreativeModeTabs.TIANJIN_METRO, TextHelper.translatable("filter.tjmetro.tianjin_gates"), () -> new ItemStack(new ItemConvertible(ItemList.PSD_DOOR_TIANJIN.get().data))); + Filter TIANJIN_DECORATION = FilterBuilder.registerFilter(CreativeModeTabs.TIANJIN_METRO, TextHelper.translatable("filter.tjmetro.tianjin_decoration"), () -> new ItemStack(new ItemConvertible(BlockList.LOGO.get().data))); + Filter TIANJIN_CEILINGS = FilterBuilder.registerFilter(CreativeModeTabs.TIANJIN_METRO, TextHelper.translatable("filter.tjmetro.tianjin_ceilings"), () -> new ItemStack(new ItemConvertible(BlockList.STATION_COLOR_CEILING.get().data))); + Filter TIANJIN_RAILWAY_SIGNS = FilterBuilder.registerFilter(CreativeModeTabs.TIANJIN_METRO, TextHelper.translatable("filter.tjmetro.tianjin_railway_signs"), () -> new ItemStack(new ItemConvertible(BlockList.RAILWAY_SIGN_TIANJIN_3_EVEN.get().data))); + Filter TIANJIN_UNCATEGORIZED = FilterBuilder.registerUncategorizedItemsFilter(CreativeModeTabs.TIANJIN_METRO); + + static void init() { + FilterBuilder.addItems(Filters.TIANJIN_MISCELLANEOUS, WRENCH); + FilterBuilder.addBlocks(Filters.TIANJIN_MISCELLANEOUS, PLAYER_DETECTOR); + FilterBuilder.addBlocks(Filters.TIANJIN_BUILDING, + ROLLING, + PLATFORM_TJ_1, PLATFORM_TJ_2, PLATFORM_TJ_1_INDENTED, PLATFORM_TJ_2_INDENTED, + MARBLE_GRAY, MARBLE_GRAY_SLAB, MARBLE_GRAY_STAIRS, MARBLE_YELLOW, MARBLE_YELLOW_SLAB, MARBLE_YELLOW_STAIRS, + ROADBLOCK, ROADBLOCK_SIGN, + CUSTOM_COLOR_CONCRETE, CUSTOM_COLOR_CONCRETE_SLAB, CUSTOM_COLOR_CONCRETE_STAIRS); + FilterBuilder.addBlocks(Filters.TIANJIN_SIGNS, + STATION_NAME_SIGN_1, STATION_NAME_SIGN_2, + STATION_NAME_ENTRANCE_TIANJIN, STATION_NAME_ENTRANCE_TIANJIN_PINYIN, STATION_NAME_ENTRANCE_TIANJIN_BMT, STATION_NAME_ENTRANCE_TIANJIN_BMT_PINYIN, + STATION_NAME_WALL_LEGACY, + STATION_NAME_PLATE); + FilterBuilder.addItems(Filters.TIANJIN_GATES, + PSD_DOOR_TIANJIN, PSD_GLASS_TIANJIN, PSD_GLASS_END_TIANJIN, + APG_DOOR_TIANJIN, APG_GLASS_TIANJIN, APG_GLASS_END_TIANJIN, + APG_DOOR_TIANJIN_BMT, APG_GLASS_TIANJIN_BMT, APG_GLASS_END_TIANJIN_BMT); + FilterBuilder.addBlocks(Filters.TIANJIN_DECORATION, LOGO, APG_CORNER, TIME_DISPLAY, EMERGENCY_EXIT_SIGN, SERVICE_CORRIDOR_SIGN, BENCH, METAL_DETECTION_DOOR, METAL_POLE_BMT); + FilterBuilder.addBlocks(Filters.TIANJIN_CEILINGS, + CEILING_NOT_LIT, + STATION_COLOR_CEILING, STATION_COLOR_CEILING_LIGHT, STATION_COLOR_CEILING_NO_LIGHT, STATION_COLOR_CEILING_NOT_LIT); + FilterBuilder.addBlocks(Filters.TIANJIN_RAILWAY_SIGNS, + RAILWAY_SIGN_WALL_4, RAILWAY_SIGN_WALL_6, RAILWAY_SIGN_WALL_8, RAILWAY_SIGN_WALL_10, + RAILWAY_SIGN_WALL_DOUBLE_4, RAILWAY_SIGN_WALL_DOUBLE_6, RAILWAY_SIGN_WALL_DOUBLE_8, RAILWAY_SIGN_WALL_DOUBLE_10, + RAILWAY_SIGN_WALL_BIG_2, RAILWAY_SIGN_WALL_BIG_3, RAILWAY_SIGN_WALL_BIG_4, RAILWAY_SIGN_WALL_BIG_5, RAILWAY_SIGN_WALL_BIG_6, RAILWAY_SIGN_WALL_BIG_7, RAILWAY_SIGN_WALL_BIG_8, RAILWAY_SIGN_WALL_BIG_9, RAILWAY_SIGN_WALL_BIG_10, + RAILWAY_SIGN_TIANJIN_3_ODD, RAILWAY_SIGN_TIANJIN_4_ODD, RAILWAY_SIGN_TIANJIN_5_ODD, RAILWAY_SIGN_TIANJIN_6_ODD, RAILWAY_SIGN_TIANJIN_7_ODD, RAILWAY_SIGN_TIANJIN_2_EVEN, RAILWAY_SIGN_TIANJIN_3_EVEN, RAILWAY_SIGN_TIANJIN_4_EVEN, RAILWAY_SIGN_TIANJIN_5_EVEN, RAILWAY_SIGN_TIANJIN_6_EVEN, RAILWAY_SIGN_TIANJIN_7_EVEN, RAILWAY_SIGN_TIANJIN_POLE, + RAILWAY_SIGN_TIANJIN_BMT_2_ODD, RAILWAY_SIGN_TIANJIN_BMT_3_ODD, RAILWAY_SIGN_TIANJIN_BMT_4_ODD, RAILWAY_SIGN_TIANJIN_BMT_5_ODD, RAILWAY_SIGN_TIANJIN_BMT_6_ODD, RAILWAY_SIGN_TIANJIN_BMT_7_ODD, RAILWAY_SIGN_TIANJIN_BMT_2_EVEN, RAILWAY_SIGN_TIANJIN_BMT_3_EVEN, RAILWAY_SIGN_TIANJIN_BMT_4_EVEN, RAILWAY_SIGN_TIANJIN_BMT_5_EVEN, RAILWAY_SIGN_TIANJIN_BMT_6_EVEN, RAILWAY_SIGN_TIANJIN_BMT_7_EVEN); + + FilterBuilder.setReservedButton(CreativeModeTabs.TIANJIN_METRO, TextHelper.translatable("button.tjmetro.tianjin_metro_options"), OPTION_BUTTON_ACTION); + } } diff --git a/fabric/src/main/resources/assets/tjmetro/lang/en_us.json b/fabric/src/main/resources/assets/tjmetro/lang/en_us.json index e5bb8a6..7c813bd 100644 --- a/fabric/src/main/resources/assets/tjmetro/lang/en_us.json +++ b/fabric/src/main/resources/assets/tjmetro/lang/en_us.json @@ -2,7 +2,7 @@ "modmenu.nameTranslation.tjmetro": "Tianjin Metro", "modmenu.descriptionTranslation.tjmetro": "A small mod for Minecraft Transit Railway.", - "itemGroup.tjmetro.tjmetro_tab": "Tianjin Metro", + "itemGroup.tjmetro.tianjin_metro": "Tianjin Metro", "item.tjmetro.wrench": "Wrench", @@ -116,13 +116,13 @@ "footer.tjmetro.discord": "Join our Discord server!", "footer.tjmetro.prevent_block_falling": "Did you know you can stop sand falling?", - "filter.tjmetro.miscellaneous": "Miscellaneous", - "filter.tjmetro.building": "Buildings", - "filter.tjmetro.signs": "Station Name Signs", - "filter.tjmetro.gates": "Platform Gates", - "filter.tjmetro.decoration": "Decorations", - "filter.tjmetro.ceilings": "Ceilings", - "filter.tjmetro.railway_signs": "Railway Signs", + "filter.tjmetro.tianjin_miscellaneous": "Miscellaneous", + "filter.tjmetro.tianjin_building": "Buildings", + "filter.tjmetro.tianjin_signs": "Station Name Signs", + "filter.tjmetro.tianjin_gates": "Platform Gates", + "filter.tjmetro.tianjin_decoration": "Decorations", + "filter.tjmetro.tianjin_ceilings": "Ceilings", + "filter.tjmetro.tianjin_railway_signs": "Railway Signs", "filter.tjmetro.mtr_core_dashboards": "Dashboards", "filter.tjmetro.mtr_core_rails": "Rails", "filter.tjmetro.mtr_core_signals": "Signals", diff --git a/forge/src/main/java/org/mtr/mapping/registry/RegistryHelper.java b/forge/src/main/java/org/mtr/mapping/registry/RegistryHelper.java deleted file mode 100644 index 64e9c94..0000000 --- a/forge/src/main/java/org/mtr/mapping/registry/RegistryHelper.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.mtr.mapping.registry; - -import org.mtr.mapping.holder.Identifier; - -// This is a very hacky way but I have no choice. -public interface RegistryHelper -{ - static ItemRegistryObject RegistryObjectBlock2Item(BlockRegistryObject fabric, Identifier forge) { - return new ItemRegistryObject(forge); - } -} diff --git a/forge/src/main/java/ziyue/tjmetro/forge/MainForge.java b/forge/src/main/java/ziyue/tjmetro/forge/MainForge.java index 8e29e30..ea5c196 100644 --- a/forge/src/main/java/ziyue/tjmetro/forge/MainForge.java +++ b/forge/src/main/java/ziyue/tjmetro/forge/MainForge.java @@ -8,9 +8,9 @@ import net.minecraftforge.fml.common.Mod; import org.mtr.mapping.holder.Screen; import ziyue.tjmetro.mod.Reference; -import ziyue.tjmetro.mod.Registry; import ziyue.tjmetro.mod.TianjinMetro; import ziyue.tjmetro.mod.TianjinMetroClient; +import ziyue.tjmetro.mod.client.Filters; import ziyue.tjmetro.mod.screen.ConfigClientScreen; /** @@ -45,28 +45,11 @@ public void afterRegistry( #elif MC_VERSION <= "11802" net.minecraftforge.client.event.ScreenEvent.DrawScreenEvent.Post event #elif MC_VERSION <= "12004" - net.minecraftforge.client.event.ScreenEvent.Init.Pre event + net.minecraftforge.client.event.ScreenEvent.Init.Post event #endif ) { - // As you see, this is a very dumb thing due to we are using Forge. - // Please read Fabric codes so that you will know how Fabric is awesome. - #if MC_VERSION >= "11904" - ziyue.filters.FilterList filterTianjinMetro = ziyue.filters.FilterList.empty(); - filterTianjinMetro.add(ziyue.tjmetro.mod.client.Filters.MISCELLANEOUS); - filterTianjinMetro.add(ziyue.tjmetro.mod.client.Filters.BUILDING); - filterTianjinMetro.add(ziyue.tjmetro.mod.client.Filters.SIGNS); - filterTianjinMetro.add(ziyue.tjmetro.mod.client.Filters.GATES); - filterTianjinMetro.add(ziyue.tjmetro.mod.client.Filters.DECORATION); - filterTianjinMetro.add(ziyue.tjmetro.mod.client.Filters.CEILINGS); - filterTianjinMetro.add(ziyue.tjmetro.mod.client.Filters.RAILWAY_SIGNS); - ziyue.filters.FilterBuilder.FILTERS.put(net.minecraftforge.common.CreativeModeTabRegistry.getTab(TianjinMetro.CREATIVE_MODE_TAB.identifier), filterTianjinMetro); - - ziyue.tjmetro.mapping.FilterBuilder.setReservedButton(TianjinMetro.CREATIVE_MODE_TAB, org.mtr.mapping.mapper.TextHelper.translatable("button.tjmetro.tianjin_metro_options"), button -> - org.mtr.mapping.holder.MinecraftClient.getInstance().openScreen(new Screen(new ConfigClientScreen(org.mtr.mapping.holder.MinecraftClient.getInstance().getCurrentScreenMapped())))); - #endif if (filterInitialized) return; - Registry.FILTERS_REGISTRY_ITEM.forEach(pair -> pair.getFirst().addItems(pair.getSecond().get().data)); - Registry.FILTERS_REGISTRY_BLOCK.forEach(pair -> pair.getFirst().addItems(pair.getSecond().get().asItem().data)); + Filters.init(); filterInitialized = true; } } diff --git a/forge/src/main/java/ziyue/tjmetro/mapping/FilterBuilder.java b/forge/src/main/java/ziyue/tjmetro/mapping/FilterBuilder.java index 29be542..fb299e6 100644 --- a/forge/src/main/java/ziyue/tjmetro/mapping/FilterBuilder.java +++ b/forge/src/main/java/ziyue/tjmetro/mapping/FilterBuilder.java @@ -3,7 +3,9 @@ import org.mtr.mapping.holder.ItemStack; import org.mtr.mapping.holder.MutableText; import org.mtr.mapping.holder.PressAction; +import org.mtr.mapping.registry.BlockRegistryObject; import org.mtr.mapping.registry.CreativeModeTabHolder; +import org.mtr.mapping.registry.ItemRegistryObject; import ziyue.filters.Filter; import java.util.function.Supplier; @@ -31,19 +33,30 @@ static void setReservedButton(CreativeModeTabHolder creativeModeTab, MutableText } #else static Filter registerFilter(CreativeModeTabHolder creativeModeTab, MutableText filterName, Supplier filterIcon) { - return ziyue.filters.FilterBuilder.registerFilter((net.minecraft.world.item.CreativeModeTab) null, filterName.data, () -> filterIcon.get().data); + return ziyue.filters.FilterBuilder.registerFilter(net.minecraftforge.common.CreativeModeTabRegistry.getTab(creativeModeTab.identifier), filterName.data, () -> filterIcon.get().data); } static Filter registerUncategorizedItemsFilter(CreativeModeTabHolder creativeModeTab) { - return ziyue.filters.FilterBuilder.registerUncategorizedItemsFilter((net.minecraft.world.item.CreativeModeTab) null); + return ziyue.filters.FilterBuilder.registerUncategorizedItemsFilter(net.minecraftforge.common.CreativeModeTabRegistry.getTab(creativeModeTab.identifier)); } static void filtersVisibility(CreativeModeTabHolder creativeModeTab, boolean visible) { - ziyue.filters.FilterBuilder.filtersVisibility((net.minecraft.world.item.CreativeModeTab) null, visible); + ziyue.filters.FilterBuilder.filtersVisibility(net.minecraftforge.common.CreativeModeTabRegistry.getTab(creativeModeTab.identifier), visible); } static void setReservedButton(CreativeModeTabHolder creativeModeTab, MutableText tooltip, PressAction onPress) { ziyue.filters.FilterBuilder.setReservedButton(net.minecraftforge.common.CreativeModeTabRegistry.getTab(creativeModeTab.identifier), tooltip.data, onPress); } #endif + static void addBlocks(Filter filter, BlockRegistryObject... blocks) { + for (BlockRegistryObject block : blocks) { + filter.addItems(block.get().asItem().data); + } + } + + static void addItems(Filter filter, ItemRegistryObject... items) { + for (ItemRegistryObject item : items) { + filter.addItems(item.get().data); + } + } } diff --git a/forge/src/main/java/ziyue/tjmetro/mapping/RegistryHelper.java b/forge/src/main/java/ziyue/tjmetro/mapping/RegistryHelper.java new file mode 100644 index 0000000..7c61f83 --- /dev/null +++ b/forge/src/main/java/ziyue/tjmetro/mapping/RegistryHelper.java @@ -0,0 +1,27 @@ +package ziyue.tjmetro.mapping; + +import org.mtr.mapping.holder.Identifier; +import org.mtr.mapping.registry.BlockRegistryObject; +import org.mtr.mapping.registry.ItemRegistryObject; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +/** + * Converting block to item. This may not be stable since it uses reflection. + * + * @author ZiYueCommentary + * @since 1.0.0-beta-2 + */ + +// This is a very mad way but I have no choice. +public interface RegistryHelper +{ + static ItemRegistryObject RegistryObjectBlock2Item(BlockRegistryObject fabric, Identifier forge) + throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException { + Class clazz = ItemRegistryObject.class; + Constructor constructor = clazz.getDeclaredConstructor(Identifier.class); + constructor.setAccessible(true); + return constructor.newInstance(forge); + } +}