Compare commits

..

3 commits

Author SHA1 Message Date
Ell
6b5c63059d 1.16.1 2024-05-19 11:06:03 +02:00
Ell
4d022f3489 fixed pipes being washed away by water
closes #204
2024-05-19 11:04:29 +02:00
Ell
6b4f86ce1a improve performance of getOrderedNetworkItems
(see #205)
2024-05-19 10:48:08 +02:00
3 changed files with 7 additions and 6 deletions

View file

@ -32,7 +32,7 @@ mod_name=PrettyPipes
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.16.0
mod_version=1.16.1
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -21,6 +21,7 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.saveddata.SavedData;
import net.neoforged.neoforge.items.IItemHandler;
import net.neoforged.neoforge.network.PacketDistributor;
import org.apache.commons.lang3.tuple.Pair;
import org.jgrapht.ListenableGraph;
@ -339,7 +340,7 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
if (!this.isNode(node))
return Collections.emptyList();
this.startProfile("get_network_items");
List<NetworkLocation> info = new ArrayList<>();
var ret = new HashMap<IItemHandler, NetworkLocation>();
for (var dest : this.getOrderedNetworkNodes(node)) {
if (!this.level.isLoaded(dest))
continue;
@ -349,15 +350,15 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
if (handler == null || !pipe.canNetworkSee(dir, handler))
continue;
// check if this handler already exists (double-connected pipes, double chests etc.)
if (info.stream().anyMatch(l -> handler.equals(l.getItemHandler(this.level))))
if (ret.containsKey(handler))
continue;
var location = new NetworkLocation(dest, dir);
if (!location.isEmpty(this.level))
info.add(location);
ret.put(handler, location);
}
}
this.endProfile();
return info;
return new ArrayList<>(ret.values());
}
public void createNetworkLock(NetworkLock lock) {

View file

@ -45,7 +45,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
public class PipeBlock extends BaseEntityBlock {
public class PipeBlock extends BaseEntityBlock implements SimpleWaterloggedBlock {
public static final MapCodec<PipeBlock> CODEC = BlockBehaviour.simpleCodec(PipeBlock::new);