This repository has been archived by the owner on Dec 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
109 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/test/java/com/lb_stuff/mcmodify/test/TestingUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.lb_stuff.mcmodify.test; | ||
|
||
import java.io.File; | ||
import java.net.URISyntaxException; | ||
|
||
public final class TestingUtils | ||
{ | ||
private TestingUtils() | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public static File getInputFile(String name) | ||
{ | ||
try | ||
{ | ||
return new File(TestingUtils.class.getResource("/"+name+".in").toURI()); | ||
} | ||
catch(URISyntaxException e) | ||
{ | ||
return null; | ||
} | ||
} | ||
public static File getOutputFile(String name) | ||
{ | ||
return new File(name+".out"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/java/com/lb_stuff/mcmodify/test/minecraft/MapTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.lb_stuff.mcmodify.test.minecraft; | ||
|
||
import com.lb_stuff.mcmodify.minecraft.CompressionScheme; | ||
import com.lb_stuff.mcmodify.minecraft.Map; | ||
import com.lb_stuff.mcmodify.nbt.Tag; | ||
import com.lb_stuff.mcmodify.test.TestingUtils; | ||
|
||
import javax.imageio.ImageIO; | ||
import org.junit.Test; | ||
|
||
import java.awt.Color; | ||
import java.awt.Graphics2D; | ||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
|
||
public class MapTest | ||
{ | ||
@Test | ||
public void printLastMapId() throws Throwable | ||
{ | ||
Tag.Compound idcounts; | ||
try(FileInputStream fis = new FileInputStream(TestingUtils.getInputFile("idcounts.dat"))) | ||
{ | ||
idcounts = (Tag.Compound)Tag.deserialize(CompressionScheme.None.getInputStream(fis)); | ||
} | ||
System.out.println("Last created map number: "+((Tag.Short)idcounts.find(Tag.Type.SHORT, "map")).v); | ||
} | ||
@Test | ||
public void editMapImage() throws Throwable | ||
{ | ||
final Map map; | ||
try(FileInputStream fis = new FileInputStream(TestingUtils.getInputFile("map.dat"))) | ||
{ | ||
map = new Map((Tag.Compound)Tag.deserialize(CompressionScheme.GZip.getInputStream(fis))); | ||
} | ||
|
||
BufferedImage mapimage = map.Image(); | ||
ImageIO.write(mapimage, "png", TestingUtils.getOutputFile("map.png")); | ||
|
||
Graphics2D g = mapimage.createGraphics(); | ||
g.setColor(Color.red); | ||
g.drawString("My Minecraft Map", 16, 16); | ||
|
||
try(FileOutputStream fos = new FileOutputStream(TestingUtils.getOutputFile("map.dat"))) | ||
{ | ||
map.ToNBT("").serialize(CompressionScheme.GZip.getOutputStream(fos)); | ||
} | ||
} | ||
} |
14 changes: 9 additions & 5 deletions
14
...modify/test/ModifyEveryChunkInRegion.java → ...f/mcmodify/test/minecraft/RegionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
...stuff/mcmodify/test/ManualTimeAdjust.java → .../lb_stuff/mcmodify/test/nbt/TagTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters