Skip to content

Commit

Permalink
Fixed bug related Metal Pole BMT
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiYueCommentary committed Aug 9, 2024
1 parent e22ddf8 commit f384aed
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
11 changes: 11 additions & 0 deletions fabric/src/main/java/org/mtr/mapping/registry/RegistryHelper.java
Original file line number Diff line number Diff line change
@@ -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());
}
}
7 changes: 2 additions & 5 deletions fabric/src/main/java/ziyue/tjmetro/mod/RegistryClient.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -101,15 +102,15 @@ 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");

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();
}
}
11 changes: 11 additions & 0 deletions forge/src/main/java/org/mtr/mapping/registry/RegistryHelper.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit f384aed

Please sign in to comment.