mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 11:53:29 +01:00
fixed pipe network
This commit is contained in:
parent
cca0f12f1a
commit
c8fee33ca5
3 changed files with 9 additions and 15 deletions
|
@ -39,7 +39,6 @@ import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
// TODO it appears that this doesn't save properly yet :(
|
|
||||||
public class PipeNetwork extends SavedData implements GraphListener<BlockPos, NetworkEdge> {
|
public class PipeNetwork extends SavedData implements GraphListener<BlockPos, NetworkEdge> {
|
||||||
|
|
||||||
private static final Factory<PipeNetwork> FACTORY = new Factory<>(PipeNetwork::new, PipeNetwork::new);
|
private static final Factory<PipeNetwork> FACTORY = new Factory<>(PipeNetwork::new, PipeNetwork::new);
|
||||||
|
@ -518,10 +517,12 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startProfile(String name) {
|
public void startProfile(String name) {
|
||||||
|
if (this.level != null)
|
||||||
this.level.getProfiler().push(() -> PrettyPipes.ID + ":pipe_network_" + name);
|
this.level.getProfiler().push(() -> PrettyPipes.ID + ":pipe_network_" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endProfile() {
|
public void endProfile() {
|
||||||
|
if (this.level != null)
|
||||||
this.level.getProfiler().pop();
|
this.level.getProfiler().pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,6 +268,11 @@ public class PipeBlock extends BaseEntityBlock {
|
||||||
var network = PipeNetwork.get(worldIn);
|
var network = PipeNetwork.get(worldIn);
|
||||||
network.removeNode(pos);
|
network.removeNode(pos);
|
||||||
network.onPipeChanged(pos, state);
|
network.onPipeChanged(pos, state);
|
||||||
|
if (worldIn.getBlockEntity(pos) instanceof PipeBlockEntity pipe) {
|
||||||
|
pipe.getItems().clear();
|
||||||
|
for (var lock : pipe.craftIngredientRequests)
|
||||||
|
network.resolveNetworkLock(lock);
|
||||||
|
}
|
||||||
super.onRemove(state, worldIn, pos, newState, isMoving);
|
super.onRemove(state, worldIn, pos, newState, isMoving);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,6 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.AABB;
|
|
||||||
import net.neoforged.api.distmarker.Dist;
|
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
|
||||||
import net.neoforged.neoforge.capabilities.BlockCapability;
|
import net.neoforged.neoforge.capabilities.BlockCapability;
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.common.util.Lazy;
|
import net.neoforged.neoforge.common.util.Lazy;
|
||||||
|
@ -391,15 +388,6 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRemoved() {
|
|
||||||
super.setRemoved();
|
|
||||||
this.getItems().clear();
|
|
||||||
var network = PipeNetwork.get(this.level);
|
|
||||||
for (var lock : this.craftIngredientRequests)
|
|
||||||
network.resolveNetworkLock(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return Component.translatable("container." + PrettyPipes.ID + ".pipe");
|
return Component.translatable("container." + PrettyPipes.ID + ".pipe");
|
||||||
|
|
Loading…
Reference in a new issue