@Override
 public void preInit(FMLPreInitializationEvent event) {
   super.preInit(event);
   Item item = Item.getItemFromBlock(CustomModelBlock.instance);
   ModelLoader.setCustomModelResourceLocation(item, 0, itemLocation);
   ModelLoader.setCustomStateMapper(
       CustomModelBlock.instance,
       new StateMapperBase() {
         protected ModelResourceLocation getModelResourceLocation(IBlockState p_178132_1_) {
           return blockLocation;
         }
       });
   MinecraftForge.EVENT_BUS.register(BakeEventHandler.instance);
 }
Пример #2
0
 @Override
 public void preInit(FMLPreInitializationEvent event) {
   super.preInit(event);
   registerKeyBindings();
   ModelLoader.setCustomModelResourceLocation(MeleeCore.meleeCore, 0, Refs.modelResourceLocation);
   ModelLoaderRegistry.registerLoader(new ItemCoreModelLoader());
 }
Пример #3
0
  private void addVariantNames(Item item, String... names) {
    for (int i = 0; i < names.length; i++) {
      names[i] = "weaponmod:" + names[i];
    }

    ModelLoader.addVariantName(item, names);
  }
Пример #4
0
  private static void registerBlockItemModel(Block block, String resourceName) {
    if (Settings.disabledItemsBlocks.contains(resourceName)) return;

    ModelLoader.setCustomModelResourceLocation(
        Item.getItemFromBlock(block),
        0,
        new ModelResourceLocation(Reference.DOMAIN + resourceName, "inventory"));
  }
Пример #5
0
 @SideOnly(Side.CLIENT)
 @Override
 public void registerModels() {
   ModelLoader.setCustomStateMapper(
       this, (new StateMap.Builder()).ignore(getTypeProperty()).build());
   ModelHandler.registerCustomItemblock(
       this,
       EnumDyeColor.values().length,
       i -> "glimmering_flower_" + EnumDyeColor.byMetadata(i).getName());
 }
Пример #6
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);
 }
Пример #7
0
 @SideOnly(Side.CLIENT)
 public static void registerFluidRender(BlockFluidBase blockFluid, String blockStateName) {
   final String location = FMLTutor.MODID + ":" + blockStateName;
   final Item itemFluid = Item.getItemFromBlock(blockFluid);
   ModelLoader.setCustomMeshDefinition(
       itemFluid,
       new ItemMeshDefinition() {
         @Override
         public ModelResourceLocation getModelLocation(ItemStack stack) {
           return new ModelResourceLocation(location, "fluid");
         }
       });
   ModelLoader.setCustomStateMapper(
       blockFluid,
       new StateMapperBase() {
         @Override
         protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
           return new ModelResourceLocation(location, "fluid");
         }
       });
 }
  /** ■モデルの登録 */
  @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);
  }
Пример #9
0
 @SideOnly(Side.CLIENT)
 public void registerModel() {
   ModelLoader.setCustomModelResourceLocation(
       this, 0, new ModelResourceLocation("parachronology:basicmoment", "inventory"));
 }
Пример #10
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);
        }
      }
    }
  }
Пример #11
0
 public IModel loadModel(ResourceLocation modelLocation) throws IOException {
   return loader.new VanillaModelWrapper(modelLocation, loader.loadModel(modelLocation));
 }
Пример #12
0
 @SideOnly(Side.CLIENT)
 public void initModel() {
   ModelLoader.setCustomModelResourceLocation(
       Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory"));
   ClientRegistry.bindTileEntitySpecialRenderer(TilePedestal.class, new TilePedestalRenderer());
 }
Пример #13
0
 @SideOnly(Side.CLIENT)
 public void initModel() {
   ModelLoader.setCustomModelResourceLocation(
       this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
 }
Пример #14
0
 private void registerItem(Item item, int damage) {
   ModelLoader.setCustomModelResourceLocation(
       item, damage, new ModelResourceLocation(item.getRegistryName(), "inventory"));
 }
Пример #15
0
 private void registerItemBlock(Block block, int damage) {
   ModelLoader.setCustomModelResourceLocation(
       Item.getItemFromBlock(block),
       damage,
       new ModelResourceLocation(block.getRegistryName(), "inventory"));
 }
Пример #16
0
 @Override
 public void setTextureName(Item item, int damage, String texturename) {
   ModelLoader.setCustomModelResourceLocation(
       item, damage, new ModelResourceLocation("weaponmod:" + texturename, "inventory"));
 }
Пример #17
0
 @SideOnly(Side.CLIENT)
 @Override
 public final void registerModels() {
   ModelLoader.setCustomStateMapper(
       this, (new StateMap.Builder()).ignore(getTypeProperty()).build());
 }