Bump development to 1.17, Added a few more light emitting blocks, Improved PlayerChatEvent formatting

This commit is contained in:
LOOHP 2021-06-13 00:56:41 +08:00
parent c6ac7b3593
commit edbc668fa2
19 changed files with 100755 additions and 67995 deletions

View File

@ -5,7 +5,7 @@
<groupId>com.loohp</groupId> <groupId>com.loohp</groupId>
<artifactId>Limbo</artifactId> <artifactId>Limbo</artifactId>
<name>Limbo</name> <name>Limbo</name>
<version>0.4.5-ALPHA</version> <version>0.5.0-ALPHA</version>
<description>Standalone Limbo Minecraft Server.</description> <description>Standalone Limbo Minecraft Server.</description>
<url>https://github.com/LOOHP/Limbo</url> <url>https://github.com/LOOHP/Limbo</url>
@ -87,7 +87,7 @@
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
<finalName>${project.artifactId}-${project.version}-1.16.5</finalName> <finalName>${project.artifactId}-${project.version}-1.17</finalName>
</build> </build>
<profiles> <profiles>

View File

@ -108,8 +108,8 @@ public class Limbo {
//=========================== //===========================
public final String serverImplementationVersion = "1.16.5"; public final String serverImplementationVersion = "1.17";
public final int serverImplmentationProtocol = 754; public final int serverImplmentationProtocol = 755;
public final String limboImplementationVersion; public final String limboImplementationVersion;
private AtomicBoolean isRunning; private AtomicBoolean isRunning;

View File

@ -11,25 +11,25 @@ import com.loohp.limbo.world.World;
public class ArmorStand extends LivingEntity { public class ArmorStand extends LivingEntity {
@WatchableField(MetadataIndex = 14, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x01) @WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x01)
protected boolean small = false; protected boolean small = false;
@WatchableField(MetadataIndex = 14, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x04) @WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x04)
protected boolean arms = false; protected boolean arms = false;
@WatchableField(MetadataIndex = 14, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x08) @WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x08)
protected boolean noBasePlate = false; protected boolean noBasePlate = false;
@WatchableField(MetadataIndex = 14, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x10) @WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x10)
protected boolean marker = false; protected boolean marker = false;
@WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.ROTATION)
protected Rotation3f headRotation = new Rotation3f(0.0, 0.0, 0.0);
@WatchableField(MetadataIndex = 16, WatchableObjectType = WatchableObjectType.ROTATION) @WatchableField(MetadataIndex = 16, WatchableObjectType = WatchableObjectType.ROTATION)
protected Rotation3f bodyRotation = new Rotation3f(0.0, 0.0, 0.0); protected Rotation3f headRotation = new Rotation3f(0.0, 0.0, 0.0);
@WatchableField(MetadataIndex = 17, WatchableObjectType = WatchableObjectType.ROTATION) @WatchableField(MetadataIndex = 17, WatchableObjectType = WatchableObjectType.ROTATION)
protected Rotation3f leftArmRotation = new Rotation3f(-10.0, 0.0, -10.0); protected Rotation3f bodyRotation = new Rotation3f(0.0, 0.0, 0.0);
@WatchableField(MetadataIndex = 18, WatchableObjectType = WatchableObjectType.ROTATION) @WatchableField(MetadataIndex = 18, WatchableObjectType = WatchableObjectType.ROTATION)
protected Rotation3f rightArmRotation = new Rotation3f(-15.0, 0.0, 10.0); protected Rotation3f leftArmRotation = new Rotation3f(-10.0, 0.0, -10.0);
@WatchableField(MetadataIndex = 19, WatchableObjectType = WatchableObjectType.ROTATION) @WatchableField(MetadataIndex = 19, WatchableObjectType = WatchableObjectType.ROTATION)
protected Rotation3f leftLegRotation = new Rotation3f(-1.0, 0.0, -1.0); protected Rotation3f rightArmRotation = new Rotation3f(-15.0, 0.0, 10.0);
@WatchableField(MetadataIndex = 20, WatchableObjectType = WatchableObjectType.ROTATION) @WatchableField(MetadataIndex = 20, WatchableObjectType = WatchableObjectType.ROTATION)
protected Rotation3f leftLegRotation = new Rotation3f(-1.0, 0.0, -1.0);
@WatchableField(MetadataIndex = 21, WatchableObjectType = WatchableObjectType.ROTATION)
protected Rotation3f rightLegRotation = new Rotation3f(1.0, 0.0, 1.0); protected Rotation3f rightLegRotation = new Rotation3f(1.0, 0.0, 1.0);
public ArmorStand(int entityId, UUID uuid, World world, double x, double y, double z, float yaw, float pitch) { public ArmorStand(int entityId, UUID uuid, World world, double x, double y, double z, float yaw, float pitch) {

View File

@ -41,6 +41,8 @@ public abstract class Entity {
protected boolean noGravity = false; protected boolean noGravity = false;
@WatchableField(MetadataIndex = 6, WatchableObjectType = WatchableObjectType.POSE) @WatchableField(MetadataIndex = 6, WatchableObjectType = WatchableObjectType.POSE)
protected Pose pose = Pose.STANDING; protected Pose pose = Pose.STANDING;
@WatchableField(MetadataIndex = 7, WatchableObjectType = WatchableObjectType.VARINT)
protected int frozenTicks = 0;
protected final EntityType type; protected final EntityType type;

View File

@ -12,23 +12,23 @@ import com.loohp.limbo.world.World;
public abstract class LivingEntity extends Entity { public abstract class LivingEntity extends Entity {
@WatchableField(MetadataIndex = 7, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x01) @WatchableField(MetadataIndex = 8, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x01)
protected boolean handActive = false; protected boolean handActive = false;
@WatchableField(MetadataIndex = 7, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x02) @WatchableField(MetadataIndex = 8, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x02)
protected boolean activeHand = false; //false = main hand, true = off hand protected boolean activeHand = false; //false = main hand, true = off hand
@WatchableField(MetadataIndex = 7, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x04) @WatchableField(MetadataIndex = 8, WatchableObjectType = WatchableObjectType.BYTE, IsBitmask = true, Bitmask = 0x04)
protected boolean inRiptideSpinAttack = false; protected boolean inRiptideSpinAttack = false;
@WatchableField(MetadataIndex = 8, WatchableObjectType = WatchableObjectType.FLOAT) @WatchableField(MetadataIndex = 9, WatchableObjectType = WatchableObjectType.FLOAT)
protected float health = 1.0F; protected float health = 1.0F;
@WatchableField(MetadataIndex = 9, WatchableObjectType = WatchableObjectType.VARINT) @WatchableField(MetadataIndex = 10, WatchableObjectType = WatchableObjectType.VARINT)
protected int potionEffectColor = 0; protected int potionEffectColor = 0;
@WatchableField(MetadataIndex = 10, WatchableObjectType = WatchableObjectType.BOOLEAN) @WatchableField(MetadataIndex = 11, WatchableObjectType = WatchableObjectType.BOOLEAN)
protected boolean potionEffectAmbient = false; protected boolean potionEffectAmbient = false;
@WatchableField(MetadataIndex = 11, WatchableObjectType = WatchableObjectType.VARINT)
protected int arrowsInEntity = 0;
@WatchableField(MetadataIndex = 12, WatchableObjectType = WatchableObjectType.VARINT) @WatchableField(MetadataIndex = 12, WatchableObjectType = WatchableObjectType.VARINT)
protected int arrowsInEntity = 0;
@WatchableField(MetadataIndex = 13, WatchableObjectType = WatchableObjectType.VARINT)
protected int absorption = 0; protected int absorption = 0;
@WatchableField(MetadataIndex = 13, WatchableObjectType = WatchableObjectType.POSITION, IsOptional = true) @WatchableField(MetadataIndex = 14, WatchableObjectType = WatchableObjectType.POSITION, IsOptional = true)
protected BlockPosition sleepingLocation = null; protected BlockPosition sleepingLocation = null;
public LivingEntity(EntityType type, int entityId, UUID uuid, World world, double x, double y, double z, float yaw, float pitch) { public LivingEntity(EntityType type, int entityId, UUID uuid, World world, double x, double y, double z, float yaw, float pitch) {

View File

@ -5,23 +5,23 @@ import com.loohp.limbo.player.Player;
public class PlayerChatEvent extends PlayerEvent implements Cancellable { public class PlayerChatEvent extends PlayerEvent implements Cancellable {
private String prefix; private String format;
private String message; private String message;
private boolean cancelled; private boolean cancelled;
public PlayerChatEvent(Player player, String prefix, String message, boolean cancelled) { public PlayerChatEvent(Player player, String format, String message, boolean cancelled) {
super(player); super(player);
this.prefix = prefix; this.format = format;
this.message = message; this.message = message;
this.cancelled = cancelled; this.cancelled = cancelled;
} }
public String getPrefix() { public String getFormat() {
return prefix; return format;
} }
public void setPrefix(String prefix) { public void setFormat(String format) {
this.prefix = prefix; this.format = format;
} }
public String getMessage() { public String getMessage() {

View File

@ -35,17 +35,17 @@ public class Player extends LivingEntity implements CommandSender {
protected DataWatcher watcher; protected DataWatcher watcher;
protected byte selectedSlot; protected byte selectedSlot;
@WatchableField(MetadataIndex = 14, WatchableObjectType = WatchableObjectType.FLOAT) @WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.FLOAT)
protected float additionalHearts = 0.0F; protected float additionalHearts = 0.0F;
@WatchableField(MetadataIndex = 15, WatchableObjectType = WatchableObjectType.VARINT) @WatchableField(MetadataIndex = 16, WatchableObjectType = WatchableObjectType.VARINT)
protected int score = 0; protected int score = 0;
@WatchableField(MetadataIndex = 16, WatchableObjectType = WatchableObjectType.BYTE)
protected byte skinLayers = 0;
@WatchableField(MetadataIndex = 17, WatchableObjectType = WatchableObjectType.BYTE) @WatchableField(MetadataIndex = 17, WatchableObjectType = WatchableObjectType.BYTE)
protected byte skinLayers = 0;
@WatchableField(MetadataIndex = 18, WatchableObjectType = WatchableObjectType.BYTE)
protected byte mainHand = 1; protected byte mainHand = 1;
//@WatchableField(MetadataIndex = 18, WatchableObjectType = WatchableObjectType.NBT)
//protected Entity leftShoulder = null;
//@WatchableField(MetadataIndex = 19, WatchableObjectType = WatchableObjectType.NBT) //@WatchableField(MetadataIndex = 19, WatchableObjectType = WatchableObjectType.NBT)
//protected Entity leftShoulder = null;
//@WatchableField(MetadataIndex = 20, WatchableObjectType = WatchableObjectType.NBT)
//protected Entity rightShoulder = null; //protected Entity rightShoulder = null;
public Player(ClientConnection clientConnection, String username, UUID uuid, int entityId, Location location, PlayerInteractManager playerInteractManager) throws IllegalArgumentException, IllegalAccessException { public Player(ClientConnection clientConnection, String username, UUID uuid, int entityId, Location location, PlayerInteractManager playerInteractManager) throws IllegalArgumentException, IllegalAccessException {
@ -182,7 +182,7 @@ public class Player extends LivingEntity implements CommandSender {
PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(location.getWorld(), Limbo.getInstance().getDimensionRegistry().getCodec(), 0, gamemode, false, false, true); PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(location.getWorld(), Limbo.getInstance().getDimensionRegistry().getCodec(), 0, gamemode, false, false, true);
clientConnection.sendPacket(respawn); clientConnection.sendPacket(respawn);
} }
PacketPlayOutPositionAndLook positionLook = new PacketPlayOutPositionAndLook(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch(), 1); PacketPlayOutPositionAndLook positionLook = new PacketPlayOutPositionAndLook(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch(), 1, false);
clientConnection.sendPacket(positionLook); clientConnection.sendPacket(positionLook);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -247,10 +247,10 @@ public class Player extends LivingEntity implements CommandSender {
} }
public void chat(String message) { public void chat(String message) {
String prefix = "<" + username + "> "; String format = "<%name%> %message%";
PlayerChatEvent event = (PlayerChatEvent) Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, prefix, message, false)); PlayerChatEvent event = (PlayerChatEvent) Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, format, message, false));
if (!event.isCancelled()) { if (!event.isCancelled()) {
String chat = event.getPrefix() + event.getMessage(); String chat = event.getFormat().replace("%name%", username).replace("%message%", event.getMessage());
Limbo.getInstance().getConsole().sendMessage(chat); Limbo.getInstance().getConsole().sendMessage(chat);
for (Player each : Limbo.getInstance().getPlayers()) { for (Player each : Limbo.getInstance().getPlayers()) {
each.sendMessage(chat, uuid); each.sendMessage(chat, uuid);

View File

@ -77,8 +77,10 @@ public class PlayerInteractManager {
ids.add(entity.getEntityId()); ids.add(entity.getEntityId());
} }
} }
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(ids.stream().mapToInt(each -> each).toArray()); for (int id : ids) {
player.clientConnection.sendPacket(packet); PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(id);
player.clientConnection.sendPacket(packet);
}
entities = entitiesInRange; entities = entitiesInRange;

View File

@ -311,8 +311,6 @@ public class ClientConnection extends Thread {
sendPacket(join); sendPacket(join);
Limbo.getInstance().getUnsafe().setPlayerGameModeSilently(player, properties.getDefaultGamemode()); Limbo.getInstance().getUnsafe().setPlayerGameModeSilently(player, properties.getDefaultGamemode());
player.playerInteractManager.update();
SkinResponse skinresponce = isBungeecord && bungeeSkin != null ? bungeeSkin : MojangAPIUtils.getSkinFromMojangServer(player.getName()); SkinResponse skinresponce = isBungeecord && bungeeSkin != null ? bungeeSkin : MojangAPIUtils.getSkinFromMojangServer(player.getName());
PlayerSkinProperty skin = skinresponce != null ? new PlayerSkinProperty(skinresponce.getSkin(), skinresponce.getSignature()) : null; PlayerSkinProperty skin = skinresponce != null ? new PlayerSkinProperty(skinresponce.getSkin(), skinresponce.getSignature()) : null;
PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PlayerInfoAction.ADD_PLAYER, player.getUniqueId(), new PlayerInfoData.PlayerInfoDataAddPlayer(player.getName(), Optional.ofNullable(skin), properties.getDefaultGamemode(), 0, false, Optional.empty())); PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PlayerInfoAction.ADD_PLAYER, player.getUniqueId(), new PlayerInfoData.PlayerInfoDataAddPlayer(player.getName(), Optional.ofNullable(skin), properties.getDefaultGamemode(), 0, false, Optional.empty()));
@ -336,10 +334,12 @@ public class ClientConnection extends Thread {
sendPacket(declare); sendPacket(declare);
} }
PacketPlayOutSpawnPosition spawnPos = new PacketPlayOutSpawnPosition(BlockPosition.from(worldSpawn)); player.playerInteractManager.update();
PacketPlayOutSpawnPosition spawnPos = new PacketPlayOutSpawnPosition(BlockPosition.from(worldSpawn), worldSpawn.getPitch());
sendPacket(spawnPos); sendPacket(spawnPos);
PacketPlayOutPositionAndLook positionLook = new PacketPlayOutPositionAndLook(worldSpawn.getX(), worldSpawn.getY(), worldSpawn.getZ(), worldSpawn.getYaw(), worldSpawn.getPitch(), 1); PacketPlayOutPositionAndLook positionLook = new PacketPlayOutPositionAndLook(worldSpawn.getX(), worldSpawn.getY(), worldSpawn.getZ(), worldSpawn.getYaw(), worldSpawn.getPitch(), 1, false);
Limbo.getInstance().getUnsafe().setPlayerLocationSilently(player, new Location(world, worldSpawn.getX(), worldSpawn.getY(), worldSpawn.getZ(), worldSpawn.getYaw(), worldSpawn.getPitch())); Limbo.getInstance().getUnsafe().setPlayerLocationSilently(player, new Location(world, worldSpawn.getX(), worldSpawn.getY(), worldSpawn.getZ(), worldSpawn.getYaw(), worldSpawn.getPitch()));
sendPacket(positionLook); sendPacket(positionLook);
@ -359,14 +359,14 @@ public class ClientConnection extends Thread {
Location originalTo = event.getTo().clone(); Location originalTo = event.getTo().clone();
if (event.isCancelled()) { if (event.isCancelled()) {
Location returnTo = event.getFrom(); Location returnTo = event.getFrom();
PacketPlayOutPositionAndLook cancel = new PacketPlayOutPositionAndLook(returnTo.getX(), returnTo.getY(), returnTo.getZ(), returnTo.getYaw(), returnTo.getPitch(), 1); PacketPlayOutPositionAndLook cancel = new PacketPlayOutPositionAndLook(returnTo.getX(), returnTo.getY(), returnTo.getZ(), returnTo.getYaw(), returnTo.getPitch(), 1, false);
sendPacket(cancel); sendPacket(cancel);
} else { } else {
Location to = event.getTo(); Location to = event.getTo();
Limbo.getInstance().getUnsafe().setPlayerLocationSilently(player, to); Limbo.getInstance().getUnsafe().setPlayerLocationSilently(player, to);
// If an event handler used setTo, let's make sure we tell the player about it. // If an event handler used setTo, let's make sure we tell the player about it.
if (!originalTo.equals(to)) { if (!originalTo.equals(to)) {
PacketPlayOutPositionAndLook pos = new PacketPlayOutPositionAndLook(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch(), 1); PacketPlayOutPositionAndLook pos = new PacketPlayOutPositionAndLook(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch(), 1, false);
sendPacket(pos); sendPacket(pos);
} }
PacketPlayOutUpdateViewPosition response = new PacketPlayOutUpdateViewPosition((int) player.getLocation().getX() >> 4, (int) player.getLocation().getZ() >> 4); PacketPlayOutUpdateViewPosition response = new PacketPlayOutUpdateViewPosition((int) player.getLocation().getX() >> 4, (int) player.getLocation().getZ() >> 4);

View File

@ -8,14 +8,14 @@ import com.loohp.limbo.utils.DataTypeIO;
public class PacketPlayOutEntityDestroy extends PacketOut { public class PacketPlayOutEntityDestroy extends PacketOut {
private int[] entityIds; private int entityId;
public PacketPlayOutEntityDestroy(int... entityIds) { public PacketPlayOutEntityDestroy(int entityId) {
this.entityIds = entityIds; this.entityId = entityId;
} }
public int[] getEntityIds() { public int getEntityId() {
return entityIds; return entityId;
} }
@Override @Override
@ -24,10 +24,7 @@ public class PacketPlayOutEntityDestroy extends PacketOut {
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(Packet.getPlayOut().get(getClass()));
DataTypeIO.writeVarInt(output, entityIds.length); DataTypeIO.writeVarInt(output, entityId);
for (int id : entityIds) {
DataTypeIO.writeVarInt(output, id);
}
return buffer.toByteArray(); return buffer.toByteArray();
} }

View File

@ -3,6 +3,7 @@ package com.loohp.limbo.server.packets;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.BitSet;
import java.util.List; import java.util.List;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
@ -12,8 +13,10 @@ public class PacketPlayOutLightUpdate extends PacketOut {
private int chunkX; private int chunkX;
private int chunkZ; private int chunkZ;
private boolean trustEdges; private boolean trustEdges;
private int skyLightBitMask; private long[] skyLightBitMasks;
private int blockLightBitMask; private long[] blockLightBitMasks;
private long[] skyLightBitMasksEmpty;
private long[] blockLightBitMasksEmpty;
private List<Byte[]> skylightArrays; private List<Byte[]> skylightArrays;
private List<Byte[]> blocklightArrays; private List<Byte[]> blocklightArrays;
@ -24,21 +27,23 @@ public class PacketPlayOutLightUpdate extends PacketOut {
this.skylightArrays = skylightArrays; this.skylightArrays = skylightArrays;
this.blocklightArrays = blocklightArrays; this.blocklightArrays = blocklightArrays;
skyLightBitMask = 0; BitSet skyLightBitSet = new BitSet();
BitSet skyLightBitSetInverse = new BitSet();
for (int i = Math.min(17, skylightArrays.size() - 1); i >= 0; i--) { for (int i = Math.min(17, skylightArrays.size() - 1); i >= 0; i--) {
skyLightBitMask = skyLightBitMask >> 1; skyLightBitSet.set(i, skylightArrays.get(i) != null);
if (skylightArrays.get(i) != null) { skyLightBitSetInverse.set(i, skylightArrays.get(i) == null);
skyLightBitMask |= 131072;
}
} }
skyLightBitMasks = skyLightBitSet.toLongArray();
skyLightBitMasksEmpty = skyLightBitSetInverse.toLongArray();
blockLightBitMask = 0; BitSet blockLightBitSet = new BitSet();
BitSet blockLightBitSetInverse = new BitSet();
for (int i = Math.min(17, blocklightArrays.size() - 1); i >= 0; i--) { for (int i = Math.min(17, blocklightArrays.size() - 1); i >= 0; i--) {
blockLightBitMask = blockLightBitMask >> 1; blockLightBitSet.set(i, blocklightArrays.get(i) != null);
if (blocklightArrays.get(i) != null) { blockLightBitSetInverse.set(i, blocklightArrays.get(i) == null);
blockLightBitMask |= 131072;
}
} }
blockLightBitMasks = blockLightBitSet.toLongArray();
blockLightBitMasksEmpty = blockLightBitSetInverse.toLongArray();
} }
public int getChunkX() { public int getChunkX() {
@ -53,12 +58,12 @@ public class PacketPlayOutLightUpdate extends PacketOut {
return trustEdges; return trustEdges;
} }
public int getSkyLightBitMask() { public long[] getSkyLightBitMasks() {
return skyLightBitMask; return skyLightBitMasks;
} }
public int getBlockLightBitMask() { public long[] getBlockLightBitMasks() {
return blockLightBitMask; return blockLightBitMasks;
} }
public List<Byte[]> getSkylightArrays() { public List<Byte[]> getSkylightArrays() {
@ -78,11 +83,24 @@ public class PacketPlayOutLightUpdate extends PacketOut {
DataTypeIO.writeVarInt(output, chunkX); DataTypeIO.writeVarInt(output, chunkX);
DataTypeIO.writeVarInt(output, chunkZ); DataTypeIO.writeVarInt(output, chunkZ);
output.writeBoolean(trustEdges); output.writeBoolean(trustEdges);
DataTypeIO.writeVarInt(output, skyLightBitMask); DataTypeIO.writeVarInt(output, skyLightBitMasks.length);
DataTypeIO.writeVarInt(output, blockLightBitMask); for (long l : skyLightBitMasks) {
DataTypeIO.writeVarInt(output, ~skyLightBitMask & 262143); output.writeLong(l);
DataTypeIO.writeVarInt(output, ~blockLightBitMask & 262143); }
DataTypeIO.writeVarInt(output, blockLightBitMasks.length);
for (long l : blockLightBitMasks) {
output.writeLong(l);
}
DataTypeIO.writeVarInt(output, skyLightBitMasksEmpty.length);
for (long l : skyLightBitMasksEmpty) {
output.writeLong(l);
}
DataTypeIO.writeVarInt(output, blockLightBitMasksEmpty.length);
for (long l : blockLightBitMasksEmpty) {
output.writeLong(l);
}
DataTypeIO.writeVarInt(output, skylightArrays.stream().mapToInt(each -> each == null ? 0 : 1).sum());
for (int i = skylightArrays.size() - 1; i >= 0; i--) { for (int i = skylightArrays.size() - 1; i >= 0; i--) {
Byte[] array = skylightArrays.get(i); Byte[] array = skylightArrays.get(i);
if (array != null) { if (array != null) {
@ -94,6 +112,7 @@ public class PacketPlayOutLightUpdate extends PacketOut {
} }
} }
DataTypeIO.writeVarInt(output, blocklightArrays.stream().mapToInt(each -> each == null ? 0 : 1).sum());
for (int i = blocklightArrays.size() - 1; i >= 0; i--) { for (int i = blocklightArrays.size() - 1; i >= 0; i--) {
Byte[] array = blocklightArrays.get(i); Byte[] array = blocklightArrays.get(i);
if (array != null) { if (array != null) {

View File

@ -31,10 +31,7 @@ public class PacketPlayOutLogin extends PacketOut {
private boolean isDebug; private boolean isDebug;
private boolean isFlat; private boolean isFlat;
public PacketPlayOutLogin(int entityId, boolean isHardcore, GameMode gamemode, public PacketPlayOutLogin(int entityId, boolean isHardcore, GameMode gamemode, String[] worldsNames, CompoundTag dimensionCodec, World world, long hashedSeed, byte maxPlayers, int viewDistance, boolean reducedDebugInfo, boolean enableRespawnScreen, boolean isDebug, boolean isFlat) {
String[] worldsNames, CompoundTag dimensionCodec, World world, long hashedSeed,
byte maxPlayers, int viewDistance, boolean reducedDebugInfo, boolean enableRespawnScreen, boolean isDebug,
boolean isFlat) {
this.entityId = entityId; this.entityId = entityId;
this.isHardcore = isHardcore; this.isHardcore = isHardcore;
this.gamemode = gamemode; this.gamemode = gamemode;
@ -130,7 +127,7 @@ public class PacketPlayOutLogin extends PacketOut {
break; break;
} }
} }
DataTypeIO.writeCompoundTag(output, tag != null ? tag : list.get(0)); DataTypeIO.writeCompoundTag(output, tag != null ? tag : list.get(0).getCompoundTag("element"));
DataTypeIO.writeString(output, worldName, StandardCharsets.UTF_8); DataTypeIO.writeString(output, worldName, StandardCharsets.UTF_8);
output.writeLong(hashedSeed); output.writeLong(hashedSeed);
DataTypeIO.writeVarInt(output, maxPlayers); DataTypeIO.writeVarInt(output, maxPlayers);

View File

@ -63,15 +63,16 @@ public class PacketPlayOutMapChunk extends PacketOut {
output.writeInt(chunkX); output.writeInt(chunkX);
output.writeInt(chunkZ); output.writeInt(chunkZ);
output.writeBoolean(true); BitSet chunkPresent = new BitSet();
int bitmask = 0;
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
Section section = chunk.getSection(i); Section section = chunk.getSection(i);
if (section != null) { chunkPresent.set(i, section != null);
bitmask = bitmask | (int) Math.pow(2, i); }
} long[] bitmasks = chunkPresent.toLongArray();
DataTypeIO.writeVarInt(output, bitmasks.length);
for (long l : bitmasks) {
output.writeLong(l);
} }
DataTypeIO.writeVarInt(output, bitmask);
DataTypeIO.writeCompoundTag(output, chunk.getHeightMaps()); DataTypeIO.writeCompoundTag(output, chunk.getHeightMaps());
DataTypeIO.writeVarInt(output, 1024); DataTypeIO.writeVarInt(output, 1024);

View File

@ -36,8 +36,9 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
private float pitch; private float pitch;
private Set<PlayerTeleportFlags> flags; private Set<PlayerTeleportFlags> flags;
private int teleportId; private int teleportId;
private boolean dismountVehicle;
public PacketPlayOutPositionAndLook(double x, double y, double z, float yaw, float pitch, int teleportId, PlayerTeleportFlags... flags) { public PacketPlayOutPositionAndLook(double x, double y, double z, float yaw, float pitch, int teleportId, boolean dismountVehicle, PlayerTeleportFlags... flags) {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
@ -45,6 +46,7 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
this.pitch = pitch; this.pitch = pitch;
this.teleportId = teleportId; this.teleportId = teleportId;
this.flags = Arrays.asList(flags).stream().collect(Collectors.toSet()); this.flags = Arrays.asList(flags).stream().collect(Collectors.toSet());
this.dismountVehicle = dismountVehicle;
} }
public double getX() { public double getX() {
@ -75,6 +77,10 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
return teleportId; return teleportId;
} }
public boolean isDismountVehicle() {
return dismountVehicle;
}
@Override @Override
public byte[] serializePacket() throws IOException { public byte[] serializePacket() throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
@ -94,6 +100,7 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
output.writeByte(flag); output.writeByte(flag);
DataTypeIO.writeVarInt(output, teleportId); DataTypeIO.writeVarInt(output, teleportId);
output.writeBoolean(dismountVehicle);
return buffer.toByteArray(); return buffer.toByteArray();
} }

View File

@ -10,21 +10,28 @@ import com.loohp.limbo.world.BlockPosition;
public class PacketPlayOutSpawnPosition extends PacketOut { public class PacketPlayOutSpawnPosition extends PacketOut {
private BlockPosition position; private BlockPosition position;
private float angle;
public PacketPlayOutSpawnPosition(BlockPosition position) { public PacketPlayOutSpawnPosition(BlockPosition position, float angle) {
this.position = position; this.position = position;
this.angle = angle;
} }
public BlockPosition getPosition() { public BlockPosition getPosition() {
return position; return position;
} }
public float getAngle() {
return angle;
}
public byte[] serializePacket() throws IOException { public byte[] serializePacket() throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(Packet.getPlayOut().get(getClass()));
DataTypeIO.writeBlockPosition(output, position); DataTypeIO.writeBlockPosition(output, position);
output.writeFloat(angle);
return buffer.toByteArray(); return buffer.toByteArray();
} }

View File

@ -10,15 +10,15 @@ public abstract class LightEngine {
static { static {
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:beacon", (byte) 15);
blockLightLevelMapping.put("minecraft:torch", (byte) 15); blockLightLevelMapping.put("minecraft:torch", (byte) 15);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:sea_lantern", (byte) 15);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:end_rod", (byte) 15);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:fire", (byte) 15);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:lava", (byte) 15);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:lantern", (byte) 15);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:soul_lantern", (byte) 10);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:glowstone", (byte) 15);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:campfire", (byte) 15);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:soul_campfire", (byte) 10);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:beacon", (byte) 15);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:beacon", (byte) 15);
blockLightLevelMapping.put("minecraft:beacon", (byte) 15); blockLightLevelMapping.put("minecraft:beacon", (byte) 15);

File diff suppressed because it is too large Load Diff

View File

@ -69,13 +69,21 @@
"type": "DoubleTag", "type": "DoubleTag",
"value": 1 "value": 1
}, },
"ultrawarm": { "min_y": {
"type": "ByteTag", "type": "IntTag",
"value": 0 "value": 0
}, },
"has_ceiling": { "has_ceiling": {
"type": "ByteTag", "type": "ByteTag",
"value": 0 "value": 0
},
"ultrawarm": {
"type": "ByteTag",
"value": 0
},
"height": {
"type": "IntTag",
"value": 256
} }
} }
} }
@ -136,13 +144,21 @@
"type": "DoubleTag", "type": "DoubleTag",
"value": 1 "value": 1
}, },
"ultrawarm": { "min_y": {
"type": "ByteTag", "type": "IntTag",
"value": 0 "value": 0
}, },
"has_ceiling": { "has_ceiling": {
"type": "ByteTag", "type": "ByteTag",
"value": 1 "value": 1
},
"ultrawarm": {
"type": "ByteTag",
"value": 0
},
"height": {
"type": "IntTag",
"value": 256
} }
} }
} }
@ -207,13 +223,21 @@
"type": "DoubleTag", "type": "DoubleTag",
"value": 8 "value": 8
}, },
"ultrawarm": { "min_y": {
"type": "ByteTag", "type": "IntTag",
"value": 1 "value": 0
}, },
"has_ceiling": { "has_ceiling": {
"type": "ByteTag", "type": "ByteTag",
"value": 1 "value": 1
},
"ultrawarm": {
"type": "ByteTag",
"value": 1
},
"height": {
"type": "IntTag",
"value": 256
} }
} }
} }
@ -278,13 +302,21 @@
"type": "DoubleTag", "type": "DoubleTag",
"value": 1 "value": 1
}, },
"ultrawarm": { "min_y": {
"type": "ByteTag", "type": "IntTag",
"value": 0 "value": 0
}, },
"has_ceiling": { "has_ceiling": {
"type": "ByteTag", "type": "ByteTag",
"value": 0 "value": 0
},
"ultrawarm": {
"type": "ByteTag",
"value": 0
},
"height": {
"type": "IntTag",
"value": 256
} }
} }
} }
@ -7046,6 +7078,147 @@
} }
} }
} }
},
{
"name": {
"type": "StringTag",
"value": "minecraft:dripstone_caves"
},
"id": {
"type": "IntTag",
"value": 174
},
"element": {
"type": "CompoundTag",
"value": {
"precipitation": {
"type": "StringTag",
"value": "rain"
},
"effects": {
"type": "CompoundTag",
"value": {
"water_fog_color": {
"type": "IntTag",
"value": 329011
},
"sky_color": {
"type": "IntTag",
"value": 7907327
},
"fog_color": {
"type": "IntTag",
"value": 12638463
},
"water_color": {
"type": "IntTag",
"value": 4159204
},
"mood_sound": {
"type": "CompoundTag",
"value": {
"tick_delay": {
"type": "IntTag",
"value": 6000
},
"offset": {
"type": "DoubleTag",
"value": 2
},
"block_search_extent": {
"type": "IntTag",
"value": 8
},
"sound": {
"type": "StringTag",
"value": "minecraft:ambient.cave"
}
}
}
}
},
"depth": {
"type": "FloatTag",
"value": 0.125
},
"temperature": {
"type": "FloatTag",
"value": 0.8
},
"scale": {
"type": "FloatTag",
"value": 0.05
},
"downfall": {
"type": "FloatTag",
"value": 0.4
},
"category": {
"type": "StringTag",
"value": "underground"
}
}
}
},
{
"name": {
"type": "StringTag",
"value": "minecraft:lush_caves"
},
"id": {
"type": "IntTag",
"value": 175
},
"element": {
"type": "CompoundTag",
"value": {
"precipitation": {
"type": "StringTag",
"value": "rain"
},
"effects": {
"type": "CompoundTag",
"value": {
"water_fog_color": {
"type": "IntTag",
"value": 329011
},
"sky_color": {
"type": "IntTag",
"value": 8103167
},
"fog_color": {
"type": "IntTag",
"value": 12638463
},
"water_color": {
"type": "IntTag",
"value": 4159204
}
}
},
"depth": {
"type": "FloatTag",
"value": 0.1
},
"temperature": {
"type": "FloatTag",
"value": 0.5
},
"scale": {
"type": "FloatTag",
"value": 0.2
},
"downfall": {
"type": "FloatTag",
"value": 0.5
},
"category": {
"type": "StringTag",
"value": "underground"
}
}
}
} }
] ]
} }

