diff options
Diffstat (limited to 'src')
29 files changed, 109 insertions, 97 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java b/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java index 012a215..baffa4c 100644 --- a/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/CustomModelBakerPatch.java @@ -30,21 +30,21 @@ import java.util.function.BiFunction; public abstract class CustomModelBakerPatch { @Shadow - protected abstract void addModel(ModelIdentifier modelId); + protected abstract void loadItemModel(ModelIdentifier id); @Shadow - @Final - private Map<Identifier, UnbakedModel> modelsToBake; + abstract UnbakedModel getOrLoadModel(Identifier id); @Shadow - public abstract UnbakedModel getOrLoadModel(Identifier id); + @Final + private Map<ModelIdentifier, UnbakedModel> modelsToBake; @Inject(method = "bake", at = @At("HEAD")) - public void onBake(BiFunction<Identifier, SpriteIdentifier, Sprite> spriteLoader, CallbackInfo ci) { - BakeExtraModelsEvent.Companion.publish(new BakeExtraModelsEvent(this::addModel)); + public void onBake(ModelLoader.SpriteGetter spliteGetter, CallbackInfo ci) { + BakeExtraModelsEvent.Companion.publish(new BakeExtraModelsEvent(this::loadItemModel)); modelsToBake.values().forEach(model -> model.setParents(this::getOrLoadModel)); - modelsToBake.keySet().stream() - .filter(it -> !it.getNamespace().equals("minecraft")) - .forEach(it -> System.out.println("Non minecraft texture is being loaded: " + it)); +// modelsToBake.keySet().stream() +// .filter(it -> !it.id().getNamespace().equals("minecraft")) +// .forEach(it -> System.out.println("Non minecraft texture is being loaded: " + it)); } } diff --git a/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java b/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java index 6618e95..d1b7d92 100644 --- a/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java @@ -11,6 +11,7 @@ import moe.nea.firmament.events.HotbarItemRenderEvent; import moe.nea.firmament.events.HudRenderEvent; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; @@ -21,13 +22,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(InGameHud.class) public class HudRenderEventsPatch { @Inject(method = "renderSleepOverlay", at = @At(value = "HEAD")) - public void renderCallBack(DrawContext context, float tickDelta, CallbackInfo ci) { - HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickDelta)); + public void renderCallBack(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { + HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickCounter)); } @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()) - HotbarItemRenderEvent.Companion.publish(new HotbarItemRenderEvent(stack, context, x, y, tickDelta)); + HotbarItemRenderEvent.Companion.publish(new HotbarItemRenderEvent(stack, context, x, y, tickCounter)); } } diff --git a/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java b/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java index 1ad1ae8..f3ebba9 100644 --- a/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java @@ -11,6 +11,7 @@ import com.llamalad7.mixinextras.sugar.Local; import moe.nea.firmament.events.WorldRenderLastEvent; import net.minecraft.client.render.*; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.world.tick.TickManager; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -26,10 +27,13 @@ public class WorldRenderLastEventPatch { 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)) - public void onWorldRenderLast(float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci - , @Local MatrixStack matrixStack) { + public void onWorldRenderLast( + RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, + LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, + CallbackInfo ci, @Local MatrixStack matrixStack + ) { var event = new WorldRenderLastEvent( - matrixStack, tickDelta, renderBlockOutline, + matrixStack, tickCounter, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, this.bufferBuilders.getEntityVertexConsumers() ); diff --git a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java index f61aca3..2e9879d 100644 --- a/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java +++ b/src/main/java/moe/nea/firmament/mixins/accessor/AccessorHandledScreen.java @@ -6,7 +6,6 @@ package moe.nea.firmament.mixins.accessor; -import kotlin.Deprecated; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.screen.slot.Slot; import org.jetbrains.annotations.Nullable; diff --git a/src/main/kotlin/moe/nea/firmament/Firmament.kt b/src/main/kotlin/moe/nea/firmament/Firmament.kt index 630950a..9a04db1 100644 --- a/src/main/kotlin/moe/nea/firmament/Firmament.kt +++ b/src/main/kotlin/moe/nea/firmament/Firmament.kt @@ -145,8 +145,8 @@ object Firmament { globalJob.cancel() }) registerFirmamentEvents() - ItemTooltipCallback.EVENT.register { a, b, c, d -> - ItemTooltipEvent.publish(ItemTooltipEvent(a, b, c, d)) + ItemTooltipCallback.EVENT.register { stack, context, type, lines -> + ItemTooltipEvent.publish(ItemTooltipEvent(stack, context, type, lines)) } ScreenEvents.AFTER_INIT.register(ScreenEvents.AfterInit { client, screen, scaledWidth, scaledHeight -> 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> { return runCatching { json.decodeFromStream<T>(inputStream) diff --git a/src/main/kotlin/moe/nea/firmament/apis/ingame/packets/PartyInfoRequest.kt b/src/main/kotlin/moe/nea/firmament/apis/ingame/packets/PartyInfoRequest.kt index 2b3d234..4f34e8d 100644 --- a/src/main/kotlin/moe/nea/firmament/apis/ingame/packets/PartyInfoRequest.kt +++ b/src/main/kotlin/moe/nea/firmament/apis/ingame/packets/PartyInfoRequest.kt @@ -12,6 +12,7 @@ import net.minecraft.network.PacketByteBuf import net.minecraft.network.codec.PacketCodec import net.minecraft.network.codec.PacketCodecs import net.minecraft.network.packet.CustomPayload +import net.minecraft.util.Identifier import net.minecraft.util.Uuids import moe.nea.firmament.apis.ingame.FirmamentCustomPayload @@ -19,6 +20,10 @@ interface FirmamentCustomPayloadMeta<T : FirmamentCustomPayload> { val ID: CustomPayload.Id<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> { return CustomPayload.Type(ID, CODEC) } @@ -26,7 +31,7 @@ interface FirmamentCustomPayloadMeta<T : FirmamentCustomPayload> { data class PartyInfoRequest(val version: Int) : FirmamentCustomPayload { companion object : FirmamentCustomPayloadMeta<PartyInfoRequest> { - override val ID = CustomPayload.id<PartyInfoRequest>("hypixel:party_info") + override val ID = id("hypixel:party_info") override val CODEC = PacketCodecs.VAR_INT.cast<PacketByteBuf>() .xmap(::PartyInfoRequest, PartyInfoRequest::version) @@ -116,7 +121,7 @@ data class PartyInfoResponseV1( data class PartyInfoResponse(val data: HypixelVersionedPacketData<PartyInfoResponseV>) : FirmamentCustomPayload { 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 = CodecUtils .dispatchVersioned<PacketByteBuf, PartyInfoResponseV>( diff --git a/src/main/kotlin/moe/nea/firmament/events/HotbarItemRenderEvent.kt b/src/main/kotlin/moe/nea/firmament/events/HotbarItemRenderEvent.kt index 59660ce..d105737 100644 --- a/src/main/kotlin/moe/nea/firmament/events/HotbarItemRenderEvent.kt +++ b/src/main/kotlin/moe/nea/firmament/events/HotbarItemRenderEvent.kt @@ -7,14 +7,15 @@ package moe.nea.firmament.events import net.minecraft.client.gui.DrawContext +import net.minecraft.client.render.RenderTickCounter import net.minecraft.item.ItemStack data class HotbarItemRenderEvent( - val item: ItemStack, - val context: DrawContext, - val x: Int, - val y: Int, - val tickDelta: Float, + val item: ItemStack, + val context: DrawContext, + val x: Int, + val y: Int, + val tickDelta: RenderTickCounter, ) : FirmamentEvent() { companion object : FirmamentEventBus<HotbarItemRenderEvent>() } diff --git a/src/main/kotlin/moe/nea/firmament/events/HudRenderEvent.kt b/src/main/kotlin/moe/nea/firmament/events/HudRenderEvent.kt index bf008d3..8b8e31d 100644 --- a/src/main/kotlin/moe/nea/firmament/events/HudRenderEvent.kt +++ b/src/main/kotlin/moe/nea/firmament/events/HudRenderEvent.kt @@ -7,10 +7,11 @@ package moe.nea.firmament.events 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. */ -data class HudRenderEvent(val context: DrawContext, val tickDelta: Float) : FirmamentEvent() { +data class HudRenderEvent(val context: DrawContext, val tickDelta: RenderTickCounter) : FirmamentEvent() { companion object : FirmamentEventBus<HudRenderEvent>() } diff --git a/src/main/kotlin/moe/nea/firmament/events/ItemTooltipEvent.kt b/src/main/kotlin/moe/nea/firmament/events/ItemTooltipEvent.kt index 94a1678..be9a659 100644 --- a/src/main/kotlin/moe/nea/firmament/events/ItemTooltipEvent.kt +++ b/src/main/kotlin/moe/nea/firmament/events/ItemTooltipEvent.kt @@ -7,9 +7,9 @@ package moe.nea.firmament.events -import net.minecraft.client.item.TooltipType import net.minecraft.item.Item.TooltipContext import net.minecraft.item.ItemStack +import net.minecraft.item.tooltip.TooltipType import net.minecraft.text.Text data class ItemTooltipEvent( diff --git a/src/main/kotlin/moe/nea/firmament/events/WorldRenderLastEvent.kt b/src/main/kotlin/moe/nea/firmament/events/WorldRenderLastEvent.kt index b42e9ab..7ba9b9f 100644 --- a/src/main/kotlin/moe/nea/firmament/events/WorldRenderLastEvent.kt +++ b/src/main/kotlin/moe/nea/firmament/events/WorldRenderLastEvent.kt @@ -7,10 +7,10 @@ package moe.nea.firmament.events -import org.joml.Matrix4f import net.minecraft.client.render.Camera import net.minecraft.client.render.GameRenderer import net.minecraft.client.render.LightmapTextureManager +import net.minecraft.client.render.RenderTickCounter import net.minecraft.client.render.VertexConsumerProvider import net.minecraft.client.util.math.MatrixStack import net.minecraft.util.math.Position @@ -21,7 +21,7 @@ import net.minecraft.util.math.Vec3d */ data class WorldRenderLastEvent( val matrices: MatrixStack, - val tickDelta: Float, + val tickCounter: RenderTickCounter, val renderBlockOutline: Boolean, val camera: Camera, val gameRenderer: GameRenderer, @@ -29,8 +29,4 @@ data class WorldRenderLastEvent( val vertexConsumers: VertexConsumerProvider.Immediate, ) : FirmamentEvent() { 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))) - } diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/ItemRarityCosmetics.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/ItemRarityCosmetics.kt index de37748..0ed5c9a 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/ItemRarityCosmetics.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/ItemRarityCosmetics.kt @@ -68,7 +68,7 @@ object ItemRarityCosmetics : FirmamentFeature { x, y, 0, 16, 16, - MC.guiAtlasManager.getSprite(Identifier("firmament:item_rarity_background")), + MC.guiAtlasManager.getSprite(Identifier.of("firmament:item_rarity_background")), r, g, b, 1F ) } diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt index b0fb57b..70b887c 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt @@ -190,10 +190,10 @@ object SlotLocking : FirmamentFeature { MC.guiAtlasManager.getSprite( when { isSlotLocked -> - (Identifier("firmament:slot_locked")) + (Identifier.of("firmament:slot_locked")) isUUIDLocked -> - (Identifier("firmament:uuid_locked")) + (Identifier.of("firmament:uuid_locked")) else -> error("unreachable") diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/buttons/InventoryButton.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/buttons/InventoryButton.kt index 5ff1768..51993af 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/buttons/InventoryButton.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/buttons/InventoryButton.kt @@ -42,7 +42,7 @@ data class InventoryButton( 0, dimensions.width, dimensions.height, - MC.guiAtlasManager.getSprite(Identifier("firmament:inventory_button_background")) + MC.guiAtlasManager.getSprite(Identifier.of("firmament:inventory_button_background")) ) context.drawItem(getItem(), 1, 1) } diff --git a/src/main/kotlin/moe/nea/firmament/features/mining/PickaxeAbility.kt b/src/main/kotlin/moe/nea/firmament/features/mining/PickaxeAbility.kt index 8e62172..33bf578 100644 --- a/src/main/kotlin/moe/nea/firmament/features/mining/PickaxeAbility.kt +++ b/src/main/kotlin/moe/nea/firmament/features/mining/PickaxeAbility.kt @@ -172,7 +172,7 @@ object PickaxeAbility : FirmamentFeature { event.context.matrices.translate(MC.window.scaledWidth / 2F, MC.window.scaledHeight / 2F, 0F) event.context.matrices.scale(TConfig.cooldownScale.toFloat(), TConfig.cooldownScale.toFloat(), 1F) 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(), 0f, 1f, 0f, 1f ) diff --git a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomGlobalTextures.kt b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomGlobalTextures.kt index 147697b..24aa6ef 100644 --- a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomGlobalTextures.kt +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomGlobalTextures.kt @@ -117,7 +117,7 @@ object CustomGlobalTextures : SinglePreparationResourceReloader<CustomGlobalText .mapNotNull { val key = it.key val guiClassResource = - manager.getResource(Identifier(key.namespace, "filters/screen/${key.path}.json")) + manager.getResource(Identifier.of(key.namespace, "filters/screen/${key.path}.json")) .getOrNull() ?: return@mapNotNull runNull { logger.error("Failed to locate screen filter at $key") diff --git a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt index 458f8ff..4ae73e8 100644 --- a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomModelOverrideParser.kt @@ -34,7 +34,7 @@ object CustomModelOverrideParser { fun registerPredicateParser(name: String, parser: FirmamentModelPredicateParser) { - predicateParsers[Identifier("firmament", name)] = parser + predicateParsers[Identifier.of("firmament", name)] = parser } init { @@ -59,7 +59,7 @@ object CustomModelOverrideParser { val parsedPredicates = mutableListOf<FirmamentModelPredicate>() for (predicateName in predicates.keySet()) { if (!predicateName.startsWith("firmament:")) continue - val identifier = Identifier(predicateName) + val identifier = Identifier.of(predicateName) val parser = predicateParsers[identifier] ?: return neverPredicate val parsedPredicate = parser.parse(predicates[predicateName]) ?: return neverPredicate parsedPredicates.add(parsedPredicate) diff --git a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt index 82989e4..f37e3ea 100644 --- a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt @@ -9,7 +9,6 @@ package moe.nea.firmament.features.texturepack import com.mojang.authlib.minecraft.MinecraftProfileTexture 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 net.minecraft.block.SkullBlock import net.minecraft.client.MinecraftClient @@ -62,10 +61,13 @@ object CustomSkyBlockTextures : FirmamentFeature { .endsWith(".json") } for (identifier in resources.keys) { - val modelId = ModelIdentifier("firmskyblock", - identifier.path.substring("models/item/".length, - identifier.path.length - ".json".length), - "inventory") + val modelId = ModelIdentifier.ofInventoryVariant( + Identifier.of( + "firmskyblock", + identifier.path.substring( + "models/item/".length, + identifier.path.length - ".json".length), + )) event.addModel(modelId) } } @@ -74,7 +76,7 @@ object CustomSkyBlockTextures : FirmamentFeature { fun onCustomModelId(it: CustomItemModelEvent) { if (!TConfig.enabled) 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>() @@ -92,7 +94,7 @@ object CustomSkyBlockTextures : FirmamentFeature { fun getSkullTexture(profile: ProfileComponent): Identifier? { 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( diff --git a/src/main/kotlin/moe/nea/firmament/gui/entity/FakeWorld.kt b/src/main/kotlin/moe/nea/firmament/gui/entity/FakeWorld.kt index ac1b33b..c838922 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/entity/FakeWorld.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/entity/FakeWorld.kt @@ -129,6 +129,10 @@ fun <T> makeRegistry(registryWrapper: RegistryWrapper.Impl<T>, key: RegistryKey< return Lifecycle.stable() } + override fun getDefaultEntry(): Optional<RegistryEntry.Reference<T>> { + return Optional.empty() + } + override fun getIds(): MutableSet<Identifier> { return idLookup.keys.mapTo(mutableSetOf()) { it.value } } @@ -251,7 +255,7 @@ class FakeWorld( registries[RegistryKeys.DIMENSION_TYPE].entryOf( RegistryKey.of( RegistryKeys.DIMENSION_TYPE, - Identifier("minecraft", "overworld") + Identifier.of("minecraft", "overworld") ) ), { DummyProfiler.INSTANCE }, @@ -436,7 +440,7 @@ class FakeWorld( override fun putMapState(id: MapIdComponent?, state: MapState?) { } - override fun getNextMapId(): MapIdComponent { + override fun increaseAndGetMapId(): MapIdComponent { return MapIdComponent(0) } diff --git a/src/main/kotlin/moe/nea/firmament/gui/entity/ModifyPlayerSkin.kt b/src/main/kotlin/moe/nea/firmament/gui/entity/ModifyPlayerSkin.kt index 886a17e..b382fe2 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/entity/ModifyPlayerSkin.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/entity/ModifyPlayerSkin.kt @@ -15,10 +15,10 @@ object ModifyPlayerSkin : EntityModifier { override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity { require(entity is GuiPlayer) info["cape"]?.let { - entity.capeTexture = Identifier(it.asString) + entity.capeTexture = Identifier.of(it.asString) } info["skin"]?.let { - entity.skinTexture = Identifier(it.asString) + entity.skinTexture = Identifier.of(it.asString) } info["slim"]?.let { entity.model = if (it.asBoolean) SkinTextures.Model.SLIM else SkinTextures.Model.WIDE diff --git a/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt b/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt index 7e22a1e..a916b3e 100644 --- a/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt +++ b/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt @@ -42,7 +42,7 @@ class FirmamentReiPlugin : REIClientPlugin { 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) { registry.register(TransferHandler { context -> diff --git a/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntryRenderer.kt b/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntryRenderer.kt index fb608be..6b5e3fe 100644 --- a/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntryRenderer.kt +++ b/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntryRenderer.kt @@ -20,7 +20,6 @@ import me.shedaniel.rei.api.client.gui.widgets.TooltipContext import me.shedaniel.rei.api.common.entry.EntryStack import net.minecraft.client.MinecraftClient import net.minecraft.client.gui.DrawContext -import net.minecraft.client.item.TooltipType import net.minecraft.client.render.DiffuseLighting import net.minecraft.client.render.LightmapTextureManager 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.item.Item import net.minecraft.item.ItemStack +import net.minecraft.item.tooltip.TooltipType import moe.nea.firmament.rei.FirmamentReiPlugin.Companion.asItemEntry object NEUItemEntryRenderer : EntryRenderer<SBItemStack>, BatchedEntryRenderer<SBItemStack, BakedModel> { diff --git a/src/main/kotlin/moe/nea/firmament/rei/recipes/SBMobDropRecipe.kt b/src/main/kotlin/moe/nea/firmament/rei/recipes/SBMobDropRecipe.kt index 5af1f9e..f0f8a6d 100644 --- a/src/main/kotlin/moe/nea/firmament/rei/recipes/SBMobDropRecipe.kt +++ b/src/main/kotlin/moe/nea/firmament/rei/recipes/SBMobDropRecipe.kt @@ -41,7 +41,7 @@ class SBMobDropRecipe(override val neuRecipe: NEUMobDropRecipe) : SBRecipe() { add(Widgets.createRecipeBase(bounds)) val source = display.neuRecipe.render val entity = if (source.startsWith("@")) { - EntityRenderer.constructEntity(Identifier(source.substring(1))) + EntityRenderer.constructEntity(Identifier.of(source.substring(1))) } else { EntityRenderer.applyModifiers(source, listOf()) } diff --git a/src/main/kotlin/moe/nea/firmament/util/CommonSoundEffects.kt b/src/main/kotlin/moe/nea/firmament/util/CommonSoundEffects.kt index 10e9249..d2d9881 100644 --- a/src/main/kotlin/moe/nea/firmament/util/CommonSoundEffects.kt +++ b/src/main/kotlin/moe/nea/firmament/util/CommonSoundEffects.kt @@ -17,7 +17,7 @@ object CommonSoundEffects { } fun playFailure() { - playSound(Identifier("minecraft", "block.anvil.place")) + playSound(Identifier.of("minecraft", "block.anvil.place")) } fun playSuccess() { @@ -25,6 +25,6 @@ object CommonSoundEffects { } fun playDing() { - playSound(Identifier("minecraft", "entity.arrow.hit_player")) + playSound(Identifier.of("minecraft", "entity.arrow.hit_player")) } } diff --git a/src/main/kotlin/moe/nea/firmament/util/IdentifierSerializer.kt b/src/main/kotlin/moe/nea/firmament/util/IdentifierSerializer.kt index 3c1aa52..c88d9ee 100644 --- a/src/main/kotlin/moe/nea/firmament/util/IdentifierSerializer.kt +++ b/src/main/kotlin/moe/nea/firmament/util/IdentifierSerializer.kt @@ -19,7 +19,7 @@ object IdentifierSerializer : KSerializer<Identifier> { get() = SerialDescriptor("Identifier", delegateSerializer.descriptor) override fun deserialize(decoder: Decoder): Identifier { - return Identifier(decoder.decodeSerializableValue(delegateSerializer)) + return Identifier.of(decoder.decodeSerializableValue(delegateSerializer)) } override fun serialize(encoder: Encoder, value: Identifier) { diff --git a/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt b/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt index 3de5c26..040e2e9 100644 --- a/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt +++ b/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt @@ -31,7 +31,7 @@ import moe.nea.firmament.util.json.DashlessUUIDSerializer @Serializable value class SkyblockId(val neuItem: String) { val identifier - get() = Identifier("skyblockitem", + get() = Identifier.of("skyblockitem", neuItem.lowercase().replace(";", "__") .replace(":", "___") .replace(illlegalPathRegex) { diff --git a/src/main/kotlin/moe/nea/firmament/util/render/FacingThePlayerContext.kt b/src/main/kotlin/moe/nea/firmament/util/render/FacingThePlayerContext.kt index 178422d..01a7083 100644 --- a/src/main/kotlin/moe/nea/firmament/util/render/FacingThePlayerContext.kt +++ b/src/main/kotlin/moe/nea/firmament/util/render/FacingThePlayerContext.kt @@ -7,6 +7,7 @@ package moe.nea.firmament.util.render import com.mojang.blaze3d.systems.RenderSystem +import io.github.notenoughupdates.moulconfig.platform.next import org.joml.Matrix4f import net.minecraft.client.font.TextRenderer import net.minecraft.client.render.BufferRenderer @@ -80,22 +81,24 @@ class FacingThePlayerContext(val worldContext: RenderInWorldContext) { u2: Float, v2: Float, ) { RenderSystem.setShaderTexture(0, texture) - RenderSystem.setShader(GameRenderer::getPositionColorTexProgram) + RenderSystem.setShader(GameRenderer::getPositionTexColorProgram) val hw = width / 2F val hh = height / 2F val matrix4f: Matrix4f = worldContext.matrixStack.peek().positionMatrix - val buf = Tessellator.getInstance().buffer - buf.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE) - buf.fixedColor(255, 255, 255, 255) + val buf = Tessellator.getInstance() + .begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR) buf.vertex(matrix4f, -hw, -hh, 0F) + .color(-1) .texture(u1, v1).next() buf.vertex(matrix4f, -hw, +hh, 0F) + .color(-1) .texture(u1, v2).next() buf.vertex(matrix4f, +hw, +hh, 0F) + .color(-1) .texture(u2, v2).next() buf.vertex(matrix4f, +hw, -hh, 0F) + .color(-1) .texture(u2, v1).next() - buf.unfixColor() BufferRenderer.drawWithGlobalProgram(buf.end()) } diff --git a/src/main/kotlin/moe/nea/firmament/util/render/RenderCircleProgress.kt b/src/main/kotlin/moe/nea/firmament/util/render/RenderCircleProgress.kt index a8245ca..28dcb5e 100644 --- a/src/main/kotlin/moe/nea/firmament/util/render/RenderCircleProgress.kt +++ b/src/main/kotlin/moe/nea/firmament/util/render/RenderCircleProgress.kt @@ -7,6 +7,7 @@ package moe.nea.firmament.util.render import com.mojang.blaze3d.systems.RenderSystem +import io.github.notenoughupdates.moulconfig.platform.next import org.joml.Matrix4f import org.joml.Vector2f import kotlin.math.atan2 @@ -31,12 +32,10 @@ object RenderCircleProgress { v2: Float, ) { RenderSystem.setShaderTexture(0, texture) - RenderSystem.setShader { GameRenderer.getPositionColorTexProgram() } + RenderSystem.setShader(GameRenderer::getPositionTexColorProgram) RenderSystem.enableBlend() val matrix: Matrix4f = drawContext.matrices.peek().positionMatrix - val bufferBuilder = Tessellator.getInstance().buffer - bufferBuilder.begin(DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR_TEXTURE) - bufferBuilder.fixedColor(255, 255, 255, 255) + val bufferBuilder = Tessellator.getInstance().begin(DrawMode.TRIANGLES, VertexFormats.POSITION_TEXTURE_COLOR) val corners = listOf( Vector2f(0F, -1F), @@ -79,17 +78,19 @@ object RenderCircleProgress { bufferBuilder .vertex(matrix, second.x, second.y, 0F) .texture(lerp(u1, u2, ilerp(second.x)), lerp(v1, v2, ilerp(second.y))) + .color(-1) .next() bufferBuilder .vertex(matrix, first.x, first.y, 0F) .texture(lerp(u1, u2, ilerp(first.x)), lerp(v1, v2, ilerp(first.y))) + .color(-1) .next() bufferBuilder .vertex(matrix, 0F, 0F, 0F) .texture(lerp(u1, u2, ilerp(0F)), lerp(v1, v2, ilerp(0F))) + .color(-1) .next() } - bufferBuilder.unfixColor() BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()) RenderSystem.disableBlend() } diff --git a/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt b/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt index 750d8ac..2db4cad 100644 --- a/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt +++ b/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt @@ -8,15 +8,16 @@ package moe.nea.firmament.util.render import com.mojang.blaze3d.systems.RenderSystem +import io.github.notenoughupdates.moulconfig.platform.next import java.lang.Math.pow -import java.lang.Math.toRadians import org.joml.Matrix4f import org.joml.Vector3f -import kotlin.math.tan import net.minecraft.client.gl.VertexBuffer import net.minecraft.client.render.BufferBuilder +import net.minecraft.client.render.BufferRenderer import net.minecraft.client.render.Camera import net.minecraft.client.render.GameRenderer +import net.minecraft.client.render.RenderTickCounter import net.minecraft.client.render.Tessellator import net.minecraft.client.render.VertexConsumerProvider 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.Vec3d import moe.nea.firmament.events.WorldRenderLastEvent -import moe.nea.firmament.mixins.accessor.AccessorGameRenderer import moe.nea.firmament.util.FirmFormatters import moe.nea.firmament.util.MC @@ -37,12 +37,9 @@ class RenderInWorldContext private constructor( private val tesselator: Tessellator, val matrixStack: MatrixStack, private val camera: Camera, - private val tickDelta: Float, + private val tickCounter: RenderTickCounter, 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) { 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) matrixStack.push() matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat()) - buildCube(matrixStack.peek().positionMatrix, buffer) - tesselator.draw() + buildCube(matrixStack.peek().positionMatrix, tesselator) matrixStack.pop() } @@ -125,8 +121,7 @@ class RenderInWorldContext private constructor( matrixStack.translate(vec3d.x, vec3d.y, vec3d.z) matrixStack.scale(size, size, size) matrixStack.translate(-.5, -.5, -.5) - buildCube(matrixStack.peek().positionMatrix, buffer) - tesselator.draw() + buildCube(matrixStack.peek().positionMatrix, tesselator) matrixStack.pop() } @@ -135,8 +130,7 @@ class RenderInWorldContext private constructor( matrixStack.push() RenderSystem.lineWidth(lineWidth / pow(camera.pos.squaredDistanceTo(blockPos.toCenterPos()), 0.25).toFloat()) matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat()) - buildWireFrameCube(matrixStack.peek(), buffer) - tesselator.draw() + buildWireFrameCube(matrixStack.peek(), tesselator) matrixStack.pop() } @@ -152,8 +146,7 @@ class RenderInWorldContext private constructor( fun line(points: List<Vec3d>, lineWidth: Float = 10F) { RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram) RenderSystem.lineWidth(lineWidth) - buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES) - buffer.fixedColor(255, 255, 255, 255) + val buffer = tesselator.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES) val matrix = matrixStack.peek() var lastNormal: Vector3f? = null @@ -170,9 +163,8 @@ class RenderInWorldContext private constructor( .normal(matrix, normal.x, normal.y, normal.z) .next() } - buffer.unfixColor() - tesselator.draw() + BufferRenderer.drawWithGlobalProgram(buffer.end()) } companion object { @@ -191,16 +183,17 @@ class RenderInWorldContext private constructor( .normalize() buf.vertex(matrix.positionMatrix, i, j, k) .normal(matrix, normal.x, normal.y, normal.z) + .color(-1) .next() buf.vertex(matrix.positionMatrix, x, y, z) .normal(matrix, normal.x, normal.y, normal.z) + .color(-1) .next() } - private fun buildWireFrameCube(matrix: MatrixStack.Entry, buf: BufferBuilder) { - buf.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES) - buf.fixedColor(255, 255, 255, 255) + private fun buildWireFrameCube(matrix: MatrixStack.Entry, tessellator: Tessellator) { + val buf = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES) for (i 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) } } - buf.unfixColor() + BufferRenderer.drawWithGlobalProgram(buf.end()) } - private fun buildCube(matrix: Matrix4f, buf: BufferBuilder) { - buf.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR) - buf.fixedColor(255, 255, 255, 255) + private fun buildCube(matrix: Matrix4f, tessellator: Tessellator) { + val buf = tessellator.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION) 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, 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, 0.0F, 1.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(), event.matrices, event.camera, - event.tickDelta, + event.tickCounter, event.vertexConsumers ) diff --git a/src/main/resources/assets/firmament/textures/gui/sprites/widget/button_active.png.license b/src/main/resources/assets/firmament/textures/gui/sprites/widget/button_active.png.license new file mode 100644 index 0000000..c5a7a6d --- /dev/null +++ b/src/main/resources/assets/firmament/textures/gui/sprites/widget/button_active.png.license @@ -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 |