Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Fixed StargateTeleportEntityEvent not being posted
Browse files Browse the repository at this point in the history
  • Loading branch information
MrJake222 committed Feb 4, 2021
1 parent f421ee8 commit 6940b02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import javax.vecmath.Vector2f;

import mrjake.aunis.AunisProps;
import mrjake.aunis.api.event.StargateTeleportEntityEvent;
import mrjake.aunis.packet.AunisPacketHandler;
import mrjake.aunis.packet.stargate.StargateMotionToClient;
import mrjake.aunis.sound.AunisSoundHelper;
import mrjake.aunis.sound.SoundEventEnum;
import mrjake.aunis.stargate.network.StargatePos;
import mrjake.aunis.tileentity.stargate.StargateAbstractBaseTile;
import mrjake.aunis.util.AunisAxisAlignedBB;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
Expand Down Expand Up @@ -105,9 +107,14 @@ public void scheduleTeleportation(StargatePos targetGate) {
}

public void teleportEntity(int entityId) {
scheduledTeleportMap.get(entityId).teleport();
TeleportPacket packet = scheduledTeleportMap.get(entityId);

if (!new StargateTeleportEntityEvent((StargateAbstractBaseTile) world.getTileEntity(pos), packet.getTargetGatePos().getTileEntity(), packet.getEntity()).post()) {
// Not cancelled
packet.teleport();
AunisSoundHelper.playSoundEvent(world, gateCenter, SoundEventEnum.WORMHOLE_GO);
};

AunisSoundHelper.playSoundEvent(world, gateCenter, SoundEventEnum.WORMHOLE_GO);
scheduledTeleportMap.remove(entityId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public TeleportPacket(Entity entity, BlockPos source, StargatePos target, float
this.rotation = rotation;
}

public StargatePos getTargetGatePos() {
return targetGatePos;
}

public Entity getEntity() {
return entity;
}

public void teleport() {
TeleportHelper.teleportEntity(entity, sourceGatePos, targetGatePos, rotation, motionVector);

Expand Down

0 comments on commit 6940b02

Please sign in to comment.