3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-25 15:50:19 +01:00

Use getBoolean/putBoolean, and fix using the wrong field for respawn_anchor_works

Dieser Commit ist enthalten in:
kashike 2020-08-16 04:11:24 -07:00
Ursprung 1717d7f9b4
Commit 5623baf1e7

Datei anzeigen

@ -186,22 +186,22 @@ public final class DimensionData {
*/ */
public static DimensionData decodeBaseCompoundTag(CompoundBinaryTag details, public static DimensionData decodeBaseCompoundTag(CompoundBinaryTag details,
ProtocolVersion version) { ProtocolVersion version) {
boolean isNatural = details.getByte("natural") >= 1; boolean isNatural = details.getBoolean("natural");
float ambientLight = details.getFloat("ambient_light"); float ambientLight = details.getFloat("ambient_light");
boolean isShrunk = details.getByte("shrunk") >= 1; boolean isShrunk = details.getBoolean("shrunk");
boolean isUltrawarm = details.getByte("ultrawarm") >= 1; boolean isUltrawarm = details.getBoolean("ultrawarm");
boolean hasCeiling = details.getByte("has_ceiling") >= 1; boolean hasCeiling = details.getBoolean("has_ceiling");
boolean hasSkylight = details.getByte("has_skylight") >= 1; boolean hasSkylight = details.getBoolean("has_skylight");
boolean isPiglinSafe = details.getByte("piglin_safe") >= 1; boolean isPiglinSafe = details.getBoolean("piglin_safe");
boolean doBedsWork = details.getByte("bed_works") >= 1; boolean doBedsWork = details.getBoolean("bed_works");
boolean doRespawnAnchorsWork = details.getByte("respawn_anchor_works") >= 1; boolean doRespawnAnchorsWork = details.getBoolean("respawn_anchor_works");
boolean hasRaids = details.getByte("has_raids") >= 1; boolean hasRaids = details.getBoolean("has_raids");
int logicalHeight = details.getInt("logical_height"); int logicalHeight = details.getInt("logical_height");
String burningBehaviourIdentifier = details.getString("infiniburn"); String burningBehaviourIdentifier = details.getString("infiniburn");
Long fixedTime = details.keySet().contains("fixed_time") Long fixedTime = details.keySet().contains("fixed_time")
? details.getLong("fixed_time") : null; ? details.getLong("fixed_time") : null;
Boolean hasEnderdragonFight = details.keySet().contains("has_enderdragon_fight") Boolean hasEnderdragonFight = details.keySet().contains("has_enderdragon_fight")
? details.getByte("has_enderdragon_fight") >= 1 : null; ? details.getBoolean("has_enderdragon_fight") : null;
Double coordinateScale = details.keySet().contains("coordinate_scale") Double coordinateScale = details.keySet().contains("coordinate_scale")
? details.getDouble("coordinate_scale") : null; ? details.getDouble("coordinate_scale") : null;
String effects = details.keySet().contains("effects") ? details.getString("effects") String effects = details.keySet().contains("effects") ? details.getString("effects")
@ -265,23 +265,23 @@ public final class DimensionData {
*/ */
public CompoundBinaryTag serializeDimensionDetails() { public CompoundBinaryTag serializeDimensionDetails() {
CompoundBinaryTag.Builder ret = CompoundBinaryTag.builder(); CompoundBinaryTag.Builder ret = CompoundBinaryTag.builder();
ret.putByte("natural", (byte) (isNatural ? 1 : 0)); ret.putBoolean("natural", isNatural);
ret.putFloat("ambient_light", ambientLight); ret.putFloat("ambient_light", ambientLight);
ret.putByte("shrunk", (byte) (isShrunk ? 1 : 0)); ret.putBoolean("shrunk", isShrunk);
ret.putByte("ultrawarm", (byte) (isUltrawarm ? 1 : 0)); ret.putBoolean("ultrawarm", isUltrawarm);
ret.putByte("has_ceiling", (byte) (hasCeiling ? 1 : 0)); ret.putBoolean("has_ceiling", hasCeiling);
ret.putByte("has_skylight", (byte) (hasSkylight ? 1 : 0)); ret.putBoolean("has_skylight", hasSkylight);
ret.putByte("piglin_safe", (byte) (isPiglinSafe ? 1 : 0)); ret.putBoolean("piglin_safe", isPiglinSafe);
ret.putByte("bed_works", (byte) (doBedsWork ? 1 : 0)); ret.putBoolean("bed_works", doBedsWork);
ret.putByte("respawn_anchor_works", (byte) (doBedsWork ? 1 : 0)); ret.putBoolean("respawn_anchor_works", doRespawnAnchorsWork);
ret.putByte("has_raids", (byte) (hasRaids ? 1 : 0)); ret.putBoolean("has_raids", hasRaids);
ret.putInt("logical_height", logicalHeight); ret.putInt("logical_height", logicalHeight);
ret.putString("infiniburn", burningBehaviourIdentifier); ret.putString("infiniburn", burningBehaviourIdentifier);
if (fixedTime != null) { if (fixedTime != null) {
ret.putLong("fixed_time", fixedTime); ret.putLong("fixed_time", fixedTime);
} }
if (createDragonFight != null) { if (createDragonFight != null) {
ret.putByte("has_enderdragon_fight", (byte) (createDragonFight ? 1 : 0)); ret.putBoolean("has_enderdragon_fight", createDragonFight);
} }
if (coordinateScale != null) { if (coordinateScale != null) {
ret.putDouble("coordinate_scale", coordinateScale); ret.putDouble("coordinate_scale", coordinateScale);