mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-06 15:52:03 +00:00
add destroy sound
This commit is contained in:
@@ -72,6 +72,7 @@ items:
|
||||
hit: minecraft:block.anvil.hit
|
||||
fall: minecraft:block.anvil.fall
|
||||
land: minecraft:block.anvil.land
|
||||
destroy: minecraft:block.anvil.destroy
|
||||
item: default:netherite_anvil
|
||||
map-color: 29
|
||||
hardness: 10.0
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
|
||||
public class ModMenuIntegration implements ModMenuApi {
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return ModConfig::getConfigScreen;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class BlockSounds {
|
||||
Break 1 0.8
|
||||
*/
|
||||
public static final SoundData EMPTY_SOUND = new SoundData(Key.of("minecraft:intentionally_empty"), 1, 1);
|
||||
public static final BlockSounds EMPTY = new BlockSounds(EMPTY_SOUND, EMPTY_SOUND, EMPTY_SOUND, EMPTY_SOUND, EMPTY_SOUND, EMPTY_SOUND);
|
||||
public static final BlockSounds EMPTY = new BlockSounds(EMPTY_SOUND, EMPTY_SOUND, EMPTY_SOUND, EMPTY_SOUND, EMPTY_SOUND, EMPTY_SOUND, EMPTY_SOUND);
|
||||
|
||||
private final SoundData breakSound;
|
||||
private final SoundData stepSound;
|
||||
@@ -22,14 +22,16 @@ public class BlockSounds {
|
||||
private final SoundData hitSound;
|
||||
private final SoundData fallSound;
|
||||
private final SoundData landSound;
|
||||
private final SoundData destroySound;
|
||||
|
||||
public BlockSounds(SoundData breakSound, SoundData stepSound, SoundData placeSound, SoundData hitSound, SoundData fallSound, SoundData landSound) {
|
||||
public BlockSounds(SoundData breakSound, SoundData stepSound, SoundData placeSound, SoundData hitSound, SoundData fallSound, SoundData landSound, SoundData destroySound) {
|
||||
this.breakSound = breakSound;
|
||||
this.stepSound = stepSound;
|
||||
this.placeSound = placeSound;
|
||||
this.hitSound = hitSound;
|
||||
this.fallSound = fallSound;
|
||||
this.landSound = landSound;
|
||||
this.destroySound = destroySound;
|
||||
}
|
||||
|
||||
public static BlockSounds fromMap(Map<String, Object> map) {
|
||||
@@ -40,10 +42,15 @@ public class BlockSounds {
|
||||
SoundData.create(map.getOrDefault("place", "minecraft:intentionally_empty"), 0f, 0.8f), // todo 0?
|
||||
SoundData.create(map.getOrDefault("hit", "minecraft:intentionally_empty"), 0.5f, 0.5f),
|
||||
SoundData.create(map.getOrDefault("fall", "minecraft:intentionally_empty"), 0.5f, 0.75f),
|
||||
SoundData.create(map.getOrDefault("land", "minecraft:intentionally_empty"), 0.3f, 1f)
|
||||
SoundData.create(map.getOrDefault("land", "minecraft:intentionally_empty"), 0.3f, 1f),
|
||||
SoundData.create(map.getOrDefault("destroy", "minecraft:intentionally_empty"), 1f, 1f)
|
||||
);
|
||||
}
|
||||
|
||||
public SoundData destroySound() {
|
||||
return destroySound;
|
||||
}
|
||||
|
||||
public SoundData breakSound() {
|
||||
return breakSound;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package net.momirealms.craftengine.core.entity.furniture;
|
||||
|
||||
import net.momirealms.craftengine.core.sound.SoundData;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class FurnitureSounds {
|
||||
public static final Key EMPTY_SOUND = Key.of("minecraft:intentionally_empty");
|
||||
public static final SoundData EMPTY_SOUND = new SoundData(Key.of("minecraft:intentionally_empty"), 1, 1);
|
||||
public static final FurnitureSounds EMPTY = new FurnitureSounds(EMPTY_SOUND, EMPTY_SOUND, EMPTY_SOUND);
|
||||
|
||||
private final Key breakSound;
|
||||
private final Key placeSound;
|
||||
private final Key rotateSound;
|
||||
private final SoundData breakSound;
|
||||
private final SoundData placeSound;
|
||||
private final SoundData rotateSound;
|
||||
|
||||
public FurnitureSounds(Key breakSound, Key placeSound, Key rotateSound) {
|
||||
public FurnitureSounds(SoundData breakSound, SoundData placeSound, SoundData rotateSound) {
|
||||
this.breakSound = breakSound;
|
||||
this.placeSound = placeSound;
|
||||
this.rotateSound = rotateSound;
|
||||
@@ -21,21 +22,21 @@ public class FurnitureSounds {
|
||||
public static FurnitureSounds fromMap(Map<String, Object> map) {
|
||||
if (map == null) return EMPTY;
|
||||
return new FurnitureSounds(
|
||||
Key.of(map.getOrDefault("break", "minecraft:intentionally_empty").toString()),
|
||||
Key.of(map.getOrDefault("place", "minecraft:intentionally_empty").toString()),
|
||||
Key.of(map.getOrDefault("rotate", "minecraft:intentionally_empty").toString())
|
||||
SoundData.create(map.getOrDefault("break", "minecraft:intentionally_empty"), 1f, 0.8f),
|
||||
SoundData.create(map.getOrDefault("place", "minecraft:intentionally_empty"), 0f, 0.8f),
|
||||
SoundData.create(map.getOrDefault("rotate", "minecraft:intentionally_empty"), 1f, 0.8f)
|
||||
);
|
||||
}
|
||||
|
||||
public Key breakSound() {
|
||||
public SoundData breakSound() {
|
||||
return breakSound;
|
||||
}
|
||||
|
||||
public Key placeSound() {
|
||||
public SoundData placeSound() {
|
||||
return placeSound;
|
||||
}
|
||||
|
||||
public Key rotateSound() {
|
||||
public SoundData rotateSound() {
|
||||
return rotateSound;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user