Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20' into 1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Aug 24, 2024
2 parents 2abc4fa + 333147c commit 1572bd7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.embeddedt.modernfix.blockstate;

import com.google.common.collect.Iterators;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.world.level.block.state.properties.Property;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -96,104 +97,66 @@ public void clear() {
this.usedSlots = 0;
}

private <T> List<T> asList(T... array) {
var list = Arrays.asList(array);
if(usedSlots < array.length) {
list = list.subList(0, usedSlots);
}
return list;
}

@NotNull
@Override
public Set<Map<Property<?>, Comparable<?>>> keySet() {
throw new UnsupportedOperationException();
return new AbstractSet<>() {
@Override
public Iterator<Map<Property<?>, Comparable<?>>> iterator() {
return keys.length == usedSlots ? Iterators.forArray(keys) : asList(keys).iterator();
}

@Override
public int size() {
return usedSlots;
}
};
}

@NotNull
@Override
public Collection<S> values() {
throw new UnsupportedOperationException();
return (Collection<S>)asList(values);
}

@NotNull
@Override
public Set<Entry<Map<Property<?>, Comparable<?>>, S>> entrySet() {
return new Set<Entry<Map<Property<?>, Comparable<?>>, S>>() {
return new AbstractSet<>() {
@Override
public int size() {
return usedSlots;
}

@Override
public boolean isEmpty() {
return FakeStateMap.this.isEmpty();
}

@Override
public boolean contains(Object o) {
throw new UnsupportedOperationException();
}

@NotNull
@Override
public Iterator<Entry<Map<Property<?>, Comparable<?>>, S>> iterator() {
return new Iterator<Entry<Map<Property<?>, Comparable<?>>, S>>() {
return new Iterator<>() {
int currentIdx = 0;

@Override
public boolean hasNext() {
return currentIdx < usedSlots;
}

@Override
public Entry<Map<Property<?>, Comparable<?>>, S> next() {
if(currentIdx >= usedSlots)
if (currentIdx >= usedSlots)
throw new IndexOutOfBoundsException();
Entry<Map<Property<?>, Comparable<?>>, S> entry = new AbstractMap.SimpleImmutableEntry<>(keys[currentIdx], (S)values[currentIdx]);
Entry<Map<Property<?>, Comparable<?>>, S> entry = new AbstractMap.SimpleImmutableEntry<>(keys[currentIdx], (S) values[currentIdx]);
currentIdx++;
return entry;
}
};
}

@NotNull
@Override
public Object[] toArray() {
throw new UnsupportedOperationException();
}

@NotNull
@Override
public <T> T[] toArray(@NotNull T[] ts) {
throw new UnsupportedOperationException();
}

@Override
public boolean add(Entry<Map<Property<?>, Comparable<?>>, S> mapSEntry) {
throw new UnsupportedOperationException();
}

@Override
public boolean remove(Object o) {
throw new UnsupportedOperationException();
}

@Override
public boolean containsAll(@NotNull Collection<?> collection) {
throw new UnsupportedOperationException();
}

@Override
public boolean addAll(@NotNull Collection<? extends Entry<Map<Property<?>, Comparable<?>>, S>> collection) {
throw new UnsupportedOperationException();
}

@Override
public boolean retainAll(@NotNull Collection<?> collection) {
throw new UnsupportedOperationException();
}

@Override
public boolean removeAll(@NotNull Collection<?> collection) {
throw new UnsupportedOperationException();
}

@Override
public void clear() {
throw new UnsupportedOperationException();
}
};
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.embeddedt.modernfix.common.mixin.bugfix.paper_chunk_patches;

import net.minecraft.util.SortedArraySet;
import org.embeddedt.modernfix.annotation.RequiresMod;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

Expand All @@ -9,6 +10,7 @@
import java.util.function.Predicate;

@Mixin(SortedArraySet.class)
@RequiresMod("!moonrise")
public abstract class SortedArraySetMixin<T> extends AbstractSet<T> {
@Shadow private int size;

Expand Down

0 comments on commit 1572bd7

Please sign in to comment.