LightAPI icon indicating copy to clipboard operation
LightAPI copied to clipboard

Tunity Starlight Support.

Open EuanM199 opened this issue 3 years ago • 21 comments

Since the popularity of starlight by being both in tuninity and its forks, could we get support for starlight?

here is the current issue I have found due to starlight + LightAPI

[20:56:19 WARN]: [InteractionVisualizer] Task #205 for InteractionVisualizer v1.16.2.3 generated an exception java.lang.ClassCastException: class ca.spottedleaf.starlight.light.StarLightInterface$2 cannot be cast to class net.minecraft.world.level.lighting.LightEngineBlock (ca.spottedleaf.starlight.light.StarLightInterface$2 and net.minecraft.world.level.lighting.LightEngineBlock are in unnamed module of loader 'app') at ru.beykerykt.lightapi.server.nms.craftbukkit.CraftBukkit_v1_17_R1$2.run(CraftBukkit_v1_17_R1.java:166) ~[?:?] at ru.beykerykt.lightapi.server.nms.craftbukkit.CraftBukkit_v1_17_R1.executeSync(CraftBukkit_v1_17_R1.java:242) ~[?:?] at ru.beykerykt.lightapi.server.nms.craftbukkit.CraftBukkit_v1_17_R1.recalculateLighting(CraftBukkit_v1_17_R1.java:159) ~[?:?] at ru.beykerykt.lightapi.server.nms.craftbukkit.CraftBukkit_v1_17_R1.deleteLight(CraftBukkit_v1_17_R1.java:103) ~[?:?] at ru.beykerykt.lightapi.LightAPI$2.run(LightAPI.java:375) ~[?:?] at ru.beykerykt.lightapi.LightAPI.deleteLight(LightAPI.java:386) ~[?:?] at ru.beykerykt.lightapi.LightAPI.deleteLight(LightAPI.java:349) ~[?:?] at com.loohp.interactionvisualizer.managers.LightManager.lambda$run$0(LightManager.java:133) ~[?:?] at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:100) ~[patched_1.17.1.jar:git-Purpur-1265] at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:468) ~[patched_1.17.1.jar:git-Purpur-1265] at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1565) ~[patched_1.17.1.jar:git-Purpur-1265] at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:492) ~[patched_1.17.1.jar:git-Purpur-1265] at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1480) ~[patched_1.17.1.jar:git-Purpur-1265] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1270) ~[patched_1.17.1.jar:git-Purpur-1265] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Purpur-1265]

EuanM199 avatar Jul 15 '21 09:07 EuanM199

I did quick look at the source code here https://github.com/Tuinity/Starlight. Yes, starlight has rewritten bukkit light engine. Therefore, ATM LightAPI is incompatible with starlight. Additional research is required for this mod. Also, I am not very good with mods. I need a brief description: how, where and what excatly to install to start the server with this mod (step by step). Next, I will try to do research and, probably, the solution.

Qveshn avatar Jul 15 '21 10:07 Qveshn

Starlight is already built into Tuninity, Purpur, and airplane by default, it's not actually a mod, See https://github.com/Tuinity/Tuinity and https://github.com/pl3xgaming/Purpur

its actually built into the forks by default and not a mod you can use it by installing purpur, tuninity or airplane no outside mod or plugin is required

EuanM199 avatar Jul 15 '21 10:07 EuanM199

https://github.com/Tuinity/Tuinity -> https://ci.codemc.io/job/Spottedleaf/job/Tuinity/ -> tuinity-paperclip.jar #240 last version 1.16.5

will try purpur instead

Qveshn avatar Jul 15 '21 11:07 Qveshn

this is the correct CI for Tuninity 1.17 https://ci.codemc.io/job/Spottedleaf/job/Tuinity-1.17/

EuanM199 avatar Jul 15 '21 11:07 EuanM199

https://github.com/pl3xgaming/Purpur -> https://purpur.pl3x.net/downloads/ -> purpur-1.17.1-1265.jar downloaded