View File

@ -12,38 +12,38 @@
"PacketLoginOutPluginMessaging": "0x04", "PacketLoginOutPluginMessaging": "0x04",
}, },
"PlayIn": { "PlayIn": {
"0x10": "PacketPlayInKeepAlive", "0x0F": "PacketPlayInKeepAlive",
"0x03": "PacketPlayInChat", "0x03": "PacketPlayInChat",
"0x13": "PacketPlayInPositionAndLook", "0x12": "PacketPlayInPositionAndLook",
"0x12": "PacketPlayInPosition", "0x11": "PacketPlayInPosition",
"0x14": "PacketPlayInRotation", "0x13": "PacketPlayInRotation",
"0x0B": "PacketPlayInPluginMessaging", "0x0A": "PacketPlayInPluginMessaging",
"0x06": "PacketPlayInTabComplete", "0x06": "PacketPlayInTabComplete",
"0x25": "PacketPlayInHeldItemChange" "0x25": "PacketPlayInHeldItemChange"
}, },
"PlayOut": { "PlayOut": {
"PacketPlayOutLogin": "0x24", "PacketPlayOutLogin": "0x26",
"PacketPlayOutPositionAndLook": "0x34", "PacketPlayOutPositionAndLook": "0x38",
"PacketPlayOutSpawnPosition": "0x42", "PacketPlayOutSpawnPosition": "0x4B",
"PacketPlayOutChat": "0x0E", "PacketPlayOutChat": "0x0F",
"PacketPlayOutPlayerAbilities": "0x30", "PacketPlayOutPlayerAbilities": "0x32",
"PacketPlayOutMapChunk": "0x20", "PacketPlayOutMapChunk": "0x22",
"PacketPlayOutUnloadChunk": "0x1C", "PacketPlayOutUnloadChunk": "0x1D",
"PacketPlayOutLightUpdate": "0x23", "PacketPlayOutLightUpdate": "0x25",
"PacketPlayOutKeepAlive": "0x1F", "PacketPlayOutKeepAlive": "0x21",
"PacketPlayOutPlayerInfo": "0x32", "PacketPlayOutPlayerInfo": "0x36",
"PacketPlayOutUpdateViewPosition": "0x40", "PacketPlayOutUpdateViewPosition": "0x49",
"PacketPlayOutDisconnect": "0x19", "PacketPlayOutDisconnect": "0x1A",
"PacketPlayOutPluginMessaging": "0x17", "PacketPlayOutPluginMessaging": "0x18",
"PacketPlayOutTabComplete": "0x0F", "PacketPlayOutTabComplete": "0x11",
"PacketPlayOutDeclareCommands": "0x10", "PacketPlayOutDeclareCommands": "0x12",
"PacketPlayOutRespawn": "0x39", "PacketPlayOutRespawn": "0x3D",
"PacketPlayOutGameState": "0x1D", "PacketPlayOutGameState": "0x1E",
"PacketPlayOutEntityDestroy": "0x36", "PacketPlayOutEntityDestroy": "0x3A",
"PacketPlayOutEntityMetadata": "0x44", "PacketPlayOutEntityMetadata": "0x4D",
"PacketPlayOutSpawnEntity": "0x00", "PacketPlayOutSpawnEntity": "0x00",
"PacketPlayOutSpawnEntityLiving": "0x02", "PacketPlayOutSpawnEntityLiving": "0x02",
"PacketPlayOutHeldItemChange": "0x3F" "PacketPlayOutHeldItemChange": "0x48"
}, },
"StatusIn": { "StatusIn": {
"0x01": "PacketStatusInPing", "0x01": "PacketStatusInPing",