Skip to content

Commit

Permalink
Merge pull request #4 from TheMeinerLP/feature/folia/1-20-wand-fix
Browse files Browse the repository at this point in the history
Fixes Wand Command
  • Loading branch information
TheMeinerLP committed Dec 3, 2023
2 parents dea40d1 + a7d2112 commit 7e9dd96
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public synchronized net.minecraft.world.level.block.state.BlockState setBlockSta
} else {
currentTick = MinecraftServer.currentTick;
}
if (Fawe.isMainThread()) {
if (Fawe.isTickThread()) {
return levelChunk.setBlockState(blockPos, blockState,
this.sideEffectSet != null && this.sideEffectSet.shouldApply(SideEffect.UPDATE)
);
Expand Down Expand Up @@ -309,7 +309,7 @@ public void run(Object value) {
}
}
};
if (Fawe.isMainThread()) {
if (Fawe.isTickThread()) {
runnableVal.run();
} else {
TaskManager.taskManager().sync(runnableVal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public static LevelChunk ensureLoaded(ServerLevel serverLevel, int chunkX, int c
if (nmsChunk != null) {
return nmsChunk;
}
if (Fawe.isMainThread()) {
if (Fawe.isTickThread()) {
return serverLevel.getChunk(chunkX, chunkZ);
}
} else {
Expand All @@ -310,7 +310,7 @@ public static LevelChunk ensureLoaded(ServerLevel serverLevel, int chunkX, int c
return nmsChunk;
}
// Avoid "async" methods from the main thread.
if (Fawe.isMainThread()) {
if (Fawe.isTickThread()) {
return serverLevel.getChunk(chunkX, chunkZ);
}
if (FOLIA_SUPPORT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,21 @@ private static class SchedulerAdapter {
"execute",
ENTITY_EXECUTE_TYPE
);
// (ES, P, R, R, L)Z (ES, R, R, L)Z
// (Entity, Plugin, Runnable, Runnable, Long)Z (Entity, Runnable, Runnable, Long)Z
executeForPlayer = insertArguments(executeForPlayer, 1, pluginInstance);
// (ES, R1, R2, L)Z -> (ES, R1)Z
// (Entity, Runnable, Runnable, Long)Boolean -> (Entity, Runnable1)Boolean
executeForPlayer = insertArguments(executeForPlayer, 2, THROW_IF_RETIRED, 0);
// (ES, R1)Z -> (ES, R1)V
// (Entity, Runnable1)Boolean -> (Entity, Runnable1)boolean
executeForPlayer = dropReturn(executeForPlayer);
MethodHandle getScheduler = lookup.findVirtual(
org.bukkit.entity.Entity.class,
"getScheduler",
methodType(entitySchedulerClass)
);
// (ES, R1)V -> (E, R1)V
// (Entity, Runnable1)V -> (Entity, Runnable1)V
executeForPlayer = filterArguments(executeForPlayer, 0, getScheduler);
MethodType finalType = methodType(void.class, org.bukkit.entity.Player.class, Runnable.class);
// (ES, R1)V -> (P, R1)V
// (Entity, Runnable1)V -> (Player, Runnable1)V
executeForPlayer = explicitCastArguments(executeForPlayer, finalType);
} catch (Throwable throwable) {
throw new AssertionError(throwable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ public void parallel(Collection<Runnable> runnables, @Nullable Integer numThread
@Deprecated
public void runUnsafe(Runnable run) {
QueueHandler queue = Fawe.instance().getQueueHandler();
queue.startUnsafe(Fawe.isMainThread());
queue.startUnsafe(Fawe.isTickThread());
try {
run.run();
} catch (Throwable e) {
e.printStackTrace();
}
queue.endUnsafe(Fawe.isMainThread());
queue.endUnsafe(Fawe.isTickThread());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ public void handleCommand(CommandEvent event) {
Command cmd = optional.get();
PermissionCondition queued = cmd.getCondition().as(PermissionCondition.class).orElse(null);
if (queued != null && !queued.isQueued()) {
TaskManager.taskManager().taskNow(() -> handleCommandOnCurrentThread(event), Fawe.isMainThread());
TaskManager.taskManager().taskNow(() -> handleCommandOnCurrentThread(event), Fawe.isTickThread());
return;
} else {
actor.decline();
Expand Down

0 comments on commit 7e9dd96

Please sign in to comment.