mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 17:07:55 -04:00
wip spawning, PacketRespawn
This commit is contained in:
parent
b398fecf45
commit
7469e56648
@ -16,9 +16,9 @@ package de.bixilon.minosoft.objects;
|
|||||||
import de.bixilon.minosoft.game.datatypes.GameMode;
|
import de.bixilon.minosoft.game.datatypes.GameMode;
|
||||||
import de.bixilon.minosoft.game.datatypes.Slot;
|
import de.bixilon.minosoft.game.datatypes.Slot;
|
||||||
import de.bixilon.minosoft.game.datatypes.Slots;
|
import de.bixilon.minosoft.game.datatypes.Slots;
|
||||||
import de.bixilon.minosoft.game.datatypes.world.World;
|
|
||||||
import de.bixilon.minosoft.game.datatypes.entities.Location;
|
import de.bixilon.minosoft.game.datatypes.entities.Location;
|
||||||
import de.bixilon.minosoft.game.datatypes.entities.meta.HumanMetaData;
|
import de.bixilon.minosoft.game.datatypes.entities.meta.HumanMetaData;
|
||||||
|
import de.bixilon.minosoft.game.datatypes.world.World;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -37,6 +37,7 @@ public class Player {
|
|||||||
short totalExperience;
|
short totalExperience;
|
||||||
HumanMetaData metaData;
|
HumanMetaData metaData;
|
||||||
HashMap<Slots.Inventory, Slot> inventory = new HashMap<>();
|
HashMap<Slots.Inventory, Slot> inventory = new HashMap<>();
|
||||||
|
boolean spawnConfirmed = false;
|
||||||
|
|
||||||
public Player(Account acc) {
|
public Player(Account acc) {
|
||||||
this.acc = acc;
|
this.acc = acc;
|
||||||
@ -160,4 +161,12 @@ public class Player {
|
|||||||
public void setSlot(Slots.Inventory slot, Slot data) {
|
public void setSlot(Slots.Inventory slot, Slot data) {
|
||||||
inventory.put(slot, data);
|
inventory.put(slot, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSpawnConfirmed() {
|
||||||
|
return spawnConfirmed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpawnConfirmed(boolean spawnConfirmed) {
|
||||||
|
this.spawnConfirmed = spawnConfirmed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Codename Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.packets.clientbound.play;
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.game.datatypes.Difficulty;
|
||||||
|
import de.bixilon.minosoft.game.datatypes.Dimension;
|
||||||
|
import de.bixilon.minosoft.game.datatypes.GameMode;
|
||||||
|
import de.bixilon.minosoft.game.datatypes.LevelType;
|
||||||
|
import de.bixilon.minosoft.logging.Log;
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||||
|
|
||||||
|
public class PacketRespawn implements ClientboundPacket {
|
||||||
|
Dimension dimension;
|
||||||
|
Difficulty difficulty;
|
||||||
|
GameMode gameMode;
|
||||||
|
LevelType levelType;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(InPacketBuffer buffer, ProtocolVersion v) {
|
||||||
|
switch (v) {
|
||||||
|
case VERSION_1_7_10:
|
||||||
|
dimension = Dimension.byId(buffer.readInteger());
|
||||||
|
difficulty = Difficulty.byId(buffer.readByte());
|
||||||
|
gameMode = GameMode.byId(buffer.readByte());
|
||||||
|
levelType = LevelType.byType(buffer.readString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void log() {
|
||||||
|
Log.protocol(String.format("Respawn packet received (dimension=%s, difficulty=%s, gamemode=%s, levelType=%s)", dimension.name(), difficulty.name(), gameMode.name(), levelType.name()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension getDimension() {
|
||||||
|
return dimension;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Difficulty getDifficulty() {
|
||||||
|
return difficulty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameMode getGameMode() {
|
||||||
|
return gameMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LevelType getLevelType() {
|
||||||
|
return levelType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(PacketHandler h) {
|
||||||
|
h.handle(this);
|
||||||
|
}
|
||||||
|
}
|
@ -218,4 +218,10 @@ public class PacketHandler {
|
|||||||
public void handle(PacketMultiBlockChange pkg) {
|
public void handle(PacketMultiBlockChange pkg) {
|
||||||
connection.getPlayer().getWorld().getChunk(pkg.getLocation()).setBlocks(pkg.getBlocks());
|
connection.getPlayer().getWorld().getChunk(pkg.getLocation()).setBlocks(pkg.getBlocks());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handle(PacketRespawn pkg) {
|
||||||
|
connection.getPlayer().getWorld().setDimension(pkg.getDimension());
|
||||||
|
connection.getPlayer().setSpawnConfirmed(false);
|
||||||
|
connection.getPlayer().setGameMode(pkg.getGameMode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,5 +76,6 @@ public interface Protocol {
|
|||||||
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_EQUIPMENT, PacketEntityEquipment.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_EQUIPMENT, PacketEntityEquipment.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_BLOCK_CHANGE, PacketBlockChange.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_BLOCK_CHANGE, PacketBlockChange.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_MULTIBLOCK_CHANGE, PacketMultiBlockChange.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_MULTIBLOCK_CHANGE, PacketMultiBlockChange.class);
|
||||||
|
packetClassMapping.put(Packets.Clientbound.PLAY_RESPAWN, PacketRespawn.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user