chore: other melonhell pr changes

(cherry picked from commit 266040cfa7)
This commit is contained in:
mworzala 2023-11-01 22:51:37 -04:00 committed by Matt Worzala
parent 9439b62ff0
commit bad9e80c88
4 changed files with 26 additions and 20 deletions

View File

@ -465,8 +465,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
refreshHealth(); refreshHealth();
sendPacket(new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(), sendPacket(new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(),
0, gameMode, gameMode, false, levelFlat, RespawnPacket.COPY_ALL, 0, gameMode, gameMode, false, levelFlat, deathLocation, portalCooldown, RespawnPacket.COPY_ALL));
deathLocation, portalCooldown));
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this); PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this);
EventDispatcher.call(respawnEvent); EventDispatcher.call(respawnEvent);
@ -1086,8 +1085,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
final PlayerInfoUpdatePacket addPlayerPacket = getAddPlayerToList(); final PlayerInfoUpdatePacket addPlayerPacket = getAddPlayerToList();
RespawnPacket respawnPacket = new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(), RespawnPacket respawnPacket = new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(),
0, gameMode, gameMode, false, levelFlat, RespawnPacket.COPY_ALL, 0, gameMode, gameMode, false, levelFlat, deathLocation, portalCooldown, RespawnPacket.COPY_ALL);
deathLocation, portalCooldown);
sendPacket(removePlayerPacket); sendPacket(removePlayerPacket);
sendPacket(destroyEntitiesPacket); sendPacket(destroyEntitiesPacket);
@ -1488,7 +1486,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
this.dimensionType = dimensionType; this.dimensionType = dimensionType;
sendPacket(new RespawnPacket(dimensionType.toString(), dimensionName, sendPacket(new RespawnPacket(dimensionType.toString(), dimensionName,
0, gameMode, gameMode, false, levelFlat, 0, gameMode, gameMode, false, levelFlat,
RespawnPacket.COPY_ALL, deathLocation, portalCooldown)); deathLocation, portalCooldown, RespawnPacket.COPY_ALL));
refreshClientStateAfterRespawn(); refreshClientStateAfterRespawn();
} }

View File

@ -10,9 +10,15 @@ import org.jetbrains.annotations.Nullable;
import static net.minestom.server.network.NetworkBuffer.*; import static net.minestom.server.network.NetworkBuffer.*;
// Notes /**
// sourceEntityId - 0 indicates no source entity, otherwise it is entityId + 1 * See <a href="https://wiki.vg/Protocol#Damage_Event">https://wiki.vg/Protocol#Damage_Event</a> for more info.
// sourceDirectId - 0 indicates no direct source. Direct attacks (e.g. melee) will have this number me the same as sourceEntityId, indirect attacks (e.g. projectiles) will have this be be the projectile entity id + 1 *
* @param targetEntityId ID of the entity being damaged
* @param damageTypeId ID of damage type
* @param sourceEntityId 0 if there is no source entity, otherwise it is entityId + 1
* @param sourceDirectId 0 if there is no direct source. For direct attacks (e.g. melee), this is the same as sourceEntityId. For indirect attacks (e.g. projectiles), this is the projectile entity id + 1
* @param sourcePos null if there is no source position, otherwise the position of the source
*/
public record DamageEventPacket(int targetEntityId, int damageTypeId, int sourceEntityId, int sourceDirectId, @Nullable Point sourcePos) implements ServerPacket { public record DamageEventPacket(int targetEntityId, int damageTypeId, int sourceEntityId, int sourceDirectId, @Nullable Point sourcePos) implements ServerPacket {
public DamageEventPacket(@NotNull NetworkBuffer reader) { public DamageEventPacket(@NotNull NetworkBuffer reader) {

View File

@ -10,22 +10,24 @@ import org.jetbrains.annotations.NotNull;
import static net.minestom.server.network.NetworkBuffer.*; import static net.minestom.server.network.NetworkBuffer.*;
public record RespawnPacket(String dimensionType, String worldName, public record RespawnPacket(
long hashedSeed, GameMode gameMode, GameMode previousGameMode, String dimensionType, String worldName,
boolean isDebug, boolean isFlat, byte dataToCopy, long hashedSeed, GameMode gameMode, GameMode previousGameMode,
DeathLocation deathLocation, int portalCooldown) implements ServerPacket { boolean isDebug, boolean isFlat, DeathLocation deathLocation,
int portalCooldown, int copyData
public static final byte COPY_ATTRIBUTES = 0x1; ) implements ServerPacket {
public static final byte COPY_METADATA = 0x2; public static final int COPY_NONE = 0x0;
public static final byte COPY_ALL = COPY_ATTRIBUTES | COPY_METADATA; public static final int COPY_ATTRIBUTES = 0x1;
public static final int COPY_METADATA = 0x2;
public static final int COPY_ALL = COPY_ATTRIBUTES | COPY_METADATA;
public RespawnPacket(@NotNull NetworkBuffer reader) { public RespawnPacket(@NotNull NetworkBuffer reader) {
this(reader.read(STRING), reader.read(STRING), this(reader.read(STRING), reader.read(STRING),
reader.read(LONG), GameMode.fromId(reader.read(BYTE)), reader.read(LONG), GameMode.fromId(reader.read(BYTE)),
GameMode.fromId(reader.read(BYTE)), GameMode.fromId(reader.read(BYTE)),
reader.read(BOOLEAN), reader.read(BOOLEAN), reader.read(BOOLEAN), reader.read(BOOLEAN),
reader.read(BYTE), reader.read(DEATH_LOCATION), reader.read(DEATH_LOCATION),
reader.read(VAR_INT)); reader.read(VAR_INT), reader.read(BYTE));
} }
@Override @Override
@ -37,9 +39,9 @@ public record RespawnPacket(String dimensionType, String worldName,
writer.write(BYTE, previousGameMode.id()); writer.write(BYTE, previousGameMode.id());
writer.write(BOOLEAN, isDebug); writer.write(BOOLEAN, isDebug);
writer.write(BOOLEAN, isFlat); writer.write(BOOLEAN, isFlat);
writer.write(BYTE, dataToCopy);
writer.write(DEATH_LOCATION, deathLocation); writer.write(DEATH_LOCATION, deathLocation);
writer.write(VAR_INT, portalCooldown); writer.write(VAR_INT, portalCooldown);
writer.write(BYTE, (byte) copyData);
} }
@Override @Override

View File

@ -72,7 +72,7 @@ public final class Biome {
element.setFloat("scale", scale); element.setFloat("scale", scale);
element.setFloat("downfall", downfall); element.setFloat("downfall", downfall);
element.setString("category", category.name().toLowerCase(Locale.ROOT)); element.setString("category", category.name().toLowerCase(Locale.ROOT));
element.setByte("has_precipitation", (byte) 1); //todo bad fix element.setByte("has_precipitation", (byte) (precipitation == Precipitation.NONE ? 0 : 1));
element.setString("precipitation", precipitation.name().toLowerCase(Locale.ROOT)); element.setString("precipitation", precipitation.name().toLowerCase(Locale.ROOT));
if (temperatureModifier != TemperatureModifier.NONE) if (temperatureModifier != TemperatureModifier.NONE)
element.setString("temperature_modifier", temperatureModifier.name().toLowerCase(Locale.ROOT)); element.setString("temperature_modifier", temperatureModifier.name().toLowerCase(Locale.ROOT));