mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Exploding pipes
- Potentially fix pipes when blocks are removed etc near them
This commit is contained in:
parent
058fc2bd64
commit
f4baa9bc77
2 changed files with 8 additions and 41 deletions
|
@ -12,6 +12,7 @@ import net.createmod.catnip.math.BlockFace;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
|
||||||
import net.neoforged.neoforge.capabilities.BlockCapabilityCache;
|
import net.neoforged.neoforge.capabilities.BlockCapabilityCache;
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.fluids.FluidStack;
|
import net.neoforged.neoforge.fluids.FluidStack;
|
||||||
|
@ -76,19 +77,18 @@ public abstract class FlowSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void manageSource(Level world) {
|
public void manageSource(Level world) {
|
||||||
// TODO 1.21: is it even necessary to periodically reset the cache?
|
if (fluidHandlerCache == null) {
|
||||||
if (fluidHandlerCache != null && world.getGameTime() % 20 != 0)
|
BlockEntity blockEntity = world.getBlockEntity(location.getConnectedPos());
|
||||||
return;
|
if (blockEntity != null && world instanceof ServerLevel serverLevel)
|
||||||
BlockEntity blockEntity = world.getBlockEntity(location.getConnectedPos());
|
fluidHandlerCache = ICapabilityProvider.of(BlockCapabilityCache.create(
|
||||||
if (blockEntity != null && world instanceof ServerLevel serverLevel)
|
|
||||||
fluidHandlerCache = ICapabilityProvider.of(BlockCapabilityCache.create(
|
|
||||||
Capabilities.FluidHandler.BLOCK,
|
Capabilities.FluidHandler.BLOCK,
|
||||||
serverLevel,
|
serverLevel,
|
||||||
blockEntity.getBlockPos(),
|
blockEntity.getBlockPos(),
|
||||||
location.getOppositeFace(),
|
location.getOppositeFace(),
|
||||||
() -> !blockEntity.isRemoved(),
|
() -> !blockEntity.isRemoved(),
|
||||||
() -> {}
|
() -> fluidHandlerCache = EMPTY
|
||||||
));
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.simibubi.create.foundation.utility;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.neoforged.neoforge.capabilities.ICapabilityInvalidationListener;
|
|
||||||
|
|
||||||
public class HashableCapabilityInvalidationListener<H> implements ICapabilityInvalidationListener {
|
|
||||||
private final ICapabilityInvalidationListener listener;
|
|
||||||
private final H hashKey;
|
|
||||||
|
|
||||||
public HashableCapabilityInvalidationListener(ICapabilityInvalidationListener listener, H hashKey) {
|
|
||||||
this.listener = listener;
|
|
||||||
this.hashKey = hashKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
HashableCapabilityInvalidationListener<?> that = (HashableCapabilityInvalidationListener<?>) o;
|
|
||||||
return Objects.equals(hashKey, that.hashKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(hashKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onInvalidate() {
|
|
||||||
return listener.onInvalidate();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue