mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-28 19:39:11 +00:00
add destroy sound
This commit is contained in:
@@ -254,7 +254,7 @@ public class CraftEngineFurniture {
|
||||
}
|
||||
}
|
||||
if (playSound) {
|
||||
world.playBlockSound(vec3d, loadedFurniture.furniture().settings().sounds().breakSound(), 1f, 0.8f);
|
||||
world.playBlockSound(vec3d, loadedFurniture.furniture().settings().sounds().breakSound());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,11 @@ public class FallingBlockRemoveListener implements Listener {
|
||||
for (Item<Object> item : immutableBlockState.getDrops(builder, world)) {
|
||||
world.dropItemNaturally(vec3d, item);
|
||||
}
|
||||
Object entityData = Reflections.field$Entity$entityData.get(fallingBlockEntity);
|
||||
boolean isSilent = (boolean) Reflections.method$SynchedEntityData$get.invoke(entityData, Reflections.instance$Entity$DATA_SILENT);
|
||||
if (!isSilent) {
|
||||
world.playBlockSound(vec3d, immutableBlockState.sounds().destroySound());
|
||||
}
|
||||
} catch (ReflectiveOperationException e) {
|
||||
CraftEngine.instance().logger().warn("Failed to handle EntityRemoveEvent", e);
|
||||
}
|
||||
|
||||
@@ -101,6 +101,11 @@ public class FallingBlockBehavior extends BlockBehavior {
|
||||
for (Item<Object> item : immutableBlockState.getDrops(builder, world)) {
|
||||
world.dropItemNaturally(vec3d, item);
|
||||
}
|
||||
Object entityData = Reflections.field$Entity$entityData.get(fallingBlockEntity);
|
||||
boolean isSilent = (boolean) Reflections.method$SynchedEntityData$get.invoke(entityData, Reflections.instance$Entity$DATA_SILENT);
|
||||
if (!isSilent) {
|
||||
world.playBlockSound(vec3d, immutableBlockState.sounds().destroySound());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.momirealms.craftengine.core.loot.LootTable;
|
||||
import net.momirealms.craftengine.core.pack.Pack;
|
||||
import net.momirealms.craftengine.core.plugin.config.ConfigManager;
|
||||
import net.momirealms.craftengine.core.plugin.scheduler.SchedulerTask;
|
||||
import net.momirealms.craftengine.core.sound.SoundData;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
@@ -60,7 +61,8 @@ public class BukkitFurnitureManager implements FurnitureManager {
|
||||
handleEntityLoadEarly(display);
|
||||
});
|
||||
if (playSound) {
|
||||
location.getWorld().playSound(location, furniture.settings().sounds().placeSound().toString(), SoundCategory.BLOCKS,1f, 1f);
|
||||
SoundData data = furniture.settings().sounds().placeSound();
|
||||
location.getWorld().playSound(location, data.id().toString(), SoundCategory.BLOCKS, data.volume(), data.pitch());
|
||||
}
|
||||
return getLoadedFurnitureByBaseEntityId(furnitureEntity.getEntityId());
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class FurnitureItemBehavior extends ItemBehavior {
|
||||
item.load();
|
||||
}
|
||||
|
||||
furnitureLocation.getWorld().playSound(furnitureLocation, customFurniture.settings().sounds().placeSound().toString(), SoundCategory.BLOCKS,1f, 1f);
|
||||
context.getLevel().playBlockSound(finalPlacePosition, customFurniture.settings().sounds().placeSound());
|
||||
player.swingHand(context.getHand());
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user