Permalink
Browse files

Merge remote-tracking branch 'origin/1.0'

  • Loading branch information...
Tee7even committed Mar 17, 2017
2 parents 9b7758a + 3894aa6 commit 225fe43d93d9db35596b4681a18608e65f4d90bb
Showing with 943 additions and 558 deletions.
  1. +4 −4 .gitignore
  2. +0 −1 api/src/main/java/com/voxelwind/api/game/entities/Entity.java
  3. +18 −16 api/src/main/java/com/voxelwind/api/game/level/block/BlockTypes.java
  4. +0 −1 api/src/main/java/com/voxelwind/api/server/Player.java
  5. +1 −1 nbt/pom.xml
  6. +2 −1 nbt/src/main/java/com/voxelwind/nbt/io/NBTReader.java
  7. +12 −4 nbt/src/main/java/com/voxelwind/nbt/io/NBTWriter.java
  8. +72 −0 nbt/src/main/java/com/voxelwind/nbt/tags/CompoundTag.java
  9. +82 −0 nbt/src/main/java/com/voxelwind/nbt/util/CompoundTagBuilder.java
  10. +44 −99 nbt/src/main/java/com/voxelwind/nbt/util/Varints.java
  11. +2 −2 nbt/src/test/java/com/voxelwind/nbt/io/NBTReaderTest.java
  12. +2 −2 server/pom.xml
  13. +2 −1 server/src/main/java/com/voxelwind/server/VoxelwindServer.java
  14. +1 −22 server/src/main/java/com/voxelwind/server/game/entities/BaseEntity.java
  15. +0 −2 server/src/main/java/com/voxelwind/server/game/entities/LivingEntity.java
  16. +0 −2 server/src/main/java/com/voxelwind/server/game/entities/misc/VoxelwindDroppedItem.java
  17. +7 −6 server/src/main/java/com/voxelwind/server/game/item/VoxelwindItemStack.java
  18. +4 −5 server/src/main/java/com/voxelwind/server/game/level/VoxelwindLevel.java
  19. +2 −2 server/src/main/java/com/voxelwind/server/game/level/block/behaviors/BehaviorUtils.java
  20. +13 −4 server/src/main/java/com/voxelwind/server/game/level/chunk/{provider/anvil → }/ChunkSection.java
  21. +147 −31 server/src/main/java/com/voxelwind/server/game/level/chunk/SectionedChunk.java
  22. +4 −5 server/src/main/java/com/voxelwind/server/game/level/chunk/SectionedChunkSnapshot.java
  23. +0 −1 server/src/main/java/com/voxelwind/server/game/level/chunk/provider/anvil/AnvilChunkProvider.java
  24. +32 −13 server/src/main/java/com/voxelwind/server/game/level/chunk/provider/anvil/AnvilConversion.java
  25. +5 −5 server/src/main/java/com/voxelwind/server/game/level/manager/LevelChunkManager.java
  26. +66 −56 server/src/main/java/com/voxelwind/server/game/level/manager/LevelEntityManager.java
  27. +20 −0 server/src/main/java/com/voxelwind/server/game/level/util/NibbleArray.java
  28. +7 −3 server/src/main/java/com/voxelwind/server/game/serializer/FlowerpotSerializer.java
  29. +61 −55 server/src/main/java/com/voxelwind/server/network/PacketRegistry.java
  30. +46 −45 server/src/main/java/com/voxelwind/server/network/mcpe/McpeUtil.java
  31. +3 −5 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeAddEntity.java
  32. +1 −1 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeAddItemEntity.java
  33. +1 −1 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeAddPlayer.java
  34. +2 −2 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeAdventureSettings.java
  35. +2 −10 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeBatch.java
  36. +2 −3 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeBlockEntityData.java
  37. +3 −3 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeCommandStep.java
  38. +2 −2 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeContainerOpen.java
  39. +2 −2 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeContainerSetContents.java
  40. +0 −2 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeFullChunkData.java
  41. +10 −8 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeLogin.java
  42. +2 −2 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeMovePlayer.java
  43. +1 −1 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpePlayerList.java
  44. +5 −4 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeResourcePackClientResponse.java
  45. +1 −1 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeServerHandshake.java
  46. +1 −1 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeStartGame.java
  47. +2 −2 server/src/main/java/com/voxelwind/server/network/mcpe/packets/McpeUpdateBlock.java
  48. +5 −1 server/src/main/java/com/voxelwind/server/network/mcpe/util/VersionUtil.java
  49. +8 −9 server/src/main/java/com/voxelwind/server/network/mcpe/util/metadata/MetadataDictionary.java
  50. +2 −0 server/src/main/java/com/voxelwind/server/network/raknet/RakNetSession.java
  51. +19 −9 server/src/main/java/com/voxelwind/server/network/raknet/datagrams/EncapsulatedRakNetPacket.java
  52. +11 −3 server/src/main/java/com/voxelwind/server/network/raknet/datagrams/RakNetDatagram.java
  53. +11 −7 server/src/main/java/com/voxelwind/server/network/raknet/handler/RakNetDatagramHandler.java
  54. +4 −5 server/src/main/java/com/voxelwind/server/network/raknet/packets/BaseAckPacket.java
  55. +4 −1 server/src/main/java/com/voxelwind/server/network/raknet/util/SplitPacketHelper.java
  56. +2 −4 server/src/main/java/com/voxelwind/server/network/rcon/RconDecoder.java
  57. +2 −5 server/src/main/java/com/voxelwind/server/network/rcon/RconEncoder.java
  58. +9 −4 server/src/main/java/com/voxelwind/server/network/session/InitialNetworkPacketHandler.java
  59. +30 −14 server/src/main/java/com/voxelwind/server/network/session/McpeSession.java
  60. +10 −2 server/src/main/java/com/voxelwind/server/network/session/PlayerSession.java
  61. +0 −4 server/src/main/java/com/voxelwind/server/network/session/auth/ClientData.java
  62. +30 −0 server/src/main/java/com/voxelwind/server/network/util/LittleEndianByteBufInputStream.java
  63. +30 −0 server/src/main/java/com/voxelwind/server/network/util/LittleEndianByteBufOutputStream.java
  64. +10 −0 server/src/test/java/com/voxelwind/server/game/level/util/NibbleArrayTest.java
  65. +4 −2 server/src/test/java/com/voxelwind/server/network/mcpe/McpeUtilTest.java
  66. +28 −0 server/src/test/java/com/voxelwind/server/network/util/LittleEndianByteBufInputStreamTest.java
  67. +28 −0 server/src/test/java/com/voxelwind/server/network/util/LittleEndianByteBufOutputStreamTest.java
  68. +0 −49 server/voxelwind-server.iml
