mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 08:27:29 -04:00
entities wip (6): head rotation
This commit is contained in:
parent
74d34a8078
commit
91e4f28a5f
@ -19,4 +19,8 @@ public interface Mob extends Entity {
|
|||||||
void setHealth(float health);
|
void setHealth(float health);
|
||||||
|
|
||||||
int getMaxHealth();
|
int getMaxHealth();
|
||||||
|
|
||||||
|
int getHeadYaw();
|
||||||
|
|
||||||
|
void setHeadYaw(int headYaw);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ public class OtherPlayer implements Mob {
|
|||||||
Location location;
|
Location location;
|
||||||
int yaw;
|
int yaw;
|
||||||
int pitch;
|
int pitch;
|
||||||
|
int headYaw;
|
||||||
short currentItem;
|
short currentItem;
|
||||||
EntityMetaData metaData;
|
EntityMetaData metaData;
|
||||||
float health;
|
float health;
|
||||||
@ -184,4 +185,14 @@ public class OtherPlayer implements Mob {
|
|||||||
GLIDING,
|
GLIDING,
|
||||||
SWIMMING
|
SWIMMING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeadYaw() {
|
||||||
|
return headYaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeadYaw(int headYaw) {
|
||||||
|
this.headYaw = headYaw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ public class Zombie implements Mob {
|
|||||||
Velocity velocity;
|
Velocity velocity;
|
||||||
int yaw;
|
int yaw;
|
||||||
int pitch;
|
int pitch;
|
||||||
|
int headYaw;
|
||||||
EntityMetaData metaData;
|
EntityMetaData metaData;
|
||||||
float health;
|
float health;
|
||||||
|
|
||||||
@ -124,4 +125,14 @@ public class Zombie implements Mob {
|
|||||||
public int getMaxHealth() {
|
public int getMaxHealth() {
|
||||||
return 40;
|
return 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeadYaw() {
|
||||||
|
return headYaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeadYaw(int headYaw) {
|
||||||
|
this.headYaw = headYaw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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.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 PacketEntityHeadRotation implements ClientboundPacket {
|
||||||
|
int entityId;
|
||||||
|
int headYaw;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(InPacketBuffer buffer, ProtocolVersion v) {
|
||||||
|
switch (v) {
|
||||||
|
case VERSION_1_7_10:
|
||||||
|
this.entityId = buffer.readInteger();
|
||||||
|
this.headYaw = buffer.readByte(); //ToDo
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void log() {
|
||||||
|
Log.protocol(String.format("Entity %d moved head %s", entityId, headYaw));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEntityId() {
|
||||||
|
return entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getHeadYaw() {
|
||||||
|
return headYaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(PacketHandler h) {
|
||||||
|
h.handle(this);
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.protocol.protocol;
|
|||||||
import de.bixilon.minosoft.Minosoft;
|
import de.bixilon.minosoft.Minosoft;
|
||||||
import de.bixilon.minosoft.config.GameConfiguration;
|
import de.bixilon.minosoft.config.GameConfiguration;
|
||||||
import de.bixilon.minosoft.game.datatypes.GameMode;
|
import de.bixilon.minosoft.game.datatypes.GameMode;
|
||||||
|
import de.bixilon.minosoft.game.datatypes.entities.Mob;
|
||||||
import de.bixilon.minosoft.logging.Log;
|
import de.bixilon.minosoft.logging.Log;
|
||||||
import de.bixilon.minosoft.protocol.network.Connection;
|
import de.bixilon.minosoft.protocol.network.Connection;
|
||||||
import de.bixilon.minosoft.protocol.packets.clientbound.login.PacketEncryptionKeyRequest;
|
import de.bixilon.minosoft.protocol.packets.clientbound.login.PacketEncryptionKeyRequest;
|
||||||
@ -182,4 +183,8 @@ public class PacketHandler {
|
|||||||
connection.getPlayer().getWorld().getEntity(pkg.getEntityId()).setYaw(pkg.getYaw());
|
connection.getPlayer().getWorld().getEntity(pkg.getEntityId()).setYaw(pkg.getYaw());
|
||||||
connection.getPlayer().getWorld().getEntity(pkg.getEntityId()).setPitch(pkg.getPitch());
|
connection.getPlayer().getWorld().getEntity(pkg.getEntityId()).setPitch(pkg.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handle(PacketEntityHeadRotation pkg) {
|
||||||
|
((Mob) connection.getPlayer().getWorld().getEntity(pkg.getEntityId())).setHeadYaw(pkg.getHeadYaw());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,5 +70,6 @@ public interface Protocol {
|
|||||||
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_VELOCITY, PacketEntityVelocity.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_VELOCITY, PacketEntityVelocity.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_SPAWN_PLAYER, PacketSpawnPlayer.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_SPAWN_PLAYER, PacketSpawnPlayer.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_TELEPORT, PacketEntityTeleport.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_TELEPORT, PacketEntityTeleport.class);
|
||||||
|
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_HEAD_LOOK, PacketEntityHeadRotation.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user