cn.nukkit.network.protocol.StartGamePacket Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
package cn.nukkit.network.protocol;
import cn.nukkit.item.RuntimeItems;
import cn.nukkit.api.Since;
import cn.nukkit.blockstate.BlockStateRegistry;
import cn.nukkit.level.GameRules;
import cn.nukkit.utils.BinaryStream;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lombok.ToString;
import lombok.extern.log4j.Log4j2;
/**
* @since 15-10-13
*/
@Log4j2
@ToString
public class StartGamePacket extends DataPacket {
public static final byte NETWORK_ID = ProtocolInfo.START_GAME_PACKET;
public static final int GAME_PUBLISH_SETTING_NO_MULTI_PLAY = 0;
public static final int GAME_PUBLISH_SETTING_INVITE_ONLY = 1;
public static final int GAME_PUBLISH_SETTING_FRIENDS_ONLY = 2;
public static final int GAME_PUBLISH_SETTING_FRIENDS_OF_FRIENDS = 3;
public static final int GAME_PUBLISH_SETTING_PUBLIC = 4;
@Override
public byte pid() {
return NETWORK_ID;
}
public long entityUniqueId;
public long entityRuntimeId;
public int playerGamemode;
public float x;
public float y;
public float z;
public float yaw;
public float pitch;
public int seed;
public byte dimension;
public int generator = 1;
public int worldGamemode;
public int difficulty;
public int spawnX;
public int spawnY;
public int spawnZ;
public boolean hasAchievementsDisabled = true;
public int dayCycleStopTime = -1; //-1 = not stopped, any positive value = stopped at that time
public int eduEditionOffer = 0;
public boolean hasEduFeaturesEnabled = false;
public float rainLevel;
public float lightningLevel;
public boolean hasConfirmedPlatformLockedContent = false;
public boolean multiplayerGame = true;
public boolean broadcastToLAN = true;
public int xblBroadcastIntent = GAME_PUBLISH_SETTING_PUBLIC;
public int platformBroadcastIntent = GAME_PUBLISH_SETTING_PUBLIC;
public boolean commandsEnabled;
public boolean isTexturePacksRequired = false;
public GameRules gameRules;
public boolean bonusChest = false;
public boolean hasStartWithMapEnabled = false;
@Since("1.3.0.0-PN") public boolean trustingPlayers;
public int permissionLevel = 1;
public int serverChunkTickRange = 4;
public boolean hasLockedBehaviorPack = false;
public boolean hasLockedResourcePack = false;
public boolean isFromLockedWorldTemplate = false;
public boolean isUsingMsaGamertagsOnly = false;
public boolean isFromWorldTemplate = false;
public boolean isWorldTemplateOptionLocked = false;
public boolean isOnlySpawningV1Villagers = false;
public String vanillaVersion = ProtocolInfo.MINECRAFT_VERSION_NETWORK;
public String levelId = ""; //base64 string, usually the same as world folder name in vanilla
public String worldName;
public String premiumWorldTemplateId = "";
public boolean isTrial = false;
public boolean isMovementServerAuthoritative;
@Since("1.3.0.0-PN") public boolean isInventoryServerAuthoritative;
public long currentTick;
public int enchantmentSeed;
public String multiplayerCorrelationId = "";
@Override
public void decode() {
}
@Override
public void encode() {
this.reset();
this.putEntityUniqueId(this.entityUniqueId);
this.putEntityRuntimeId(this.entityRuntimeId);
this.putVarInt(this.playerGamemode);
this.putVector3f(this.x, this.y, this.z);
this.putLFloat(this.yaw);
this.putLFloat(this.pitch);
this.putVarInt(this.seed);
this.putLShort(0x00); // SpawnBiomeType - Default
this.putString("plains"); // UserDefinedBiomeName
this.putVarInt(this.dimension);
this.putVarInt(this.generator);
this.putVarInt(this.worldGamemode);
this.putVarInt(this.difficulty);
this.putBlockVector3(this.spawnX, this.spawnY, this.spawnZ);
this.putBoolean(this.hasAchievementsDisabled);
this.putVarInt(this.dayCycleStopTime);
this.putVarInt(this.eduEditionOffer);
this.putBoolean(this.hasEduFeaturesEnabled);
this.putString(""); // Education Edition Product ID
this.putLFloat(this.rainLevel);
this.putLFloat(this.lightningLevel);
this.putBoolean(this.hasConfirmedPlatformLockedContent);
this.putBoolean(this.multiplayerGame);
this.putBoolean(this.broadcastToLAN);
this.putVarInt(this.xblBroadcastIntent);
this.putVarInt(this.platformBroadcastIntent);
this.putBoolean(this.commandsEnabled);
this.putBoolean(this.isTexturePacksRequired);
this.putGameRules(this.gameRules);
this.putLInt(0); // Experiment count
this.putBoolean(false); // Were experiments previously toggled
this.putBoolean(this.bonusChest);
this.putBoolean(this.hasStartWithMapEnabled);
this.putVarInt(this.permissionLevel);
this.putLInt(this.serverChunkTickRange);
this.putBoolean(this.hasLockedBehaviorPack);
this.putBoolean(this.hasLockedResourcePack);
this.putBoolean(this.isFromLockedWorldTemplate);
this.putBoolean(this.isUsingMsaGamertagsOnly);
this.putBoolean(this.isFromWorldTemplate);
this.putBoolean(this.isWorldTemplateOptionLocked);
this.putBoolean(this.isOnlySpawningV1Villagers);
this.putString(this.vanillaVersion);
this.putLInt(16); // Limited world width
this.putLInt(16); // Limited world height
this.putBoolean(false); // Nether type
this.putBoolean(false); // Experimental Gameplay
this.putString(this.levelId);
this.putString(this.worldName);
this.putString(this.premiumWorldTemplateId);
this.putBoolean(this.isTrial);
this.putVarInt(this.isMovementServerAuthoritative ? 1 : 0); // 2 - rewind
this.putLLong(this.currentTick);
this.putVarInt(this.enchantmentSeed);
this.putUnsignedVarInt(0); // Custom blocks
this.put(RuntimeItems.ITEM_DATA_PALETTE);
this.putString(this.multiplayerCorrelationId);
this.putBoolean(this.isInventoryServerAuthoritative);
}
}