View
@@ -50,10 +50,10 @@ fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
*.iml
modules.xml
.idea/misc.xml
*.ipr
### Maven ###
@@ -13,7 +13,6 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;
import java.util.Optional;
import java.util.Set;

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -6,7 +6,6 @@
import com.voxelwind.api.game.inventories.PlayerInventory;
import com.voxelwind.api.server.command.CommandExecutorSource;
import com.voxelwind.api.server.event.block.iface.BlockReplacer;
import com.voxelwind.api.server.player.GameMode;
import com.voxelwind.api.server.player.PlayerMessageDisplayType;
import com.voxelwind.api.server.player.PopupMessage;
import com.voxelwind.api.server.player.TranslatedMessage;
View
@@ -36,7 +36,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>4.0.41.Final</version>
<version>4.1.6.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -59,7 +59,7 @@ public NBTReader(DataInput input, NBTEncoding encoding) {
switch (type) {
case END:
if (depth == 0) {
throw new IllegalArgumentException("Found TAG_End but not in a compound or list.");
throw new IllegalArgumentException("Found a TAG_End in root tag!");
}
return EndTag.INSTANCE;
case BYTE:
@@ -122,6 +122,7 @@ public NBTReader(DataInput input, NBTEncoding encoding) {
@Override
public void close() throws IOException {
if (closed) return;
closed = true;
if (input instanceof Closeable) {
((Closeable) input).close();
@@ -10,6 +10,7 @@
import java.util.Objects;
public class NBTWriter implements Closeable {
private static final int MAXIMUM_DEPTH = 16;
private final DataOutput output;
private final NBTEncoding encoding;
private boolean closed = false;
@@ -24,14 +25,20 @@ public NBTWriter(DataOutput output, NBTEncoding encoding) {
}
public void write(Tag<?> tag) throws IOException {
if (closed) {
throw new IllegalStateException("closed");
}
Objects.requireNonNull(tag, "tag");
if (!(tag instanceof CompoundTag)) {
throw new IllegalArgumentException("Trying to write a non-compound tag!");
}
serialize(tag, false);
serialize(tag, false, 0);
}
private void serialize(Tag<?> tag, boolean skipHeader) throws IOException {
private void serialize(Tag<?> tag, boolean skipHeader, int depth) throws IOException {
if (depth >= MAXIMUM_DEPTH) {
throw new IllegalArgumentException("Reached depth limit");
}
TagType type = TagType.fromClass(tag.getClass());
if (type == null) {
throw new IllegalArgumentException("Tag " + tag + " is not valid.");
@@ -96,13 +103,13 @@ private void serialize(Tag<?> tag, boolean skipHeader) throws IOException {
output.writeInt(listt.getValue().size());
}
for (Tag<?> tag1 : listt.getValue()) {
serialize(tag1, true);
serialize(tag1, true, depth+1);
}
break;
case COMPOUND:
CompoundTag compoundTag = (CompoundTag) tag;
for (Tag<?> tag1 : compoundTag.getValue().values()) {
serialize(tag1, false);
serialize(tag1, false, depth+1);
}
output.writeByte(0);
break;
@@ -133,6 +140,7 @@ private void writeString(String name) throws IOException {
@Override
public void close() throws IOException {
if (closed) return;
closed = true;
if (output instanceof Closeable) {
((Closeable) output).close();
@@ -1,16 +1,80 @@
package com.voxelwind.nbt.tags;
import com.voxelwind.nbt.util.CompoundTagBuilder;
import java.util.*;
public class CompoundTag implements Tag<Map<String, Tag<?>>> {
private final String name;
private final Map<String, Tag<?>> value;
public CompoundTag(String name) {
this.name = name;
this.value = Collections.unmodifiableMap(new HashMap<>());
}
public CompoundTag(String name, Map<String, Tag<?>> value) {
this.name = name;
this.value = Collections.unmodifiableMap(new HashMap<>(value));
}
public void remove(String name) {
if (value.containsKey(name)) {
value.remove(name);
}
}
public CompoundTag tag(Tag<?> tag) {
value.put(tag.getName(), tag);
return this;
}
public CompoundTag tagByte(String name, byte value) {
return tag(new ByteTag(name, value));
}
public CompoundTag tagByteArray(String name, byte[] value) {
return tag(new ByteArrayTag(name, value));
}
public CompoundTag tagDouble(String name, double value) {
return tag(new DoubleTag(name, value));
}
public CompoundTag tagFloat(String name, float value) {
return tag(new FloatTag(name, value));
}
public CompoundTag tagIntArray(String name, int[] value) {
return tag(new IntArrayTag(name, value));
}
public CompoundTag tagInt(String name, int value) {
return tag(new IntTag(name, value));
}
public CompoundTag tagLong(String name, long value) {
return tag(new LongTag(name, value));
}
public CompoundTag tagShort(String name, short value) {
return tag(new ShortTag(name, value));
}
public CompoundTag tagString(String name, String value) {
return tag(new StringTag(name, value));
}
public CompoundTag tagCompoundTag(String name, CompoundTag value) {
this.value.put(name, value);
return this;
}
public CompoundTag tagListTag(String name, ListTag value) {
this.value.put(name, value);
return this;
}
@Override
public String getName() {
return name;
@@ -61,4 +125,12 @@ public static CompoundTag createFromList(String name, List<Tag<?>> list) {
}
return new CompoundTag(name, map);
}
public CompoundTagBuilder toBuilder() {
return CompoundTagBuilder.from(this);
}
public Tag<?> get(String key) {
return value.get(key);
}
}
@@ -0,0 +1,82 @@
package com.voxelwind.nbt.util;
import com.voxelwind.nbt.tags.*;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.util.HashMap;
import java.util.Map;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CompoundTagBuilder {
private final Map<String, Tag<?>> tagMap = new HashMap<>();
public static CompoundTagBuilder builder() {
return new CompoundTagBuilder();
}
public static CompoundTagBuilder from(CompoundTag tag) {
CompoundTagBuilder builder = new CompoundTagBuilder();
builder.tagMap.putAll(tag.getValue());
return builder;
}
public CompoundTagBuilder tag(Tag<?> tag) {
tagMap.put(tag.getName(), tag);
return this;
}
public CompoundTagBuilder tagByte (String name, byte value) {
return tag(new ByteTag(name, value));
}
public CompoundTagBuilder tagByteArray (String name, byte [] value) {
return tag(new ByteArrayTag(name, value));
}
public CompoundTagBuilder tagDouble (String name, double value) {
return tag(new DoubleTag(name, value));
}
public CompoundTagBuilder tagFloat (String name, float value) {
return tag(new FloatTag(name, value));
}
public CompoundTagBuilder tagIntArray (String name, int[] value) {
return tag(new IntArrayTag(name, value));
}
public CompoundTagBuilder tagInt (String name, int value) {
return tag(new IntTag(name, value));
}
public CompoundTagBuilder tagLong (String name, long value) {
return tag(new LongTag(name, value));
}
public CompoundTagBuilder tagShort (String name, short value) {
return tag(new ShortTag(name, value));
}
public CompoundTagBuilder tagString (String name, String value) {
return tag(new StringTag(name, value));
}
public CompoundTagBuilder tagCompoundTag (String name, CompoundTag value) {
tagMap.put(name, value);
return this;
}
public CompoundTagBuilder tagListTag(String name, ListTag value) {
tagMap.put(name, value);
return this;
}
public CompoundTag buildRootTag() {
return new CompoundTag("", tagMap);
}
public CompoundTag build(String tagName) {
return new CompoundTag(tagName, tagMap);
}
}
Oops, something went wrong.

0 comments on commit 225fe43

Please sign in to comment.