Skip to content

Commit

Permalink
Merge pull request #4 from auxves/1.19
Browse files Browse the repository at this point in the history
Update to 1.19
  • Loading branch information
auxves authored Nov 18, 2022
2 parents dbb7d88 + c1a61cc commit 208d1d3
Show file tree
Hide file tree
Showing 56 changed files with 581 additions and 554 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
6 changes: 1 addition & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")}")
}

Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
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 {
AbstractFurnaceBlockEntity that = AbstractFurnaceBlockEntity.class.cast(this);

@Inject(method = "setStack", at = @At("HEAD"))
private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) {
ServerNetworking.INSTANCE.changePositionProvider(stack, that);
BridgesKt.changePosition(stack, that);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/io/auxves/vibes/mixin/HopperBlockEntityMixin.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
}
33 changes: 33 additions & 0 deletions src/main/java/io/auxves/vibes/mixin/ItemEntityMixin.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}
24 changes: 24 additions & 0 deletions src/main/java/io/auxves/vibes/mixin/JukeboxBlockMixin.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
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 {
LootableContainerBlockEntity that = LootableContainerBlockEntity.class.cast(this);

@Inject(method = "setStack", at = @At("HEAD"))
private void onSetStack(int slot, ItemStack stack, CallbackInfo ci) {
ServerNetworking.INSTANCE.changePositionProvider(stack, that);
BridgesKt.changePosition(stack, that);
}
}
Original file line number Diff line number Diff line change
@@ -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<ItemEntity> cir) {
ServerNetworking.INSTANCE.changePositionProvider(stack, cir.getReturnValue());
Entity entity = cir.getReturnValue();
if (entity != null) BridgesKt.changePosition(stack, entity);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,13 +10,19 @@
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 {
@Shadow @Final public PlayerEntity player;

@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<Boolean> cir) {
BridgesKt.changePosition(stack, player);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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));
}
}
Loading

0 comments on commit 208d1d3

Please sign in to comment.