use of net.minecraft.client.renderer.block.statemap.DefaultStateMapper in project TechReborn by TechReborn.
the class RegisterItemJsons method setBlockStateMapper.
public static void setBlockStateMapper(Block block, String path, IProperty<?>... ignoredProperties) {
final String slash = !path.isEmpty() ? "/" : "";
ModelLoader.setCustomStateMapper(block, new DefaultStateMapper() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
Map<IProperty<?>, Comparable<?>> map = Maps.<IProperty<?>, Comparable<?>>newLinkedHashMap(state.getProperties());
for (IProperty<?> iproperty : ignoredProperties) {
map.remove(iproperty);
}
return new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), path + slash + block.getRegistryName().getResourcePath()), this.getPropertyString(map));
}
});
}
use of net.minecraft.client.renderer.block.statemap.DefaultStateMapper in project TechReborn by TechReborn.
the class RegisterItemJsons method registerItems.
private static void registerItems() {
register(ModItems.RE_BATTERY, "battery/re_battery");
register(ModItems.LITHIUM_BATTERY, "battery/lithium_battery");
register(ModItems.ENERGY_CRYSTAL, "battery/energy_crystal");
register(ModItems.LAPOTRONIC_CRYSTAL, "battery/lapotron_crystal");
register(ModItems.LAPOTRONIC_ORB, "battery/lapotronic_orb");
register(ModItems.FREQUENCY_TRANSMITTER, "misc/frequency_transmitter");
register(ModItems.UU_MATTER, "misc/uu_matter");
register(ModItems.SCRAP_BOX, "misc/scrapbox");
register(ModItems.MANUAL, "misc/manual");
register(ModItems.DEBUG, "misc/debug");
register(ModBlocks.RUBBER_SAPLING, "misc/rubber_sapling");
register(ModItems.MISSING_RECIPE_PLACEHOLDER, "misc/missing_recipe");
register(ModItems.STEEL_DRILL, "tool/steel_drill");
register(ModItems.DIAMOND_DRILL, "tool/diamond_drill");
register(ModItems.ADVANCED_DRILL, "tool/advanced_drill");
register(ModItems.STEEL_CHAINSAW, "tool/steel_chainsaw");
register(ModItems.DIAMOND_CHAINSAW, "tool/diamond_chainsaw");
register(ModItems.ADVANCED_CHAINSAW, "tool/advanced_chainsaw");
register(ModItems.STEEL_JACKHAMMER, "tool/steel_jackhammer");
register(ModItems.DIAMOND_JACKHAMMER, "tool/diamond_jackhammer");
register(ModItems.ADVANCED_JACKHAMMER, "tool/advanced_jackhammer");
register(ModItems.NANOSABER, "tool/nanosaber");
register(ModItems.TREE_TAP, "tool/treetap");
register(ModItems.ELECTRIC_TREE_TAP, "tool/electric_treetap");
register(ModItems.CLOAKING_DEVICE, "tool/cloaking_device");
register(ModItems.OMNI_TOOL, "tool/omni_tool");
register(ModItems.ROCK_CUTTER, "tool/rock_cutter");
register(ModItems.WRENCH, "tool/wrench");
register(ModItems.LAPOTRONIC_ORB_PACK, "tool/lapotronic_orbpack");
register(ModItems.LITHIUM_BATTERY_PACK, "tool/lithium_batpack");
if (ConfigTechReborn.enableGemArmorAndTools) {
registerBlockstateMultiItem(ModItems.RUBY_HELMET, "ruby_helmet", "items/tool/armour");
registerBlockstateMultiItem(ModItems.RUBY_CHESTPLATE, "ruby_chestplate", "items/tool/armour");
registerBlockstateMultiItem(ModItems.RUBY_LEGGINGS, "ruby_leggings", "items/tool/armour");
registerBlockstateMultiItem(ModItems.RUBY_BOOTS, "ruby_boots", "items/tool/armour");
registerBlockstateMultiItem(ModItems.SAPPHIRE_HELMET, "sapphire_helmet", "items/tool/armour");
registerBlockstateMultiItem(ModItems.SAPPHIRE_CHSTPLATE, "sapphire_chestplate", "items/tool/armour");
registerBlockstateMultiItem(ModItems.SAPPHIRE_LEGGINGS, "sapphire_leggings", "items/tool/armour");
registerBlockstateMultiItem(ModItems.SAPPHIRE_BOOTS, "sapphire_boots", "items/tool/armour");
registerBlockstateMultiItem(ModItems.PERIDOT_HELMET, "peridot_helmet", "items/tool/armour");
registerBlockstateMultiItem(ModItems.PERIDOT_CHESTPLATE, "peridot_chestplate", "items/tool/armour");
registerBlockstateMultiItem(ModItems.PERIDOT_LEGGINGS, "peridot_leggings", "items/tool/armour");
registerBlockstateMultiItem(ModItems.PERIDOT_BOOTS, "peridot_boots", "items/tool/armour");
registerBlockstateMultiItem(ModItems.BRONZE_HELMET, "bronze_helmet", "items/tool/armour");
registerBlockstateMultiItem(ModItems.BRONZE_CHESTPLATE, "bronze_chestplate", "items/tool/armour");
registerBlockstateMultiItem(ModItems.BRONZE_LEGGINGS, "bronze_leggings", "items/tool/armour");
registerBlockstateMultiItem(ModItems.BRONZE_BOOTS, "bronze_boots", "items/tool/armour");
registerBlockstateMultiItem(ModItems.RUBY_PICKAXE, "ruby_pickaxe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.RUBY_SWORD, "ruby_sword", "items/tool/tool");
registerBlockstateMultiItem(ModItems.RUBY_AXE, "ruby_axe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.RUBY_SPADE, "ruby_spade", "items/tool/tool");
registerBlockstateMultiItem(ModItems.RUBY_HOE, "ruby_hoe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.SAPPHIRE_PICKAXE, "sapphire_pickaxe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.SAPPHIRE_SWORD, "sapphire_sword", "items/tool/tool");
registerBlockstateMultiItem(ModItems.SAPPHIRE_AXE, "sapphire_axe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.SAPPHIRE_SPADE, "sapphire_spade", "items/tool/tool");
registerBlockstateMultiItem(ModItems.SAPPHIRE_HOE, "sapphire_hoe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.PERIDOT_PICKAXE, "peridot_pickaxe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.PERIDOT_SWORD, "peridot_sword", "items/tool/tool");
registerBlockstateMultiItem(ModItems.PERIDOT_AXE, "peridot_axe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.PERIDOT_SAPPHIRE, "peridot_spade", "items/tool/tool");
registerBlockstateMultiItem(ModItems.PERIDOT_HOE, "peridot_hoe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.BRONZE_PICKAXE, "bronze_pickaxe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.BRONZE_SWORD, "bronze_sword", "items/tool/tool");
registerBlockstateMultiItem(ModItems.BRONZE_AXE, "bronze_axe", "items/tool/tool");
registerBlockstateMultiItem(ModItems.BRONZE_SPADE, "bronze_spade", "items/tool/tool");
registerBlockstateMultiItem(ModItems.BRONZE_HOE, "bronze_hoe", "items/tool/tool");
}
String[] name = ItemIngots.types.clone();
for (int i = 0; i < ItemIngots.types.length; ++i) {
registerBlockstate(ModItems.INGOTS, i, name[i], "items/materials/");
}
name = ItemGems.types.clone();
for (int i = 0; i < ItemGems.types.length; ++i) {
registerBlockstate(ModItems.GEMS, i, name[i], "items/materials/");
}
name = ItemPlates.types.clone();
for (int i = 0; i < ItemPlates.types.length; ++i) {
if (!name[i].equals(ModItems.META_PLACEHOLDER)) {
registerBlockstate(ModItems.PLATES, i, name[i], "items/materials/");
}
}
name = ItemNuggets.types.clone();
for (int i = 0; i < ItemNuggets.types.length; ++i) {
if (!name[i].equals(ModItems.META_PLACEHOLDER)) {
registerBlockstate(ModItems.NUGGETS, i, name[i], "items/materials/");
}
}
name = ItemDusts.types.clone();
for (int i = 0; i < ItemDusts.types.length; ++i) {
if (!name[i].equals(ModItems.META_PLACEHOLDER)) {
registerBlockstate(ModItems.DUSTS, i, name[i], "items/materials/");
}
}
name = ItemDustsSmall.types.clone();
for (int i = 0; i < ItemDustsSmall.types.length; ++i) {
if (!name[i].equals(ModItems.META_PLACEHOLDER)) {
registerBlockstate(ModItems.SMALL_DUSTS, i, name[i], "items/materials/");
}
}
name = ItemParts.types.clone();
for (int i = 0; i < ItemParts.types.length; ++i) {
if (!name[i].equals(ModItems.META_PLACEHOLDER)) {
registerBlockstate(ModItems.PARTS, i, name[i], "items/materials/");
}
}
name = ItemUpgrades.types.clone();
for (int i = 0; i < ItemUpgrades.types.length; ++i) {
registerBlockstate(ModItems.UPGRADES, i, name[i], "items/misc/");
}
for (EnumCableType cableType : EnumCableType.values()) {
registerBlockstateMultiItem(Item.getItemFromBlock(ModBlocks.CABLE), cableType.ordinal(), cableType.getName().toLowerCase(), "cable_inv");
}
ModelLoader.setCustomStateMapper(ModBlocks.CABLE, new DefaultStateMapper() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
Map<IProperty<?>, Comparable<?>> map = Maps.<IProperty<?>, Comparable<?>>newLinkedHashMap(state.getProperties());
if (state.getValue(BlockCable.TYPE).ordinal() <= 4) {
return new ModelResourceLocation(new ResourceLocation(ModBlocks.CABLE.getRegistryName().getResourceDomain(), ModBlocks.CABLE.getRegistryName().getResourcePath()) + "_thin", this.getPropertyString(map));
}
return new ModelResourceLocation(new ResourceLocation(ModBlocks.CABLE.getRegistryName().getResourceDomain(), ModBlocks.CABLE.getRegistryName().getResourcePath()) + "_thick", this.getPropertyString(map));
}
});
}
use of net.minecraft.client.renderer.block.statemap.DefaultStateMapper in project EnderIO by SleepyTrousers.
the class BlockDetector method registerRenderers.
@Override
@SideOnly(Side.CLIENT)
public void registerRenderers(@Nonnull IModObject modObject) {
Item item = Item.getItemFromBlock(this);
Map<IBlockState, ModelResourceLocation> locations = new DefaultStateMapper().putStateModelLocations(this);
IBlockState state = getDefaultState().withProperty(IS_ON, true).withProperty(FACING, EnumFacing.UP);
ModelResourceLocation mrl = locations.get(state);
if (mrl != null) {
ModelLoader.setCustomModelResourceLocation(item, 0, mrl);
}
}
Aggregations