mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 19:58:35 +01:00
Revert "added pipe network energy storages"
This reverts commit 9a934431
This commit is contained in:
parent
9a93443152
commit
f9bbc16b7b
4 changed files with 2 additions and 47 deletions
|
@ -141,7 +141,7 @@ public final class Registry {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends AbstractPipeContainer<?>> ContainerType<T> createPipeContainer(String name) {
|
private static <T extends AbstractPipeContainer<?>> ContainerType<T> createPipeContainer(String name) {
|
||||||
return (ContainerType<T>) IForgeContainerType.create((windowId, inv, data) -> {
|
return (ContainerType<T>) IForgeContainerType.create((windowId, inv, data) -> {
|
||||||
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, inv.player.world, data.readBlockPos());
|
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, inv.player.world, data.readBlockPos());
|
||||||
int moduleIndex = data.readInt();
|
int moduleIndex = data.readInt();
|
||||||
|
@ -150,7 +150,7 @@ public final class Registry {
|
||||||
}).setRegistryName(name);
|
}).setRegistryName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Item[] createTieredModule(String name, BiFunction<String, ModuleTier, ModuleItem> item) {
|
private static Item[] createTieredModule(String name, BiFunction<String, ModuleTier, ModuleItem> item) {
|
||||||
List<Item> items = new ArrayList<>();
|
List<Item> items = new ArrayList<>();
|
||||||
for (ModuleTier tier : ModuleTier.values())
|
for (ModuleTier tier : ModuleTier.values())
|
||||||
items.add(item.apply(name, tier).setRegistryName(tier.name().toLowerCase(Locale.ROOT) + "_" + name));
|
items.add(item.apply(name, tier).setRegistryName(tier.name().toLowerCase(Locale.ROOT) + "_" + name));
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.google.common.collect.Streams;
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import de.ellpeck.prettypipes.Registry;
|
import de.ellpeck.prettypipes.Registry;
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
|
||||||
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||||
|
@ -16,7 +15,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.ListNBT;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -24,9 +22,6 @@ import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.jgrapht.GraphPath;
|
import org.jgrapht.GraphPath;
|
||||||
|
@ -53,7 +48,6 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundNBT>, GraphL
|
||||||
private final DijkstraShortestPath<BlockPos, NetworkEdge> dijkstra;
|
private final DijkstraShortestPath<BlockPos, NetworkEdge> dijkstra;
|
||||||
private final Map<BlockPos, List<BlockPos>> nodeToConnectedNodes = new HashMap<>();
|
private final Map<BlockPos, List<BlockPos>> nodeToConnectedNodes = new HashMap<>();
|
||||||
private final Map<BlockPos, PipeTileEntity> tileCache = new HashMap<>();
|
private final Map<BlockPos, PipeTileEntity> tileCache = new HashMap<>();
|
||||||
private final Map<BlockPos, Pair<TileEntity, Direction>> energyStorageCache = new HashMap<>();
|
|
||||||
private final ListMultimap<BlockPos, PipeItem> pipeItems = ArrayListMultimap.create();
|
private final ListMultimap<BlockPos, PipeItem> pipeItems = ArrayListMultimap.create();
|
||||||
private final World world;
|
private final World world;
|
||||||
|
|
||||||
|
@ -184,30 +178,6 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundNBT>, GraphL
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnergyStorage getEnergyStorage(BlockPos node) {
|
|
||||||
Pair<TileEntity, Direction> value = this.energyStorageCache.get(node);
|
|
||||||
isNull:
|
|
||||||
if (value == null || value.getLeft().isRemoved()) {
|
|
||||||
for (BlockPos other : this.getOrderedNetworkNodes(node)) {
|
|
||||||
PipeTileEntity pipe = this.getPipe(other);
|
|
||||||
for (Direction dir : Direction.values()) {
|
|
||||||
IPipeConnectable connectable = pipe.getConnectable(dir);
|
|
||||||
if (connectable == null)
|
|
||||||
continue;
|
|
||||||
BlockPos pos = other.offset(dir);
|
|
||||||
if (!connectable.provideEnergyStorage(this.world, pos, other, dir.getOpposite()))
|
|
||||||
continue;
|
|
||||||
value = Pair.of(this.world.getTileEntity(pos), dir.getOpposite());
|
|
||||||
this.energyStorageCache.put(node, value);
|
|
||||||
break isNull;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (value == null)
|
|
||||||
return null;
|
|
||||||
return value.getLeft().getCapability(CapabilityEnergy.ENERGY, value.getRight()).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<NetworkLocation> getOrderedNetworkItems(BlockPos node) {
|
public List<NetworkLocation> getOrderedNetworkItems(BlockPos node) {
|
||||||
if (!this.isNode(node))
|
if (!this.isNode(node))
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
|
@ -9,7 +9,4 @@ public interface IPipeConnectable {
|
||||||
|
|
||||||
ConnectionType getConnectionType(World world, BlockPos pos, BlockState state, BlockPos pipePos, Direction direction);
|
ConnectionType getConnectionType(World world, BlockPos pos, BlockState state, BlockPos pipePos, Direction direction);
|
||||||
|
|
||||||
default boolean provideEnergyStorage(World world, BlockPos pos, BlockPos pipePos, Direction direction) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import de.ellpeck.prettypipes.items.IModule;
|
||||||
import de.ellpeck.prettypipes.network.PipeItem;
|
import de.ellpeck.prettypipes.network.PipeItem;
|
||||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
import de.ellpeck.prettypipes.pipe.modules.containers.MainPipeContainer;
|
import de.ellpeck.prettypipes.pipe.modules.containers.MainPipeContainer;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.ChestBlock;
|
import net.minecraft.block.ChestBlock;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -201,17 +200,6 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
||||||
return tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir.getOpposite()).orElse(null);
|
return tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir.getOpposite()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPipeConnectable getConnectable(Direction dir) {
|
|
||||||
if (!this.isConnected(dir))
|
|
||||||
return null;
|
|
||||||
BlockPos offset = this.pos.offset(dir);
|
|
||||||
BlockState state = this.world.getBlockState(offset);
|
|
||||||
Block block = state.getBlock();
|
|
||||||
if (block instanceof IPipeConnectable)
|
|
||||||
return (IPipeConnectable) block;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isConnectedInventory(Direction dir) {
|
public boolean isConnectedInventory(Direction dir) {
|
||||||
return this.getItemHandler(dir) != null;
|
return this.getItemHandler(dir) != null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue