net.minecraft.client.Minecraft.getResourceManager()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(176)

本文整理了Java中net.minecraft.client.Minecraft.getResourceManager()方法的一些代码示例,展示了Minecraft.getResourceManager()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Minecraft.getResourceManager()方法的具体详情如下:
包路径:net.minecraft.client.Minecraft
类名称:Minecraft
方法名:getResourceManager

Minecraft.getResourceManager介绍

暂无

代码示例

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
  public void modelRegistration( Side side, IModelRegistry registry )
  {
    registry.setCustomStateMapper( this.block, this.stateMapper );
    if( this.stateMapper instanceof IResourceManagerReloadListener )
    {
      ( (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager() )
          .registerReloadListener( (IResourceManagerReloadListener) this.stateMapper );
    }
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public boolean accepts( ResourceLocation modelLocation )
{
  String modelPath = modelLocation.getResourcePath();
  if( modelLocation.getResourcePath().startsWith( "models/" ) )
  {
    modelPath = modelPath.substring( "models/".length() );
  }
  try( InputStreamReader io = new InputStreamReader( Minecraft.getMinecraft()
      .getResourceManager()
      .getResource( new ResourceLocation( modelLocation.getResourceDomain(), "models/" + modelPath + ".json" ) )
      .getInputStream() ) )
  {
    return gson.fromJson( io, UVLMarker.class ).ae2_uvl_marker;
  }
  catch( Exception e )
  {
    // Catch-all in case of any JSON parser issues.
  }
  return false;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

.getResourceManager()
.getResource(
    new ResourceLocation( modelLocation.getResourceDomain(), "models/" + modelPath + ".json" ) );

代码示例来源:origin: Vazkii/Botania

public static void initShaders() {
  if (Minecraft.getMinecraft().getResourceManager() instanceof SimpleReloadableResourceManager) {
    ((SimpleReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(manager -> {
      deleteShader(pylonGlow); pylonGlow = 0;
      deleteShader(enchanterRune); enchanterRune = 0;
      deleteShader(manaPool); manaPool = 0;
      deleteShader(doppleganger); doppleganger = 0;
      deleteShader(halo); halo = 0;
      deleteShader(dopplegangerBar); dopplegangerBar = 0;
      deleteShader(terraPlateRune); terraPlateRune = 0;
      deleteShader(filmGrain); filmGrain = 0;
      deleteShader(gold); gold = 0;
      deleteShader(categoryButton); categoryButton = 0;
      deleteShader(alpha); alpha = 0;
      loadShaders();
    });
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

@Nullable
public static IResource getResource(ResourceLocation location) {
  try {
    IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
    return resourceManager.getResource(location);
  } catch (IOException e) {
    return null;
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

public static List<IResource> getResources(ResourceLocation location) {
    try {
      IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
      return resourceManager.getAllResources(location);
    } catch (IOException e) {
      return Collections.emptyList();
    }
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
  public void preInit() {
    IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
    if (resourceManager instanceof IReloadableResourceManager) {
      IReloadableResourceManager manager = (IReloadableResourceManager) resourceManager;
      manager.registerReloadListener(BookLoader.INSTANCE);
    }
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

public static boolean resourceExists(ResourceLocation location) {
  IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
  try {
    resourceManager.getResource(location);
    return true;
  } catch (IOException e) {
    return false;
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

private static ModelBlockDefinition loadMultipartMBD(ResourceLocation location, ResourceLocation fileIn) {
  List<ModelBlockDefinition> list = Lists.newArrayList();
  Minecraft mc = Minecraft.getMinecraft();
  IResourceManager manager = mc.getResourceManager();
  try {
    for (IResource resource : manager.getAllResources(fileIn)) {
      list.add(loadModelBlockDefinition(location, resource));
    }
  } catch (IOException e) {
    throw new RuntimeException("Encountered an exception when loading model definition of model " + fileIn, e);
  }
  return new ModelBlockDefinition(list);
}

代码示例来源:origin: GregTechCE/GregTech

public static void init() {
  IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
  Minecraft.getMinecraft().defaultResourcePacks.add(instance);
  if (resourceManager instanceof SimpleReloadableResourceManager) {
    ((SimpleReloadableResourceManager) resourceManager).registerReloadListener(instance);
  }
}

代码示例来源:origin: Vazkii/Patchouli

public void init() {
  addPageTypes();
  IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
  if (manager instanceof IReloadableResourceManager)
    ((IReloadableResourceManager) manager).registerReloadListener(this);
  else
    throw new RuntimeException("Minecraft's resource manager is not reloadable. Something went way wrong.");
}

代码示例来源:origin: ForestryMC/ForestryMC

private static Reader getReaderForResource(ResourceLocation location) throws IOException {
  ResourceLocation file = new ResourceLocation(location.getNamespace(),
    location.getPath() + ".json");
  IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(file);
  return new BufferedReader(new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8));
}

代码示例来源:origin: MrCrayfish/MrCrayfishDeviceMod

@Override
public void preInit()
{
  super.preInit();
  ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(this);
}

代码示例来源:origin: ForestryMC/Binnie

@Override
public boolean checkTexture(final ResourceLocation location) {
  final SimpleTexture texture = new SimpleTexture(location);
  try {
    texture.loadTexture(this.getMinecraftInstance().getResourceManager());
  } catch (IOException e) {
    return false;
  }
  return true;
}

代码示例来源:origin: Vazkii/Patchouli

protected InputStream loadJson(ResourceLocation resloc, ResourceLocation fallback) {
  try {
    return Minecraft.getMinecraft().getResourceManager().getResource(resloc).getInputStream();
  } catch (IOException e) {
    //no-op
  }
  if(fallback != null) {
    System.err.println("Patchouli failed to load " + resloc + ". Switching to fallback.");
    return loadJson(fallback, null);
  }
  return null;
}

代码示例来源:origin: ExtraCells/ExtraCells2

private static Reader getReaderForResource(ResourceLocation location) throws IOException {
    ResourceLocation file = new ResourceLocation(location.getResourceDomain(),
      location.getResourcePath() + ".json");
    IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(file);
    return new BufferedReader(new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8));
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

public DynaTextureProvider(int textureSize, @Nonnull ResourceLocation fallBackTexture) {
 this.textureManager = Minecraft.getMinecraft().getTextureManager();
 this.resourceManager = Minecraft.getMinecraft().getResourceManager();
 this.fallBackTexture = fallBackTexture;
 this.dynamicTexture = new DynamicTexture(textureSize, textureSize);
 this.imageData = this.dynamicTexture.getTextureData();
 this.resourceLocation = textureManager.getDynamicTextureLocation(EnderIO.DOMAIN, this.dynamicTexture);
 for (int i = 0; i < this.imageData.length; ++i) {
  this.imageData[i] = 0;
 }
 instances.add(this);
}

代码示例来源:origin: sinkillerj/ProjectE

public static void init()
{
  IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
  if (resourceManager instanceof IReloadableResourceManager)
  {
    ((IReloadableResourceManager) resourceManager).registerReloadListener(resourceManager1 -> ManualPageHandler.reset());
  }
  reset();
}

代码示例来源:origin: CoFH/CoFHCore

@Override
public void postInit(FMLPostInitializationEvent event) {
  super.postInit(event);
  fontRenderer = new FontRendererCore(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().renderEngine, Minecraft.getMinecraft().gameSettings.forceUnicodeFont);
  if (Minecraft.getMinecraft().gameSettings.language != null) {
    fontRenderer.setUnicodeFlag(Minecraft.getMinecraft().isUnicode());
    fontRenderer.setBidiFlag(Minecraft.getMinecraft().getLanguageManager().isCurrentLanguageBidirectional());
  }
  ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(fontRenderer);
  ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(EventHandlerRender.INSTANCE);
  fontRenderer.initSpecialCharacters();
}

代码示例来源:origin: elucent/Albedo

@SideOnly(Side.CLIENT)
  @EventHandler
  public void preinit(FMLPreInitializationEvent event)
  {
    ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new ShaderUtil());
    MinecraftForge.EVENT_BUS.register(new EventManager());
    MinecraftForge.EVENT_BUS.register(new ConfigManager());
    ConfigManager.init(event.getSuggestedConfigurationFile());
  }
}

相关文章