diff --git a/src/main/java/org/orecruncher/dsurround/client/sound/SoundEffect.java b/src/main/java/org/orecruncher/dsurround/client/sound/SoundEffect.java index beec77c1b..66587778e 100644 --- a/src/main/java/org/orecruncher/dsurround/client/sound/SoundEffect.java +++ b/src/main/java/org/orecruncher/dsurround/client/sound/SoundEffect.java @@ -44,6 +44,8 @@ import org.orecruncher.lib.chunk.IBlockAccessEx; import org.orecruncher.lib.random.XorShiftRandom; +import com.google.common.base.MoreObjects; + import net.minecraft.block.state.IBlockState; import net.minecraft.client.audio.ISound.AttenuationType; import net.minecraft.entity.Entity; @@ -88,7 +90,7 @@ protected SoundEffect(final ResourceLocation resource, final SoundCategory categ this.conditions = StringUtils.EMPTY; this.weight = 10; this.type = SoundType.SPOT; - this.category = category == null ? SoundCategory.BLOCKS : category; + this.category = MoreObjects.firstNonNull(category, SoundCategory.BLOCKS); this.variable = variable; this.repeatDelayRandom = 0; this.repeatDelay = repeatDelay; diff --git a/src/main/java/org/orecruncher/dsurround/network/Network.java b/src/main/java/org/orecruncher/dsurround/network/Network.java index 19ab47cc9..8c1a2692a 100644 --- a/src/main/java/org/orecruncher/dsurround/network/Network.java +++ b/src/main/java/org/orecruncher/dsurround/network/Network.java @@ -120,7 +120,7 @@ public static void clientDisconnect(@Nonnull final ServerDisconnectionFromClient final NetworkDispatcher dispatcher = NetworkDispatcher.get(event.getManager()); if (dispatcher != null) { try { - final EntityPlayerMP p = (EntityPlayerMP) player.get(dispatcher); + final EntityPlayerMP p = player.get(dispatcher); blockList.remove(p.getPersistentID()); } catch (@Nonnull final Throwable t) { t.printStackTrace(); diff --git a/src/main/java/org/orecruncher/dsurround/registry/acoustics/AcousticRegistry.java b/src/main/java/org/orecruncher/dsurround/registry/acoustics/AcousticRegistry.java index c58250d6e..4179198e7 100644 --- a/src/main/java/org/orecruncher/dsurround/registry/acoustics/AcousticRegistry.java +++ b/src/main/java/org/orecruncher/dsurround/registry/acoustics/AcousticRegistry.java @@ -44,6 +44,7 @@ import org.orecruncher.dsurround.registry.config.ModConfiguration; import org.orecruncher.lib.MCHelper; +import com.google.common.base.MoreObjects; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -170,19 +171,6 @@ protected void complete() { ModBase.log().info("[%s] %d primitives by sound generated", getName(), this.primitives); } - @Nullable - public IAcoustic[] getPrimitive(@Nonnull final String primitive) { - IAcoustic[] result = this.compiled.get(primitive); - if (result == null) { - final IAcoustic a = generateAcoustic(primitive); - if (a != null) { - this.compiled.put(primitive, result = new IAcoustic[] { a }); - this.primitives++; - } - } - return result; - } - /** * Used to determine what acoustics to play based on the block's sound * attributes. It's a fallback method in case there isn't a configuration @@ -233,7 +221,20 @@ public IAcoustic[] resolvePrimitive(@Nonnull final IBlockState state) { if (acoustics == null && StringUtils.isNotEmpty(soundName)) acoustics = getPrimitive(soundName); - return acoustics != null ? acoustics : EMPTY; + return MoreObjects.firstNonNull(acoustics, EMPTY); + } + + @Nullable + private IAcoustic[] getPrimitive(@Nonnull final String primitive) { + IAcoustic[] result = this.compiled.get(primitive); + if (result == null) { + final IAcoustic a = generateAcoustic(primitive); + if (a != null) { + this.compiled.put(primitive, result = new IAcoustic[] { a }); + this.primitives++; + } + } + return result; } @Nullable @@ -245,7 +246,7 @@ private IAcoustic[] resolveByMaterial(@Nonnull final IBlockState state) { return result == EMPTY ? null : result; } - public void addAcoustic(@Nonnull final IAcoustic acoustic) { + private void addAcoustic(@Nonnull final IAcoustic acoustic) { this.acoustics.put(acoustic.getName(), acoustic); } @@ -254,18 +255,6 @@ public IAcoustic getAcoustic(@Nonnull final String name) { return this.acoustics.get(name); } - @Nonnull - public IAcoustic[] compileAcoustics(@Nonnull final SoundEvent evt) { - IAcoustic[] result = this.compiled.get(evt.getSoundName().toString()); - if (result == null) { - final IAcoustic a = generateAcoustic(evt); - this.compiled.put(a.getName(), result = new IAcoustic[] { a }); - } else { - this.hits++; - } - return result; - } - @Nonnull public IAcoustic[] compileAcoustics(@Nonnull final String acousticName) { IAcoustic[] result = this.compiled.get(acousticName); diff --git a/src/main/java/org/orecruncher/dsurround/registry/biome/BiomeRegistry.java b/src/main/java/org/orecruncher/dsurround/registry/biome/BiomeRegistry.java index 661f53ff0..192639cfa 100644 --- a/src/main/java/org/orecruncher/dsurround/registry/biome/BiomeRegistry.java +++ b/src/main/java/org/orecruncher/dsurround/registry/biome/BiomeRegistry.java @@ -171,13 +171,13 @@ public void reload() { complete(); } - protected void register(@Nonnull final Biome biome) { + private void register(@Nonnull final Biome biome) { final BiomeHandler handler = new BiomeHandler(biome); final BiomeInfo info = new BiomeInfo(handler); BiomeUtil.setBiomeData(biome, info); } - protected void register(@Nonnull final IBiome biome) { + private void register(@Nonnull final IBiome biome) { if (biome.isFake()) { final FakeBiome fb = (FakeBiome) biome; final BiomeInfo info = new BiomeInfo(fb); @@ -187,7 +187,7 @@ protected void register(@Nonnull final IBiome biome) { } @Nullable - protected BiomeInfo resolve(@Nonnull final IBiome biome) { + private BiomeInfo resolve(@Nonnull final IBiome biome) { if (biome.isFake()) { final FakeBiome fb = (FakeBiome) biome; return (BiomeInfo) fb.getBiomeData(); diff --git a/src/main/java/org/orecruncher/dsurround/registry/blockstate/BlockStateRegistry.java b/src/main/java/org/orecruncher/dsurround/registry/blockstate/BlockStateRegistry.java index 48e34a5cb..fb4891efd 100644 --- a/src/main/java/org/orecruncher/dsurround/registry/blockstate/BlockStateRegistry.java +++ b/src/main/java/org/orecruncher/dsurround/registry/blockstate/BlockStateRegistry.java @@ -98,7 +98,7 @@ private Stream getBlockStates() { } @Nonnull - protected BlockStateData get(@Nonnull final IBlockState state) { + private BlockStateData get(@Nonnull final IBlockState state) { BlockStateData profile = BlockStateUtil.getStateData(state); if (profile == null) { if (this.registry == null) { diff --git a/src/main/java/org/orecruncher/dsurround/registry/sound/SoundMetadata.java b/src/main/java/org/orecruncher/dsurround/registry/sound/SoundMetadata.java index d5095c960..81e6dbfbe 100644 --- a/src/main/java/org/orecruncher/dsurround/registry/sound/SoundMetadata.java +++ b/src/main/java/org/orecruncher/dsurround/registry/sound/SoundMetadata.java @@ -30,6 +30,7 @@ import org.orecruncher.dsurround.registry.config.SoundMetadataConfig; +import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; import net.minecraft.util.SoundCategory; @@ -40,10 +41,9 @@ public class SoundMetadata { protected final SoundCategory category; protected final List credits; - public SoundMetadata(@Nonnull final SoundMetadataConfig cfg) { + protected SoundMetadata(@Nonnull final SoundMetadataConfig cfg) { this.title = cfg.title; - final SoundCategory cat = translate(cfg.category); - this.category = cat != null ? cat : SoundCategory.NEUTRAL; + this.category = MoreObjects.firstNonNull(translate(cfg.category), SoundCategory.NEUTRAL); this.credits = ImmutableList.copyOf(cfg.credits); }