mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 01:49:30 +00:00
Merge branch 'Xiao-MoMi:dev' into dev
This commit is contained in:
@@ -63,18 +63,20 @@ public class BlockEventListener implements Listener {
|
||||
if (Config.enableSoundSystem()) {
|
||||
Block block = event.getBlock();
|
||||
Object blockState = BlockStateUtils.blockDataToBlockState(block.getBlockData());
|
||||
Object ownerBlock = BlockStateUtils.getBlockOwner(blockState);
|
||||
if (this.manager.isBlockSoundRemoved(ownerBlock)) {
|
||||
if (player.getInventory().getItemInMainHand().getType() != Material.DEBUG_STICK) {
|
||||
try {
|
||||
Object soundType = Reflections.field$BlockBehaviour$soundType.get(ownerBlock);
|
||||
Object placeSound = Reflections.field$SoundType$placeSound.get(soundType);
|
||||
player.playSound(block.getLocation(), Reflections.field$SoundEvent$location.get(placeSound).toString(), SoundCategory.BLOCKS, 1f, 0.8f);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
this.plugin.logger().warn("Failed to get sound type", e);
|
||||
if (blockState != Reflections.instance$Blocks$AIR$defaultState) {
|
||||
Object ownerBlock = BlockStateUtils.getBlockOwner(blockState);
|
||||
if (this.manager.isBlockSoundRemoved(ownerBlock)) {
|
||||
if (player.getInventory().getItemInMainHand().getType() != Material.DEBUG_STICK) {
|
||||
try {
|
||||
Object soundType = Reflections.field$BlockBehaviour$soundType.get(ownerBlock);
|
||||
Object placeSound = Reflections.field$SoundType$placeSound.get(soundType);
|
||||
player.playSound(block.getLocation(), Reflections.field$SoundEvent$location.get(placeSound).toString(), SoundCategory.BLOCKS, 1f, 0.8f);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
this.plugin.logger().warn("Failed to get sound type", e);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// resend sound if the clicked block is interactable on client side
|
||||
|
||||
@@ -311,7 +311,10 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
for (Object block : (Iterable<Object>) Reflections.instance$BuiltInRegistries$BLOCK) {
|
||||
Object soundType = Reflections.field$BlockBehaviour$soundType.get(block);
|
||||
if (affectedSounds.contains(soundType)) {
|
||||
affectedBlocks.add(block);
|
||||
Object state = getOnlyBlockState(block);
|
||||
if (BlockStateUtils.isVanillaBlock(state)) {
|
||||
affectedBlocks.add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.craftengine.bukkit.sound;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.util.ComponentUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.Reflections;
|
||||
@@ -17,6 +18,7 @@ public class BukkitSoundManager extends AbstractSoundManager {
|
||||
|
||||
public BukkitSoundManager(CraftEngine plugin) {
|
||||
super(plugin);
|
||||
VANILLA_SOUND_EVENTS.addAll(FastNMS.INSTANCE.getAllVanillaSounds().stream().map(it -> Key.of(it.getNamespace(), it.getKey())).toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ public class BlockSounds {
|
||||
return new BlockSounds(
|
||||
SoundData.create(map.getOrDefault("break", "minecraft:intentionally_empty"), 1f, 0.8f),
|
||||
SoundData.create(map.getOrDefault("step", "minecraft:intentionally_empty"), 0.15f, 1f),
|
||||
SoundData.create(map.getOrDefault("place", "minecraft:intentionally_empty"), 0f, 0.8f), // todo 0?
|
||||
SoundData.create(map.getOrDefault("place", "minecraft:intentionally_empty"), 1f, 0.8f),
|
||||
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),
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class AbstractSoundManager implements SoundManager {
|
||||
protected static final Set<Key> VANILLA_SOUND_EVENTS = new HashSet<>();
|
||||
protected final CraftEngine plugin;
|
||||
protected final Map<Key, SoundEvent> byId = new HashMap<>();
|
||||
protected final Map<String, List<SoundEvent>> byNamespace = new HashMap<>();
|
||||
@@ -28,6 +29,11 @@ public abstract class AbstractSoundManager implements SoundManager {
|
||||
this.songParser = new SongParser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVanillaSoundEvent(Key key) {
|
||||
return VANILLA_SOUND_EVENTS.contains(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigSectionParser[] parsers() {
|
||||
return new ConfigSectionParser[] { this.soundParser, this.songParser };
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.util.Map;
|
||||
|
||||
public interface SoundManager extends Manageable {
|
||||
|
||||
boolean isVanillaSoundEvent(Key key);
|
||||
|
||||
ConfigSectionParser[] parsers();
|
||||
|
||||
Map<Key, SoundEvent> sounds();
|
||||
|
||||
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=0.0.46
|
||||
project_version=0.0.46.1
|
||||
config_version=23
|
||||
lang_version=4
|
||||
project_group=net.momirealms
|
||||
@@ -51,7 +51,7 @@ byte_buddy_version=1.17.5
|
||||
ahocorasick_version=0.6.3
|
||||
snake_yaml_version=2.4
|
||||
anti_grief_version=0.13
|
||||
nms_helper_version=0.47
|
||||
nms_helper_version=0.48
|
||||
# Ignite Dependencies
|
||||
mixinextras_version=0.4.1
|
||||
mixin_version=0.15.2+mixin.0.8.7
|
||||
|
||||
Reference in New Issue
Block a user