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

Plane sound config #7437

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions src/main/java/appeng/core/AEConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ private static void makeBackupAndReset(Path configFolder, String configFile) {
private int craftingCalculationTimePerTick;
private boolean craftingSimulatedExtraction;
private boolean spatialAnchorEnablesRandomTicks;
private double planeVolumeLevel;

// Spatial IO/Dimension
private double spatialPowerExponent;
Expand Down Expand Up @@ -198,6 +199,8 @@ private void syncCommonConfig() {
AELog.setCraftingLogEnabled(COMMON.craftingLog.get());
AELog.setDebugLogEnabled(COMMON.debugLog.get());
AELog.setGridLogEnabled(COMMON.gridLog.get());

this.planeVolumeLevel = COMMON.planeVolumeLevel.get();
}

public static AEConfig instance() {
Expand Down Expand Up @@ -324,6 +327,10 @@ public int getFormationPlaneEntityLimit() {
return this.formationPlaneEntityLimit;
}

public double getPlaneVolumeLevel() {
return this.planeVolumeLevel;
}

public boolean isEnableEffects() {
return this.enableEffects;
}
Expand Down Expand Up @@ -619,6 +626,7 @@ private static class CommonConfig {

// Misc
public final IntegerOption formationPlaneEntityLimit;
public final DoubleOption planeVolumeLevel;
public final IntegerOption craftingCalculationTimePerTick;
public final BooleanOption craftingSimulatedExtraction;
public final BooleanOption allowBlockEntityFacades;
Expand Down Expand Up @@ -703,6 +711,7 @@ public CommonConfig(ConfigSection root) {

ConfigSection automation = root.subsection("automation");
formationPlaneEntityLimit = automation.addInt("formationPlaneEntityLimit", 128);
planeVolumeLevel = automation.addDouble("planeVolumeLevel", 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the volume really 0 and has no min/max? It should have a description to say what it is and reduce the volume by default vs. what it is now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going off of the original feedback from @Technici4n who suggested a value from 0 to 1. I could see the argument for either, just let me know. I will look into adding a description though.


ConfigSection facades = root.subsection("facades");
allowBlockEntityFacades = facades.addBoolean("allowBlockEntities", false,
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/appeng/mixins/FormationPlaneVolumeMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package appeng.mixins;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import net.fabricmc.fabric.api.entity.FakePlayer;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.SoundType;

import appeng.core.AEConfig;

@Mixin(BlockItem.class)
public abstract class FormationPlaneVolumeMixin {

@Redirect(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/SoundType;getVolume()F"))
private float modifyVolume(SoundType instance, BlockPlaceContext context) {
if (context.getPlayer() instanceof FakePlayer
&& context.getPlayer().getGameProfile().getName().equals("[AE2]")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather compare the profile UIID than the name here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you guys use a special UUID for the AE2 fakeplayer? My goal was to limit the effect of this volume control to just AE2 fakeplayer events.

return ((float) AEConfig.instance().getPlaneVolumeLevel()) - 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to look up what the volume actually means in this case, and why you are subtracting 1 :-P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am new to mixins. The argument I am modifying is in the following line and they add 1.

level.playSound(player, blockPos, this.getPlaceSound(blockState2), SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F);

} else {
return instance.getVolume();
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/ae2.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"unlitquad.BlockPartFaceDeserializerMixin",
"AbstractContainerScreenMixin",
"BlockBreakParticleMixin",
"FormationPlaneVolumeMixin",
"MouseWheelMixin",
"GuiGraphicsMixin",
"WrappedGenericStackTooltipModIdMixin",
Expand Down