Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimagined Features #47

Open
wants to merge 51 commits into
base: 1.20
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
215ccb3
Range-limited radios
techno-sam Aug 7, 2024
b7232d3
version bump
techno-sam Aug 7, 2024
211f44b
fix headset radio range
techno-sam Aug 7, 2024
d768ae6
initial voichat compat impl
techno-sam Aug 10, 2024
377d865
voicechat compat complete
techno-sam Aug 11, 2024
7dd63d2
bug squashing and debug tooling
techno-sam Aug 31, 2024
b5ec56f
initial rework of radio transceiver
Violet-Scarelli Aug 31, 2024
71b70ed
ender music box
Violet-Scarelli Aug 31, 2024
2cbd5d2
resumable jukebox
techno-sam Aug 31, 2024
f6d83fb
more resumability
techno-sam Aug 31, 2024
4c7b7e8
audio breaker parts
Violet-Scarelli Aug 31, 2024
ac816e1
fix microphone rotation
techno-sam Aug 31, 2024
61db85d
microphone revision
Violet-Scarelli Aug 31, 2024
e987d1e
Merge remote-tracking branch 'refs/remotes/origin/revised-textures' i…
techno-sam Aug 31, 2024
a258603
separate satellite dish model
Violet-Scarelli Aug 31, 2024
4d560ac
fix transceiver texture
techno-sam Aug 31, 2024
ff15d5d
modify satellite blocks
Violet-Scarelli Aug 31, 2024
82121a0
microphone base outputs power when in use
techno-sam Aug 31, 2024
72fb431
implement newly-modeled radio transceiver
techno-sam Aug 31, 2024
3752904
Audio switch
techno-sam Sep 1, 2024
a2a0577
fix jukebox-chute desync
techno-sam Sep 1, 2024
b4b97ad
radio debug rendering
techno-sam Sep 1, 2024
d272a73
proper config and own-mic volume
techno-sam Sep 2, 2024
86ea40d
Merge branch 'refs/heads/revised-textures' into 1.20
techno-sam Sep 2, 2024
4e1abba
begin satellite reimplementation
techno-sam Sep 2, 2024
00ca9ae
finish satellite radio implementation
techno-sam Sep 2, 2024
73ec599
version bump
techno-sam Sep 2, 2024
ec9cba5
temporarily disable resume feature
techno-sam Sep 3, 2024
ffd8ff2
Revert "temporarily disable resume feature"
techno-sam Sep 3, 2024
476c823
failed seeking impl
techno-sam Sep 3, 2024
4bc1741
implement CleanableBufferedInputStream
techno-sam Sep 5, 2024
6a52989
fix more of ElectronicJukeboxBlockEntity's interaction with chutes
techno-sam Sep 5, 2024
527d125
fix unconnected Jukeboxes: their MultiSourceSoundInstanceis now silent
techno-sam Sep 5, 2024
94ad506
CleanableBufferedInputStream: support adding history
techno-sam Sep 7, 2024
8884644
proper seeking implementation
techno-sam Sep 7, 2024
a45275a
optimize seeking more
techno-sam Sep 7, 2024
2cc70aa
improve satellite launch process
techno-sam Sep 7, 2024
f4597fa
ender music box
techno-sam Sep 8, 2024
69f5c7c
make ender music box resumable
techno-sam Sep 8, 2024
2d5b903
add music disc duration data pack system
techno-sam Sep 15, 2024
abb5d4b
fix ender music box crash
techno-sam Sep 21, 2024
cf86e2d
tiny fix of positioning for mic base
Violet-Scarelli Oct 3, 2024
225aa72
radio mic base model
Violet-Scarelli Oct 3, 2024
d86bc6f
radio mic model + textures
Violet-Scarelli Oct 3, 2024
33d2e36
microphone transfer & prepare for wireless microphones
techno-sam Oct 3, 2024
00e74ee
wireless microphones impl
techno-sam Oct 3, 2024
6bb6f5c
Merge branch 'refs/heads/revised-textures' into 1.20
techno-sam Oct 3, 2024
89c5ae2
finish wireless microphones
techno-sam Oct 3, 2024
f959441
update SVC API version
techno-sam Oct 4, 2024
6ac177d
fix static loading crash and disable debug commands
techno-sam Oct 4, 2024
99b0fee
fix radios in clientside unloaded chunks
techno-sam Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -13,6 +13,27 @@ group = project.maven_group
repositories {
maven { url "https://api.modrinth.com/maven" }
maven { url = 'https://maven.terraformersmc.com/' }
maven { url = "https://maven.maxhenkel.de/repository/public" } // Simple Voice Chat
maven { url = "https://mvn.devos.one/snapshots/" } // Create Fabric, Porting Lib, Forge Tags, Milk Lib, Registrate Fabric
maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes
maven { // Flywheel, Registrate, Create
url = "https://maven.tterrag.com/"
content {
includeGroup("com.simibubi.create")
includeGroup("com.tterrag.registrate")
includeGroup("com.jozufozu.flywheel")
}
}
maven { // YACL
name 'Xander Maven'
url 'https://maven.isxander.dev/releases'
}
maven {
url 'https://repo.sleeping.town'
content {
includeGroup 'com.unascribed'
}
}
}

