Port to 1.21

This commit is contained in:
Linnea Gräf
2024-07-05 22:17:02 +02:00
parent 5ee4b8d925
commit 3d792dbef7
31 changed files with 126 additions and 119 deletions

View File

@@ -251,11 +251,11 @@ tasks.processResources {
tasks.scanLicenses { tasks.scanLicenses {
scanConfiguration(nonModImplentation) scanConfiguration(nonModImplentation)
scanConfiguration(configurations.modCompileClasspath.get()) scanConfiguration(configurations.modCompileClasspath.get())
outputFile.set(file("$buildDir/LICENSES-FIRMAMENT.json")) outputFile.set(layout.buildDirectory.file("LICENSES-FIRMAMENT.json"))
licenseFormatter.set(moe.nea.licenseextractificator.JsonLicenseFormatter()) licenseFormatter.set(moe.nea.licenseextractificator.JsonLicenseFormatter())
} }
tasks.create("printAllLicenses", LicenseDiscoveryTask::class.java, licensing).apply { tasks.create("printAllLicenses", LicenseDiscoveryTask::class.java, licensing).apply {
outputFile.set(file("$buildDir/LICENSES-FIRMAMENT.txt")) outputFile.set(layout.buildDirectory.file("LICENSES-FIRMAMENT.txt"))
licenseFormatter.set(moe.nea.licenseextractificator.TextLicenseFormatter()) licenseFormatter.set(moe.nea.licenseextractificator.TextLicenseFormatter())
scanConfiguration(nonModImplentation) scanConfiguration(nonModImplentation)
scanConfiguration(configurations.modCompileClasspath.get()) scanConfiguration(configurations.modCompileClasspath.get())
@@ -268,7 +268,3 @@ tasks.create("printAllLicenses", LicenseDiscoveryTask::class.java, licensing).ap
licensing.addExtraLicenseMatchers() licensing.addExtraLicenseMatchers()
fletchingTable.defaultMixinEnvironment.set("client") fletchingTable.defaultMixinEnvironment.set("client")
//vineflower {
// toolVersion.set("1.9.1")
//}

View File

@@ -3,23 +3,22 @@
# SPDX-License-Identifier: CC0-1.0 # SPDX-License-Identifier: CC0-1.0
[versions] [versions]
minecraft = "1.20.6" minecraft = "1.21"
fabric_loader = "0.15.11" fabric_loader = "0.15.11"
fabric_api = "0.97.8+1.20.6" fabric_api = "0.100.4+1.21"
fabric_kotlin = "1.10.19+kotlin.1.9.23" fabric_kotlin = "1.11.0+kotlin.2.0.0"
yarn = "1.20.6+build.1" yarn = "1.21+build.7"
libgui = "10.0.0+1.20.6" rei = "16.0.729"
rei = "15.0.728" modmenu = "11.0.1"
modmenu = "10.0.0-beta.1" architectury = "13.0.3"
architectury = "12.0.27"
qolify = "1.3.0-1.20.2" qolify = "1.3.0-1.20.2"
citresewn = "1.1.3+1.20" citresewn = "1.1.3+1.20"
sodium = "mc1.20.6-0.5.8" sodium = "mc1.21-0.5.11"
freecammod = "1.2.4+1.20.5" freecammod = "U5eR0FyR"
ncr = "Fabric-1.20.4-v2.5.0" ncr = "Fabric-1.21-v2.8.0"
explosiveenhancement = "1.2.2-1.20.x" explosiveenhancement = "1.2.3-1.21.0"
notenoughanimations = "roq966Ei" notenoughanimations = "WaI2x21x"
devauth = "1.2.0" devauth = "1.2.0"
ktor = "2.3.0" ktor = "2.3.0"
@@ -27,9 +26,9 @@ dbus_java = "4.2.1"
neurepoparser = "1.4.0" neurepoparser = "1.4.0"
hotswap_agent = "1.4.2-SNAPSHOT" hotswap_agent = "1.4.2-SNAPSHOT"
mixinextras = "0.3.5" mixinextras = "0.3.5"
jarvis = "1.1.1" jarvis = "1.1.3"
nealisp = "1.0.0" nealisp = "1.0.0"
moulconfig = "9999.9999.9999" moulconfig = "3.0.0-beta.13"
manninghamMills = "2.4.1" manninghamMills = "2.4.1"
[libraries] [libraries]

View File

@@ -30,21 +30,21 @@ import java.util.function.BiFunction;
public abstract class CustomModelBakerPatch { public abstract class CustomModelBakerPatch {
@Shadow @Shadow
protected abstract void addModel(ModelIdentifier modelId); protected abstract void loadItemModel(ModelIdentifier id);
@Shadow
abstract UnbakedModel getOrLoadModel(Identifier id);
@Shadow @Shadow
@Final @Final
private Map<Identifier, UnbakedModel> modelsToBake; private Map<ModelIdentifier, UnbakedModel> modelsToBake;
@Shadow
public abstract UnbakedModel getOrLoadModel(Identifier id);
@Inject(method = "bake", at = @At("HEAD")) @Inject(method = "bake", at = @At("HEAD"))
public void onBake(BiFunction<Identifier, SpriteIdentifier, Sprite> spriteLoader, CallbackInfo ci) { public void onBake(ModelLoader.SpriteGetter spliteGetter, CallbackInfo ci) {
BakeExtraModelsEvent.Companion.publish(new BakeExtraModelsEvent(this::addModel)); BakeExtraModelsEvent.Companion.publish(new BakeExtraModelsEvent(this::loadItemModel));
modelsToBake.values().forEach(model -> model.setParents(this::getOrLoadModel)); modelsToBake.values().forEach(model -> model.setParents(this::getOrLoadModel));
modelsToBake.keySet().stream() // modelsToBake.keySet().stream()
.filter(it -> !it.getNamespace().equals("minecraft")) // .filter(it -> !it.id().getNamespace().equals("minecraft"))
.forEach(it -> System.out.println("Non minecraft texture is being loaded: " + it)); // .forEach(it -> System.out.println("Non minecraft texture is being loaded: " + it));
} }
} }

View File

@@ -11,6 +11,7 @@ import moe.nea.firmament.events.HotbarItemRenderEvent;
import moe.nea.firmament.events.HudRenderEvent; import moe.nea.firmament.events.HudRenderEvent;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -21,13 +22,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(InGameHud.class) @Mixin(InGameHud.class)
public class HudRenderEventsPatch { public class HudRenderEventsPatch {
@Inject(method = "renderSleepOverlay", at = @At(value = "HEAD")) @Inject(method = "renderSleepOverlay", at = @At(value = "HEAD"))
public void renderCallBack(DrawContext context, float tickDelta, CallbackInfo ci) { public void renderCallBack(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickDelta)); HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickCounter));
} }
@Inject(method = "renderHotbarItem", at = @At("HEAD")) @Inject(method = "renderHotbarItem", at = @At("HEAD"))
public void onRenderHotbarItem(DrawContext context, int x, int y, float tickDelta, PlayerEntity player, ItemStack stack, int seed, CallbackInfo ci) { public void onRenderHotbarItem(DrawContext context, int x, int y, RenderTickCounter tickCounter, PlayerEntity player, ItemStack stack, int seed, CallbackInfo ci) {
if (stack != null && !stack.isEmpty()) if (stack != null && !stack.isEmpty())
HotbarItemRenderEvent.Companion.publish(new HotbarItemRenderEvent(stack, context, x, y, tickDelta)); HotbarItemRenderEvent.Companion.publish(new HotbarItemRenderEvent(stack, context, x, y, tickCounter));
} }
} }

