Fixed effect sounds and vines

- Store the effect sound category as a vanilla category name
- Resolve the sound category to a Bukkit category when an effect plays
- Send modded effect sounds on the authored category
- Skip the sound and warn once for an unknown sound category
- Keep authored vine side faces only where a sturdy block or the vine above holds them
- Attach kept vine faces upward under a sturdy block
- Reattach multi-face blocks with no holdable side face to sturdy neighbours
- Cover sound category and vine face rules on Bukkit and modded
- Repin the studio schema digest
This commit is contained in:
Brian Neumann-Fopiano committed 2026-10-31 21:58:58 -04:00
1 parent 64dc22025e
commit c2eb8b5f42
8 files changed
+498 -26

No files matched your search

@@ -37,6 +37,7 @@ final class DecoratorCore {
private static final long SEED_OFFSET = 29356788L;
private static final long PART_FACTOR = 10439677L;
private static final String VINE = "minecraft:vine";
private static final String WEEPING_VINES = "minecraft:weeping_vines";
private static final String WEEPING_VINES_PLANT = "minecraft:weeping_vines_plant";
private static final String TWISTING_VINES = "minecraft:twisting_vines";
@@ -454,22 +455,20 @@ final class DecoratorCore {
if (fixer != null) {
return fixer.fixFaces(b, hunk, rX, rZ, x, y, z, mantle);
}
BlockData rawB = (BlockData) b.nativeHandle();
BlockData cloned = rawB.clone();
BlockData cloned = ((BlockData) b.nativeHandle()).clone();
MultipleFacing data = (MultipleFacing) cloned;
if (data.getFaces().stream().anyMatch(f -> f != BlockFace.UP && f != BlockFace.DOWN)) {
// The pack chose which side a hanging strand faces: keep it (the vine above holds it up), and tie the
// block under a solid ceiling to it, so ceiling decorators hang curtains instead of flat ceiling sheets.
if (data.getAllowedFaces().contains(BlockFace.UP) && sturdy(BlockFace.UP, hunk, rX, rZ, x, y, z, mantle)) {
data.setFace(BlockFace.UP, true);
}
if (keepSupportedSides(data, VINE.equals(IrisProceduralBlocks.materialKey(b)), hunk, rX, rZ, x, y, z, mantle)) {
return BukkitBlockState.of(cloned);
}
data.getFaces().forEach(f -> data.setFace(f, false));
for (BlockFace f : Faces.CARTESIAN) {
if (data.hasFace(f)) {
data.setFace(f, false);
}
}
boolean found = false;
for (BlockFace f : BlockFace.values()) {
if (f.isCartesian() && sturdy(f, hunk, rX, rZ, x, y, z, mantle) && data.getAllowedFaces().contains(f)) {
for (BlockFace f : Faces.CARTESIAN) {
if (data.getAllowedFaces().contains(f) && sturdy(f, hunk, rX, rZ, x, y, z, mantle)) {
found = true;
data.setFace(f, true);
}
@@ -483,20 +482,58 @@ final class DecoratorCore {
return BukkitBlockState.of(cloned);
}
/** Whether the neighbour on that face (mantle first, then this chunk's hunk) offers a full sturdy face to attach to. */
private static boolean keepSupportedSides(MultipleFacing data, boolean vine, Hunk<NativeBlockState> hunk,
int rX, int rZ, int x, int y, int z, EngineMantle mantle) {
boolean side = false;
for (BlockFace f : Faces.SIDES) {
if (!data.hasFace(f)) {
continue;
}
if (sturdy(f, hunk, rX, rZ, x, y, z, mantle) || vine && vineAboveCarries(f, hunk, rX, rZ, x, y, z, mantle)) {
side = true;
} else {
data.setFace(f, false);
}
}
if (!side) {
return false;
}
if (data.getAllowedFaces().contains(BlockFace.UP)) {
data.setFace(BlockFace.UP, sturdy(BlockFace.UP, hunk, rX, rZ, x, y, z, mantle));
}
if (data.hasFace(BlockFace.DOWN) && !sturdy(BlockFace.DOWN, hunk, rX, rZ, x, y, z, mantle)) {
data.setFace(BlockFace.DOWN, false);
}
return true;
}
private static boolean sturdy(BlockFace f, Hunk<NativeBlockState> hunk, int rX, int rZ, int x, int y, int z, EngineMantle mantle) {
int yy = y + f.getModY();
NativeBlockState rs = mantle == null ? null : mantle.getMantle().get(x + f.getModX(), yy, z + f.getModZ(), NativeBlockState.class);
BlockData r = rs == null ? (BlockData) EngineMantle.AIR.get().nativeHandle() : (BlockData) rs.nativeHandle();
if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) {
BlockFace attached = f.getOppositeFace();
if (mantle != null && sturdy(mantle.getMantle().get(x + f.getModX(), yy, z + f.getModZ(), NativeBlockState.class), attached)) {
return true;
}
int xx = rX + f.getModX();
int zz = rZ + f.getModZ();
if (xx < 0 || xx > 15 || zz < 0 || zz > 15 || yy < 0 || yy >= hunk.getHeight()) {
return false;
return xx >= 0 && xx <= 15 && zz >= 0 && zz <= 15 && yy >= 0 && yy < hunk.getHeight()
&& sturdy(hunk.get(xx, yy, zz), attached);
}
private static boolean sturdy(NativeBlockState state, BlockFace attached) {
return state != null && ((BlockData) state.nativeHandle()).isFaceSturdy(attached, BlockSupport.FULL);
}
private static boolean vineAboveCarries(BlockFace f, Hunk<NativeBlockState> hunk, int rX, int rZ,
int x, int y, int z, EngineMantle mantle) {
if (mantle != null && carries(mantle.getMantle().get(x, y + 1, z, NativeBlockState.class), f)) {
return true;
}
return ((BlockData) hunk.get(xx, yy, zz).nativeHandle()).isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL);
return y + 1 < hunk.getHeight() && carries(hunk.get(rX, y + 1, rZ), f);
}
private static boolean carries(NativeBlockState state, BlockFace f) {
return state != null && VINE.equals(IrisProceduralBlocks.materialKey(state))
&& state.nativeHandle() instanceof MultipleFacing facing && facing.hasFace(f);
}
static boolean canGoOn(NativeBlockState decorator, NativeBlockState surface) {
@@ -586,4 +623,10 @@ final class DecoratorCore {
default -> state;
};
}
private static final class Faces {
private static final BlockFace[] SIDES = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
private static final BlockFace[] CARTESIAN = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST,
BlockFace.UP, BlockFace.DOWN};
}
}
@@ -51,6 +51,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@Snippet("effect")
@Accessors(chain = true)
@NoArgsConstructor
@@ -58,6 +62,9 @@ import org.bukkit.util.Vector;
@Description("An iris effect")
@Data
public class IrisEffect {
private static final String MASTER_SOUND_CATEGORY = "master";
private static final Set<String> UNKNOWN_SOUND_CATEGORIES = ConcurrentHashMap.newKeySet();
private final transient AtomicCache<PotionEffectType> pt = new AtomicCache<>();
private final transient AtomicCache<ChronoLatch> latch = new AtomicCache<>();
private final transient AtomicCache<Particle> particleEffectResolved = new AtomicCache<>();
@@ -119,8 +126,8 @@ public class IrisEffect {
@Description("The sound volume.")
private double volume = 1.5D;
@DependsOn({"sound"})
@Description("The sound category the sound plays in, which picks the client volume slider that controls it (for example MUSIC, AMBIENT or HOSTILE).")
private SoundCategory soundCategory = SoundCategory.MASTER;
@Description("The sound category the sound plays in, which picks the client volume slider that controls it: master, music, record, weather, block, hostile, neutral, player, ambient, voice or ui.")
private String soundCategory = MASTER_SOUND_CATEGORY;
@DependsOn({"particleEffect"})
@MinNumber(0)
@MaxNumber(512)
@@ -185,6 +192,10 @@ public class IrisEffect {
return sound;
}
public String getSoundCategoryKey() {
return soundCategory == null || soundCategory.isBlank() ? MASTER_SOUND_CATEGORY : soundCategory.trim().toLowerCase(Locale.ROOT);
}
public Particle getParticleEffect() {
if (particleEffect == null) {
return null;
@@ -199,6 +210,32 @@ public class IrisEffect {
return soundResolved.aquire(() -> resolveKeyed(Sound.class, sound));
}
static SoundCategory bukkitSoundCategory(String key) {
return switch (key) {
case "master" -> SoundCategory.MASTER;
case "music" -> SoundCategory.MUSIC;
case "record" -> SoundCategory.RECORDS;
case "weather" -> SoundCategory.WEATHER;
case "block" -> SoundCategory.BLOCKS;
case "hostile" -> SoundCategory.HOSTILE;
case "neutral" -> SoundCategory.NEUTRAL;
case "player" -> SoundCategory.PLAYERS;
case "ambient" -> SoundCategory.AMBIENT;
case "voice" -> SoundCategory.VOICE;
case "ui" -> SoundCategory.UI;
default -> null;
};
}
private SoundCategory resolveSoundCategory() {
String key = getSoundCategoryKey();
SoundCategory category = bukkitSoundCategory(key);
if (category == null && UNKNOWN_SOUND_CATEGORIES.add(key)) {
IrisLogging.warn("Unknown sound category: \"" + key + "\".");
}
return category;
}
private static <T> T resolveKeyed(Class<T> type, String key) {
NamespacedKey namespacedKey = NamespacedKey.fromString(key);
return namespacedKey == null ? null : RegistryUtil.lookup(type).get(namespacedKey);
@@ -242,9 +279,10 @@ public class IrisEffect {
BukkitFx.run(p, () -> {
Sound soundType = getSound();
Particle particleType = getParticleEffect();
if (soundType != null) {
SoundCategory category = soundType == null ? null : resolveSoundCategory();
if (category != null) {
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
p.playSound(part, soundType, soundCategory, (float) volume, (float) RNG.r.d(minPitch, maxPitch));
p.playSound(part, soundType, category, (float) volume, (float) RNG.r.d(minPitch, maxPitch));
}
if (particleType != null) {
@@ -319,9 +357,10 @@ public class IrisEffect {
J.runEntity(p, () -> {
Sound soundType = getSound();
Particle particleType = getParticleEffect();
if (soundType != null) {
SoundCategory category = soundType == null ? null : resolveSoundCategory();
if (category != null) {
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
p.getWorld().playSound(part, soundType, soundCategory, (float) volume, (float) RNG.r.d(minPitch, maxPitch));
p.getWorld().playSound(part, soundType, category, (float) volume, (float) RNG.r.d(minPitch, maxPitch));
}
if (particleType != null) {