Пример #1
0
 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);
 }
  /** ■モデルの登録 */
  @Override
  public void registerModels() {
    String strName[] = new String[arrNum];
    for (int idx = 0; idx < strName.length; idx++) {
      // ■リソース文字列
      strName[idx] = Hizume.MOD_ID + ":" + Hizume.nameHizume + (idx == 0 ? "" : idx);
      // ■リソース
      mrHizume[idx] = new ModelResourceLocation(strName[idx], "inventory");
    }

    ModelLoader.setCustomModelResourceLocation(Hizume.itemHizume, 0, mrHizume[0]);

    ModelBakery.addVariantName(Hizume.itemHizume, strName);
  }
Пример #3
0
 @Override
 public void registerItemBlockTexture(
     Block block, String blockclassname, String subtype, int meta) {
   Minecraft.getMinecraft()
       .getRenderItem()
       .getItemModelMesher()
       .register(
           Item.getItemFromBlock(block),
           meta,
           new ModelResourceLocation(
               "vintagecraft:" + blockclassname + "/" + subtype, "inventory"));
   ModelBakery.addVariantName(
       Item.getItemFromBlock(block), "vintagecraft:" + blockclassname + "/" + subtype);
 }
Пример #4
0
 public void addVariantNamesFromEnum(Item item, String prefix, IStateEnum[] names) {
   for (IStateEnum state : names) {
     ModelBakery.addVariantName(item, prefix + state.getStateName());
   }
 }
Пример #5
0
 public void addVariantName(Item item, String... names) {
   ModelBakery.addVariantName(item, names);
 }