View File

@@ -11,6 +11,7 @@ import com.llamalad7.mixinextras.sugar.Local;
import moe.nea.firmament.events.WorldRenderLastEvent; import moe.nea.firmament.events.WorldRenderLastEvent;
import net.minecraft.client.render.*; import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.world.tick.TickManager;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -26,10 +27,13 @@ public class WorldRenderLastEventPatch {
private BufferBuilderStorage bufferBuilders; private BufferBuilderStorage bufferBuilders;
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.BEFORE)) @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.BEFORE))
public void onWorldRenderLast(float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci public void onWorldRenderLast(
, @Local MatrixStack matrixStack) { RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer,
LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2,
CallbackInfo ci, @Local MatrixStack matrixStack
) {
var event = new WorldRenderLastEvent( var event = new WorldRenderLastEvent(
matrixStack, tickDelta, renderBlockOutline, matrixStack, tickCounter, renderBlockOutline,
camera, gameRenderer, lightmapTextureManager, camera, gameRenderer, lightmapTextureManager,
this.bufferBuilders.getEntityVertexConsumers() this.bufferBuilders.getEntityVertexConsumers()
); );

View File

@@ -6,7 +6,6 @@
package moe.nea.firmament.mixins.accessor; package moe.nea.firmament.mixins.accessor;
import kotlin.Deprecated;
import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@@ -145,8 +145,8 @@ object Firmament {
globalJob.cancel() globalJob.cancel()
}) })
registerFirmamentEvents() registerFirmamentEvents()
ItemTooltipCallback.EVENT.register { a, b, c, d -> ItemTooltipCallback.EVENT.register { stack, context, type, lines ->
ItemTooltipEvent.publish(ItemTooltipEvent(a, b, c, d)) ItemTooltipEvent.publish(ItemTooltipEvent(stack, context, type, lines))
} }
ScreenEvents.AFTER_INIT.register(ScreenEvents.AfterInit { client, screen, scaledWidth, scaledHeight -> ScreenEvents.AFTER_INIT.register(ScreenEvents.AfterInit { client, screen, scaledWidth, scaledHeight ->
ScreenEvents.afterRender(screen) ScreenEvents.afterRender(screen)
@@ -157,7 +157,7 @@ object Firmament {
} }
fun identifier(path: String) = Identifier(MOD_ID, path) fun identifier(path: String) = Identifier.of(MOD_ID, path)
inline fun <reified T : Any> tryDecodeJsonFromStream(inputStream: InputStream): Result<T> { inline fun <reified T : Any> tryDecodeJsonFromStream(inputStream: InputStream): Result<T> {
return runCatching { return runCatching {
json.decodeFromStream<T>(inputStream) json.decodeFromStream<T>(inputStream)

View File

@@ -12,6 +12,7 @@ import net.minecraft.network.PacketByteBuf
import net.minecraft.network.codec.PacketCodec import net.minecraft.network.codec.PacketCodec
import net.minecraft.network.codec.PacketCodecs import net.minecraft.network.codec.PacketCodecs
import net.minecraft.network.packet.CustomPayload import net.minecraft.network.packet.CustomPayload
import net.minecraft.util.Identifier
import net.minecraft.util.Uuids import net.minecraft.util.Uuids
import moe.nea.firmament.apis.ingame.FirmamentCustomPayload import moe.nea.firmament.apis.ingame.FirmamentCustomPayload
@@ -19,6 +20,10 @@ interface FirmamentCustomPayloadMeta<T : FirmamentCustomPayload> {
val ID: CustomPayload.Id<T> val ID: CustomPayload.Id<T>
val CODEC: PacketCodec<PacketByteBuf, T> val CODEC: PacketCodec<PacketByteBuf, T>
fun id(name: String): CustomPayload.Id<T> {
return CustomPayload.Id<T>(Identifier.of(name))
}
fun intoType(): CustomPayload.Type<PacketByteBuf, T> { fun intoType(): CustomPayload.Type<PacketByteBuf, T> {
return CustomPayload.Type(ID, CODEC) return CustomPayload.Type(ID, CODEC)
} }
@@ -26,7 +31,7 @@ interface FirmamentCustomPayloadMeta<T : FirmamentCustomPayload> {
data class PartyInfoRequest(val version: Int) : FirmamentCustomPayload { data class PartyInfoRequest(val version: Int) : FirmamentCustomPayload {
companion object : FirmamentCustomPayloadMeta<PartyInfoRequest> { companion object : FirmamentCustomPayloadMeta<PartyInfoRequest> {
override val ID = CustomPayload.id<PartyInfoRequest>("hypixel:party_info") override val ID = id("hypixel:party_info")
override val CODEC = override val CODEC =
PacketCodecs.VAR_INT.cast<PacketByteBuf>() PacketCodecs.VAR_INT.cast<PacketByteBuf>()
.xmap(::PartyInfoRequest, PartyInfoRequest::version) .xmap(::PartyInfoRequest, PartyInfoRequest::version)
@@ -116,7 +121,7 @@ data class PartyInfoResponseV1(
data class PartyInfoResponse(val data: HypixelVersionedPacketData<PartyInfoResponseV>) : FirmamentCustomPayload { data class PartyInfoResponse(val data: HypixelVersionedPacketData<PartyInfoResponseV>) : FirmamentCustomPayload {
companion object : FirmamentCustomPayloadMeta<PartyInfoResponse> { companion object : FirmamentCustomPayloadMeta<PartyInfoResponse> {
override val ID: CustomPayload.Id<PartyInfoResponse> = CustomPayload.id("hypixel:party_info") override val ID = id("hypixel:party_info")
override val CODEC = override val CODEC =
CodecUtils CodecUtils
.dispatchVersioned<PacketByteBuf, PartyInfoResponseV>( .dispatchVersioned<PacketByteBuf, PartyInfoResponseV>(

View File

@@ -7,14 +7,15 @@
package moe.nea.firmament.events package moe.nea.firmament.events
import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.DrawContext
import net.minecraft.client.render.RenderTickCounter
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
data class HotbarItemRenderEvent( data class HotbarItemRenderEvent(
val item: ItemStack, val item: ItemStack,
val context: DrawContext, val context: DrawContext,
val x: Int, val x: Int,
val y: Int, val y: Int,
val tickDelta: Float, val tickDelta: RenderTickCounter,
) : FirmamentEvent() { ) : FirmamentEvent() {
companion object : FirmamentEventBus<HotbarItemRenderEvent>() companion object : FirmamentEventBus<HotbarItemRenderEvent>()
} }

View File

@@ -7,10 +7,11 @@
package moe.nea.firmament.events package moe.nea.firmament.events
import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.DrawContext
import net.minecraft.client.render.RenderTickCounter
/** /**
* Called when hud elements should be rendered, before the screen, but after the world. * Called when hud elements should be rendered, before the screen, but after the world.
*/ */
data class HudRenderEvent(val context: DrawContext, val tickDelta: Float) : FirmamentEvent() { data class HudRenderEvent(val context: DrawContext, val tickDelta: RenderTickCounter) : FirmamentEvent() {
companion object : FirmamentEventBus<HudRenderEvent>() companion object : FirmamentEventBus<HudRenderEvent>()
} }

View File

@@ -7,9 +7,9 @@
package moe.nea.firmament.events package moe.nea.firmament.events
import net.minecraft.client.item.TooltipType
import net.minecraft.item.Item.TooltipContext import net.minecraft.item.Item.TooltipContext
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.item.tooltip.TooltipType
import net.minecraft.text.Text import net.minecraft.text.Text
data class ItemTooltipEvent( data class ItemTooltipEvent(

View File

@@ -7,10 +7,10 @@
package moe.nea.firmament.events package moe.nea.firmament.events
import org.joml.Matrix4f
import net.minecraft.client.render.Camera import net.minecraft.client.render.Camera
import net.minecraft.client.render.GameRenderer import net.minecraft.client.render.GameRenderer
import net.minecraft.client.render.LightmapTextureManager import net.minecraft.client.render.LightmapTextureManager
import net.minecraft.client.render.RenderTickCounter
import net.minecraft.client.render.VertexConsumerProvider import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.util.math.MatrixStack import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.Position import net.minecraft.util.math.Position
@@ -21,7 +21,7 @@ import net.minecraft.util.math.Vec3d
*/ */
data class WorldRenderLastEvent( data class WorldRenderLastEvent(
val matrices: MatrixStack, val matrices: MatrixStack,
val tickDelta: Float, val tickCounter: RenderTickCounter,
val renderBlockOutline: Boolean, val renderBlockOutline: Boolean,
val camera: Camera, val camera: Camera,
val gameRenderer: GameRenderer, val gameRenderer: GameRenderer,
@@ -29,8 +29,4 @@ data class WorldRenderLastEvent(
val vertexConsumers: VertexConsumerProvider.Immediate, val vertexConsumers: VertexConsumerProvider.Immediate,
) : FirmamentEvent() { ) : FirmamentEvent() {
companion object : FirmamentEventBus<WorldRenderLastEvent>() companion object : FirmamentEventBus<WorldRenderLastEvent>()
data class TextRenderCall(val string: String, val position: Position)
val toRender = mutableListOf<TextRenderCall>(TextRenderCall("Test String", Vec3d(0.0, 0.0, 0.0)))
} }

View File

@@ -68,7 +68,7 @@ object ItemRarityCosmetics : FirmamentFeature {
x, y, x, y,
0, 0,
16, 16, 16, 16,
MC.guiAtlasManager.getSprite(Identifier("firmament:item_rarity_background")), MC.guiAtlasManager.getSprite(Identifier.of("firmament:item_rarity_background")),
r, g, b, 1F r, g, b, 1F
) )
} }

View File

@@ -190,10 +190,10 @@ object SlotLocking : FirmamentFeature {
MC.guiAtlasManager.getSprite( MC.guiAtlasManager.getSprite(
when { when {
isSlotLocked -> isSlotLocked ->
(Identifier("firmament:slot_locked")) (Identifier.of("firmament:slot_locked"))
isUUIDLocked -> isUUIDLocked ->
(Identifier("firmament:uuid_locked")) (Identifier.of("firmament:uuid_locked"))
else -> else ->
error("unreachable") error("unreachable")

View File

@@ -42,7 +42,7 @@ data class InventoryButton(
0, 0,
dimensions.width, dimensions.width,
dimensions.height, dimensions.height,
MC.guiAtlasManager.getSprite(Identifier("firmament:inventory_button_background")) MC.guiAtlasManager.getSprite(Identifier.of("firmament:inventory_button_background"))
) )
context.drawItem(getItem(), 1, 1) context.drawItem(getItem(), 1, 1)
} }

View File

@@ -172,7 +172,7 @@ object PickaxeAbility : FirmamentFeature {
event.context.matrices.translate(MC.window.scaledWidth / 2F, MC.window.scaledHeight / 2F, 0F) event.context.matrices.translate(MC.window.scaledWidth / 2F, MC.window.scaledHeight / 2F, 0F)
event.context.matrices.scale(TConfig.cooldownScale.toFloat(), TConfig.cooldownScale.toFloat(), 1F) event.context.matrices.scale(TConfig.cooldownScale.toFloat(), TConfig.cooldownScale.toFloat(), 1F)
RenderCircleProgress.renderCircle( RenderCircleProgress.renderCircle(
event.context, Identifier("firmament", "textures/gui/circle.png"), event.context, Identifier.of("firmament", "textures/gui/circle.png"),
getCooldownPercentage(ability.name, ability.cooldown).toFloat(), getCooldownPercentage(ability.name, ability.cooldown).toFloat(),
0f, 1f, 0f, 1f 0f, 1f, 0f, 1f
) )

View File

@@ -117,7 +117,7 @@ object CustomGlobalTextures : SinglePreparationResourceReloader<CustomGlobalText
.mapNotNull { .mapNotNull {
val key = it.key val key = it.key
val guiClassResource = val guiClassResource =
manager.getResource(Identifier(key.namespace, "filters/screen/${key.path}.json")) manager.getResource(Identifier.of(key.namespace, "filters/screen/${key.path}.json"))
.getOrNull() .getOrNull()
?: return@mapNotNull runNull { ?: return@mapNotNull runNull {
logger.error("Failed to locate screen filter at $key") logger.error("Failed to locate screen filter at $key")

View File

@@ -34,7 +34,7 @@ object CustomModelOverrideParser {
fun registerPredicateParser(name: String, parser: FirmamentModelPredicateParser) { fun registerPredicateParser(name: String, parser: FirmamentModelPredicateParser) {
predicateParsers[Identifier("firmament", name)] = parser predicateParsers[Identifier.of("firmament", name)] = parser
} }
init { init {
@@ -59,7 +59,7 @@ object CustomModelOverrideParser {
val parsedPredicates = mutableListOf<FirmamentModelPredicate>() val parsedPredicates = mutableListOf<FirmamentModelPredicate>()
for (predicateName in predicates.keySet()) { for (predicateName in predicates.keySet()) {
if (!predicateName.startsWith("firmament:")) continue if (!predicateName.startsWith("firmament:")) continue
val identifier = Identifier(predicateName) val identifier = Identifier.of(predicateName)
val parser = predicateParsers[identifier] ?: return neverPredicate val parser = predicateParsers[identifier] ?: return neverPredicate
val parsedPredicate = parser.parse(predicates[predicateName]) ?: return neverPredicate val parsedPredicate = parser.parse(predicates[predicateName]) ?: return neverPredicate
parsedPredicates.add(parsedPredicate) parsedPredicates.add(parsedPredicate)

View File

@@ -9,7 +9,6 @@ package moe.nea.firmament.features.texturepack
import com.mojang.authlib.minecraft.MinecraftProfileTexture import com.mojang.authlib.minecraft.MinecraftProfileTexture
import com.mojang.authlib.properties.Property import com.mojang.authlib.properties.Property
import net.fabricmc.fabric.api.entity.event.v1.EntityElytraEvents.Custom
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
import net.minecraft.block.SkullBlock import net.minecraft.block.SkullBlock
import net.minecraft.client.MinecraftClient import net.minecraft.client.MinecraftClient
@@ -62,10 +61,13 @@ object CustomSkyBlockTextures : FirmamentFeature {
.endsWith(".json") .endsWith(".json")
} }
for (identifier in resources.keys) { for (identifier in resources.keys) {
val modelId = ModelIdentifier("firmskyblock", val modelId = ModelIdentifier.ofInventoryVariant(
identifier.path.substring("models/item/".length, Identifier.of(
identifier.path.length - ".json".length), "firmskyblock",
"inventory") identifier.path.substring(
"models/item/".length,
identifier.path.length - ".json".length),
))
event.addModel(modelId) event.addModel(modelId)
} }
} }
@@ -74,7 +76,7 @@ object CustomSkyBlockTextures : FirmamentFeature {
fun onCustomModelId(it: CustomItemModelEvent) { fun onCustomModelId(it: CustomItemModelEvent) {
if (!TConfig.enabled) return if (!TConfig.enabled) return
val id = it.itemStack.skyBlockId ?: return val id = it.itemStack.skyBlockId ?: return
it.overrideModel = ModelIdentifier("firmskyblock", id.identifier.path, "inventory") it.overrideModel = ModelIdentifier.ofInventoryVariant(Identifier.of("firmskyblock", id.identifier.path))
} }
private val skullTextureCache = mutableMapOf<IdentityCharacteristics<ProfileComponent>, Any>() private val skullTextureCache = mutableMapOf<IdentityCharacteristics<ProfileComponent>, Any>()
@@ -92,7 +94,7 @@ object CustomSkyBlockTextures : FirmamentFeature {
fun getSkullTexture(profile: ProfileComponent): Identifier? { fun getSkullTexture(profile: ProfileComponent): Identifier? {
val id = getSkullId(profile.properties["textures"].firstOrNull() ?: return null) ?: return null val id = getSkullId(profile.properties["textures"].firstOrNull() ?: return null) ?: return null
return Identifier("firmskyblock", "textures/placedskull/$id.png") return Identifier.of("firmskyblock", "textures/placedskull/$id.png")
} }
fun modifySkullTexture( fun modifySkullTexture(

View File

@@ -129,6 +129,10 @@ fun <T> makeRegistry(registryWrapper: RegistryWrapper.Impl<T>, key: RegistryKey<
return Lifecycle.stable() return Lifecycle.stable()
} }
override fun getDefaultEntry(): Optional<RegistryEntry.Reference<T>> {
return Optional.empty()
}
override fun getIds(): MutableSet<Identifier> { override fun getIds(): MutableSet<Identifier> {
return idLookup.keys.mapTo(mutableSetOf()) { it.value } return idLookup.keys.mapTo(mutableSetOf()) { it.value }
} }
@@ -251,7 +255,7 @@ class FakeWorld(
registries[RegistryKeys.DIMENSION_TYPE].entryOf( registries[RegistryKeys.DIMENSION_TYPE].entryOf(
RegistryKey.of( RegistryKey.of(
RegistryKeys.DIMENSION_TYPE, RegistryKeys.DIMENSION_TYPE,
Identifier("minecraft", "overworld") Identifier.of("minecraft", "overworld")
) )
), ),
{ DummyProfiler.INSTANCE }, { DummyProfiler.INSTANCE },
@@ -436,7 +440,7 @@ class FakeWorld(
override fun putMapState(id: MapIdComponent?, state: MapState?) { override fun putMapState(id: MapIdComponent?, state: MapState?) {
} }
override fun getNextMapId(): MapIdComponent { override fun increaseAndGetMapId(): MapIdComponent {
return MapIdComponent(0) return MapIdComponent(0)
} }

View File

@@ -15,10 +15,10 @@ object ModifyPlayerSkin : EntityModifier {
override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity { override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
require(entity is GuiPlayer) require(entity is GuiPlayer)
info["cape"]?.let { info["cape"]?.let {
entity.capeTexture = Identifier(it.asString) entity.capeTexture = Identifier.of(it.asString)
} }
info["skin"]?.let { info["skin"]?.let {
entity.skinTexture = Identifier(it.asString) entity.skinTexture = Identifier.of(it.asString)
} }
info["slim"]?.let { info["slim"]?.let {
entity.model = if (it.asBoolean) SkinTextures.Model.SLIM else SkinTextures.Model.WIDE entity.model = if (it.asBoolean) SkinTextures.Model.SLIM else SkinTextures.Model.WIDE

View File

@@ -42,7 +42,7 @@ class FirmamentReiPlugin : REIClientPlugin {
return EntryStack.of(VanillaEntryTypes.ITEM, value.asImmutableItemStack()) return EntryStack.of(VanillaEntryTypes.ITEM, value.asImmutableItemStack())
} }
val SKYBLOCK_ITEM_TYPE_ID = Identifier("firmament", "skyblockitems") val SKYBLOCK_ITEM_TYPE_ID = Identifier.of("firmament", "skyblockitems")
} }
override fun registerTransferHandlers(registry: TransferHandlerRegistry) { override fun registerTransferHandlers(registry: TransferHandlerRegistry) {
registry.register(TransferHandler { context -> registry.register(TransferHandler { context ->

View File

@@ -20,7 +20,6 @@ import me.shedaniel.rei.api.client.gui.widgets.TooltipContext
import me.shedaniel.rei.api.common.entry.EntryStack import me.shedaniel.rei.api.common.entry.EntryStack
import net.minecraft.client.MinecraftClient import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.DrawContext
import net.minecraft.client.item.TooltipType
import net.minecraft.client.render.DiffuseLighting import net.minecraft.client.render.DiffuseLighting
import net.minecraft.client.render.LightmapTextureManager import net.minecraft.client.render.LightmapTextureManager
import net.minecraft.client.render.OverlayTexture import net.minecraft.client.render.OverlayTexture
@@ -30,6 +29,7 @@ import net.minecraft.client.render.model.json.ModelTransformationMode
import net.minecraft.client.texture.SpriteAtlasTexture import net.minecraft.client.texture.SpriteAtlasTexture
import net.minecraft.item.Item import net.minecraft.item.Item
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.item.tooltip.TooltipType
import moe.nea.firmament.rei.FirmamentReiPlugin.Companion.asItemEntry import moe.nea.firmament.rei.FirmamentReiPlugin.Companion.asItemEntry
object NEUItemEntryRenderer : EntryRenderer<SBItemStack>, BatchedEntryRenderer<SBItemStack, BakedModel> { object NEUItemEntryRenderer : EntryRenderer<SBItemStack>, BatchedEntryRenderer<SBItemStack, BakedModel> {

View File

@@ -41,7 +41,7 @@ class SBMobDropRecipe(override val neuRecipe: NEUMobDropRecipe) : SBRecipe() {
add(Widgets.createRecipeBase(bounds)) add(Widgets.createRecipeBase(bounds))
val source = display.neuRecipe.render val source = display.neuRecipe.render
val entity = if (source.startsWith("@")) { val entity = if (source.startsWith("@")) {
EntityRenderer.constructEntity(Identifier(source.substring(1))) EntityRenderer.constructEntity(Identifier.of(source.substring(1)))
} else { } else {
EntityRenderer.applyModifiers(source, listOf()) EntityRenderer.applyModifiers(source, listOf())
} }

View File

@@ -17,7 +17,7 @@ object CommonSoundEffects {
} }
fun playFailure() { fun playFailure() {
playSound(Identifier("minecraft", "block.anvil.place")) playSound(Identifier.of("minecraft", "block.anvil.place"))
} }
fun playSuccess() { fun playSuccess() {
@@ -25,6 +25,6 @@ object CommonSoundEffects {
} }
fun playDing() { fun playDing() {
playSound(Identifier("minecraft", "entity.arrow.hit_player")) playSound(Identifier.of("minecraft", "entity.arrow.hit_player"))
} }
} }

View File

@@ -19,7 +19,7 @@ object IdentifierSerializer : KSerializer<Identifier> {
get() = SerialDescriptor("Identifier", delegateSerializer.descriptor) get() = SerialDescriptor("Identifier", delegateSerializer.descriptor)
override fun deserialize(decoder: Decoder): Identifier { override fun deserialize(decoder: Decoder): Identifier {
return Identifier(decoder.decodeSerializableValue(delegateSerializer)) return Identifier.of(decoder.decodeSerializableValue(delegateSerializer))
} }
override fun serialize(encoder: Encoder, value: Identifier) { override fun serialize(encoder: Encoder, value: Identifier) {

View File

@@ -31,7 +31,7 @@ import moe.nea.firmament.util.json.DashlessUUIDSerializer
@Serializable @Serializable
value class SkyblockId(val neuItem: String) { value class SkyblockId(val neuItem: String) {
val identifier val identifier
get() = Identifier("skyblockitem", get() = Identifier.of("skyblockitem",
neuItem.lowercase().replace(";", "__") neuItem.lowercase().replace(";", "__")
.replace(":", "___") .replace(":", "___")
.replace(illlegalPathRegex) { .replace(illlegalPathRegex) {

View File

@@ -7,6 +7,7 @@
package moe.nea.firmament.util.render package moe.nea.firmament.util.render
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import io.github.notenoughupdates.moulconfig.platform.next
import org.joml.Matrix4f import org.joml.Matrix4f
import net.minecraft.client.font.TextRenderer import net.minecraft.client.font.TextRenderer
import net.minecraft.client.render.BufferRenderer import net.minecraft.client.render.BufferRenderer
@@ -80,22 +81,24 @@ class FacingThePlayerContext(val worldContext: RenderInWorldContext) {
u2: Float, v2: Float, u2: Float, v2: Float,
) { ) {
RenderSystem.setShaderTexture(0, texture) RenderSystem.setShaderTexture(0, texture)
RenderSystem.setShader(GameRenderer::getPositionColorTexProgram) RenderSystem.setShader(GameRenderer::getPositionTexColorProgram)
val hw = width / 2F val hw = width / 2F
val hh = height / 2F val hh = height / 2F
val matrix4f: Matrix4f = worldContext.matrixStack.peek().positionMatrix val matrix4f: Matrix4f = worldContext.matrixStack.peek().positionMatrix
val buf = Tessellator.getInstance().buffer val buf = Tessellator.getInstance()
buf.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE) .begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR)
buf.fixedColor(255, 255, 255, 255)
buf.vertex(matrix4f, -hw, -hh, 0F) buf.vertex(matrix4f, -hw, -hh, 0F)
.color(-1)
.texture(u1, v1).next() .texture(u1, v1).next()
buf.vertex(matrix4f, -hw, +hh, 0F) buf.vertex(matrix4f, -hw, +hh, 0F)
.color(-1)
.texture(u1, v2).next() .texture(u1, v2).next()
buf.vertex(matrix4f, +hw, +hh, 0F) buf.vertex(matrix4f, +hw, +hh, 0F)
.color(-1)
.texture(u2, v2).next() .texture(u2, v2).next()
buf.vertex(matrix4f, +hw, -hh, 0F) buf.vertex(matrix4f, +hw, -hh, 0F)
.color(-1)
.texture(u2, v1).next() .texture(u2, v1).next()
buf.unfixColor()
BufferRenderer.drawWithGlobalProgram(buf.end()) BufferRenderer.drawWithGlobalProgram(buf.end())
} }

View File

@@ -7,6 +7,7 @@
package moe.nea.firmament.util.render package moe.nea.firmament.util.render
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import io.github.notenoughupdates.moulconfig.platform.next
import org.joml.Matrix4f import org.joml.Matrix4f
import org.joml.Vector2f import org.joml.Vector2f
import kotlin.math.atan2 import kotlin.math.atan2
@@ -31,12 +32,10 @@ object RenderCircleProgress {
v2: Float, v2: Float,
) { ) {
RenderSystem.setShaderTexture(0, texture) RenderSystem.setShaderTexture(0, texture)
RenderSystem.setShader { GameRenderer.getPositionColorTexProgram() } RenderSystem.setShader(GameRenderer::getPositionTexColorProgram)
RenderSystem.enableBlend() RenderSystem.enableBlend()
val matrix: Matrix4f = drawContext.matrices.peek().positionMatrix val matrix: Matrix4f = drawContext.matrices.peek().positionMatrix
val bufferBuilder = Tessellator.getInstance().buffer val bufferBuilder = Tessellator.getInstance().begin(DrawMode.TRIANGLES, VertexFormats.POSITION_TEXTURE_COLOR)
bufferBuilder.begin(DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR_TEXTURE)
bufferBuilder.fixedColor(255, 255, 255, 255)
val corners = listOf( val corners = listOf(
Vector2f(0F, -1F), Vector2f(0F, -1F),
@@ -79,17 +78,19 @@ object RenderCircleProgress {
bufferBuilder bufferBuilder
.vertex(matrix, second.x, second.y, 0F) .vertex(matrix, second.x, second.y, 0F)
.texture(lerp(u1, u2, ilerp(second.x)), lerp(v1, v2, ilerp(second.y))) .texture(lerp(u1, u2, ilerp(second.x)), lerp(v1, v2, ilerp(second.y)))
.color(-1)
.next() .next()
bufferBuilder bufferBuilder
.vertex(matrix, first.x, first.y, 0F) .vertex(matrix, first.x, first.y, 0F)
.texture(lerp(u1, u2, ilerp(first.x)), lerp(v1, v2, ilerp(first.y))) .texture(lerp(u1, u2, ilerp(first.x)), lerp(v1, v2, ilerp(first.y)))
.color(-1)
.next() .next()
bufferBuilder bufferBuilder
.vertex(matrix, 0F, 0F, 0F) .vertex(matrix, 0F, 0F, 0F)
.texture(lerp(u1, u2, ilerp(0F)), lerp(v1, v2, ilerp(0F))) .texture(lerp(u1, u2, ilerp(0F)), lerp(v1, v2, ilerp(0F)))
.color(-1)
.next() .next()
} }
bufferBuilder.unfixColor()
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()) BufferRenderer.drawWithGlobalProgram(bufferBuilder.end())
RenderSystem.disableBlend() RenderSystem.disableBlend()
} }

View File

@@ -8,15 +8,16 @@
package moe.nea.firmament.util.render package moe.nea.firmament.util.render
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import io.github.notenoughupdates.moulconfig.platform.next
import java.lang.Math.pow import java.lang.Math.pow
import java.lang.Math.toRadians
import org.joml.Matrix4f import org.joml.Matrix4f
import org.joml.Vector3f import org.joml.Vector3f
import kotlin.math.tan
import net.minecraft.client.gl.VertexBuffer import net.minecraft.client.gl.VertexBuffer
import net.minecraft.client.render.BufferBuilder import net.minecraft.client.render.BufferBuilder
import net.minecraft.client.render.BufferRenderer
import net.minecraft.client.render.Camera import net.minecraft.client.render.Camera
import net.minecraft.client.render.GameRenderer import net.minecraft.client.render.GameRenderer
import net.minecraft.client.render.RenderTickCounter
import net.minecraft.client.render.Tessellator import net.minecraft.client.render.Tessellator
import net.minecraft.client.render.VertexConsumerProvider import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.VertexFormat import net.minecraft.client.render.VertexFormat
@@ -28,7 +29,6 @@ import net.minecraft.util.Identifier
import net.minecraft.util.math.BlockPos import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Vec3d import net.minecraft.util.math.Vec3d
import moe.nea.firmament.events.WorldRenderLastEvent import moe.nea.firmament.events.WorldRenderLastEvent
import moe.nea.firmament.mixins.accessor.AccessorGameRenderer
import moe.nea.firmament.util.FirmFormatters import moe.nea.firmament.util.FirmFormatters
import moe.nea.firmament.util.MC import moe.nea.firmament.util.MC
@@ -37,12 +37,9 @@ class RenderInWorldContext private constructor(
private val tesselator: Tessellator, private val tesselator: Tessellator,
val matrixStack: MatrixStack, val matrixStack: MatrixStack,
private val camera: Camera, private val camera: Camera,
private val tickDelta: Float, private val tickCounter: RenderTickCounter,
val vertexConsumers: VertexConsumerProvider.Immediate, val vertexConsumers: VertexConsumerProvider.Immediate,
) { ) {
private val buffer = tesselator.buffer
val effectiveFov = (MC.instance.gameRenderer as AccessorGameRenderer).getFov_firmament(camera, tickDelta, true)
val effectiveFovScaleFactor = 1 / tan(toRadians(effectiveFov) / 2)
fun color(color: me.shedaniel.math.Color) { fun color(color: me.shedaniel.math.Color) {
color(color.red / 255F, color.green / 255f, color.blue / 255f, color.alpha / 255f) color(color.red / 255F, color.green / 255f, color.blue / 255f, color.alpha / 255f)
@@ -56,8 +53,7 @@ class RenderInWorldContext private constructor(
RenderSystem.setShader(GameRenderer::getPositionColorProgram) RenderSystem.setShader(GameRenderer::getPositionColorProgram)
matrixStack.push() matrixStack.push()
matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat()) matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat())
buildCube(matrixStack.peek().positionMatrix, buffer) buildCube(matrixStack.peek().positionMatrix, tesselator)
tesselator.draw()
matrixStack.pop() matrixStack.pop()
} }
@@ -125,8 +121,7 @@ class RenderInWorldContext private constructor(
matrixStack.translate(vec3d.x, vec3d.y, vec3d.z) matrixStack.translate(vec3d.x, vec3d.y, vec3d.z)
matrixStack.scale(size, size, size) matrixStack.scale(size, size, size)
matrixStack.translate(-.5, -.5, -.5) matrixStack.translate(-.5, -.5, -.5)
buildCube(matrixStack.peek().positionMatrix, buffer) buildCube(matrixStack.peek().positionMatrix, tesselator)
tesselator.draw()
matrixStack.pop() matrixStack.pop()
} }
@@ -135,8 +130,7 @@ class RenderInWorldContext private constructor(
matrixStack.push() matrixStack.push()
RenderSystem.lineWidth(lineWidth / pow(camera.pos.squaredDistanceTo(blockPos.toCenterPos()), 0.25).toFloat()) RenderSystem.lineWidth(lineWidth / pow(camera.pos.squaredDistanceTo(blockPos.toCenterPos()), 0.25).toFloat())
matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat()) matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat())
buildWireFrameCube(matrixStack.peek(), buffer) buildWireFrameCube(matrixStack.peek(), tesselator)
tesselator.draw()
matrixStack.pop() matrixStack.pop()
} }
@@ -152,8 +146,7 @@ class RenderInWorldContext private constructor(
fun line(points: List<Vec3d>, lineWidth: Float = 10F) { fun line(points: List<Vec3d>, lineWidth: Float = 10F) {
RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram) RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram)
RenderSystem.lineWidth(lineWidth) RenderSystem.lineWidth(lineWidth)
buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES) val buffer = tesselator.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES)
buffer.fixedColor(255, 255, 255, 255)
val matrix = matrixStack.peek() val matrix = matrixStack.peek()
var lastNormal: Vector3f? = null var lastNormal: Vector3f? = null
@@ -170,9 +163,8 @@ class RenderInWorldContext private constructor(
.normal(matrix, normal.x, normal.y, normal.z) .normal(matrix, normal.x, normal.y, normal.z)
.next() .next()
} }
buffer.unfixColor()
tesselator.draw() BufferRenderer.drawWithGlobalProgram(buffer.end())
} }
companion object { companion object {
@@ -191,16 +183,17 @@ class RenderInWorldContext private constructor(
.normalize() .normalize()
buf.vertex(matrix.positionMatrix, i, j, k) buf.vertex(matrix.positionMatrix, i, j, k)
.normal(matrix, normal.x, normal.y, normal.z) .normal(matrix, normal.x, normal.y, normal.z)
.color(-1)
.next() .next()
buf.vertex(matrix.positionMatrix, x, y, z) buf.vertex(matrix.positionMatrix, x, y, z)
.normal(matrix, normal.x, normal.y, normal.z) .normal(matrix, normal.x, normal.y, normal.z)
.color(-1)
.next() .next()
} }
private fun buildWireFrameCube(matrix: MatrixStack.Entry, buf: BufferBuilder) { private fun buildWireFrameCube(matrix: MatrixStack.Entry, tessellator: Tessellator) {
buf.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES) val buf = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES)
buf.fixedColor(255, 255, 255, 255)
for (i in 0..1) { for (i in 0..1) {
for (j in 0..1) { for (j in 0..1) {
@@ -211,12 +204,11 @@ class RenderInWorldContext private constructor(
doLine(matrix, buf, i, j, 0F, i, j, 1F) doLine(matrix, buf, i, j, 0F, i, j, 1F)
} }
} }
buf.unfixColor() BufferRenderer.drawWithGlobalProgram(buf.end())
} }
private fun buildCube(matrix: Matrix4f, buf: BufferBuilder) { private fun buildCube(matrix: Matrix4f, tessellator: Tessellator) {
buf.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR) val buf = tessellator.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION)
buf.fixedColor(255, 255, 255, 255)
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).next() buf.vertex(matrix, 0.0F, 0.0F, 0.0F).next()
buf.vertex(matrix, 0.0F, 0.0F, 1.0F).next() buf.vertex(matrix, 0.0F, 0.0F, 1.0F).next()
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).next() buf.vertex(matrix, 0.0F, 1.0F, 1.0F).next()
@@ -253,7 +245,7 @@ class RenderInWorldContext private constructor(
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).next() buf.vertex(matrix, 1.0F, 1.0F, 1.0F).next()
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).next() buf.vertex(matrix, 0.0F, 1.0F, 1.0F).next()
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).next() buf.vertex(matrix, 1.0F, 0.0F, 1.0F).next()
buf.unfixColor() BufferRenderer.drawWithGlobalProgram(buf.end())
} }
@@ -270,7 +262,7 @@ class RenderInWorldContext private constructor(
RenderSystem.renderThreadTesselator(), RenderSystem.renderThreadTesselator(),
event.matrices, event.matrices,
event.camera, event.camera,
event.tickDelta, event.tickCounter,
event.vertexConsumers event.vertexConsumers
) )

View File

@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
SPDX-FileCopyrightText: This texture is a derivative of textures from Minecraft by Mojang.
SPDX-License-Identifier: CC0-1.0