MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / run

Method run

Minecraft-Utils/1.13/src/ResourceManager.java:113–199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111
112 EXECUTOR_SERVICE.execute(new Runnable() {
113 @Override
114 public void run() {
115 MinecraftFactory.getClassProxyCallback().getLogger().debug("Loading player resource textures from {} for player {}", minecraftProfileTexture.getUrl(), gameProfile.getName());
116
117 HttpURLConnection connection = null;
118 BufferedReader reader = null;
119 try {
120 connection = (HttpURLConnection) (new URL(minecraftProfileTexture.getUrl())).openConnection(MinecraftFactory.getVars().getProxy());
121 connection.setDoInput(true);
122 connection.setDoOutput(false);
123 connection.connect();
124
125 if (connection.getResponseCode() != 200) {
126 return;
127 }
128 reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
129 String line = reader.readLine();
130
131 TextureData data = gson.fromJson(line, TextureData.class);
132 if (data.animatedCape != null && !data.animatedCape.isEmpty()) {
133 try {
134 BufferedImage cape = ImageIO.read(new ByteArrayInputStream(Base64.decodeBase64(data.animatedCape)));
135 capeTexture.setBufferedImage(cape);
136
137 playerResource.setCapeResource(new CapeResource(capeLocation, capeTexture));
138 } catch (Exception e) {
139 MinecraftFactory.getClassProxyCallback().getLogger().error("Could not parse cape for " + gameProfile.getId(), e);
140 }
141 } else if (data.cape != null && !data.cape.isEmpty()) {
142 try {
143 BufferedImage cape = ImageIO.read(new ByteArrayInputStream(Base64.decodeBase64(data.cape)));
144 capeTexture.setBufferedImage(cape);
145
146 playerResource.setCapeResource(new CapeResource(capeLocation, capeTexture));
147 } catch (Exception e) {
148 MinecraftFactory.getClassProxyCallback().getLogger().error("Could not parse cape for " + gameProfile.getId(), e);
149 }
150 }
151 if (data.models != null) {
152 playerResource.setItemModelResources(Lists.<ItemModelResource>newArrayList());
153 List<TextureData.Model> models = data.models;
154 for (TextureData.Model model : models) {
155 if (StringUtils.isEmpty(model.itemName) || StringUtils.isEmpty(model.texture)) {
156 continue;
157 }
158 try {
159 asw item = asw.f.c(new ResourceLocation(model.itemName));
160 if (item != null) {
161 final ResourceLocation modelLocation = new ResourceLocation(
162 "item-models/" + gameProfile.getId() + "/" + model.itemName + (StringUtils.isNotEmpty(model.render) ? "/" + model.render.toLowerCase(
163 Locale.ROOT) : "") + ".png");
164 final SimpleTexture modelTexture = new SimpleTexture();
165 if (((Variables) MinecraftFactory.getVars()).getTextureManager().b(modelLocation) == null) {
166 ((Variables) MinecraftFactory.getVars()).getTextureManager().a(modelLocation, modelTexture);
167 }
168
169 BufferedImage modelImage = ImageIO.read(new ByteArrayInputStream(Base64.decodeBase64(model.texture)));
170 modelTexture.setBufferedImage(modelImage);

Callers

nothing calls this directly

Calls 15

getClassProxyCallbackMethod · 0.95
getVarsMethod · 0.95
setBufferedImageMethod · 0.95
getModelIdDataMethod · 0.95
createModelMethod · 0.95
isEmptyMethod · 0.80
setCapeResourceMethod · 0.80
setItemModelResourcesMethod · 0.80
getItemModelResourcesMethod · 0.80
disconnectMethod · 0.80
getLoggerMethod · 0.65
getProxyMethod · 0.65

Tested by

no test coverage detected