Skip to content

Commit

Permalink
- Fixed bubble column sound playing in freecam
Browse files Browse the repository at this point in the history
- Added some comments
  • Loading branch information
hashalite committed Jul 13, 2023
1 parent 5fc28c7 commit f8c5f7c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.xolt.freecam.mixins;

import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.sound.BubbleColumnSoundPlayer;
import net.xolt.freecam.util.FreeCamera;
import org.spongepowered.asm.mixin.Final;
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(BubbleColumnSoundPlayer.class)
public class BubbleColumnSoundPlayerMixin {

@Shadow
@Final
private ClientPlayerEntity player;

// Prevent bubble column sound in freecam
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
private void onTick(CallbackInfo ci) {
if (player instanceof FreeCamera) {
ci.cancel();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@Mixin(EntityRenderer.class)
public class EntityRendererMixin {

// Prevent rendering of nametag in inventory screen
@Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
private void onRenderLabel(Entity entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
if (Freecam.isEnabled() && !((EntityRenderDispatcherAccessor)MC.getEntityRenderDispatcher()).getRenderShadows()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/freecam.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_17",
"client": [
"AbstractBlockStateMixin",
"BubbleColumnSoundPlayerMixin",
"CameraMixin",
"ClientConnectionMixin",
"ClientPlayerEntityMixin",
Expand Down

0 comments on commit f8c5f7c

Please sign in to comment.