Remove effects on world/server change (Fixes #467)

The server re-sends these effects upon joining the new world or server.
This commit is contained in:
RednedEpic 2020-05-23 23:45:39 -05:00
parent 7f5414cdef
commit 3d0dbff87b
1 changed files with 11 additions and 0 deletions

View File

@ -25,6 +25,7 @@
package org.geysermc.connector.utils;
import com.github.steveice10.mc.protocol.data.game.entity.Effect;
import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.protocol.bedrock.packet.*;
import org.geysermc.connector.entity.Entity;
@ -59,6 +60,16 @@ public class DimensionUtils {
session.setSpawned(false);
session.setLastChunkPosition(null);
for (Effect effect : session.getPlayerEntity().getEffectCache().getEntityEffects().keySet()) {
MobEffectPacket mobEffectPacket = new MobEffectPacket();
mobEffectPacket.setEvent(MobEffectPacket.Event.REMOVE);
mobEffectPacket.setRuntimeEntityId(session.getPlayerEntity().getGeyserId());
mobEffectPacket.setEffectId(EntityUtils.toBedrockEffectId(effect));
session.sendUpstreamPacket(mobEffectPacket);
}
// Effects are re-sent from server
session.getPlayerEntity().getEffectCache().getEntityEffects().clear();
//let java server handle portal travel sound
StopSoundPacket stopSoundPacket = new StopSoundPacket();
stopSoundPacket.setStoppingAllSound(true);