本文整理汇总了Java中net.minecraft.client.renderer.ItemMeshDefinition类的典型用法代码示例。如果您正苦于以下问题:Java ItemMeshDefinition类的具体用法?Java ItemMeshDefinition怎么用?Java ItemMeshDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ItemMeshDefinition类属于net.minecraft.client.renderer包,在下文中一共展示了ItemMeshDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initModel
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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));
}
});
}
示例2: registerBlockWithStateMapper
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
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");
}
});
}
示例3: registerRenderer
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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;
}
});
}
示例4: registerRenderer
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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;
}
});
}
示例5: registerFluidModel
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
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;
}
});
}
示例6: registerISensitiveMeshes
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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));
}
}
}
示例7: registerRender
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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];
}
});
}
示例8: postRegisterBlock
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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");
}
}
);
}
示例9: __getCustomMeshDefinition
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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;
}
});
}
示例10: buildRenderFor
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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;
}
});
}
示例11: preInit
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
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));
}
}
示例12: bakeModels
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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;
}
});
}
}
示例13: registerModelLocation
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
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);
}
}
});
}
}
示例14: reflectMaps
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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);
}
}
}
示例15: registerResources
import net.minecraft.client.renderer.ItemMeshDefinition; //导入依赖的package包/类
@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);
}
});
}