Skip to content

Commit

Permalink
Merge pull request #152 from anatawa12/fix-invalid-name
Browse files Browse the repository at this point in the history
Fix invalid name
  • Loading branch information
Kai-Z-JP authored Sep 8, 2021
2 parents 4751558 + 3897d47 commit 2883333
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 63 deletions.
70 changes: 35 additions & 35 deletions src/main/java/jp/ngt/rtm/RTMBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,26 +160,26 @@ public static void init() {

RTMRail.init();

GameRegistry.registerBlock(marker, "rtm:marker");
GameRegistry.registerBlock(markerSwitch, "rtm:markerSwitch");
// GameRegistry.registerBlock(markerSlope, "rtm:markerSlope");

GameRegistry.registerBlock(fluorescent, "rtm:fluorescent");
GameRegistry.registerBlock(ironPillar, "rtm:ironPillar");
GameRegistry.registerBlock(insulator, "rtm:insulator");
GameRegistry.registerBlock(signal, "rtm:signal");
GameRegistry.registerBlock(crossingGate, "rtm:crossing");
GameRegistry.registerBlock(variableBlock, "rtm:Variable");
GameRegistry.registerBlock(linePole, "rtm:linePole");
GameRegistry.registerBlock(connector, "rtm:connector");
GameRegistry.registerBlock(powerUnit, "rtm:powerUnit");
RTMCore.registerRtmPrefixed(marker, "rtm:marker");
RTMCore.registerRtmPrefixed(markerSwitch, "rtm:markerSwitch");
// RTMCore.registerRtmPrefixed(markerSlope, "rtm:markerSlope");

RTMCore.registerRtmPrefixed(fluorescent, "rtm:fluorescent");
RTMCore.registerRtmPrefixed(ironPillar, "rtm:ironPillar");
RTMCore.registerRtmPrefixed(insulator, "rtm:insulator");
RTMCore.registerRtmPrefixed(signal, "rtm:signal");
RTMCore.registerRtmPrefixed(crossingGate, "rtm:crossing");
RTMCore.registerRtmPrefixed(variableBlock, "rtm:Variable");
RTMCore.registerRtmPrefixed(linePole, "rtm:linePole");
RTMCore.registerRtmPrefixed(connector, "rtm:connector");
RTMCore.registerRtmPrefixed(powerUnit, "rtm:powerUnit");
GameRegistry.registerBlock(signalConverter, ItemBlockCustom.class, "signal_converter");
GameRegistry.registerBlock(railroadSign, "rtm:railroadSign");
GameRegistry.registerBlock(turnstile, "rtm:turnstile");
GameRegistry.registerBlock(point, "rtm:point");
GameRegistry.registerBlock(rsWire, "rtm:rsWire");
GameRegistry.registerBlock(signboard, "rtm:signboard");
GameRegistry.registerBlock(trainWorkBench, ItemBlockCustom.class, "rtm:trainWorkBench");
RTMCore.registerRtmPrefixed(railroadSign, "rtm:railroadSign");
RTMCore.registerRtmPrefixed(turnstile, "rtm:turnstile");
RTMCore.registerRtmPrefixed(point, "rtm:point");
RTMCore.registerRtmPrefixed(rsWire, "rtm:rsWire");
RTMCore.registerRtmPrefixed(signboard, "rtm:signboard");
RTMCore.registerRtmPrefixed(trainWorkBench, ItemBlockCustom.class, "rtm:trainWorkBench");
GameRegistry.registerBlock(ticketVendor, "ticketVendor");
GameRegistry.registerBlock(mirror, "mirror");
GameRegistry.registerBlock(mirrorCube, "mirror_cube");
Expand All @@ -188,21 +188,21 @@ public static void init() {
GameRegistry.registerBlock(light, "light_block");
GameRegistry.registerBlock(speaker, "speaker");

GameRegistry.registerBlock(fireBrick, "rtm:fireBrick");
GameRegistry.registerBlock(hotStoveBrick, "rtm:hotStoveBrick");
GameRegistry.registerBlock(pipe, "rtm:pipe");
GameRegistry.registerBlock(slot, "rtm:slot");
GameRegistry.registerBlock(furnaceFire, "rtm:furnaceFire");
GameRegistry.registerBlock(exhaustGas, "rtm:exhaustGas");
GameRegistry.registerBlock(liquefiedPigIron, "rtm:pigIron_L");
GameRegistry.registerBlock(liquefiedSteel, "rtm:steel_L");
GameRegistry.registerBlock(slag, "rtm:slag");
GameRegistry.registerBlock(converterCore, "rtm:converterCore");
GameRegistry.registerBlock(converterBase, "rtm:converterBase");
GameRegistry.registerBlock(steelSlab, "rtm:steelSlab");
GameRegistry.registerBlock(brickSlab, "rtm:brickSlab");
GameRegistry.registerBlock(brickDoubleSlab, "rtm:brickDoubleSlab");
GameRegistry.registerBlock(steelMaterial, "rtm:steelMaterial");
RTMCore.registerRtmPrefixed(fireBrick, "rtm:fireBrick");
RTMCore.registerRtmPrefixed(hotStoveBrick, "rtm:hotStoveBrick");
RTMCore.registerRtmPrefixed(pipe, "rtm:pipe");
RTMCore.registerRtmPrefixed(slot, "rtm:slot");
RTMCore.registerRtmPrefixed(furnaceFire, "rtm:furnaceFire");
RTMCore.registerRtmPrefixed(exhaustGas, "rtm:exhaustGas");
RTMCore.registerRtmPrefixed(liquefiedPigIron, "rtm:pigIron_L");
RTMCore.registerRtmPrefixed(liquefiedSteel, "rtm:steel_L");
RTMCore.registerRtmPrefixed(slag, "rtm:slag");
RTMCore.registerRtmPrefixed(converterCore, "rtm:converterCore");
RTMCore.registerRtmPrefixed(converterBase, "rtm:converterBase");
RTMCore.registerRtmPrefixed(steelSlab, "rtm:steelSlab");
RTMCore.registerRtmPrefixed(brickSlab, "rtm:brickSlab");
RTMCore.registerRtmPrefixed(brickDoubleSlab, "rtm:brickDoubleSlab");
RTMCore.registerRtmPrefixed(steelMaterial, "rtm:steelMaterial");
GameRegistry.registerBlock(scaffold, "scaffold");
GameRegistry.registerBlock(scaffoldStairs, "scaffold_stairs");
GameRegistry.registerBlock(framework, "framework");
Expand Down Expand Up @@ -246,4 +246,4 @@ public static void init() {

GameRegistry.registerTileEntity(TileEntityEffect.class, "TEEffect");
}
}
}
60 changes: 60 additions & 0 deletions src/main/java/jp/ngt/rtm/RTMCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import jp.kaiz.kaizpatch.fixrtm.modelpack.FIXFileLoader;
import jp.ngt.ngtlib.util.PermissionManager;
Expand All @@ -16,13 +17,19 @@
import jp.ngt.rtm.gui.RTMGuiHandler;
import jp.ngt.rtm.item.ItemBucketLiquid;
import jp.ngt.rtm.world.RTMChunkManager;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import org.apache.logging.log4j.Level;
import paulscode.sound.SoundSystemConfig;

