Skip to content

Commit

Permalink
Fixed #367
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Jan 27, 2025
1 parent a1cd459 commit 726ab11
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

public class EntityEventDispatcher {

// TODO: not triggered
public static void dispatchEntityEvent() {
ServerEntityWorldChangeEvents.AFTER_ENTITY_CHANGE_WORLD.register((originalEntity, newEntity, origin, destination) -> {
var pos = originalEntity.getOnPos();
Expand All @@ -36,6 +37,22 @@ public static void dispatchEntityEvent() {
PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(player.getBukkitEntity(), origin.getWorld());
player.level().getCraftServer().getPluginManager().callEvent(changeEvent);
// CraftBukkit end
var pos = player.getOnPos();
if (destination.getTypeKey() == LevelStem.NETHER) {
player.callPortalEvent(player, destination, new PositionImpl(pos.getX(), pos.getY(), pos.getZ()),
PlayerTeleportEvent.TeleportCause.NETHER_PORTAL,
16, 16);
}else if (destination.getTypeKey() == LevelStem.END) {
if (Bukkit.getAllowEnd()) {
player.callPortalEvent(player, destination, new PositionImpl(pos.getX(), pos.getY(), pos.getZ()),
PlayerTeleportEvent.TeleportCause.END_PORTAL,
128, 16);
}
}else {
player.callPortalEvent(player, destination, new PositionImpl(pos.getX(), pos.getY(), pos.getZ()),
PlayerTeleportEvent.TeleportCause.UNKNOWN,
0, 0);
}
});

ServerLivingEntityEvents.AFTER_DEATH.register((entity, source) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@ public void postTick() {
}
}

@Inject(method = "handleNetherPortal", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;changeDimension(Lnet/minecraft/server/level/ServerLevel;)Lnet/minecraft/world/entity/Entity;"))
public void banner$changeDimension(CallbackInfo ci) {
if ((Entity)(Object)this instanceof ServerPlayer serverPlayer) {
serverPlayer.pushChangeDimensionCause(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL);
}
}

public AtomicBoolean callEntityCombustEvent = new AtomicBoolean(true);

@Override
Expand Down

0 comments on commit 726ab11

Please sign in to comment.