Implemented capabilities for cable buses in a way that dispatches the capabilities to the parts on the appropriate attachment point. Implemented the capabilities for interface parts and tiles to provide a proof of concept.
This commit is contained in:
@@ -22,6 +22,7 @@ package appeng.tile.networking;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
@@ -35,6 +36,7 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.IFacadeContainer;
|
||||
@@ -391,4 +393,24 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
this.cb = cb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capabilityClass, @Nullable EnumFacing fromSide )
|
||||
{
|
||||
// Note that null will be translated to INTERNAL here
|
||||
AEPartLocation partLocation = AEPartLocation.fromFacing( fromSide );
|
||||
|
||||
IPart part = getPart( partLocation );
|
||||
return part != null && part.hasCapability( capabilityClass );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capabilityClass, @Nullable EnumFacing fromSide )
|
||||
{
|
||||
// Note that null will be translated to INTERNAL here
|
||||
AEPartLocation partLocation = AEPartLocation.fromFacing( fromSide );
|
||||
|
||||
IPart part = getPart( partLocation );
|
||||
return part == null ? null : part.getCapability( capabilityClass );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user