76 lines
3.1 KiB
Diff
76 lines
3.1 KiB
Diff
|
From 617f88e61fffc22f9180ac64050ccfe3c27c83a3 Mon Sep 17 00:00:00 2001
|
||
|
From: Michael Himing <mhiming@gmail.com>
|
||
|
Date: Mon, 24 Apr 2017 16:10:46 +1000
|
||
|
Subject: [PATCH] Don't play sounds for cancelled block placement
|
||
|
|
||
|
|
||
|
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||
|
index cd7aa9415..cefeb7ddb 100644
|
||
|
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||
|
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||
|
@@ -401,7 +401,18 @@ public class PlayerInteractManager {
|
||
|
int j1 = itemstack.getData();
|
||
|
int k1 = itemstack.count;
|
||
|
|
||
|
- result = itemstack.placeItem(entityhuman, world, i, j, k, l, f, f1, f2);
|
||
|
+ // MineHQ start - hack to silence sounds from cancelled block place
|
||
|
+ try {
|
||
|
+ world.interceptSounds();
|
||
|
+ result = itemstack.placeItem(entityhuman, world, i, j, k, l, f, f1, f2);
|
||
|
+ } finally {
|
||
|
+ if (result) {
|
||
|
+ world.sendInterceptedSounds();
|
||
|
+ } else {
|
||
|
+ world.clearInterceptedSounds();
|
||
|
+ }
|
||
|
+ }
|
||
|
+ // MineHQ end
|
||
|
|
||
|
// The item count should not decrement in Creative mode.
|
||
|
if (this.isCreative()) {
|
||
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||
|
index 9f0bf9207..3acf60ab6 100644
|
||
|
--- a/src/main/java/net/minecraft/server/World.java
|
||
|
+++ b/src/main/java/net/minecraft/server/World.java
|
||
|
@@ -1095,7 +1095,36 @@ public abstract class World implements IBlockAccess {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- public void makeSound(double d0, double d1, double d2, String s, float f, float f1) {
|
||
|
+ // MineHQ start - hack to silence sounds from cancelled block place
|
||
|
+ private boolean interceptSounds = false;
|
||
|
+ private final List<Runnable> interceptedSounds = new ArrayList<Runnable>();
|
||
|
+ public void interceptSounds() {
|
||
|
+ interceptSounds = true;
|
||
|
+ }
|
||
|
+ public void sendInterceptedSounds() {
|
||
|
+ for (Runnable r : interceptedSounds) {
|
||
|
+ r.run();
|
||
|
+ }
|
||
|
+ interceptedSounds.clear();
|
||
|
+ interceptSounds = false;
|
||
|
+ }
|
||
|
+ public void clearInterceptedSounds() {
|
||
|
+ interceptedSounds.clear();
|
||
|
+ interceptSounds = false;
|
||
|
+ }
|
||
|
+ public void makeSound(final double d0, final double d1, final double d2, final String s, final float f, final float f1) {
|
||
|
+ if (interceptSounds && org.bukkit.Bukkit.isPrimaryThread()) {
|
||
|
+ interceptedSounds.add(new Runnable() {
|
||
|
+ @Override
|
||
|
+ public void run() {
|
||
|
+ for (int i = 0; i < World.this.u.size(); ++i) {
|
||
|
+ ((IWorldAccess) World.this.u.get(i)).a(s, d0, d1, d2, f, f1);
|
||
|
+ }
|
||
|
+ }
|
||
|
+ });
|
||
|
+ return;
|
||
|
+ }
|
||
|
+ // MineHQ end
|
||
|
for (int i = 0; i < this.u.size(); ++i) {
|
||
|
((IWorldAccess) this.u.get(i)).a(s, d0, d1, d2, f, f1);
|
||
|
}
|
||
|
--
|
||
|
2.13.3
|
||
|
|