From a84e5830c92c8a4c275f6a62c1cf5dccdede710f Mon Sep 17 00:00:00 2001 From: Aeronica Date: Tue, 23 Jan 2024 07:23:34 -0600 Subject: [PATCH] Resolve code analysis issues. --- src/main/java/aeronicamc/mods/mxtune/MXTune.java | 2 +- .../mods/mxtune/blocks/LockableHelper.java | 2 +- .../aeronicamc/mods/mxtune/blocks/MusicBlock.java | 15 +++++---------- .../mods/mxtune/blocks/MusicBlockEntity.java | 3 --- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/aeronicamc/mods/mxtune/MXTune.java b/src/main/java/aeronicamc/mods/mxtune/MXTune.java index 67e9ab83..c83f72c2 100644 --- a/src/main/java/aeronicamc/mods/mxtune/MXTune.java +++ b/src/main/java/aeronicamc/mods/mxtune/MXTune.java @@ -74,7 +74,7 @@ public ItemStack makeIcon() { } }; - public static boolean isDevEnv() { return !FMLEnvironment.production; }; + public static boolean isDevEnv() { return !FMLEnvironment.production; } public MXTune() { diff --git a/src/main/java/aeronicamc/mods/mxtune/blocks/LockableHelper.java b/src/main/java/aeronicamc/mods/mxtune/blocks/LockableHelper.java index 027aa37a..a5681fc0 100644 --- a/src/main/java/aeronicamc/mods/mxtune/blocks/LockableHelper.java +++ b/src/main/java/aeronicamc/mods/mxtune/blocks/LockableHelper.java @@ -22,7 +22,7 @@ public static boolean isLocked(World level, BlockPos blockPos) TileEntity blockEntity = level.getBlockEntity(blockPos); boolean lock = false; if (blockEntity instanceof ILockable) - lock = ((ILockable) blockEntity).isLocked() ; //canManage(player, (ILockable) blockEntity); + lock = ((ILockable) blockEntity).isLocked() ; return lock; } diff --git a/src/main/java/aeronicamc/mods/mxtune/blocks/MusicBlock.java b/src/main/java/aeronicamc/mods/mxtune/blocks/MusicBlock.java index 29f5750a..7a9cf648 100644 --- a/src/main/java/aeronicamc/mods/mxtune/blocks/MusicBlock.java +++ b/src/main/java/aeronicamc/mods/mxtune/blocks/MusicBlock.java @@ -150,7 +150,7 @@ public ActionResultType use(BlockState state, World worldIn, BlockPos pos, Playe // but I have not found another solution yet. if (musicBlockEntity.notHeld()) { - boolean isPlaying = canPlayOrStopMusic(worldIn, state, pos, musicBlockEntity, player, false); + boolean isPlaying = canPlayOrStopMusic(worldIn, state, pos, musicBlockEntity, player); if (isPlaying) musicBlockEntity.setLastPlay(true); setPlayingState(worldIn, pos, state, isPlaying); @@ -175,7 +175,7 @@ private boolean invertShiftIfLocked(PlayerEntity player, World level, BlockPos b return LockableHelper.isLocked(level, blockPos) != player.isShiftKeyDown(); } - private boolean canPlayOrStopMusic(World pLevel, BlockState pState, BlockPos pPos, MusicBlockEntity musicBlockEntity, @Nullable PlayerEntity playerEntity, Boolean noPlay) + private boolean canPlayOrStopMusic(World pLevel, BlockState pState, BlockPos pPos, MusicBlockEntity musicBlockEntity, @Nullable PlayerEntity playerEntity) { int playId = PlayManager.getEntitiesPlayId(musicBlockEntity.getMusicSourceEntityId()); if (PlayManager.isActivePlayId(playId) || pState.getValue(PLAYING)) @@ -183,12 +183,8 @@ private boolean canPlayOrStopMusic(World pLevel, BlockState pState, BlockPos pPo PlayManager.stopPlayId(playId, 0); return false; } - if (!noPlay) - { - playId = PlayManager.playMusic(pLevel, pPos, playerEntity); - return playId != PlayIdSupplier.INVALID && !pState.getValue(PLAYING); - } - return false; + playId = PlayManager.playMusic(pLevel, pPos, playerEntity); + return playId != PlayIdSupplier.INVALID && !pState.getValue(PLAYING); } private boolean handleWrenchAble(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) @@ -216,7 +212,6 @@ private boolean handleWrenchAble(BlockState state, World level, BlockPos pos, Pl if (!hit.getDirection().equals(Direction.UP ) && !hit.getDirection().equals(Direction.DOWN)) { newState = state.setValue(HORIZONTAL_FACING, hit.getDirection()); - //newState = state.rotate(level, pos, Rotation.CLOCKWISE_90); level.setBlockAndUpdate(pos, newState); level.playSound(null, pos, ModSoundEvents.ROTATE_BLOCK.get(), SoundCategory.BLOCKS, 0.6F, 1.0F); } else @@ -264,7 +259,7 @@ public void neighborChanged(BlockState pState, World pLevel, BlockPos pPos, Bloc { if (isSidePowered) { - boolean isPlaying = canPlayOrStopMusic(pLevel, pState, pPos, musicBlockEntity, null, false); + boolean isPlaying = canPlayOrStopMusic(pLevel, pState, pPos, musicBlockEntity, null); if (isPlaying) musicBlockEntity.setLastPlay(true); setPlayingState(pLevel, pPos, pState, isPlaying); diff --git a/src/main/java/aeronicamc/mods/mxtune/blocks/MusicBlockEntity.java b/src/main/java/aeronicamc/mods/mxtune/blocks/MusicBlockEntity.java index 1654153c..eabe7084 100644 --- a/src/main/java/aeronicamc/mods/mxtune/blocks/MusicBlockEntity.java +++ b/src/main/java/aeronicamc/mods/mxtune/blocks/MusicBlockEntity.java @@ -26,8 +26,6 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -36,7 +34,6 @@ public class MusicBlockEntity extends TileEntity implements INamedContainerProvider, ILockable, IMusicPlayer, INameable, ITickableTileEntity { public static final UUID EMPTY_OWNER = new UUID(0,0); - private static final Logger LOGGER = LogManager.getLogger(MusicBlockEntity.class); private final LazyOptional handler = LazyOptional.of(this::createHandler); public static final String KEY_CUSTOM_NAME = "CustomName"; public static final String KEY_INVENTORY = "Inventory";