mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 22:16:01 +00:00
Add workaround for mods that use non-standard entity spawn packets
This commit is contained in:
1 parent
193b6ef058
commit
fe33b55fc2
5 files changed
+62
-5
No files matched your search
@@ -959,7 +959,12 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
@Override
|
||||
public void handleRotateMob(ClientboundRotateHeadPacket clientboundRotateHeadPacket) {
|
||||
Entity entity = this.getEntityOrPending(clientboundRotateHeadPacket.entityId);
|
||||
if (entity == null || entity.getId() == this.localPlayerId) {
|
||||
if (entity == null) {
|
||||
forward(clientboundRotateHeadPacket);
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity.getId() == this.localPlayerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1002,6 +1007,7 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
public void handleSetEntityData(ClientboundSetEntityDataPacket clientboundSetEntityDataPacket) {
|
||||
Entity entity = this.getEntityOrPending(clientboundSetEntityDataPacket.id());
|
||||
if (entity == null) {
|
||||
forward(clientboundSetEntityDataPacket);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1022,6 +1028,7 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
public void handleSetEntityMotion(ClientboundSetEntityMotionPacket clientboundSetEntityMotionPacket) {
|
||||
Entity entity = this.getEntityOrPending(clientboundSetEntityMotionPacket.getId());
|
||||
if (entity == null) {
|
||||
forward(clientboundSetEntityMotionPacket);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1035,6 +1042,10 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
@Override
|
||||
public void handleSetEquipment(ClientboundSetEquipmentPacket clientboundSetEquipmentPacket) {
|
||||
Entity entity = this.getEntityOrPending(clientboundSetEquipmentPacket.getEntity());
|
||||
if (entity == null) {
|
||||
forward(clientboundSetEquipmentPacket);
|
||||
return;
|
||||
}
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
clientboundSetEquipmentPacket.getSlots().forEach((pair) -> {
|
||||
livingEntity.setItemSlot(pair.getFirst(), pair.getSecond());
|
||||
@@ -1189,6 +1200,7 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
public void handleTeleportEntity(ClientboundTeleportEntityPacket clientboundTeleportEntityPacket) {
|
||||
Entity entity = this.getEntityOrPending(clientboundTeleportEntityPacket.id());
|
||||
if (entity == null) {
|
||||
forward(clientboundTeleportEntityPacket);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1217,6 +1229,10 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
@Override
|
||||
public void handleUpdateAttributes(ClientboundUpdateAttributesPacket clientboundUpdateAttributesPacket) {
|
||||
Entity entity = this.getEntityOrPending(clientboundUpdateAttributesPacket.getEntityId());
|
||||
if (entity == null) {
|
||||
forward(clientboundUpdateAttributesPacket);
|
||||
return;
|
||||
}
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
AttributeMap attributeMap = livingEntity.getAttributes();
|
||||
for (ClientboundUpdateAttributesPacket.AttributeSnapshot snapshot : clientboundUpdateAttributesPacket.getValues()) {
|
||||
@@ -1237,6 +1253,10 @@ public class ReplayGamePacketHandler implements ClientGamePacketListener {
|
||||
@Override
|
||||
public void handleUpdateMobEffect(ClientboundUpdateMobEffectPacket clientboundUpdateMobEffectPacket) {
|
||||
Entity entity = this.getEntityOrPending(clientboundUpdateMobEffectPacket.getEntityId());
|
||||
if (entity == null) {
|
||||
forward(clientboundUpdateMobEffectPacket);
|
||||
return;
|
||||
}
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
Holder<MobEffect> holder = clientboundUpdateMobEffectPacket.getEffect();
|
||||
MobEffectInstance mobEffectInstance = new MobEffectInstance(holder, clientboundUpdateMobEffectPacket.getEffectDurationTicks(), clientboundUpdateMobEffectPacket.getEffectAmplifier(),
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.PacketHelper;
|
||||
import com.moulberry.flashback.SneakyThrow;
|
||||
import com.moulberry.flashback.ext.LevelChunkExt;
|
||||
import com.moulberry.flashback.TempFolderProvider;
|
||||
@@ -643,6 +644,10 @@ public class ReplayServer extends IntegratedServer {
|
||||
}
|
||||
|
||||
positionUpdateSet.add(id);
|
||||
} else {
|
||||
byte yRot = (byte) Mth.floor(yaw * 256.0F / 360.0F);
|
||||
byte xRot = (byte) Mth.floor(pitch * 256.0F / 360.0F);
|
||||
this.getPlayerList().broadcastAll(PacketHelper.createTeleportForUnknown(id, x, y, z, yRot, xRot, onGround));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user