This server is running Purpur version git-Purpur-1265 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) (Git: 2824f64 on HEAD)

LightAPI do not work, but no exceptions...

Does I need to set any property in configs to turn on Tunity Starlight?

Qveshn avatar Jul 15 '21 12:07 Qveshn

its on by default, this error i found only started appearing when interaction visualizer was used, https://www.spigotmc.org/resources/interactionvisualizer-visualize-function-blocks-entities-like-crafting-tables-with-animations.77050/

it seems to me like when interaction visualizer goes to call light API to delete light, that's when the error occurs

(ru.beykerykt.lightapi.LightAPI$2.run(LightAPI.java:375) ~[?:?] at ru.beykerykt.lightapi.LightAPI.deleteLight)

EuanM199 avatar Jul 15 '21 12:07 EuanM199

i alerted Spottedleaf (Starlight Dev) to this thread and they said this

Spottedleaf as of 1.17 I don't support custom light sources, as mojang has a custom light block

EuanM199 avatar Jul 15 '21 12:07 EuanM199

We have to talk a little in discord serjproch#3585 What is your native language?

Qveshn avatar Jul 15 '21 12:07 Qveshn

Sent, im english

EuanM199 avatar Jul 15 '21 12:07 EuanM199

Well, I can fix the bug, but I can not fix the problem yet 😟 The bug - is exception The problem - is that LightAPI incompatible with Tuinity Starlight and, therefore, purpur, tuinity and other starlight-based minecraft servers, Starlight completely removed mechanics to set custom lights in blocks. 😟

Qveshn avatar Jul 15 '21 20:07 Qveshn

Is there no way to set light levels in starlight? I'm looking into their code as well rn.

LOOHP avatar Jul 15 '21 20:07 LOOHP

@LOOHP They changed class LightEngineBlock and LightEngineSky to anonymous class from interface LayerLightEventListener. In addition, in this interface, the mechanics of setting the light were cut out, as well as a stub was put in other necessary methods like throw new UnsupportedOperationException();. I do not find workarround yet, 😟

But InteractionVisualizer will work fine because since 1.16.3 armo stands are not darkened in the blocks The exception was because: LightAPI.deleteLight(location, LightType.BLOCK, false); is without if (LightAPI.isSupported(location.getWorld(), LightType.BLOCK)) https://github.com/LOOHP/InteractionVisualizer/blob/bb302978828be64b54024dc11c74e663f8d806b8/src/main/java/com/loohp/interactionvisualizer/managers/LightManager.java#L139 You can add this check in LightManager, but I will also need to add this check inside deleteLight because it is also my mistake. Also, you can add configuration option like 'do-not-use-lightapi' and also softdepend in plugin.yml to LightAPI (instead hard depend)


Also I found error in InteractionVisualizer 1.16.2.6 with spigot 1.14.4:

java.lang.ClassCastException: org.bukkit.craftbukkit.v1_14_R1.block.impl.CraftCampfire cannot be cast to org.bukkit.block.data.Directional
	at com.loohp.interactionvisualizer.blocks.CampfireDisplay.spawnArmorStands(CampfireDisplay.java:381) ~[?:?]
	at com.loohp.interactionvisualizer.blocks.CampfireDisplay.lambda$run$2(CampfireDisplay.java:142) ~[?:?]
	at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftTask.run(CraftTask.java:81) ~[spigot-1.14.4.jar:git-Spigot-56f8471-56118c6]
	at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:394) [spigot-1.14.4.jar:git-Spigot-56f8471-56118c6]
	at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1022) [spigot-1.14.4.jar:git-Spigot-56f8471-56118c6]
	at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:393) [spigot-1.14.4.jar:git-Spigot-56f8471-56118c6]
	at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:970) [spigot-1.14.4.jar:git-Spigot-56f8471-56118c6]
	at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:815) [spigot-1.14.4.jar:git-Spigot-56f8471-56118c6]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212] 

Do I need to create issue?

Qveshn avatar Jul 15 '21 21:07 Qveshn

