13
0
geforkt von Mirrors/Velocity

Changes 1.16-pre3

Dieser Commit ist enthalten in:
Five (Xer) 2020-06-10 21:00:18 +02:00
Ursprung 4e5f708bed
Commit 101a6a58dd
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F306B10E6330E7
3 geänderte Dateien mit 101 neuen und 49 gelöschten Zeilen

Datei anzeigen

@ -35,7 +35,7 @@ public enum ProtocolVersion {
MINECRAFT_1_15(573, "1.15"), MINECRAFT_1_15(573, "1.15"),
MINECRAFT_1_15_1(575, "1.15.1"), MINECRAFT_1_15_1(575, "1.15.1"),
MINECRAFT_1_15_2(578, "1.15.2"), MINECRAFT_1_15_2(578, "1.15.2"),
MINECRAFT_1_16(722, "1.16"); MINECRAFT_1_16(725, "1.16");
private final int protocol; private final int protocol;
private final String name; private final String name;

Datei anzeigen

@ -12,8 +12,14 @@ public final class DimensionData {
private final boolean isUltrawarm; private final boolean isUltrawarm;
private final boolean hasCeiling; private final boolean hasCeiling;
private final boolean hasSkylight; private final boolean hasSkylight;
private final boolean isPiglinSafe;
private final boolean doBedsWork;
private final boolean doRespawnAnchorsWork;
private final boolean hasRaids;
private final int logicalHeight;
private final String burningBehaviourIdentifier;
private final @Nullable Long fixedTime; private final @Nullable Long fixedTime;
private final @Nullable Boolean hasEnderdragonFight; private final @Nullable Boolean createDragonFight;
/** /**
* Initializes a new {@link DimensionData} instance. * Initializes a new {@link DimensionData} instance.
@ -24,17 +30,32 @@ public final class DimensionData {
* @param isUltrawarm internal dimension warmth flag * @param isUltrawarm internal dimension warmth flag
* @param hasCeiling indicates if the dimension has a ceiling layer * @param hasCeiling indicates if the dimension has a ceiling layer
* @param hasSkylight indicates if the dimension should display the sun * @param hasSkylight indicates if the dimension should display the sun
* @param isPiglinSafe indicates if piglins should naturally zombify in this dimension
* @param doBedsWork indicates if players should be able to sleep in beds in this dimension
* @param doRespawnAnchorsWork indicates if player respawn points can be used in this dimension
* @param hasRaids indicates if raids can be spawned in the dimension
* @param logicalHeight the natural max height for the given dimension
* @param burningBehaviourIdentifier the identifier for how burning blocks work in the dimension
* @param fixedTime optional. If set to any game daytime value will deactivate time cycle * @param fixedTime optional. If set to any game daytime value will deactivate time cycle
* @param hasEnderdragonFight optional. Internal flag used in the end dimension * @param createDragonFight optional. Internal flag used in the end dimension
*/ */
public DimensionData(String registryIdentifier, boolean isNatural, public DimensionData(String registryIdentifier, boolean isNatural,
float ambientLight, boolean isShrunk, boolean isUltrawarm, float ambientLight, boolean isShrunk, boolean isUltrawarm,
boolean hasCeiling, boolean hasSkylight, boolean hasCeiling, boolean hasSkylight,
@Nullable Long fixedTime, @Nullable Boolean hasEnderdragonFight) { boolean isPiglinSafe, boolean doBedsWork,
boolean doRespawnAnchorsWork, boolean hasRaids,
int logicalHeight, String burningBehaviourIdentifier,
@Nullable Long fixedTime, @Nullable Boolean createDragonFight) {
Preconditions.checkNotNull( Preconditions.checkNotNull(
registryIdentifier, "registryIdentifier cannot be null"); registryIdentifier, "registryIdentifier cannot be null");
Preconditions.checkArgument(registryIdentifier.length() > 0 && !registryIdentifier.isBlank(), Preconditions.checkArgument(registryIdentifier.length() > 0 && !registryIdentifier.isBlank(),
"registryIdentifier cannot be empty"); "registryIdentifier cannot be empty");
Preconditions.checkArgument(logicalHeight >= 0, "localHeight must be >= 0");
Preconditions.checkNotNull(
burningBehaviourIdentifier, "burningBehaviourIdentifier cannot be null");
Preconditions.checkArgument(burningBehaviourIdentifier.length() > 0
&& !burningBehaviourIdentifier.isBlank(),
"burningBehaviourIdentifier cannot be empty");
this.registryIdentifier = registryIdentifier; this.registryIdentifier = registryIdentifier;
this.isNatural = isNatural; this.isNatural = isNatural;
this.ambientLight = ambientLight; this.ambientLight = ambientLight;
@ -42,8 +63,14 @@ public final class DimensionData {
this.isUltrawarm = isUltrawarm; this.isUltrawarm = isUltrawarm;
this.hasCeiling = hasCeiling; this.hasCeiling = hasCeiling;
this.hasSkylight = hasSkylight; this.hasSkylight = hasSkylight;
this.isPiglinSafe = isPiglinSafe;
this.doBedsWork = doBedsWork;
this.doRespawnAnchorsWork = doRespawnAnchorsWork;
this.hasRaids = hasRaids;
this.logicalHeight = logicalHeight;
this.burningBehaviourIdentifier = burningBehaviourIdentifier;
this.fixedTime = fixedTime; this.fixedTime = fixedTime;
this.hasEnderdragonFight = hasEnderdragonFight; this.createDragonFight = createDragonFight;
} }
public String getRegistryIdentifier() { public String getRegistryIdentifier() {
@ -66,20 +93,44 @@ public final class DimensionData {
return isUltrawarm; return isUltrawarm;
} }
public boolean isHasCeiling() { public boolean hasCeiling() {
return hasCeiling; return hasCeiling;
} }
public boolean isHasSkylight() { public boolean hasSkylight() {
return hasSkylight; return hasSkylight;
} }
public boolean isPiglinSafe() {
return isPiglinSafe;
}
public boolean doBedsWork() {
return doBedsWork;
}
public boolean doRespawnAnchorsWork() {
return doRespawnAnchorsWork;
}
public boolean hasRaids() {
return hasRaids;
}
public int getLogicalHeight() {
return logicalHeight;
}
public String getBurningBehaviourIdentifier() {
return burningBehaviourIdentifier;
}
public @Nullable Long getFixedTime() { public @Nullable Long getFixedTime() {
return fixedTime; return fixedTime;
} }
public @Nullable Boolean getHasEnderdragonFight() { public @Nullable Boolean getCreateDragonFight() {
return hasEnderdragonFight; return createDragonFight;
} }
/** /**
@ -89,21 +140,27 @@ public final class DimensionData {
*/ */
public static DimensionData decodeCompoundTag(CompoundTag toRead) { public static DimensionData decodeCompoundTag(CompoundTag toRead) {
Preconditions.checkNotNull(toRead, "CompoundTag cannot be null"); Preconditions.checkNotNull(toRead, "CompoundTag cannot be null");
String registryIdentifier = toRead.getString("key"); String registryIdentifier = toRead.getString("name");
CompoundTag values = toRead.getCompound("element"); boolean isNatural = toRead.getBoolean("natural");
boolean isNatural = values.getBoolean("natural"); float ambientLight = toRead.getFloat("ambient_light");
float ambientLight = values.getFloat("ambient_light"); boolean isShrunk = toRead.getBoolean("shrunk");
boolean isShrunk = values.getBoolean("shrunk"); boolean isUltrawarm = toRead.getBoolean("ultrawarm");
boolean isUltrawarm = values.getBoolean("ultrawarm"); boolean hasCeiling = toRead.getBoolean("has_ceiling");
boolean hasCeiling = values.getBoolean("has_ceiling"); boolean hasSkylight = toRead.getBoolean("has_skylight");
boolean hasSkylight = values.getBoolean("has_skylight"); boolean isPiglinSafe = toRead.getBoolean("piglin_safe");
Long fixedTime = values.contains("fixed_time") boolean doBedsWork = toRead.getBoolean("bed_works");
? values.getLong("fixed_time") : null; boolean doRespawnAnchorsWork = toRead.getBoolean("respawn_anchor_works");
Boolean hasEnderdragonFight = values.contains("has_enderdragon_fight") boolean hasRaids = toRead.getBoolean("has_raids");
? values.getBoolean("has_enderdragon_fight") : null; int logicalHeight = toRead.getInt("logical_height");
String burningBehaviourIdentifier = toRead.getString("infiniburn");
Long fixedTime = toRead.contains("fixed_time")
? toRead.getLong("fixed_time") : null;
Boolean hasEnderdragonFight = toRead.contains("has_enderdragon_fight")
? toRead.getBoolean("has_enderdragon_fight") : null;
return new DimensionData( return new DimensionData(
registryIdentifier, isNatural, ambientLight, isShrunk, registryIdentifier, isNatural, ambientLight, isShrunk,
isUltrawarm, hasCeiling, hasSkylight, fixedTime, hasEnderdragonFight); isUltrawarm, hasCeiling, hasSkylight, isPiglinSafe, doBedsWork, doRespawnAnchorsWork,
hasRaids, logicalHeight, burningBehaviourIdentifier, fixedTime, hasEnderdragonFight);
} }
/** /**
@ -112,21 +169,25 @@ public final class DimensionData {
*/ */
public CompoundTag encodeAsCompundTag() { public CompoundTag encodeAsCompundTag() {
CompoundTag ret = new CompoundTag(); CompoundTag ret = new CompoundTag();
ret.putString("key", registryIdentifier); ret.putString("name", registryIdentifier);
CompoundTag values = new CompoundTag(); ret.putBoolean("natural", isNatural);
values.putBoolean("natural", isNatural); ret.putFloat("ambient_light", ambientLight);
values.putFloat("ambient_light", ambientLight); ret.putBoolean("shrunk", isShrunk);
values.putBoolean("shrunk", isShrunk); ret.putBoolean("ultrawarm", isUltrawarm);
values.putBoolean("ultrawarm", isUltrawarm); ret.putBoolean("has_ceiling", hasCeiling);
values.putBoolean("has_ceiling", hasCeiling); ret.putBoolean("has_skylight", hasSkylight);
values.putBoolean("has_skylight", hasSkylight); ret.putBoolean("piglin_safe", isPiglinSafe);
ret.putBoolean("bed_works", doBedsWork);
ret.putBoolean("respawn_anchor_works", doRespawnAnchorsWork);
ret.putBoolean("has_raids", hasRaids);
ret.putInt("logical_height", logicalHeight);
ret.putString("infiniburn", burningBehaviourIdentifier);
if (fixedTime != null) { if (fixedTime != null) {
values.putLong("fixed_time", fixedTime); ret.putLong("fixed_time", fixedTime);
} }
if (hasEnderdragonFight != null) { if (createDragonFight != null) {
values.putBoolean("has_enderdragon_fight", hasEnderdragonFight); ret.putBoolean("has_enderdragon_fight", createDragonFight);
} }
ret.put("element", values);
return ret; return ret;
} }
} }

Datei anzeigen

@ -21,6 +21,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import net.kyori.nbt.CompoundTag; import net.kyori.nbt.CompoundTag;
import net.kyori.nbt.TagIO;
import net.kyori.nbt.TagType; import net.kyori.nbt.TagType;
public enum ProtocolUtils { public enum ProtocolUtils {
@ -203,17 +204,10 @@ public enum ProtocolUtils {
} }
buf.readerIndex(indexBefore); buf.readerIndex(indexBefore);
try { try {
DataInput input = new ByteBufInputStream(buf); return TagIO.readDataInput(new ByteBufInputStream(buf));
byte type = input.readByte(); } catch (IOException thrown) {
if (type != TagType.COMPOUND.id()) { throw new DecoderException(
throw new DecoderException("NBTTag is not a CompoundTag"); "Unable to parse NBT CompoundTag, full error: " + thrown.getMessage());
}
input.readUTF(); // Head-padding
CompoundTag compoundTag = new CompoundTag();
compoundTag.read(input, 0);
return compoundTag;
} catch (IOException e) {
throw new DecoderException("Unable to decode NBT CompoundTag at " + indexBefore);
} }
} }
@ -228,10 +222,7 @@ public enum ProtocolUtils {
return; return;
} }
try { try {
DataOutput output = new ByteBufOutputStream(buf); TagIO.writeDataOutput(compoundTag, new ByteBufOutputStream(buf));
output.writeByte(10); // Type 10 - CompoundTag
output.writeUTF(""); // Head-padding
compoundTag.write(output);
} catch (IOException e) { } catch (IOException e) {
throw new EncoderException("Unable to encode NBT CompoundTag"); throw new EncoderException("Unable to encode NBT CompoundTag");
} }