From 64ac209a2cb1840b249da7d32335778c24fd9737 Mon Sep 17 00:00:00 2001 From: Harshit Date: Sat, 19 Jun 2021 23:32:40 +0530 Subject: [PATCH] modify character teleport event --- .../componentsystem/controllers/PlayerDeathSystem.java | 8 ++++++-- .../componentsystem/controllers/TeleporterSystem.java | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/PlayerDeathSystem.java b/src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/PlayerDeathSystem.java index 0a10598f..49739d18 100644 --- a/src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/PlayerDeathSystem.java +++ b/src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/PlayerDeathSystem.java @@ -18,6 +18,8 @@ import java.util.Optional; import java.util.Random; +import org.joml.AxisAngle4f; +import org.joml.Quaternionf; import org.joml.Vector3f; import org.joml.Vector3fc; import org.terasology.engine.utilities.Assets; @@ -72,12 +74,14 @@ public void beforeDestroy(BeforeDestroyEvent event, EntityRef player, CharacterC if (player.hasComponent(PlayerCharacterComponent.class)) { event.consume(); String team = player.getComponent(LASTeamComponent.class).team; - updateStatistics(event.getInstigator(), "kills"); + if (event.getInstigator() != EntityRef.NULL) { + updateStatistics(event.getInstigator(), "kills"); + } updateStatistics(player, "deaths"); dropItemsFromInventory(player); player.send(new RestoreFullHealthEvent(player)); Vector3f randomVector = new Vector3f(-1 + random.nextInt(3), 0, -1 + random.nextInt(3)); - player.send(new CharacterTeleportEvent(randomVector.add(LASUtils.getTeleportDestination(team)))); + player.send(new CharacterTeleportEvent(randomVector.add(LASUtils.getTeleportDestination(team)), new Quaternionf(new AxisAngle4f((float) (Math.PI), 0, 1, 0)))); player.addOrSaveComponent(startingInventory); player.send(new RequestInventoryEvent(startingInventory.items)); } diff --git a/src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/TeleporterSystem.java b/src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/TeleporterSystem.java index f60d7794..572e7517 100644 --- a/src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/TeleporterSystem.java +++ b/src/main/java/org/terasology/ligthandshadow/componentsystem/controllers/TeleporterSystem.java @@ -5,6 +5,8 @@ import java.util.Optional; import java.util.Random; +import org.joml.AxisAngle4f; +import org.joml.Quaternionf; import org.joml.Vector3f; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -123,7 +125,7 @@ private String setPlayerTeamToTeleporterTeam(EntityRef player, EntityRef telepor private void handlePlayerTeleport(EntityRef player, String team) { Vector3f randomVector = new Vector3f(-1 + random.nextInt(3), 0, -1 + random.nextInt(3)); - player.send(new CharacterTeleportEvent(randomVector.add(LASUtils.getTeleportDestination(team)))); + player.send(new CharacterTeleportEvent(randomVector.add(LASUtils.getTeleportDestination(team)), new Quaternionf(new AxisAngle4f((float) (Math.PI), 0, 1, 0)))); player.addOrSaveComponent(startingInventory); player.send(new RequestInventoryEvent(startingInventory.items)); }