mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 08:27:03 +01:00
Fix issue restricting the maximum size of contraptions.
This commit is contained in:
parent
6dc4a18ed3
commit
3a2771c5c0
2 changed files with 91 additions and 6 deletions
|
@ -21,6 +21,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.utility.*;
|
||||||
import org.apache.commons.lang3.tuple.MutablePair;
|
import org.apache.commons.lang3.tuple.MutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
@ -53,11 +54,6 @@ import com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
||||||
import com.simibubi.create.foundation.render.backend.light.EmptyLighter;
|
import com.simibubi.create.foundation.render.backend.light.EmptyLighter;
|
||||||
import com.simibubi.create.foundation.utility.BlockFace;
|
|
||||||
import com.simibubi.create.foundation.utility.Iterate;
|
|
||||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
|
||||||
import com.simibubi.create.foundation.utility.NBTProcessors;
|
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
||||||
|
|
||||||
import net.minecraft.block.AbstractButtonBlock;
|
import net.minecraft.block.AbstractButtonBlock;
|
||||||
|
@ -178,7 +174,7 @@ public abstract class Contraption {
|
||||||
|
|
||||||
public boolean searchMovedStructure(World world, BlockPos pos, @Nullable Direction forcedDirection) throws AssemblyException {
|
public boolean searchMovedStructure(World world, BlockPos pos, @Nullable Direction forcedDirection) throws AssemblyException {
|
||||||
initialPassengers.clear();
|
initialPassengers.clear();
|
||||||
Queue<BlockPos> frontier = new LinkedList<>();
|
Queue<BlockPos> frontier = new UniqueLinkedList<>();
|
||||||
Set<BlockPos> visited = new HashSet<>();
|
Set<BlockPos> visited = new HashSet<>();
|
||||||
anchor = pos;
|
anchor = pos;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.simibubi.create.foundation.utility;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class UniqueLinkedList<E> extends LinkedList<E> {
|
||||||
|
private final HashSet<E> contained = new HashSet<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(Object o) {
|
||||||
|
return contained.contains(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E poll() {
|
||||||
|
E e = super.poll();
|
||||||
|
contained.remove(e);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean add(E e) {
|
||||||
|
if (contained.add(e)) return super.add(e);
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(int index, E element) {
|
||||||
|
if (contained.add(element)) super.add(index, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addFirst(E e) {
|
||||||
|
if (contained.add(e)) super.addFirst(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addLast(E e) {
|
||||||
|
if (contained.add(e)) super.addLast(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(Collection<? extends E> c) {
|
||||||
|
List<? extends E> filtered = c.stream().filter(it -> !contained.contains(it)).collect(Collectors.toList());
|
||||||
|
return super.addAll(filtered);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(int index, Collection<? extends E> c) {
|
||||||
|
List<? extends E> filtered = c.stream().filter(it -> !contained.contains(it)).collect(Collectors.toList());
|
||||||
|
return super.addAll(index, filtered);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(Object o) {
|
||||||
|
contained.remove(o);
|
||||||
|
return super.remove(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E remove(int index) {
|
||||||
|
E e = super.remove(index);
|
||||||
|
contained.remove(e);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E removeFirst() {
|
||||||
|
E e = super.removeFirst();
|
||||||
|
contained.remove(e);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E removeLast() {
|
||||||
|
E e = super.removeLast();
|
||||||
|
contained.remove(e);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
super.clear();
|
||||||
|
contained.clear();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue