diff --git a/fabric/src/main/java/org/mtr/mapping/registry/RegistryHelper.java b/fabric/src/main/java/org/mtr/mapping/registry/RegistryHelper.java new file mode 100644 index 0000000..9a6803d --- /dev/null +++ b/fabric/src/main/java/org/mtr/mapping/registry/RegistryHelper.java @@ -0,0 +1,11 @@ +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 block, Identifier blockIdentifier) { + return new ItemRegistryObject(block.get().asItem()); + } +} diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/RegistryClient.java b/fabric/src/main/java/ziyue/tjmetro/mod/RegistryClient.java index f4702e6..8c763bd 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/RegistryClient.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/RegistryClient.java @@ -1,9 +1,6 @@ package ziyue.tjmetro.mod; -import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import org.mtr.mapping.holder.Identifier; -import org.mtr.mapping.holder.Item; -import org.mtr.mapping.holder.ItemConvertible; import org.mtr.mapping.holder.RenderLayer; import org.mtr.mapping.mapper.BlockEntityExtension; import org.mtr.mapping.mapper.BlockEntityRenderer; @@ -31,8 +28,8 @@ public static void registerBlockStationColor(BlockRegistryObject... blocks) { REGISTRY_CLIENT.registerBlockColors((state, world, pos, tintIndex) -> InitClient.getStationColor(pos), blocks); } - public static void registerItemCustomColor(int color, Item item) { - ColorProviderRegistry.ITEM.register((stack, index) -> color, item.data); + public static void registerItemCustomColor(int color, BlockRegistryObject block, String blockIdentifier) { + REGISTRY_CLIENT.registerItemColors((stack, index) -> color, RegistryHelper.RegistryObjectBlock2Item(block, new Identifier(Reference.MOD_ID, blockIdentifier))); } public static void registerBlockCustomColor(BlockRegistryObject... blocks) { diff --git a/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetroClient.java b/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetroClient.java index 3e31fb4..6a8f324 100644 --- a/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetroClient.java +++ b/fabric/src/main/java/ziyue/tjmetro/mod/TianjinMetroClient.java @@ -4,6 +4,7 @@ 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; @@ -101,7 +102,7 @@ public static void init() { RegistryClient.registerBlockStationColor(BlockList.STATION_NAME_SIGN_1); RegistryClient.registerBlockCustomColor(BlockList.CUSTOM_COLOR_CONCRETE, BlockList.CUSTOM_COLOR_CONCRETE_SLAB, BlockList.CUSTOM_COLOR_CONCRETE_STAIRS); RegistryClient.registerBlockCustomColor(BlockList.METAL_POLE_BMT); - RegistryClient.registerItemCustomColor(0xfff100, BlockList.METAL_POLE_BMT.get().asItem()); + RegistryClient.registerItemCustomColor(0xfff100, BlockList.METAL_POLE_BMT, "metal_pole_bmt"); RegistryClient.setupPackets("packet"); @@ -109,7 +110,7 @@ public static void 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/forge/src/main/java/org/mtr/mapping/registry/RegistryHelper.java b/forge/src/main/java/org/mtr/mapping/registry/RegistryHelper.java new file mode 100644 index 0000000..9dd7fb8 --- /dev/null +++ b/forge/src/main/java/org/mtr/mapping/registry/RegistryHelper.java @@ -0,0 +1,11 @@ +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 block, Identifier blockIdentifier) { + return new ItemRegistryObject(blockIdentifier); + } +}