Paper/Spigot-Server-Patches/0360-Implement-CraftBlockSoundGroup.patch

102 lines
4.3 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: simpleauthority <jacob@algorithmjunkie.com>
Date: Tue, 28 May 2019 03:48:51 -0700
Subject: [PATCH] Implement CraftBlockSoundGroup
diff --git a/src/main/java/com/destroystokyo/paper/block/CraftBlockSoundGroup.java b/src/main/java/com/destroystokyo/paper/block/CraftBlockSoundGroup.java
new file mode 100644
index 0000000000000000000000000000000000000000..99f99330d01fc61ce8ede9f225b0c42bd8f9ded1
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/block/CraftBlockSoundGroup.java
@@ -0,0 +1,38 @@
+package com.destroystokyo.paper.block;
+
+import net.minecraft.server.SoundEffectType;
+import org.bukkit.Sound;
+import org.bukkit.craftbukkit.CraftSound;
+
+public class CraftBlockSoundGroup implements BlockSoundGroup {
+ private final SoundEffectType soundEffectType;
+
+ public CraftBlockSoundGroup(SoundEffectType soundEffectType) {
+ this.soundEffectType = soundEffectType;
+ }
+
+ @Override
+ public Sound getBreakSound() {
+ return CraftSound.getSoundByEffect(soundEffectType.getBreakSound());
+ }
+
+ @Override
+ public Sound getStepSound() {
+ return CraftSound.getSoundByEffect(soundEffectType.getStepSound());
+ }
+
+ @Override
+ public Sound getPlaceSound() {
+ return CraftSound.getSoundByEffect(soundEffectType.getPlaceSound());
+ }
+
+ @Override
+ public Sound getHitSound() {
+ return CraftSound.getSoundByEffect(soundEffectType.getHitSound());
+ }
+
+ @Override
+ public Sound getFallSound() {
+ return CraftSound.getSoundByEffect(soundEffectType.getFallSound());
+ }
+}
diff --git a/src/main/java/net/minecraft/server/SoundEffectType.java b/src/main/java/net/minecraft/server/SoundEffectType.java
2020-06-25 16:09:55 +02:00
index 957799e034ad8bc7201815b849244b7a809fb666..2301b38ac3b488809d2f624055ad3e23663d3fdb 100644
--- a/src/main/java/net/minecraft/server/SoundEffectType.java
+++ b/src/main/java/net/minecraft/server/SoundEffectType.java
2020-06-25 16:09:55 +02:00
@@ -51,10 +51,10 @@ public class SoundEffectType {
public static final SoundEffectType U = new SoundEffectType(1.0F, 1.0F, SoundEffects.BLOCK_GILDED_BLACKSTONE_BREAK, SoundEffects.BLOCK_GILDED_BLACKSTONE_STEP, SoundEffects.BLOCK_GILDED_BLACKSTONE_PLACE, SoundEffects.BLOCK_GILDED_BLACKSTONE_HIT, SoundEffects.BLOCK_GILDED_BLACKSTONE_FALL);
public final float V;
public final float W;
- private final SoundEffect X;
+ private final SoundEffect X; public final SoundEffect getBreakSound() { return this.X; } // Paper - OBFHELPER
private final SoundEffect Y;
private final SoundEffect Z;
- private final SoundEffect aa;
+ private final SoundEffect aa; public final SoundEffect getHitSound() { return this.aa; } // Paper - OBFHELPER
private final SoundEffect ab;
public SoundEffectType(float f, float f1, SoundEffect soundeffect, SoundEffect soundeffect1, SoundEffect soundeffect2, SoundEffect soundeffect3, SoundEffect soundeffect4) {
2020-06-25 16:09:55 +02:00
@@ -75,14 +75,17 @@ public class SoundEffectType {
return this.W;
}
+ public final SoundEffect getStepSound() { return this.d(); } // Paper - OBFHELPER
public SoundEffect d() {
2020-06-25 16:09:55 +02:00
return this.Y;
}
+ public final SoundEffect getPlaceSound() { return this.e(); } // Paper - OBFHELPER
public SoundEffect e() {
2020-06-25 16:09:55 +02:00
return this.Z;
}
+ public final SoundEffect getFallSound() { return this.g(); } // Paper - OBFHELPER
public SoundEffect g() {
2020-06-25 16:09:55 +02:00
return this.ab;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 49e52d3ba93b2c68680f03aae244142e4532d68c..8a1261ccb3b3eae7f00fdcad7f1220f459cdbfad 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -738,4 +738,11 @@ public class CraftBlock implements Block {
AxisAlignedBB aabb = shape.getBoundingBox();
return new BoundingBox(getX() + aabb.minX, getY() + aabb.minY, getZ() + aabb.minZ, getX() + aabb.maxX, getY() + aabb.maxY, getZ() + aabb.maxZ);
}
+
+ // Paper start
+ @Override
+ public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() {
+ return new com.destroystokyo.paper.block.CraftBlockSoundGroup(getNMSBlock().getBlockData().getStepSound());
+ }
+ // Paper end
}