Skip to content

Commit

Permalink
make cast list not null
Browse files Browse the repository at this point in the history
add toString to instances
  • Loading branch information
ghzdude committed Mar 4, 2025
1 parent 707a57e commit 83a4325
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,9 @@ public Object remove(int index) {
public int size() {
return instances.size();
}

@Override
public String toString() {
return String.format("key{%s, %s}", this.key, super.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraftforge.items.IItemHandlerModifiable;

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -114,10 +115,11 @@ public boolean checkType(Object o) {
}

@SuppressWarnings("unchecked")
public <R> List<R> castList(AbilityInstances instances) {
public @NotNull <R> List<R> castList(AbilityInstances instances) {
if (instances.isKey(this)) {
return (List<R>) instances;
}
return null;
throw new IllegalArgumentException("Cannot cast instances of " + instances + " because they are not of " +
this.clazz.getSimpleName() + "!");
}
}

0 comments on commit 83a4325

Please sign in to comment.