use of mcmultipart.api.multipart.IMultipartTile in project Charset by CharsetMC.
the class MCMPAddonBase method onAttachTile.
@SubscribeEvent
public final void onAttachTile(AttachCapabilitiesEvent<TileEntity> event) {
if (tileEntityPredicate.test(event.getObject())) {
final IMultipartTile multipartTile = multipartTileSupplier.apply(event.getObject());
event.addCapability(KEY, factory.create(multipartTile));
}
}
use of mcmultipart.api.multipart.IMultipartTile in project Charset by CharsetMC.
the class WireUtils method getWire.
@Nullable
public static Wire getWire(IBlockAccess access, BlockPos pos, WireFace face) {
IMultipartContainer container = null;
if (access instanceof IMultipartBlockAccess) {
access = ((IMultipartBlockAccess) access).getActualWorld();
}
Optional<IMultipartContainer> containerOpt = MultipartHelper.getContainer(access, pos);
if (containerOpt.isPresent()) {
container = containerOpt.get();
}
if (container != null) {
Optional<IMultipartTile> tile = container.getPartTile(toPartSlot(face));
if (tile.isPresent() && tile.get().getTileEntity() instanceof TileWire) {
Wire wire = ((TileWire) tile.get().getTileEntity()).wire;
if (wire != null && wire.getLocation() == face) {
return ((TileWire) tile.get().getTileEntity()).wire;
}
}
return null;
}
TileEntity tile = access.getTileEntity(pos);
if (tile != null && tile instanceof TileWire && ((TileWire) tile).wire != null && ((TileWire) tile).wire.getLocation() == face) {
return ((TileWire) tile).wire;
} else {
return null;
}
}
use of mcmultipart.api.multipart.IMultipartTile in project Charset by CharsetMC.
the class MCMPAddonGates method onAttachCaps.
@SubscribeEvent
public void onAttachCaps(AttachCapabilitiesEvent<TileEntity> event) {
if (event.getObject() instanceof PartGate) {
final PartGate gate = (PartGate) event.getObject();
final IMultipartTile mpartTile = new MultipartTile<>(gate);
event.addCapability(LOC, new ICapabilityProvider() {
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == MCMPCapabilities.MULTIPART_TILE;
}
@Nullable
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
return capability == MCMPCapabilities.MULTIPART_TILE ? MCMPCapabilities.MULTIPART_TILE.cast(mpartTile) : null;
}
});
}
}
Aggregations