Java源码示例:net.minecraft.client.renderer.texture.ITextureObject

示例1
private void deleteSkin(ResourceLocation skinLocation) {
    if (skinLocation == null) return;
    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    Map<ResourceLocation, ITextureObject> mapTextureObjects = ((IMixinTextureManager) textureManager).getMapTextureObjects();
    textureManager.deleteTexture(skinLocation);
    mapTextureObjects.remove(skinLocation); // not needed with optifine but needed without it
}
 
示例2
private ResourceLocation findResourceLocation(String name) {
  Map<ResourceLocation, ITextureObject> mapTextureObjects =
      FastReflection.Fields.TextureManager_mapTextureObjects.get(MC.getTextureManager());

  return mapTextureObjects
      .keySet()
      .stream()
      .filter(k -> k.getResourcePath().contains(name))
      .findFirst()
      .orElse(null);
}
 
示例3
private void updateHeldMapTexture(String url) {
  if (MC.player == null || !(MC.player.getHeldItemMainhand().getItem() instanceof ItemMap)) {
    return;
  }
  
  MC.addScheduledTask(
      () -> { // allows DynamicTexture to work
        ItemMap map = (ItemMap) MC.player.getHeldItemMainhand().getItem();
        MapData heldMapData = map.getMapData(MC.player.getHeldItemMainhand(), MC.world);
        
        try {
          BufferedImage image = getImageFromUrl(url);
          
          DynamicTexture dynamicTexture = new DynamicTexture(image);
          dynamicTexture.loadTexture(MC.getResourceManager());
          
          Map<ResourceLocation, ITextureObject> mapTextureObjects =
              FastReflection.Fields.TextureManager_mapTextureObjects.get(MC.getTextureManager());
          
          ResourceLocation textureLocation =
              mapTextureObjects
                  .keySet()
                  .stream()
                  .filter(k -> k.getResourcePath().contains(heldMapData.mapName))
                  .findFirst()
                  .orElse(null);
          
          mapTextureObjects.put(
              textureLocation, dynamicTexture); // overwrite old texture with our custom one
          
        } catch (Exception e) {
          e.printStackTrace();
        }
      });
}
 
示例4
@Override
public ResourceLocation func_152789_a(final MinecraftProfileTexture texture, final Type type, final SkinManager.SkinAvailableCallback callBack) {
	if (type != Type.SKIN)
		return super.func_152789_a(texture, type, callBack);

	final boolean isSpecialCallBack = callBack instanceof ISkinDownloadCallback;
	final ResourceLocation resLocationOld = new ResourceLocation("skins/" + texture.getHash());
	final ResourceLocation resLocation = new ResourceLocation(Reference.MOD_ID, resLocationOld.getResourcePath());
	ITextureObject itextureobject = textureManager.getTexture(resLocation);

	if (itextureobject != null) {
		if (callBack != null)
			callBack.func_152121_a(type, resLocation);
	} else {
		File file1 = new File(skinFolder, texture.getHash().substring(0, 2));
		File file2 = new File(file1, texture.getHash());
		final NewImageBufferDownload imgDownload = new NewImageBufferDownload();
		ITextureObject imgData = new NewThreadDownloadImageData(file2, texture.getUrl(), field_152793_a, imgDownload, resLocationOld, new IImageBuffer() {

			@Override
			public BufferedImage parseUserSkin(BufferedImage buffImg) {
				if (buffImg != null)
					PlayerModelManager.analyseTexture(buffImg, resLocation);
				return imgDownload.parseUserSkin(buffImg);
			}

			@Override
			public void func_152634_a() {
				imgDownload.func_152634_a();
				if (callBack != null)
					callBack.func_152121_a(type, isSpecialCallBack ? resLocation : resLocationOld);
			}
		});
		textureManager.loadTexture(resLocation, imgData);
		textureManager.loadTexture(resLocationOld, imgData); // Avoid thrown exception if the image is requested before the download is done
	}

	return isSpecialCallBack ? resLocation : resLocationOld;
}
 
示例5
@Override
public ITextureObject getTexture() {
    return this.texture;
}
 
示例6
@Accessor Map<ResourceLocation, ITextureObject> getMapTextureObjects(); 
示例7
public ITextureObject getTexture();