dependencies {
Expand All @@ -26,13 +47,39 @@ dependencies {
include "maven.modrinth:jsonem:${project.jsonem_version}"

modApi("com.terraformersmc:modmenu:${project.modmenu_version}") { transitive false }

modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}"

//modCompileOnly("de.maxhenkel.voicechat:voicechat-api:${project.voicechat_api_version}")
modCompileOnly("maven.modrinth:simple-voice-chat:fabric-${project.voicechat_version}")

if (project.enable_simple_voice_chat.toBoolean()) {
modLocalRuntime("maven.modrinth:simple-voice-chat:fabric-${project.voicechat_version}")
}

if (project.enable_create.toBoolean()) {
// Create - dependencies are added transitively
modLocalRuntime("com.simibubi.create:create-fabric-${project.minecraft_version}:${project.create_fabric_version}")
}

if (project.enable_music_disc_mods.toBoolean()) {
modLocalRuntime("maven.modrinth:more-music-discs:${project.more_music_discs_version}") { transitive = false }
modLocalRuntime("maven.modrinth:spindlemark:${project.spindlemark_version}") { transitive = false }
modLocalRuntime("com.unascribed:lib39-core:${project.lib39_version}")
modLocalRuntime("com.unascribed:lib39-keygen:${project.lib39_version}")
}
}

processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
expand(
"version": project.version,
"fabric_loader_version": project.loader_version,
"fabric_api_version": project.fabric_version,
"yacl_version": project.yacl_version,
)
}
}

Expand Down
34 changes: 30 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
org.gradle.jvmargs=-Xmx1G

minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21
yarn_mappings=1.20.1+build.10
loader_version=0.16.3

#Fabric api
fabric_version=0.84.0+1.20.1
fabric_version=0.92.2+1.20.1

mod_version = 1.0.0-beta.11
mod_version = 1.1.1-beta.1
maven_group = io.github.foundationgames
archives_base_name = phonos

jsonem_version=0.2.1+1.20
modmenu_version=7.1.0

# YACL - https://docs.isxander.dev/yet-another-config-lib/installing-yacl
yacl_version = 3.5.0+1.20.1-fabric

# Simple Voice Chat - https://modrepo.de/minecraft/voicechat/api/getting_started
# https://maven.maxhenkel.de/#/releases/de/maxhenkel/voicechat/voicechat-api
# https://modrinth.com/plugin/simple-voice-chat
voicechat_api_version = 2.5.0
voicechat_version = 1.20.1-2.5.23
enable_simple_voice_chat = true