Пример #6
0
  @Override
  public void postInit(FMLPostInitializationEvent event) {
    super.postInit(event);

    registerModelLocation(Item.getItemFromBlock(BlocksVC.woodenrail), "woodenrail", "inventory");

    registerModelLocation(Item.getItemFromBlock(BlocksVC.saltlamp), "saltlamp", "inventory");

    registerModelLocation(
        Item.getItemFromBlock(BlocksVC.tallmetalmolds), "tallmetalmolds", "inventory");

    registerModelLocation(
        Item.getItemFromBlock(BlocksVC.blastpowdersack), "blastpowdersack", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.stonepot), "vintagecraft:stonepot/", EnumRockType.values());
    registerModelLocation(Item.getItemFromBlock(BlocksVC.stonepot), "stonepot", "inventory");

    registerModelLocation(Item.getItemFromBlock(BlocksVC.toolrack), "toolrack", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.axle), "vintagecraft:axle/", EnumTree.values());
    registerModelLocation(Item.getItemFromBlock(BlocksVC.axle), "axle", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.angledgears),
        "vintagecraft:angledgearbox/",
        EnumTree.values());
    registerModelLocation(
        Item.getItemFromBlock(BlocksVC.angledgears), "angledgearbox", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.windmillrotor),
        "vintagecraft:windmillrotor/",
        EnumTree.values());
    registerModelLocation(
        Item.getItemFromBlock(BlocksVC.windmillrotor), "windmillrotor", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.bellows), "vintagecraft:bellows/", EnumTree.values());
    registerModelLocation(Item.getItemFromBlock(BlocksVC.bellows), "bellows", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.grindstone),
        "vintagecraft:grindstone/",
        EnumRockType.values());
    registerModelLocation(Item.getItemFromBlock(BlocksVC.grindstone), "grindstone", "inventory");

    for (EnumTree treetype : EnumTree.values()) {
      if (treetype.jankahardness > 800) {
        ModelBakery.addVariantName(
            Item.getItemFromBlock(BlocksVC.carpenterTable),
            "vintagecraft:carpentertable/" + treetype.getName());

        for (EnumBucketContents cnt : EnumBucketContents.values()) {
          ModelBakery.addVariantName(
              Item.getItemFromBlock(BlocksVC.woodbucket),
              "vintagecraft:woodbucket/" + treetype.getName() + "-" + cnt.getName());
        }
      }
    }
    registerModelLocation(Item.getItemFromBlock(BlocksVC.woodbucket), "woodbucket", "inventory");
    registerModelLocation(
        Item.getItemFromBlock(BlocksVC.carpenterTable), "carpentertable", "inventory");

    registerModelLocation(ItemsVC.stone, "stone", "inventory");
    registerModelLocation(ItemsVC.seeds, "seeds", "inventory");

    registerModelLocation(ItemsVC.fireclay_ball, "fireclay_ball", "inventory");
    registerModelLocation(ItemsVC.fireclay_brick_raw, "fireclay_brick_raw", "inventory");
    registerModelLocation(ItemsVC.fireclay_brick, "fireclay_brick", "inventory");

    registerModelLocation(ItemsVC.ore, "ore", "inventory");
    registerModelLocation(ItemsVC.metalingot, "ingot", "inventory");

    registerModelLocation(ItemsVC.seeds, "seeds", "inventory");
    registerModelLocation(ItemsVC.dryGrass, "drygrass", "inventory");

    registerModelLocation(ItemsVC.coalpoweredMinecart, "minecart/coalpowered", "inventory");
    registerModelLocation(ItemsVC.emptyMinecart, "minecart/empty", "inventory");

    registerModelLocation(ItemsVC.blastingPowder, "blastingpowder", "inventory");
    registerModelLocation(ItemsVC.flaxFibers, "flaxfibers", "inventory");

    registerModelLocation(ItemsVC.linenCloth, "linencloth", "inventory");
    registerModelLocation(ItemsVC.firestarter, "firestarter", "inventory");
    registerModelLocation(ItemsVC.ironTuyere, "irontuyere", "inventory");
    registerModelLocation(ItemsVC.flaxTwine, "flaxtwine", "inventory");
    registerModelLocation(ItemsVC.stitchedleather, "stitchedleather", "inventory");
    registerModelLocation(ItemsVC.sail, "sail", "inventory");
    registerModelLocation(ItemsVC.peatbrick, "peatbrick", "inventory");

    registerModelLocation(ItemsVC.tools.values().toArray(new Item[0]), "tool", "inventory");
    registerModelLocation(ItemsVC.toolheads.values().toArray(new Item[0]), "toolhead", "inventory");

    registerModelLocation(ItemsVC.anvilbase, "anvilbase", "inventory");
    registerModelLocation(ItemsVC.anvilsurface, "anvilsurface", "inventory");

    registerModelLocation(ItemsVC.armor.values().toArray(new Item[0]), "armor", "inventory");

    registerModelLocation(
        new Item[] {
          ItemsVC.bread,
          ItemsVC.porkchopRaw,
          ItemsVC.porkchopCooked,
          ItemsVC.beefRaw,
          ItemsVC.beefCooked,
          ItemsVC.chickenRaw,
          ItemsVC.chickenCooked
        },
        "food",
        "inventory");

    ClientRegistry.registerTileEntity(TEIngotPile.class, "ingotpile", new TESRIngotPile());
    ClientRegistry.registerTileEntity(TEToolRack.class, "toolrack", new TESRToolRack());
    ClientRegistry.registerTileEntity(TEVessel.class, "ceramicvessel2", new TESRCeramicVessel());
    ClientRegistry.registerTileEntity(TEStonePot.class, "stonepot", new TESRStonePot());
    ClientRegistry.registerTileEntity(TEAxle.class, "axle", new TESRAxle());
    ClientRegistry.registerTileEntity(
        TEAngledGears.class, "angledgearbox", new TESRAngledGearBox());
    ClientRegistry.registerTileEntity(
        TEWindmillRotor.class, "windmillrotor", new TESRWindmillRotor());
    ClientRegistry.registerTileEntity(TEGrindStone.class, "grindstone", new TESRGrindstone());
    ClientRegistry.registerTileEntity(TEBellows.class, "bellows", new TESRBellows());
    ClientRegistry.registerTileEntity(
        TETallMetalMold.class, "tallmetalmold", new TESRTallMetalMold());
    ClientRegistry.registerTileEntity(TEWoodBucket.class, "woodbucket", new TESRWoodBucket());
  }
Пример #7
0
 public static void preInit() {
   ModelBakery.addVariantName(
       ModItems.metaItem, "mayhem:meta_item_white", "mayhem:meta_item_black");
 }
Пример #8
0
 /**
  * Adds a simple mapping from Item + metadata to the model variant. Registers the variant with the
  * ModelBakery too.
  */
 public static void setCustomModelResourceLocation(
     Item item, int metadata, ModelResourceLocation model) {
   customModels.put(Pair.of(item.delegate, metadata), model);
   ModelBakery.registerItemVariants(item, model);
 }
