crwdns145227:0crwdne145227:0
Note
crwdns145229:0crwdne145229:0
crwdns145231:0crwdne145231:0
crwdns145233:0crwdne145233:0
crwdns145235:0crwdne145235:0
crwdns145237:0crwdne145237:0
Note
crwdns145239:0crwdne145239:0
crwdns145241:0crwdne145241:0
crwdns145243:0crwdne145243:0
crwdns145245:0crwdne145245:0
return new Collection<ItemStack>() {
@Override
public Iterator<ItemStack> iterator() {
return new Iterator<ItemStack>() {
// THIS WILL NOT WORK!
@Override
public boolean hasNext() {
// Code skipped
}
@Override
public ItemStack next() {
// Code skipped
}
};
}
// Other methods skipped
};
crwdns145247:0crwdne145247:0
crwdns145249:0crwdne145249:0
public class SampleCollection implements Collection<ItemStack> {
private final TargetClass target;
public SampleCollection(TargetClass target) {
this.target = target;
}
@Override
public Iterator<ItemStack> iterator() {
return new Iterator<ItemStack>() {
@Override
public boolean hasNext() {
// Code skipped
}
@Override
public ItemStack next() {
// Code skipped
}
};
}
// Other methods skipped
}
@Mixin(TargetClass.class)
public abstract class SomeMixin {
public Collection<ItemStack> someFunction() {
return new SampleCollection((TargetClass) (Object) this);
}
}
crwdns145251:0crwdne145251:0
@Mixin(TargetClass.class)
public abstract class SomeMixin {
private final class SampleIterator implements Iterator<ItemStack> {
@Override
public boolean hasNext() {
// Code skipped
}
@Override
public ItemStack next() {
// Code skipped
}
}
public Collection<ItemStack> someFunction() {
return new Collection<ItemStack>() {
@Override
public Iterator<ItemStack> iterator() {
return new SampleIterator();
}
// Other methods skipped
};
}
}