Skip to content

Commit

Permalink
register block/item and mapping at once
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Sep 6, 2021
1 parent a2ad16f commit 3897d47
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 119 deletions.
101 changes: 34 additions & 67 deletions src/main/java/jp/ngt/rtm/RTMBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,44 +160,26 @@ public static void init() {

RTMRail.init();

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

GameRegistry.registerBlock(fluorescent, "fluorescent");
GameRegistry.registerBlock(ironPillar, "ironPillar");
GameRegistry.registerBlock(insulator, "insulator");
GameRegistry.registerBlock(signal, "signal");
GameRegistry.registerBlock(crossingGate, "crossing");
GameRegistry.registerBlock(variableBlock, "Variable");
GameRegistry.registerBlock(linePole, "linePole");
GameRegistry.registerBlock(connector, "connector");
GameRegistry.registerBlock(powerUnit, "powerUnit");
RTMCore.registerMapping(fluorescent, "rtm:fluorescent");
RTMCore.registerMapping(ironPillar, "rtm:ironPillar");
RTMCore.registerMapping(insulator, "rtm:insulator");
RTMCore.registerMapping(signal, "rtm:signal");
RTMCore.registerMapping(crossingGate, "rtm:crossing");
RTMCore.registerMapping(variableBlock, "rtm:Variable");
RTMCore.registerMapping(linePole, "rtm:linePole");
RTMCore.registerMapping(connector, "rtm:connector");
RTMCore.registerMapping(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, "railroadSign");
GameRegistry.registerBlock(turnstile, "turnstile");
GameRegistry.registerBlock(point, "point");
GameRegistry.registerBlock(rsWire, "rsWire");
GameRegistry.registerBlock(signboard, "signboard");
GameRegistry.registerBlock(trainWorkBench, ItemBlockCustom.class, "trainWorkBench");
RTMCore.registerMapping(railroadSign, "rtm:railroadSign");
RTMCore.registerMapping(turnstile, "rtm:turnstile");
RTMCore.registerMapping(point, "rtm:point");
RTMCore.registerMapping(rsWire, "rtm:rsWire");
RTMCore.registerMapping(signboard, "rtm:signboard");
RTMCore.registerMapping(trainWorkBench, "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 @@ -206,36 +188,21 @@ public static void init() {
GameRegistry.registerBlock(light, "light_block");
GameRegistry.registerBlock(speaker, "speaker");

GameRegistry.registerBlock(fireBrick, "fireBrick");
GameRegistry.registerBlock(hotStoveBrick, "hotStoveBrick");
GameRegistry.registerBlock(pipe, "pipe");
GameRegistry.registerBlock(slot, "slot");
GameRegistry.registerBlock(furnaceFire, "furnaceFire");
GameRegistry.registerBlock(exhaustGas, "exhaustGas");
GameRegistry.registerBlock(liquefiedPigIron, "pigIron_L");
GameRegistry.registerBlock(liquefiedSteel, "steel_L");
GameRegistry.registerBlock(slag, "slag");
GameRegistry.registerBlock(converterCore, "converterCore");
GameRegistry.registerBlock(converterBase, "converterBase");
GameRegistry.registerBlock(steelSlab, "steelSlab");
GameRegistry.registerBlock(brickSlab, "brickSlab");
GameRegistry.registerBlock(brickDoubleSlab, "brickDoubleSlab");
GameRegistry.registerBlock(steelMaterial, "steelMaterial");
RTMCore.registerMapping(fireBrick, "rtm:fireBrick");
RTMCore.registerMapping(hotStoveBrick, "rtm:hotStoveBrick");
RTMCore.registerMapping(pipe, "rtm:pipe");
RTMCore.registerMapping(slot, "rtm:slot");
RTMCore.registerMapping(furnaceFire, "rtm:furnaceFire");
RTMCore.registerMapping(exhaustGas, "rtm:exhaustGas");
RTMCore.registerMapping(liquefiedPigIron, "rtm:pigIron_L");
RTMCore.registerMapping(liquefiedSteel, "rtm:steel_L");
RTMCore.registerMapping(slag, "rtm:slag");
RTMCore.registerMapping(converterCore, "rtm:converterCore");
RTMCore.registerMapping(converterBase, "rtm:converterBase");
RTMCore.registerMapping(steelSlab, "rtm:steelSlab");
RTMCore.registerMapping(brickSlab, "rtm:brickSlab");
RTMCore.registerMapping(brickDoubleSlab, "rtm:brickDoubleSlab");
RTMCore.registerMapping(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
22 changes: 22 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 @@ -18,6 +19,7 @@
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;
Expand Down Expand Up @@ -220,6 +222,26 @@ 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);
}
Expand Down
57 changes: 19 additions & 38 deletions src/main/java/jp/ngt/rtm/RTMItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,17 @@ public static void init() {

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

GameRegistry.registerItem(bogie, "bogie");
GameRegistry.registerItem(installedObject, "installedObject");
GameRegistry.registerItem(material, "material");
GameRegistry.registerItem(crowbar, "crowbar");
GameRegistry.registerItem(itemtrain, "itemTrain");
GameRegistry.registerItem(itemMotorman, "itemMotorman");
GameRegistry.registerItem(itemCargo, "itemCargo");
GameRegistry.registerItem(itemRailroadSign, "itemRailroadSign");
GameRegistry.registerItem(ticket, "ticket");
GameRegistry.registerItem(ticketBook, "ticketBook");
GameRegistry.registerItem(icCard, "icCard");
RTMCore.registerMapping(bogie, "rtm:bogie");
RTMCore.registerMapping(installedObject, "rtm:installedObject");
RTMCore.registerMapping(material, "rtm:material");
RTMCore.registerMapping(crowbar, "rtm:crowbar");
RTMCore.registerMapping(itemtrain, "rtm:itemTrain");
RTMCore.registerMapping(itemMotorman, "rtm:itemMotorman");
RTMCore.registerMapping(itemCargo, "rtm:itemCargo");
RTMCore.registerMapping(itemRailroadSign, "rtm:itemRailroadSign");
RTMCore.registerMapping(ticket, "rtm:ticket");
RTMCore.registerMapping(ticketBook, "rtm:ticketBook");
RTMCore.registerMapping(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 @@ -160,24 +149,16 @@ public static void init() {
GameRegistry.registerItem(bullet, "bullet");
GameRegistry.registerItem(nvd, "nvd");

GameRegistry.registerItem(bucketLiquid, "bucketLiquid");
GameRegistry.registerItem(iron_hacksaw, "ironHacksaw");
GameRegistry.registerItem(steel_ingot, "ingotSteel");
GameRegistry.registerItem(paddle, "paddle");
GameRegistry.registerItem(coke, "coke");
GameRegistry.registerItem(bellows, "bellows");
GameRegistry.registerItem(itemPipe, "itemPipe");
RTMCore.registerMapping(bucketLiquid, "rtm:bucketLiquid");
RTMCore.registerMapping(iron_hacksaw, "rtm:ironHacksaw");
RTMCore.registerMapping(steel_ingot, "rtm:ingotSteel");
RTMCore.registerMapping(paddle, "rtm:paddle");
RTMCore.registerMapping(coke, "rtm:coke");
RTMCore.registerMapping(bellows, "rtm:bellows");
RTMCore.registerMapping(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, "camera");
RTMCore.registerMapping(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
21 changes: 7 additions & 14 deletions src/main/java/jp/ngt/rtm/RTMRail.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,13 @@ public static void init() {
largeRailSlopeCore[i] = (new BlockLargeRailSlopeCore(i)).setBlockName("rtm:LRLCore." + i).setBlockTextureName(railTexture[i]);
});

GameRegistry.registerBlock(largeRailBase0, "LRBase");
GameRegistry.registerBlock(largeRailCore0, "LRCore");
GameRegistry.registerBlock(largeRailSwitchBase0, "LRSBase");
GameRegistry.registerBlock(largeRailSwitchCore0, "LRSCore");
GameRegistry.registerBlock(largeRailSlopeBase0, "LRLBase");
GameRegistry.registerBlock(largeRailSlopeCore0, "LRLCore");
GameRegistry.registerBlock(TURNTABLE_CORE, "turntable_core");
RTMCore.registerMapping(largeRailBase0, "rtm:LRBase");
RTMCore.registerMapping(largeRailCore0, "rtm:LRCore");
RTMCore.registerMapping(largeRailSwitchBase0, "rtm:LRSBase");
RTMCore.registerMapping(largeRailSwitchCore0, "rtm:LRSCore");
RTMCore.registerMapping(largeRailSlopeBase0, "rtm:LRLBase");
RTMCore.registerMapping(largeRailSlopeCore0, "rtm:LRLCore");
RTMCore.registerMapping(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

0 comments on commit 3897d47

Please sign in to comment.