Skip to content

Commit

Permalink
Address some automated code inspections
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Apr 4, 2024
1 parent 32e0b5f commit a7ea195
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 32 deletions.
Expand Up @@ -87,7 +87,7 @@ protected void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY)
GuiUtils.fill(guiGraphics, getRelativeX() + optionCenter, getRelativeY() + 17, 1, 3, color);
if (usesIcons) {
IHasModeIcon hasModeIcon = (IHasModeIcon) option;
guiGraphics.blit(hasModeIcon.getModeIcon(), (int) (getRelativeX() + optionCenter - 8), getRelativeY() + 19, 0, 0, 16, 16, 16, 16);
guiGraphics.blit(hasModeIcon.getModeIcon(), getRelativeX() + optionCenter - 8, getRelativeY() + 19, 0, 0, 16, 16, 16, 16);
} else {
parent.drawTextWithScale(guiGraphics, text, getRelativeX() + left, getRelativeY() + 20, textColor, TEXT_SCALE);
}
Expand Down
Expand Up @@ -326,6 +326,7 @@ record TrackedIngredients<SLOT extends RVRecipeSlot>(SLOT view, Set<HashedItem>
shuffleLookup.put(source, Collections.singletonList(actualSources));
} else {
List<List<SingularHashedItemSource>> list = shuffleLookup.get(source);
//noinspection Java8MapApi - Capturing lambda
if (list == null) {
list = new ArrayList<>(elements);
shuffleLookup.put(source, list);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/mekanism/client/render/armor/MekaSuitArmor.java
Expand Up @@ -495,7 +495,7 @@ private static boolean checkEquipment(EquipmentSlot type, String text) {

private record ArmorQuads(Map<ModelPos, List<BakedQuad>> opaqueQuads, Map<ModelPos, List<BakedQuad>> transparentQuads) {

public ArmorQuads {
private ArmorQuads {
if (opaqueQuads.isEmpty()) {
opaqueQuads = Collections.emptyMap();
}
Expand Down Expand Up @@ -566,7 +566,7 @@ public ModuleOBJModelData(ResourceLocation rl) {
super(rl);
}

public Set<String> getPartsForSpec(ModuleModelSpec spec, boolean active) {
private Set<String> getPartsForSpec(ModuleModelSpec spec, boolean active) {
SpecData specData = specParts.get(spec);
if (specData == null) {
return Collections.emptySet();
Expand Down Expand Up @@ -672,7 +672,7 @@ public ResourceLocation getRenderTypeHint() {
}

@Override
public boolean isComponentVisible(String component, boolean fallback) {
public boolean isComponentVisible(@NotNull String component, boolean fallback) {
//Ignore fallback as we always have a true or false answer
return parts.contains(component);
}
Expand Down
Expand Up @@ -87,31 +87,14 @@ private List<RPCMethodGroup> buildMethodGroups() {
}).toList();
}

private static class MethodGroup implements RPCMethodGroup {

private final String name;
private final Set<RPCMethod> children;

private MethodGroup(String name, Set<RPCMethod> children) {
this.name = name;
this.children = children;
}

@Override
public String getName() {
return name;
}

@Override
public Set<RPCMethod> getOverloads() {
return children;
}
private record MethodGroup(String getName, Set<RPCMethod> getOverloads) implements RPCMethodGroup {

@Override
public Optional<RPCMethod> findOverload(RPCInvocation invocation) {
if (!this.children.isEmpty()) {
Set<RPCMethod> children = getOverloads();
if (!children.isEmpty()) {
int parameters = invocation.getParameters().size();
for (RPCMethod m : this.children) {
for (RPCMethod m : children) {
if (m.getParameters().length == parameters) {
return Optional.of(m);
}
Expand Down
Expand Up @@ -19,7 +19,7 @@ public class OC2CapabilityHelper {
});
}*/

@SuppressWarnings("unchecked")
//@SuppressWarnings("unchecked")
public static <TILE extends CapabilityTileEntity & IComputerTile> void addCapability(BlockEntityTypeBuilder<TILE> builder, BooleanSupplier supportsComputer) {
//TODO - 1.20.2: Reimplement when OC2 updates
//builder.with(CAPABILITY, (ICapabilityProvider<? super TILE, @Nullable Direction, Device>) PROVIDER, supportsComputer);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mekanism/common/item/gear/ItemMekaTool.java
Expand Up @@ -166,6 +166,7 @@ public int getEnchantmentLevel(ItemStack stack, Enchantment enchantment) {
return Math.max(moduleLevel, super.getEnchantmentLevel(stack, enchantment));
}

@Override
public Map<Enchantment, Integer> getAllEnchantments(ItemStack stack) {
Map<Enchantment, Integer> enchantments = super.getAllEnchantments(stack);
IModuleContainer container = IModuleHelper.INSTANCE.getModuleContainerNullable(stack);
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/mekanism/common/lib/collection/HashList.java
Expand Up @@ -22,13 +22,11 @@ public class HashList<T> extends LinkedHashSet<T> {
protected List<T> list;

public HashList() {
super();
list = new ArrayList<>();
}

public HashList(Collection<? extends T> toCopy) {
super();
list = new ArrayList<>();
this();
addAll(toCopy);
}

Expand Down Expand Up @@ -93,7 +91,7 @@ public List<T> elements() {
public Object clone() {
@SuppressWarnings("unchecked") // safe (result of clone)
HashList<T> dup = (HashList<T>) super.clone();
dup.list = new ArrayList<T>(this.list);
dup.list = new ArrayList<>(this.list);
return dup;
}

Expand Down
Expand Up @@ -351,7 +351,6 @@ public void invalidate() {
}

@Override
@SuppressWarnings({"unchecked"})
public void trackForMainContainer(MekanismContainer container) {
if (securityFrequency != null) {
trackFrequencyForMainContainer(container, securityFrequency, FrequencyType.SECURITY);
Expand Down
Expand Up @@ -83,6 +83,7 @@ public ACCEPTOR getConnectedAcceptor(Direction side) {
*/
private RefreshListener getRefreshListener(@NotNull Direction side) {
RefreshListener listener = cachedListeners.get(side);
//noinspection Java8MapApi - Capturing lambda
if (listener == null) {
listener = new RefreshListener(transmitterTile, side);
cachedListeners.put(side, listener);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mekanism/common/util/UnitDisplayUtils.java
Expand Up @@ -63,7 +63,7 @@ public static Component getDisplay(double temp, TemperatureUnit unit, int decima
return getDisplayBase(unit.convertFromK(temp, shift), unit, decimalPlaces, isShort, spaceBetweenSymbol);
}

public static Component getDisplayBase(double value, Unit unit, int decimalPlaces, boolean isShort, boolean spaceBetweenSymbol) {
private static Component getDisplayBase(double value, Unit unit, int decimalPlaces, boolean isShort, boolean spaceBetweenSymbol) {
if (value == 0) {
if (isShort) {
String spaceStr = spaceBetweenSymbol ? " " : "";
Expand Down

0 comments on commit a7ea195

Please sign in to comment.