Пример #9
0
  @SideOnly(Side.CLIENT)
  @SubscribeEvent(priority = EventPriority.LOWEST)
  public void bakeModels(ModelBakeEvent event) {
    ItemModelMesher itemModelMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
    for (Object object : jsonDestroyer.objectsToDestroy) {
      if (object instanceof Block && object instanceof ITexturedBlock) {
        ITexturedBlock textureProvdier = (ITexturedBlock) object;
        Block block = (Block) object;
        for (int i = 0; i < textureProvdier.amountOfStates(); i++) {
          HashMap<EnumFacing, TextureAtlasSprite> textureMap =
              new HashMap<EnumFacing, TextureAtlasSprite>();
          for (EnumFacing side : EnumFacing.VALUES) {
            for (BlockIconInfo iconInfo : blockIconInfoList) {
              if (iconInfo.getBlock() == block
                  && iconInfo.getMeta() == i
                  && iconInfo.getSide() == side) {
                if (blockIconList.containsKey(iconInfo))
                  textureMap.put(side, blockIconList.get(iconInfo));
              }
            }
          }
          if (textureMap.isEmpty()) {
            return;
          }

          BlockModel model =
              new BlockModel(
                  textureMap, block.getStateFromMeta(i).getBlock() instanceof IOpaqueBlock);
          ModelResourceLocation modelResourceLocation =
              getModelResourceLocation(block.getStateFromMeta(i));
          //                    if(event.modelManager.getModel(modelResourceLocation) !=
          // event.modelManager.getMissingModel()){
          //                        FMLLog.info("Model found @ " + modelResourceLocation.toString()
          // + ", this means a resource pack is overriding it or a modder is doing something bad.
          // JSON-Destoyer will not attempt to create a model for it.");
          //                        continue;
          //                    }
          event.modelRegistry.putObject(modelResourceLocation, model);
          ModelResourceLocation inventory = getBlockinventoryResourceLocation(block);
          //                    if(event.modelManager.getModel(inventory) !=
          // event.modelManager.getMissingModel()){
          //                        FMLLog.info("Model found @ " + inventory.toString() + ", this
          // means a resource pack is overriding it or a modder is doing something bad.
          // JSON-Destoyer will not attempt to create a model for it.");
          //                        continue;
          //                    }
          event.modelRegistry.putObject(inventory, model);
          itemModelMesher.register(Item.getItemFromBlock(block), i, inventory);
          event.modelRegistry.putObject(modelResourceLocation, model);
          itemModelMesher.register(Item.getItemFromBlock(block), i, modelResourceLocation);
        }
      } else if (object instanceof ITexturedFluid && object instanceof BlockFluidBase) {
        final BlockFluidBase fluid = (BlockFluidBase) object;
        final ModelResourceLocation fluidLocation =
            new ModelResourceLocation(fluid.getFluid().getFlowing(), "fluid");
        //                if(event.modelManager.getModel(fluidLocation) !=
        // event.modelManager.getMissingModel()){
        //                    FMLLog.info("Model found @ " + fluidLocation.toString() + ", this
        // means a resource pack is overriding it or a modder is doing something bad. JSON-Destoyer
        // will not attempt to create a model for it.");
        //                    continue;
        //                }
        Item fluidItem = Item.getItemFromBlock(fluid);
        ModelBakery.addVariantName(fluidItem);
        ModelLoader.setCustomMeshDefinition(
            fluidItem,
            new ItemMeshDefinition() {
              public ModelResourceLocation getModelLocation(ItemStack stack) {
                return fluidLocation;
              }
            });
        ModelLoader.setCustomStateMapper(
            fluid,
            new StateMapperBase() {
              protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
                return fluidLocation;
              }
            });

        for (int i = 0; i < 16; i++) {
          ModelResourceLocation location =
              new ModelResourceLocation(getBlockResourceLocation(fluid), "level=" + i);
          if (event.modelManager.getModel(location) != event.modelManager.getMissingModel()) {
            FMLLog.info(
                "Model found @ "
                    + location.toString()
                    + ", this means a resource pack is overriding it or a modder is doing something bad. JSON-Destoyer will not attempt to create a model for it.");
            continue;
          }
          ModelFluid modelFluid = new ModelFluid(fluid.getFluid());
          Function<ResourceLocation, TextureAtlasSprite> textureGetter =
              new Function<ResourceLocation, TextureAtlasSprite>() {
                public TextureAtlasSprite apply(ResourceLocation location) {
                  return fluidIcons.get(fluid);
                }
              };
          IFlexibleBakedModel bakedModel =
              modelFluid.bake(
                  modelFluid.getDefaultState(), DefaultVertexFormats.BLOCK, textureGetter);

          event.modelRegistry.putObject(location, bakedModel);
        }
        ModelResourceLocation inventoryLocation =
            new ModelResourceLocation(getBlockResourceLocation(fluid), "inventory");
        //                if(event.modelManager.getModel(inventoryLocation) !=
        // event.modelManager.getMissingModel()){
        //                    FMLLog.info("Model found @ " + inventoryLocation.toString() + ", this
        // means a resource pack is overriding it or a modder is doing something bad. JSON-Destoyer
        // will not attempt to create a model for it.");
        //                    continue;
        //                }
        ModelFluid modelFluid = new ModelFluid(fluid.getFluid());
        Function<ResourceLocation, TextureAtlasSprite> textureGetter =
            new Function<ResourceLocation, TextureAtlasSprite>() {
              public TextureAtlasSprite apply(ResourceLocation location) {
                return fluidIcons.get(fluid);
              }
            };
        IFlexibleBakedModel bakedModel =
            modelFluid.bake(modelFluid.getDefaultState(), DefaultVertexFormats.ITEM, textureGetter);

        event.modelRegistry.putObject(inventoryLocation, bakedModel);
      } else if (object instanceof Item && object instanceof ITexturedItem) {
        ITexturedItem iTexturedItem = (ITexturedItem) object;
        Item item = (Item) object;
        for (int i = 0; i < iTexturedItem.getMaxMeta(); i++) {
          TextureAtlasSprite texture = null;
          ItemIconInfo itemIconInfo = null;
          for (ItemIconInfo info : itemIcons) {
            if (info.damage == i && info.getItem() == item && info.isBucket == false) {
              texture = info.getSprite();
              itemIconInfo = info;
              break;
            }
          }
          if (texture == null) {
            break;
          }

          ModelResourceLocation inventory;
          inventory = getItemInventoryResourceLocation(item);

          if (iTexturedItem.getMaxMeta() != 1) {
            if (item.getModel(new ItemStack(item, 1, i), Minecraft.getMinecraft().thePlayer, 0)
                != null) {
              inventory =
                  item.getModel(new ItemStack(item, 1, i), Minecraft.getMinecraft().thePlayer, 0);
            }
          }
          //                    if(event.modelManager.getModel(inventory) !=
          // event.modelManager.getMissingModel()){
          //                        FMLLog.info("Model found @ " + inventory.toString() + ", this
          // means a resource pack is overriding it or a modder is doing something bad.
          // JSON-Destoyer will not attempt to create a model for it.");
          //                        continue;
          //                    }

          final TextureAtlasSprite finalTexture = texture;
          Function<ResourceLocation, TextureAtlasSprite> textureGetter =
              new Function<ResourceLocation, TextureAtlasSprite>() {
                public TextureAtlasSprite apply(ResourceLocation location) {
                  return finalTexture;
                }
              };
          ImmutableList.Builder<ResourceLocation> builder = ImmutableList.builder();
          builder.add(new ResourceLocation(itemIconInfo.textureName));
          CustomModel itemLayerModel = new CustomModel(builder.build());
          IBakedModel model =
              itemLayerModel.bake(
                  ItemLayerModel.instance.getDefaultState(),
                  DefaultVertexFormats.ITEM,
                  textureGetter);
          itemModelMesher.register(item, i, inventory);
          event.modelRegistry.putObject(inventory, model);
        }
      } else if (object instanceof Item && object instanceof ITexturedBucket) {
        ITexturedBucket iTexturedBucket = (ITexturedBucket) object;
        Item item = (Item) object;
        for (int i = 0; i < iTexturedBucket.getMaxMeta(); i++) {
          ModelResourceLocation inventory;
          inventory = getItemInventoryResourceLocation(item);
          if (iTexturedBucket.getMaxMeta() != 1) {
            if (item.getModel(new ItemStack(item, 1, i), Minecraft.getMinecraft().thePlayer, 0)
                != null) {
              inventory =
                  item.getModel(new ItemStack(item, 1, i), Minecraft.getMinecraft().thePlayer, 0);
            }
          }
          //                    if(event.modelManager.getModel(inventory) !=
          // event.modelManager.getMissingModel()){
          //                        FMLLog.info("Model found @ " + inventory.toString() + ", this
          // means a resource pack is overriding it or a modder is doing something bad.
          // JSON-Destoyer will not attempt to create a model for it.");
          //                        continue;
          //                    }
          Function<ResourceLocation, TextureAtlasSprite> textureGetter;
          textureGetter =
              new Function<ResourceLocation, TextureAtlasSprite>() {
                public TextureAtlasSprite apply(ResourceLocation location) {
                  return Minecraft.getMinecraft()
                      .getTextureMapBlocks()
                      .getAtlasSprite(location.toString());
                }
              };
          ModelDynBucket modelDynBucket =
              new ModelDynBucket(
                  new ResourceLocation("forge:items/bucket_base"),
                  new ResourceLocation("forge:items/bucket_fluid"),
                  new ResourceLocation("forge:items/bucket_cover"),
                  iTexturedBucket.getFluid(i),
                  iTexturedBucket.isGas(i));

          IBakedModel model =
              modelDynBucket.bake(
                  ItemLayerModel.instance.getDefaultState(),
                  DefaultVertexFormats.ITEM,
                  textureGetter);
          itemModelMesher.register(item, i, inventory);
          event.modelRegistry.putObject(inventory, model);
        }
      }
    }
  }