use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project BaseMetals by MinecraftModDevelopmentMods.
the class RegistrationHelper method registerRender.
/**
* @param item
*/
@SideOnly(Side.CLIENT)
public static void registerRender(@Nonnull final Item item) {
final ResourceLocation resourceLocation = item.getRegistryName();
if (!resourceLocation.getResourceDomain().equals(Loader.instance().activeModContainer().getModId())) {
return;
}
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(resourceLocation, "inventory"));
}
use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project artisan-worktables by codetaylor.
the class ModuleTools method onClientRegister.
@Override
public void onClientRegister(Registry registry) {
super.onClientRegister(registry);
registry.registerClientModelRegistrationStrategy(() -> {
for (ItemWorktableTool item : ModuleTools.this.registeredToolList) {
String resourcePath = item.getMaterial().getDataCustomMaterial().isShiny() ? item.getName() + "_highlighted" : item.getName();
ResourceLocation location = new ResourceLocation(MOD_ID, resourcePath);
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(location, "inventory");
ModelLoader.setCustomModelResourceLocation(item, 0, modelResourceLocation);
}
});
}
use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project artisan-worktables by codetaylor.
the class BlockModelRegistrationStrategy method register.
@Override
public void register() {
BlockBase.VARIANT.getAllowedValues().forEach(type -> {
IBlockState state = this.block.getDefaultState().withProperty(BlockBase.VARIANT, type);
Block block = state.getBlock();
Item item = Item.getItemFromBlock(block);
ModelLoader.setCustomModelResourceLocation(item, type.getMeta(), new ModelResourceLocation(Preconditions.checkNotNull(item.getRegistryName(), "Item %s has null registry name", item), BlockBase.VARIANT.getName() + "=" + type.getName()));
});
IBlockState state = this.block.getDefaultState().withProperty(BlockBase.VARIANT, EnumType.MAGE);
Block block = state.getBlock();
Item item = Item.getItemFromBlock(block);
ModelLoader.setCustomModelResourceLocation(item, Short.MAX_VALUE / 2 + EnumType.MAGE.getMeta(), new ModelResourceLocation(Preconditions.checkNotNull(item.getRegistryName(), "Item %s has null registry name", item), BlockBase.VARIANT.getName() + "=" + EnumType.MAGE.getName() + "_active"));
ModelLoader.setCustomStateMapper(this.block, new DefaultStateMapper() {
@Nonnull
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
EnumType type = state.getValue(BlockBase.VARIANT);
if (type == EnumType.MAGE) {
Block block = state.getBlock();
boolean active = state.getValue(BlockBase.ACTIVE);
return new ModelResourceLocation(Preconditions.checkNotNull(Block.REGISTRY.getNameForObject(block), "Block %s has null registry name", block), BlockBase.VARIANT.getName() + "=" + type.getName() + (active ? "_active" : ""));
} else {
Block block = state.getBlock();
return new ModelResourceLocation(Preconditions.checkNotNull(Block.REGISTRY.getNameForObject(block), "Block %s has null registry name", block), BlockBase.VARIANT.getName() + "=" + type.getName());
}
}
});
}
use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project ForestryMC by ForestryMC.
the class ProxyArboricultureClient method onModelBake.
@SubscribeEvent
public <T extends Block & IWoodTyped> void onModelBake(ModelBakeEvent event) {
IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
for (WoodModelEntry<T> entry : woodModelEntrys) {
T woodTyped = entry.woodTyped;
WoodBlockKind woodKind = woodTyped.getBlockKind();
IWoodStateMapper woodMapper = stateMappers.get(woodTyped);
for (IBlockState blockState : woodTyped.getBlockState().getValidStates()) {
IWoodType woodType;
ItemStack itemStack;
if (entry.withVariants) {
int meta = woodTyped.getMetaFromState(blockState);
woodType = woodTyped.getWoodType(meta);
itemStack = new ItemStack(woodTyped, 1, meta);
} else {
woodType = woodTyped.getWoodType(0);
itemStack = new ItemStack(woodTyped);
}
IWoodItemMeshDefinition definition = shapers.get(itemStack.getItem());
ImmutableMap<String, String> textures = WoodTextureManager.getTextures(woodType, woodKind);
if (definition != null) {
retextureItemModel(registry, textures, woodType, woodKind, itemStack, definition);
}
if (woodMapper != null) {
retexturBlockModel(registry, textures, woodType, woodKind, blockState, woodMapper);
}
}
}
}
use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project ForestryMC by ForestryMC.
the class SaplingStateMapper method putStateModelLocations.
@Override
public Map<IBlockState, ModelResourceLocation> putStateModelLocations(Block block) {
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleTreeSpecies) {
IAlleleTreeSpecies tree = (IAlleleTreeSpecies) allele;
IBlockState state = block.getDefaultState().withProperty(BlockSapling.TREE, tree);
LinkedHashMap<IProperty<?>, Comparable<?>> linkedhashmap = Maps.newLinkedHashMap(state.getProperties());
String modID = tree.getModID();
String s = String.format("%s:%s", modID, "germlings");
mapStateModelLocations.put(state, new ModelResourceLocation(s, getPropertyString(linkedhashmap)));
}
}
return mapStateModelLocations;
}
Aggregations