This repository has been archived by the owner on Jun 26, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 33
Add Region file reading support #13
Closed
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
109a674
Allow tags be mutated
sainttx 14d50f2
Merge branch 'develop' of github.com:sainttx/nbt into develop
sainttx 1bfc629
Improved stream compression
piegamesde 3601525
Removed any internal usage of the now deprecated methods
piegamesde f118c1a
Added RegionFile class
piegamesde 6c05f19
Made it Java 1.7 compatible
piegamesde 7c0aafd
Fix typo
piegamesde f0438cd
Support the long array tag
jamierocks 40c4f23
Added some tests
piegamesde 0dde724
Chunk data extractor
piegamesde 6314abb
Merge branch 'RegionFile' into develop
piegamesde dbe4ea2
Allow to write region files
piegamesde 10e0ffe
Fixes and improvements
piegamesde 713b339
Merge branch 'develop' into RegionFile
piegamesde 18cf9f4
Allow to mutate LongArrayTag
piegamesde 5a9b4e9
API changes
piegamesde b871a74
API changes (again)
piegamesde bbee1ee
Fixed RegionFile tests
piegamesde ef87596
Cleanup SimpleRegionFileReader
piegamesde a2ede34
Optimized NBT streams a bit
piegamesde 45b6231
Update to Java 8
piegamesde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 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 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 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 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 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 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 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 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 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 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 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,101 @@ | ||
/* | ||
* This file is part of Flow NBT, licensed under the MIT License (MIT). | ||
* | ||
* Copyright (c) 2011 Flow Powered <https://flowpowered.com/> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package com.flowpowered.nbt; | ||
|
||
import java.util.Arrays; | ||
|
||
public class LongArrayTag extends Tag<long[]> { | ||
/** | ||
* The value. | ||
*/ | ||
private long[] value; | ||
|
||
/** | ||
* Creates the tag. | ||
* | ||
* @param name The name. | ||
* @param value The value. | ||
*/ | ||
public LongArrayTag(String name, long[] value) { | ||
super(TagType.TAG_LONG_ARRAY, name); | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public long[] getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public void setValue(long[] value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder hex = new StringBuilder(); | ||
for (long s : value) { | ||
String hexDigits = Long.toHexString(s).toUpperCase(); | ||
if (hexDigits.length() == 1) { | ||
hex.append("0"); | ||
} | ||
hex.append(hexDigits).append(" "); | ||
} | ||
|
||
String name = getName(); | ||
String append = ""; | ||
if (name != null && !name.equals("")) { | ||
append = "(\"" + this.getName() + "\")"; | ||
} | ||
return "TAG_Long_Array" + append + ": " + hex.toString(); | ||
} | ||
|
||
@Override | ||
public LongArrayTag clone() { | ||
long[] clonedArray = cloneArray(value); | ||
|
||
return new LongArrayTag(getName(), clonedArray); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (!(other instanceof LongArrayTag)) { | ||
return false; | ||
} | ||
|
||
LongArrayTag tag = (LongArrayTag) other; | ||
return Arrays.equals(value, tag.value) && getName().equals(tag.getName()); | ||
} | ||
|
||
private long[] cloneArray(long[] longArray) { | ||
if (longArray == null) { | ||
return null; | ||
} else { | ||
int length = longArray.length; | ||
byte[] newArray = new byte[length]; | ||
System.arraycopy(longArray, 0, newArray, 0, length); | ||
return longArray; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you make every Tag mutable!? D': cries
I don't care what @kashike says, this is one of my favorite NBT libraries.
Immutable Tags are one reason for that.
If everyone really wants this.... cries some more
Maybe it should be in its own PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you ever tried to change the position of an entity in chunk with the NBT data being immutable?
IIRC this was, but I merged it onto my dev branch and I later build the API changes on top of it; sorry.