Skip to content

Commit

Permalink
fix pipe capability retrieval logic (GregTechCEu#2415)
Browse files Browse the repository at this point in the history
  • Loading branch information
TechLord22 authored Mar 16, 2024
1 parent 77ed2e0 commit e85169e
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/main/java/gregtech/api/pipenet/tile/TileEntityPipeBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,24 +335,28 @@ public <T> T getCapabilityInternal(Capability<T> capability, @Nullable EnumFacin
@Nullable
@Override
public final <T> T getCapability(@NotNull Capability<T> capability, @Nullable EnumFacing facing) {
boolean isCoverable = capability == GregtechTileCapabilities.CAPABILITY_COVER_HOLDER;
Cover cover = facing == null ? null : coverableImplementation.getCoverAtSide(facing);
T defaultValue;
if (getPipeBlock() == null)
defaultValue = null;
else
defaultValue = getCapabilityInternal(capability, facing);
T pipeCapability = getPipeBlock() == null ? null : getCapabilityInternal(capability, facing);

if (isCoverable) {
return defaultValue;
if (capability == GregtechTileCapabilities.CAPABILITY_COVER_HOLDER) {
return pipeCapability;
}
if (cover == null && facing != null) {
return isConnected(facing) ? defaultValue : null;

Cover cover = facing == null ? null : coverableImplementation.getCoverAtSide(facing);
if (cover == null) {
if (facing == null || isConnected(facing)) {
return pipeCapability;
}
return null;
}
if (cover != null) {
return cover.getCapability(capability, defaultValue);

T coverCapability = cover.getCapability(capability, pipeCapability);
if (coverCapability == pipeCapability) {
if (isConnected(facing)) {
return pipeCapability;
}
return null;
}
return defaultValue;
return coverCapability;
}

@Override
Expand Down

0 comments on commit e85169e

Please sign in to comment.