import java.util.HashMap;
import java.util.Map;

@Mod(modid = RTMCore.MODID, name = "RealTrainMod", version = RTMCore.VERSION)
public final class RTMCore {
public static final String MODID = "RTM";
Expand Down Expand Up @@ -215,6 +222,59 @@ public void handleServerStarting(FMLServerStartingEvent event) {
WireManager.INSTANCE.clear();
}

public static void registerRtmPrefixed(Item item, String name) {
GameRegistry.registerItem(item, removePrefix(name));
registerMapping(item, name);
}

public static void registerRtmPrefixed(Block block, String name) {
GameRegistry.registerBlock(block, removePrefix(name));
registerMapping(block, name);
}

public static void registerRtmPrefixed(Block block, Class<? extends ItemBlock> itemclass, String name) {
GameRegistry.registerBlock(block, itemclass, removePrefix(name));
registerMapping(block, name);
}

private static String removePrefix(String name) {
assert name.startsWith("rtm:");
return name.substring("rtm:".length());
}

public static void registerMapping(Item item, String name) {
itemMap.put(MODID + ':' + name, item);
}

public static void registerMapping(Block block, String name) {
blockMap.put(MODID + ':' + name, block);
Item itemForBlock = Item.getItemFromBlock(block);
if (itemForBlock != null) {
registerMapping(itemForBlock, name);
}
}

private static Map<String, Item> itemMap = new HashMap<>();
private static Map<String, Block> blockMap = new HashMap<>();

@EventHandler
public void handleMissingMapping(FMLMissingMappingsEvent event) {
for (FMLMissingMappingsEvent.MissingMapping mapping : event.get()) {
switch (mapping.type) {
case BLOCK:
Block mappedBlock = blockMap.get(mapping.name);
if (mappedBlock != null)
mapping.remap(mappedBlock);
break;
case ITEM:
Item mappedItem = itemMap.get(mapping.name);
if (mappedItem != null)
mapping.remap(mappedItem);
break;
}
}
}

private static short guiId;

private static short getNextGuiID() {
Expand Down
40 changes: 20 additions & 20 deletions src/main/java/jp/ngt/rtm/RTMItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ public static void init() {

camera = (new ItemCamera()).setUnlocalizedName("rtm:camera").setTextureName("rtm:camera").setCreativeTab(CreativeTabRTM.tabRTMTools);

GameRegistry.registerItem(bogie, "rtm:bogie");
GameRegistry.registerItem(installedObject, "rtm:installedObject");
GameRegistry.registerItem(material, "rtm:material");
GameRegistry.registerItem(crowbar, "rtm:crowbar");
GameRegistry.registerItem(itemtrain, "rtm:itemTrain");
GameRegistry.registerItem(itemMotorman, "rtm:itemMotorman");
GameRegistry.registerItem(itemCargo, "rtm:itemCargo");
GameRegistry.registerItem(itemRailroadSign, "rtm:itemRailroadSign");
GameRegistry.registerItem(ticket, "rtm:ticket");
GameRegistry.registerItem(ticketBook, "rtm:ticketBook");
GameRegistry.registerItem(icCard, "rtm:icCard");
RTMCore.registerRtmPrefixed(bogie, "rtm:bogie");
RTMCore.registerRtmPrefixed(installedObject, "rtm:installedObject");
RTMCore.registerRtmPrefixed(material, "rtm:material");
RTMCore.registerRtmPrefixed(crowbar, "rtm:crowbar");
RTMCore.registerRtmPrefixed(itemtrain, "rtm:itemTrain");
RTMCore.registerRtmPrefixed(itemMotorman, "rtm:itemMotorman");
RTMCore.registerRtmPrefixed(itemCargo, "rtm:itemCargo");
RTMCore.registerRtmPrefixed(itemRailroadSign, "rtm:itemRailroadSign");
RTMCore.registerRtmPrefixed(ticket, "rtm:ticket");
RTMCore.registerRtmPrefixed(ticketBook, "rtm:ticketBook");
RTMCore.registerRtmPrefixed(icCard, "rtm:icCard");
GameRegistry.registerItem(itemLargeRail, "itemLargeRail");
GameRegistry.registerItem(itemSignal, "itemSignal");
GameRegistry.registerItem(itemLinePole, "itemLinePole");
Expand All @@ -149,16 +149,16 @@ public static void init() {
GameRegistry.registerItem(bullet, "bullet");
GameRegistry.registerItem(nvd, "nvd");

GameRegistry.registerItem(bucketLiquid, "rtm:bucketLiquid");
GameRegistry.registerItem(iron_hacksaw, "rtm:ironHacksaw");
GameRegistry.registerItem(steel_ingot, "rtm:ingotSteel");
GameRegistry.registerItem(paddle, "rtm:paddle");
GameRegistry.registerItem(coke, "rtm:coke");
GameRegistry.registerItem(bellows, "rtm:bellows");
GameRegistry.registerItem(itemPipe, "rtm:itemPipe");
RTMCore.registerRtmPrefixed(bucketLiquid, "rtm:bucketLiquid");
RTMCore.registerRtmPrefixed(iron_hacksaw, "rtm:ironHacksaw");
RTMCore.registerRtmPrefixed(steel_ingot, "rtm:ingotSteel");
RTMCore.registerRtmPrefixed(paddle, "rtm:paddle");
RTMCore.registerRtmPrefixed(coke, "rtm:coke");
RTMCore.registerRtmPrefixed(bellows, "rtm:bellows");
RTMCore.registerRtmPrefixed(itemPipe, "rtm:itemPipe");
GameRegistry.registerItem(paintTool, "paint_tool");

GameRegistry.registerItem(camera, "rtm:camera");
RTMCore.registerRtmPrefixed(camera, "rtm:camera");

OreDictionary.registerOre("ingotSteel", new ItemStack(steel_ingot, 1, 0));
OreDictionary.registerOre("fuelCoke", new ItemStack(coke, 1, 0));
Expand Down Expand Up @@ -220,4 +220,4 @@ public static int getPrice(int id) {
return Arrays.stream(MoneyType.values()).filter(type -> type.id == id).findFirst().map(type -> type.price).orElse((short) 0);
}
}
}
}
16 changes: 8 additions & 8 deletions src/main/java/jp/ngt/rtm/RTMRail.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public static void init() {
largeRailSlopeCore[i] = (new BlockLargeRailSlopeCore(i)).setBlockName("rtm:LRLCore." + i).setBlockTextureName(railTexture[i]);
});

