@Override
@SideOnly(Side.CLIENT)
public void initModel() {
final Map<WolfArmor, ModelResourceLocation> models = Maps.newHashMap();
for(WolfArmor armor : new WolfArmor[]{WolfArmor.LEATHER, WolfArmor.CHAIN, WolfArmor.IRON, WolfArmor.DIRON, WolfArmor.DIAMOND, WolfArmor.GOLD}){
ModelResourceLocation loc = new ModelResourceLocation("crystalmod:wolfarmor", "armor="+armor.name().toLowerCase());
models.put(armor, loc);
ModelBakery.registerItemVariants(this, loc);
}
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return models.get(getWolfArmor(stack));
}
});
}
java类net.minecraft.client.renderer.ItemMeshDefinition的实例源码
ItemWolfArmor.java 文件源码
项目:CrystalMod
阅读 21
收藏 0
点赞 0
评论 0
BlockRendering.java 文件源码
项目:Aether-Legacy
阅读 20
收藏 0
点赞 0
评论 0
public static void registerBlockWithStateMapper(Block block)
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getBlockModelShapes().registerBlockWithStateMapper(block, new StateMapperBase()
{
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
return new ModelResourceLocation(state.getBlock().getRegistryName(), "normal");
}
});
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), new ItemMeshDefinition()
{
@Override
public ModelResourceLocation getModelLocation(ItemStack stack)
{
return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory");
}
});
}
LiquidXPFluid.java 文件源码
项目:Mekfarm
阅读 19
收藏 0
点赞 0
评论 0
@SideOnly(Side.CLIENT)
public void registerRenderer() {
IFluidBlock block = BlocksRegistry.liquidXpBlock;
Item item = Item.getItemFromBlock((Block)block);
assert (item == Items.AIR);
ModelBakery.registerItemVariants(item);
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(MekfarmMod.MODID + ":fluids", this.getName());
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return modelResourceLocation;
}
});
ModelLoader.setCustomStateMapper((Block) block, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return modelResourceLocation;
}
});
}
SewageFluid.java 文件源码
项目:Mekfarm
阅读 22
收藏 0
点赞 0
评论 0
@SideOnly(Side.CLIENT)
public void registerRenderer() {
IFluidBlock block = BlocksRegistry.sewageBlock;
Item item = Item.getItemFromBlock((Block)block);
assert (item == Items.AIR);
ModelBakery.registerItemVariants(item);
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(MekfarmMod.MODID + ":fluids", this.getName());
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return modelResourceLocation;
}
});
ModelLoader.setCustomStateMapper((Block) block, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return modelResourceLocation;
}
});
}
ClientProxy.java 文件源码
项目:Malgra
阅读 18
收藏 0
点赞 0
评论 0
public void registerFluidModel(Block block) {
Item item = Item.getItemFromBlock(block);
ModelBakery.registerItemVariants(item);
final ModelResourceLocation loc = new ModelResourceLocation(Reference.MODID + ":fluid", "liquidmalgra");
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return loc;
}
});
ModelLoader.setCustomStateMapper(block, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return loc;
}
});
}
FactorizationClientProxy.java 文件源码
项目:Factorization
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void registerISensitiveMeshes(Collection<Item> items) {
for (Item it : items) {
if (!(it instanceof ISensitiveMesh)) {
continue;
}
final ISensitiveMesh ism = (ISensitiveMesh) it;
ModelLoader.setCustomMeshDefinition(it, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
String meshName = ism.getMeshName(stack);
return new ModelResourceLocation("factorization:" + meshName + "#inventory");
}
});
for (ItemStack is : ism.getMeshSamples()) {
ModelLoader.addVariantName(it, "factorization:" + ism.getMeshName(is));
}
}
}
ItemDolly.java 文件源码
项目:EZStorage2
阅读 19
收藏 0
点赞 0
评论 0
@SideOnly(Side.CLIENT)
@Override
public void registerRender() {
ModelResourceLocation[] locations = new ModelResourceLocation[]{
new ModelResourceLocation(this.getRegistryName() + "_empty", "inventory"),
new ModelResourceLocation(this.getRegistryName() + "_chest", "inventory"),
new ModelResourceLocation(this.getRegistryName() + "_storage_core", "inventory")
};
ModelBakery.registerItemVariants(this, locations);
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
if(stack.hasTagCompound() && stack.getTagCompound().getBoolean("isFull")) {
if(stack.getTagCompound().getBoolean("isChest")) {
return locations[1];
}
if(stack.getTagCompound().getBoolean("isStorageCore")) {
return locations[2];
}
}
return locations[0];
}
});
}
ClientProxy.java 文件源码
项目:NOVA-Core
阅读 28
收藏 0
点赞 0
评论 0
@Override
public void postRegisterBlock(FWBlock block) {
super.postRegisterBlock(block);
//Hack to inject custom itemblock definition
Item itemFromBlock = Item.getItemFromBlock(block);
ModelLoader.setCustomMeshDefinition(itemFromBlock, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
ResourceLocation itemRL = (ResourceLocation) Item.itemRegistry.getNameForObject(itemFromBlock);
return new ModelResourceLocation(itemRL, "inventory");
}
}
);
}
PrizeBox.java 文件源码
项目:Skree
阅读 17
收藏 0
点赞 0
评论 0
@Override
public Optional<ItemMeshDefinition> __getCustomMeshDefinition() {
// DO NOT use a lambda here, converting this code to a lambda results
// in the model being unresolvable
//noinspection Convert2Lambda
return Optional.of(new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
Optional<org.spongepowered.api.item.inventory.ItemStack> optContained = getPrizeStack(stack);
return optContained.isPresent() ? new ModelResourceLocation(
optContained.get().getItem().getId(),
"inventory"
) : null;
}
});
}
MFluid.java 文件源码
项目:Minestrappolation-4
阅读 21
收藏 0
点赞 0
评论 0
@SideOnly(Side.CLIENT)
public static void buildRenderFor(Block block, String name)
{
final ModelResourceLocation fluidLocation = new ModelResourceLocation(MReference.MODID + ":" + name, "fluid");
Item fluid = Item.getItemFromBlock(block);
ModelBakery.addVariantName(fluid);
ModelLoader.setCustomMeshDefinition(fluid, new ItemMeshDefinition()
{
@Override
public ModelResourceLocation getModelLocation(ItemStack stack)
{
return fluidLocation;
}
});
ModelLoader.setCustomStateMapper(block, new StateMapperBase()
{
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
return fluidLocation;
}
});
}
ClientHelper.java 文件源码
项目:JsonLootBags
阅读 23
收藏 0
点赞 0
评论 0
public static void preInit()
{
for (final ItemLootBag item : ItemLootBag.getLootBags())
{
// IDK which one is effective, or which one is recommended. So I'm using them all.
// The modeling system is confusing...
ModelLoader.registerItemVariants(item, new ModelResourceLocation(item.texture), new ModelResourceLocation(item.texture, "inventory"));
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack)
{
return new ModelResourceLocation(item.texture);
}
});
ModelLoader.registerItemVariants(item, new ModelResourceLocation(item.texture));
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.texture));
}
}
Fluids.java 文件源码
项目:BaseMetals
阅读 26
收藏 0
点赞 0
评论 0
@SideOnly(Side.CLIENT)
public static void bakeModels(String modID){
for(Fluid fluid : fluidBlocks.keySet()){
BlockFluidBase block = fluidBlocks.get(fluid);
Item item = Item.getItemFromBlock(block);
final ModelResourceLocation fluidModelLocation = new ModelResourceLocation(
modID.toLowerCase() + ":" + fluidBlockNames.get(block), "fluid");
ModelBakery.registerItemVariants(item);
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
{
public ModelResourceLocation getModelLocation(ItemStack stack)
{
return fluidModelLocation;
}
});
ModelLoader.setCustomStateMapper(block, new StateMapperBase()
{
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
return fluidModelLocation;
}
});
}
}
ClientProxy.java 文件源码
项目:vintagecraft
阅读 19
收藏 0
点赞 0
评论 0
private void registerModelLocation(final Item item, final String name, final String type) {
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
//System.out.println("registerModelLocation for " + name);
if (renderItem != null) {
renderItem.getItemModelMesher().register(item, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
//System.out.println(name + "/" + stack.getUnlocalizedName());
if (item instanceof ISubtypeFromStackPovider && ((ISubtypeFromStackPovider)item).getSubType(stack) != null) {
//System.out.println(ModInfo.ModID + ":" + name + "/" + ((ISubtypeFromStackPovider)item).getSubType(stack));
return new ModelResourceLocation(ModInfo.ModID + ":" + name + "/" + ((ISubtypeFromStackPovider)item).getSubType(stack), type);
} else {
return new ModelResourceLocation(ModInfo.ModID + ":" + name, type);
}
}
});
}
}
ModelNullifierBaked.java 文件源码
项目:enderutilities
阅读 23
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
private void reflectMaps()
{
if (LOCATIONS == null || SHAPERS == null)
{
try
{
ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
Field locs = ReflectionHelper.findField(ItemModelMesherForge.class, "locations");
LOCATIONS = (Map<IRegistryDelegate<Item>, TIntObjectHashMap<ModelResourceLocation>>) locs.get(mesher);
Field shapers = ReflectionHelper.findField(ItemModelMesher.class, "field_178092_c", "shapers");
SHAPERS = (Map<Item, ItemMeshDefinition>) shapers.get(mesher);
Field models = ReflectionHelper.findField(ModelLoader.class, "stateModels");
STATE_MODELS = (Map<ModelResourceLocation, IModel>) models.get(MODEL_LOADER);
}
catch (Exception e)
{
EnderUtilities.logger.warn("ModelNullifierBaked: Failed to reflect model maps", e);
}
}
}
ItemHeroBow.java 文件源码
项目:ZeldaSwordSkills
阅读 22
收藏 0
点赞 0
评论 0
@Override
@SideOnly(Side.CLIENT)
public void registerResources() {
String[] variants = getVariants();
models = new ArrayList<ModelResourceLocation>(variants.length);
for (int i = 0; i < variants.length; ++i) {
models.add(new ModelResourceLocation(variants[i], "inventory"));
}
ModelLoader.registerItemVariants(this, models.toArray(new ModelResourceLocation[0]));
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return models.get(0);
}
});
}
ItemMagicMirror.java 文件源码
项目:ZeldaSwordSkills
阅读 20
收藏 0
点赞 0
评论 0
@Override
@SideOnly(Side.CLIENT)
public void registerResources() {
String[] variants = getVariants();
this.models = new ArrayList<ModelResourceLocation>(variants.length);
for (int i = 0; i < variants.length; ++i) {
this.models.add(new ModelResourceLocation(variants[i], "inventory"));
}
ModelLoader.registerItemVariants(this, this.models.toArray(new ModelResourceLocation[0]));
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return models.get(0);
}
});
}
ItemZeldaShield.java 文件源码
项目:ZeldaSwordSkills
阅读 29
收藏 0
点赞 0
评论 0
@Override
@SideOnly(Side.CLIENT)
public void registerResources() {
String[] variants = getVariants();
models = new ArrayList<ModelResourceLocation>(variants.length);
for (int i = 0; i < variants.length; ++i) {
models.add(new ModelResourceLocation(variants[i], "inventory"));
}
ModelLoader.registerItemVariants(this, models.toArray(new ModelResourceLocation[0]));
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return models.get(0);
}
});
}
ItemBlockPedestal.java 文件源码
项目:ZeldaSwordSkills
阅读 19
收藏 0
点赞 0
评论 0
/**
* Pedestal has two variants, one each using meta 0 and 8
*/
@Override
@SideOnly(Side.CLIENT)
public void registerResources() {
String[] variants = getVariants();
this.models = new ArrayList<ModelResourceLocation>(variants.length);
for (int i = 0; i < variants.length; ++i) {
this.models.add(new ModelResourceLocation(variants[i], "inventory"));
}
ModelLoader.registerItemVariants(this, this.models.toArray(new ModelResourceLocation[0]));
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return models.get(stack.getItemDamage() == 8 ? 1 : 0);
}
});
}
ItemCompositionPaper.java 文件源码
项目:Melodium
阅读 21
收藏 0
点赞 0
评论 0
@SideOnly(Side.CLIENT)
@Override
public void initModel(){
ModelBakery.registerItemVariants(this, new ModelResourceLocation(Melodium.MODID+":composition_paper"), new ModelResourceLocation(Melodium.MODID+":song_paper"));
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition(){
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
if (isLearned(stack)){
return new ModelResourceLocation(Melodium.MODID+":song_paper");
}
return new ModelResourceLocation(Melodium.MODID+":composition_paper");
}
});
}
ModelLoader.java 文件源码
项目:CustomWorldGen
阅读 25
收藏 0
点赞 0
评论 0
/**
* Helper method for registering all itemstacks for given item to map to universal bucket model.
*/
public static void setBucketModelDefinition(Item item) {
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
{
@Override
public ModelResourceLocation getModelLocation(ItemStack stack)
{
return ModelDynBucket.LOCATION;
}
});
ModelBakery.registerItemVariants(item, ModelDynBucket.LOCATION);
}
LiqueurLoader.java 文件源码
项目:FoodCraft-Reloaded
阅读 30
收藏 0
点赞 0
评论 0
@Load(side = Side.CLIENT)
@SideOnly(Side.CLIENT)
public void loadRenders() {
try {
Field field = ModelLoader.class.getDeclaredField("customMeshDefinitions");
field.setAccessible(true);
Map<IRegistryDelegate<Item>, ItemMeshDefinition> customMeshDefinitions = (Map<IRegistryDelegate<Item>, ItemMeshDefinition>) field.get(null);
cachedLiqueurs.forEach(liqueur -> {
if (customMeshDefinitions.containsKey(liqueur))
ModelLoader.setCustomModelResourceLocation(liqueur, 0, customMeshDefinitions.get(liqueur).getModelLocation(new ItemStack(liqueur)));
});
} catch (Exception e) {
FoodCraftReloaded.getLogger().error("Cannot get custom mesh definitions", e);
}
}
ItemWrappedFood.java 文件源码
项目:CrystalMod
阅读 21
收藏 0
点赞 0
评论 0
@Override
@SideOnly(Side.CLIENT)
public void initModel(){
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition()
{
@Override
public ModelResourceLocation getModelLocation(ItemStack stack)
{
return ModelWrappedFood.LOCATION;
}
});
ModelBakery.registerItemVariants(this, ModelWrappedFood.LOCATION);
}
ItemMaterialSeed.java 文件源码
项目:CrystalMod
阅读 25
收藏 0
点赞 0
评论 0
@Override
@SideOnly(Side.CLIENT)
public void initModel(){
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition()
{
@Override
public ModelResourceLocation getModelLocation(ItemStack stack)
{
return ModelSeed.LOCATION;
}
});
ModelBakery.registerItemVariants(this, ModelSeed.LOCATION);
}
ItemTeloportTool.java 文件源码
项目:CrystalMod
阅读 19
收藏 0
点赞 0
评论 0
@Override
@SideOnly(Side.CLIENT)
public void initModel() {
final ModelResourceLocation locUnBound = new ModelResourceLocation("crystalmod:telepearl", "bound=false");
final ModelResourceLocation locBound = new ModelResourceLocation("crystalmod:telepearl", "bound=true");
ModelBakery.registerItemVariants(this, locUnBound, locBound);
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
boolean bound = !ItemStackTools.isNullStack(stack) && stack.hasTagCompound() && ItemNBTHelper.verifyExistance(stack, "TeleportLocation");
return bound ? locBound : locUnBound;
}
});
}
ItemSuperTorch.java 文件源码
项目:CrystalMod
阅读 21
收藏 0
点赞 0
评论 0
@Override
@SideOnly(Side.CLIENT)
public void initModel() {
final ModelResourceLocation off = new ModelResourceLocation(getRegistryName(), "on=false");
ModelBakery.registerItemVariants(this, off);
final ModelResourceLocation on = new ModelResourceLocation(getRegistryName(), "on=true");
ModelBakery.registerItemVariants(this, on);
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return ItemNBTHelper.getBoolean(stack, NBT_ON, false) ? on : off;
}
});
}
ItemWirelessPanel.java 文件源码
项目:CrystalMod
阅读 23
收藏 0
点赞 0
评论 0
@Override
@SideOnly(Side.CLIENT)
public void initModel() {
final ModelResourceLocation loc = new ModelResourceLocation("crystalmod:item_wirelesspanel", "active=false");
ModelBakery.registerItemVariants(this, loc);
final ModelResourceLocation active = new ModelResourceLocation("crystalmod:item_wirelesspanel", "active=true");
ModelBakery.registerItemVariants(this, active);
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return isValid(stack) ? active : loc;
}
});
}
OreRegistry.java 文件源码
项目:ExNihiloAdscensio
阅读 26
收藏 0
点赞 0
评论 0
@SideOnly(Side.CLIENT)
public static void initModels() {
final ItemMeshDefinition ORES = new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
switch (stack.getItemDamage()) {
case 0:
return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=piece");
case 1:
return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=hunk");
case 2:
return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=dust");
case 3:
return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=ingot");
default:
return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory");
}
}
};
for (ItemOre ore : itemOreRegistry) {
ModelLoader.setCustomMeshDefinition(ore, ORES);
ModelBakery.registerItemVariants(ore, new ModelResourceLocation("exnihiloadscensio:itemOre", "type=piece"),
new ModelResourceLocation("exnihiloadscensio:itemOre", "type=hunk"),
new ModelResourceLocation("exnihiloadscensio:itemOre", "type=dust"),
new ModelResourceLocation("exnihiloadscensio:itemOre", "type=ingot"));
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ore, ORES);
}
}
ModelHandler.java 文件源码
项目:DFArtifacts
阅读 23
收藏 0
点赞 0
评论 0
public static void registerModel(IVariantHolder holder)
{
ItemMeshDefinition def = holder.getCustomMeshDefinition();
if(holder.getCustomMeshDefinition() != null)
ModelLoader.setCustomMeshDefinition((Item)holder, def);
else
registerModel((Item)holder,holder.getVariants());
}
ItemDish.java 文件源码
项目:AquaMunda
阅读 17
收藏 0
点赞 0
评论 0
@SideOnly(Side.CLIENT)
public void initModel() {
List<ModelResourceLocation> resources = new ArrayList<>();
for (DishInfo info : dishInfos) {
resources.add(new ModelResourceLocation(getRegistryName(), "food=" + info.getTag()));
}
ModelLoader.registerItemVariants(this, resources.toArray(new ModelResourceLocation[resources.size()]));
ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return new ModelResourceLocation(getRegistryName(), "food=" + dishInfos[stack.getItemDamage()].getTag());
}
});
}
ClientProxy.java 文件源码
项目:NOVA-Core
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void registerItem(FWItem item) {
super.registerItem(item);
//Hacks to inject custom item definition
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
ResourceLocation itemRL = (ResourceLocation) Item.itemRegistry.getNameForObject(item);
return new ModelResourceLocation(itemRL, "inventory");
}
}
);
}