-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 44a61e9
Showing
47 changed files
with
1,309 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/.gradle | ||
/.idea | ||
/build | ||
/run | ||
/gradle | ||
/gradlew* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright © 2020 Arno Hovhannisyan | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Vibes | ||
|
||
Vibes adds a new item, the Vibe, that lets you play music discs on the go without needing a jukebox. | ||
|
||
Vibes try to position their music logically, which means that putting a Vibe inside a chest while it's still playing will move the sound source to the chest's position. This not only works with chests, but with all vanilla storage blocks, storage minecarts, shulker boxes, and item frames. | ||
|
||
Dropping a Vibe on the ground will move the sound source to the item entity, and picking it up will move the sound source to the position of the player that picked it up. | ||
|
||
### Dependencies | ||
|
||
- [Fabric Loader] | ||
- [Fabric API] | ||
- [Fabric Language Kotlin] | ||
|
||
## Installation | ||
|
||
You have three options for downloading Vibes. | ||
|
||
- [CurseForge] | ||
- [Modrinth] | ||
- [GitHub Releases] | ||
|
||
## Crafting | ||
|
||
A Vibe can be crafted with **1 Jukebox** and **4 Iron Ingots**. | ||
|
||
![crafting recipe](https://i.imgur.com/maHXzce.png) | ||
|
||
## Usage | ||
|
||
The mechanics for Vibe are very similar to how the bundle is used. | ||
|
||
### Playing Discs | ||
|
||
1. Pick up the Vibe | ||
1. Hover over the disc | ||
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 | ||
|
||
## Compatibility | ||
|
||
Vibes is compatible with mods that introduce new music discs into the game, so you can enjoy your favorite modded music on the go. | ||
|
||
## Suggestions | ||
|
||
- [Disco] - Modular music disc loader | ||
|
||
<!-- Dependencies --> | ||
|
||
[fabric loader]: https://fabricmc.net/use | ||
[fabric api]: https://www.curseforge.com/minecraft/mc-mods/fabric-api | ||
[fabric language kotlin]: https://www.curseforge.com/minecraft/mc-mods/fabric-language-kotlin | ||
|
||
<!-- Distribution --> | ||
|
||
[curseforge]: https://www.curseforge.com/minecraft/mc-mods/vibes | ||
[modrinth]: https://modrinth.com/mod/vibes | ||
[github releases]: https://github.com/glossnyx/vibes/releases | ||
|
||
<!-- Suggestions --> | ||
|
||
[disco]: https://github.com/glossnyx/disco |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
import com.modrinth.minotaur.TaskModrinthUpload | ||
|
||
java.sourceCompatibility = JavaVersion.VERSION_1_8 | ||
java.targetCompatibility = JavaVersion.VERSION_1_8 | ||
|
||
fun getArtifactPath(): String { | ||
return tasks.named<Jar>("jar").get().archiveFile.get().toString() | ||
} | ||
|
||
fun p(name: String): String { | ||
return project.property(name).toString() | ||
} | ||
|
||
plugins { | ||
id("fabric-loom") | ||
id("com.modrinth.minotaur") version "1.1.0" | ||
kotlin("jvm") version "1.4.21" | ||
} | ||
|
||
repositories { | ||
maven("https://maven.fabricmc.net/") | ||
} | ||
|
||
dependencies { | ||
minecraft("com.mojang:minecraft:${p("minecraft.target")}") | ||
mappings("net.fabricmc:yarn:${p("yarn")}:v2") | ||
modImplementation("net.fabricmc:fabric-loader:${p("loader")}") | ||
modImplementation("net.fabricmc.fabric-api:fabric-api:${p("fabric_api")}") | ||
modImplementation("net.fabricmc:fabric-language-kotlin:${p("fabric_kotlin")}") | ||
} | ||
|
||
tasks.named<Copy>("processResources") { | ||
duplicatesStrategy = DuplicatesStrategy.INCLUDE | ||
|
||
from(sourceSets["main"].resources.srcDirs) { | ||
include("fabric.mod.json") | ||
expand("version" to project.version) | ||
} | ||
|
||
from(sourceSets["main"].resources.srcDirs) { | ||
exclude("fabric.mod.json") | ||
} | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
|
||
task<TaskModrinthUpload>("modrinth") { | ||
token = System.getenv("MODRINTH_TOKEN") | ||
projectId = p("id") | ||
|
||
versionNumber = p("version") | ||
versionName = "${project.property("name")} v$versionNumber" | ||
|
||
uploadFile = getArtifactPath() | ||
|
||
addGameVersion(p("minecraft.target")) | ||
|
||
p("minecraft.compatible").split(", ").forEach { addGameVersion(it) } | ||
|
||
addLoader("fabric") | ||
} | ||
|
||
task("publish") { | ||
dependsOn("build") | ||
dependsOn("modrinth") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
kotlin.code.style=official | ||
org.gradle.jvmargs=-Xmx1G | ||
|
||
# Project | ||
id=vibes | ||
name=Vibes | ||
version=1.0.0 | ||
|
||
# Curse | ||
|
||
curse.id=?????? | ||
|
||
# Versions (https://modmuss50.me/fabric.html) | ||
minecraft.target=1.16.4 | ||
minecraft.compatible=1.16.3, 1.16.2 | ||
yarn=1.16.4+build.7 | ||
loader=0.10.8 | ||
|
||
fabric_api=0.29.2+1.16 | ||
fabric_kotlin=1.4.21+build.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
maven("https://maven.fabricmc.net") | ||
} | ||
|
||
plugins { | ||
id("fabric-loom") version "0.5-SNAPSHOT" | ||
kotlin("jvm") version embeddedKotlinVersion | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/io/glossnyx/vibes/mixin/AbstractFurnaceBlockEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.glossnyx.vibes.mixin; | ||
|
||
import io.glossnyx.vibes.network.ServerNetworking; | ||
import net.minecraft.block.entity.AbstractFurnaceBlockEntity; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.block.entity.BlockEntityType; | ||
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 extends BlockEntity { | ||
public AbstractFurnaceBlockEntityMixin(BlockEntityType<?> type) { | ||
super(type); | ||
} | ||
|
||
@Inject(method = "setStack", at = @At("HEAD")) | ||
private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) { | ||
ServerNetworking.INSTANCE.changePositionProvider(stack, this); | ||
} | ||
|
||
@Inject(method = "removeStack(II)Lnet/minecraft/item/ItemStack;", at = @At("RETURN")) | ||
private void onRemoveStack(int slot, int amount, CallbackInfoReturnable<ItemStack> cir) { | ||
ServerNetworking.INSTANCE.changePositionProvider(cir.getReturnValue(), this.world); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.glossnyx.vibes.mixin; | ||
|
||
import io.glossnyx.vibes.network.ServerNetworking; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.entity.Entity; | ||
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(Block.class) | ||
class BlockMixin { | ||
@Redirect( | ||
method = "dropStack", | ||
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); | ||
return world.spawnEntity(entity); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/io/glossnyx/vibes/mixin/EnderChestInventoryAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.glossnyx.vibes.mixin; | ||
|
||
import net.minecraft.block.entity.EnderChestBlockEntity; | ||
import net.minecraft.inventory.EnderChestInventory; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(EnderChestInventory.class) | ||
public interface EnderChestInventoryAccessor { | ||
@Accessor("activeBlockEntity") | ||
EnderChestBlockEntity getActiveBlockEntity(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
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 = "remove", at = @At("HEAD")) | ||
private void onRemove(CallbackInfo ci) { | ||
if (this.world.isClient) return; | ||
|
||
//noinspection ConstantConditions | ||
if (!ItemEntity.class.isInstance(this)) return; | ||
|
||
ServerNetworking.INSTANCE.stopPlaying(ItemEntity.class.cast(this).getStack(), world); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/io/glossnyx/vibes/mixin/HopperBlockEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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.ItemEntity; | ||
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.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(HopperBlockEntity.class) | ||
class HopperBlockEntityMixin extends BlockEntity { | ||
public HopperBlockEntityMixin(BlockEntityType<?> type) { | ||
super(type); | ||
} | ||
|
||
@Inject(method = "setStack", at = @At("HEAD")) | ||
private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) { | ||
ServerNetworking.INSTANCE.changePositionProvider(stack, this); | ||
} | ||
|
||
@Inject(method = "removeStack(II)Lnet/minecraft/item/ItemStack;", at = @At("RETURN")) | ||
private void onRemoveStack(int slot, int amount, CallbackInfoReturnable<ItemStack> cir) { | ||
ServerNetworking.INSTANCE.changePositionProvider(cir.getReturnValue(), this.world); | ||
} | ||
|
||
@Redirect( | ||
method = "extract(Lnet/minecraft/inventory/Inventory;Lnet/minecraft/entity/ItemEntity;)Z", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;remove()V") | ||
) | ||
private static void onRemoveItem(ItemEntity entity) { | ||
if (!entity.world.isClient && ItemsKt.vibeTypeOf(entity.getStack()) == VibeType.VIBE) entity.removed = true; | ||
else entity.remove(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/io/glossnyx/vibes/mixin/ItemDispenserBehaviorMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.glossnyx.vibes.mixin; | ||
|
||
import io.glossnyx.vibes.network.ServerNetworking; | ||
import net.minecraft.block.dispenser.ItemDispenserBehavior; | ||
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.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(ItemDispenserBehavior.class) | ||
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); | ||
return world.spawnEntity(entity); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/io/glossnyx/vibes/mixin/ItemEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
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) | ||
abstract | ||
class ItemEntityMixin { | ||
@Shadow private int age; | ||
@Shadow public abstract ItemStack getStack(); | ||
|
||
@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;remove()V")) | ||
private void onRemove(ItemEntity entity) { | ||
if (ItemsKt.isPlaying(entity.getStack())) age = 0; | ||
else entity.remove(); | ||
} | ||
} |
Oops, something went wrong.