Also I found error in InteractionVisualizer 1.16.2.6 with spigot 1.14.4:

You could create an issue for that as I'm pretty sure org.bukkit.craftbukkit.block.impl.CraftCampfire implements org.bukkit.block.data.Directional. Are you using the last build of spigot 1.14.4?

https://helpch.at/docs/1.14.4/org/bukkit/block/data/type/Campfire.html

From the source created by buildtools:

package org.bukkit.craftbukkit.block.impl;

public final class CraftCampfire extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Campfire, org.bukkit.block.data.Directional, org.bukkit.block.data.Lightable, org.bukkit.block.data.Waterlogged {...}

LOOHP avatar Jul 16 '21 03:07 LOOHP

@LOOHP sorry, it really wasn't the last build. Works fine with the latest build 2502-b.

Qveshn avatar Jul 16 '21 08:07 Qveshn

@LOOHP sorry, it really wasn't the last build. Works fine with the latest build 2502-b.

No problem :)

They changed class LightEngineBlock and LightEngineSky to anonymous class from interface LayerLightEventListener. In addition, in this interface, the mechanics of setting the light were cut out, as well as a stub was put in other necessary methods like throw new UnsupportedOperationException();. I do not find workarround yet, 😟

Maybe discussing with the devs of starlight would make things easier?

LOOHP avatar Jul 16 '21 11:07 LOOHP

Maybe discussing with the devs of starlight would make things easier?

I will try. But I do not know what to say... "hI, I did what is forbidden to do: picked out the undocumented functions and private fields of the light engine in craftbukkit and used them to set lights, and now Starlight rewrote this engine and its implementation does not coincide with the Bukkit. What should I do now?" 😄 In addition, the developer in discord has already said "as of 1.17 I don't support custom light sources, as mojang has a custom light block" (although in 1.16 LightAPI plugin also quietly did not work with Starlight 😄).

But nevertheless, I will try ... My main arguments are:

  1. LIGHT BLOCK can be set only in the air (it is an independent block) while custom lights could be placed inside other blocks
  2. LIGHT BLOCK can emmit light only of LightType.BLOCK, while cutom lights can be set both for BLOCK and SKY types
  3. LIGHT BLOCK can be set only from min to max world height, while custom light can be set also in one section below and above world. This will allow to illuminate structures from the outside of the world.

Qveshn avatar Jul 16 '21 14:07 Qveshn

This issue is actually going to become pain in the rear to LightAPI now that Tunity is part of Paper which will now be using starlight. Or so I have heard (unconfirmed rumor). Since it seems the blame is pushed solely to starlight.

That is unless I have read something wrongly in the above and other opened/closed issues. Sadly closed means NOT FIXED.

EchocallingEarth avatar Sep 08 '21 19:09 EchocallingEarth

Probably this can be achieved by calling this function setLightLevel: https://github.com/PaperMC/Paper/blob/cc6fd371b2d1ab2ad1df85789b143f04a17c1468/patches/server/0763-Rewrite-the-light-engine.patch#L1811

LoneDev6 avatar Sep 20 '21 15:09 LoneDev6

Someone pointed out that upstream received a v5 release which seems to include Starlight support amongst other features. However, the release also mentions that the API has been rewritten, so this could be breaking...

The actual release: https://github.com/BeYkeRYkt/LightAPI/releases/tag/5.0.0-Bukkit

Andre601 avatar Nov 07 '21 23:11 Andre601

Someone pointed out that upstream received a v5 release which seems to include Starlight support amongst other features. However, the release also mentions that the API has been rewritten, so this could be breaking...

The actual release: https://github.com/BeYkeRYkt/LightAPI/releases/tag/5.0.0-Bukkit

I think it's better to wait some time due to the fact that there is no docs for the new API and I suspect it will be rewritten again.

LoneDev6 avatar Nov 09 '21 11:11 LoneDev6

I already gave my concerns on upstream in an issue.

Andre601 avatar Nov 09 '21 11:11 Andre601