use of net.minecraft.client.render.MapRenderer in project Skyblocker by LifeIsAParadox.
the class DungeonMap method render.
public static void render(MatrixStack matrices) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null && client.world == null)
return;
ItemStack item = client.player.getInventory().main.get(8);
NbtCompound tag = item.getNbt();
if (tag != null && tag.contains("map")) {
String tag2 = tag.asString();
tag2 = StringUtils.substringBetween(tag2, "map:", "}");
int mapid = Integer.parseInt(tag2);
VertexConsumerProvider.Immediate vertices = client.getBufferBuilders().getEffectVertexConsumers();
MapRenderer map = client.gameRenderer.getMapRenderer();
MapState state = FilledMapItem.getMapState(mapid, client.world);
if (state == null)
return;
matrices.push();
matrices.translate(2, 2, 0);
matrices.scale(1, 1, 0);
map.draw(matrices, vertices, mapid, state, false, 15728880);
vertices.draw();
matrices.pop();
}
}
use of net.minecraft.client.render.MapRenderer in project meteor-client by MeteorDevelopment.
the class SaveMapCommand method saveMap.
private void saveMap(ItemStack map, MapState state, String path, int scale) {
// this is horrible code but it somehow works
MapRenderer mapRenderer = mc.gameRenderer.getMapRenderer();
MapRenderer.MapTexture texture = ((MapRendererAccessor) mapRenderer).invokeGetMapTexture(FilledMapItem.getMapId(map), state);
int[] data = texture.texture.getImage().makePixelArray();
BufferedImage image = new BufferedImage(128, 128, 2);
image.setRGB(0, 0, image.getWidth(), image.getHeight(), data, 0, 128);
BufferedImage scaledImage = new BufferedImage(scale, scale, 2);
if (scale != 128) {
Graphics2D g = scaledImage.createGraphics();
g.setComposite(AlphaComposite.Src);
g.drawImage(image, 0, 0, scale, scale, null);
g.dispose();
}
try {
ImageIO.write((scale == 128 ? image : scaledImage), "png", new File(path));
} catch (IOException e) {
e.printStackTrace();
}
}
use of net.minecraft.client.render.MapRenderer in project Client by MatHax.
the class SaveMapCommand method saveMap.
private void saveMap(ItemStack map, MapState state, String path, int scale) {
// This is horrible code but it somehow works
MapRenderer mapRenderer = mc.gameRenderer.getMapRenderer();
MapRenderer.MapTexture texture = ((MapRendererAccessor) mapRenderer).invokeGetMapTexture(FilledMapItem.getMapId(map), state);
int[] data = texture.texture.getImage().makePixelArray();
BufferedImage image = new BufferedImage(128, 128, 2);
image.setRGB(0, 0, image.getWidth(), image.getHeight(), data, 0, 128);
BufferedImage scaledImage = new BufferedImage(scale, scale, 2);
if (scale != 128) {
Graphics2D g = scaledImage.createGraphics();
g.setComposite(AlphaComposite.Src);
g.drawImage(image, 0, 0, scale, scale, null);
g.dispose();
}
try {
ImageIO.write((scale == 128 ? image : scaledImage), "png", new File(path));
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations