Delete NBTUtils/src/text directory
@ -1,43 +0,0 @@
|
|||||||
package text;
|
|
||||||
|
|
||||||
import main.mc.MCBlock;
|
|
||||||
import main.mc.MCBlocksCollective;
|
|
||||||
import main.mc.MCPosInt;
|
|
||||||
import main.mc.MCRegion;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class BlocksCollective {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
try {
|
|
||||||
//创建
|
|
||||||
MCRegion mcRegion = new MCRegion(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\测试地图\\region"));
|
|
||||||
//mcRegion.setSaveMode(MCRegion.SAVEMODE_RewriteAll);
|
|
||||||
|
|
||||||
//获取方块集
|
|
||||||
MCBlocksCollective blocks = mcRegion.getBlocksCollective(new MCPosInt(9404, 60, 10171), new MCPosInt(9303, 97, 10098));
|
|
||||||
|
|
||||||
//替换水为蓝色羊毛
|
|
||||||
blocks.replace(b -> {
|
|
||||||
return "minecraft:water".equals(b.getBlockName());
|
|
||||||
}, new MCBlock("minecraft:blue_wool"));
|
|
||||||
|
|
||||||
//替换空气为屏障
|
|
||||||
blocks.replace(b -> {
|
|
||||||
return "minecraft:air".equals(b.getBlockName());
|
|
||||||
}, new MCBlock("minecraft:barrier"));
|
|
||||||
|
|
||||||
//设置方块集 绕y轴顺时针旋转1次
|
|
||||||
mcRegion.setBlocksCollective(new MCPosInt(9303, 100, 10098), blocks.rotation(1, 1));
|
|
||||||
|
|
||||||
//设置方块集 y轴翻转
|
|
||||||
mcRegion.setBlocksCollective(new MCPosInt(9303, 150, 10098), blocks.flip(false, true, false));
|
|
||||||
|
|
||||||
//保存
|
|
||||||
mcRegion.saveMCA();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 29 KiB |
@ -1,172 +0,0 @@
|
|||||||
package text;
|
|
||||||
|
|
||||||
import main.Utils.BytesUtils;
|
|
||||||
import main.mc.MCPosInt;
|
|
||||||
import main.mc.MCRegion;
|
|
||||||
import main.nbt.CompoundTag;
|
|
||||||
|
|
||||||
import javax.sound.midi.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class MCMusic {
|
|
||||||
static final String[] NOTE_NAMES = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
|
|
||||||
static MCRegion mcRegion = null;
|
|
||||||
static int z = 0;
|
|
||||||
static int x = 0;
|
|
||||||
static CompoundTag c1, c2, c3, cs, cb, cb2;
|
|
||||||
|
|
||||||
static boolean[] playkey = new boolean[25];
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Sequence sequence = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
mcRegion = new MCRegion(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\BadApple\\region"), MCRegion.SAVEMODE_RewritePart);
|
|
||||||
sequence = MidiSystem.getSequence(new File("E:\\工程文件\\java\\MCNBT\\src\\text\\Touhou-Bad-Apple-train-20220115212348-nonstop2k.com.mid"));
|
|
||||||
mcRegion.setGenerateChunk(mcRegion.getChunk(new MCPosInt(4, 4)));
|
|
||||||
cb = mcRegion.getBlockState(new MCPosInt(0, -60, 0));
|
|
||||||
cb2 = mcRegion.getBlockState(new MCPosInt(1, -60, 0));
|
|
||||||
c1 = mcRegion.getBlockEntitie(new MCPosInt(0, -60, 0));
|
|
||||||
c2 = mcRegion.getBlockEntitie(new MCPosInt(1, -60, 0));
|
|
||||||
c3 = mcRegion.getBlockEntitie(new MCPosInt(2, -60, 0));
|
|
||||||
cs = c2.clone();
|
|
||||||
} catch (InvalidMidiDataException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
long tickTime = ((sequence.getMicrosecondLength() / sequence.getTickLength())) / 1000;// 1tick 的毫秒时间
|
|
||||||
System.out.println("时长:" + sequence.getMicrosecondLength());
|
|
||||||
System.out.println("Ticks:" + sequence.getTickLength());
|
|
||||||
System.out.println(sequence.getMicrosecondLength() / sequence.getTickLength());
|
|
||||||
long Ntick = 0;
|
|
||||||
int minK = 999;
|
|
||||||
z = 10000;
|
|
||||||
|
|
||||||
//生成轨道
|
|
||||||
for (int i = 0; i < (sequence.getMicrosecondLength() / 1000) / 50; i++) {
|
|
||||||
mcRegion.setBlockState(new MCPosInt(0, -60, z + i), cb);
|
|
||||||
mcRegion.setBlockState(new MCPosInt(1, -60, z + i), cb2);
|
|
||||||
mcRegion.setBlockState(new MCPosInt(2, -60, z + i), cb2);
|
|
||||||
mcRegion.setBlockEntitie(new MCPosInt(0, -60, z + i), c1);
|
|
||||||
mcRegion.setBlockEntitie(new MCPosInt(1, -60, z + i), c2);
|
|
||||||
mcRegion.setBlockEntitie(new MCPosInt(2, -60, z + i), c3);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (Track track : sequence.getTracks()) {
|
|
||||||
|
|
||||||
for (int i = 0; i < track.size(); i++) {
|
|
||||||
|
|
||||||
MidiMessage message = track.get(i).getMessage();
|
|
||||||
if (message instanceof ShortMessage) {
|
|
||||||
ShortMessage sm = (ShortMessage) message;
|
|
||||||
if (sm.getCommand() == ShortMessage.NOTE_ON) {
|
|
||||||
int key = sm.getData1();
|
|
||||||
int octave = (key / 12) - 1;
|
|
||||||
int note = key % 12;
|
|
||||||
|
|
||||||
if (minK > key)
|
|
||||||
minK = key;
|
|
||||||
playsound(key - 24 - 8 , (int) (track.get(i).getTick() * tickTime));
|
|
||||||
//play(key - 60);
|
|
||||||
} else if (sm.getCommand() == ShortMessage.NOTE_OFF) {
|
|
||||||
int key = sm.getData1();
|
|
||||||
int octave = (key / 12) - 1;
|
|
||||||
int note = key % 12;
|
|
||||||
|
|
||||||
if (minK > key)
|
|
||||||
minK = key;
|
|
||||||
|
|
||||||
//stop(key - 60);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//System.out.println(track.get(i).getTick());
|
|
||||||
//delay(tickTime * track.get(i).getTick() - Ntick);
|
|
||||||
//Ntick = tickTime * track.get(i).getTick();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("最小音调" + minK);
|
|
||||||
|
|
||||||
delay(100);
|
|
||||||
|
|
||||||
mcRegion.saveMCA();
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void delay(long ms) throws IOException {
|
|
||||||
for (long i = 0; i < ms / 40; i++) {
|
|
||||||
|
|
||||||
|
|
||||||
mcRegion.setBlockState(new MCPosInt(0, -60, z), cb);
|
|
||||||
mcRegion.setBlockState(new MCPosInt(1, -60, z), cb2);
|
|
||||||
mcRegion.setBlockState(new MCPosInt(2, -60, z), cb2);
|
|
||||||
mcRegion.setBlockEntitie(new MCPosInt(0, -60, z), c1);
|
|
||||||
mcRegion.setBlockEntitie(new MCPosInt(1, -60, z), c2);
|
|
||||||
mcRegion.setBlockEntitie(new MCPosInt(2, -60, z), c3);
|
|
||||||
/*for (int j = 0; j < playkey.length; j++) {
|
|
||||||
if (playkey[j])
|
|
||||||
playsound(j);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
z++;
|
|
||||||
x = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void playsound(int a, int time) throws IOException {
|
|
||||||
//0-24
|
|
||||||
int posZ = time / 50;
|
|
||||||
int posX = 3;
|
|
||||||
|
|
||||||
while (!"minecraft:air".equals(mcRegion.getBlockState(new MCPosInt(x + posX, -60, z + posZ)).getTag("Name"))) {
|
|
||||||
posX++;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcRegion.setBlockState(new MCPosInt(x + posX, -60, z + posZ), cb2);
|
|
||||||
String block = "";
|
|
||||||
if (a < 25) {
|
|
||||||
a--;
|
|
||||||
block = "notepp:block.note_block.bit_-1";
|
|
||||||
} else if (a < 49) {
|
|
||||||
block = "block.note_block.bit";
|
|
||||||
} else if (a < 73) {
|
|
||||||
a++;
|
|
||||||
block = "notepp:block.note_block.bit_1";
|
|
||||||
}
|
|
||||||
///playsound notepp:block.note_block.bit_1 ambient @a 2.49 -59.00 -0.63 1 2
|
|
||||||
cs.setTag("Command", "playsound " + block + " ambient @a ~ ~ ~ 1000 " + String.valueOf((float) Math.pow(2, ((-12.0 + (a % 25)) / 12.0))));
|
|
||||||
|
|
||||||
mcRegion.setBlockEntitie(new MCPosInt(x + posX, -60, z + posZ), cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void play(int a) {
|
|
||||||
if (a < 0)
|
|
||||||
a = 0;
|
|
||||||
if (a > 24)
|
|
||||||
a = 24;
|
|
||||||
playkey[a] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void stop(int a) {
|
|
||||||
if (a < 0)
|
|
||||||
a = 0;
|
|
||||||
if (a > 24)
|
|
||||||
a = 24;
|
|
||||||
playkey[a] = false;
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 422 KiB |
Before Width: | Height: | Size: 631 KiB |
Before Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 9.7 KiB |
@ -1,188 +0,0 @@
|
|||||||
package text.lib;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.font.GlyphVector;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class MyImageFilter {
|
|
||||||
public BufferedImage bufferedImage;
|
|
||||||
|
|
||||||
public MyImageFilter(Dimension size) {
|
|
||||||
bufferedImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_4BYTE_ABGR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyImageFilter(BufferedImage bufferedImage) {
|
|
||||||
this.bufferedImage = bufferedImage;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyImageFilter(String imgPath) throws IOException {
|
|
||||||
bufferedImage = ImageIO.read(new File(imgPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyImageFilter(Image image) {
|
|
||||||
bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_4BYTE_ABGR);
|
|
||||||
bufferedImage.createGraphics().drawImage(image, 0, 0, bufferedImage.getWidth(), bufferedImage.getHeight(), null);
|
|
||||||
//this.image = image;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//缩放图片
|
|
||||||
public MyImageFilter Zoom(Dimension size) {
|
|
||||||
BufferedImage bfimg = new BufferedImage(size.width, size.height, BufferedImage.TYPE_4BYTE_ABGR);
|
|
||||||
Graphics2D graphics2D = bfimg.createGraphics();
|
|
||||||
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
||||||
graphics2D.drawImage(bufferedImage, 0, 0, size.width, size.height, null);
|
|
||||||
bfimg.getGraphics().dispose();
|
|
||||||
|
|
||||||
bufferedImage = bfimg;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//修改画布
|
|
||||||
public MyImageFilter ChangeCanvas(Point Pos, Dimension size) {
|
|
||||||
BufferedImage bfimg = new BufferedImage(size.width, size.height, BufferedImage.TYPE_4BYTE_ABGR);
|
|
||||||
bfimg.getGraphics().drawImage(bufferedImage, Pos.x, Pos.y, bufferedImage.getWidth(), bufferedImage.getHeight(), null);
|
|
||||||
bfimg.getGraphics().dispose();
|
|
||||||
bufferedImage = bfimg;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public MyImageFilter DrawIMG(MyImageFilter img, Point pos,Dimension size) {
|
|
||||||
Graphics2D g2d = bufferedImage.createGraphics();
|
|
||||||
g2d.drawImage(img.bufferedImage, pos.x, pos.y,size.width,size.height, null);
|
|
||||||
g2d.dispose();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//改透明度
|
|
||||||
public MyImageFilter ChangeAllAlpha(int Alpha) {
|
|
||||||
BufferedImage bfimg = new BufferedImage(bufferedImage.getWidth(null), bufferedImage.getHeight(null), BufferedImage.TYPE_4BYTE_ABGR);
|
|
||||||
bfimg.getGraphics().drawImage(bufferedImage, 0, 0, bfimg.getWidth(), bfimg.getHeight(), null);
|
|
||||||
//
|
|
||||||
for (int y = 0; y < bfimg.getHeight(); y++) {
|
|
||||||
for (int x = 0; x < bfimg.getWidth(); x++) {
|
|
||||||
Color color = new Color(bfimg.getRGB(x, y), true);
|
|
||||||
|
|
||||||
//System.out.println(color.getAlpha());
|
|
||||||
if (color.getAlpha() > Alpha) {
|
|
||||||
bfimg.setRGB(x, y, new Color(color.getRed(), color.getGreen(), color.getBlue(), Alpha).getRGB());
|
|
||||||
//bfimg.setRGB(x, y, new Color(Alpha,0,0,255).getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bfimg.getGraphics().dispose();
|
|
||||||
bufferedImage = bfimg;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//与另一张图片进行比较 颜色相同Alpha
|
|
||||||
public MyImageFilter CompareColor(MyImageFilter img) {
|
|
||||||
BufferedImage bfimg = new BufferedImage(bufferedImage.getWidth(null), bufferedImage.getHeight(null), BufferedImage.TYPE_4BYTE_ABGR);
|
|
||||||
bfimg.getGraphics().drawImage(bufferedImage, 0, 0, bfimg.getWidth(), bfimg.getHeight(), null);
|
|
||||||
|
|
||||||
for (int y = 0; y < bfimg.getHeight(); y++) {
|
|
||||||
for (int x = 0; x < bfimg.getWidth(); x++) {
|
|
||||||
Color color = new Color(bfimg.getRGB(x, y), true);
|
|
||||||
Color color2 = new Color(img.bufferedImage.getRGB(x, y), true);
|
|
||||||
int r = 3;
|
|
||||||
//System.out.println(color.getAlpha());
|
|
||||||
if (color.getRed() - color2.getRed() < r) {
|
|
||||||
if (color.getGreen() - color2.getGreen() < r)
|
|
||||||
if (color.getBlue() - color2.getBlue() < r)
|
|
||||||
bfimg.setRGB(x, y, new Color(color.getRed(), color.getGreen(), color.getBlue(), 0).getRGB());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bfimg.getGraphics().dispose();
|
|
||||||
bufferedImage = bfimg;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//截取图片
|
|
||||||
public MyImageFilter Intercept(Rectangle rectangle) {
|
|
||||||
BufferedImage bfimg = new BufferedImage(rectangle.width, rectangle.height, BufferedImage.TYPE_4BYTE_ABGR);
|
|
||||||
bfimg.getGraphics().drawImage(bufferedImage, -rectangle.x, -rectangle.y, bufferedImage.getWidth(null), bufferedImage.getHeight(null), null);
|
|
||||||
bfimg.getGraphics().dispose();
|
|
||||||
bufferedImage = bfimg;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//写文字
|
|
||||||
public MyImageFilter WriteString(Point point, String str, Font font, Color color) {
|
|
||||||
Graphics2D g2d = bufferedImage.createGraphics();
|
|
||||||
FontMetrics fm = g2d.getFontMetrics(font);
|
|
||||||
int widthx = (bufferedImage.getWidth() - fm.stringWidth(str)) / 2;
|
|
||||||
bufferedImage = WriteString(str, font, color, new Point(widthx, (bufferedImage.getHeight()) / 2 + font.getSize() / 4)).bufferedImage;
|
|
||||||
g2d.dispose();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyImageFilter WriteString(String str, Font font, Color color, Point p) {
|
|
||||||
Graphics2D g2d = bufferedImage.createGraphics();
|
|
||||||
g2d.setFont(font);
|
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
||||||
GlyphVector v = font.createGlyphVector(g2d.getFontRenderContext(), str);
|
|
||||||
Shape shape = v.getOutline();
|
|
||||||
g2d.translate(p.x, p.y);
|
|
||||||
g2d.setColor(color);
|
|
||||||
g2d.fill(shape);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyImageFilter WriteString(String str, Font font, Color color, Point p, Color OutlineColor, float OutlineSize) {
|
|
||||||
Graphics2D g2d = bufferedImage.createGraphics();
|
|
||||||
g2d.setFont(font);
|
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
||||||
|
|
||||||
GlyphVector v = font.createGlyphVector(g2d.getFontRenderContext(), str);
|
|
||||||
Shape shape = v.getOutline();
|
|
||||||
g2d.translate(p.x, p.y);
|
|
||||||
g2d.setColor(color);
|
|
||||||
g2d.fill(shape);
|
|
||||||
|
|
||||||
|
|
||||||
g2d.setColor(OutlineColor);
|
|
||||||
g2d.setStroke(new BasicStroke(OutlineSize));
|
|
||||||
g2d.draw(shape);
|
|
||||||
g2d.dispose();
|
|
||||||
//g2d.drawString(str, 0,0);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//抠图
|
|
||||||
public MyImageFilter ChangeBlackAlpha(int Alpha) {
|
|
||||||
BufferedImage bfimg = new BufferedImage(bufferedImage.getWidth(null), bufferedImage.getHeight(null), BufferedImage.TYPE_4BYTE_ABGR);
|
|
||||||
bfimg.getGraphics().drawImage(bufferedImage, 0, 0, bfimg.getWidth(), bfimg.getHeight(), null);
|
|
||||||
//
|
|
||||||
for (int y = 0; y < bfimg.getHeight(); y++) {
|
|
||||||
for (int x = 0; x < bfimg.getWidth(); x++) {
|
|
||||||
Color color = new Color(bfimg.getRGB(x, y), true);
|
|
||||||
if (color.getAlpha() > Alpha) {
|
|
||||||
bfimg.setRGB(x, y, new Color(255, 255, 255, 255).getRGB());
|
|
||||||
//bfimg.setRGB(x, y, new Color(Alpha,0,0,255).getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteFile(File file) throws IOException {
|
|
||||||
ImageIO.write(bufferedImage, "png", file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteFile(String file) throws IOException {
|
|
||||||
WriteFile(new File(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
package text;
|
|
||||||
|
|
||||||
import main.mc.MCChunk;
|
|
||||||
import main.mc.MCPosInt;
|
|
||||||
import main.mc.MCRegion;
|
|
||||||
import main.nbt.CompoundTag;
|
|
||||||
import org.w3c.dom.css.RGBColor;
|
|
||||||
import text.lib.MyImageFilter;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class mapPrint {
|
|
||||||
static ArrayList<Block> blocks = new ArrayList<>();
|
|
||||||
|
|
||||||
static class Block {
|
|
||||||
String name;
|
|
||||||
Color color;
|
|
||||||
|
|
||||||
public Block(String name, Color color) {
|
|
||||||
this.name = name;
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compare(Color color2) {
|
|
||||||
return Math.abs(color2.getRed() - color.getRed()) + Math.abs(color2.getGreen() - color.getGreen()) + Math.abs(color2.getBlue() - color.getBlue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Block colorFindBlock(Color color) {
|
|
||||||
int minIndex = 0;
|
|
||||||
int min = 255 * 255 * 255;
|
|
||||||
for (int i = 0; i < blocks.size(); i++) {
|
|
||||||
int c = blocks.get(i).compare(color);
|
|
||||||
if (min > c) {
|
|
||||||
min = c;
|
|
||||||
minIndex = i;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return blocks.get(minIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
ArrayList<File> FileList = new ArrayList<>();
|
|
||||||
File[] files = new File("E:\\工程文件\\java\\MCNBT\\src\\text\\mc").listFiles();
|
|
||||||
for (File f : files) {
|
|
||||||
if (f.isFile()) {
|
|
||||||
FileList.add(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (File file : FileList) {
|
|
||||||
MyImageFilter img = new MyImageFilter(file.getPath());
|
|
||||||
img.Zoom(new Dimension(1, 1));
|
|
||||||
blocks.add(new Block(file.getName().substring(0, file.getName().length() - 4), new Color(img.bufferedImage.getRGB(0, 0))));
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MyImageFilter img = null;
|
|
||||||
try {
|
|
||||||
img = new MyImageFilter("E:\\工程文件\\java\\MCNBT\\src\\text\\白猫RGB.png");
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
//img.Zoom(new Dimension(128, 128));
|
|
||||||
System.out.println("开始生成");
|
|
||||||
try {
|
|
||||||
MCRegion mcRegion = new MCRegion(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\测试地图\\region"));
|
|
||||||
|
|
||||||
|
|
||||||
MCChunk chunk = mcRegion.getChunk(new MCPosInt(0, 0));
|
|
||||||
mcRegion.setGenerateChunk(chunk);
|
|
||||||
//mcRegion.setChunk(new MCPosInt(0, 6400-10), chunk);
|
|
||||||
//mcRegion.setBlockState(new MCPosInt(114514, 1, 114514), new CompoundTag().setTag("Name", "minecraft:diamond_block"));
|
|
||||||
//CompoundTag tag = mcRegion.getBlockEntitie(new MCPosInt(114514, 1, 130));
|
|
||||||
//tag.getListTag("Items").getCompoundTag(0).getCompoundTag("tag").getListTag("Enchantments").getCompoundTag(0).setTag("lvl", 114514);
|
|
||||||
//tag.setTag("CustomName","{\"text\":\"我焯!!!\"}");
|
|
||||||
//tag.setTag("Command","say 芜湖起飞~");
|
|
||||||
//System.out.println(tag);
|
|
||||||
//tag.getCompoundTag("Properties").setTag("facing", "down");
|
|
||||||
//mcRegion.setBlockState(new MCPosInt(1138, 1, 130),tag);
|
|
||||||
|
|
||||||
for (int x = 0; x < img.bufferedImage.getWidth(); x++) {
|
|
||||||
for (int y = 0; y < img.bufferedImage.getHeight(); y++) {
|
|
||||||
|
|
||||||
CompoundTag block;
|
|
||||||
//block = new CompoundTag().setTag("Name", "minecraft:air");
|
|
||||||
block = new CompoundTag().setTag("Name", "minecraft:" + colorFindBlock(new Color(img.bufferedImage.getRGB(x, y))).name);
|
|
||||||
mcRegion.setBlockState(new MCPosInt(x + 114514, 0, y + 114514), block);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*for (int x = 0; x < img.bufferedImage.getWidth(); x++) {
|
|
||||||
for (int y = 0; y < img.bufferedImage.getHeight(); y++) {
|
|
||||||
mcRegion.setBlockState(new MCPosInt(x, 80, y + 10240), new CompoundTag().setTag("Name", "minecraft:" + colorFindBlock(new Color(img.bufferedImage.getRGB(x, y))).name));
|
|
||||||
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
mcRegion.saveMCA();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
System.out.println("结束生成");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,198 +0,0 @@
|
|||||||
package text;
|
|
||||||
|
|
||||||
import de.javagl.obj.*;
|
|
||||||
import main.mc.*;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
public class test3d {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
MCRegion mcRegion = new MCRegion(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\OBJ\\region"), 10);
|
|
||||||
mcRegion.setGenerateChunk(mcRegion.getChunk(new MCPosInt(0, 0)));
|
|
||||||
|
|
||||||
File objFile = new File("E:\\桌面\\测试模型\\蒙德\\蒙德城1.1\\蒙德城.obj");
|
|
||||||
|
|
||||||
|
|
||||||
MCBlockColors mcBlockColors = new MCBlockColors(new File("E:\\工程文件\\java\\NBTUtils\\src\\text\\mc"));
|
|
||||||
|
|
||||||
|
|
||||||
/*//测试画板
|
|
||||||
MyImageFilter myImageFilter = new MyImageFilter(new Dimension(200, 200));*/
|
|
||||||
|
|
||||||
|
|
||||||
Obj originalObj = ObjReader.read(new FileReader(objFile));
|
|
||||||
|
|
||||||
//MCBlocksCollective blocks = new MCBlocksCollective(new MCPosInt(1024, 370, 1024));
|
|
||||||
|
|
||||||
//三角化
|
|
||||||
Obj obj = ObjUtils.convertToRenderable(originalObj);
|
|
||||||
//Obj obj = originalObj;
|
|
||||||
//读取材质文件
|
|
||||||
List<Mtl> allMtls =
|
|
||||||
MtlReader.read(new FileReader(
|
|
||||||
objFile.getParent() + "\\" + obj.getMtlFileNames().get(0).substring(2)
|
|
||||||
));
|
|
||||||
|
|
||||||
//按材质分割obj
|
|
||||||
Map<String, Obj> materialGroups =
|
|
||||||
ObjSplitting.splitByMaterialGroups(obj);
|
|
||||||
//System.out.println("getNumGroups:" + obj.getGroup(0).);
|
|
||||||
for (Map.Entry<String, Obj> entry : materialGroups.entrySet()) {
|
|
||||||
String materialName = entry.getKey();
|
|
||||||
Obj materialGroup = entry.getValue();
|
|
||||||
System.out.println("材质名:" + materialName);
|
|
||||||
Mtl material = findMtlForName(allMtls, materialName);
|
|
||||||
File materialFile = new File(objFile.getParent() + "\\" + material.getMapKd());
|
|
||||||
System.out.println("纹理图片:" + materialFile);
|
|
||||||
System.out.println("面数:" + materialGroup.getNumFaces());
|
|
||||||
|
|
||||||
BufferedImage materialImg = null;
|
|
||||||
|
|
||||||
if (materialFile.isFile()) {
|
|
||||||
//读取纹理文件
|
|
||||||
materialImg = ImageIO.read(materialFile);
|
|
||||||
} else {
|
|
||||||
System.out.println("未找到纹理文件");
|
|
||||||
}
|
|
||||||
//枚举所有面
|
|
||||||
for (int i = 0; i < materialGroup.getNumFaces(); i++) {
|
|
||||||
//System.out.println("面索引:" + i);
|
|
||||||
ObjFace face = materialGroup.getFace(i);//获取面
|
|
||||||
FloatTuple[] faceVertex = new FloatTuple[3];
|
|
||||||
FloatTuple[] faceUV = new FloatTuple[3];
|
|
||||||
|
|
||||||
//枚举所有顶点
|
|
||||||
for (int j = 0; j < 3; j++) {
|
|
||||||
faceVertex[j] = materialGroup.getVertex(face.getVertexIndex(j));//获取顶点坐标
|
|
||||||
if (materialImg != null) {
|
|
||||||
faceUV[j] = materialGroup.getTexCoord(face.getTexCoordIndex(j));//获取uv坐标
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//顶点边
|
|
||||||
List<MCPosInt> side1 = new ArrayList<>();//取边1
|
|
||||||
List<MCPosInt> side2 = new ArrayList<>();//取边2
|
|
||||||
MCPosInt.enumLinePos(f2m(faceVertex[0]), f2m(faceVertex[1]), 10f, p -> {
|
|
||||||
side1.add(p);
|
|
||||||
});
|
|
||||||
MCPosInt.enumLinePos(f2m(faceVertex[0]), f2m(faceVertex[2]), 10f, p -> {
|
|
||||||
side2.add(p);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (side1.size() == 0 || side2.size() == 0) {
|
|
||||||
side1.add(f2m(faceVertex[0]));
|
|
||||||
side2.add(f2m(faceVertex[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (int j = 0; j < side1.size(); j++) {
|
|
||||||
|
|
||||||
|
|
||||||
int finalJ = j;
|
|
||||||
BufferedImage finalMaterialImg = materialImg;
|
|
||||||
|
|
||||||
MCPosInt.enumLinePos(side1.get(j),
|
|
||||||
side2.get((int) (((float) side2.size() / side1.size() * j))),
|
|
||||||
4f,
|
|
||||||
(p, d) -> {
|
|
||||||
|
|
||||||
|
|
||||||
//myImageFilter.bufferedImage.setRGB(p.x, p.z, color.getRGB());
|
|
||||||
Color color;
|
|
||||||
if (finalMaterialImg != null) {
|
|
||||||
FloatTuple UV1 = in2Pos((faceUV[0]), (faceUV[1]), 1f / side1.size() * finalJ);
|
|
||||||
FloatTuple UV2 = in2Pos((faceUV[0]), (faceUV[2]), 1f / side1.size() * finalJ);
|
|
||||||
|
|
||||||
FloatTuple UV3 = in2Pos(UV1, UV2, d);
|
|
||||||
|
|
||||||
|
|
||||||
int UVx = Math.round(finalMaterialImg.getWidth() * UV3.getX());
|
|
||||||
int UVy = Math.round(finalMaterialImg.getHeight() * (1f - UV3.getY()));
|
|
||||||
if ((UVx < 0 || UVx >= finalMaterialImg.getWidth()) || (UVy < 0 || UVy >= finalMaterialImg.getHeight())) {
|
|
||||||
|
|
||||||
//color = Color.CYAN;
|
|
||||||
//System.out.println("纹理过界 原大小>W:" + finalMaterialImg.getWidth() + " H:" + finalMaterialImg.getHeight());
|
|
||||||
//System.out.println("UVxy> x:" + UVx + " y:" + UVy);
|
|
||||||
|
|
||||||
if (UVx < 0)
|
|
||||||
UVx = UVx + finalMaterialImg.getWidth() * (-UVx / finalMaterialImg.getWidth() + 1);
|
|
||||||
if (UVy < 0)
|
|
||||||
UVy = UVy + finalMaterialImg.getHeight() * (-UVy / finalMaterialImg.getHeight() + 1);
|
|
||||||
|
|
||||||
UVx = UVx % finalMaterialImg.getWidth();
|
|
||||||
UVy = UVy % finalMaterialImg.getHeight();
|
|
||||||
//System.out.println("w:" + finalMaterialImg.getWidth() + " h:" + finalMaterialImg.getHeight());
|
|
||||||
//System.out.println("UVx:" + UVx + " UVy:" + UVy);
|
|
||||||
|
|
||||||
|
|
||||||
color = new Color(finalMaterialImg.getRGB(
|
|
||||||
UVx,
|
|
||||||
UVy));
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
color = new Color(finalMaterialImg.getRGB(
|
|
||||||
UVx,
|
|
||||||
UVy));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
color = Color.MAGENTA;
|
|
||||||
}
|
|
||||||
|
|
||||||
MCBlockColors.BlockColor blockColor = mcBlockColors.colorFindBlock(color);
|
|
||||||
|
|
||||||
try {
|
|
||||||
//System.out.println(MCPosInt.additive(p,new MCPosInt(10240,-50,0)).toStr());
|
|
||||||
mcRegion.setBlock(MCPosInt.additive(p, new MCPosInt(10240, -59, 0)), new MCBlock("minecraft:" + blockColor.name));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//mcRegion.setBlocksCollective(new MCPosInt(10434, -60, 10434), blocks);
|
|
||||||
mcRegion.saveMCA();
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//材质名找材质
|
|
||||||
private static Mtl findMtlForName(Iterable<? extends Mtl> mtls, String name) {
|
|
||||||
for (Mtl mtl : mtls) {
|
|
||||||
if (mtl.getName().equals(name)) {
|
|
||||||
return mtl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FloatTuple in2Pos(FloatTuple p1, FloatTuple p2, float i) {
|
|
||||||
return FloatTuples.create(((p1.getX() - (p1.getX() - p2.getX()) * i)),
|
|
||||||
((p1.getY() - (p1.getY() - p2.getY()) * i)),
|
|
||||||
((p1.getZ() - (p1.getZ() - p2.getZ()) * i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static MCPosInt f2m(FloatTuple floatTuple) {
|
|
||||||
return new MCPosInt(Math.round(floatTuple.getX()), Math.round(floatTuple.getY()), Math.round(floatTuple.getZ()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,301 +0,0 @@
|
|||||||
package text;
|
|
||||||
|
|
||||||
|
|
||||||
import main.mc.*;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class text {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
BufferedImage Image = ImageIO.read(new File("E:\\工程文件\\java\\NBTUtils\\src\\text\\白猫RGB.png"));
|
|
||||||
|
|
||||||
|
|
||||||
BufferedImage bufferedImage = new BufferedImage(250, 250, BufferedImage.TYPE_4BYTE_ABGR);
|
|
||||||
for (int y = 0; y < 250; y++) {
|
|
||||||
for (int x = 0; x < 250; x++) {
|
|
||||||
bufferedImage.setRGB(x, y, MCMapColors.byte2color(MCMapColors.color2byte(new Color(Image.getRGB(x*4, y*4)))).getRGB());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImageIO.write(bufferedImage, "png", new File("E:\\工程文件\\java\\NBTUtils\\src\\text\\白猫RGB预览.png"));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*{
|
|
||||||
MCMap mcMap = new MCMap(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\地图画测试\\data\\map_0.dat"));
|
|
||||||
mcMap.setImg(new File("E:\\工程文件\\java\\MCNBT\\src\\text\\RGB.png"));
|
|
||||||
mcMap.saveFile();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
MCMap mcMap = new MCMap(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\地图画测试\\data\\map_" + (i + 1) + ".dat"));
|
|
||||||
mcMap.setImg(new File("E:\\工程文件\\java\\MCNBT\\src\\text\\IMG" + (i + 1) + ".png"));
|
|
||||||
mcMap.saveFile();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
/* {
|
|
||||||
MCMap mcMap = new MCMap(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\data\\map_17.dat"));
|
|
||||||
mcMap.save2img(new File("E:\\工程文件\\java\\MCNBT\\src\\text\\保存的地图.png"));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*try {
|
|
||||||
MCRegion mcRegion = new MCRegion(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\BadApple\\region"));
|
|
||||||
CompoundTag block = mcRegion.getBlockState(new MCPosInt(2 ,-60, -1));
|
|
||||||
System.out.println(block);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}*/
|
|
||||||
//octave=mid low high {Properties={note=0, octave=low, powered=false, instrument=harp_l}, Name=minecraft:note_block}
|
|
||||||
|
|
||||||
//System.out.println(MCPosInt.pos2subChunkIndex(new MCPosInt(100,-10,100)).toStr());
|
|
||||||
//System.out.println(MCPosInt.pos2chunk2(new MCPosInt(10000,100,100)).toStr());
|
|
||||||
|
|
||||||
|
|
||||||
//System.out.println(1024>> 5);
|
|
||||||
//System.out.println(9999999>> 5);
|
|
||||||
//System.out.println(MCPosInt.blockToChunk(-114514));
|
|
||||||
/*System.out.println(MCPosInt.chunk2relativelyChunk(new MCPosInt(0,0)).toStr());
|
|
||||||
|
|
||||||
try {
|
|
||||||
MCRegion mcRegion = new MCRegion(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\测试地图\\region"));
|
|
||||||
|
|
||||||
CompoundTag c = mcRegion.getBlockEntitie(new MCPosInt(4, -60, 0));
|
|
||||||
System.out.println(c);
|
|
||||||
|
|
||||||
mcRegion.setBlockEntitie(new MCPosInt(10, -60, -21), c);
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
//System.out.println(MCUtil.getMapBitSize(33));
|
|
||||||
//MCSubChunk mcSubChunk = new MCSubChunk(1, 4);
|
|
||||||
//mcSubChunk.set(12, 5);
|
|
||||||
|
|
||||||
//System.out.println(mcSubChunk.get(12));
|
|
||||||
//mcSubChunk.set(17, 0xf);
|
|
||||||
//System.out.println(Long.toBinaryString(mcSubChunk.getLongArray()[0]));
|
|
||||||
//System.out.println(BitsUtils.bits2fStr(BitSet.valueOf(mcSubChunk.getLongArray())));
|
|
||||||
/* long a = 55;
|
|
||||||
a = a << 10;
|
|
||||||
System.out.println(Long.toBinaryString(a));
|
|
||||||
System.out.println(Long.toBinaryString(a & 0xF));
|
|
||||||
System.out.println(a & 0xF);*/
|
|
||||||
//System.out.println(BitsUtils.bits2fStr(BitSet.valueOf(a.toLongArray())));
|
|
||||||
//System.out.println(MCUtil.getMapBitSize(16 * 16));
|
|
||||||
/*MCRegion mcRegion = new MCRegion(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\测试地图\\region"));
|
|
||||||
mcRegion.setBlockState(new MCPosInt(-30, -60, 9), new CompoundTag().setTag("Name", "minecraft:red_wool"));
|
|
||||||
mcRegion.setBlockState(new MCPosInt(-32, -60, 0), new CompoundTag().setTag("Name", "minecraft:red_wool"));
|
|
||||||
mcRegion.setBlockState(new MCPosInt(-512, -60, 0), new CompoundTag().setTag("Name", "minecraft:red_wool"));
|
|
||||||
mcRegion.setBlockState(new MCPosInt(-513, -60, 0), new CompoundTag().setTag("Name", "minecraft:red_wool"));
|
|
||||||
mcRegion.setBlockState(new MCPosInt(32, -60, 0), new CompoundTag().setTag("Name", "minecraft:red_wool"));
|
|
||||||
mcRegion.setBlockState(new MCPosInt(-511, -60, 0), new CompoundTag().setTag("Name", "minecraft:red_wool"));
|
|
||||||
mcRegion.setBlockState(new MCPosInt(-512, -60, 0), new CompoundTag().setTag("Name", "minecraft:red_wool"));
|
|
||||||
mcRegion.setBlockState(new MCPosInt(-513, -60, 0), new CompoundTag().setTag("Name", "minecraft:red_wool"));
|
|
||||||
mcRegion.upDate();*/
|
|
||||||
//MCA mca = MCUtil.readMCAFile(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界 (1)\\region\\r.19.19.mca"));
|
|
||||||
/* MCChunk chunk = mca.getChunk(new MCPosInt(17, 17));
|
|
||||||
System.out.println(chunk.getBlockState(new MCPosInt(0, 100, 0)));
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
for (int j = 0; j < 50; j++) {
|
|
||||||
count++;
|
|
||||||
for (int i = 0; i < 16; i++) {
|
|
||||||
chunk.setBlockState(new CompoundTag().setTag("Name", "minecraft:diamond_block"), new MCPosInt(i, 80 + count, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
count++;
|
|
||||||
for (int i = 0; i < 16; i++) {
|
|
||||||
chunk.setBlockState(new CompoundTag().setTag("Name", "minecraft:gold_block"), new MCPosInt(i, 80 + count, 15));
|
|
||||||
}
|
|
||||||
count++;
|
|
||||||
for (int i = 0; i < 16; i++) {
|
|
||||||
chunk.setBlockState(new CompoundTag().setTag("Name", "minecraft:glass"), new MCPosInt(15, 80 + count, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
count++;
|
|
||||||
for (int i = 0; i < 16; i++) {
|
|
||||||
chunk.setBlockState(new CompoundTag().setTag("Name", "minecraft:iron_block"), new MCPosInt(0, 80 + count, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MCUtil.writeMCAFile(mca, new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界aaa\\region\\r.19.19.mca"));*/
|
|
||||||
|
|
||||||
//MCRegion mcRegion=new MCRegion(new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\region"));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
try {
|
|
||||||
MCPosInt localPos = MCChunkUtils.chunk2local(MCChunkUtils.pos2chunk(new MCPosInt(10000, 10000)));
|
|
||||||
MCA mca = MCUtil.readMCAFile(new FileInputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\region\\r." + localPos.x + "." + localPos.z + ".mca"));
|
|
||||||
CompoundTag chunk = MCChunkUtils.findChunk(mca.chunksNBT, new MCPosInt(10000 / 16, -4, 10000 / 16));
|
|
||||||
|
|
||||||
|
|
||||||
//CompoundTag az = new CompoundTag();
|
|
||||||
//az.setCompoundTag("",new CompoundTag().setListTag("az", mca.chunksNBT));
|
|
||||||
|
|
||||||
// MCUtil.writeNBT(az, new FileOutputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\aaaa.dat"));
|
|
||||||
|
|
||||||
//System.out.println(mca.chunksNBT);
|
|
||||||
System.out.println(MCChunkUtils.subChunkFindBlockStates(MCChunkUtils.findSubChunk(chunk, -4), new MCPosInt(0, 6, 0)).getTag("Name"));
|
|
||||||
System.out.println(MCChunkUtils.subChunkFindBlockStates(MCChunkUtils.findSubChunk(chunk, -4), new MCPosInt(0, 6, 0)));
|
|
||||||
|
|
||||||
System.out.println("修改前---");
|
|
||||||
System.out.println(MCChunkUtils.chunkFindBlockEntities(chunk, new MCPosInt(10000, -59, 10000)));
|
|
||||||
CompoundTag block = MCChunkUtils.chunkFindBlockEntities(chunk, new MCPosInt(10000, -59, 10000)).getListTag("Items").getCompoundTag(0);
|
|
||||||
block.setTag("id", "minecraft:diamond");
|
|
||||||
block.setCompoundTag("tag").setCompoundTag("display").setTag("Name","{\"text\":\"ZEDO\",\"color\":\"green\"}");
|
|
||||||
System.out.println("修改后---");
|
|
||||||
System.out.println(MCChunkUtils.chunkFindBlockEntities(chunk, new MCPosInt(10000, -59, 10000)));
|
|
||||||
|
|
||||||
MCUtil.writeMCAFile(mca, new File("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\region\\r." + localPos.x + "." + localPos.z + ".mca"));
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*try {
|
|
||||||
|
|
||||||
System.out.println(MCUtil.readDATFile(new FileInputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\level.dat")));
|
|
||||||
MCUtil.writeNBT(MCUtil.readDATFile(new FileInputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\level.dat")),new FileOutputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\level.dat.dat"));
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//System.out.println(BytesUtils.bytes2longA(new byte[]{ (byte) 0x64,(byte) 0x00,(byte) 0x00 ,(byte) 0xFF,(byte) 0x00 , (byte) 0x00, (byte) 0x00,(byte) 0xAA}));
|
|
||||||
//System.out.println(BytesUtils.bytes2longA((new byte[]{ (byte) 0xAA,(byte) 0x00,(byte) 0x00 ,(byte) 0x00 ,(byte) 0xFF,(byte) 0x00, (byte) 0x00,(byte) 0x64})));
|
|
||||||
//System.out.println(BytesUtils.bytes2fStr(BytesUtils.long2bytes(-6196953082983612316l)));
|
|
||||||
//System.out.println("bit:" + BitsUtils.bits2fStr(BytesUtils.bytes2bitsA(new byte[]{(byte) 0x23,(byte) 0xa3,(byte) 0x89})));
|
|
||||||
//System.out.println("bit:" + BitsUtils.bits2fStr(BytesUtils.bytes2bitsA(BytesUtils.bytes2bytesA(new byte[]{(byte) 0x23,(byte) 0xa3,(byte) 0x89}))));
|
|
||||||
|
|
||||||
|
|
||||||
//ByteArrayOutputStream out =new ByteArrayOutputStream();
|
|
||||||
//{={fml=}}
|
|
||||||
/* CompoundTag nbt = new CompoundTag("");
|
|
||||||
|
|
||||||
CompoundTag nbt2 = new CompoundTag("复合标签");
|
|
||||||
nbt2.addTag(new Tag("short", (short) 2233));
|
|
||||||
nbt2.addTag(new Tag("int", -114514));
|
|
||||||
nbt2.addTag(new Tag("long", 114514L));
|
|
||||||
nbt2.addTag(new Tag("float", 2.33f));
|
|
||||||
nbt2.addTag(new Tag("double", 223344.5566));
|
|
||||||
nbt2.addTag(new Tag("bytes", new byte[]{0, 1, 2, -5}));
|
|
||||||
nbt2.addTag(new Tag("ints", new int[]{11, 22, 33, 44}));
|
|
||||||
nbt2.addTag(new Tag("longs", new long[]{11, 22, 33, 44}));
|
|
||||||
nbt2.addTag(new Tag("string", "字符串测试"));
|
|
||||||
|
|
||||||
|
|
||||||
ListTag listTag = new ListTag("longlist", TagType.TAG_Long);
|
|
||||||
listTag.addTag(8848L);
|
|
||||||
listTag.addTag(-6666L);
|
|
||||||
|
|
||||||
|
|
||||||
ListTag listTag2 = new ListTag("复合list", TagType.TAG_Compound);
|
|
||||||
listTag2.addTag(new CompoundTag(null).addTag(new Tag("tag1","字符串")));
|
|
||||||
listTag2.addTag(new CompoundTag(null).addTag(new Tag("tag2","好耶")));
|
|
||||||
|
|
||||||
nbt.addCompoundTag(nbt2);
|
|
||||||
nbt.addCompoundTag(new CompoundTag("套娃测试1").addCompoundTag(new CompoundTag("套娃测试2").addCompoundTag(new CompoundTag("套娃测试3"))));
|
|
||||||
nbt.addListTag(listTag);
|
|
||||||
nbt.addListTag(listTag2);
|
|
||||||
|
|
||||||
System.out.println(nbt);
|
|
||||||
try {
|
|
||||||
MCUtil.writeNBT(nbt, new FileOutputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\test.dat"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}*/
|
|
||||||
//System.out.println(BytesUtils.bytes2fStr(out.toByteArray()));
|
|
||||||
|
|
||||||
|
|
||||||
//ByteArrayInputStream in = new ByteArrayInputStream();
|
|
||||||
|
|
||||||
|
|
||||||
/* try {
|
|
||||||
inflaterOutputStream.flush();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*try {
|
|
||||||
System.out.println(BytesUtils.bytes2fStr(ZLibUtils.decompress(new FileInputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\map.zlib"))));
|
|
||||||
new FileOutputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\map.zlib.dat").write(ZLibUtils.decompress(new FileInputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\map.zlib")));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
/*int x, z;
|
|
||||||
x = 1;
|
|
||||||
z = 1;
|
|
||||||
System.out.println(4 * ((x & 31) + (z & 31) * 32));*/
|
|
||||||
/*try {
|
|
||||||
FileInputStream fileInputStream = new FileInputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\level.dat");
|
|
||||||
GZIPInputStream gzipInputStream = new GZIPInputStream(fileInputStream);
|
|
||||||
|
|
||||||
byte[] data = ((InputStream)gzipInputStream).readAllBytes();
|
|
||||||
System.out.println(data.length);
|
|
||||||
|
|
||||||
FileOutputStream fileOutputStream =new FileOutputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\level.dat.gzip");
|
|
||||||
fileOutputStream.write(data);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
/* CompoundTag compoundTag;
|
|
||||||
try {
|
|
||||||
compoundTag = MCUtil.readDATFile(new FileInputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\level.dat"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
//System.out.println(compoundTag.getNBT("a").getNBT("aa"));
|
|
||||||
System.out.println(compoundTag);
|
|
||||||
//compoundTag.getCompoundTag("").getCompoundTag("Data").addTag(new Tag("LevelName","芜湖"));
|
|
||||||
System.out.println("世界名:" + compoundTag.getCompoundTag("").getCompoundTag("Data").getTag("LevelName").getData());
|
|
||||||
System.out.println("玩家坐标:" + compoundTag.getCompoundTag("").getCompoundTag("Data").getCompoundTag("Player").getListTag("Pos"));
|
|
||||||
|
|
||||||
try {
|
|
||||||
MCUtil.writeNBT(compoundTag,new FileOutputStream("E:\\MineCraft文件\\1.18.2\\.minecraft\\saves\\新的世界\\level.dat.dat"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}*/
|
|
||||||
/*
|
|
||||||
ListTag listTag = compoundTag.getCompoundTag("").getCompoundTag("Data").getCompoundTag("Player").getListTag("Inventory");
|
|
||||||
for (int i = 0; i < listTag.size(); i++) {
|
|
||||||
System.out.println(listTag.getCompoundTag(i).getTagData("Slot"));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//System.out.println(((int[]) compoundTag.getCompoundTag("").getCompoundTag("Data").getCompoundTag("Player").getTag("UUID").getTag())[0]);
|
|
||||||
//CompoundTag compoundTag = new CompoundTag("az");
|
|
||||||
//compoundTag.addCompoundTag(new CompoundTag("ddd"));
|
|
||||||
|
|
||||||
//System.out.println();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 752 KiB |
Before Width: | Height: | Size: 20 KiB |