diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ceec52a..b58714e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,7 +13,7 @@ jobs: uses: actions/checkout@v2 - name: Deploy - uses: glossnyx/actions/deploy-minecraft-mod@main + uses: auxves/actions/deploy-minecraft-mod@main with: token: ${{ secrets.GITHUB_TOKEN }} java-version: 17 diff --git a/README.md b/README.md index f75231b..1a8ee5a 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,9 @@ Dropping a Vibe on the ground will move the sound source to the item entity, and ## Installation -You have three options for downloading Vibes. - -- [CurseForge] -- [Modrinth] - [GitHub Releases] +- [Modrinth] +- [CurseForge] ## Crafting @@ -34,12 +32,12 @@ The mechanics for Vibe are very similar to how the bundle is used. 1. Pick up the Vibe 1. Hover over the disc -1. Right click the disc with the Vibe +1. Right-click the disc with the Vibe ### Ejecting Discs 1. Pick up the Vibe -1. Right click an empty inventory slot with the Vibe +1. Right-click an empty inventory slot with the Vibe ## Compatibility diff --git a/build.gradle.kts b/build.gradle.kts index e08124a..4def417 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,11 +15,7 @@ dependencies { mappings("net.fabricmc:yarn:${p("yarn")}:v2") modImplementation("net.fabricmc:fabric-loader:${p("loader")}") - - listOf("fabric-resource-loader-v0", "fabric-networking-api-v1").forEach { - modImplementation(fabricApi.module(it, p("fabric_api"))) - } - + modImplementation("net.fabricmc.fabric-api:fabric-api:${p("fabric_api")}") modImplementation("net.fabricmc:fabric-language-kotlin:${p("fabric_kotlin")}") } diff --git a/gradle.properties b/gradle.properties index c192dea..95be551 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,14 +4,14 @@ org.gradle.jvmargs=-Xmx1G # Project id=vibes title=Vibes -author=glossnyx -description=Listen to music discs on the go with the Vibe -version=2.0.2 +author=auxves +description=Listen to music discs on the go with the Vibe, a portable jukebox! +version=3.0.0 # Versions (https://fabricmc.net/develop) -minecraft=1.18.2 -yarn=1.18.2+build.2 -loader=0.13.3 +minecraft=1.19.2 +yarn=1.19.2+build.28 +loader=0.14.10 -fabric_api=0.48.0+1.18.2 -fabric_kotlin=1.7.1+kotlin.1.6.10 +fabric_api=0.66.0+1.19.2 +fabric_kotlin=1.8.6+kotlin.1.7.21 diff --git a/settings.gradle.kts b/settings.gradle.kts index d689260..8467b71 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,7 +5,7 @@ pluginManagement { } plugins { - id("fabric-loom") version "0.11-SNAPSHOT" - kotlin("jvm") version "1.6.10" + id("fabric-loom") version "1.0-SNAPSHOT" + kotlin("jvm") version "1.7.21" } } diff --git a/src/main/java/io/glossnyx/vibes/mixin/AbstractFurnaceBlockEntityMixin.java b/src/main/java/io/auxves/vibes/mixin/AbstractFurnaceBlockEntityMixin.java similarity index 72% rename from src/main/java/io/glossnyx/vibes/mixin/AbstractFurnaceBlockEntityMixin.java rename to src/main/java/io/auxves/vibes/mixin/AbstractFurnaceBlockEntityMixin.java index 9cd9d3c..b35a5bc 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/AbstractFurnaceBlockEntityMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/AbstractFurnaceBlockEntityMixin.java @@ -1,13 +1,12 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(AbstractFurnaceBlockEntity.class) class AbstractFurnaceBlockEntityMixin { @@ -15,6 +14,6 @@ class AbstractFurnaceBlockEntityMixin { @Inject(method = "setStack", at = @At("HEAD")) private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) { - ServerNetworking.INSTANCE.changePositionProvider(stack, that); + BridgesKt.changePosition(stack, that); } } diff --git a/src/main/java/io/glossnyx/vibes/mixin/BlockMixin.java b/src/main/java/io/auxves/vibes/mixin/BlockMixin.java similarity index 66% rename from src/main/java/io/glossnyx/vibes/mixin/BlockMixin.java rename to src/main/java/io/auxves/vibes/mixin/BlockMixin.java index 9fe4201..2ce07f4 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/BlockMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/BlockMixin.java @@ -1,6 +1,6 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.world.World; @@ -12,13 +12,10 @@ class BlockMixin { @Redirect( method = "dropStack(Lnet/minecraft/world/World;Ljava/util/function/Supplier;Lnet/minecraft/item/ItemStack;)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z" - ) + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z") ) private static boolean onSpawnEntity(World world, Entity entity) { - ServerNetworking.INSTANCE.onBreakShulkerBox(entity); + BridgesKt.onBreakShulkerBox(entity); return world.spawnEntity(entity); } } diff --git a/src/main/java/io/glossnyx/vibes/mixin/EnderChestInventoryAccessor.java b/src/main/java/io/auxves/vibes/mixin/EnderChestInventoryAccessor.java similarity index 91% rename from src/main/java/io/glossnyx/vibes/mixin/EnderChestInventoryAccessor.java rename to src/main/java/io/auxves/vibes/mixin/EnderChestInventoryAccessor.java index ad2804e..c690ad7 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/EnderChestInventoryAccessor.java +++ b/src/main/java/io/auxves/vibes/mixin/EnderChestInventoryAccessor.java @@ -1,4 +1,4 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; import net.minecraft.block.entity.EnderChestBlockEntity; import net.minecraft.inventory.EnderChestInventory; diff --git a/src/main/java/io/auxves/vibes/mixin/HopperBlockEntityMixin.java b/src/main/java/io/auxves/vibes/mixin/HopperBlockEntityMixin.java new file mode 100644 index 0000000..96eb0c6 --- /dev/null +++ b/src/main/java/io/auxves/vibes/mixin/HopperBlockEntityMixin.java @@ -0,0 +1,19 @@ +package io.auxves.vibes.mixin; + +import io.auxves.vibes.server.BridgesKt; +import net.minecraft.block.entity.HopperBlockEntity; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(HopperBlockEntity.class) +class HopperBlockEntityMixin { + HopperBlockEntity that = HopperBlockEntity.class.cast(this); + + @Inject(method = "setStack", at = @At("HEAD")) + private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) { + BridgesKt.changePosition(stack, that); + } +} diff --git a/src/main/java/io/glossnyx/vibes/mixin/ItemDispenserBehaviorMixin.java b/src/main/java/io/auxves/vibes/mixin/ItemDispenserBehaviorMixin.java similarity index 80% rename from src/main/java/io/glossnyx/vibes/mixin/ItemDispenserBehaviorMixin.java rename to src/main/java/io/auxves/vibes/mixin/ItemDispenserBehaviorMixin.java index 9a8b40f..e03d48f 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/ItemDispenserBehaviorMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/ItemDispenserBehaviorMixin.java @@ -1,6 +1,6 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.block.dispenser.ItemDispenserBehavior; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; @@ -14,7 +14,7 @@ class ItemDispenserBehaviorMixin { @Redirect(method = "spawnItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) private static boolean onSpawnEntity(World world, Entity entity) { ItemEntity itemEntity = (ItemEntity) entity; - ServerNetworking.INSTANCE.changePositionProvider(itemEntity.getStack(), itemEntity); + BridgesKt.changePosition(itemEntity.getStack(), itemEntity); return world.spawnEntity(entity); } } diff --git a/src/main/java/io/auxves/vibes/mixin/ItemEntityMixin.java b/src/main/java/io/auxves/vibes/mixin/ItemEntityMixin.java new file mode 100644 index 0000000..9893d8a --- /dev/null +++ b/src/main/java/io/auxves/vibes/mixin/ItemEntityMixin.java @@ -0,0 +1,33 @@ +package io.auxves.vibes.mixin; + +import io.auxves.vibes.server.BridgesKt; +import io.auxves.vibes.util.ItemsKt; +import net.minecraft.entity.ItemEntity; +import net.minecraft.item.ItemStack; +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.Redirect; + +@Mixin(ItemEntity.class) +class ItemEntityMixin { + @Shadow private int itemAge; + + @Redirect(method = "onPlayerCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;getStack()Lnet/minecraft/item/ItemStack;")) + private ItemStack onGetStack(ItemEntity entity) { + if (ItemsKt.isPlaying(entity.getStack())) return entity.getStack().copy(); + return entity.getStack(); + } + + @Redirect(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;discard()V")) + private void stopPlayingWhenKilled(ItemEntity entity) { + BridgesKt.stopPlaying(entity.getStack(), entity.world); + entity.discard(); + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;discard()V")) + private void keepAlive(ItemEntity entity) { + if (!ItemsKt.isPlaying(entity.getStack())) entity.discard(); + else itemAge = 0; + } +} diff --git a/src/main/java/io/glossnyx/vibes/mixin/ItemFrameEntityMixin.java b/src/main/java/io/auxves/vibes/mixin/ItemFrameEntityMixin.java similarity index 59% rename from src/main/java/io/glossnyx/vibes/mixin/ItemFrameEntityMixin.java rename to src/main/java/io/auxves/vibes/mixin/ItemFrameEntityMixin.java index 8ba2250..71116ab 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/ItemFrameEntityMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/ItemFrameEntityMixin.java @@ -1,12 +1,9 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; -import net.minecraft.entity.EntityType; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.decoration.AbstractDecorationEntity; import net.minecraft.entity.decoration.ItemFrameEntity; import net.minecraft.item.ItemStack; -import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -19,19 +16,13 @@ class ItemFrameEntityMixin { @Inject(method = "setHeldItemStack(Lnet/minecraft/item/ItemStack;)V", at = @At("HEAD")) private void onSetStack(ItemStack stack, CallbackInfo ci) { - ServerNetworking.INSTANCE.changePositionProvider(stack, that); + BridgesKt.changePosition(stack, that); } - @Redirect( - method = "dropHeldStack", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/entity/decoration/ItemFrameEntity;dropStack(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/entity/ItemEntity;" - ) - ) + @Redirect(method = "dropHeldStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/decoration/ItemFrameEntity;dropStack(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/entity/ItemEntity;")) private ItemEntity onDropStack(ItemFrameEntity entity, ItemStack stack) { ItemEntity itemEntity = entity.dropStack(stack); - ServerNetworking.INSTANCE.changePositionProvider(stack, itemEntity); + if (itemEntity != null) BridgesKt.changePosition(stack, itemEntity); return itemEntity; } } diff --git a/src/main/java/io/auxves/vibes/mixin/JukeboxBlockMixin.java b/src/main/java/io/auxves/vibes/mixin/JukeboxBlockMixin.java new file mode 100644 index 0000000..ca0aaba --- /dev/null +++ b/src/main/java/io/auxves/vibes/mixin/JukeboxBlockMixin.java @@ -0,0 +1,24 @@ +package io.auxves.vibes.mixin; + +import io.auxves.vibes.network.packet.ChangeDistance; +import io.auxves.vibes.server.BridgesKt; +import net.minecraft.block.JukeboxBlock; +import net.minecraft.entity.Entity; +import net.minecraft.entity.ItemEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(JukeboxBlock.class) +class JukeboxBlockMixin { + @Redirect(method = "removeRecord", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) + private boolean onSpawnEntity(World world, Entity entity) { + ItemEntity itemEntity = (ItemEntity) entity; + ItemStack stack = itemEntity.getStack(); + BridgesKt.changePosition(stack, entity); + BridgesKt.setDistance(entity.world, stack, ChangeDistance.Normal); + return world.spawnEntity(entity); + } +} diff --git a/src/main/java/io/glossnyx/vibes/mixin/LootableContainerBlockEntityMixin.java b/src/main/java/io/auxves/vibes/mixin/LootableContainerBlockEntityMixin.java similarity index 62% rename from src/main/java/io/glossnyx/vibes/mixin/LootableContainerBlockEntityMixin.java rename to src/main/java/io/auxves/vibes/mixin/LootableContainerBlockEntityMixin.java index 9d20ce7..1be2a13 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/LootableContainerBlockEntityMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/LootableContainerBlockEntityMixin.java @@ -1,16 +1,12 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.BlockEntityType; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.block.entity.LootableContainerBlockEntity; import net.minecraft.item.ItemStack; 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; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LootableContainerBlockEntity.class) class LootableContainerBlockEntityMixin { @@ -18,6 +14,6 @@ class LootableContainerBlockEntityMixin { @Inject(method = "setStack", at = @At("HEAD")) private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) { - ServerNetworking.INSTANCE.changePositionProvider(stack, that); + BridgesKt.changePosition(stack, that); } } \ No newline at end of file diff --git a/src/main/java/io/glossnyx/vibes/mixin/PlayerEntityMixin.java b/src/main/java/io/auxves/vibes/mixin/PlayerEntityMixin.java similarity index 70% rename from src/main/java/io/glossnyx/vibes/mixin/PlayerEntityMixin.java rename to src/main/java/io/auxves/vibes/mixin/PlayerEntityMixin.java index 2335ed3..e50efcd 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/PlayerEntityMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/PlayerEntityMixin.java @@ -1,21 +1,20 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.server.network.ServerPlayerEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) class PlayerEntityMixin { @Inject(method = "dropItem(Lnet/minecraft/item/ItemStack;ZZ)Lnet/minecraft/entity/ItemEntity;", at = @At("RETURN")) private void onDropItem(ItemStack stack, boolean throwRandomly, boolean retainOwnership, CallbackInfoReturnable cir) { - ServerNetworking.INSTANCE.changePositionProvider(stack, cir.getReturnValue()); + Entity entity = cir.getReturnValue(); + if (entity != null) BridgesKt.changePosition(stack, entity); } } \ No newline at end of file diff --git a/src/main/java/io/glossnyx/vibes/mixin/PlayerInventoryMixin.java b/src/main/java/io/auxves/vibes/mixin/PlayerInventoryMixin.java similarity index 62% rename from src/main/java/io/glossnyx/vibes/mixin/PlayerInventoryMixin.java rename to src/main/java/io/auxves/vibes/mixin/PlayerInventoryMixin.java index 318d64e..61bed29 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/PlayerInventoryMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/PlayerInventoryMixin.java @@ -1,6 +1,6 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; @@ -10,6 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerInventory.class) class PlayerInventoryMixin { @@ -17,6 +18,11 @@ class PlayerInventoryMixin { @Inject(method = "setStack", at = @At("HEAD")) private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) { - ServerNetworking.INSTANCE.changePositionProvider(stack, player); + BridgesKt.changePosition(stack, player); + } + + @Inject(method = "insertStack(Lnet/minecraft/item/ItemStack;)Z", at = @At("HEAD")) + private void onInsert(ItemStack stack, CallbackInfoReturnable cir) { + BridgesKt.changePosition(stack, player); } } diff --git a/src/main/java/io/glossnyx/vibes/mixin/ServerPlayNetworkHandlerMixin.java b/src/main/java/io/auxves/vibes/mixin/ServerPlayNetworkHandlerMixin.java similarity index 83% rename from src/main/java/io/glossnyx/vibes/mixin/ServerPlayNetworkHandlerMixin.java rename to src/main/java/io/auxves/vibes/mixin/ServerPlayNetworkHandlerMixin.java index d9ca378..149540e 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/ServerPlayNetworkHandlerMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/ServerPlayNetworkHandlerMixin.java @@ -1,6 +1,6 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; @@ -19,6 +19,6 @@ class ServerPlayNetworkHandlerMixin { @Inject(method = "onDisconnected", at = @At("HEAD")) private void onDisconnect(Text reason, CallbackInfo ci) { - server.execute(() -> ServerNetworking.INSTANCE.onDisconnect(player)); + server.execute(() -> BridgesKt.onDisconnect(player)); } } \ No newline at end of file diff --git a/src/main/java/io/glossnyx/vibes/mixin/ServerPlayerEntityMixin.java b/src/main/java/io/auxves/vibes/mixin/ServerPlayerEntityMixin.java similarity index 63% rename from src/main/java/io/glossnyx/vibes/mixin/ServerPlayerEntityMixin.java rename to src/main/java/io/auxves/vibes/mixin/ServerPlayerEntityMixin.java index 4dfea53..26da0bc 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/ServerPlayerEntityMixin.java @@ -1,7 +1,8 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.entity.Entity; +import net.minecraft.entity.ItemEntity; import net.minecraft.server.network.ServerPlayerEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -10,8 +11,12 @@ @Mixin(ServerPlayerEntity.class) class ServerPlayerEntityMixin { + ServerPlayerEntity that = ServerPlayerEntity.class.cast(this); + @Inject(method = "sendPickup", at = @At("HEAD")) private void onPickup(Entity item, int count, CallbackInfo ci) { - ServerNetworking.INSTANCE.onPickup(ServerPlayerEntity.class.cast(this), item); + if (item instanceof ItemEntity) { + BridgesKt.changePosition(((ItemEntity) item).getStack(), that); + } } } diff --git a/src/main/java/io/glossnyx/vibes/mixin/ShulkerBoxBlockMixin.java b/src/main/java/io/auxves/vibes/mixin/ShulkerBoxBlockMixin.java similarity index 74% rename from src/main/java/io/glossnyx/vibes/mixin/ShulkerBoxBlockMixin.java rename to src/main/java/io/auxves/vibes/mixin/ShulkerBoxBlockMixin.java index 8fa4a1c..cc39846 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/ShulkerBoxBlockMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/ShulkerBoxBlockMixin.java @@ -1,8 +1,9 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.block.BlockState; import net.minecraft.block.ShulkerBoxBlock; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -16,6 +17,7 @@ class ShulkerBoxBlockMixin { @Inject(method = "onPlaced", at = @At("HEAD")) private void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack, CallbackInfo ci) { - ServerNetworking.INSTANCE.changePositionProvider(itemStack, world.getBlockEntity(pos)); + BlockEntity entity = world.getBlockEntity(pos); + if (entity != null) BridgesKt.changePosition(itemStack, entity); } } diff --git a/src/main/java/io/glossnyx/vibes/mixin/SimpleInventoryMixin.java b/src/main/java/io/auxves/vibes/mixin/SimpleInventoryMixin.java similarity index 77% rename from src/main/java/io/glossnyx/vibes/mixin/SimpleInventoryMixin.java rename to src/main/java/io/auxves/vibes/mixin/SimpleInventoryMixin.java index 3d84620..c166d4c 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/SimpleInventoryMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/SimpleInventoryMixin.java @@ -1,6 +1,6 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.inventory.Inventory; import net.minecraft.inventory.SimpleInventory; import net.minecraft.item.ItemStack; @@ -13,6 +13,6 @@ class SimpleInventoryMixin { @Inject(method = "setStack", at = @At("HEAD")) private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) { - ServerNetworking.INSTANCE.handleEnderChest((Inventory) this, stack); + BridgesKt.handleEnderChest((Inventory) this, stack); } } \ No newline at end of file diff --git a/src/main/java/io/auxves/vibes/mixin/SoundManagerAccessor.java b/src/main/java/io/auxves/vibes/mixin/SoundManagerAccessor.java new file mode 100644 index 0000000..8211ec3 --- /dev/null +++ b/src/main/java/io/auxves/vibes/mixin/SoundManagerAccessor.java @@ -0,0 +1,12 @@ +package io.auxves.vibes.mixin; + +import net.minecraft.client.sound.SoundManager; +import net.minecraft.client.sound.SoundSystem; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(SoundManager.class) +public interface SoundManagerAccessor { + @Accessor("soundSystem") + SoundSystem getSoundSystem(); +} diff --git a/src/main/java/io/auxves/vibes/mixin/SoundSystemAccessor.java b/src/main/java/io/auxves/vibes/mixin/SoundSystemAccessor.java new file mode 100644 index 0000000..c53411c --- /dev/null +++ b/src/main/java/io/auxves/vibes/mixin/SoundSystemAccessor.java @@ -0,0 +1,15 @@ +package io.auxves.vibes.mixin; + +import net.minecraft.client.sound.Channel; +import net.minecraft.client.sound.SoundInstance; +import net.minecraft.client.sound.SoundSystem; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.Map; + +@Mixin(SoundSystem.class) +public interface SoundSystemAccessor { + @Accessor("sources") + Map getSources(); +} diff --git a/src/main/java/io/glossnyx/vibes/mixin/StorageMinecartEntityMixin.java b/src/main/java/io/auxves/vibes/mixin/StorageMinecartEntityMixin.java similarity index 61% rename from src/main/java/io/glossnyx/vibes/mixin/StorageMinecartEntityMixin.java rename to src/main/java/io/auxves/vibes/mixin/StorageMinecartEntityMixin.java index 0ecda1d..2a78136 100644 --- a/src/main/java/io/glossnyx/vibes/mixin/StorageMinecartEntityMixin.java +++ b/src/main/java/io/auxves/vibes/mixin/StorageMinecartEntityMixin.java @@ -1,16 +1,12 @@ -package io.glossnyx.vibes.mixin; +package io.auxves.vibes.mixin; -import io.glossnyx.vibes.network.ServerNetworking; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.vehicle.AbstractMinecartEntity; +import io.auxves.vibes.server.BridgesKt; import net.minecraft.entity.vehicle.StorageMinecartEntity; import net.minecraft.item.ItemStack; -import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(StorageMinecartEntity.class) class StorageMinecartEntityMixin { @@ -18,6 +14,6 @@ class StorageMinecartEntityMixin { @Inject(method = "setStack", at = @At("HEAD")) private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) { - ServerNetworking.INSTANCE.changePositionProvider(stack, that); + BridgesKt.changePosition(stack, that); } } diff --git a/src/main/java/io/glossnyx/vibes/mixin/EntityMixin.java b/src/main/java/io/glossnyx/vibes/mixin/EntityMixin.java deleted file mode 100644 index b8227da..0000000 --- a/src/main/java/io/glossnyx/vibes/mixin/EntityMixin.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.glossnyx.vibes.mixin; - -import io.glossnyx.vibes.network.ServerNetworking; -import net.minecraft.entity.Entity; -import net.minecraft.entity.ItemEntity; -import net.minecraft.world.World; -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(Entity.class) -class EntityMixin { - @Shadow public World world; - - @Inject(method = "discard", at = @At("HEAD")) - private void onDiscard(CallbackInfo ci) { - if (world.isClient) return; - - //noinspection ConstantConditions - if (!ItemEntity.class.isInstance(this)) return; - - ServerNetworking.INSTANCE.stopPlaying(ItemEntity.class.cast(this).getStack(), world); - } -} diff --git a/src/main/java/io/glossnyx/vibes/mixin/HopperBlockEntityMixin.java b/src/main/java/io/glossnyx/vibes/mixin/HopperBlockEntityMixin.java deleted file mode 100644 index b753f8f..0000000 --- a/src/main/java/io/glossnyx/vibes/mixin/HopperBlockEntityMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.glossnyx.vibes.mixin; - -import io.glossnyx.vibes.network.ServerNetworking; -import io.glossnyx.vibes.util.*; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.block.entity.HopperBlockEntity; -import net.minecraft.entity.Entity; -import net.minecraft.entity.ItemEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.collection.DefaultedList; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(HopperBlockEntity.class) -class HopperBlockEntityMixin { - HopperBlockEntity that = HopperBlockEntity.class.cast(this); - - @Inject(method = "setStack", at = @At("HEAD")) - private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) { - ServerNetworking.INSTANCE.changePositionProvider(stack, that); - } - - @Redirect( - method = "extract(Lnet/minecraft/inventory/Inventory;Lnet/minecraft/entity/ItemEntity;)Z", - at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;discard()V") - ) - private static void onRemoveItem(ItemEntity entity) { - if (!entity.world.isClient && ItemsKt.isPlaying(entity.getStack())) { - entity.remove(Entity.RemovalReason.DISCARDED); - } else { - entity.discard(); - } - } -} diff --git a/src/main/java/io/glossnyx/vibes/mixin/ItemEntityMixin.java b/src/main/java/io/glossnyx/vibes/mixin/ItemEntityMixin.java deleted file mode 100644 index 07477d9..0000000 --- a/src/main/java/io/glossnyx/vibes/mixin/ItemEntityMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.glossnyx.vibes.mixin; - -import io.glossnyx.vibes.util.ItemsKt; -import net.minecraft.entity.Entity; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -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.Redirect; - -@Mixin(ItemEntity.class) -class ItemEntityMixin { - @Redirect( - method = "onPlayerCollision", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/entity/ItemEntity;getStack()Lnet/minecraft/item/ItemStack;" - ) - ) - private ItemStack onGetStack(ItemEntity entity) { - if (ItemsKt.isPlaying(entity.getStack())) return entity.getStack().copy(); - return entity.getStack(); - } - - @Redirect( - method = "onPlayerCollision", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/entity/player/PlayerEntity;sendPickup(Lnet/minecraft/entity/Entity;I)V" - ) - ) - private void onSendPickup(PlayerEntity player, Entity item, int count) { - player.sendPickup(item, count); - ItemStack stack = ((ItemEntity) item).getStack(); - if (ItemsKt.isPlaying(stack)) stack.setCount(0); - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;discard()V")) - private void onDiscard(ItemEntity entity) { - if (!ItemsKt.isPlaying(entity.getStack())) entity.discard(); - } -} diff --git a/src/main/kotlin/io/auxves/vibes/Entrypoint.kt b/src/main/kotlin/io/auxves/vibes/Entrypoint.kt new file mode 100644 index 0000000..80d7a64 --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/Entrypoint.kt @@ -0,0 +1,17 @@ +package io.auxves.vibes + +import io.auxves.vibes.item.Vibe +import io.auxves.vibes.network.packet.* +import net.minecraft.util.Identifier +import net.minecraft.util.registry.Registry + +object Vibes { + fun id(path: String) = Identifier("vibes", path) +} + +@Suppress("unused") +fun init() { + Registry.register(Registry.ITEM, Vibe.id, Vibe) + + io.auxves.vibes.server.initServer() +} diff --git a/src/main/kotlin/io/auxves/vibes/client/Client.kt b/src/main/kotlin/io/auxves/vibes/client/Client.kt new file mode 100644 index 0000000..11a6d5e --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/client/Client.kt @@ -0,0 +1,69 @@ +package io.auxves.vibes.client + +import io.auxves.vibes.mixin.SoundManagerAccessor +import io.auxves.vibes.mixin.SoundSystemAccessor +import io.auxves.vibes.network.packet.* +import io.auxves.vibes.sound.BlockPositionProvider +import io.auxves.vibes.sound.EntityPositionProvider +import io.auxves.vibes.sound.VibeInstance +import kotlinx.coroutines.* +import net.minecraft.client.MinecraftClient +import net.minecraft.sound.SoundEvent +import java.util.UUID + +private val client = MinecraftClient.getInstance() +private val instances = mutableMapOf() + +private fun getEntity(uuid: UUID) = client.world?.let { world -> + world.players.asSequence().plus(world.entities).find { it.uuid == uuid } +} + +private fun stop(uuid: UUID) = instances[uuid]?.let { + client.soundManager.stop(it) + instances.remove(uuid) +} + +@Suppress("unused") +fun init() { + val scope = CoroutineScope(Dispatchers.Unconfined) + + val sources by lazy { + val soundManager = client.soundManager as SoundManagerAccessor + val soundSystem = soundManager.soundSystem as SoundSystemAccessor + soundSystem.sources + } + + register { data -> + stop(data.uuid) + + val entity = getEntity(data.player) ?: return@register + val instance = VibeInstance(EntityPositionProvider(entity), SoundEvent(data.sound)) + instances[data.uuid] = instance + + client.soundManager.play(instance) + } + + register { data -> stop(data.uuid) } + + register { data -> + instances[data.uuid]?.let { + scope.launch { + delay(100) + val entity = getEntity(data.entityUUID) ?: return@launch + it.position = EntityPositionProvider(entity) + } + } + } + + register { data -> + instances[data.uuid]?.let { + it.position = BlockPositionProvider(data.blockPos) + } + } + + register { data -> + instances[data.uuid]?.let { + sources[it]?.run { source -> source.setAttenuation(data.distance) } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/auxves/vibes/item/Vibe.kt b/src/main/kotlin/io/auxves/vibes/item/Vibe.kt new file mode 100644 index 0000000..334cd12 --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/item/Vibe.kt @@ -0,0 +1,84 @@ +package io.auxves.vibes.item + +import io.auxves.vibes.Vibes +import io.auxves.vibes.network.packet.* +import io.auxves.vibes.util.* +import net.minecraft.block.Blocks +import net.minecraft.block.JukeboxBlock +import net.minecraft.client.item.TooltipContext +import net.minecraft.entity.player.PlayerEntity +import net.minecraft.item.* +import net.minecraft.screen.slot.Slot +import net.minecraft.text.Text +import net.minecraft.util.ActionResult +import net.minecraft.util.ClickType +import net.minecraft.util.Formatting +import net.minecraft.util.Rarity +import net.minecraft.world.World + +private val settings: Item.Settings = Item.Settings() + .group(ItemGroup.MISC) + .rarity(Rarity.RARE) + .maxCount(1) + +object Vibe : Item(settings) { + val id = Vibes.id("vibe") + + override fun appendTooltip(stack: ItemStack, world: World?, tooltip: MutableList, context: TooltipContext) { + stack.disc?.item?.appendTooltip(stack, world, tooltip, context) + + val helpKey = if (stack.disc == null) ".play" else ".stop" + tooltip.add(Text.translatable(translationKey + helpKey).formatted(Formatting.DARK_GRAY)) + } + + override fun onStackClicked(stack: ItemStack, slot: Slot, clickType: ClickType, player: PlayerEntity): Boolean { + if (clickType != ClickType.RIGHT) return false + + val packet = when (val item = slot.stack.item) { + is MusicDiscItem -> { + val disc = stack.disc ?: ItemStack.EMPTY + stack.disc = slot.stack + slot.stack = disc + slot.markDirty() + + Play(stack.uuid, player.uuid, item.sound.id) + } + + Items.AIR -> { + slot.stack = stack.disc ?: return false + stack.disc = null + slot.markDirty() + + Stop(stack.uuid) + } + + else -> return false + } + + if (player.world.isClient) send(packet) + + return true + } + + override fun useOnBlock(context: ItemUsageContext): ActionResult { + val block = Blocks.JUKEBOX as JukeboxBlock + + val blockPos = context.blockPos + val stack = context.stack + val world = context.world + val player = context.player!! + + if (!isPlaying(stack)) return ActionResult.PASS + + val state = world.getBlockState(blockPos) + if (!state.isOf(block) || state.get(JukeboxBlock.HAS_RECORD)) return ActionResult.PASS + + world.sendAll(ChangePositionBlock(stack.uuid, blockPos)) + world.sendAll(ChangeDistance(stack.uuid, ChangeDistance.Boosted)) + + block.setRecord(player, world, blockPos, state, stack) + stack.decrement(1) + + return ActionResult.success(world.isClient) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/auxves/vibes/network/packet/ChangeDistance.kt b/src/main/kotlin/io/auxves/vibes/network/packet/ChangeDistance.kt new file mode 100644 index 0000000..fc12059 --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/network/packet/ChangeDistance.kt @@ -0,0 +1,24 @@ +package io.auxves.vibes.network.packet + +import io.auxves.vibes.Vibes +import net.minecraft.network.PacketByteBuf +import java.util.UUID + +data class ChangeDistance(val uuid: UUID, val distance: Float) : Packet { + companion object : PacketCompanion { + const val Normal = 16F + const val Boosted = 64F + + override val id = Vibes.id("change-distance") + + override fun fromBuf(buf: PacketByteBuf) = ChangeDistance( + buf.readUuid(), + buf.readFloat() + ) + } + + override val buffer = createPacket { + writeUuid(uuid) + writeFloat(distance) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/glossnyx/vibes/network/packet/ChangePositionBlock.kt b/src/main/kotlin/io/auxves/vibes/network/packet/ChangePositionBlock.kt similarity index 87% rename from src/main/kotlin/io/glossnyx/vibes/network/packet/ChangePositionBlock.kt rename to src/main/kotlin/io/auxves/vibes/network/packet/ChangePositionBlock.kt index b791996..66b84b9 100644 --- a/src/main/kotlin/io/glossnyx/vibes/network/packet/ChangePositionBlock.kt +++ b/src/main/kotlin/io/auxves/vibes/network/packet/ChangePositionBlock.kt @@ -1,6 +1,6 @@ -package io.glossnyx.vibes.network.packet +package io.auxves.vibes.network.packet -import io.glossnyx.vibes.Vibes +import io.auxves.vibes.Vibes import net.minecraft.network.PacketByteBuf import net.minecraft.util.math.BlockPos import java.util.UUID diff --git a/src/main/kotlin/io/glossnyx/vibes/network/packet/ChangePositionEntity.kt b/src/main/kotlin/io/auxves/vibes/network/packet/ChangePositionEntity.kt similarity index 85% rename from src/main/kotlin/io/glossnyx/vibes/network/packet/ChangePositionEntity.kt rename to src/main/kotlin/io/auxves/vibes/network/packet/ChangePositionEntity.kt index 4a3c9c7..70da0d0 100644 --- a/src/main/kotlin/io/glossnyx/vibes/network/packet/ChangePositionEntity.kt +++ b/src/main/kotlin/io/auxves/vibes/network/packet/ChangePositionEntity.kt @@ -1,6 +1,6 @@ -package io.glossnyx.vibes.network.packet +package io.auxves.vibes.network.packet -import io.glossnyx.vibes.Vibes +import io.auxves.vibes.Vibes import net.minecraft.network.PacketByteBuf import java.util.UUID diff --git a/src/main/kotlin/io/glossnyx/vibes/network/packet/Packets.kt b/src/main/kotlin/io/auxves/vibes/network/packet/Packets.kt similarity index 76% rename from src/main/kotlin/io/glossnyx/vibes/network/packet/Packets.kt rename to src/main/kotlin/io/auxves/vibes/network/packet/Packets.kt index 4a78463..f08b85a 100644 --- a/src/main/kotlin/io/glossnyx/vibes/network/packet/Packets.kt +++ b/src/main/kotlin/io/auxves/vibes/network/packet/Packets.kt @@ -1,4 +1,4 @@ -package io.glossnyx.vibes.network.packet +package io.auxves.vibes.network.packet import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking import net.fabricmc.fabric.api.networking.v1.PacketByteBufs @@ -19,6 +19,7 @@ interface PacketCompanion { fun fromBuf(buf: PacketByteBuf): Packet } +/** Registers a server receiver */ inline fun register(crossinline handler: (packet: T) -> Unit) { val companion = T::class.companionObjectInstance as PacketCompanion @@ -28,6 +29,13 @@ inline fun register(crossinline handler: (packet: T) -> Uni } } +/** Sends a packet from the server to the client associated with this player */ +fun ServerPlayerEntity.send(packet: Packet) { + val companion = packet::class.companionObjectInstance as PacketCompanion + ServerPlayNetworking.send(this, companion.id, packet.buffer) +} + +/** Registers a client receiver */ inline fun register(crossinline handler: (packet: T, player: ServerPlayerEntity) -> Unit) { val companion = T::class.companionObjectInstance as PacketCompanion @@ -37,16 +45,16 @@ inline fun register(crossinline handler: (packet: T, player } } -fun send(player: ServerPlayerEntity, packet: Packet) { - val companion = packet::class.companionObjectInstance as PacketCompanion - ServerPlayNetworking.send(player, companion.id, packet.buffer) -} - +/** Sends a packet from the client to the server */ fun send(packet: Packet) { val companion = packet::class.companionObjectInstance as PacketCompanion ClientPlayNetworking.send(companion.id, packet.buffer) } -fun World.sendAll(packet: Packet) = (this as? ServerWorld)?.players?.forEach { send(it, packet) } +/** Sends a packet to every client */ +fun World.sendAll(packet: Packet) { + val world = this as? ServerWorld ?: return + world.players.forEach { it.send(packet) } +} fun createPacket(block: PacketByteBuf.() -> Unit) = PacketByteBufs.create().apply(block)!! diff --git a/src/main/kotlin/io/glossnyx/vibes/network/packet/Play.kt b/src/main/kotlin/io/auxves/vibes/network/packet/Play.kt similarity index 62% rename from src/main/kotlin/io/glossnyx/vibes/network/packet/Play.kt rename to src/main/kotlin/io/auxves/vibes/network/packet/Play.kt index 365a93a..f29a443 100644 --- a/src/main/kotlin/io/glossnyx/vibes/network/packet/Play.kt +++ b/src/main/kotlin/io/auxves/vibes/network/packet/Play.kt @@ -1,11 +1,11 @@ -package io.glossnyx.vibes.network.packet +package io.auxves.vibes.network.packet -import io.glossnyx.vibes.Vibes +import io.auxves.vibes.Vibes import net.minecraft.network.PacketByteBuf import net.minecraft.util.Identifier import java.util.UUID -data class Play(val uuid: UUID, val entityUUID: UUID, val identifier: Identifier) : Packet { +data class Play(val uuid: UUID, val player: UUID, val sound: Identifier) : Packet { companion object : PacketCompanion { override val id = Vibes.id("play") @@ -18,7 +18,7 @@ data class Play(val uuid: UUID, val entityUUID: UUID, val identifier: Identifier override val buffer = createPacket { writeUuid(uuid) - writeUuid(entityUUID) - writeIdentifier(identifier) + writeUuid(player) + writeIdentifier(sound) } } \ No newline at end of file diff --git a/src/main/kotlin/io/glossnyx/vibes/network/packet/Stop.kt b/src/main/kotlin/io/auxves/vibes/network/packet/Stop.kt similarity index 81% rename from src/main/kotlin/io/glossnyx/vibes/network/packet/Stop.kt rename to src/main/kotlin/io/auxves/vibes/network/packet/Stop.kt index 41590f6..0ab85ee 100644 --- a/src/main/kotlin/io/glossnyx/vibes/network/packet/Stop.kt +++ b/src/main/kotlin/io/auxves/vibes/network/packet/Stop.kt @@ -1,12 +1,13 @@ -package io.glossnyx.vibes.network.packet +package io.auxves.vibes.network.packet -import io.glossnyx.vibes.Vibes +import io.auxves.vibes.Vibes import net.minecraft.network.PacketByteBuf import java.util.UUID data class Stop(val uuid: UUID) : Packet { companion object : PacketCompanion { override val id = Vibes.id("stop") + override fun fromBuf(buf: PacketByteBuf) = Stop(buf.readUuid()) } diff --git a/src/main/kotlin/io/auxves/vibes/server/Bridges.kt b/src/main/kotlin/io/auxves/vibes/server/Bridges.kt new file mode 100644 index 0000000..2d9ad9c --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/server/Bridges.kt @@ -0,0 +1,56 @@ +package io.auxves.vibes.server + +import io.auxves.vibes.mixin.EnderChestInventoryAccessor +import io.auxves.vibes.network.packet.* +import io.auxves.vibes.util.* +import net.minecraft.block.entity.BlockEntity +import net.minecraft.entity.Entity +import net.minecraft.entity.ItemEntity +import net.minecraft.entity.player.PlayerEntity +import net.minecraft.inventory.EnderChestInventory +import net.minecraft.inventory.Inventory +import net.minecraft.item.ItemStack +import net.minecraft.world.World + +fun onDisconnect(player: PlayerEntity) { + player.inventory.main.forEach { stopPlaying(it, player.world) } +} + +fun handleEnderChest(inventory: Inventory, stack: ItemStack) { + if (inventory !is EnderChestInventory) return + + val world = (inventory as? EnderChestInventoryAccessor)?.activeBlockEntity?.world ?: return + + stopPlaying(stack, world) +} + +fun onBreakShulkerBox(entity: Entity) { + if (entity !is ItemEntity) return + if (vibeTypeOf(entity.stack) != VibeType.SHULKER) return + + changePosition(entity.stack, entity) +} + +fun stopPlaying(stack: ItemStack, world: World) { + vibesIn(stack).map { it.uuid }.forEach { world.sendAll(Stop(it)) } +} + +fun changePosition(stack: ItemStack, block: BlockEntity) { + val world = block.world ?: return + + vibesIn(stack).map { it.uuid }.forEach { + world.sendAll(ChangePositionBlock(it, block.pos)) + } +} + +fun changePosition(stack: ItemStack, entity: Entity) { + vibesIn(stack).map { it.uuid }.forEach { + entity.world.sendAll(ChangePositionEntity(it, entity.uuid)) + } +} + +fun setDistance(world: World, stack: ItemStack, distance: Float) { + vibesIn(stack).map { it.uuid }.forEach { + world.sendAll(ChangeDistance(it, distance)) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/auxves/vibes/server/Server.kt b/src/main/kotlin/io/auxves/vibes/server/Server.kt new file mode 100644 index 0000000..5ae3e95 --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/server/Server.kt @@ -0,0 +1,8 @@ +package io.auxves.vibes.server + +import io.auxves.vibes.network.packet.* + +fun initServer() { + register { data, player -> player.send(data) } + register { data, player -> player.send(data) } +} \ No newline at end of file diff --git a/src/main/kotlin/io/auxves/vibes/sound/BlockPositionProvider.kt b/src/main/kotlin/io/auxves/vibes/sound/BlockPositionProvider.kt new file mode 100644 index 0000000..6b42112 --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/sound/BlockPositionProvider.kt @@ -0,0 +1,9 @@ +package io.auxves.vibes.sound + +import net.minecraft.util.math.BlockPos + +class BlockPositionProvider(blockPos: BlockPos) : PositionProvider { + override val x = blockPos.x.toDouble() + 0.5 + override val y = blockPos.y.toDouble() + 0.5 + override val z = blockPos.z.toDouble() + 0.5 +} \ No newline at end of file diff --git a/src/main/kotlin/io/auxves/vibes/sound/EntityPositionProvider.kt b/src/main/kotlin/io/auxves/vibes/sound/EntityPositionProvider.kt new file mode 100644 index 0000000..0c16d7c --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/sound/EntityPositionProvider.kt @@ -0,0 +1,9 @@ +package io.auxves.vibes.sound + +import net.minecraft.entity.Entity + +class EntityPositionProvider(val entity: Entity) : PositionProvider { + override val x get() = entity.x + override val y get() = entity.y + override val z get() = entity.z +} \ No newline at end of file diff --git a/src/main/kotlin/io/auxves/vibes/sound/PositionProvider.kt b/src/main/kotlin/io/auxves/vibes/sound/PositionProvider.kt new file mode 100644 index 0000000..638c19c --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/sound/PositionProvider.kt @@ -0,0 +1,7 @@ +package io.auxves.vibes.sound + +interface PositionProvider { + val x: Double + val y: Double + val z: Double +} \ No newline at end of file diff --git a/src/main/kotlin/io/auxves/vibes/sound/VibeInstance.kt b/src/main/kotlin/io/auxves/vibes/sound/VibeInstance.kt new file mode 100644 index 0000000..9156f54 --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/sound/VibeInstance.kt @@ -0,0 +1,20 @@ +package io.auxves.vibes.sound + +import net.minecraft.client.sound.MovingSoundInstance +import net.minecraft.client.sound.SoundInstance +import net.minecraft.sound.SoundCategory +import net.minecraft.sound.SoundEvent + +class VibeInstance(var position: PositionProvider, event: SoundEvent) : + MovingSoundInstance(event, SoundCategory.RECORDS, SoundInstance.createRandom()) +{ + init { + tick() + } + + override fun tick() { + x = position.x + y = position.y + z = position.z + } +} diff --git a/src/main/kotlin/io/auxves/vibes/util/Items.kt b/src/main/kotlin/io/auxves/vibes/util/Items.kt new file mode 100644 index 0000000..3d97e7e --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/util/Items.kt @@ -0,0 +1,29 @@ +package io.auxves.vibes.util + +import io.auxves.vibes.item.Vibe +import net.minecraft.block.ShulkerBoxBlock +import net.minecraft.item.BlockItem +import net.minecraft.item.ItemStack + +enum class VibeType { + VIBE, + SHULKER +} + +fun isPlaying(stack: ItemStack): Boolean = when (vibeTypeOf(stack)) { + VibeType.VIBE -> stack.disc != null + VibeType.SHULKER -> shulkerInventoryOf(stack).any(::isPlaying) + else -> false +} + +fun vibeTypeOf(stack: ItemStack): VibeType? = when { + stack.item is Vibe -> VibeType.VIBE + (stack.item as? BlockItem)?.block is ShulkerBoxBlock -> VibeType.SHULKER + else -> null +} + +fun vibesIn(stack: ItemStack): Sequence = when (vibeTypeOf(stack)) { + VibeType.VIBE -> sequenceOf(stack) + VibeType.SHULKER -> shulkerInventoryOf(stack).asSequence().flatMap(::vibesIn) + else -> sequenceOf() +}.filter(::isPlaying) diff --git a/src/main/kotlin/io/auxves/vibes/util/Tags.kt b/src/main/kotlin/io/auxves/vibes/util/Tags.kt new file mode 100644 index 0000000..21a88fa --- /dev/null +++ b/src/main/kotlin/io/auxves/vibes/util/Tags.kt @@ -0,0 +1,37 @@ +package io.auxves.vibes.util + +import net.minecraft.inventory.Inventories +import net.minecraft.item.ItemStack +import net.minecraft.nbt.NbtCompound +import net.minecraft.util.collection.DefaultedList +import java.util.UUID + +object Tags { + const val DISC = "Disc" + const val UUID = "VibeUUID" + + const val SHULKER = "BlockEntityTag" +} + +var ItemStack.uuid: UUID + get() { + if (orCreateNbt.containsUuid(Tags.UUID)) return orCreateNbt.getUuid(Tags.UUID) + val new = UUID.randomUUID() + uuid = new + return new + } + set(new) = orCreateNbt.putUuid(Tags.UUID, new) + +var ItemStack.disc: ItemStack? + get() = getSubNbt(Tags.DISC)?.let { ItemStack.fromNbt(it) } + set(stack) { + if (stack == null || stack == ItemStack.EMPTY) return removeSubNbt(Tags.DISC) + setSubNbt(Tags.DISC, stack.writeNbt(NbtCompound())) + } + +fun shulkerInventoryOf(stack: ItemStack): List { + val nbt = stack.getSubNbt(Tags.SHULKER) ?: return listOf() + val inventory = DefaultedList.ofSize(27, ItemStack.EMPTY) + Inventories.readNbt(nbt, inventory) + return inventory.toList() +} \ No newline at end of file diff --git a/src/main/kotlin/io/glossnyx/vibes/Entrypoint.kt b/src/main/kotlin/io/glossnyx/vibes/Entrypoint.kt deleted file mode 100644 index cb19813..0000000 --- a/src/main/kotlin/io/glossnyx/vibes/Entrypoint.kt +++ /dev/null @@ -1,21 +0,0 @@ -package io.glossnyx.vibes - -import io.glossnyx.vibes.item.Vibe -import io.glossnyx.vibes.network.ClientNetworking -import io.glossnyx.vibes.network.ServerNetworking -import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry - -object Vibes { - fun id(path: String) = Identifier("vibes", path) -} - -fun init() { - Registry.register(Registry.ITEM, Vibe.id, Vibe) - - ServerNetworking.init() -} - -fun initClient() { - ClientNetworking.init() -} diff --git a/src/main/kotlin/io/glossnyx/vibes/item/Vibe.kt b/src/main/kotlin/io/glossnyx/vibes/item/Vibe.kt deleted file mode 100644 index 40fe440..0000000 --- a/src/main/kotlin/io/glossnyx/vibes/item/Vibe.kt +++ /dev/null @@ -1,62 +0,0 @@ -package io.glossnyx.vibes.item - -import io.glossnyx.vibes.Vibes -import io.glossnyx.vibes.network.packet.* -import io.glossnyx.vibes.util.* -import net.minecraft.client.item.TooltipContext -import net.minecraft.entity.player.PlayerEntity -import net.minecraft.inventory.StackReference -import net.minecraft.item.* -import net.minecraft.screen.slot.Slot -import net.minecraft.text.Text -import net.minecraft.util.ClickType -import net.minecraft.world.World -import java.util.* - -private val settings: Item.Settings = Item.Settings() - .group(ItemGroup.MISC) - .maxCount(1) - -object Vibe : Item(settings) { - val id = Vibes.id("vibe") - - override fun appendTooltip(stack: ItemStack?, world: World?, tooltip: MutableList?, context: TooltipContext?) { - discOf(stack)?.item?.appendTooltip(stack, world, tooltip, context) - } - - override fun onStackClicked(stack: ItemStack?, slot: Slot?, clickType: ClickType?, player: PlayerEntity?): Boolean { - if (stack == null) return false - if (slot == null) return false - if (player == null) return false - if (vibeTypeOf(stack) != VibeType.VIBE) return false - if (clickType != ClickType.RIGHT) return false - - val uuid = uuidOf(stack) ?: UUID.randomUUID() - setUUIDOf(stack, uuid) - - return when (val item = slot.stack.item) { - is MusicDiscItem -> { - val disc = discOf(stack) ?: ItemStack.EMPTY - setDiscOf(stack, slot.stack) - slot.stack = disc - slot.markDirty() - - if (player.world.isClient) send(Play(uuid, player.uuid, item.sound.id)) - - true - } - - Items.AIR -> { - slot.stack = discOf(stack) ?: return false - setDiscOf(stack, ItemStack.EMPTY) - slot.markDirty() - - if (player.world.isClient) send(Stop(uuid)) - - true - } - - else -> false - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/io/glossnyx/vibes/network/ClientNetworking.kt b/src/main/kotlin/io/glossnyx/vibes/network/ClientNetworking.kt deleted file mode 100644 index 8814aea..0000000 --- a/src/main/kotlin/io/glossnyx/vibes/network/ClientNetworking.kt +++ /dev/null @@ -1,56 +0,0 @@ -package io.glossnyx.vibes.network - -import io.glossnyx.vibes.network.packet.* -import io.glossnyx.vibes.sound.* -import kotlinx.coroutines.* -import net.minecraft.client.MinecraftClient -import net.minecraft.sound.SoundEvent -import java.util.UUID - -object ClientNetworking { - private val client = MinecraftClient.getInstance() - private val vibeInstances = mutableListOf() - - private fun getInstance(uuid: UUID) = vibeInstances.find { it.uuid == uuid } - - private fun getEntity(uuid: UUID) = client.world?.let { world -> - world.players.plus(world.entities).find { it.uuid == uuid } - } - - private fun stop(uuid: UUID) = getInstance(uuid)?.let { - client.soundManager.stop(it) - vibeInstances.remove(it) - } - - fun init() { - val scope = CoroutineScope(Dispatchers.Unconfined) - - register { data -> - stop(data.uuid) - - val entity = getEntity(data.entityUUID) ?: return@register - val instance = VibeInstance(data.uuid, EntityPositionProvider(entity), SoundEvent(data.identifier)) - vibeInstances.add(instance) - - client.soundManager.play(instance) - } - - register { data -> stop(data.uuid) } - - register { data -> - getInstance(data.uuid)?.let { - scope.launch { - delay(100) - val entity = getEntity(data.entityUUID) ?: return@launch - it.position = EntityPositionProvider(entity) - } - } - } - - register { data -> - getInstance(data.uuid)?.let { - it.position = BlockPositionProvider(data.blockPos) - } - } - } -} diff --git a/src/main/kotlin/io/glossnyx/vibes/network/ServerNetworking.kt b/src/main/kotlin/io/glossnyx/vibes/network/ServerNetworking.kt deleted file mode 100644 index 931472f..0000000 --- a/src/main/kotlin/io/glossnyx/vibes/network/ServerNetworking.kt +++ /dev/null @@ -1,74 +0,0 @@ -package io.glossnyx.vibes.network - -import io.glossnyx.vibes.network.packet.* -import io.glossnyx.vibes.mixin.EnderChestInventoryAccessor -import io.glossnyx.vibes.util.* -import net.minecraft.block.entity.BlockEntity -import net.minecraft.entity.Entity -import net.minecraft.entity.ItemEntity -import net.minecraft.entity.player.PlayerEntity -import net.minecraft.inventory.EnderChestInventory -import net.minecraft.inventory.Inventory -import net.minecraft.item.ItemStack -import net.minecraft.world.World - -object ServerNetworking { - fun onDisconnect(player: PlayerEntity) { - player.inventory.main.forEach { stopPlaying(it, player.world) } - } - - fun stopPlaying(stack: ItemStack, world: World) { - forEachVibe(stack) { - val uuid = uuidOf(it) ?: return@forEachVibe - world.sendAll(Stop(uuid)) - } - } - - fun handleEnderChest(inventory: Inventory, stack: ItemStack) { - if (inventory !is EnderChestInventory) return - if (!isPlaying(stack)) return - - val world = (inventory as? EnderChestInventoryAccessor)?.activeBlockEntity?.world ?: return - if (world.isClient) return - - stopPlaying(stack, world) - } - - fun onBreakShulkerBox(entity: Entity) { - if (entity !is ItemEntity) return - if (vibeTypeOf(entity.stack) != VibeType.SHULKER) return - - changePositionProvider(entity.stack, entity) - } - - fun onPickup(player: PlayerEntity, entity: Entity?) { - if (entity !is ItemEntity) return - - changePositionProvider(entity.stack, player) - } - - fun changePositionProvider(stack: ItemStack, block: BlockEntity?) { - val world = block?.world ?: return - if (world.isClient) return - - forEachVibe(stack) { - val uuid = uuidOf(it) ?: return@forEachVibe - world.sendAll(ChangePositionBlock(uuid, block.pos)) - } - } - - fun changePositionProvider(stack: ItemStack, entity: Entity?) { - if (entity == null) return - if (entity.world.isClient) return - - forEachVibe(stack) { - val uuid = uuidOf(it) ?: return@forEachVibe - entity.world.sendAll(ChangePositionEntity(uuid, entity.uuid)) - } - } - - fun init() { - register { data, player -> player.world.sendAll(data) } - register { data, player -> player.world.sendAll(data) } - } -} diff --git a/src/main/kotlin/io/glossnyx/vibes/sound/BlockPositionProvider.kt b/src/main/kotlin/io/glossnyx/vibes/sound/BlockPositionProvider.kt deleted file mode 100644 index 39a44dc..0000000 --- a/src/main/kotlin/io/glossnyx/vibes/sound/BlockPositionProvider.kt +++ /dev/null @@ -1,13 +0,0 @@ -package io.glossnyx.vibes.sound - -import net.minecraft.util.math.BlockPos - -class BlockPositionProvider(blockPos: BlockPos) : PositionProvider { - private val x = blockPos.x.toDouble() + 0.5 - private val y = blockPos.y.toDouble() + 0.5 - private val z = blockPos.z.toDouble() + 0.5 - - override fun getX() = x - override fun getY() = y - override fun getZ() = z -} \ No newline at end of file diff --git a/src/main/kotlin/io/glossnyx/vibes/sound/EntityPositionProvider.kt b/src/main/kotlin/io/glossnyx/vibes/sound/EntityPositionProvider.kt deleted file mode 100644 index f37bbf9..0000000 --- a/src/main/kotlin/io/glossnyx/vibes/sound/EntityPositionProvider.kt +++ /dev/null @@ -1,9 +0,0 @@ -package io.glossnyx.vibes.sound - -import net.minecraft.entity.Entity - -class EntityPositionProvider(private val entity: Entity) : PositionProvider { - override fun getX() = entity.x - override fun getY() = entity.y - override fun getZ() = entity.z -} \ No newline at end of file diff --git a/src/main/kotlin/io/glossnyx/vibes/sound/PositionProvider.kt b/src/main/kotlin/io/glossnyx/vibes/sound/PositionProvider.kt deleted file mode 100644 index 41142ce..0000000 --- a/src/main/kotlin/io/glossnyx/vibes/sound/PositionProvider.kt +++ /dev/null @@ -1,7 +0,0 @@ -package io.glossnyx.vibes.sound - -interface PositionProvider { - fun getX(): Double - fun getY(): Double - fun getZ(): Double -} \ No newline at end of file diff --git a/src/main/kotlin/io/glossnyx/vibes/sound/VibeInstance.kt b/src/main/kotlin/io/glossnyx/vibes/sound/VibeInstance.kt deleted file mode 100644 index e45b66b..0000000 --- a/src/main/kotlin/io/glossnyx/vibes/sound/VibeInstance.kt +++ /dev/null @@ -1,18 +0,0 @@ -package io.glossnyx.vibes.sound - -import net.minecraft.client.sound.MovingSoundInstance -import net.minecraft.sound.SoundCategory -import net.minecraft.sound.SoundEvent -import java.util.UUID - -class VibeInstance(val uuid: UUID, var position: PositionProvider, event: SoundEvent) : MovingSoundInstance(event, SoundCategory.RECORDS) { - init { - tick() - } - - override fun tick() { - x = position.getX() - y = position.getY() - z = position.getZ() - } -} diff --git a/src/main/kotlin/io/glossnyx/vibes/util/Items.kt b/src/main/kotlin/io/glossnyx/vibes/util/Items.kt deleted file mode 100644 index 7d4ad6d..0000000 --- a/src/main/kotlin/io/glossnyx/vibes/util/Items.kt +++ /dev/null @@ -1,46 +0,0 @@ -package io.glossnyx.vibes.util - -import io.glossnyx.vibes.item.Vibe -import net.minecraft.block.ShulkerBoxBlock -import net.minecraft.inventory.Inventories -import net.minecraft.item.BlockItem -import net.minecraft.item.ItemStack -import net.minecraft.util.collection.DefaultedList - -enum class VibeType { - VIBE, - SHULKER -} - -fun shulkerInventoryOf(stack: ItemStack): List? { - val nbt = stack.getSubNbt("BlockEntityTag") ?: return null - val inventory = DefaultedList.ofSize(27, ItemStack.EMPTY) - Inventories.readNbt(nbt, inventory) - return inventory.toList() -} - -fun isPlaying(stack: ItemStack): Boolean { - return when (vibeTypeOf(stack)) { - VibeType.VIBE -> uuidOf(stack) != null && discOf(stack) != null - VibeType.SHULKER -> shulkerInventoryOf(stack)?.find(::isPlaying) != null - else -> false - } -} - -fun vibeTypeOf(stack: ItemStack): VibeType? { - return when (val item = stack.item) { - is Vibe -> VibeType.VIBE - is BlockItem -> if (item.block is ShulkerBoxBlock) VibeType.SHULKER else null - else -> null - } -} - -fun forEachVibe(stack: ItemStack, fn: (stack: ItemStack) -> Unit) { - if (!isPlaying(stack)) return - - when (vibeTypeOf(stack)) { - VibeType.VIBE -> fn(stack) - VibeType.SHULKER -> shulkerInventoryOf(stack)?.filter(::isPlaying)?.forEach { forEachVibe(it, fn) } - else -> return - } -} diff --git a/src/main/kotlin/io/glossnyx/vibes/util/Tags.kt b/src/main/kotlin/io/glossnyx/vibes/util/Tags.kt deleted file mode 100644 index c7a1237..0000000 --- a/src/main/kotlin/io/glossnyx/vibes/util/Tags.kt +++ /dev/null @@ -1,25 +0,0 @@ -package io.glossnyx.vibes.util - -import net.minecraft.item.ItemStack -import net.minecraft.nbt.NbtCompound -import java.util.UUID - -object Tags { - const val DISC = "Disc" - const val UUID = "VibeUUID" -} - -fun uuidOf(stack: ItemStack) = stack.nbt?.let { - if (it.containsUuid(Tags.UUID)) it.getUuid(Tags.UUID) else null -} - -fun setUUIDOf(stack: ItemStack, uuid: UUID) = stack.orCreateNbt.putUuid(Tags.UUID, uuid) - -fun discOf(stack: ItemStack?) = stack?.getSubNbt(Tags.DISC)?.let { - ItemStack.fromNbt(it) -} - -fun setDiscOf(stack: ItemStack, disc: ItemStack) { - if (disc == ItemStack.EMPTY) return stack.removeSubNbt(Tags.DISC) - stack.setSubNbt(Tags.DISC, disc.writeNbt(NbtCompound())) -} diff --git a/src/main/resources/assets/vibes/lang/en_us.json b/src/main/resources/assets/vibes/lang/en_us.json index 5bc92ee..3febdb9 100644 --- a/src/main/resources/assets/vibes/lang/en_us.json +++ b/src/main/resources/assets/vibes/lang/en_us.json @@ -1,3 +1,5 @@ { - "item.vibes.vibe": "Vibe" + "item.vibes.vibe": "Vibe", + "item.vibes.vibe.play": "Right click on a music disc to play", + "item.vibes.vibe.stop": "Right click on an empty slot to stop" } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 532beff..81dd38c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -14,14 +14,13 @@ "environment": "*", "entrypoints": { "main": ["io.${author}.${id}.EntrypointKt::init"], - "client": ["io.${author}.${id}.EntrypointKt::initClient"] + "client": ["io.${author}.${id}.client.ClientKt::init"] }, "mixins": ["${id}.mixins.json"], "depends": { - "minecraft": "1.18.2", + "minecraft": "1.19.x", "fabricloader": "*", - "fabric-resource-loader-v0": "*", - "fabric-networking-api-v1": "*", + "fabric-api": "*", "fabric-language-kotlin": "*" } } diff --git a/src/main/resources/vibes.mixins.json b/src/main/resources/vibes.mixins.json index 2a2cacc..f856c01 100644 --- a/src/main/resources/vibes.mixins.json +++ b/src/main/resources/vibes.mixins.json @@ -1,28 +1,29 @@ { "required": true, "minVersion": "0.8", - "package": "io.glossnyx.vibes.mixin", + "package": "io.auxves.vibes.mixin", "compatibilityLevel": "JAVA_17", + "server": [], + "client": [], "mixins": [ "AbstractFurnaceBlockEntityMixin", "BlockMixin", "EnderChestInventoryAccessor", - "EntityMixin", "HopperBlockEntityMixin", "ItemDispenserBehaviorMixin", "ItemEntityMixin", "ItemFrameEntityMixin", + "JukeboxBlockMixin", "LootableContainerBlockEntityMixin", "PlayerEntityMixin", "PlayerInventoryMixin", - "ServerPlayerEntityMixin", "ServerPlayNetworkHandlerMixin", "ShulkerBoxBlockMixin", "SimpleInventoryMixin", + "SoundManagerAccessor", + "SoundSystemAccessor", "StorageMinecartEntityMixin" ], - "client": [], - "server": [], "injectors": { "defaultRequire": 1 }