Rename and clean up AbstractAnimatedMapleMapObject

This commit is contained in:
P0nk
2021-09-09 22:16:30 +02:00
parent af2707120a
commit 8814a18d0c
7 changed files with 39 additions and 39 deletions

View File

@@ -21,16 +21,16 @@
*/
package server.maps;
import java.util.Arrays;
import io.netty.buffer.Unpooled;
import net.packet.*;
public abstract class AbstractAnimatedMapleMapObject extends AbstractMapleMapObject implements AnimatedMapleMapObject {
public static final int IDLE_MOVEMENT_PACKET_LENGTH = 15;
private static final Packet IDLE_MOVEMENT_PACKET = createIdleMovementPacket();
import java.util.Arrays;
private int stance;
public abstract class AbstractAnimatedMapObject extends AbstractMapleMapObject implements AnimatedMapleMapObject {
public static final int IDLE_MOVEMENT_PACKET_LENGTH = 15;
private static final Packet IDLE_MOVEMENT_PACKET = createIdleMovementPacket();
private int stance;
@Override
public int getStance() {
@@ -46,32 +46,32 @@ public abstract class AbstractAnimatedMapleMapObject extends AbstractMapleMapObj
public boolean isFacingLeft() {
return Math.abs(stance) % 2 == 1;
}
public InPacket getIdleMovement() {
final byte[] idleMovementBytes = IDLE_MOVEMENT_PACKET.getBytes();
byte[] movementData = Arrays.copyOf(idleMovementBytes, idleMovementBytes.length);
//seems wasteful to create a whole packet writer when only a few values are changed
int x = getPosition().x;
int y = getPosition().y;
movementData[2] = (byte) (x & 0xFF); //x
movementData[3] = (byte) (x >> 8 & 0xFF);
movementData[4] = (byte) (y & 0xFF); //y
movementData[5] = (byte) (y >> 8 & 0xFF);
movementData[12] = (byte) (getStance() & 0xFF);
return new ByteBufInPacket(Unpooled.wrappedBuffer(movementData));
final byte[] idleMovementBytes = IDLE_MOVEMENT_PACKET.getBytes();
byte[] movementData = Arrays.copyOf(idleMovementBytes, idleMovementBytes.length);
//seems wasteful to create a whole packet writer when only a few values are changed
int x = getPosition().x;
int y = getPosition().y;
movementData[2] = (byte) (x & 0xFF); //x
movementData[3] = (byte) (x >> 8 & 0xFF);
movementData[4] = (byte) (y & 0xFF); //y
movementData[5] = (byte) (y >> 8 & 0xFF);
movementData[12] = (byte) (getStance() & 0xFF);
return new ByteBufInPacket(Unpooled.wrappedBuffer(movementData));
}
private static Packet createIdleMovementPacket() {
OutPacket p = new ByteBufOutPacket();
p.writeByte(1); //movement command count
p.writeByte(0);
p.writeShort(-1); //x
p.writeShort(-1); //y
p.writeShort(0); //xwobble
p.writeShort(0); //ywobble
p.writeShort(0); //fh
p.writeByte(-1); //stance
p.writeShort(0); //duration
return p;
}
OutPacket p = new ByteBufOutPacket();
p.writeByte(1); //movement command count
p.writeByte(0);
p.writeShort(-1); //x
p.writeShort(-1); //y
p.writeShort(0); //xwobble
p.writeShort(0); //ywobble
p.writeShort(0); //fh
p.writeByte(-1); //stance
p.writeShort(0); //duration
return p;
}
}

View File

@@ -27,7 +27,7 @@ import tools.PacketCreator;
public class MapleDragon extends AbstractAnimatedMapleMapObject {
public class MapleDragon extends AbstractAnimatedMapObject {
private Character owner;

View File

@@ -32,7 +32,7 @@ import java.awt.*;
*
* @author Jan
*/
public class MapleSummon extends AbstractAnimatedMapleMapObject {
public class MapleSummon extends AbstractAnimatedMapObject {
private Character owner;
private byte skillLevel;
private int skill, hp;