Skip to content

Instantly share code, notes, and snippets.

@aksource
Last active August 29, 2015 13:56
Show Gist options
  • Save aksource/8844739 to your computer and use it in GitHub Desktop.
Save aksource/8844739 to your computer and use it in GitHub Desktop.
//ID指定だけ。被ってたら被らなくなるまで増加方向にずれる。
private void registerItemToId(Item item, String name, String modId, int Id)
{
//これに悩んでたってわけ。
Map<UniqueIdentifier, ModContainer> customOwners = ObfuscationReflectionHelper.getPrivateValue(GameData.class, null, 3);
ModContainer mc = Loader.instance().activeModContainer();
if (modId != null)
{
//地味にここも悩んだ。
customOwners.put(new UniqueIdentifier(modId + ":" +name), mc);
}
if (item instanceof ItemBlock)
{
throw new RuntimeException("Cannot register an itemblock separately from it's block");
}
int itemId = GameData.itemRegistry.add(Id, name, item);
GameData.blockRegistry.useSlot(itemId);
}
//Itemと殆ど同じ。
private void registerBlockToId(Block block, String name, String modId, int Id)
{
Map<UniqueIdentifier, ModContainer> customOwners = ObfuscationReflectionHelper.getPrivateValue(GameData.class, null, 3);
ModContainer mc = Loader.instance().activeModContainer();
if (modId != null)
{
customOwners.put(new UniqueIdentifier(modId + ":" + name), mc);
}
int blockId = GameData.blockRegistry.add(Id, name, block);
GameData.itemRegistry.useSlot(blockId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment