diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index b58714e..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Deploy - -on: - release: - types: [published] - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Deploy - uses: auxves/actions/deploy-minecraft-mod@main - with: - token: ${{ secrets.GITHUB_TOKEN }} - java-version: 17 diff --git a/build.gradle.kts b/build.gradle.kts index b8b0f2d..755c895 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,7 @@ tasks.named("processResources") { from(sourceSets["main"].resources.srcDirs) { include("fabric.mod.json") - expand(project.properties) + expand(properties) } from(sourceSets["main"].resources.srcDirs) { diff --git a/gradle.properties b/gradle.properties index d8056ff..e25937f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ kotlin.code.style=official org.gradle.jvmargs=-Xmx1G -version=3.0.1 +version=3.1.0+1.20.2 # Versions (https://fabricmc.net/develop) -minecraft=1.20.1 -yarn=1.20.1+build.10 -loader=0.14.22 +minecraft=1.20.2 +yarn=1.20.2+build.4 +loader=0.14.23 -fabric_api=0.88.1+1.20.1 -fabric_kotlin=1.10.10+kotlin.1.9.10 +fabric_api=0.90.0+1.20.2 +fabric_kotlin=1.10.10+kotlin.1.9.10 \ No newline at end of file diff --git a/src/main/java/dev/auxves/vibes/mixin/ServerPlayNetworkHandlerMixin.java b/src/main/java/dev/auxves/vibes/mixin/ServerPlayNetworkHandlerMixin.java deleted file mode 100644 index 5329021..0000000 --- a/src/main/java/dev/auxves/vibes/mixin/ServerPlayNetworkHandlerMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package dev.auxves.vibes.mixin; - -import dev.auxves.vibes.server.BridgesKt; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayNetworkHandler; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(ServerPlayNetworkHandler.class) -class ServerPlayNetworkHandlerMixin { - @Shadow public ServerPlayerEntity player; - @Shadow @Final private MinecraftServer server; - - @Inject(method = "onDisconnected", at = @At("HEAD")) - private void onDisconnect(Text reason, CallbackInfo ci) { - server.execute(() -> BridgesKt.onDisconnect(player)); - } -} \ No newline at end of file diff --git a/src/main/kotlin/dev/auxves/vibes/client/Client.kt b/src/main/kotlin/dev/auxves/vibes/client/Client.kt index c96bf68..221e943 100644 --- a/src/main/kotlin/dev/auxves/vibes/client/Client.kt +++ b/src/main/kotlin/dev/auxves/vibes/client/Client.kt @@ -9,7 +9,7 @@ import dev.auxves.vibes.sound.VibeInstance import kotlinx.coroutines.* import net.minecraft.client.MinecraftClient import net.minecraft.sound.SoundEvent -import java.util.UUID +import java.util.* private val client = MinecraftClient.getInstance() private val instances = mutableMapOf() diff --git a/src/main/kotlin/dev/auxves/vibes/server/Bridges.kt b/src/main/kotlin/dev/auxves/vibes/server/Bridges.kt index 48a9eb8..424f00f 100644 --- a/src/main/kotlin/dev/auxves/vibes/server/Bridges.kt +++ b/src/main/kotlin/dev/auxves/vibes/server/Bridges.kt @@ -2,10 +2,7 @@ package dev.auxves.vibes.server import dev.auxves.vibes.mixin.EnderChestInventoryAccessor import dev.auxves.vibes.network.packet.* -import dev.auxves.vibes.util.VibeType -import dev.auxves.vibes.util.uuid -import dev.auxves.vibes.util.vibeTypeOf -import dev.auxves.vibes.util.vibesIn +import dev.auxves.vibes.util.* import net.minecraft.block.entity.BlockEntity import net.minecraft.entity.Entity import net.minecraft.entity.ItemEntity @@ -35,7 +32,9 @@ fun onBreakShulkerBox(entity: Entity) { } fun stopPlaying(stack: ItemStack, world: World) { - vibesIn(stack).map { it.uuid }.forEach { world.sendAll(Stop(it)) } + vibesIn(stack).map { it.uuid }.forEach { + world.sendAll(Stop(it)) + } } fun changePosition(stack: ItemStack, block: BlockEntity) { diff --git a/src/main/kotlin/dev/auxves/vibes/server/Server.kt b/src/main/kotlin/dev/auxves/vibes/server/Server.kt index f75b8a3..51f85e5 100644 --- a/src/main/kotlin/dev/auxves/vibes/server/Server.kt +++ b/src/main/kotlin/dev/auxves/vibes/server/Server.kt @@ -1,8 +1,13 @@ package dev.auxves.vibes.server import dev.auxves.vibes.network.packet.* +import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents fun initServer() { - register { data, player -> player.send(data) } - register { data, player -> player.send(data) } + register { data, player -> player.world.sendAll(data) } + register { data, player -> player.world.sendAll(data) } + + ServerPlayConnectionEvents.DISCONNECT.register { handler, server -> + server.execute { onDisconnect(handler.player) } + } } \ No newline at end of file diff --git a/src/main/kotlin/dev/auxves/vibes/util/Items.kt b/src/main/kotlin/dev/auxves/vibes/util/Items.kt index 3b0d658..f2a6126 100644 --- a/src/main/kotlin/dev/auxves/vibes/util/Items.kt +++ b/src/main/kotlin/dev/auxves/vibes/util/Items.kt @@ -4,6 +4,7 @@ import dev.auxves.vibes.item.Vibe import net.minecraft.block.ShulkerBoxBlock import net.minecraft.item.BlockItem import net.minecraft.item.ItemStack +import java.util.UUID enum class VibeType { VIBE, @@ -16,6 +17,14 @@ fun isPlaying(stack: ItemStack): Boolean = when (vibeTypeOf(stack)) { else -> false } +fun ensureUuid(stack: ItemStack): ItemStack { + if (stack.item is Vibe && !stack.orCreateNbt.containsUuid(Tags.UUID)) { + stack.uuid = UUID.randomUUID() + } + + return stack +} + fun vibeTypeOf(stack: ItemStack): VibeType? = when { stack.item is Vibe -> VibeType.VIBE (stack.item as? BlockItem)?.block is ShulkerBoxBlock -> VibeType.SHULKER @@ -26,4 +35,4 @@ fun vibesIn(stack: ItemStack): Sequence = when (vibeTypeOf(stack)) { VibeType.VIBE -> sequenceOf(stack) VibeType.SHULKER -> shulkerInventoryOf(stack).asSequence().flatMap(::vibesIn) else -> sequenceOf() -}.filter(::isPlaying) +}.map(::ensureUuid).filter(::isPlaying) diff --git a/src/main/kotlin/dev/auxves/vibes/util/Tags.kt b/src/main/kotlin/dev/auxves/vibes/util/Tags.kt index 1833797..d39422c 100644 --- a/src/main/kotlin/dev/auxves/vibes/util/Tags.kt +++ b/src/main/kotlin/dev/auxves/vibes/util/Tags.kt @@ -14,12 +14,7 @@ object Tags { } var ItemStack.uuid: UUID - get() { - if (orCreateNbt.containsUuid(Tags.UUID)) return orCreateNbt.getUuid(Tags.UUID) - val new = UUID.randomUUID() - uuid = new - return new - } + get() = orCreateNbt.getUuid(Tags.UUID) set(new) = orCreateNbt.putUuid(Tags.UUID, new) var ItemStack.disc: ItemStack? diff --git a/src/main/resources/data/curios/tags/items/back.json b/src/main/resources/data/curios/tags/items/back.json new file mode 100644 index 0000000..a1bd698 --- /dev/null +++ b/src/main/resources/data/curios/tags/items/back.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "vibes:vibe" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/trinkets/entities/vibes.json b/src/main/resources/data/trinkets/entities/vibes.json new file mode 100644 index 0000000..db83035 --- /dev/null +++ b/src/main/resources/data/trinkets/entities/vibes.json @@ -0,0 +1,4 @@ +{ + "entities": ["player"], + "slots": ["chest/back"] +} \ No newline at end of file diff --git a/src/main/resources/data/trinkets/tags/items/chest/back.json b/src/main/resources/data/trinkets/tags/items/chest/back.json new file mode 100644 index 0000000..a1bd698 --- /dev/null +++ b/src/main/resources/data/trinkets/tags/items/chest/back.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "vibes:vibe" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/vibes/curios/entities/vibes.json b/src/main/resources/data/vibes/curios/entities/vibes.json new file mode 100644 index 0000000..8c6772b --- /dev/null +++ b/src/main/resources/data/vibes/curios/entities/vibes.json @@ -0,0 +1,4 @@ +{ + "entities": ["player"], + "slots": ["back"] +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index edd5674..fabc76f 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -18,8 +18,7 @@ }, "mixins": ["vibes.mixins.json"], "depends": { - "minecraft": "1.20.x", - "fabricloader": "*", + "minecraft": "1.20.1", "fabric-api": "*", "fabric-language-kotlin": "*" } diff --git a/src/main/resources/vibes.mixins.json b/src/main/resources/vibes.mixins.json index 521382b..488d9d8 100644 --- a/src/main/resources/vibes.mixins.json +++ b/src/main/resources/vibes.mixins.json @@ -17,7 +17,6 @@ "LootableContainerBlockEntityMixin", "PlayerEntityMixin", "PlayerInventoryMixin", - "ServerPlayNetworkHandlerMixin", "ShulkerBoxBlockMixin", "SimpleInventoryMixin", "SoundManagerAccessor",