GameRegistry.registerBlock(largeRailBase0, "rtm:LRBase");
GameRegistry.registerBlock(largeRailCore0, "rtm:LRCore");
GameRegistry.registerBlock(largeRailSwitchBase0, "rtm:LRSBase");
GameRegistry.registerBlock(largeRailSwitchCore0, "rtm:LRSCore");
GameRegistry.registerBlock(largeRailSlopeBase0, "rtm:LRLBase");
GameRegistry.registerBlock(largeRailSlopeCore0, "rtm:LRLCore");
GameRegistry.registerBlock(TURNTABLE_CORE, "rtm:turntable_core");
RTMCore.registerRtmPrefixed(largeRailBase0, "rtm:LRBase");
RTMCore.registerRtmPrefixed(largeRailCore0, "rtm:LRCore");
RTMCore.registerRtmPrefixed(largeRailSwitchBase0, "rtm:LRSBase");
RTMCore.registerRtmPrefixed(largeRailSwitchCore0, "rtm:LRSCore");
RTMCore.registerRtmPrefixed(largeRailSlopeBase0, "rtm:LRLBase");
RTMCore.registerRtmPrefixed(largeRailSlopeCore0, "rtm:LRLCore");
RTMCore.registerRtmPrefixed(TURNTABLE_CORE, "rtm:turntable_core");

//インスタンス使いまわして登録は不可
IntStream.range(0, railTexture.length).forEach(i -> {
Expand Down Expand Up @@ -156,4 +156,4 @@ public static RailProperty getProperty(byte shape, int texType) {
float h = (texType == 4) ? 0.18125F + 0.0625F : 0.0625F;
return new RailProperty(s0, block, meta, h);
}
}
}

0 comments on commit 2883333

Please sign in to comment.