# Create - Fabric
# https://modrinth.com/mod/create-fabric/versions
create_fabric_version = 0.5.1-f-build.1490+mc1.20.1
enable_create = true

# Music Disc Testing
enable_music_disc_mods = true

# More Music Discs - https://modrinth.com/mod/more-music-discs/versions
more_music_discs_version = 1.20.1-33-fabric

# Spindlemark - https://modrinth.com/mod/spindlemark/versions
spindlemark_version = 1.1.0
# Lib39 - https://modrinth.com/mod/lib39/versions
lib39_version = 1.5.0-experimental5+1.20.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
71 changes: 63 additions & 8 deletions src/main/java/io/github/foundationgames/phonos/Phonos.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
package io.github.foundationgames.phonos;

import io.github.foundationgames.phonos.block.PhonosBlocks;
import io.github.foundationgames.phonos.config.PhonosServerConfig;
import io.github.foundationgames.phonos.item.ItemGroupQueue;
import io.github.foundationgames.phonos.item.PhonosItems;
import io.github.foundationgames.phonos.mixin_interfaces.IMicrophoneHoldingServerPlayerEntity;
import io.github.foundationgames.phonos.network.PayloadPackets;
import io.github.foundationgames.phonos.radio.RadioDevice;
import io.github.foundationgames.phonos.radio.RadioStorage;
import io.github.foundationgames.phonos.recipe.ItemGlowRecipe;
import io.github.foundationgames.phonos.sound.MusicDiscOverrides;
import io.github.foundationgames.phonos.sound.SoundStorage;
import io.github.foundationgames.phonos.sound.custom.ServerCustomAudio;
import io.github.foundationgames.phonos.sound.emitter.SecondaryEmitterHolder;
import io.github.foundationgames.phonos.sound.emitter.SoundEmitter;
import io.github.foundationgames.phonos.sound.emitter.SoundEmitterStorage;
import io.github.foundationgames.phonos.sound.stream.ServerOutgoingStreamHandler;
import io.github.foundationgames.phonos.util.PhonosTags;
import io.github.foundationgames.phonos.util.PhonosUtil;
import io.github.foundationgames.phonos.util.ServerLifecycleHooks;
import io.github.foundationgames.phonos.world.command.PhonosCommands;
import io.github.foundationgames.phonos.world.sound.InputPlugPoint;
import io.github.foundationgames.phonos.world.sound.data.SoundDataTypes;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerBlockEntityEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory;
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry;
import net.fabricmc.fabric.api.event.player.UseEntityCallback;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.dispenser.FallibleItemDispenserBehavior;
import net.minecraft.item.ArmorItem;
Expand All @@ -32,9 +40,12 @@
import net.minecraft.recipe.SpecialRecipeSerializer;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.resource.ResourceType;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPointer;
import net.minecraft.world.GameRules;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand All @@ -46,13 +57,13 @@ public class Phonos implements ModInitializer {

public static final ItemGroupQueue PHONOS_ITEMS = new ItemGroupQueue(id("phonos"));

public static final GameRules.Key<GameRules.IntRule> PHONOS_UPLOAD_LIMIT_KB = GameRuleRegistry.register(
"phonosUploadLimitKB", GameRules.Category.MISC, GameRuleFactory.createIntRule(-1, -1));

public static final Identifier STREAMED_SOUND = Phonos.id("streamed");

public static final RecipeSerializer<ItemGlowRecipe> ITEM_GLOW_RECIPE_SERIALIZER = Registry.register(
Registries.RECIPE_SERIALIZER, Phonos.id("crafting_special_itemglow"), new SpecialRecipeSerializer<>(ItemGlowRecipe::new));
public static final Identifier SVC_STREAMED_SOUND = Phonos.id("svc_streamed");

public static final RecipeSerializer<ItemGlowRecipe> ITEM_GLOW_RECIPE_SERIALIZER = new SpecialRecipeSerializer<>(ItemGlowRecipe::new);

public static final boolean DEBUG = false;

@Override
public void onInitialize() {
Expand All @@ -62,10 +73,13 @@ public void onInitialize() {
.entries(PHONOS_ITEMS)
.build());

Registry.register(Registries.RECIPE_SERIALIZER, Phonos.id("crafting_special_itemglow"), ITEM_GLOW_RECIPE_SERIALIZER);

PayloadPackets.initCommon();

PhonosBlocks.init();
PhonosItems.init();
PhonosTags.init();

SoundDataTypes.init();
InputPlugPoint.init();
Expand All @@ -78,6 +92,9 @@ public void onInitialize() {
});

ServerLifecycleEvents.SERVER_STARTED.register(e -> {
// Initialize config
PhonosServerConfig.get(e.getOverworld());

ServerCustomAudio.reset();
try {
var path = PhonosUtil.getCustomSoundFolder(e);
Expand All @@ -91,13 +108,28 @@ public void onInitialize() {
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) ->
ServerCustomAudio.onPlayerDisconnect(handler.getPlayer()));

ServerPlayConnectionEvents.JOIN.register(((handler, sender, server) -> {
ServerPlayerEntity player = handler.getPlayer();
SoundStorage.getInstance(player.getServerWorld())
.registerPlayerWaitingForResume(player);
PayloadPackets.sendConfig(player, PhonosServerConfig.getHandler(player.getServerWorld()));
}));

ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register(((player, origin, destination) -> {
SoundStorage.getInstance(player.getServerWorld())
.registerPlayerWaitingForResume(player);
}));

ServerTickEvents.END_WORLD_TICK.register(world -> SoundStorage.getInstance(world).tick(world));
ServerTickEvents.START_SERVER_TICK.register(ServerOutgoingStreamHandler::tick);

ServerBlockEntityEvents.BLOCK_ENTITY_LOAD.register((be, world) -> {
if (be instanceof SoundEmitter p) {
SoundEmitterStorage.getInstance(world).addEmitter(p);
}
if (be instanceof SecondaryEmitterHolder p) {
SoundEmitterStorage.getInstance(world).addEmitter(p.getSecondaryEmitter());
}
if (be instanceof RadioDevice.Receiver rec) {
rec.setAndUpdateChannel(rec.getChannel());
}
Expand All @@ -106,11 +138,16 @@ public void onInitialize() {
if (be instanceof SoundEmitter p) {
SoundEmitterStorage.getInstance(world).removeEmitter(p);
}
if (be instanceof SecondaryEmitterHolder p) {
SoundEmitterStorage.getInstance(world).removeEmitter(p.getSecondaryEmitter());
}
if (be instanceof RadioDevice.Receiver rec) {
rec.removeReceiver();
}
});

ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(MusicDiscOverrides.ReloadListener.INSTANCE);

DispenserBlock.registerBehavior(PhonosItems.HEADSET, new FallibleItemDispenserBehavior() {
@Override
protected ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) {
Expand All @@ -119,8 +156,26 @@ protected ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) {
}
});

UseEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
if (player instanceof IMicrophoneHoldingServerPlayerEntity sourceMHP && entity instanceof ServerPlayerEntity target && target instanceof IMicrophoneHoldingServerPlayerEntity targetMHP) {
var sourceStation = sourceMHP.phonos$getBaseStation();
if (sourceStation != null && targetMHP.phonos$getBaseStation() == null && sourceStation.canStart(target)) {
sourceStation.stop();
sourceStation.start(target);

player.sendMessage(Text.translatable("message.phonos.transferred_microphone_to", target.getDisplayName()), true);
target.sendMessage(Text.translatable("message.phonos.received_microphone_from", player.getDisplayName()), true);

return ActionResult.SUCCESS;
}
}

return ActionResult.PASS;
});

RadioStorage.init();
PhonosCommands.init();
ServerLifecycleHooks.init();
}

public static Identifier id(String path) {
Expand Down
Loading