Skip to content

Commit

Permalink
Resolve code analysis issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeronica committed Jan 23, 2024
1 parent 465017a commit a84e583
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/java/aeronicamc/mods/mxtune/MXTune.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public ItemStack makeIcon() {
}
};

public static boolean isDevEnv() { return !FMLEnvironment.production; };
public static boolean isDevEnv() { return !FMLEnvironment.production; }

public MXTune()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/aeronicamc/mods/mxtune/blocks/MusicBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -175,20 +175,16 @@ 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))
{
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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<IItemHandler> handler = LazyOptional.of(this::createHandler);
public static final String KEY_CUSTOM_NAME = "CustomName";
public static final String KEY_INVENTORY = "Inventory";
Expand Down

0 comments on commit a84e583

Please sign in to comment.